diff options
author | Joseph Eagar <joeedh@gmail.com> | 2009-08-26 14:27:04 +0400 |
---|---|---|
committer | Joseph Eagar <joeedh@gmail.com> | 2009-08-26 14:27:04 +0400 |
commit | de7f08cc41c7087ecde096c89ee58f43ccb1cf91 (patch) | |
tree | 401ab2a2a7429c2caa63c3135341958155a86935 /source/blender | |
parent | a34ffefa0025d144826cd1bf7a136af743847f1b (diff) | |
parent | d893b0f9ff5fc21277b9c24568e224961537c23c (diff) |
merge with 2.5 at r22793
Diffstat (limited to 'source/blender')
434 files changed, 22546 insertions, 14877 deletions
diff --git a/source/blender/blenfont/BLF_api.h b/source/blender/blenfont/BLF_api.h index c1b14a14f8c..760b7059bc7 100644 --- a/source/blender/blenfont/BLF_api.h +++ b/source/blender/blenfont/BLF_api.h @@ -70,6 +70,11 @@ void BLF_boundbox(char *str, struct rctf *box); float BLF_width(char *str); float BLF_height(char *str); +/* + * The following function return the width and height of the string, but + * just in one call, so avoid extra freetype2 stuff. + */ +void BLF_width_and_height(char *str, float *width, float *height); /* * For fixed width fonts only, returns the width of a @@ -117,6 +122,28 @@ void BLF_shadow(int level, float r, float g, float b, float a); void BLF_shadow_offset(int x, int y); /* + * Set the buffer, size and number of channels to draw, one thing to take care is call + * this function with NULL pointer when we finish, for example: + * BLF_buffer(my_fbuf, my_cbuf, 100, 100, 4); + * + * ... set color, position and draw ... + * + * BLF_buffer(NULL, NULL, 0, 0, 0); + */ +void BLF_buffer(float *fbuf, unsigned char *cbuf, unsigned int w, unsigned int h, int nch); + +/* + * Set the color to be used for text. + */ +void BLF_buffer_col(float r, float g, float b, float a); + +/* + * Draw the string into the buffer, this function draw in both buffer, float and unsigned char _BUT_ + * it's not necessary set both buffer, NULL is valid here. + */ +void BLF_draw_buffer(char *str); + +/* * Search the path directory to the locale files, this try all * the case for Linux, Win and Mac. */ @@ -140,17 +167,10 @@ char **BLF_dir_get(int *ndir); /* Free the data return by BLF_dir_get. */ void BLF_dir_free(char **dirs, int count); -/* Set the current draw mode. */ -void BLF_mode(int mode); - /* font->flags. */ #define BLF_ROTATION (1<<0) #define BLF_CLIPPING (1<<1) #define BLF_SHADOW (1<<2) #define BLF_KERNING_DEFAULT (1<<3) -/* font->mode. */ -#define BLF_MODE_TEXTURE 0 -#define BLF_MODE_BITMAP 1 - #endif /* BLF_API_H */ diff --git a/source/blender/blenfont/CMakeLists.txt b/source/blender/blenfont/CMakeLists.txt index aef655ca0d1..bc03e69eb88 100644 --- a/source/blender/blenfont/CMakeLists.txt +++ b/source/blender/blenfont/CMakeLists.txt @@ -27,11 +27,13 @@ FILE(GLOB SRC intern/*.c) SET(INC ../../../intern/guardedalloc ../blenlib ../makesdna ../editors/include ../blenkernel ../../../extern/glew/include . - ${FTGL_INC} - ${FREETYPE_INC} - ${GETTEXT_INC} + ${FREETYPE_INCLUDE_DIRS} ) +IF(WITH_INTERNATIONAL) + SET(INC ${INC} ${GETTEXT_INC}) +ENDIF(WITH_INTERNATIONAL) + IF(WIN32) ADD_DEFINITIONS(-D_WIN32 -DUSE_GETTEXT_DLL) ENDIF(WIN32) diff --git a/source/blender/blenfont/intern/blf.c b/source/blender/blenfont/intern/blf.c index af57f822c40..8cb237a19ac 100644 --- a/source/blender/blenfont/intern/blf.c +++ b/source/blender/blenfont/intern/blf.c @@ -333,7 +333,6 @@ void BLF_default_rotation(float angle) } } - void BLF_draw(char *str) { FontBLF *font; @@ -342,40 +341,24 @@ void BLF_draw(char *str) * The pixmap alignment hack is handle * in BLF_position (old ui_rasterpos_safe). */ - font= global_font[global_font_cur]; if (font) { - if (font->mode == BLF_MODE_BITMAP) { - glPushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT); - glPushAttrib(GL_ENABLE_BIT); - glPixelStorei(GL_UNPACK_LSB_FIRST, GL_FALSE); - glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - glDisable(GL_BLEND); - glRasterPos3f(font->pos[0], font->pos[1], font->pos[2]); - - blf_font_draw(font, str); - - glPopAttrib(); - glPopClientAttrib(); - } - else { - glEnable(GL_BLEND); - glEnable(GL_TEXTURE_2D); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_BLEND); + glEnable(GL_TEXTURE_2D); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glPushMatrix(); - glTranslatef(font->pos[0], font->pos[1], font->pos[2]); - glScalef(font->aspect, font->aspect, 1.0); + glPushMatrix(); + glTranslatef(font->pos[0], font->pos[1], font->pos[2]); + glScalef(font->aspect, font->aspect, 1.0); - if (font->flags & BLF_ROTATION) - glRotatef(font->angle, 0.0f, 0.0f, 1.0f); + if (font->flags & BLF_ROTATION) + glRotatef(font->angle, 0.0f, 0.0f, 1.0f); - blf_font_draw(font, str); + blf_font_draw(font, str); - glPopMatrix(); - glDisable(GL_BLEND); - glDisable(GL_TEXTURE_2D); - } + glPopMatrix(); + glDisable(GL_BLEND); + glDisable(GL_TEXTURE_2D); } } @@ -388,6 +371,15 @@ void BLF_boundbox(char *str, rctf *box) blf_font_boundbox(font, str, box); } +void BLF_width_and_height(char *str, float *width, float *height) +{ + FontBLF *font; + + font= global_font[global_font_cur]; + if (font) + blf_font_width_and_height(font, str, width, height); +} + float BLF_width(char *str) { FontBLF *font; @@ -506,15 +498,6 @@ void BLF_clipping(float xmin, float ymin, float xmax, float ymax) } } -void BLF_mode(int mode) -{ - FontBLF *font; - - font= global_font[global_font_cur]; - if (font) - font->mode= mode; -} - void BLF_shadow(int level, float r, float g, float b, float a) { FontBLF *font; @@ -539,3 +522,39 @@ void BLF_shadow_offset(int x, int y) font->shadow_y= y; } } + +void BLF_buffer(float *fbuf, unsigned char *cbuf, unsigned int w, unsigned int h, int nch) +{ + FontBLF *font; + + font= global_font[global_font_cur]; + if (font) { + font->b_fbuf= fbuf; + font->b_cbuf= cbuf; + font->bw= w; + font->bh= h; + font->bch= nch; + } +} + +void BLF_buffer_col(float r, float g, float b, float a) +{ + FontBLF *font; + + font= global_font[global_font_cur]; + if (font) { + font->b_col[0]= r; + font->b_col[1]= g; + font->b_col[2]= b; + font->b_col[3]= a; + } +} + +void BLF_draw_buffer(char *str) +{ + FontBLF *font; + + font= global_font[global_font_cur]; + if (font) + blf_font_buffer(font, str); +} diff --git a/source/blender/blenfont/intern/blf_dir.c b/source/blender/blenfont/intern/blf_dir.c index 92dfe8457b0..b4d902ff428 100644 --- a/source/blender/blenfont/intern/blf_dir.c +++ b/source/blender/blenfont/intern/blf_dir.c @@ -153,7 +153,8 @@ char *blf_dir_search(char *file) int blf_dir_split(const char *str, char *file, int *size) { - char *s, i, len; + int i, len; + char *s; /* Window, Linux or Mac, this is always / */ s= strrchr(str, '/'); diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index 6fc35a96e1e..2cd72809579 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -100,7 +100,7 @@ void blf_font_draw(FontBLF *font, char *str) unsigned int c; GlyphBLF *g, *g_prev; FT_Vector delta; - FT_UInt glyph_index, g_prev_index; + FT_UInt glyph_index; int pen_x, pen_y; int i, has_kerning, st; @@ -112,41 +112,30 @@ void blf_font_draw(FontBLF *font, char *str) pen_y= 0; has_kerning= FT_HAS_KERNING(font->face); g_prev= NULL; - g_prev_index= 0; while (str[i]) { c= blf_utf8_next((unsigned char *)str, &i); if (c == 0) break; - glyph_index= FT_Get_Char_Index(font->face, c); g= blf_glyph_search(font->glyph_cache, c); - if (!g) + if (!g) { + glyph_index= FT_Get_Char_Index(font->face, c); g= blf_glyph_add(font, glyph_index, c); + } /* if we don't found a glyph, skip it. */ if (!g) continue; - /* - * This happen if we change the mode of the - * font, we don't drop the glyph cache, so it's - * possible that some glyph don't have the - * bitmap or texture information. - */ - if (font->mode == BLF_MODE_BITMAP && (!g->bitmap_data)) - g= blf_glyph_add(font, glyph_index, c); - else if (font->mode == BLF_MODE_TEXTURE && (!g->tex_data)) - g= blf_glyph_add(font, glyph_index, c); - if (has_kerning && g_prev) { delta.x= 0; delta.y= 0; if (font->flags & BLF_KERNING_DEFAULT) - st= FT_Get_Kerning(font->face, g_prev_index, glyph_index, ft_kerning_default, &delta); + st= FT_Get_Kerning(font->face, g_prev->idx, g->idx, ft_kerning_default, &delta); else - st= FT_Get_Kerning(font->face, g_prev_index, glyph_index, FT_KERNING_UNFITTED, &delta); + st= FT_Get_Kerning(font->face, g_prev->idx, g->idx, FT_KERNING_UNFITTED, &delta); if (st == 0) pen_x += delta.x >> 6; @@ -157,7 +146,158 @@ void blf_font_draw(FontBLF *font, char *str) pen_x += g->advance; g_prev= g; - g_prev_index= glyph_index; + } +} + +void blf_font_buffer(FontBLF *font, char *str) +{ + unsigned char *data, *cbuf; + unsigned int c; + GlyphBLF *g, *g_prev; + FT_Vector delta; + FT_UInt glyph_index; + float a, *fbuf; + int pen_x, pen_y, y, x, yb, diff; + int i, has_kerning, st, chx, chy; + + if (!font->glyph_cache) + return; + + i= 0; + pen_x= (int)font->pos[0]; + pen_y= (int)font->pos[1]; + has_kerning= FT_HAS_KERNING(font->face); + g_prev= NULL; + + while (str[i]) { + c= blf_utf8_next((unsigned char *)str, &i); + if (c == 0) + break; + + g= blf_glyph_search(font->glyph_cache, c); + if (!g) { + glyph_index= FT_Get_Char_Index(font->face, c); + g= blf_glyph_add(font, glyph_index, c); + } + + /* if we don't found a glyph, skip it. */ + if (!g) + continue; + + if (has_kerning && g_prev) { + delta.x= 0; + delta.y= 0; + + if (font->flags & BLF_KERNING_DEFAULT) + st= FT_Get_Kerning(font->face, g_prev->idx, g->idx, ft_kerning_default, &delta); + else + st= FT_Get_Kerning(font->face, g_prev->idx, g->idx, FT_KERNING_UNFITTED, &delta); + + if (st == 0) + pen_x += delta.x >> 6; + } + + chx= pen_x + ((int)g->pos_x); + diff= g->height - ((int)g->pos_y); + if (diff > 0) { + if (g->pitch < 0) + pen_y += diff; + else + pen_y -= diff; + } + else if (diff < 0) { + if (g->pitch < 0) + pen_y -= diff; + else + pen_y += diff; + } + + if (g->pitch < 0) + chy= pen_y - ((int)g->pos_y); + else + chy= pen_y + ((int)g->pos_y); + + if (font->b_fbuf) { + if (chx >= 0 && chx < font->bw && pen_y >= 0 && pen_y < font->bh) { + if (g->pitch < 0) + yb= 0; + else + yb= g->height-1; + + for (y= 0; y < g->height; y++) { + for (x= 0; x < g->width; x++) { + fbuf= font->b_fbuf + font->bch * ((chx + x) + ((pen_y + y)*font->bw)); + data= g->bitmap + x + (yb * g->pitch); + a= data[0]/255.0f; + + if (a == 1.0) { + fbuf[0]= font->b_col[0]; + fbuf[1]= font->b_col[1]; + fbuf[2]= font->b_col[2]; + } + else { + fbuf[0]= (font->b_col[0]*a) + (fbuf[0] * (1-a)); + fbuf[1]= (font->b_col[1]*a) + (fbuf[1] * (1-a)); + fbuf[2]= (font->b_col[2]*a) + (fbuf[2] * (1-a)); + } + } + + if (g->pitch < 0) + yb++; + else + yb--; + } + } + } + + if (font->b_cbuf) { + if (chx >= 0 && chx < font->bw && pen_y >= 0 && pen_y < font->bh) { + if (g->pitch < 0) + yb= 0; + else + yb= g->height-1; + + for (y= 0; y < g->height; y++) { + for (x= 0; x < g->width; x++) { + cbuf= font->b_cbuf + font->bch * ((chx + x) + ((pen_y + y)*font->bw)); + data= g->bitmap + x + (yb * g->pitch); + a= data[0]; + + if (a == 256) { + cbuf[0]= font->b_col[0]; + cbuf[1]= font->b_col[1]; + cbuf[2]= font->b_col[2]; + } + else { + cbuf[0]= (font->b_col[0]*a) + (cbuf[0] * (256-a)); + cbuf[1]= (font->b_col[1]*a) + (cbuf[1] * (256-a)); + cbuf[2]= (font->b_col[2]*a) + (cbuf[2] * (256-a)); + } + } + + if (g->pitch < 0) + yb++; + else + yb--; + } + } + } + + if (diff > 0) { + if (g->pitch < 0) + pen_x -= diff; + else + pen_y += diff; + } + else if (diff < 0) { + if (g->pitch < 0) + pen_x += diff; + else + pen_y -= diff; + } + + pen_x += g->advance; + g_prev= g; } } @@ -166,7 +306,7 @@ void blf_font_boundbox(FontBLF *font, char *str, rctf *box) unsigned int c; GlyphBLF *g, *g_prev; FT_Vector delta; - FT_UInt glyph_index, g_prev_index; + FT_UInt glyph_index; rctf gbox; int pen_x, pen_y; int i, has_kerning, st; @@ -184,41 +324,30 @@ void blf_font_boundbox(FontBLF *font, char *str, rctf *box) pen_y= 0; has_kerning= FT_HAS_KERNING(font->face); g_prev= NULL; - g_prev_index= 0; while (str[i]) { c= blf_utf8_next((unsigned char *)str, &i); if (c == 0) break; - glyph_index= FT_Get_Char_Index(font->face, c); g= blf_glyph_search(font->glyph_cache, c); - if (!g) + if (!g) { + glyph_index= FT_Get_Char_Index(font->face, c); g= blf_glyph_add(font, glyph_index, c); + } /* if we don't found a glyph, skip it. */ if (!g) continue; - /* - * This happen if we change the mode of the - * font, we don't drop the glyph cache, so it's - * possible that some glyph don't have the - * bitmap or texture information. - */ - if (font->mode == BLF_MODE_BITMAP && (!g->bitmap_data)) - g= blf_glyph_add(font, glyph_index, c); - else if (font->mode == BLF_MODE_TEXTURE && (!g->tex_data)) - g= blf_glyph_add(font, glyph_index, c); - if (has_kerning && g_prev) { delta.x= 0; delta.y= 0; if (font->flags & BLF_KERNING_DEFAULT) - st= FT_Get_Kerning(font->face, g_prev_index, glyph_index, ft_kerning_default, &delta); + st= FT_Get_Kerning(font->face, g_prev->idx, g->idx, ft_kerning_default, &delta); else - st= FT_Get_Kerning(font->face, g_prev_index, glyph_index, FT_KERNING_UNFITTED, &delta); + st= FT_Get_Kerning(font->face, g_prev->idx, g->idx, FT_KERNING_UNFITTED, &delta); if (st == 0) pen_x += delta.x >> 6; @@ -241,7 +370,6 @@ void blf_font_boundbox(FontBLF *font, char *str, rctf *box) pen_x += g->advance; g_prev= g; - g_prev_index= glyph_index; } if (box->xmin > box->xmax) { @@ -252,6 +380,17 @@ void blf_font_boundbox(FontBLF *font, char *str, rctf *box) } } +void blf_font_width_and_height(FontBLF *font, char *str, float *width, float *height) +{ + rctf box; + + if (font->glyph_cache) { + blf_font_boundbox(font, str, &box); + *width= ((box.xmax - box.xmin) * font->aspect); + *height= ((box.ymax - box.ymin) * font->aspect); + } +} + float blf_font_width(FontBLF *font, char *str) { rctf box; @@ -316,7 +455,6 @@ void blf_font_free(FontBLF *font) void blf_font_fill(FontBLF *font) { - font->mode= BLF_MODE_TEXTURE; font->aspect= 1.0f; font->pos[0]= 0.0f; font->pos[1]= 0.0f; @@ -333,7 +471,16 @@ void blf_font_fill(FontBLF *font) font->cache.last= NULL; font->glyph_cache= NULL; font->blur= 0; - glGetIntegerv(GL_MAX_TEXTURE_SIZE, (GLint *)&font->max_tex_size); + font->max_tex_size= -1; + font->b_fbuf= NULL; + font->b_cbuf= NULL; + font->bw= 0; + font->bh= 0; + font->bch= 0; + font->b_col[0]= 0; + font->b_col[1]= 0; + font->b_col[2]= 0; + font->b_col[3]= 0; } FontBLF *blf_font_new(char *name, char *filename) diff --git a/source/blender/blenfont/intern/blf_glyph.c b/source/blender/blenfont/intern/blf_glyph.c index 805da02ba36..f3db3ddc9a5 100644 --- a/source/blender/blenfont/intern/blf_glyph.c +++ b/source/blender/blenfont/intern/blf_glyph.c @@ -189,29 +189,18 @@ GlyphBLF *blf_glyph_search(GlyphCacheBLF *gc, unsigned int c) return(NULL); } -GlyphBLF *blf_glyph_texture_add(FontBLF *font, FT_UInt index, unsigned int c) +GlyphBLF *blf_glyph_add(FontBLF *font, FT_UInt index, unsigned int c) { FT_GlyphSlot slot; - GlyphCacheBLF *gc; GlyphBLF *g; - GlyphTextureBLF *gt; FT_Error err; FT_Bitmap bitmap; FT_BBox bbox; unsigned int key; - int do_new; g= blf_glyph_search(font->glyph_cache, c); - - /* The glyph can be add on Bitmap mode, so we have the - * glyph, but not the texture data. - */ - if (g && g->tex_data) + if (g) return(g); - else if (g) - do_new= 0; - else - do_new= 1; err= FT_Load_Glyph(font->face, index, FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP); if (err) @@ -224,56 +213,33 @@ GlyphBLF *blf_glyph_texture_add(FontBLF *font, FT_UInt index, unsigned int c) if (err || slot->format != FT_GLYPH_FORMAT_BITMAP) return(NULL); - if (do_new) { - g= (GlyphBLF *)MEM_mallocN(sizeof(GlyphBLF), "blf_glyph_add"); - g->next= NULL; - g->prev= NULL; - g->tex_data= NULL; - g->bitmap_data= NULL; - g->c= c; - } - - gt= (GlyphTextureBLF *)MEM_mallocN(sizeof(GlyphTextureBLF), "blf_glyph_texture_add"); - gc= font->glyph_cache; - - if (gc->cur_tex == -1) { - blf_glyph_cache_texture(font, gc); - gc->x_offs= gc->pad; - gc->y_offs= gc->pad; - } - - if (gc->x_offs > (gc->p2_width - gc->max_glyph_width)) { - gc->x_offs= gc->pad; - gc->y_offs += gc->max_glyph_height; - - if (gc->y_offs > (gc->p2_height - gc->max_glyph_height)) { - gc->y_offs= gc->pad; - blf_glyph_cache_texture(font, gc); - } - } - + g= (GlyphBLF *)MEM_mallocN(sizeof(GlyphBLF), "blf_glyph_add"); + g->next= NULL; + g->prev= NULL; + g->c= c; + g->idx= index; + g->tex= 0; + g->build_tex= 0; + g->bitmap= NULL; + g->xoff= -1; + g->yoff= -1; + g->uv[0][0]= 0.0f; + g->uv[0][1]= 0.0f; + g->uv[1][0]= 0.0f; + g->uv[1][1]= 0.0f; bitmap= slot->bitmap; - gt->tex= gc->textures[gc->cur_tex]; - - gt->xoff= gc->x_offs; - gt->yoff= gc->y_offs; - gt->width= bitmap.width; - gt->height= bitmap.rows; + g->width= bitmap.width; + g->height= bitmap.rows; - if (gt->width && gt->height) { - glPushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT); - glPixelStorei(GL_UNPACK_LSB_FIRST, GL_FALSE); - glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); - glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - - glBindTexture(GL_TEXTURE_2D, gt->tex); - glTexSubImage2D(GL_TEXTURE_2D, 0, gt->xoff, gt->yoff, gt->width, gt->height, GL_ALPHA, GL_UNSIGNED_BYTE, bitmap.buffer); - glPopClientAttrib(); + if (g->width && g->height) { + g->bitmap= (unsigned char *)MEM_mallocN(g->width * g->height, "glyph bitmap"); + memcpy((void *)g->bitmap, (void *)bitmap.buffer, g->width * g->height); } g->advance= ((float)slot->advance.x) / 64.0f; - gt->pos_x= slot->bitmap_left; - gt->pos_y= slot->bitmap_top; + g->pos_x= slot->bitmap_left; + g->pos_y= slot->bitmap_top; + g->pitch= slot->bitmap.pitch; FT_Outline_Get_CBox(&(slot->outline), &bbox); g->box.xmin= ((float)bbox.xMin) / 64.0f; @@ -281,143 +247,18 @@ GlyphBLF *blf_glyph_texture_add(FontBLF *font, FT_UInt index, unsigned int c) g->box.ymin= ((float)bbox.yMin) / 64.0f; g->box.ymax= ((float)bbox.yMax) / 64.0f; - gt->uv[0][0]= ((float)gt->xoff) / ((float)gc->p2_width); - gt->uv[0][1]= ((float)gt->yoff) / ((float)gc->p2_height); - gt->uv[1][0]= ((float)(gt->xoff + gt->width)) / ((float)gc->p2_width); - gt->uv[1][1]= ((float)(gt->yoff + gt->height)) / ((float)gc->p2_height); - - /* update the x offset for the next glyph. */ - gc->x_offs += (int)(g->box.xmax - g->box.xmin + gc->pad); - - if (do_new) { - key= blf_hash(g->c); - BLI_addhead(&(gc->bucket[key]), g); - gc->rem_glyphs--; - } - - /* and attach the texture information. */ - g->tex_data= gt; - + key= blf_hash(g->c); + BLI_addhead(&(font->glyph_cache->bucket[key]), g); return(g); } -GlyphBLF *blf_glyph_bitmap_add(FontBLF *font, FT_UInt index, unsigned int c) -{ - FT_GlyphSlot slot; - GlyphCacheBLF *gc; - GlyphBLF *g; - GlyphBitmapBLF *gt; - FT_Error err; - FT_Bitmap bitmap; - FT_BBox bbox; - unsigned char *dest, *src; - unsigned int key, y; - unsigned int src_width, src_height, src_pitch; - int do_new; - - g= blf_glyph_search(font->glyph_cache, c); - - /* - * The glyph can be add on Texture mode, so we have the - * glyph, but not the bitmap data. - */ - if (g && g->bitmap_data) - return(g); - else if (g) - do_new= 0; - else - do_new= 1; - - err= FT_Load_Glyph(font->face, index, FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP); - if (err) - return(NULL); - - /* get the glyph. */ - slot= font->face->glyph; - - err= FT_Render_Glyph(slot, FT_RENDER_MODE_MONO); - if (err || slot->format != FT_GLYPH_FORMAT_BITMAP) - return(NULL); - - if (do_new) { - g= (GlyphBLF *)MEM_mallocN(sizeof(GlyphBLF), "blf_glyph_add"); - g->next= NULL; - g->prev= NULL; - g->tex_data= NULL; - g->bitmap_data= NULL; - g->c= c; - } - - gt= (GlyphBitmapBLF *)MEM_mallocN(sizeof(GlyphBitmapBLF), "blf_glyph_bitmap_add"); - gc= font->glyph_cache; - - bitmap= slot->bitmap; - - src_width= bitmap.width; - src_height= bitmap.rows; - src_pitch= bitmap.pitch; - - gt->width= src_width; - gt->height= src_height; - gt->pitch= src_pitch; - gt->image= NULL; - - if (gt->width && gt->height) { - gt->image= (unsigned char *)malloc(gt->pitch * gt->height); - - dest= gt->image + ((gt->height - 1) * gt->pitch); - src= bitmap.buffer; - - for (y= 0; y < src_height; ++y) { - memcpy((void *)dest, (void *)src, src_pitch); - dest -= gt->pitch; - src += src_pitch; - } - } - - g->advance= ((float)slot->advance.x) / 64.0f; - gt->pos_x= slot->bitmap_left; - gt->pos_y= ((int)src_height) - slot->bitmap_top; - - FT_Outline_Get_CBox(&(slot->outline), &bbox); - g->box.xmin= ((float)bbox.xMin) / 64.0f; - g->box.xmax= ((float)bbox.xMax) / 64.0f; - g->box.ymin= ((float)bbox.yMin) / 64.0f; - g->box.ymax= ((float)bbox.yMax) / 64.0f; - - if (do_new) { - key= blf_hash(g->c); - BLI_addhead(&(gc->bucket[key]), g); - gc->rem_glyphs--; - } - - /* and attach the bitmap information. */ - g->bitmap_data= gt; - - return(g); -} - -GlyphBLF *blf_glyph_add(FontBLF *font, FT_UInt index, unsigned int c) -{ - if (font->mode == BLF_MODE_BITMAP) - return(blf_glyph_bitmap_add(font, index, c)); - return(blf_glyph_texture_add(font, index, c)); -} - void blf_glyph_free(GlyphBLF *g) { - if (g->tex_data) - MEM_freeN(g->tex_data); - - if (g->bitmap_data) { - if (g->bitmap_data->image) - free((void *)g->bitmap_data->image); - MEM_freeN(g->bitmap_data); - } - /* don't need free the texture, the GlyphCache already * have a list of all the texture and free it. */ + if (g->bitmap) + MEM_freeN(g->bitmap); MEM_freeN(g); } @@ -482,16 +323,65 @@ static void blf_texture3_draw(float uv[2][2], float x1, float y1, float x2, floa glColor4fv(color); } -int blf_glyph_texture_render(FontBLF *font, GlyphBLF *g, float x, float y) +int blf_glyph_render(FontBLF *font, GlyphBLF *g, float x, float y) { - GlyphTextureBLF *gt; + GlyphCacheBLF *gc; GLint cur_tex; float dx, dx1; float y1, y2; float xo, yo; float color[4]; - gt= g->tex_data; + if ((!g->width) || (!g->height)) + return(1); + + if (g->build_tex == 0) { + gc= font->glyph_cache; + + if (font->max_tex_size == -1) + glGetIntegerv(GL_MAX_TEXTURE_SIZE, (GLint *)&font->max_tex_size); + + if (gc->cur_tex == -1) { + blf_glyph_cache_texture(font, gc); + gc->x_offs= gc->pad; + gc->y_offs= gc->pad; + } + + if (gc->x_offs > (gc->p2_width - gc->max_glyph_width)) { + gc->x_offs= gc->pad; + gc->y_offs += gc->max_glyph_height; + + if (gc->y_offs > (gc->p2_height - gc->max_glyph_height)) { + gc->y_offs= gc->pad; + blf_glyph_cache_texture(font, gc); + } + } + + g->tex= gc->textures[gc->cur_tex]; + g->xoff= gc->x_offs; + g->yoff= gc->y_offs; + + glPushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT); + glPixelStorei(GL_UNPACK_LSB_FIRST, GL_FALSE); + glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + + glBindTexture(GL_TEXTURE_2D, g->tex); + glTexSubImage2D(GL_TEXTURE_2D, 0, g->xoff, g->yoff, g->width, g->height, GL_ALPHA, GL_UNSIGNED_BYTE, g->bitmap); + glPopClientAttrib(); + + g->uv[0][0]= ((float)g->xoff) / ((float)gc->p2_width); + g->uv[0][1]= ((float)g->yoff) / ((float)gc->p2_height); + g->uv[1][0]= ((float)(g->xoff + g->width)) / ((float)gc->p2_width); + g->uv[1][1]= ((float)(g->yoff + g->height)) / ((float)gc->p2_height); + + /* update the x offset for the next glyph. */ + gc->x_offs += (int)(g->box.xmax - g->box.xmin + gc->pad); + + gc->rem_glyphs--; + g->build_tex= 1; + } + xo= 0.0f; yo= 0.0f; @@ -502,10 +392,10 @@ int blf_glyph_texture_render(FontBLF *font, GlyphBLF *g, float x, float y) y += font->shadow_y; } - dx= floor(x + gt->pos_x); - dx1= dx + gt->width; - y1= y + gt->pos_y; - y2= y + gt->pos_y - gt->height; + dx= floor(x + g->pos_x); + dx1= dx + g->width; + y1= y + g->pos_y; + y2= y + g->pos_y - g->height; if (font->flags & BLF_CLIPPING) { if (!BLI_in_rctf(&font->clip_rec, dx + font->pos[0], y1 + font->pos[1])) @@ -519,70 +409,36 @@ int blf_glyph_texture_render(FontBLF *font, GlyphBLF *g, float x, float y) } glGetIntegerv(GL_TEXTURE_2D_BINDING_EXT, &cur_tex); - if (cur_tex != gt->tex) - glBindTexture(GL_TEXTURE_2D, gt->tex); + if (cur_tex != g->tex) + glBindTexture(GL_TEXTURE_2D, g->tex); if (font->flags & BLF_SHADOW) { glGetFloatv(GL_CURRENT_COLOR, color); glColor4fv(font->shadow_col); if (font->shadow == 3) - blf_texture3_draw(gt->uv, dx, y1, dx1, y2); + blf_texture3_draw(g->uv, dx, y1, dx1, y2); else if (font->shadow == 5) - blf_texture5_draw(gt->uv, dx, y1, dx1, y2); + blf_texture5_draw(g->uv, dx, y1, dx1, y2); else - blf_texture_draw(gt->uv, dx, y1, dx1, y2); + blf_texture_draw(g->uv, dx, y1, dx1, y2); glColor4fv(color); x= xo; y= yo; - dx= floor(x + gt->pos_x); - dx1= dx + gt->width; - y1= y + gt->pos_y; - y2= y + gt->pos_y - gt->height; + dx= floor(x + g->pos_x); + dx1= dx + g->width; + y1= y + g->pos_y; + y2= y + g->pos_y - g->height; } if (font->blur==3) - blf_texture3_draw(gt->uv, dx, y1, dx1, y2); + blf_texture3_draw(g->uv, dx, y1, dx1, y2); else if (font->blur==5) - blf_texture5_draw(gt->uv, dx, y1, dx1, y2); + blf_texture5_draw(g->uv, dx, y1, dx1, y2); else - blf_texture_draw(gt->uv, dx, y1, dx1, y2); - - return(1); -} - -int blf_glyph_bitmap_render(FontBLF *font, GlyphBLF *g, float x, float y) -{ - GlyphBitmapBLF *gt; - GLubyte null_bitmap= 0; - - gt= g->bitmap_data; - if (!gt->image) - return(1); - - if (font->flags & BLF_CLIPPING) { - if (!BLI_in_rctf(&font->clip_rec, x + font->pos[0], y + font->pos[1])) - return(0); - if (!BLI_in_rctf(&font->clip_rec, x + font->pos[0], y + gt->height + font->pos[1])) - return(0); - if (!BLI_in_rctf(&font->clip_rec, x + gt->width + font->pos[0], y + gt->height + font->pos[1])) - return(0); - if (!BLI_in_rctf(&font->clip_rec, x + gt->width + font->pos[0], y + font->pos[1])) - return(0); - } + blf_texture_draw(g->uv, dx, y1, dx1, y2); - glBitmap(0, 0, 0.0, 0.0, x + gt->pos_x, y, (const GLubyte *)&null_bitmap); - glPixelStorei(GL_UNPACK_ROW_LENGTH, gt->pitch * 8); - glBitmap(gt->width, gt->height, 0.0, gt->pos_y, 0.0, 0.0, (const GLubyte *)gt->image); - glBitmap(0, 0, 0.0, 0.0, -x - gt->pos_x, -y, (const GLubyte *)&null_bitmap); return(1); } - -int blf_glyph_render(FontBLF *font, GlyphBLF *g, float x, float y) -{ - if (font->mode == BLF_MODE_BITMAP) - return(blf_glyph_bitmap_render(font, g, x, y)); - return(blf_glyph_texture_render(font, g, x, y)); -} diff --git a/source/blender/blenfont/intern/blf_internal.h b/source/blender/blenfont/intern/blf_internal.h index 30d5c8ede65..2a69b8652ea 100644 --- a/source/blender/blenfont/intern/blf_internal.h +++ b/source/blender/blenfont/intern/blf_internal.h @@ -45,7 +45,9 @@ void blf_font_attach_from_mem(FontBLF *font, const unsigned char *mem, int mem_s void blf_font_size(FontBLF *font, int size, int dpi); void blf_font_draw(FontBLF *font, char *str); +void blf_font_buffer(FontBLF *font, char *str); void blf_font_boundbox(FontBLF *font, char *str, rctf *box); +void blf_font_width_and_height(FontBLF *font, char *str, float *width, float *height); float blf_font_width(FontBLF *font, char *str); float blf_font_height(FontBLF *font, char *str); float blf_font_fixed_width(FontBLF *font); diff --git a/source/blender/blenfont/intern/blf_internal_types.h b/source/blender/blenfont/intern/blf_internal_types.h index 64d95986867..fb4a2e6a9e5 100644 --- a/source/blender/blenfont/intern/blf_internal_types.h +++ b/source/blender/blenfont/intern/blf_internal_types.h @@ -78,7 +78,22 @@ typedef struct GlyphCacheBLF { float descender; } GlyphCacheBLF; -typedef struct GlyphTextureBLF { +typedef struct GlyphBLF { + struct GlyphBLF *next; + struct GlyphBLF *prev; + + /* and the character, as UTF8 */ + unsigned int c; + + /* freetype2 index, to speed-up the search. */ + FT_UInt idx; + + /* glyph box. */ + rctf box; + + /* advance size. */ + float advance; + /* texture id where this glyph is store. */ GLuint tex; @@ -86,9 +101,15 @@ typedef struct GlyphTextureBLF { int xoff; int yoff; + /* Bitmap data, from freetype. Take care that this + * can be NULL. + */ + unsigned char *bitmap; + /* glyph width and height. */ int width; int height; + int pitch; /* uv coords. */ float uv[2][2]; @@ -99,38 +120,9 @@ typedef struct GlyphTextureBLF { */ float pos_x; float pos_y; -} GlyphTextureBLF; - -typedef struct GlyphBitmapBLF { - /* image data. */ - unsigned char *image; - int width; - int height; - int pitch; - - float pos_x; - float pos_y; -} GlyphBitmapBLF; - -typedef struct GlyphBLF { - struct GlyphBLF *next; - struct GlyphBLF *prev; - - /* and the character, as UTF8 */ - unsigned int c; - - /* glyph box. */ - rctf box; - - /* advance size. */ - float advance; - - /* texture information. */ - GlyphTextureBLF *tex_data; - - /* bitmap information. */ - GlyphBitmapBLF *bitmap_data; + /* with value of zero mean that we need build the texture. */ + short build_tex; } GlyphBLF; typedef struct FontBLF { @@ -140,9 +132,6 @@ typedef struct FontBLF { /* filename or NULL. */ char *filename; - /* draw mode, texture or bitmap. */ - int mode; - /* aspect ratio or scale. */ float aspect; @@ -191,6 +180,22 @@ typedef struct FontBLF { /* freetype2 face. */ FT_Face face; + + /* for draw to buffer, always set this to NULL after finish! */ + float *b_fbuf; + + /* the same but unsigned char */ + unsigned char *b_cbuf; + + /* buffer size. */ + unsigned int bw; + unsigned int bh; + + /* number of channels. */ + int bch; + + /* and the color, the alphas is get from the glyph! */ + float b_col[4]; } FontBLF; typedef struct DirBLF { diff --git a/source/blender/blenkernel/BKE_action.h b/source/blender/blenkernel/BKE_action.h index d35acb5447a..4724ee19aaa 100644 --- a/source/blender/blenkernel/BKE_action.h +++ b/source/blender/blenkernel/BKE_action.h @@ -66,7 +66,7 @@ void free_action(struct bAction *act); void make_local_action(struct bAction *act); /* Some kind of bounding box operation on the action */ -void calc_action_range(const struct bAction *act, float *start, float *end, int incl_hidden); +void calc_action_range(const struct bAction *act, float *start, float *end, short incl_modifiers); /* Does action have any motion data at all? */ short action_has_motion(const struct bAction *act); diff --git a/source/blender/blenkernel/BKE_animsys.h b/source/blender/blenkernel/BKE_animsys.h index 2447d1823af..cabbaa7aa0f 100644 --- a/source/blender/blenkernel/BKE_animsys.h +++ b/source/blender/blenkernel/BKE_animsys.h @@ -66,6 +66,9 @@ void BKE_keyingset_add_destination(struct KeyingSet *ks, struct ID *id, const ch struct KS_Path *BKE_keyingset_find_destination(struct KeyingSet *ks, struct ID *id, const char group_name[], const char rna_path[], int array_index, int group_mode); +/* Copy all KeyingSets in the given list */ +void BKE_keyingsets_copy(struct ListBase *newlist, struct ListBase *list); + /* Free data for KeyingSet but not set itself */ void BKE_keyingset_free(struct KeyingSet *ks); diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h index 52ea1484d28..0d08886aba6 100644 --- a/source/blender/blenkernel/BKE_blender.h +++ b/source/blender/blenkernel/BKE_blender.h @@ -43,7 +43,7 @@ struct bContext; struct ReportList; #define BLENDER_VERSION 250 -#define BLENDER_SUBVERSION 0 +#define BLENDER_SUBVERSION 2 #define BLENDER_MINVERSION 250 #define BLENDER_MINSUBVERSION 0 diff --git a/source/blender/blenkernel/BKE_brush.h b/source/blender/blenkernel/BKE_brush.h index 9eb0b15aed4..4d24a2433b3 100644 --- a/source/blender/blenkernel/BKE_brush.h +++ b/source/blender/blenkernel/BKE_brush.h @@ -38,16 +38,15 @@ struct Scene; struct wmOperator; /* datablock functions */ -struct Brush *add_brush(char *name); +struct Brush *add_brush(const char *name); struct Brush *copy_brush(struct Brush *brush); void make_local_brush(struct Brush *brush); void free_brush(struct Brush *brush); /* brush library operations used by different paint panels */ -struct Brush **current_brush_source(struct Scene *sce); -int brush_set_nr(struct Brush **current_brush, int nr); +int brush_set_nr(struct Brush **current_brush, int nr, const char *name); int brush_delete(struct Brush **current_brush); -void brush_check_exists(struct Brush **brush); +void brush_check_exists(struct Brush **brush, const char *name); void brush_toggled_fake_user(struct Brush *brush); int brush_texture_set_nr(struct Brush *brush, int nr); int brush_texture_delete(struct Brush *brush); @@ -65,7 +64,6 @@ float brush_curve_strength(struct Brush *br, float p, const float len); /* sampling */ float brush_sample_falloff(struct Brush *brush, float dist); -float brush_sample_falloff_noalpha(struct Brush *brush, float dist); void brush_sample_tex(struct Brush *brush, float *xy, float *rgba); void brush_imbuf_new(struct Brush *brush, short flt, short texfalloff, int size, struct ImBuf **imbuf); diff --git a/source/blender/blenkernel/BKE_cloth.h b/source/blender/blenkernel/BKE_cloth.h index f3165c959bf..bc4585106e6 100644 --- a/source/blender/blenkernel/BKE_cloth.h +++ b/source/blender/blenkernel/BKE_cloth.h @@ -244,10 +244,6 @@ void cloth_update_normals ( ClothVertex *verts, int nVerts, MFace *face, int tot void bvhtree_update_from_cloth ( ClothModifierData *clmd, int moving ); void bvhselftree_update_from_cloth ( ClothModifierData *clmd, int moving ); -// needed for editmesh.c -void cloth_write_cache( Object *ob, ClothModifierData *clmd, int framenr ); -int cloth_read_cache( Scene *scene, Object *ob, ClothModifierData *clmd, float framenr, int *old_framenr ); - // needed for button_object.c void cloth_clear_cache ( Object *ob, ClothModifierData *clmd, float framenr ); diff --git a/source/blender/blenkernel/BKE_context.h b/source/blender/blenkernel/BKE_context.h index e47ad969b91..09e13c2930e 100644 --- a/source/blender/blenkernel/BKE_context.h +++ b/source/blender/blenkernel/BKE_context.h @@ -86,6 +86,25 @@ typedef struct bContextStore { int used; } bContextStore; +/* for the conrtext's rna mode enum + * keep aligned with data_mode_strings in context.c */ +enum { + CTX_MODE_EDIT_MESH = 0, + CTX_MODE_EDIT_CURVE, + CTX_MODE_EDIT_SURFACE, + CTX_MODE_EDIT_TEXT, + CTX_MODE_EDIT_ARMATURE, + CTX_MODE_EDIT_METABALL, + CTX_MODE_EDIT_LATTICE, + CTX_MODE_POSE, + CTX_MODE_SCULPT, + CTX_MODE_PAINT_WEIGHT, + CTX_MODE_PAINT_VERTEX, + CTX_MODE_PAINT_TEXTURE, + CTX_MODE_PARTICLE, + CTX_MODE_OBJECT +}; + /* Context */ bContext *CTX_create(void); @@ -133,6 +152,7 @@ struct SpaceLogic *CTX_wm_space_logic(const bContext *C); struct SpaceIpo *CTX_wm_space_graph(const bContext *C); struct SpaceAction *CTX_wm_space_action(const bContext *C); struct SpaceInfo *CTX_wm_space_info(const bContext *C); +struct SpaceUserPref *CTX_wm_space_userpref(const bContext *C); void CTX_wm_manager_set(bContext *C, struct wmWindowManager *wm); void CTX_wm_window_set(bContext *C, struct wmWindow *win); @@ -191,6 +211,9 @@ struct Main *CTX_data_main(const bContext *C); struct Scene *CTX_data_scene(const bContext *C); struct ToolSettings *CTX_data_tool_settings(const bContext *C); +char *CTX_data_mode_string(const bContext *C); +int CTX_data_mode_enum(const bContext *C); + void CTX_data_main_set(bContext *C, struct Main *bmain); void CTX_data_scene_set(bContext *C, struct Scene *bmain); diff --git a/source/blender/blenkernel/BKE_global.h b/source/blender/blenkernel/BKE_global.h index 4b7ddf43647..6323258ff43 100644 --- a/source/blender/blenkernel/BKE_global.h +++ b/source/blender/blenkernel/BKE_global.h @@ -44,7 +44,6 @@ extern "C" { /* forwards */ struct Main; struct Object; -struct bSoundListener; struct BME_Glob; typedef struct Global { @@ -93,9 +92,6 @@ typedef struct Global { /* save the allowed windowstate of blender when using -W or -w */ int windowstate; - /* Janco's playing ground */ - struct bSoundListener* listener; - /* ndof device found ? */ int ndofdevice; @@ -116,52 +112,40 @@ typedef struct Global { #define G_FACESELECT (1 << 8) -#define G_VERTEXPAINT (1 << 10) - #define G_DEBUG (1 << 12) #define G_DOSCRIPTLINKS (1 << 13) -#define G_WEIGHTPAINT (1 << 15) -#define G_TEXTUREPAINT (1 << 16) /* #define G_NOFROZEN (1 << 17) also removed */ #define G_GREASEPENCIL (1 << 17) -#define G_SCULPTMODE (1 << 29) -#define G_PARTICLEEDIT (1 << 30) - /* #define G_AUTOMATKEYS (1 << 30) also removed */ #define G_HIDDENHANDLES (1 << 31) /* used for curves only */ -/* macro for testing face select mode - * Texture paint could be removed since selected faces are not used - * however hiding faces is useful */ -#define FACESEL_PAINT_TEST ((G.f&G_FACESELECT) && (G.f & (G_VERTEXPAINT|G_WEIGHTPAINT|G_TEXTUREPAINT))) - /* G.fileflags */ #define G_AUTOPACK (1 << 0) #define G_FILE_COMPRESS (1 << 1) #define G_FILE_AUTOPLAY (1 << 2) -#define G_FILE_ENABLE_ALL_FRAMES (1 << 3) -#define G_FILE_SHOW_DEBUG_PROPS (1 << 4) -#define G_FILE_SHOW_FRAMERATE (1 << 5) -#define G_FILE_SHOW_PROFILE (1 << 6) +#define G_FILE_ENABLE_ALL_FRAMES (1 << 3) /* deprecated */ +#define G_FILE_SHOW_DEBUG_PROPS (1 << 4) /* deprecated */ +#define G_FILE_SHOW_FRAMERATE (1 << 5) /* deprecated */ +#define G_FILE_SHOW_PROFILE (1 << 6) /* deprecated */ #define G_FILE_LOCK (1 << 7) #define G_FILE_SIGN (1 << 8) #define G_FIle_PUBLISH (1 << 9) #define G_FILE_NO_UI (1 << 10) -#define G_FILE_GAME_TO_IPO (1 << 11) -#define G_FILE_GAME_MAT (1 << 12) -#define G_FILE_DISPLAY_LISTS (1 << 13) -#define G_FILE_SHOW_PHYSICS (1 << 14) -#define G_FILE_GAME_MAT_GLSL (1 << 15) -#define G_FILE_GLSL_NO_LIGHTS (1 << 16) -#define G_FILE_GLSL_NO_SHADERS (1 << 17) -#define G_FILE_GLSL_NO_SHADOWS (1 << 18) -#define G_FILE_GLSL_NO_RAMPS (1 << 19) -#define G_FILE_GLSL_NO_NODES (1 << 20) -#define G_FILE_GLSL_NO_EXTRA_TEX (1 << 21) -#define G_FILE_IGNORE_DEPRECATION_WARNINGS (1 << 22) +#define G_FILE_GAME_TO_IPO (1 << 11) /* deprecated */ +#define G_FILE_GAME_MAT (1 << 12) /* deprecated */ +#define G_FILE_DISPLAY_LISTS (1 << 13) /* deprecated */ +#define G_FILE_SHOW_PHYSICS (1 << 14) /* deprecated */ +#define G_FILE_GAME_MAT_GLSL (1 << 15) /* deprecated */ +#define G_FILE_GLSL_NO_LIGHTS (1 << 16) /* deprecated */ +#define G_FILE_GLSL_NO_SHADERS (1 << 17) /* deprecated */ +#define G_FILE_GLSL_NO_SHADOWS (1 << 18) /* deprecated */ +#define G_FILE_GLSL_NO_RAMPS (1 << 19) /* deprecated */ +#define G_FILE_GLSL_NO_NODES (1 << 20) /* deprecated */ +#define G_FILE_GLSL_NO_EXTRA_TEX (1 << 21) /* deprecated */ +#define G_FILE_IGNORE_DEPRECATION_WARNINGS (1 << 22) /* deprecated */ /* G.windowstate */ #define G_WINDOWSTATE_USERDEF 0 diff --git a/source/blender/blenkernel/BKE_library.h b/source/blender/blenkernel/BKE_library.h index ce182267b93..4e7db115168 100644 --- a/source/blender/blenkernel/BKE_library.h +++ b/source/blender/blenkernel/BKE_library.h @@ -58,6 +58,7 @@ 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 splitIDname(char *name, char *left, int *nr); void rename_id(struct ID *id, char *name); diff --git a/source/blender/blenkernel/BKE_modifier.h b/source/blender/blenkernel/BKE_modifier.h index 42a4743fd22..b5471758ea6 100644 --- a/source/blender/blenkernel/BKE_modifier.h +++ b/source/blender/blenkernel/BKE_modifier.h @@ -91,7 +91,10 @@ typedef enum { eModifierTypeFlag_UsesPointCache = (1<<6), /* For physics modifiers, max one per type */ - eModifierTypeFlag_Single = (1<<7) + eModifierTypeFlag_Single = (1<<7), + + /* Some modifier can't be added manually by user */ + eModifierTypeFlag_NoUserAdd = (1<<8) } ModifierTypeFlag; typedef void (*ObjectWalkFunc)(void *userData, struct Object *ob, struct Object **obpoin); diff --git a/source/blender/blenkernel/BKE_multires.h b/source/blender/blenkernel/BKE_multires.h index 063f0ee96aa..d20a00cbfff 100644 --- a/source/blender/blenkernel/BKE_multires.h +++ b/source/blender/blenkernel/BKE_multires.h @@ -35,10 +35,12 @@ struct Object; typedef struct MultiresSubsurf { struct MultiresModifierData *mmd; - struct Mesh *me; + struct Object *ob; + int local_mmd; } MultiresSubsurf; /* MultiresDM */ +struct Object *MultiresDM_get_object(struct DerivedMesh *dm); struct Mesh *MultiresDM_get_mesh(struct DerivedMesh *dm); struct DerivedMesh *MultiresDM_new(struct MultiresSubsurf *, struct DerivedMesh*, int, int, int, int, int); @@ -59,8 +61,8 @@ void multires_mark_as_modified(struct Object *ob); void multires_force_update(struct Object *ob); -struct DerivedMesh *multires_dm_create_from_derived(struct MultiresModifierData*, struct DerivedMesh*, - struct Mesh *, int, int); +struct DerivedMesh *multires_dm_create_from_derived(struct MultiresModifierData*, int local_mmd, struct DerivedMesh*, + struct Object *, int, int); struct MultiresModifierData *find_multires_modifier(struct Object *ob); int multiresModifier_switch_level(struct Object *, const int); diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index 87ee8f9cab3..40afa1dba36 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -47,6 +47,7 @@ struct rctf; struct ListBase; struct RenderData; struct Scene; +struct Main; struct Tex; struct GPUMaterial; struct GPUNode; @@ -420,10 +421,9 @@ extern struct ListBase node_all_textures; /* API */ int ntreeTexTagAnimated(struct bNodeTree *ntree); -void ntreeTexUpdatePreviews( struct bNodeTree* nodetree ); -void ntreeTexExecTree(struct bNodeTree *ntree, struct TexResult *target, float *coord, char do_preview, short thread, struct Tex *tex, short which_output, int cfra); +void ntreeTexSetPreviewFlag(int); +void ntreeTexExecTree(struct bNodeTree *ntree, struct TexResult *target, float *coord, float *dxt, float *dyt, short thread, struct Tex *tex, short which_output, int cfra); void ntreeTexCheckCyclics(struct bNodeTree *ntree); -void ntreeTexAssignIndex(struct bNodeTree *ntree, struct bNode *node); char* ntreeTexOutputMenu(struct bNodeTree *ntree); @@ -432,4 +432,8 @@ char* ntreeTexOutputMenu(struct bNodeTree *ntree); void init_nodesystem(void); void free_nodesystem(void); +/**/ + +void clear_scene_in_nodes(struct Main *bmain, struct Scene *sce); + #endif diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h index a57529ccf75..1cb6efeb838 100644 --- a/source/blender/blenkernel/BKE_object.h +++ b/source/blender/blenkernel/BKE_object.h @@ -115,6 +115,11 @@ void object_handle_update(struct Scene *scene, struct Object *ob); float give_timeoffset(struct Object *ob); int give_obdata_texspace(struct Object *ob, int **texflag, float **loc, float **size, float **rot); + +int object_insert_ptcache(struct Object *ob); +// void object_delete_ptcache(struct Object *ob, int index); + + #ifdef __cplusplus } #endif diff --git a/source/blender/blenkernel/BKE_packedFile.h b/source/blender/blenkernel/BKE_packedFile.h index efd930d375a..b6513bede99 100644 --- a/source/blender/blenkernel/BKE_packedFile.h +++ b/source/blender/blenkernel/BKE_packedFile.h @@ -34,7 +34,6 @@ #define RET_OK 0 #define RET_ERROR 1 -struct bSample; struct bSound; struct Image; struct Main; @@ -51,7 +50,7 @@ void packAll(struct Main *bmain, struct ReportList *reports); /* unpack */ char *unpackFile(struct ReportList *reports, char *abs_name, char *local_name, struct PackedFile *pf, int how); int unpackVFont(struct ReportList *reports, struct VFont *vfont, int how); -int unpackSample(struct ReportList *reports, struct bSample *sample, int how); +int unpackSound(struct ReportList *reports, struct bSound *sound, int how); int unpackImage(struct ReportList *reports, struct Image *ima, int how); void unpackAll(struct Main *bmain, struct ReportList *reports, int how); diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h new file mode 100644 index 00000000000..4337d275776 --- /dev/null +++ b/source/blender/blenkernel/BKE_paint.h @@ -0,0 +1,56 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2009 by Nicholas Bishop + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#ifndef BKE_PAINT_H +#define BKE_PAINT_H + +struct Brush; +struct Object; +struct Paint; +struct Scene; + +extern const char PAINT_CURSOR_SCULPT[3]; +extern const char PAINT_CURSOR_VERTEX_PAINT[3]; +extern const char PAINT_CURSOR_WEIGHT_PAINT[3]; +extern const char PAINT_CURSOR_TEXTURE_PAINT[3]; + +void paint_init(struct Paint *p, const char col[3]); +void free_paint(struct Paint *p); +void copy_paint(struct Paint *orig, struct Paint *new); + +struct Paint *paint_get_active(struct Scene *sce); +struct Brush *paint_brush(struct Paint *paint); +void paint_brush_set(struct Paint *paint, struct Brush *br); +void paint_brush_slot_add(struct Paint *p); +void paint_brush_slot_remove(struct Paint *p); + +/* testing face select mode + * Texture paint could be removed since selected faces are not used + * however hiding faces is useful */ +int paint_facesel_test(struct Object *ob); + +#endif diff --git a/source/blender/blenkernel/BKE_pointcache.h b/source/blender/blenkernel/BKE_pointcache.h index 8062f807055..531487549da 100644 --- a/source/blender/blenkernel/BKE_pointcache.h +++ b/source/blender/blenkernel/BKE_pointcache.h @@ -30,6 +30,8 @@ #define BKE_POINTCACHE_H #include "DNA_ID.h" +#include "DNA_object_force.h" +#include "DNA_boid_types.h" #include "MEM_guardedalloc.h" @@ -55,9 +57,11 @@ #define PTCACHE_FILE_WRITE 1 /* PTCacheID types */ -#define PTCACHE_TYPE_SOFTBODY 0 -#define PTCACHE_TYPE_PARTICLES 1 -#define PTCACHE_TYPE_CLOTH 2 +#define PTCACHE_TYPE_SOFTBODY 0 +#define PTCACHE_TYPE_PARTICLES 1 +#define PTCACHE_TYPE_CLOTH 2 +#define PTCACHE_TYPE_SMOKE_DOMAIN 3 +#define PTCACHE_TYPE_SMOKE_HIGHRES 4 /* PTCache read return code */ #define PTCACHE_READ_EXACT 1 @@ -69,46 +73,70 @@ struct Object; struct Scene; struct SoftBody; struct ParticleSystem; +struct ParticleKey; struct ClothModifierData; +struct SmokeModifierData; struct PointCache; struct ListBase; +/* temp structure for read/write */ +typedef struct PTCacheData { + int index; + float loc[3]; + float vel[3]; + float rot[4]; + float ave[3]; + float size; + float times[3]; + struct BoidData boids; +} PTCacheData; + typedef struct PTCacheFile { FILE *fp; + + int totpoint, type; + unsigned int data_types; + + struct PTCacheData data; + void *cur[BPHYS_TOT_DATA]; } PTCacheFile; typedef struct PTCacheID { struct PTCacheID *next, *prev; + struct Scene *scene; struct Object *ob; - void *data; + void *calldata; int type; int stack_index; - struct PointCache *cache; -} PTCacheID; - -typedef struct PTCacheWriter { - struct PTCacheID *pid; - int cfra; - int totelem; + /* flags defined in DNA_object_force.h */ + unsigned int data_types, info_types; - void (*set_elem)(int index, void *calldata, float *data); - void *calldata; -} PTCacheWriter; + /* copies point data to cache data */ + int (*write_elem)(int index, void *calldata, void **data); + /* copies point data to cache data */ + int (*write_stream)(PTCacheFile *pf, void *calldata); + /* copies cache cata to point data */ + void (*read_elem)(int index, void *calldata, void **data, float frs_sec, float cfra, float *old_data); + /* copies cache cata to point data */ + void (*read_stream)(PTCacheFile *pf, void *calldata); + /* interpolated between previously read point data and cache data */ + void (*interpolate_elem)(int index, void *calldata, void **data, float frs_sec, float cfra, float cfra1, float cfra2, float *old_data); -typedef struct PTCacheReader { - struct Scene *scene; - struct PTCacheID *pid; - float cfra; - int totelem; + /* total number of simulated points */ + int (*totpoint)(void *calldata); + /* number of points written for current cache frame (currently not used) */ + int (*totwrite)(void *calldata); - void (*set_elem)(int elem_index, void *calldata, float *data); - void (*interpolate_elem)(int index, void *calldata, float frs_sec, float cfra, float cfra1, float cfra2, float *data1, float *data2); - void *calldata; + int (*write_header)(PTCacheFile *pf); + int (*read_header)(PTCacheFile *pf); - int *old_frame; -} PTCacheReader; + struct PointCache *cache; + /* used for setting the current cache from ptcaches list */ + struct PointCache **cache_ptr; + struct ListBase *ptcaches; +} PTCacheID; typedef struct PTCacheBaker { struct Scene *scene; @@ -123,49 +151,75 @@ typedef struct PTCacheBaker { void *progresscontext; } PTCacheBaker; -/* Creating ID's */ +/* Particle functions */ +void BKE_ptcache_make_particle_key(struct ParticleKey *key, int index, void **data, float time); + +/**************** Creating ID's ****************************/ void BKE_ptcache_id_from_softbody(PTCacheID *pid, struct Object *ob, struct SoftBody *sb); void BKE_ptcache_id_from_particles(PTCacheID *pid, struct Object *ob, struct ParticleSystem *psys); void BKE_ptcache_id_from_cloth(PTCacheID *pid, struct Object *ob, struct ClothModifierData *clmd); +void BKE_ptcache_id_from_smoke(PTCacheID *pid, struct Object *ob, struct SmokeModifierData *smd); void BKE_ptcache_ids_from_object(struct ListBase *lb, struct Object *ob); -/* Global funcs */ +/***************** Global funcs ****************************/ void BKE_ptcache_remove(void); -/* ID specific functions */ +/************ ID specific functions ************************/ void BKE_ptcache_id_clear(PTCacheID *id, int mode, int cfra); int BKE_ptcache_id_exist(PTCacheID *id, int cfra); int BKE_ptcache_id_reset(struct Scene *scene, PTCacheID *id, int mode); void BKE_ptcache_id_time(PTCacheID *pid, struct Scene *scene, float cfra, int *startframe, int *endframe, float *timescale); int BKE_ptcache_object_reset(struct Scene *scene, struct Object *ob, int mode); -/* File reading/writing */ -PTCacheFile *BKE_ptcache_file_open(PTCacheID *id, int mode, int cfra); -void BKE_ptcache_file_close(PTCacheFile *pf); -int BKE_ptcache_file_read_floats(PTCacheFile *pf, float *f, int tot); -int BKE_ptcache_file_write_floats(PTCacheFile *pf, float *f, int tot); - void BKE_ptcache_update_info(PTCacheID *pid); -/* General cache reading/writing */ -int BKE_ptcache_read_cache(PTCacheReader *reader); -int BKE_ptcache_write_cache(PTCacheWriter *writer); +/*********** General cache reading/writing ******************/ + +/* Size of cache data type. */ +int BKE_ptcache_data_size(int data_type); + +/* Copy a specific data type from cache data to point data. */ +void BKE_ptcache_data_get(void **data, int type, int index, void *to); + +/* Copy a specific data type from point data to cache data. */ +void BKE_ptcache_data_set(void **data, int type, void *from); + +/* Main cache reading call. */ +int BKE_ptcache_read_cache(PTCacheID *pid, float cfra, float frs_sec); -/* Continue physics */ +/* Main cache writing call. */ +int BKE_ptcache_write_cache(PTCacheID *pid, int cfra); + +/****************** Continue physics ***************/ void BKE_ptcache_set_continue_physics(struct Scene *scene, int enable); int BKE_ptcache_get_continue_physics(void); -/* Point Cache */ -struct PointCache *BKE_ptcache_add(void); +/******************* Allocate & free ***************/ +struct PointCache *BKE_ptcache_add(struct ListBase *ptcaches); +void BKE_ptache_free_mem(struct PointCache *cache); void BKE_ptcache_free(struct PointCache *cache); -struct PointCache *BKE_ptcache_copy(struct PointCache *cache); +void BKE_ptcache_free_list(struct ListBase *ptcaches); +struct PointCache *BKE_ptcache_copy_list(struct ListBase *ptcaches_new, struct ListBase *ptcaches_old); + +/********************** Baking *********************/ -/* Baking */ +/* Bakes cache with cache_step sized jumps in time, not accurate but very fast. */ void BKE_ptcache_quick_cache_all(struct Scene *scene); + +/* Bake cache or simulate to current frame with settings defined in the baker. */ void BKE_ptcache_make_cache(struct PTCacheBaker* baker); + +/* Convert disk cache to memory cache. */ +void BKE_ptcache_disk_to_mem(struct PTCacheID *pid); + +/* Convert memory cache to disk cache. */ +void BKE_ptcache_mem_to_disk(struct PTCacheID *pid); + +/* Convert disk cache to memory cache and vice versa. Clears the cache that was converted. */ void BKE_ptcache_toggle_disk_cache(struct PTCacheID *pid); +/* Loads simulation from external (disk) cache files. */ void BKE_ptcache_load_external(struct PTCacheID *pid); #endif diff --git a/source/blender/blenkernel/BKE_scene.h b/source/blender/blenkernel/BKE_scene.h index 9bb246f88cc..12a13a2b50c 100644 --- a/source/blender/blenkernel/BKE_scene.h +++ b/source/blender/blenkernel/BKE_scene.h @@ -40,6 +40,12 @@ struct AviCodecData; struct QuicktimeCodecData; struct RenderData; struct Text; +struct Main; + +#define SCE_COPY_EMPTY 0 +#define SCE_COPY_LINK_OB 1 +#define SCE_COPY_LINK_DATA 2 +#define SCE_COPY_FULL 3 /* note; doesn't work when scene is empty */ #define SETLOOPER(s, b) sce= s, b= (Base*)sce->base.first; b; b= (Base*)(b->next?b->next:sce->set?(sce=sce->set)->base.first:NULL) @@ -48,13 +54,16 @@ struct Text; void free_avicodecdata(struct AviCodecData *acd); void free_qtcodecdata(struct QuicktimeCodecData *acd); -void free_scene(struct Scene *me); +void free_scene(struct Scene *sce); struct Scene *add_scene(char *name); struct Base *object_in_scene(struct Object *ob, struct Scene *sce); void set_scene_bg(struct Scene *sce); void set_scene_name(char *name); +struct Scene *copy_scene(struct Main *bmain, struct Scene *sce, int type); +void unlink_scene(struct Main *bmain, struct Scene *sce, struct Scene *newsce); + int next_object(struct Scene *scene, int val, struct Base **base, struct Object **ob); struct Object *scene_find_camera(struct Scene *sc); diff --git a/source/blender/blenkernel/BKE_sculpt.h b/source/blender/blenkernel/BKE_sculpt.h index 08db1ac632e..9e5647a8775 100644 --- a/source/blender/blenkernel/BKE_sculpt.h +++ b/source/blender/blenkernel/BKE_sculpt.h @@ -33,7 +33,7 @@ struct MFace; struct MultireModifierData; struct MVert; -struct Sculpt; +struct Object; struct StrokeCache; typedef struct SculptSession { @@ -59,13 +59,14 @@ typedef struct SculptSession { /* Used to cache the render of the active texture */ unsigned int texcache_side, *texcache, texcache_actual; - void *cursor; /* wm handle */ + /* Layer brush persistence between strokes */ + float (*mesh_co_orig)[3]; /* Copy of the mesh vertices' locations */ + float *layer_disps; /* Displacements for each vertex */ struct SculptStroke *stroke; - struct StrokeCache *cache; } SculptSession; -void sculptsession_free(struct Sculpt *sculpt); +void free_sculptsession(SculptSession **); #endif diff --git a/source/blender/blenkernel/BKE_sequence.h b/source/blender/blenkernel/BKE_sequence.h index 7162fa7b9dd..f72617c8312 100644 --- a/source/blender/blenkernel/BKE_sequence.h +++ b/source/blender/blenkernel/BKE_sequence.h @@ -37,6 +37,7 @@ struct Strip; struct StripElem; struct ImBuf; struct Scene; +struct bContext; #define MAXSEQ 32 @@ -44,7 +45,6 @@ struct Scene; #define BUILD_SEQAR_COUNT_CURRENT 1 #define BUILD_SEQAR_COUNT_CHILDREN 2 - /* sequence iterator */ typedef struct SeqIterator { @@ -137,9 +137,9 @@ struct SeqEffectHandle { /* sequence.c */ // extern -void seq_free_sequence(struct Editing *ed, struct Sequence *seq); +void seq_free_sequence(struct Scene *scene, struct Sequence *seq); void seq_free_strip(struct Strip *strip); -void seq_free_editing(struct Editing *ed); +void seq_free_editing(struct Scene *scene); struct Editing *seq_give_editing(struct Scene *scene, int alloc); char *give_seqname(struct Sequence *seq); struct ImBuf *give_ibuf_seq(struct Scene *scene, int rectx, int recty, int cfra, int chanshown, int render_size); @@ -183,3 +183,8 @@ int seq_test_overlap(struct ListBase * seqbasep, struct Sequence *test); int shuffle_seq(struct ListBase * seqbasep, struct Sequence *test); void free_imbuf_seq(struct ListBase * seqbasep, int check_mem_usage); +void seq_update_sound(struct Sequence *seq); + +void clear_scene_in_allseqs(struct Scene *sce); + + diff --git a/source/blender/blenkernel/BKE_smoke.h b/source/blender/blenkernel/BKE_smoke.h index b1b42286788..fddcf0fea83 100644 --- a/source/blender/blenkernel/BKE_smoke.h +++ b/source/blender/blenkernel/BKE_smoke.h @@ -1,5 +1,5 @@ /** - * BKE_cloth.h + * BKE_smoke.h * * $Id$ * @@ -32,24 +32,13 @@ #ifndef BKE_SMOKE_H_ #define BKE_SMOKE_H_ +typedef int (*bresenham_callback) (float *input, int res[3], int *pixel, float *tRay); + void smokeModifier_do(struct SmokeModifierData *smd, struct Scene *scene, struct Object *ob, struct DerivedMesh *dm, int useRenderParams, int isFinalCalc); void smokeModifier_free (struct SmokeModifierData *smd); void smokeModifier_reset(struct SmokeModifierData *smd); void smokeModifier_createType(struct SmokeModifierData *smd); -void smoke_set_tray(struct SmokeModifierData *smd, size_t index, float transparency); -float smoke_get_tray(struct SmokeModifierData *smd, size_t index); -float smoke_get_tvox(struct SmokeModifierData *smd, size_t index); -void smoke_set_tvox(struct SmokeModifierData *smd, size_t index, float tvox); - -void smoke_set_bigtray(struct SmokeModifierData *smd, size_t index, float transparency); -float smoke_get_bigtray(struct SmokeModifierData *smd, size_t index); -float smoke_get_bigtvox(struct SmokeModifierData *smd, size_t index); -void smoke_set_bigtvox(struct SmokeModifierData *smd, size_t index, float tvox); - -long long smoke_get_mem_req(int xres, int yres, int zres, int amplify); -void smoke_prepare_View(struct SmokeModifierData *smd, float *light); -void smoke_prepare_bigView(struct SmokeModifierData *smd, float *light); #endif /* BKE_SMOKE_H_ */ diff --git a/source/blender/blenkernel/BKE_softbody.h b/source/blender/blenkernel/BKE_softbody.h index 0d9682cf842..d8053281ceb 100644 --- a/source/blender/blenkernel/BKE_softbody.h +++ b/source/blender/blenkernel/BKE_softbody.h @@ -68,8 +68,5 @@ extern void sbObjectToSoftbody(struct Object *ob); /* pass NULL to unlink again */ extern void sbSetInterruptCallBack(int (*f)(void)); -/* writing to cache for bake editing */ -extern void softbody_write_cache(struct Object *ob, struct SoftBody *soft, int cfra); - #endif diff --git a/source/blender/blenkernel/BKE_sound.h b/source/blender/blenkernel/BKE_sound.h index f3bed467c3a..84ecd79a008 100644 --- a/source/blender/blenkernel/BKE_sound.h +++ b/source/blender/blenkernel/BKE_sound.h @@ -1,7 +1,7 @@ /** * sound.h (mar-2001 nzc) - * - * $Id$ + * + * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** * @@ -33,20 +33,45 @@ struct PackedFile; struct bSound; -struct bSample; +struct bContext; struct ListBase; +struct Main; + +void sound_init(); + +void sound_exit(); + +struct bSound* sound_new_file(struct Main *main, char* filename); + +// XXX unused currently +#if 0 +struct bSound* sound_new_buffer(struct bContext *C, struct bSound *source); + +struct bSound* sound_new_limiter(struct bContext *C, struct bSound *source, float start, float end); +#endif -/* bad bad global... */ -extern struct ListBase *samples; +void sound_delete(struct bContext *C, struct bSound* sound); -void sound_free_all_samples(void); +void sound_cache(struct bSound* sound, int ignore); -/* void *sound_get_listener(void); implemented in src!also declared there now */ +void sound_load(struct Main *main, struct bSound* sound); -void sound_set_packedfile(struct bSample* sample, struct PackedFile* pf); -struct PackedFile* sound_find_packedfile(struct bSound* sound); -void sound_free_sample(struct bSample* sample); -void sound_free_sound(struct bSound* sound); +void sound_free(struct bSound* sound); +void sound_unlink(struct bContext *C, struct bSound* sound); + +struct SoundHandle* sound_new_handle(struct Scene *scene, struct bSound* sound, int startframe, int endframe, int frameskip); + +void sound_delete_handle(struct Scene *scene, struct SoundHandle *handle); + +void sound_update_playing(struct bContext *C); + +void sound_scrub(struct bContext *C); + +#ifdef AUD_CAPI +AUD_Device* sound_mixdown(struct Scene *scene, AUD_Specs specs, int start, int end); #endif +void sound_stop_all(struct bContext *C); + +#endif diff --git a/source/blender/blenkernel/BKE_texture.h b/source/blender/blenkernel/BKE_texture.h index a1600ce5473..a9862ba586b 100644 --- a/source/blender/blenkernel/BKE_texture.h +++ b/source/blender/blenkernel/BKE_texture.h @@ -40,6 +40,8 @@ struct ColorBand; struct HaloRen; struct TexMapping; struct EnvMap; +struct PointDensity; +struct VoxelData; /* in ColorBand struct */ #define MAXCOLORBAND 32 @@ -75,6 +77,16 @@ void BKE_free_envmap(struct EnvMap *env); struct EnvMap *BKE_add_envmap(void); struct EnvMap *BKE_copy_envmap(struct EnvMap *env); +void BKE_free_pointdensitydata(struct PointDensity *pd); +void BKE_free_pointdensity(struct PointDensity *pd); +struct PointDensity *BKE_add_pointdensity(void); +struct PointDensity *BKE_copy_pointdensity(struct PointDensity *pd); + +void BKE_free_voxeldatadata(struct VoxelData *vd); +void BKE_free_voxeldata(struct VoxelData *vd); +struct VoxelData *BKE_add_voxeldata(void); +struct VoxelData *BKE_copy_voxeldata(struct VoxelData *vd); + int BKE_texture_dependsOnTime(const struct Tex *texture); #endif diff --git a/source/blender/blenkernel/BKE_unit.h b/source/blender/blenkernel/BKE_unit.h new file mode 100644 index 00000000000..5d5f8cddf47 --- /dev/null +++ b/source/blender/blenkernel/BKE_unit.h @@ -0,0 +1,68 @@ +/** + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * Contributor(s): Campbell Barton + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#ifndef BKE_UNIT_H +#define BKE_UNIT_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* in all cases the value is assumed to be scaled by the user preference */ + +/* humanly readable representation of a value in units (used for button drawing) */ +void bUnit_AsString(char *str, int len_max, double value, int prec, int system, int type, int split, int pad); + +/* replace units with values, used before python button evaluation */ +int bUnit_ReplaceString(char *str, int len_max, char *str_prev, double scale_pref, int system, int type); + +/* the size of the unit used for this value (used for calculating the ckickstep) */ +double bUnit_ClosestScalar(double value, int system, int type); + +/* base scale for these units */ +double bUnit_BaseScalar(int system, int type); + +/* loop over scales, coudl add names later */ +//double bUnit_Iter(void **unit, char **name, int system, int type); + +void bUnit_GetSystem(void **usys_pt, int *len, int system, int type); +char* bUnit_GetName(void *usys_pt, int index); +char* bUnit_GetNameDisplay(void *usys_pt, int index); +double bUnit_GetScaler(void *usys_pt, int index); + +/* aligned with PropertyUnit */ +#define B_UNIT_NONE 0 +#define B_UNIT_LENGTH 1 +#define B_UNIT_AREA 2 +#define B_UNIT_VOLUME 3 +#define B_UNIT_MASS 4 +#define B_UNIT_ROTATION 5 +#define B_UNIT_TIME 6 +#define B_UNIT_VELOCITY 7 +#define B_UNIT_ACCELERATION 8 + +#ifdef __cplusplus +} +#endif + +#endif /* BKE_UNIT_H */ diff --git a/source/blender/blenkernel/BKE_utildefines.h b/source/blender/blenkernel/BKE_utildefines.h index 3c01f86dc02..9a076ee16da 100644 --- a/source/blender/blenkernel/BKE_utildefines.h +++ b/source/blender/blenkernel/BKE_utildefines.h @@ -62,11 +62,6 @@ #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; } -/* string compare */ -#define STREQ(str, a) ( strcmp((str), (a))==0 ) -#define STREQ2(str, a, b) ( STREQ(str, a) || STREQ(str, b) ) -#define STREQ3(str, a, b, c) ( STREQ2(str, a, b) || STREQ(str, c) ) - /* min/max */ #define MIN2(x,y) ( (x)<(y) ? (x) : (y) ) #define MIN3(x,y,z) MIN2( MIN2((x),(y)) , (z) ) @@ -92,8 +87,6 @@ if( (max)[0]<(vec)[0] ) (max)[0]= (vec)[0]; \ if( (max)[1]<(vec)[1] ) (max)[1]= (vec)[1]; } -#define MINSIZE(val, size) ( ((val)>=0.0) ? (((val)<(size)) ? (size): (val)) : ( ((val)>(-size)) ? (-size) : (val))) - /* some math and copy defines */ #define SWAP(type, a, b) { type sw_ap; sw_ap=(a); (a)=(b); (b)=sw_ap; } diff --git a/source/blender/blenkernel/BKE_writeavi.h b/source/blender/blenkernel/BKE_writeavi.h index cae1f25d0d8..4ef63b069c2 100644 --- a/source/blender/blenkernel/BKE_writeavi.h +++ b/source/blender/blenkernel/BKE_writeavi.h @@ -37,13 +37,14 @@ extern "C" { /* generic blender movie support, could move to own module */ struct RenderData; -void start_avi(struct RenderData *rd, int rectx, int recty); +struct Scene; +void start_avi(struct Scene *scene, struct RenderData *rd, int rectx, int recty); void end_avi(void); void append_avi(struct RenderData *rd, int frame, int *pixels, int rectx, int recty); void makeavistring (struct RenderData *rd, char *string); typedef struct bMovieHandle { - void (*start_movie)(struct RenderData *rd, int rectx, int recty); + void (*start_movie)(struct Scene *scene, struct RenderData *rd, int rectx, int recty); void (*append_movie)(struct RenderData *rd, int frame, int *pixels, int rectx, int recty); void (*end_movie)(void); int (*get_next_frame)(struct RenderData *rd); /* optional */ diff --git a/source/blender/blenkernel/BKE_writeffmpeg.h b/source/blender/blenkernel/BKE_writeffmpeg.h index be136bd9d6d..07e0e01ef7e 100644 --- a/source/blender/blenkernel/BKE_writeffmpeg.h +++ b/source/blender/blenkernel/BKE_writeffmpeg.h @@ -57,8 +57,9 @@ extern "C" { struct IDProperty; struct RenderData; +struct Scene; -extern void start_ffmpeg(struct RenderData *rd, int rectx, int recty); +extern void start_ffmpeg(struct Scene *scene, struct RenderData *rd, int rectx, int recty); extern void end_ffmpeg(void); extern void append_ffmpeg(struct RenderData *rd, int frame, int *pixels, int rectx, int recty); diff --git a/source/blender/blenkernel/BKE_writeframeserver.h b/source/blender/blenkernel/BKE_writeframeserver.h index e870cbb865d..6a38abe977f 100644 --- a/source/blender/blenkernel/BKE_writeframeserver.h +++ b/source/blender/blenkernel/BKE_writeframeserver.h @@ -33,8 +33,9 @@ extern "C" { #endif struct RenderData; +struct Scene; -extern void start_frameserver(struct RenderData *rd, int rectx, int recty); +extern void start_frameserver(struct Scene *scene, struct RenderData *rd, int rectx, int recty); extern void end_frameserver(void); extern void append_frameserver(struct RenderData *rd, int frame, int *pixels, int rectx, int recty); extern int frameserver_loop(struct RenderData *rd); diff --git a/source/blender/blenkernel/SConscript b/source/blender/blenkernel/SConscript index 78732be210d..e235a790a34 100644 --- a/source/blender/blenkernel/SConscript +++ b/source/blender/blenkernel/SConscript @@ -3,7 +3,7 @@ Import ('env') sources = env.Glob('intern/*.c') -incs = '. #/intern/guardedalloc #/intern/memutil ../editors/include ../blenlib ../makesdna' +incs = '. #/intern/guardedalloc #/intern/memutil ../editors/include ../blenlib ../blenfont ../makesdna' incs += ' ../render/extern/include #/intern/decimation/extern ../makesrna' incs += ' ../imbuf ../avi #/intern/elbeem/extern ../nodes' incs += ' #/intern/iksolver/extern ../blenloader' @@ -12,6 +12,9 @@ incs += ' #/intern/opennl/extern #/intern/bsp/extern' incs += ' ../gpu #/extern/glew/include' incs += ' ../bmesh' incs += ' #/intern/smoke/extern' +incs += ' #/extern/lzo/minilzo' +incs += ' #/extern/lzma' +incs += ' #/intern/audaspace/intern' incs += ' ' + env['BF_OPENGL_INC'] incs += ' ' + env['BF_ZLIB_INC'] @@ -52,7 +55,7 @@ if env['WITH_BF_QUICKTIME']: incs += ' ' + env['BF_QUICKTIME_INC'] if env['WITH_BF_BULLET']: - defs.append('WITH_BULLET') + defs.append('USE_BULLET') if env['BF_NO_ELBEEM']: defs.append('DISABLE_ELBEEM') diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index d32da467845..71534ede09f 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -72,6 +72,7 @@ #include "BKE_modifier.h" #include "BKE_mesh.h" #include "BKE_object.h" +#include "BKE_paint.h" #include "BKE_subsurf.h" #include "BKE_texture.h" #include "BKE_utildefines.h" @@ -2300,7 +2301,7 @@ static void clear_mesh_caches(Object *ob) static void mesh_build_data(Scene *scene, Object *ob, CustomDataMask dataMask) { Object *obact = scene->basact?scene->basact->object:NULL; - int editing = (FACESEL_PAINT_TEST)|(G.f & G_PARTICLEEDIT); + int editing = paint_facesel_test(ob)|(ob && ob->mode & OB_MODE_PARTICLE_EDIT); int needMapping = editing && (ob==obact); float min[3], max[3]; diff --git a/source/blender/blenkernel/intern/Makefile b/source/blender/blenkernel/intern/Makefile index f60bdffa282..6c2edc9e25f 100644 --- a/source/blender/blenkernel/intern/Makefile +++ b/source/blender/blenkernel/intern/Makefile @@ -42,6 +42,7 @@ CPPFLAGS += -I$(NAN_PYTHON)/include/python$(NAN_PYTHON_VERSION) CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include CPPFLAGS += -I../../../../intern/memutil +CPPFLAGS += -I$(NAN_AUDASPACE)/include # Reference to the types in makesdna and imbuf CPPFLAGS += -I../../makesdna CPPFLAGS += -I../../makesrna @@ -50,6 +51,7 @@ CPPFLAGS += -I../../imbuf CPPFLAGS += -I../../blenlib CPPFLAGS += -I../../blenloader CPPFLAGS += -I../../python +CPPFLAGS += -I../../blenfont # also avi is used CPPFLAGS += -I../../avi CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include @@ -88,6 +90,10 @@ CPPFLAGS += -I$(NAN_BULLET2)/include CPPFLAGS += -I$(NAN_FREETYPE)/include CPPFLAGS += -I$(NAN_FREETYPE)/include/freetype2 +# lzo and lzma, for pointcache +CPPFLAGS += -I$(NAN_LZO)/minilzo +CPPFLAGS += -I$(NAN_LZMA) + ifeq ($(WITH_FFMPEG),true) CPPFLAGS += -DWITH_FFMPEG CPPFLAGS += $(NAN_FFMPEGCFLAGS) @@ -109,3 +115,4 @@ ifeq ($(WITH_QUICKTIME), true) CPPFLAGS += -I../../quicktime CPPFLAGS += -DWITH_QUICKTIME endif + diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index f4d4eb1cc9c..47de044ea25 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -410,8 +410,9 @@ bActionGroup *action_groups_find_named (bAction *act, const char name[]) bPoseChannel *get_pose_channel(const bPose *pose, const char *name) { bPoseChannel *chan; - - if (pose==NULL) return NULL; + + if (ELEM(NULL, pose, name) || (name[0] == 0)) + return NULL; for (chan=pose->chanbase.first; chan; chan=chan->next) { if (chan->name[0] == name[0]) { @@ -837,14 +838,15 @@ short action_has_motion(const bAction *act) } /* Calculate the extents of given action */ -void calc_action_range(const bAction *act, float *start, float *end, int incl_hidden) +void calc_action_range(const bAction *act, float *start, float *end, short incl_modifiers) { FCurve *fcu; float min=999999999.0f, max=-999999999.0f; - short foundvert=0; + short foundvert=0, foundmod=0; if (act) { for (fcu= act->curves.first; fcu; fcu= fcu->next) { + /* if curve has keyframes, consider them first */ if (fcu->totvert) { float nmin, nmax; @@ -857,10 +859,53 @@ void calc_action_range(const bAction *act, float *start, float *end, int incl_hi foundvert= 1; } + + /* if incl_modifiers is enabled, need to consider modifiers too + * - only really care about the last modifier + */ + if ((incl_modifiers) && (fcu->modifiers.last)) { + FModifier *fcm= fcu->modifiers.last; + + /* only use the maximum sensible limits of the modifiers if they are more extreme */ + switch (fcm->type) { + case FMODIFIER_TYPE_LIMITS: /* Limits F-Modifier */ + { + FMod_Limits *fmd= (FMod_Limits *)fcm->data; + + if (fmd->flag & FCM_LIMIT_XMIN) { + min= MIN2(min, fmd->rect.xmin); + } + if (fmd->flag & FCM_LIMIT_XMAX) { + max= MAX2(max, fmd->rect.xmax); + } + } + break; + + case FMODIFIER_TYPE_CYCLES: /* Cycles F-Modifier */ + { + FMod_Cycles *fmd= (FMod_Cycles *)fcm->data; + + if (fmd->before_mode != FCM_EXTRAPOLATE_NONE) + min= MINAFRAMEF; + if (fmd->after_mode != FCM_EXTRAPOLATE_NONE) + max= MAXFRAMEF; + } + break; + + // TODO: function modifier may need some special limits + + default: /* all other standard modifiers are on the infinite range... */ + min= MINAFRAMEF; + max= MAXFRAMEF; + break; + } + + foundmod= 1; + } } } - if (foundvert) { + if (foundvert || foundmod) { if(min==max) max+= 1.0f; *start= min; *end= max; diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index 983f1ecc31c..df7004d3f6b 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -207,12 +207,6 @@ AnimData *BKE_copy_animdata (AnimData *adt) /* *********************************** */ /* KeyingSet API */ -/* NOTES: - * It is very likely that there will be two copies of the api - one for internal use, - * and one 'operator' based wrapper of the internal API, which should allow for access - * from Python/scripts so that riggers can automate the creation of KeyingSets for their rigs. - */ - /* Finding Tools --------------------------- */ /* Find the first path that matches the given criteria */ @@ -276,7 +270,7 @@ KeyingSet *BKE_keyingset_add (ListBase *list, const char name[], short flag, sho if (name) BLI_snprintf(ks->name, 64, name); else - strcpy(ks->name, "Keying Set"); + strcpy(ks->name, "KeyingSet"); ks->flag= flag; ks->keyingflag= keyingflag; @@ -285,7 +279,7 @@ KeyingSet *BKE_keyingset_add (ListBase *list, const char name[], short flag, sho BLI_addtail(list, ks); /* make sure KeyingSet has a unique name (this helps with identification) */ - BLI_uniquename(list, ks, "Keying Set", ' ', offsetof(KeyingSet, name), 64); + BLI_uniquename(list, ks, "KeyingSet", '.', offsetof(KeyingSet, name), 64); /* return new KeyingSet for further editing */ return ks; @@ -299,18 +293,25 @@ void BKE_keyingset_add_destination (KeyingSet *ks, ID *id, const char group_name KS_Path *ksp; /* sanity checks */ - if ELEM(NULL, ks, rna_path) + if ELEM(NULL, ks, rna_path) { + printf("ERROR: no Keying Set and/or RNA Path to add destination with \n"); return; + } /* ID is optional for relative KeyingSets, but is necessary for absolute KeyingSets */ if (id == NULL) { - if (ks->flag & KEYINGSET_ABSOLUTE) + if (ks->flag & KEYINGSET_ABSOLUTE) { + printf("ERROR: No ID provided for absolute destination. \n"); return; + } } /* don't add if there is already a matching KS_Path in the KeyingSet */ - if (BKE_keyingset_find_destination(ks, id, group_name, rna_path, array_index, groupmode)) + if (BKE_keyingset_find_destination(ks, id, group_name, rna_path, array_index, groupmode)) { + if (G.f & G_DEBUG) + printf("ERROR: destination already exists in Keying Set \n"); return; + } /* allocate a new KeyingSet Path */ ksp= MEM_callocN(sizeof(KS_Path), "KeyingSet Path"); @@ -342,6 +343,21 @@ void BKE_keyingset_add_destination (KeyingSet *ks, ID *id, const char group_name BLI_addtail(&ks->paths, ksp); } +/* Copy all KeyingSets in the given list */ +void BKE_keyingsets_copy(ListBase *newlist, ListBase *list) +{ + KeyingSet *ksn; + KS_Path *kspn; + + BLI_duplicatelist(newlist, list); + + for(ksn=newlist->first; ksn; ksn=ksn->next) { + BLI_duplicatelist(&ksn->paths, &ksn->paths); + + for(kspn=ksn->paths.first; kspn; kspn=kspn->next) + kspn->rna_path= MEM_dupallocN(kspn->rna_path); + } +} /* Freeing Tools --------------------------- */ @@ -425,19 +441,19 @@ static short animsys_write_rna_setting (PointerRNA *ptr, char *path, int array_i switch (RNA_property_type(prop)) { case PROP_BOOLEAN: - if (RNA_property_array_length(prop)) + if (RNA_property_array_length(&new_ptr, prop)) RNA_property_boolean_set_index(&new_ptr, prop, array_index, (int)value); else RNA_property_boolean_set(&new_ptr, prop, (int)value); break; case PROP_INT: - if (RNA_property_array_length(prop)) + if (RNA_property_array_length(&new_ptr, prop)) RNA_property_int_set_index(&new_ptr, prop, array_index, (int)value); else RNA_property_int_set(&new_ptr, prop, (int)value); break; case PROP_FLOAT: - if (RNA_property_array_length(prop)) + if (RNA_property_array_length(&new_ptr, prop)) RNA_property_float_set_index(&new_ptr, prop, array_index, value); else RNA_property_float_set(&new_ptr, prop, value); @@ -1162,19 +1178,19 @@ void nladata_flush_channels (ListBase *channels) switch (RNA_property_type(prop)) { case PROP_BOOLEAN: - if (RNA_property_array_length(prop)) + if (RNA_property_array_length(ptr, prop)) RNA_property_boolean_set_index(ptr, prop, array_index, (int)value); else RNA_property_boolean_set(ptr, prop, (int)value); break; case PROP_INT: - if (RNA_property_array_length(prop)) + if (RNA_property_array_length(ptr, prop)) RNA_property_int_set_index(ptr, prop, array_index, (int)value); else RNA_property_int_set(ptr, prop, (int)value); break; case PROP_FLOAT: - if (RNA_property_array_length(prop)) + if (RNA_property_array_length(ptr, prop)) RNA_property_float_set_index(ptr, prop, array_index, value); else RNA_property_float_set(ptr, prop, value); @@ -1248,7 +1264,7 @@ static void animsys_evaluate_nla (PointerRNA *ptr, AnimData *adt, float ctime) dummy_strip.act= adt->action; dummy_strip.remap= adt->remap; - // FIXME: what happens when we want to included F-Modifier access? + /* action range is calculated taking F-Modifiers into account (which making new strips doesn't do due to the troublesome nature of that) */ calc_action_range(dummy_strip.act, &dummy_strip.actstart, &dummy_strip.actend, 1); dummy_strip.start = dummy_strip.actstart; dummy_strip.end = (IS_EQ(dummy_strip.actstart, dummy_strip.actend)) ? (dummy_strip.actstart + 1.0f): (dummy_strip.actend); diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index e354cf14830..b443114344e 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -176,8 +176,6 @@ void pushpop_test() void free_blender(void) { /* samples are in a global list..., also sets G.main->sound->sample NULL */ - sound_free_all_samples(); - free_main(G.main); G.main= NULL; @@ -228,7 +226,7 @@ static void clear_global(void) G.main= NULL; - G.f &= ~(G_WEIGHTPAINT + G_VERTEXPAINT + G_FACESELECT + G_PARTICLEEDIT); + G.f &= ~(G_FACESELECT); } /* make sure path names are correct for OS */ @@ -330,9 +328,6 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, char *filename) MEM_freeN(bfd->user); } - /* samples is a global list... */ - sound_free_all_samples(); - /* case G_FILE_NO_UI or no screens in file */ if(mode) { /* leave entire context further unaltered? */ @@ -631,8 +626,7 @@ void BKE_write_undo(bContext *C, char *name) } } -/* 1= an undo, -1 is a redo. we have to make sure 'curundo' remains at current situation - * Note, ALWAYS call sound_initialize_sounds after BKE_undo_step() */ +/* 1= an undo, -1 is a redo. we have to make sure 'curundo' remains at current situation */ void BKE_undo_step(bContext *C, int step) { diff --git a/source/blender/blenkernel/intern/boids.c b/source/blender/blenkernel/intern/boids.c index d8926fc5753..5c62e434cb6 100644 --- a/source/blender/blenkernel/intern/boids.c +++ b/source/blender/blenkernel/intern/boids.c @@ -76,7 +76,7 @@ static int rule_goal_avoid(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, Object *priority_ob = NULL; float vec[3] = {0.0f, 0.0f, 0.0f}, loc[3] = {0.0f, 0.0f, 0.0f}; float mul = (rule->type == eBoidRuleType_Avoid ? 1.0 : -1.0); - float priority = 0.0f, len; + float priority = 0.0f, len = 0.0f; int ret = 0; /* first find out goal/predator with highest priority */ @@ -614,7 +614,7 @@ static int rule_fight(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, Parti KDTreeNearest *ptn = NULL; ParticleTarget *pt; ParticleData *epars; - ParticleData *enemy_pa; + ParticleData *enemy_pa = NULL; /* friends & enemies */ float closest_enemy[3] = {0.0f,0.0f,0.0f}; float closest_dist = fbr->distance + 1.0f; diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index 30a35cbe91c..bce4e1120be 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -35,6 +35,7 @@ #include "DNA_brush_types.h" #include "DNA_color_types.h" #include "DNA_image_types.h" +#include "DNA_object_types.h" #include "DNA_texture_types.h" #include "DNA_scene_types.h" #include "DNA_windowmanager_types.h" @@ -50,6 +51,7 @@ #include "BKE_image.h" #include "BKE_library.h" #include "BKE_main.h" +#include "BKE_paint.h" #include "BKE_texture.h" #include "BKE_utildefines.h" @@ -61,7 +63,7 @@ /* Datablock add/copy/free/make_local */ -Brush *add_brush(char *name) +Brush *add_brush(const char *name) { Brush *brush; @@ -73,6 +75,8 @@ Brush *add_brush(char *name) brush->alpha= 0.2f; brush->size= 25; brush->spacing= 10.0f; + brush->smooth_stroke_radius= 75; + brush->smooth_stroke_factor= 0.9; brush->rate= 0.1f; brush->innerradius= 0.5f; brush->clone.alpha= 0.5; @@ -152,7 +156,7 @@ void make_local_brush(Brush *brush) } for(scene= G.main->scene.first; scene; scene=scene->id.next) - if(scene->toolsettings->imapaint.brush==brush) { + if(paint_brush(&scene->toolsettings->imapaint.paint)==brush) { if(scene->id.lib) lib= 1; else local= 1; } @@ -174,9 +178,9 @@ void make_local_brush(Brush *brush) brushn->id.flag |= LIB_FAKEUSER; for(scene= G.main->scene.first; scene; scene=scene->id.next) - if(scene->toolsettings->imapaint.brush==brush) + if(paint_brush(&scene->toolsettings->imapaint.paint)==brush) if(scene->id.lib==0) { - scene->toolsettings->imapaint.brush= brushn; + paint_brush_set(&scene->toolsettings->imapaint.paint, brushn); brushn->id.us++; brush->id.us--; } @@ -185,20 +189,7 @@ void make_local_brush(Brush *brush) /* Library Operations */ -Brush **current_brush_source(Scene *sce) -{ - if(G.f & G_SCULPTMODE) - return &sce->toolsettings->sculpt->brush; - else if(G.f & G_VERTEXPAINT) - return &sce->toolsettings->vpaint->brush; - else if(G.f & G_WEIGHTPAINT) - return &sce->toolsettings->wpaint->brush; - else if(G.f & G_TEXTUREPAINT) - return &sce->toolsettings->imapaint.brush; - return NULL; -} - -int brush_set_nr(Brush **current_brush, int nr) +int brush_set_nr(Brush **current_brush, int nr, const char *name) { ID *idtest, *id; @@ -207,7 +198,7 @@ int brush_set_nr(Brush **current_brush, int nr) if(idtest==0) { /* new brush */ if(id) idtest= (ID *)copy_brush((Brush *)id); - else idtest= (ID *)add_brush("Brush"); + else idtest= (ID *)add_brush(name); idtest->us--; } if(idtest!=id) { @@ -300,6 +291,13 @@ void brush_curve_preset(Brush *b, BrushCurvePreset preset) curvemapping_changed(b->curve, 0); } +static MTex *brush_active_texture(Brush *brush) +{ + if(brush && brush->texact >= 0) + return brush->mtex[brush->texact]; + return NULL; +} + int brush_texture_set_nr(Brush *brush, int nr) { ID *idtest, *id=NULL; @@ -374,10 +372,10 @@ int brush_clone_image_delete(Brush *brush) return 0; } -void brush_check_exists(Brush **brush) +void brush_check_exists(Brush **brush, const char *name) { if(*brush==NULL) - brush_set_nr(brush, 1); + brush_set_nr(brush, 1, name); } /* Brush Sampling */ @@ -411,23 +409,6 @@ float brush_sample_falloff(Brush *brush, float dist) return 0.0f; } -float brush_sample_falloff_noalpha(Brush *brush, float dist) -{ - float outer, inner; - - outer = brush->size >> 1; - inner = outer*brush->innerradius; - - if (dist <= inner) { - return 1.0f; - } - else if ((dist < outer) && (inner < outer)) { - return 1.0f - sqrt((dist - inner)/(outer - inner)); - } - else - return 0.0f; -} - void brush_sample_tex(Brush *brush, float *xy, float *rgba) { MTex *mtex= brush->mtex[brush->texact]; @@ -1077,8 +1058,11 @@ void brush_radial_control_invoke(wmOperator *op, Brush *br, float size_weight) original_value = br->size * size_weight; else if(mode == WM_RADIALCONTROL_STRENGTH) original_value = br->alpha; - else if(mode == WM_RADIALCONTROL_ANGLE) - original_value = br->rot; + else if(mode == WM_RADIALCONTROL_ANGLE) { + MTex *mtex = brush_active_texture(br); + if(mtex) + original_value = mtex->rot; + } RNA_float_set(op->ptr, "initial_value", original_value); op->customdata = brush_gen_radial_control_imbuf(br); @@ -1094,8 +1078,11 @@ int brush_radial_control_exec(wmOperator *op, Brush *br, float size_weight) br->size = new_value * size_weight; else if(mode == WM_RADIALCONTROL_STRENGTH) br->alpha = new_value; - else if(mode == WM_RADIALCONTROL_ANGLE) - br->rot = new_value * conv; + else if(mode == WM_RADIALCONTROL_ANGLE) { + MTex *mtex = brush_active_texture(br); + if(mtex) + mtex->rot = new_value * conv; + } return OPERATOR_FINISHED; } diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index b137f6d9963..ff5bf2d5bae 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -1735,6 +1735,7 @@ typedef struct MultiresDM { CDDerivedMesh cddm; MultiresModifierData *mmd; + int local_mmd; int lvl, totlvl; float (*orco)[3]; @@ -1744,7 +1745,7 @@ typedef struct MultiresDM { IndexNode *vert_face_map_mem, *vert_edge_map_mem; int *face_offsets; - Mesh *me; + Object *ob; int modified; void (*update)(DerivedMesh*); @@ -1756,14 +1757,19 @@ static void MultiresDM_release(DerivedMesh *dm) int mvert_layer; /* Before freeing, need to update the displacement map */ - if(dm->needsFree && mrdm->modified) - mrdm->update(dm); + if(dm->needsFree && mrdm->modified) { + /* Check that mmd still exists */ + if(!mrdm->local_mmd && BLI_findindex(&mrdm->ob->modifiers, mrdm->mmd) < 0) + mrdm->mmd = NULL; + if(mrdm->mmd) + mrdm->update(dm); + } /* If the MVert data is being used as the sculpt undo store, don't free it */ mvert_layer = CustomData_get_layer_index(&dm->vertData, CD_MVERT); if(mvert_layer != -1) { CustomDataLayer *cd = &dm->vertData.layers[mvert_layer]; - if(cd->data == mrdm->mmd->undo_verts) + if(mrdm->mmd && cd->data == mrdm->mmd->undo_verts) cd->flag |= CD_FLAG_NOFREE; } @@ -1797,7 +1803,8 @@ DerivedMesh *MultiresDM_new(MultiresSubsurf *ms, DerivedMesh *orig, dm = &mrdm->cddm.dm; mrdm->mmd = ms->mmd; - mrdm->me = ms->me; + mrdm->ob = ms->ob; + mrdm->local_mmd = ms->local_mmd; if(dm) { MDisps *disps; @@ -1841,7 +1848,12 @@ DerivedMesh *MultiresDM_new(MultiresSubsurf *ms, DerivedMesh *orig, Mesh *MultiresDM_get_mesh(DerivedMesh *dm) { - return ((MultiresDM*)dm)->me; + return get_mesh(((MultiresDM*)dm)->ob); +} + +Object *MultiresDM_get_object(DerivedMesh *dm) +{ + return ((MultiresDM*)dm)->ob; } void *MultiresDM_get_orco(DerivedMesh *dm) @@ -1878,10 +1890,11 @@ void MultiresDM_set_update(DerivedMesh *dm, void (*update)(DerivedMesh*)) ListBase *MultiresDM_get_vert_face_map(DerivedMesh *dm) { MultiresDM *mrdm = (MultiresDM*)dm; + Mesh *me = mrdm->ob->data; if(!mrdm->vert_face_map) - create_vert_face_map(&mrdm->vert_face_map, &mrdm->vert_face_map_mem, mrdm->me->mface, - mrdm->me->totvert, mrdm->me->totface); + create_vert_face_map(&mrdm->vert_face_map, &mrdm->vert_face_map_mem, me->mface, + me->totvert, me->totface); return mrdm->vert_face_map; } @@ -1889,10 +1902,11 @@ ListBase *MultiresDM_get_vert_face_map(DerivedMesh *dm) ListBase *MultiresDM_get_vert_edge_map(DerivedMesh *dm) { MultiresDM *mrdm = (MultiresDM*)dm; + Mesh *me = mrdm->ob->data; if(!mrdm->vert_edge_map) - create_vert_edge_map(&mrdm->vert_edge_map, &mrdm->vert_edge_map_mem, mrdm->me->medge, - mrdm->me->totvert, mrdm->me->totedge); + create_vert_edge_map(&mrdm->vert_edge_map, &mrdm->vert_edge_map_mem, me->medge, + me->totvert, me->totedge); return mrdm->vert_edge_map; } @@ -1900,6 +1914,7 @@ ListBase *MultiresDM_get_vert_edge_map(DerivedMesh *dm) int *MultiresDM_get_face_offsets(DerivedMesh *dm) { MultiresDM *mrdm = (MultiresDM*)dm; + Mesh *me = mrdm->ob->data; int i, accum = 0; if(!mrdm->face_offsets) { @@ -1907,11 +1922,11 @@ int *MultiresDM_get_face_offsets(DerivedMesh *dm) int area = len * len; int t = 1 + len * 3 + area * 3, q = t + len + area; - mrdm->face_offsets = MEM_callocN(sizeof(int) * mrdm->me->totface, "mrdm face offsets"); - for(i = 0; i < mrdm->me->totface; ++i) { + mrdm->face_offsets = MEM_callocN(sizeof(int) * me->totface, "mrdm face offsets"); + for(i = 0; i < me->totface; ++i) { mrdm->face_offsets[i] = accum; - accum += (mrdm->me->mface[i].v4 ? q : t); + accum += (me->mface[i].v4 ? q : t); } } diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c index b16a046cd58..9e105b00e15 100644 --- a/source/blender/blenkernel/intern/cloth.c +++ b/source/blender/blenkernel/intern/cloth.c @@ -340,92 +340,6 @@ void bvhselftree_update_from_cloth(ClothModifierData *clmd, int moving) } } -int modifiers_indexInObject(Object *ob, ModifierData *md_seek); -static void cloth_write_state(int index, void *cloth_v, float *data) -{ - Cloth *cloth= cloth_v; - ClothVertex *vert = cloth->verts + index; - - memcpy(data, vert->x, 3 * sizeof(float)); - memcpy(data + 3, vert->xconst, 3 * sizeof(float)); - memcpy(data + 6, vert->v, 3 * sizeof(float)); -} -static void cloth_read_state(int index, void *cloth_v, float *data) -{ - Cloth *cloth= cloth_v; - ClothVertex *vert = cloth->verts + index; - - memcpy(vert->x, data, 3 * sizeof(float)); - memcpy(vert->xconst, data + 3, 3 * sizeof(float)); - memcpy(vert->v, data + 6, 3 * sizeof(float)); -} -static void cloth_cache_interpolate(int index, void *cloth_v, float frs_sec, float cfra, float cfra1, float cfra2, float *data1, float *data2) -{ - Cloth *cloth= cloth_v; - ClothVertex *vert = cloth->verts + index; - ParticleKey keys[4]; - float dfra; - - if(cfra1 == cfra2) { - cloth_read_state(index, cloth, data1); - return; - } - - memcpy(keys[1].co, data1, 3 * sizeof(float)); - memcpy(keys[1].vel, data1 + 6, 3 * sizeof(float)); - - memcpy(keys[2].co, data2, 3 * sizeof(float)); - memcpy(keys[2].vel, data2 + 6, 3 * sizeof(float)); - - dfra = cfra2 - cfra1; - - VecMulf(keys[1].vel, dfra); - VecMulf(keys[2].vel, dfra); - - psys_interpolate_particle(-1, keys, (cfra - cfra1) / dfra, keys, 1); - - VecMulf(keys->vel, 1.0f / dfra); - - memcpy(vert->x, keys->co, 3 * sizeof(float)); - memcpy(vert->v, keys->vel, 3 * sizeof(float)); - - /* not sure what to do with this - jahka */ - memcpy(vert->xconst, data1 + 3, 3 * sizeof(float)); -} -void cloth_write_cache(Object *ob, ClothModifierData *clmd, int cfra) -{ - PTCacheWriter writer; - PTCacheID pid; - - BKE_ptcache_id_from_cloth(&pid, ob, clmd); - - writer.calldata = clmd->clothObject; - writer.cfra = cfra; - writer.set_elem = cloth_write_state; - writer.pid = &pid; - writer.totelem = clmd->clothObject->numverts; - - BKE_ptcache_write_cache(&writer); -} - -int cloth_read_cache(Scene *scene, Object *ob, ClothModifierData *clmd, float cfra, int *old_framenr) -{ - PTCacheReader reader; - PTCacheID pid; - - BKE_ptcache_id_from_cloth(&pid, ob, clmd); - - reader.calldata = clmd->clothObject; - reader.cfra = cfra; - reader.interpolate_elem = cloth_cache_interpolate; - reader.old_frame = old_framenr; - reader.pid = &pid; - reader.scene = scene; - reader.set_elem = cloth_read_state; - reader.totelem = clmd->clothObject->numverts; - - return BKE_ptcache_read_cache(&reader); -} void cloth_clear_cache(Object *ob, ClothModifierData *clmd, float framenr) { PTCacheID pid; @@ -512,7 +426,7 @@ DerivedMesh *clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob, PTCacheID pid; float timescale; int framedelta, framenr, startframe, endframe; - int cache_result, old_framenr; + int cache_result; clmd->scene= scene; /* nice to pass on later :) */ framenr= (int)scene->r.cfra; @@ -583,7 +497,7 @@ DerivedMesh *clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob, return result; /* try to read from cache */ - cache_result = cloth_read_cache(scene, ob, clmd, framenr, &old_framenr); + cache_result = BKE_ptcache_read_cache(&pid, (float)framenr, scene->r.frs_sec); if(cache_result == PTCACHE_READ_EXACT || cache_result == PTCACHE_READ_INTERPOLATED) { cache->flag |= PTCACHE_SIMULATION_VALID; @@ -600,7 +514,6 @@ DerivedMesh *clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob, implicit_set_positions(clmd); cache->flag |= PTCACHE_SIMULATION_VALID; - cache->simframe= old_framenr; } else if(ob->id.lib || (cache->flag & PTCACHE_BAKED)) { /* if baked and nothing in cache, do nothing */ @@ -624,7 +537,7 @@ DerivedMesh *clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob, else { /* if on second frame, write cache for first frame */ if(cache->simframe == startframe && (cache->flag & PTCACHE_OUTDATED || cache->last_exact==0)) - cloth_write_cache(ob, clmd, startframe); + BKE_ptcache_write_cache(&pid, startframe); clmd->sim_parms->timescale *= framenr - cache->simframe; @@ -638,7 +551,7 @@ DerivedMesh *clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob, cache->last_exact= 0; } else - cloth_write_cache(ob, clmd, framenr); + BKE_ptcache_write_cache(&pid, framenr); cloth_to_object (ob, clmd, result); } diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c index c122145c98f..37e9c93a108 100644 --- a/source/blender/blenkernel/intern/collision.c +++ b/source/blender/blenkernel/intern/collision.c @@ -591,7 +591,7 @@ CollPair* cloth_collision ( ModifierData *md1, ModifierData *md2, BVHTreeOverlap ClothModifierData *clmd = ( ClothModifierData * ) md1; CollisionModifierData *collmd = ( CollisionModifierData * ) md2; MFace *face1=NULL, *face2 = NULL; -#ifdef WITH_BULLET +#ifdef USE_BULLET ClothVertex *verts1 = clmd->clothObject->verts; #endif double distance = 0; @@ -669,7 +669,7 @@ CollPair* cloth_collision ( ModifierData *md1, ModifierData *md2, BVHTreeOverlap break; } -#ifdef WITH_BULLET +#ifdef USE_BULLET // calc distance + normal distance = plNearestPoints ( verts1[collpair->ap1].txold, verts1[collpair->ap2].txold, verts1[collpair->ap3].txold, collmd->current_x[collpair->bp1].co, collmd->current_x[collpair->bp2].co, collmd->current_x[collpair->bp3].co, collpair->pa,collpair->pb,collpair->vector ); diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c index 2280ec71f7a..26f9245abc7 100644 --- a/source/blender/blenkernel/intern/colortools.c +++ b/source/blender/blenkernel/intern/colortools.c @@ -68,33 +68,33 @@ void gamma_correct_rec709(float *c, float gamma) { /* Rec. 709 gamma correction. */ - float cc = 0.018f; + const float cc = 0.018f; if (*c < cc) - *c *= ((1.099f * (float)pow(cc, gamma)) - 0.099f) / cc; + *c *= ((1.099f * (float)powf(cc, gamma)) - 0.099f) * (1.0f/cc); else - *c = (1.099f * (float)pow(*c, gamma)) - 0.099f; + *c = (1.099f * (float)powf(*c, gamma)) - 0.099f; } void gamma_correct(float *c, float gamma) { - *c = pow((*c), gamma); + *c = powf((*c), gamma); } float srgb_to_linearrgb(float c) { if (c < 0.04045f) - return (c < 0.f)?0.f:c / 12.92; + return (c < 0.0f)? 0.0f: c*(1.0f/12.92f); else - return pow((c + 0.055)/1.055, 2.4); + return powf((c + 0.055f)*(1.0f/1.055f), 2.4f); } float linearrgb_to_srgb(float c) { - if (c < 0.0031308) - return (c < 0.f)?0.f:c * 12.92; + if (c < 0.0031308f) + return (c < 0.0f)? 0.0f: c * 12.92f; else - return 1.055 * pow(c, 1.0/2.4) - 0.055; + return 1.055f * powf(c, 1.0f/2.4f) - 0.055f; } /* utility function convert an RGB triplet from sRGB to linear RGB color space */ diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c index 78c29a96bff..bbfe077c15e 100644 --- a/source/blender/blenkernel/intern/context.c +++ b/source/blender/blenkernel/intern/context.c @@ -34,6 +34,7 @@ #include "DNA_space_types.h" #include "DNA_view3d_types.h" #include "DNA_windowmanager_types.h" +#include "DNA_object_types.h" #include "RNA_access.h" @@ -43,6 +44,7 @@ #include "BKE_context.h" #include "BKE_main.h" #include "BKE_screen.h" +#include "BKE_global.h" #include <string.h> @@ -217,7 +219,10 @@ struct ARegion *CTX_wm_menu(const bContext *C) struct ReportList *CTX_wm_reports(const bContext *C) { - return &(C->wm.manager->reports); + if (C->wm.manager) + return &(C->wm.manager->reports); + + return NULL; } View3D *CTX_wm_view3d(const bContext *C) @@ -333,6 +338,13 @@ struct SpaceInfo *CTX_wm_space_info(const bContext *C) return NULL; } +struct SpaceUserPref *CTX_wm_space_userpref(const bContext *C) +{ + if(C->wm.area && C->wm.area->spacetype==SPACE_USERPREF) + return C->wm.area->spacedata.first; + return NULL; +} + void CTX_wm_manager_set(bContext *C, wmWindowManager *wm) { C->wm.manager= wm; @@ -656,6 +668,69 @@ Scene *CTX_data_scene(const bContext *C) return C->data.scene; } +int CTX_data_mode_enum(const bContext *C) +{ + Object *obedit= CTX_data_edit_object(C); + + if(obedit) { + switch(obedit->type) { + case OB_MESH: + return CTX_MODE_EDIT_MESH; + case OB_CURVE: + return CTX_MODE_EDIT_CURVE; + case OB_SURF: + return CTX_MODE_EDIT_SURFACE; + case OB_FONT: + return CTX_MODE_EDIT_TEXT; + case OB_ARMATURE: + return CTX_MODE_EDIT_ARMATURE; + case OB_MBALL: + return CTX_MODE_EDIT_METABALL; + case OB_LATTICE: + return CTX_MODE_EDIT_LATTICE; + } + } + else { + Object *ob = CTX_data_active_object(C); + + if(ob) { + if(ob->mode & OB_MODE_POSE) return CTX_MODE_POSE; + else if(ob->mode & OB_MODE_SCULPT) return CTX_MODE_SCULPT; + else if(ob->mode & OB_MODE_WEIGHT_PAINT) return CTX_MODE_PAINT_WEIGHT; + else if(ob->mode & OB_MODE_VERTEX_PAINT) return CTX_MODE_PAINT_VERTEX; + else if(ob->mode & OB_MODE_TEXTURE_PAINT) return CTX_MODE_PAINT_TEXTURE; + else if(ob->mode & OB_MODE_PARTICLE_EDIT) return CTX_MODE_PARTICLE; + } + } + + return CTX_MODE_OBJECT; +} + + +/* would prefer if we can use the enum version below over this one - Campbell */ +/* must be aligned with above enum */ +static char *data_mode_strings[] = { + "mesh_edit", + "curve_edit", + "surface_edit", + "text_edit", + "armature_edit", + "mball_edit", + "lattice_edit", + "posemode", + "sculpt_mode", + "weightpaint", + "vertexpaint", + "texturepaint", + "particlemode", + "objectmode", + 0 +}; +char *CTX_data_mode_string(const bContext *C) +{ + return data_mode_strings[CTX_data_mode_enum(C)]; +} + void CTX_data_scene_set(bContext *C, Scene *scene) { C->data.scene= scene; diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index 3136630ce93..6f897be9b05 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -315,6 +315,9 @@ static void init_fastshade_shadeinput(Render *re) static Render *fastshade_get_render(Scene *scene) { + // XXX 2.5: this crashes combined with previewrender + // due to global R so disabled for now +#if 0 /* XXX ugly global still, but we can't do preview while rendering */ if(G.rendering==0) { @@ -326,6 +329,7 @@ static Render *fastshade_get_render(Scene *scene) } return re; } +#endif return NULL; } diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index 90bf08059d7..31f6e2c6067 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -698,19 +698,19 @@ float driver_get_target_value (ChannelDriver *driver, DriverTarget *dtar) if (RNA_path_resolve(&id_ptr, path, &ptr, &prop)) { switch (RNA_property_type(prop)) { case PROP_BOOLEAN: - if (RNA_property_array_length(prop)) + if (RNA_property_array_length(&ptr, prop)) value= (float)RNA_property_boolean_get_index(&ptr, prop, index); else value= (float)RNA_property_boolean_get(&ptr, prop); break; case PROP_INT: - if (RNA_property_array_length(prop)) + if (RNA_property_array_length(&ptr, prop)) value= (float)RNA_property_int_get_index(&ptr, prop, index); else value= (float)RNA_property_int_get(&ptr, prop); break; case PROP_FLOAT: - if (RNA_property_array_length(prop)) + if (RNA_property_array_length(&ptr, prop)) value= RNA_property_float_get_index(&ptr, prop, index); else value= RNA_property_float_get(&ptr, prop); diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c index 54366aadd92..3cff82f522a 100644 --- a/source/blender/blenkernel/intern/idprop.c +++ b/source/blender/blenkernel/intern/idprop.c @@ -167,7 +167,7 @@ void IDP_ResizeIDPArray(IDProperty *prop, int newlen) for (i=newlen; i<prop->len; i++) { IDP_FreeProperty(GETPROP(prop, i)); } - memcpy(newarr, prop->data.pointer, newlen*prop->len*sizeof(IDProperty)); + memcpy(newarr, prop->data.pointer, newlen*sizeof(IDProperty)); } if(prop->data.pointer) diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 62af05fbc9a..eb8872c43a5 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -73,6 +73,8 @@ //XXX #include "BIF_editseq.h" +#include "BLF_api.h" + #include "PIL_time.h" #include "RE_pipeline.h" @@ -978,7 +980,6 @@ static void stampdata(Scene *scene, StampData *stamp_data, int do_prefix) if (do_prefix) strcpy(stamp_data->file, "File <untitled>"); else strcpy(stamp_data->file, "<untitled>"); } - stamp_data->note[0] = '\0'; } else { stamp_data->file[0] = '\0'; } @@ -1046,8 +1047,8 @@ static void stampdata(Scene *scene, StampData *stamp_data, int do_prefix) if (scene->r.stamp & R_STAMP_FRAME) { char format[32]; - if (do_prefix) sprintf(format, "Frame %%0%di\n", 1 + (int) log10(scene->r.efra)); - else sprintf(format, "%%0%di\n", 1 + (int) log10(scene->r.efra)); + if (do_prefix) sprintf(format, "Frame %%0%di", 1 + (int) log10(scene->r.efra)); + else sprintf(format, "%%0%di", 1 + (int) log10(scene->r.efra)); sprintf (stamp_data->frame, format, scene->r.cfra); } else { stamp_data->frame[0] = '\0'; @@ -1083,131 +1084,172 @@ static void stampdata(Scene *scene, StampData *stamp_data, int do_prefix) } } +// XXX - Bad level call. +extern int datatoc_bmonofont_ttf_size; +extern char datatoc_bmonofont_ttf[]; + +// XXX - copied from text_font_begin +static void stamp_font_begin(int size) +{ + static int mono= -1; + + if (mono == -1) + mono= BLF_load_mem("monospace", (unsigned char *)datatoc_bmonofont_ttf, datatoc_bmonofont_ttf_size); + + BLF_set(mono); + BLF_aspect(1.0); + BLF_size(size, 72); +} + void BKE_stamp_buf(Scene *scene, unsigned char *rect, float *rectf, int width, int height, int channels) { -#if 0 -// XXX -// This go back when BLF_draw_buffer is implemented - Diego struct StampData stamp_data; - - int x=1,y=1; - int font_height; - int text_width; - int text_pad; - struct BMF_Font *font; + float w, h, pad; + int x, y; if (!rect && !rectf) return; stampdata(scene, &stamp_data, 1); - - switch (scene->r.stamp_font_id) { - case 1: /* tiny */ - font = BMF_GetFont(BMF_kHelveticaBold8); - break; - case 2: /* small */ - font = BMF_GetFont(BMF_kHelveticaBold10); - break; - case 3: /* medium */ - font = BMF_GetFont(BMF_kScreen12); - break; - case 0: /* large - default */ - font = BMF_GetFont(BMF_kScreen15); - break; - case 4: /* huge */ - font = BMF_GetFont(BMF_kHelveticaBold14); - break; - default: - font = NULL; - break; - } - - font_height = BMF_GetFontHeight(font); - /* All texts get halfspace+1 pixel on each side and 1 pix - above and below as padding against their backing rectangles */ - text_pad = BMF_GetStringWidth(font, " "); - - x = 1; /* Inits for everyone, text position, so 1 for padding, not 0 */ - y = height - font_height - 1; /* Also inits for everyone, notice padding pixel */ - + stamp_font_begin(12); + + BLF_buffer(rectf, rect, width, height, channels); + BLF_buffer_col(scene->r.fg_stamp[0], scene->r.fg_stamp[1], scene->r.fg_stamp[2], 1.0); + pad= BLF_width("--"); + + x= 0; + y= height; + if (stamp_data.file[0]) { /* Top left corner */ - text_width = BMF_GetStringWidth(font, stamp_data.file); - buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x-1, y-1, x+text_width+text_pad+1, y+font_height+1); - BMF_DrawStringBuf(font, stamp_data.file, x+(text_pad/2), y, scene->r.fg_stamp, rect, rectf, width, height, channels); - y -= font_height+2; /* Top and bottom 1 pix padding each */ + BLF_width_and_height(stamp_data.file, &w, &h); + y -= h; + + /* also a little of space to the background. */ + buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x, y-3, w+3, y+h+3); + + /* and draw the text. */ + BLF_position(x, y, 0.0); + BLF_draw_buffer(stamp_data.file); + + /* the extra pixel for background. */ + y -= 4; } /* Top left corner, below File */ if (stamp_data.note[0]) { - text_width = BMF_GetStringWidth(font, stamp_data.note); - buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x-1, y-1, x+text_width+text_pad+1, y+font_height+1); - BMF_DrawStringBuf(font, stamp_data.note, x+(text_pad/2), y, scene->r.fg_stamp, rect, rectf, width, height, channels); - y -= font_height+2; /* Top and bottom 1 pix padding each */ + BLF_width_and_height(stamp_data.note, &w, &h); + y -= h; + + /* and space for background. */ + buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, 0, y-2, w+3, y+h+2); + + BLF_position(x, y+1, 0.0); + BLF_draw_buffer(stamp_data.note); + + /* the extra pixel for background. */ + y -= 4; } /* Top left corner, below File (or Note) */ if (stamp_data.date[0]) { - text_width = BMF_GetStringWidth(font, stamp_data.date); - buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x-1, y-1, x+text_width+text_pad+1, y+font_height+1); - BMF_DrawStringBuf(font, stamp_data.date, x+(text_pad/2), y, scene->r.fg_stamp, rect, rectf, width, height, channels); + BLF_width_and_height(stamp_data.date, &w, &h); + y -= h; + + /* and space for background. */ + buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, 0, y-3, w+3, y+h+3); + + BLF_position(x, y, 0.0); + BLF_draw_buffer(stamp_data.date); } + x= 0; + y= 0; + /* Bottom left corner, leaving space for timing */ if (stamp_data.marker[0]) { - x = 1; - y = font_height+2+1; /* 2 for padding in TIME|FRAME fields below and 1 for padding in this one */ - text_width = BMF_GetStringWidth(font, stamp_data.marker); - buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x-1, y-1, x+text_width+text_pad+1, y+font_height+1); - BMF_DrawStringBuf(font, stamp_data.marker, x+(text_pad/2), y, scene->r.fg_stamp, rect, rectf, width, height, channels); + BLF_width_and_height(stamp_data.marker, &w, &h); + + /* extra space for background. */ + buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x, y, w+2, y+h+3); + + /* and pad the text. */ + BLF_position(x, y+3, 0.0); + BLF_draw_buffer(stamp_data.marker); + + /* space width. */ + x += w + pad; } /* Left bottom corner */ if (stamp_data.time[0]) { - x = 1; - y = 1; - text_width = BMF_GetStringWidth(font, stamp_data.time); - buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x-1, y-1, x+text_width+text_pad+1, y+font_height+1); - BMF_DrawStringBuf(font, stamp_data.time, x+(text_pad/2), y, scene->r.fg_stamp, rect, rectf, width, height, channels); - x += text_width+text_pad+2; /* Both sides have 1 pix additional padding each */ + BLF_width_and_height(stamp_data.time, &w, &h); + + /* extra space for background */ + buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x, y, x+w+2, y+h+3); + + /* and pad the text. */ + BLF_position(x, y+3, 0.0); + BLF_draw_buffer(stamp_data.time); + + /* space width. */ + x += w + pad; } if (stamp_data.frame[0]) { - text_width = BMF_GetStringWidth(font, stamp_data.frame); - /* Left bottom corner (after SMPTE if exists) */ - if (!stamp_data.time[0]) x = 1; - y = 1; - buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x-1, y-1, x+text_width+text_pad+1, y+font_height+1); - BMF_DrawStringBuf(font, stamp_data.frame, x+(text_pad/2), y, scene->r.fg_stamp, rect, rectf, width, height, channels); + BLF_width_and_height(stamp_data.frame, &w, &h); + + /* extra space for background. */ + buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x, y, x+w+2, y+h+3); + + /* and pad the text. */ + BLF_position(x, y+3, 0.0); + + BLF_draw_buffer(stamp_data.frame); + + /* space width. */ + x += w + pad; } if (stamp_data.camera[0]) { - text_width = BMF_GetStringWidth(font, stamp_data.camera); - /* Center of bottom edge */ - x = (width/2) - (BMF_GetStringWidth(font, stamp_data.camera)/2); - y = 1; - buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x-1, y-1, x+text_width+text_pad+1, y+font_height+1); - BMF_DrawStringBuf(font, stamp_data.camera, x+(text_pad/2), y, scene->r.fg_stamp, rect, rectf, width, height, channels); + BLF_width_and_height(stamp_data.camera, &w, &h); + + /* extra space for background. */ + buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x, y, x+w+2, y+h+3); + BLF_position(x, y+3, 0.0); + BLF_draw_buffer(stamp_data.camera); } if (stamp_data.scene[0]) { - text_width = BMF_GetStringWidth(font, stamp_data.scene); - /* Bottom right corner */ - x = width - (text_width+1+text_pad); - y = 1; - buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x-1, y-1, x+text_width+text_pad+1, y+font_height+1); - BMF_DrawStringBuf(font, stamp_data.scene, x+(text_pad/2), y, scene->r.fg_stamp, rect, rectf, width, height, channels); + BLF_width_and_height(stamp_data.scene, &w, &h); + + /* Bottom right corner, with an extra space because blenfont is too strict! */ + x= width - w - 2; + + /* extra space for background. */ + buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x, y, x+w+3, y+h+3); + + /* and pad the text. */ + BLF_position(x, y+3, 0.0); + BLF_draw_buffer(stamp_data.scene); } if (stamp_data.strip[0]) { - text_width = BMF_GetStringWidth(font, stamp_data.strip); - /* Top right corner */ - x = width - (text_width+1+text_pad); - y = height - font_height - 1; - buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x-1, y-1, x+text_width+text_pad+1, y+font_height+1); - BMF_DrawStringBuf(font, stamp_data.strip, x+(text_pad/2), y, scene->r.fg_stamp, rect, rectf, width, height, channels); - } -#endif // 0 XXX + BLF_width_and_height(stamp_data.scene, &w, &h); + + /* Top right corner, with an extra space because blenfont is too strict! */ + x= width - w - pad; + y= height - h; + + /* extra space for background. */ + buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x, y-3, x+w+pad, y+h+3); + + BLF_position(x, y, 0.0); + BLF_draw_buffer(stamp_data.strip); + } + + /* cleanup the buffer. */ + BLF_buffer(NULL, NULL, 0, 0, 0); } void BKE_stamp_info(Scene *scene, struct ImBuf *ibuf) diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c index a72f26f6157..2f0e0931588 100644 --- a/source/blender/blenkernel/intern/ipo.c +++ b/source/blender/blenkernel/intern/ipo.c @@ -160,7 +160,7 @@ static AdrBit2Path ma_mode_bits[]= { // {MA_SHADOW, "shadow", 0}, // {MA_SHLESS, "shadeless", 0}, // ... - {MA_RAYTRANSP, "raytrace_transparency.enabled", 0}, + {MA_RAYTRANSP, "transparency", 0}, {MA_RAYMIRROR, "raytrace_mirror.enabled", 0}, // {MA_HALO, "type", MA_TYPE_HALO} }; diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 90ab4e05d44..3c8bf9200f8 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -567,7 +567,7 @@ void free_libblock(ListBase *lb, void *idv) //XXX free_script((Script *)id); break; case ID_SO: - sound_free_sound((bSound *)id); + sound_free((bSound*)id); break; case ID_GR: free_group((Group *)id); @@ -1030,6 +1030,20 @@ static void lib_indirect_test_id(ID *id) } } +void tag_main(struct Main *mainvar, int tag) +{ + ListBase *lbarray[MAX_LIBARRAY]; + ID *id; + 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; + } + } +} /* if lib!=NULL, only all from lib local */ void all_local(Library *lib, int untagged_only) diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index 08a19cada7d..53de570b55e 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -170,7 +170,22 @@ void init_material(Material *ma) ma->sss_front= 1.0f; ma->sss_back= 1.0f; - ma->mode= MA_TRACEBLE|MA_SHADBUF|MA_SHADOW|MA_RADIO|MA_RAYBIAS|MA_TANGENT_STR; + ma->vol.density = 1.0f; + ma->vol.emission = 0.0f; + ma->vol.absorption = 1.0f; + ma->vol.scattering = 1.0f; + ma->vol.emission_col[0] = ma->vol.emission_col[1] = ma->vol.emission_col[2] = 1.0f; + ma->vol.absorption_col[0] = ma->vol.absorption_col[1] = ma->vol.absorption_col[2] = 0.0f; + ma->vol.density_scale = 1.0f; + ma->vol.depth_cutoff = 0.01f; + ma->vol.stepsize_type = MA_VOL_STEP_RANDOMIZED; + ma->vol.stepsize = 0.2f; + ma->vol.shade_stepsize = 0.2f; + ma->vol.shade_type = MA_VOL_SHADE_SINGLE; + ma->vol.shadeflag |= MA_VOL_PRECACHESHADING; + ma->vol.precache_resolution = 50; + + ma->mode= MA_TRACEBLE|MA_SHADBUF|MA_SHADOW|MA_RAYBIAS|MA_TANGENT_STR|MA_ZTRANSP; ma->preview = NULL; } @@ -678,9 +693,6 @@ static void do_init_render_material(Material *ma, int r_mode, float *amb) if(needtang) ma->mode |= MA_NORMAP_TANG; else ma->mode &= ~MA_NORMAP_TANG; - if(r_mode & R_RADIO) - if(ma->mode & MA_RADIO) needuv= 1; - if(ma->mode & (MA_VERTEXCOL|MA_VERTEXCOLP|MA_FACETEXTURE)) { needuv= 1; if(r_mode & R_OSA) ma->texco |= TEXCO_OSA; /* for texfaces */ @@ -689,7 +701,7 @@ static void do_init_render_material(Material *ma, int r_mode, float *amb) /* since the raytracer doesnt recalc O structs for each ray, we have to preset them all */ if(r_mode & R_RAYTRACE) { - if(ma->mode & (MA_RAYMIRROR|MA_RAYTRANSP|MA_SHADOW_TRA)) { + if((ma->mode & (MA_RAYMIRROR|MA_SHADOW_TRA)) || ((ma->mode && MA_TRANSP) && (ma->mode & MA_RAYTRANSP))) { ma->texco |= NEED_UV|TEXCO_ORCO|TEXCO_REFL|TEXCO_NORM; if(r_mode & R_OSA) ma->texco |= TEXCO_OSA; } diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index 03c6942a318..9bb418c4f86 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -79,6 +79,7 @@ #include "BKE_main.h" #include "BKE_anim.h" +#include "BKE_action.h" #include "BKE_bmesh.h" // XXX #include "BKE_booleanops.h" #include "BKE_cloth.h" @@ -5620,6 +5621,7 @@ static void hookModifier_copyData(ModifierData *md, ModifierData *target) thmd->indexar = MEM_dupallocN(hmd->indexar); memcpy(thmd->parentinv, hmd->parentinv, sizeof(hmd->parentinv)); strncpy(thmd->name, hmd->name, 32); + strncpy(thmd->subtarget, hmd->subtarget, 32); } CustomDataMask hookModifier_requiredDataMask(Object *ob, ModifierData *md) @@ -5664,9 +5666,11 @@ static void hookModifier_updateDepgraph(ModifierData *md, DagForest *forest, Sce if (hmd->object) { DagNode *curNode = dag_get_node(forest, hmd->object); - - dag_add_relation(forest, curNode, obNode, DAG_RL_OB_DATA, - "Hook Modifier"); + + if (hmd->subtarget[0]) + dag_add_relation(forest, curNode, obNode, DAG_RL_OB_DATA|DAG_RL_DATA_DATA, "Hook Modifier"); + else + dag_add_relation(forest, curNode, obNode, DAG_RL_OB_DATA, "Hook Modifier"); } } @@ -5675,12 +5679,22 @@ static void hookModifier_deformVerts( float (*vertexCos)[3], int numVerts, int useRenderParams, int isFinalCalc) { HookModifierData *hmd = (HookModifierData*) md; - float vec[3], mat[4][4]; + bPoseChannel *pchan= get_pose_channel(hmd->object->pose, hmd->subtarget); + float vec[3], mat[4][4], dmat[4][4]; int i; DerivedMesh *dm = derivedData; - + + /* get world-space matrix of target, corrected for the space the verts are in */ + if (hmd->subtarget[0] && pchan) { + /* bone target if there's a matching pose-channel */ + Mat4MulMat4(dmat, pchan->pose_mat, hmd->object->obmat); + } + else { + /* just object target */ + Mat4CpyMat4(dmat, hmd->object->obmat); + } Mat4Invert(ob->imat, ob->obmat); - Mat4MulSerie(mat, ob->imat, hmd->object->obmat, hmd->parentinv, + Mat4MulSerie(mat, ob->imat, dmat, hmd->parentinv, NULL, NULL, NULL, NULL, NULL); /* vertex indices? */ @@ -5737,7 +5751,8 @@ static void hookModifier_deformVerts( } } } - } else { /* vertex group hook */ + } + else if(hmd->name[0]) { /* vertex group hook */ bDeformGroup *curdef; Mesh *me = ob->data; int index = 0; @@ -5823,26 +5838,6 @@ static void smokeModifier_initData(ModifierData *md) smd->coll = NULL; smd->type = 0; smd->time = -1; - - /* - smd->fluid = NULL; - smd->maxres = 48; - smd->amplify = 4; - smd->omega = 0.5; - smd->time = 0; - smd->flags = 0; - smd->noise = MOD_SMOKE_NOISEWAVE; - smd->visibility = 1; - - // init 3dview buffer - smd->tvox = NULL; - smd->tray = NULL; - smd->tvoxbig = NULL; - smd->traybig = NULL; - smd->viewsettings = 0; - smd->bind = NULL; - smd->max_textures = 0; - */ } static void smokeModifier_freeData(ModifierData *md) @@ -5880,8 +5875,7 @@ static void smokeModifier_updateDepgraph( ModifierData *md, DagForest *forest, Scene *scene, Object *ob, DagNode *obNode) { - SmokeModifierData *smd = (SmokeModifierData *) md; - /* + /*SmokeModifierData *smd = (SmokeModifierData *) md; if(smd && (smd->type & MOD_SMOKE_TYPE_DOMAIN) && smd->domain) { if(smd->domain->fluid_group) @@ -5915,7 +5909,7 @@ static void clothModifier_initData(ModifierData *md) clmd->sim_parms = MEM_callocN(sizeof(ClothSimSettings), "cloth sim parms"); clmd->coll_parms = MEM_callocN(sizeof(ClothCollSettings), "cloth coll parms"); - clmd->point_cache = BKE_ptcache_add(); + clmd->point_cache = BKE_ptcache_add(&clmd->ptcaches); /* check for alloc failing */ if(!clmd->sim_parms || !clmd->coll_parms || !clmd->point_cache) @@ -5994,12 +5988,13 @@ static void clothModifier_copyData(ModifierData *md, ModifierData *target) MEM_freeN(tclmd->sim_parms); if(tclmd->coll_parms) MEM_freeN(tclmd->coll_parms); - if(tclmd->point_cache) - BKE_ptcache_free(tclmd->point_cache); + + BKE_ptcache_free_list(&tclmd->ptcaches); + tclmd->point_cache = NULL; tclmd->sim_parms = MEM_dupallocN(clmd->sim_parms); tclmd->coll_parms = MEM_dupallocN(clmd->coll_parms); - tclmd->point_cache = BKE_ptcache_copy(clmd->point_cache); + tclmd->point_cache = BKE_ptcache_copy_list(&tclmd->ptcaches, &clmd->ptcaches); tclmd->clothObject = NULL; } @@ -6023,8 +6018,9 @@ static void clothModifier_freeData(ModifierData *md) MEM_freeN(clmd->sim_parms); if(clmd->coll_parms) MEM_freeN(clmd->coll_parms); - if(clmd->point_cache) - BKE_ptcache_free(clmd->point_cache); + + BKE_ptcache_free_list(&clmd->ptcaches); + clmd->point_cache = NULL; } } @@ -8101,14 +8097,13 @@ static DerivedMesh *multiresModifier_applyModifier(ModifierData *md, Object *ob, int useRenderParams, int isFinalCalc) { MultiresModifierData *mmd = (MultiresModifierData*)md; - Mesh *me = get_mesh(ob); DerivedMesh *final; /* TODO: for now just skip a level1 mesh */ if(mmd->lvl == 1) return dm; - final = multires_dm_create_from_derived(mmd, dm, me, useRenderParams, isFinalCalc); + final = multires_dm_create_from_derived(mmd, 0, dm, ob, useRenderParams, isFinalCalc); if(mmd->undo_signal && mmd->undo_verts && mmd->undo_verts_tot == final->getNumVerts(final)) { int i; MVert *dst = CDDM_get_verts(final); @@ -8603,7 +8598,9 @@ ModifierTypeInfo *modifierType_getInfo(ModifierType type) mti->type = eModifierTypeType_OnlyDeform; mti->initData = smokeModifier_initData; mti->freeData = smokeModifier_freeData; - mti->flags = eModifierTypeFlag_AcceptsMesh; + mti->flags = eModifierTypeFlag_AcceptsMesh + | eModifierTypeFlag_UsesPointCache + | eModifierTypeFlag_Single; mti->deformVerts = smokeModifier_deformVerts; mti->dependsOnTime = smokeModifier_dependsOnTime; mti->updateDepgraph = smokeModifier_updateDepgraph; @@ -8634,7 +8631,7 @@ ModifierTypeInfo *modifierType_getInfo(ModifierType type) mti = INIT_TYPE(Surface); mti->type = eModifierTypeType_OnlyDeform; mti->initData = surfaceModifier_initData; - mti->flags = eModifierTypeFlag_AcceptsMesh; + mti->flags = eModifierTypeFlag_AcceptsMesh|eModifierTypeFlag_NoUserAdd; mti->dependsOnTime = surfaceModifier_dependsOnTime; mti->freeData = surfaceModifier_freeData; mti->deformVerts = surfaceModifier_deformVerts; diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index df8eb47831e..2555bc6de27 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -204,10 +204,11 @@ static void VecAddUf(float a[3], float b[3]) a[2] += b[2]; } -static void multires_subdisp(DerivedMesh *orig, Mesh *me, DerivedMesh *final, int lvl, int totlvl, +static void multires_subdisp(DerivedMesh *orig, Object *ob, DerivedMesh *final, int lvl, int totlvl, int totsubvert, int totsubedge, int totsubface, int addverts) { DerivedMesh *mrdm; + Mesh *me = ob->data; MultiresModifierData mmd_sub; MVert *mvs = CDDM_get_verts(final); MVert *mvd, *mvd_f1, *mvs_f1, *mvd_f3, *mvd_f4; @@ -220,8 +221,9 @@ static void multires_subdisp(DerivedMesh *orig, Mesh *me, DerivedMesh *final, in int skip = multires_side_tot[totlvl - lvl] - 1; int i, j, k; + memset(&mmd_sub, 0, sizeof(MultiresModifierData)); mmd_sub.lvl = mmd_sub.totlvl = totlvl; - mrdm = multires_dm_create_from_derived(&mmd_sub, orig, me, 0, 0); + mrdm = multires_dm_create_from_derived(&mmd_sub, 1, orig, ob, 0, 0); mvd = CDDM_get_verts(mrdm); /* Need to map from ccg to mrdm */ @@ -394,7 +396,7 @@ static void multires_subdisp(DerivedMesh *orig, Mesh *me, DerivedMesh *final, in } } - final->needsFree = 1; + final->needsFree = 1; final->release(final); mrdm->needsFree = 1; MultiresDM_mark_as_modified(mrdm); @@ -465,8 +467,10 @@ void multiresModifier_subdivide(MultiresModifierData *mmd, Object *ob, int dista MultiresModifierData mmd_sub; orig = CDDM_from_mesh(me, NULL); + memset(&mmd_sub, 0, sizeof(MultiresModifierData)); mmd_sub.lvl = mmd_sub.totlvl = mmd->lvl; - mrdm = multires_dm_create_from_derived(&mmd_sub, orig, me, 0, 0); + mmd_sub.simple = simple; + mrdm = multires_dm_create_from_derived(&mmd_sub, 1, orig, ob, 0, 0); totsubvert = mrdm->getNumVerts(mrdm); totsubedge = mrdm->getNumEdges(mrdm); totsubface = mrdm->getNumTessFaces(mrdm); @@ -495,7 +499,7 @@ void multiresModifier_subdivide(MultiresModifierData *mmd, Object *ob, int dista orig = CDDM_from_mesh(me, NULL); - multires_subdisp(orig, me, final, mmd->lvl, mmd->totlvl, totsubvert, totsubedge, totsubface, 0); + multires_subdisp(orig, ob, final, mmd->lvl, mmd->totlvl, totsubvert, totsubedge, totsubface, 0); orig->needsFree = 1; orig->release(orig); @@ -1164,9 +1168,11 @@ static void multiresModifier_disp_run(DerivedMesh *dm, MVert *subco, int invert) static void multiresModifier_update(DerivedMesh *dm) { + Object *ob; Mesh *me; MDisps *mdisps; + ob = MultiresDM_get_object(dm); me = MultiresDM_get_mesh(dm); mdisps = CustomData_get_layer(&me->fdata, CD_MDISPS); @@ -1187,7 +1193,7 @@ static void multiresModifier_update(DerivedMesh *dm) (includes older displacements but not new sculpts) */ mmd.totlvl = totlvl; mmd.lvl = lvl; - subco_dm = multires_dm_create_from_derived(&mmd, orig, me, 0, 0); + subco_dm = multires_dm_create_from_derived(&mmd, 1, orig, ob, 0, 0); cur_lvl_orig_verts = CDDM_get_verts(subco_dm); /* Subtract the original vertex cos from the new vertex cos */ @@ -1197,7 +1203,7 @@ static void multiresModifier_update(DerivedMesh *dm) final = multires_subdisp_pre(dm, totlvl - lvl, 0); - multires_subdisp(orig, me, final, lvl, totlvl, dm->getNumVerts(dm), dm->getNumEdges(dm), + multires_subdisp(orig, ob, final, lvl, totlvl, dm->getNumVerts(dm), dm->getNumEdges(dm), dm->getNumTessFaces(dm), 1); subco_dm->release(subco_dm); @@ -1224,7 +1230,7 @@ void multires_force_update(Object *ob) } } -struct DerivedMesh *multires_dm_create_from_derived(MultiresModifierData *mmd, DerivedMesh *dm, Mesh *me, +struct DerivedMesh *multires_dm_create_from_derived(MultiresModifierData *mmd, int local_mmd, DerivedMesh *dm, Object *ob, int useRenderParams, int isFinalCalc) { SubsurfModifierData smd; @@ -1233,7 +1239,8 @@ struct DerivedMesh *multires_dm_create_from_derived(MultiresModifierData *mmd, D int i; ms.mmd = mmd; - ms.me = me; + ms.ob = ob; + ms.local_mmd = local_mmd; memset(&smd, 0, sizeof(SubsurfModifierData)); smd.levels = smd.renderLevels = mmd->lvl - 1; diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c index c41c4ae78e4..480c79fbc1a 100644 --- a/source/blender/blenkernel/intern/nla.c +++ b/source/blender/blenkernel/intern/nla.c @@ -291,7 +291,7 @@ NlaStrip *add_nlastrip (bAction *act) /* determine initial range * - strip length cannot be 0... ever... */ - calc_action_range(strip->act, &strip->actstart, &strip->actend, 1); + calc_action_range(strip->act, &strip->actstart, &strip->actend, 0); strip->start = strip->actstart; strip->end = (IS_EQ(strip->actstart, strip->actend)) ? (strip->actstart + 1.0f): (strip->actend); diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 0f42ba0d2e2..bd6919dc115 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -950,9 +950,6 @@ bNode *nodeAddNodeType(bNodeTree *ntree, int type, bNodeTree *ngroup, ID *id) if(ntype->initfunc!=NULL) ntype->initfunc(node); - if(type==TEX_NODE_OUTPUT) - ntreeTexAssignIndex(ntree, node); - nodeAddSockets(node, ntype); return node; @@ -1021,9 +1018,6 @@ bNode *nodeCopyNode(struct bNodeTree *ntree, struct bNode *node, int internal) nnode->new_node= NULL; nnode->preview= NULL; - if(node->type==TEX_NODE_OUTPUT) - ntreeTexAssignIndex(ntree, node); - return nnode; } @@ -3112,3 +3106,29 @@ void free_nodesystem(void) BLI_freelistN(&node_all_shaders); BLI_freelistN(&node_all_textures); } + +/* called from unlink_scene, when deleting a scene goes over all scenes + * other than the input, checks if they have render layer nodes referencing + * the to-be-deleted scene, and resets them to NULL. */ + +/* XXX needs to get current scene then! */ +void clear_scene_in_nodes(Main *bmain, Scene *sce) +{ + Scene *sce1; + bNode *node; + + for(sce1= bmain->scene.first; sce1; sce1=sce1->id.next) { + if(sce1!=sce) { + if(sce1->nodetree) { + for(node= sce1->nodetree->nodes.first; node; node= node->next) { + if(node->type==CMP_NODE_R_LAYERS) { + Scene *nodesce= (Scene *)node->id; + + if (nodesce==sce) node->id = NULL; + } + } + } + } + } +} + diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 160922e3954..cdcd90b6ebf 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -108,6 +108,7 @@ #include "BKE_sca.h" #include "BKE_scene.h" #include "BKE_screen.h" +#include "BKE_sculpt.h" #include "BKE_softbody.h" #include "LBM_fluidsim.h" @@ -223,6 +224,34 @@ void object_free_display(Object *ob) freedisplist(&ob->disp); } +void free_sculptsession(SculptSession **ssp) +{ + if(ssp && *ssp) { + SculptSession *ss = *ssp; + if(ss->projverts) + MEM_freeN(ss->projverts); + + if(ss->fmap) + MEM_freeN(ss->fmap); + + if(ss->fmap_mem) + MEM_freeN(ss->fmap_mem); + + if(ss->texcache) + MEM_freeN(ss->texcache); + + if(ss->layer_disps) + MEM_freeN(ss->layer_disps); + + if(ss->mesh_co_orig) + MEM_freeN(ss->mesh_co_orig); + + MEM_freeN(ss); + + *ssp = NULL; + } +} + /* do not free object itself */ void free_object(Object *ob) { @@ -277,6 +306,10 @@ void free_object(Object *ob) if(ob->soft) sbFree(ob->soft); if(ob->bsoft) bsbFree(ob->bsoft); if(ob->gpulamp.first) GPU_lamp_free(ob); + + free_sculptsession(&ob->sculpt); + + if(ob->pc_ids.first) BLI_freelistN(&ob->pc_ids); } static void unlink_object__unlinkModifierLinks(void *userData, Object *ob, Object **obpoin) @@ -986,6 +1019,8 @@ Object *add_only_object(int type, char *name) ob->fluidsimFlag = 0; ob->fluidsimSettings = NULL; + ob->pc_ids.first = ob->pc_ids.last = NULL; + return ob; } @@ -1027,7 +1062,7 @@ SoftBody *copy_softbody(SoftBody *sb) sbn->scratch= NULL; - sbn->pointcache= BKE_ptcache_copy(sb->pointcache); + sbn->pointcache= BKE_ptcache_copy_list(&sbn->ptcaches, &sb->ptcaches); return sbn; } @@ -1086,7 +1121,7 @@ ParticleSystem *copy_particlesystem(ParticleSystem *psys) psysn->reactevents.first = psysn->reactevents.last = NULL; psysn->renderdata = NULL; - psysn->pointcache= BKE_ptcache_copy(psys->pointcache); + psysn->pointcache= BKE_ptcache_copy_list(&psysn->ptcaches, &psys->ptcaches); id_us_plus((ID *)psysn->part); @@ -1212,6 +1247,9 @@ Object *copy_object(Object *ob) copy_defgroups(&obn->defbase, &ob->defbase); copy_constraints(&obn->constraints, &ob->constraints); + obn->mode = 0; + obn->sculpt = NULL; + /* increase user numbers */ id_us_plus((ID *)obn->data); id_us_plus((ID *)obn->dup_group); @@ -1235,7 +1273,8 @@ Object *copy_object(Object *ob) obn->derivedFinal = NULL; obn->gpulamp.first = obn->gpulamp.last = NULL; - + obn->pc_ids.first = obn->pc_ids.last = NULL; + return obn; } @@ -2501,3 +2540,61 @@ int ray_hit_boundbox(struct BoundBox *bb, float ray_start[3], float ray_normal[3 return result; } + +static int pc_cmp(void *a, void *b) +{ + LinkData *ad = a, *bd = b; + if((int)ad->data > (int)bd->data) + return 1; + else return 0; +} + +int object_insert_ptcache(Object *ob) +{ + LinkData *link = NULL; + int i = 0; + + BLI_sortlist(&ob->pc_ids, pc_cmp); + + for(link=ob->pc_ids.first, i = 0; link; link=link->next, i++) + { + int index =(int)link->data; + + if(i < index) + break; + } + + link = MEM_callocN(sizeof(LinkData), "PCLink"); + link->data = (void *)i; + BLI_addtail(&ob->pc_ids, link); + + return i; +} + +#if 0 +static int pc_findindex(ListBase *listbase, int index) +{ + LinkData *link= NULL; + int number= 0; + + if (listbase == NULL) return -1; + + link= listbase->first; + while (link) { + if ((int)link->data == index) + return number; + + number++; + link= link->next; + } + + return -1; +} + +void object_delete_ptcache(Object *ob, int index) +{ + int list_index = pc_findindex(&ob->pc_ids, index); + LinkData *link = BLI_findlink(&ob->pc_ids, list_index); + BLI_freelinkN(&ob->pc_ids, link); +} +#endif diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c index 590189fbd5d..3e47c1006e5 100644 --- a/source/blender/blenkernel/intern/packedFile.c +++ b/source/blender/blenkernel/intern/packedFile.c @@ -123,7 +123,7 @@ int countPackedFiles(Main *bmain) { Image *ima; VFont *vf; - bSample *sample; + bSound *sound; int count = 0; // let's check if there are packed files... @@ -135,10 +135,9 @@ int countPackedFiles(Main *bmain) if(vf->packedfile) count++; - if(samples) - for(sample=samples->first; sample; sample=sample->id.next) - if(sample->packedfile) - count++; + for(sound=bmain->sound.first; sound; sound=sound->id.next) + if(sound->packedfile) + count++; return count; } @@ -208,8 +207,8 @@ void packAll(Main *bmain, ReportList *reports) { Image *ima; VFont *vf; - bSample *sample; - + bSound *sound; + for(ima=bmain->image.first; ima; ima=ima->id.next) if(ima->packedfile == NULL) ima->packedfile = newPackedFile(reports, ima->name); @@ -218,10 +217,9 @@ void packAll(Main *bmain, ReportList *reports) if(vf->packedfile == NULL) vf->packedfile = newPackedFile(reports, vf->name); - if(samples) - for(sample=samples->first; sample; sample=sample->id.next) - if(sample->packedfile == NULL) - sound_set_packedfile(sample, newPackedFile(reports, sample->name)); + for(sound=bmain->sound.first; sound; sound=sound->id.next) + if(sound->packedfile == NULL) + sound->packedfile = newPackedFile(reports, sound->name); } @@ -456,28 +454,26 @@ int unpackVFont(ReportList *reports, VFont *vfont, int how) return (ret_value); } -int unpackSample(ReportList *reports, bSample *sample, int how) +int unpackSound(ReportList *reports, bSound *sound, int how) { char localname[FILE_MAXDIR + FILE_MAX], fi[FILE_MAX]; char *newname; int ret_value = RET_ERROR; - PackedFile *pf; - - if (sample != NULL) { - strcpy(localname, sample->name); + + if (sound != NULL) { + strcpy(localname, sound->name); BLI_splitdirstring(localname, fi); - sprintf(localname, "//samples/%s", fi); - - newname = unpackFile(reports, sample->name, localname, sample->packedfile, how); + sprintf(localname, "//sounds/%s", fi); + + newname = unpackFile(reports, sound->name, localname, sound->packedfile, how); if (newname != NULL) { - strcpy(sample->name, newname); + strcpy(sound->name, newname); MEM_freeN(newname); - pf = sample->packedfile; - // because samples and sounds can point to the - // same packedfile we have to check them all - sound_set_packedfile(sample, NULL); - freePackedFile(pf); + freePackedFile(sound->packedfile); + sound->packedfile = 0; + + sound_load(NULL, sound); ret_value = RET_OK; } @@ -515,7 +511,7 @@ void unpackAll(Main *bmain, ReportList *reports, int how) { Image *ima; VFont *vf; - bSample *sample; + bSound *sound; for(ima=bmain->image.first; ima; ima=ima->id.next) if(ima->packedfile) @@ -525,9 +521,8 @@ void unpackAll(Main *bmain, ReportList *reports, int how) if(vf->packedfile) unpackVFont(reports, vf, how); - if(samples) - for(sample=samples->first; sample; sample=sample->id.next) - if(sample->packedfile) - unpackSample(reports, sample, how); + for(sound=bmain->sound.first; sound; sound=sound->id.next) + if(sound->packedfile) + unpackSound(reports, sound, how); } diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c new file mode 100644 index 00000000000..7c5b2b82b4b --- /dev/null +++ b/source/blender/blenkernel/intern/paint.c @@ -0,0 +1,189 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2009 by Nicholas Bishop + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include "MEM_guardedalloc.h" + +#include "DNA_brush_types.h" +#include "DNA_object_types.h" +#include "DNA_scene_types.h" + +#include "BKE_brush.h" +#include "BKE_global.h" +#include "BKE_library.h" +#include "BKE_paint.h" + +#include <stdlib.h> +#include <string.h> + +const char PAINT_CURSOR_SCULPT[3] = {255, 100, 100}; +const char PAINT_CURSOR_VERTEX_PAINT[3] = {255, 255, 255}; +const char PAINT_CURSOR_WEIGHT_PAINT[3] = {200, 200, 255}; +const char PAINT_CURSOR_TEXTURE_PAINT[3] = {255, 255, 255}; + +Paint *paint_get_active(Scene *sce) +{ + if(sce && sce->basact && sce->basact->object) { + ToolSettings *ts = sce->toolsettings; + + switch(sce->basact->object->mode) { + case OB_MODE_SCULPT: + return &ts->sculpt->paint; + case OB_MODE_VERTEX_PAINT: + return &ts->vpaint->paint; + case OB_MODE_WEIGHT_PAINT: + return &ts->wpaint->paint; + case OB_MODE_TEXTURE_PAINT: + return &ts->imapaint.paint; + } + } + + return NULL; +} + +Brush *paint_brush(Paint *p) +{ + return p && p->brushes ? p->brushes[p->active_brush_index] : NULL; +} + +void paint_brush_set(Paint *p, Brush *br) +{ + if(p && !br) { + /* Setting to NULL removes the current slot */ + paint_brush_slot_remove(p); + } + else if(p) { + int found = 0; + + if(p->brushes) { + int i; + + /* See if there's already a slot with the brush */ + for(i = 0; i < p->brush_count; ++i) { + if(p->brushes[i] == br) { + p->active_brush_index = i; + found = 1; + break; + } + } + + } + + if(!found) { + paint_brush_slot_add(p); + id_us_plus(&br->id); + } + + /* Make sure the current slot is the new brush */ + p->brushes[p->active_brush_index] = br; + } +} + +static void paint_brush_slots_alloc(Paint *p, const int count) +{ + p->brush_count = count; + if(count == 0) + p->brushes = NULL; + else + p->brushes = MEM_callocN(sizeof(Brush*) * count, "Brush slots"); +} + +void paint_brush_slot_add(Paint *p) +{ + if(p) { + Brush **orig = p->brushes; + int orig_count = p->brushes ? p->brush_count : 0; + + /* Increase size of brush slot array */ + paint_brush_slots_alloc(p, orig_count + 1); + if(orig) { + memcpy(p->brushes, orig, sizeof(Brush*) * orig_count); + MEM_freeN(orig); + } + + p->active_brush_index = orig_count; + } +} + +void paint_brush_slot_remove(Paint *p) +{ + if(p && p->brushes) { + Brush **orig = p->brushes; + int src, dst; + + /* Decrease size of brush slot array */ + paint_brush_slots_alloc(p, p->brush_count - 1); + if(p->brushes) { + for(src = 0, dst = 0; dst < p->brush_count; ++src) { + if(src != p->active_brush_index) { + p->brushes[dst] = orig[src]; + ++dst; + } + } + } + MEM_freeN(orig); + + if(p->active_brush_index >= p->brush_count) + p->active_brush_index = p->brush_count - 1; + if(p->active_brush_index < 0) + p->active_brush_index = 0; + } +} + +int paint_facesel_test(Object *ob) +{ + return (G.f&G_FACESELECT) && (ob && (ob->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT|OB_MODE_TEXTURE_PAINT))); + +} + +void paint_init(Paint *p, const char col[3]) +{ + Brush *brush; + + /* If there's no brush, create one */ + brush = paint_brush(p); + brush_check_exists(&brush, "Brush"); + paint_brush_set(p, brush); + + memcpy(p->paint_cursor_col, col, 3); + p->paint_cursor_col[3] = 128; +} + +void free_paint(Paint *paint) +{ + if(paint->brushes) + MEM_freeN(paint->brushes); +} + +void copy_paint(Paint *orig, Paint *new) +{ + if(orig->brushes) { + int i; + new->brushes = MEM_dupallocN(orig->brushes); + for(i = 0; i < orig->brush_count; ++i) + id_us_plus((ID *)new->brushes[i]); + } +} diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index e47501335ed..3d895c37884 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -321,7 +321,7 @@ int psys_ob_has_hair(Object *ob) } int psys_in_edit_mode(Scene *scene, ParticleSystem *psys) { - return ((G.f & G_PARTICLEEDIT) && psys==psys_get_current((scene->basact)->object) && psys->edit); + return ((scene->basact->object->mode & OB_MODE_PARTICLE_EDIT) && psys==psys_get_current((scene->basact)->object) && psys->edit); } int psys_check_enabled(Object *ob, ParticleSystem *psys) { @@ -431,9 +431,6 @@ void psys_free(Object *ob, ParticleSystem * psys) int nr = 0; ParticleSystem * tpsys; - if(ob->particlesystem.first == NULL && G.f & G_PARTICLEEDIT) - G.f &= ~G_PARTICLEEDIT; - psys_free_path_cache(psys); free_hair(psys, 1); @@ -484,8 +481,8 @@ void psys_free(Object *ob, ParticleSystem * psys) if(psys->reactevents.first) BLI_freelistN(&psys->reactevents); - if(psys->pointcache) - BKE_ptcache_free(psys->pointcache); + BKE_ptcache_free_list(&psys->ptcaches); + psys->pointcache = NULL; if(psys->targets.first) BLI_freelistN(&psys->targets); @@ -980,13 +977,13 @@ static void get_pointcache_keys_for_time(Object *ob, ParticleSystem *psys, int i while(pm && pm->next && (float)pm->frame < t) pm = pm->next; - copy_particle_key(key2, ((ParticleKey *)pm->data) + index, 1); - copy_particle_key(key1, ((ParticleKey *)(pm->prev)->data) + index, 1); + BKE_ptcache_make_particle_key(key2, pm->index_array ? pm->index_array[index] : index, pm->data, (float)pm->frame); + BKE_ptcache_make_particle_key(key1, pm->prev->index_array ? pm->prev->index_array[index] : index, pm->prev->data, (float)pm->prev->frame); } else if(cache->mem_cache.first) { PTCacheMem *pm2 = cache->mem_cache.first; - copy_particle_key(key2, ((ParticleKey *)pm2->data) + index, 1); - copy_particle_key(key1, ((ParticleKey *)pm2->data) + index, 1); + BKE_ptcache_make_particle_key(key2, pm2->index_array ? pm2->index_array[index] : index, pm2->data, (float)pm2->frame); + copy_particle_key(key1, key2, 1); } } } @@ -3038,7 +3035,7 @@ void object_add_particle_system(Scene *scene, Object *ob) psys->flag &= ~PSYS_CURRENT; psys = MEM_callocN(sizeof(ParticleSystem), "particle_system"); - psys->pointcache = BKE_ptcache_add(); + psys->pointcache = BKE_ptcache_add(&psys->ptcaches); BLI_addtail(&ob->particlesystem, psys); psys->part = psys_new_settings("ParticleSettings", NULL); diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 72a6bc3b862..8db4656239b 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -2260,56 +2260,21 @@ void psys_get_reactor_target(Object *ob, ParticleSystem *psys, Object **target_o void psys_make_temp_pointcache(Object *ob, ParticleSystem *psys) { PointCache *cache = psys->pointcache; - PTCacheFile *pf = NULL; - PTCacheMem *pm = NULL; PTCacheID pid; - int cfra, sfra = cache->startframe, efra = cache->endframe; - int totelem = psys->totpart; - int float_count = sizeof(ParticleKey) / sizeof(float); - int tot = totelem * float_count; if((cache->flag & PTCACHE_DISK_CACHE)==0 || cache->mem_cache.first) return; BKE_ptcache_id_from_particles(&pid, ob, psys); - for(cfra=sfra; cfra <= efra; cfra++) { - pf = BKE_ptcache_file_open(&pid, PTCACHE_FILE_READ, cfra); - - if(pf) { - pm = MEM_callocN(sizeof(PTCacheMem), "Pointcache temp mem"); - pm->data = MEM_callocN(sizeof(float)*tot, "Pointcache temp mem data"); - - if(fread(pm->data, sizeof(float), tot, pf->fp)!= tot) { - printf("Error reading from disk cache\n"); - - MEM_freeN(pm->data); - MEM_freeN(pm); - BKE_ptcache_file_close(pf); - return; - } - - pm->frame = cfra; - pm->totpoint = totelem; - - BLI_addtail(&cache->mem_cache, pm); - - BKE_ptcache_file_close(pf); - } - } + BKE_ptcache_disk_to_mem(&pid); } void psys_clear_temp_pointcache(ParticleSystem *psys) { - PTCacheMem *pm = psys->pointcache->mem_cache.first; - if((psys->pointcache->flag & PTCACHE_DISK_CACHE)==0) return; - for(; pm; pm=pm->next) { - MEM_freeN(pm->data); - } - - BLI_freelistN(&psys->pointcache->mem_cache); + BKE_ptache_free_mem(psys->pointcache); } void psys_get_pointcache_start_end(Scene *scene, ParticleSystem *psys, int *sfra, int *efra) { @@ -2318,88 +2283,6 @@ void psys_get_pointcache_start_end(Scene *scene, ParticleSystem *psys, int *sfra *sfra = MAX2(1, (int)part->sta); *efra = MIN2((int)(part->end + part->lifetime + 1.0), scene->r.efra); } -static void particle_write_state(int index, void *psys_ptr, float *data) -{ - ParticleSystem *psys= psys_ptr; - - memcpy(data, (float *)(&(psys->particles+index)->state), sizeof(ParticleKey)); -} -static void particle_read_state(int index, void *psys_ptr, float *data) -{ - ParticleSystem *psys= psys_ptr; - ParticleData *pa = psys->particles + index; - ParticleKey *key = (ParticleKey *)data; - - if(key->time > pa->state.time) - copy_particle_key(&pa->prev_state, &pa->state, 1); - - copy_particle_key(&pa->state, key, 1); -} -static void particle_cache_interpolate(int index, void *psys_ptr, float frs_sec, float cfra, float cfra1, float cfra2, float *data1, float *data2) -{ - ParticleSystem *psys= psys_ptr; - ParticleData *pa = psys->particles + index; - ParticleKey keys[4]; - float dfra; - - cfra = MIN2(cfra, pa->dietime); - cfra1 = MIN2(cfra1, pa->dietime); - cfra2 = MIN2(cfra2, pa->dietime); - - keys[1] = *((ParticleKey*)data1); - keys[2] = *((ParticleKey*)data2); - - if(cfra1 == cfra2) { - copy_particle_key(&pa->state, &keys[1], 1); - return; - } - - dfra = cfra2 - cfra1; - - VecMulf(keys[1].vel, dfra / frs_sec); - VecMulf(keys[2].vel, dfra / frs_sec); - - psys_interpolate_particle(-1, keys, (cfra - cfra1) / dfra, &pa->state, 1); - QuatInterpol(pa->state.rot, keys[1].rot,keys[2].rot, (cfra - cfra1) / dfra); - - VecMulf(pa->state.vel, frs_sec / dfra); - - pa->state.time = cfra; -} -static void write_particles_to_cache(Object *ob, ParticleSystem *psys, int cfra) -{ - PTCacheWriter writer; - PTCacheID pid; - - BKE_ptcache_id_from_particles(&pid, ob, psys); - - writer.calldata = psys; - writer.cfra = cfra; - writer.set_elem = particle_write_state; - writer.pid = &pid; - writer.totelem = psys->totpart; - - BKE_ptcache_write_cache(&writer); -} - -static int get_particles_from_cache(Scene *scene, Object *ob, ParticleSystem *psys, float cfra, int *old_frame) -{ - PTCacheReader reader; - PTCacheID pid; - - BKE_ptcache_id_from_particles(&pid, ob, psys); - - reader.calldata = psys; - reader.cfra = cfra; - reader.interpolate_elem = particle_cache_interpolate; - reader.old_frame = old_frame; - reader.pid = &pid; - reader.scene = scene; - reader.set_elem = particle_read_state; - reader.totelem = psys->totpart; - - return BKE_ptcache_read_cache(&reader); -} /************************************************/ /* Effectors */ @@ -3355,7 +3238,7 @@ static void deflect_particle(Scene *scene, Object *pob, ParticleSystemModifierDa ParticleCollision col; BVHTreeRayHit hit; float ray_dir[3], zerovec[3]={0.0,0.0,0.0}; - float radius = ((part->flag & PART_SIZE_DEFL)?pa->size:0.0f), boid_z; + float radius = ((part->flag & PART_SIZE_DEFL)?pa->size:0.0f), boid_z = 0.0f; int deflections=0, max_deflections=10; VECCOPY(col.co1, pa->prev_state.co); @@ -3843,7 +3726,7 @@ static void psys_update_path_cache(Scene *scene, Object *ob, ParticleSystemModif if((psys->part->childtype && psys->totchild != get_psys_tot_child(scene, psys)) || psys->recalc&PSYS_RECALC_RESET) alloc=1; - if(alloc || psys->recalc&PSYS_RECALC_CHILD || (psys->vgroup[PSYS_VG_DENSITY] && (G.f & G_WEIGHTPAINT))) + if(alloc || psys->recalc&PSYS_RECALC_CHILD || (psys->vgroup[PSYS_VG_DENSITY] && (ob && ob->mode & OB_MODE_WEIGHT_PAINT))) distr=1; if(distr){ @@ -4237,7 +4120,7 @@ static void system_step(Scene *scene, Object *ob, ParticleSystem *psys, Particle int totpart, oldtotpart, totchild, oldtotchild, p; float disp, *vg_vel= 0, *vg_tan= 0, *vg_rot= 0, *vg_size= 0; int init= 0, distr= 0, alloc= 0, usecache= 0, only_children_changed= 0; - int framenr, framedelta, startframe, endframe, old_framenr; + int framenr, framedelta, startframe, endframe; part= psys->part; cache= psys->pointcache; @@ -4327,8 +4210,10 @@ static void system_step(Scene *scene, Object *ob, ParticleSystem *psys, Particle if(alloc) { realloc_particles(ob, psys, totpart); - if(usecache && !only_children_changed) + if(usecache && !only_children_changed) { BKE_ptcache_id_clear(&pid, PTCACHE_CLEAR_ALL, 0); + BKE_ptcache_id_from_particles(&pid, ob, psys); + } } if(!only_children_changed) @@ -4358,7 +4243,7 @@ static void system_step(Scene *scene, Object *ob, ParticleSystem *psys, Particle /* try to read from the cache */ if(usecache) { - int result = get_particles_from_cache(scene, ob, psys, (float)framenr, &old_framenr); + int result = BKE_ptcache_read_cache(&pid, cfra, scene->r.frs_sec); if(result == PTCACHE_READ_EXACT || result == PTCACHE_READ_INTERPOLATED) { cached_step(scene, ob, psmd, psys, cfra); @@ -4369,14 +4254,12 @@ static void system_step(Scene *scene, Object *ob, ParticleSystem *psys, Particle cache->flag |= PTCACHE_SIMULATION_VALID; if(result == PTCACHE_READ_INTERPOLATED && cache->flag & PTCACHE_REDO_NEEDED) - write_particles_to_cache(ob, psys, cfra); + BKE_ptcache_write_cache(&pid, (int)cfra); return; } else if(result==PTCACHE_READ_OLD) { - /* set old cfra */ - psys->cfra = (float)old_framenr; - + psys->cfra = (float)cache->simframe; for(p=0, pa=psys->particles; p<totpart; p++, pa++) { /* update alive status */ if(pa->time > psys->cfra) @@ -4402,7 +4285,7 @@ static void system_step(Scene *scene, Object *ob, ParticleSystem *psys, Particle /* if on second frame, write cache for first frame */ if(usecache && psys->cfra == startframe && (cache->flag & PTCACHE_OUTDATED || cache->last_exact==0)) - write_particles_to_cache(ob, psys, startframe); + BKE_ptcache_write_cache(&pid, startframe); if(part->phystype==PART_PHYS_KEYED) psys_count_keyed_targets(ob,psys); @@ -4448,7 +4331,7 @@ static void system_step(Scene *scene, Object *ob, ParticleSystem *psys, Particle /* only write cache starting from second frame */ if(usecache && framenr != startframe) - write_particles_to_cache(ob, psys, framenr); + BKE_ptcache_write_cache(&pid, (int)cfra); /* for keyed particles the path is allways known so it can be drawn */ if(part->phystype==PART_PHYS_KEYED) { diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index beb72c2c13f..69da8f19d8c 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -39,6 +39,7 @@ #include "DNA_object_force.h" #include "DNA_particle_types.h" #include "DNA_scene_types.h" +#include "DNA_smoke_types.h" #include "BLI_blenlib.h" @@ -52,11 +53,19 @@ #include "BKE_particle.h" #include "BKE_pointcache.h" #include "BKE_scene.h" +#include "BKE_smoke.h" #include "BKE_softbody.h" #include "BKE_utildefines.h" #include "BLI_blenlib.h" +/* both in intern */ +#include "smoke_API.h" +#include "minilzo.h" + +#include "LzmaLib.h" + + /* needed for directory lookup */ #ifndef WIN32 #include <dirent.h> @@ -77,46 +86,677 @@ #endif #endif -/* Creating ID's */ +static void ptcache_data_to(void **data, int type, int index, void *to); +static void ptcache_data_from(void **data, int type, void *from); + +/* Common functions */ +static int ptcache_read_basic_header(PTCacheFile *pf) +{ + int error=0; + + /* Custom functions should read these basic elements too! */ + if(!error && !fread(&pf->totpoint, sizeof(int), 1, pf->fp)) + error = 1; + + if(!error && !fread(&pf->data_types, sizeof(int), 1, pf->fp)) + error = 1; + + return !error; +} +static int ptcache_write_basic_header(PTCacheFile *pf) +{ + /* Custom functions should write these basic elements too! */ + if(!fwrite(&pf->totpoint, sizeof(int), 1, pf->fp)) + return 0; + + if(!fwrite(&pf->data_types, sizeof(int), 1, pf->fp)) + return 0; + + return 1; +} +/* Softbody functions */ +static int ptcache_write_softbody(int index, void *soft_v, void **data) +{ + SoftBody *soft= soft_v; + BodyPoint *bp = soft->bpoint + index; + + ptcache_data_from(data, BPHYS_DATA_LOCATION, bp->pos); + ptcache_data_from(data, BPHYS_DATA_VELOCITY, bp->vec); + + return 1; +} +static void ptcache_read_softbody(int index, void *soft_v, void **data, float frs_sec, float cfra, float *old_data) +{ + SoftBody *soft= soft_v; + BodyPoint *bp = soft->bpoint + index; + + if(old_data) { + memcpy(bp->pos, data, 3 * sizeof(float)); + memcpy(bp->vec, data + 3, 3 * sizeof(float)); + } + else { + ptcache_data_to(data, BPHYS_DATA_LOCATION, 0, bp->pos); + ptcache_data_to(data, BPHYS_DATA_VELOCITY, 0, bp->vec); + } +} +static void ptcache_interpolate_softbody(int index, void *soft_v, void **data, float frs_sec, float cfra, float cfra1, float cfra2, float *old_data) +{ + SoftBody *soft= soft_v; + BodyPoint *bp = soft->bpoint + index; + ParticleKey keys[4]; + float dfra; + + if(cfra1 == cfra2) + return; + + VECCOPY(keys[1].co, bp->pos); + VECCOPY(keys[1].vel, bp->vec); + + if(old_data) { + memcpy(keys[2].co, old_data, 3 * sizeof(float)); + memcpy(keys[2].vel, old_data + 3, 3 * sizeof(float)); + } + else + BKE_ptcache_make_particle_key(keys+2, 0, data, cfra2); + + dfra = cfra2 - cfra1; + + VecMulf(keys[1].vel, dfra); + VecMulf(keys[2].vel, dfra); + + psys_interpolate_particle(-1, keys, (cfra - cfra1) / dfra, keys, 1); + + VecMulf(keys->vel, 1.0f / dfra); + + VECCOPY(bp->pos, keys->co); + VECCOPY(bp->vec, keys->vel); +} +static int ptcache_totpoint_softbody(void *soft_v) +{ + SoftBody *soft= soft_v; + return soft->totpoint; +} +/* Particle functions */ +static int ptcache_write_particle(int index, void *psys_v, void **data) +{ + ParticleSystem *psys= psys_v; + ParticleData *pa = psys->particles + index; + float times[3] = {pa->time, pa->dietime, pa->lifetime}; + + if(data[BPHYS_DATA_INDEX]) { + int step = psys->pointcache->step; + /* No need to store unborn or died particles */ + if(pa->time - step > pa->state.time || pa->dietime + step < pa->state.time) + return 0; + } + + ptcache_data_from(data, BPHYS_DATA_INDEX, &index); + ptcache_data_from(data, BPHYS_DATA_LOCATION, pa->state.co); + ptcache_data_from(data, BPHYS_DATA_VELOCITY, pa->state.vel); + ptcache_data_from(data, BPHYS_DATA_ROTATION, pa->state.rot); + ptcache_data_from(data, BPHYS_DATA_AVELOCITY, pa->state.ave); + ptcache_data_from(data, BPHYS_DATA_SIZE, &pa->size); + ptcache_data_from(data, BPHYS_DATA_TIMES, times); + + if(pa->boid) + ptcache_data_from(data, BPHYS_DATA_TIMES, &pa->boid); + + return 1; +} +void BKE_ptcache_make_particle_key(ParticleKey *key, int index, void **data, float time) +{ + ptcache_data_to(data, BPHYS_DATA_LOCATION, index, key->co); + ptcache_data_to(data, BPHYS_DATA_VELOCITY, index, key->vel); + ptcache_data_to(data, BPHYS_DATA_ROTATION, index, key->rot); + ptcache_data_to(data, BPHYS_DATA_AVELOCITY, index, key->ave); + key->time = time; +} +static void ptcache_read_particle(int index, void *psys_v, void **data, float frs_sec, float cfra, float *old_data) +{ + ParticleSystem *psys= psys_v; + ParticleData *pa = psys->particles + index; + + if(cfra > pa->state.time) + memcpy(&pa->prev_state, &pa->state, sizeof(ParticleKey)); + + if(old_data){ + /* old format cache */ + memcpy(&pa->state, old_data, sizeof(ParticleKey)); + return; + } + + BKE_ptcache_make_particle_key(&pa->state, 0, data, cfra); + + if(data[BPHYS_DATA_SIZE]) + ptcache_data_to(data, BPHYS_DATA_SIZE, 0, &pa->size); + + if(data[BPHYS_DATA_TIMES]) { + float times[3]; + ptcache_data_to(data, BPHYS_DATA_TIMES, 0, ×); + pa->time = times[0]; + pa->dietime = times[1]; + pa->lifetime = times[2]; + } + + if(pa->boid) + ptcache_data_to(data, BPHYS_DATA_BOIDS, 0, &pa->boid); + + /* determine velocity from previous location */ + if(data[BPHYS_DATA_LOCATION] && !data[BPHYS_DATA_VELOCITY]) { + if(cfra > pa->prev_state.time) { + VecSubf(pa->state.vel, pa->state.co, pa->prev_state.co); + VecMulf(pa->state.vel, (cfra - pa->prev_state.time) / frs_sec); + } + else { + VecSubf(pa->state.vel, pa->prev_state.co, pa->state.co); + VecMulf(pa->state.vel, (pa->prev_state.time - cfra) / frs_sec); + } + } + + /* determine rotation from velocity */ + if(data[BPHYS_DATA_LOCATION] && !data[BPHYS_DATA_ROTATION]) { + vectoquat(pa->state.vel, OB_POSX, OB_POSZ, pa->state.rot); + } +} +static void ptcache_interpolate_particle(int index, void *psys_v, void **data, float frs_sec, float cfra, float cfra1, float cfra2, float *old_data) +{ + ParticleSystem *psys= psys_v; + ParticleData *pa = psys->particles + index; + ParticleKey keys[4]; + float dfra; + + cfra = MIN2(cfra, pa->dietime); + cfra1 = MIN2(cfra1, pa->dietime); + cfra2 = MIN2(cfra2, pa->dietime); + + if(cfra1 == cfra2) + return; + + memcpy(keys+1, &pa->state, sizeof(ParticleKey)); + if(old_data) + memcpy(keys+2, old_data, sizeof(ParticleKey)); + else + BKE_ptcache_make_particle_key(keys+2, 0, data, cfra2); + + dfra = cfra2 - cfra1; + + VecMulf(keys[1].vel, dfra / frs_sec); + VecMulf(keys[2].vel, dfra / frs_sec); + + psys_interpolate_particle(-1, keys, (cfra - cfra1) / dfra, &pa->state, 1); + QuatInterpol(pa->state.rot, keys[1].rot,keys[2].rot, (cfra - cfra1) / dfra); + VecMulf(pa->state.vel, frs_sec / dfra); + + pa->state.time = cfra; +} + +static int ptcache_totpoint_particle(void *psys_v) +{ + ParticleSystem *psys = psys_v; + return psys->totpart; +} +static int ptcache_totwrite_particle(void *psys_v) +{ + ParticleSystem *psys = psys_v; + int totwrite = 0; + + /* TODO for later */ + //if((psys->part->flag & (PART_UNBORN|PART_DIED))==0) { + // ParticleData *pa= psys->particles; + // int p, step = psys->pointcache->step; + + // for(p=0; p<psys->totpart; p++,pa++) + // totwrite += (pa->time - step > pa->state.time || pa->dietime + step > pa->state.time); + //} + //else + totwrite= psys->totpart; + + return totwrite; +} + +/* Cloth functions */ +static int ptcache_write_cloth(int index, void *cloth_v, void **data) +{ + ClothModifierData *clmd= cloth_v; + Cloth *cloth= clmd->clothObject; + ClothVertex *vert = cloth->verts + index; + + ptcache_data_from(data, BPHYS_DATA_LOCATION, vert->x); + ptcache_data_from(data, BPHYS_DATA_VELOCITY, vert->v); + ptcache_data_from(data, BPHYS_DATA_XCONST, vert->xconst); + + return 1; +} +static void ptcache_read_cloth(int index, void *cloth_v, void **data, float frs_sec, float cfra, float *old_data) +{ + ClothModifierData *clmd= cloth_v; + Cloth *cloth= clmd->clothObject; + ClothVertex *vert = cloth->verts + index; + + if(old_data) { + memcpy(vert->x, data, 3 * sizeof(float)); + memcpy(vert->xconst, data + 3, 3 * sizeof(float)); + memcpy(vert->v, data + 6, 3 * sizeof(float)); + } + else { + ptcache_data_to(data, BPHYS_DATA_LOCATION, 0, vert->x); + ptcache_data_to(data, BPHYS_DATA_VELOCITY, 0, vert->v); + ptcache_data_to(data, BPHYS_DATA_XCONST, 0, vert->xconst); + } +} +static void ptcache_interpolate_cloth(int index, void *cloth_v, void **data, float frs_sec, float cfra, float cfra1, float cfra2, float *old_data) +{ + ClothModifierData *clmd= cloth_v; + Cloth *cloth= clmd->clothObject; + ClothVertex *vert = cloth->verts + index; + ParticleKey keys[4]; + float dfra; + + if(cfra1 == cfra2) + return; + + VECCOPY(keys[1].co, vert->x); + VECCOPY(keys[1].vel, vert->v); + + if(old_data) { + memcpy(keys[2].co, old_data, 3 * sizeof(float)); + memcpy(keys[2].vel, old_data + 6, 3 * sizeof(float)); + } + else + BKE_ptcache_make_particle_key(keys+2, 0, data, cfra2); + + dfra = cfra2 - cfra1; + + VecMulf(keys[1].vel, dfra); + VecMulf(keys[2].vel, dfra); + + psys_interpolate_particle(-1, keys, (cfra - cfra1) / dfra, keys, 1); + + VecMulf(keys->vel, 1.0f / dfra); + + VECCOPY(vert->x, keys->co); + VECCOPY(vert->v, keys->vel); + + /* should vert->xconst be interpolated somehow too? - jahka */ +} + +static int ptcache_totpoint_cloth(void *cloth_v) +{ + ClothModifierData *clmd= cloth_v; + return clmd->clothObject->numverts; +} + +/* Creating ID's */ void BKE_ptcache_id_from_softbody(PTCacheID *pid, Object *ob, SoftBody *sb) { ParticleSystemModifierData *psmd; - ModifierData *md; - int a; memset(pid, 0, sizeof(PTCacheID)); pid->ob= ob; - pid->data= sb; + pid->calldata= sb; pid->type= PTCACHE_TYPE_SOFTBODY; pid->cache= sb->pointcache; + pid->cache_ptr= &sb->pointcache; + pid->ptcaches= &sb->ptcaches; + pid->totpoint= pid->totwrite= ptcache_totpoint_softbody; + + pid->write_elem= ptcache_write_softbody; + pid->write_stream = NULL; + pid->read_stream = NULL; + pid->read_elem= ptcache_read_softbody; + pid->interpolate_elem= ptcache_interpolate_softbody; + + pid->write_header= ptcache_write_basic_header; + pid->read_header= ptcache_read_basic_header; + + pid->data_types= (1<<BPHYS_DATA_LOCATION) | (1<<BPHYS_DATA_VELOCITY); + pid->info_types= 0; if(sb->particles) { psmd= psys_get_modifier(ob, sb->particles); - pid->stack_index= modifiers_indexInObject(ob, (ModifierData*)psmd); - } - else { - for(a=0, md=ob->modifiers.first; md; md=md->next, a++) { - if(md->type == eModifierType_Softbody) { - pid->stack_index = a; - break; - } - } + // pid->stack_index= modifiers_indexInObject(ob, (ModifierData*)psmd); XXX TODO - get other index DG } + else + pid->stack_index = pid->cache->index; } void BKE_ptcache_id_from_particles(PTCacheID *pid, Object *ob, ParticleSystem *psys) { - ParticleSystemModifierData *psmd= psys_get_modifier(ob, psys); - memset(pid, 0, sizeof(PTCacheID)); pid->ob= ob; - pid->data= psys; + pid->calldata= psys; pid->type= PTCACHE_TYPE_PARTICLES; - pid->stack_index= modifiers_indexInObject(ob, (ModifierData *)psmd); + pid->stack_index= psys->pointcache->index; pid->cache= psys->pointcache; + pid->cache_ptr= &psys->pointcache; + pid->ptcaches= &psys->ptcaches; + + pid->write_elem= ptcache_write_particle; + pid->write_stream = NULL; + pid->read_stream = NULL; + pid->read_elem= ptcache_read_particle; + pid->interpolate_elem= ptcache_interpolate_particle; + + pid->totpoint= ptcache_totpoint_particle; + pid->totwrite= ptcache_totwrite_particle; + + pid->write_header= ptcache_write_basic_header; + pid->read_header= ptcache_read_basic_header; + + pid->data_types= (1<<BPHYS_DATA_LOCATION) | (1<<BPHYS_DATA_VELOCITY); + + /* TODO for later */ + //if((psys->part->flag & (PART_UNBORN|PART_DIED))==0) + // pid->data_types|= (1<<BPHYS_DATA_INDEX); + + if(psys->part->phystype == PART_PHYS_BOIDS) + pid->data_types|= (1<<BPHYS_DATA_AVELOCITY) | (1<<BPHYS_DATA_ROTATION) | (1<<BPHYS_DATA_BOIDS); + + if(psys->part->rotmode || psys->part->avemode) + pid->data_types|= (1<<BPHYS_DATA_AVELOCITY) | (1<<BPHYS_DATA_ROTATION); + + if(psys->part->flag & PART_ROT_DYN) + pid->data_types|= (1<<BPHYS_DATA_ROTATION); + + pid->info_types= (1<<BPHYS_DATA_TIMES); +} + +/* Smoke functions */ +static int ptcache_totpoint_smoke(void *smoke_v) +{ + SmokeModifierData *smd= (SmokeModifierData *)smoke_v; + SmokeDomainSettings *sds = smd->domain; + + if(sds->fluid) { + return sds->res[0]*sds->res[1]*sds->res[2]; + } + else + return 0; +} + +// forward decleration +static int ptcache_file_write(PTCacheFile *pf, void *f, size_t tot, int size); + +static int ptcache_compress_write(PTCacheFile *pf, unsigned char *in, unsigned int in_len, unsigned char *out, int mode) +{ + int r = 0; + unsigned char compressed; + LZO_HEAP_ALLOC(wrkmem, LZO1X_MEM_COMPRESS); + unsigned int out_len = LZO_OUT_LEN(in_len); + unsigned char *props = MEM_callocN(16*sizeof(char), "tmp"); + size_t sizeOfIt = 5; + + if(mode == 1) { + r = lzo1x_1_compress(in, (lzo_uint)in_len, out, (lzo_uint *)&out_len, wrkmem); + if (!(r == LZO_E_OK) || (out_len >= in_len)) + compressed = 0; + else + compressed = 1; + } + else if(mode == 2) { + + r = LzmaCompress(out, (size_t *)&out_len, in, in_len,//assume sizeof(char)==1.... + props, &sizeOfIt, 5, 1 << 24, 3, 0, 2, 32, 2); + + if(!(r == SZ_OK) || (out_len >= in_len)) + compressed = 0; + else + compressed = 2; + } + + ptcache_file_write(pf, &compressed, 1, sizeof(unsigned char)); + if(compressed) { + ptcache_file_write(pf, &out_len, 1, sizeof(unsigned int)); + ptcache_file_write(pf, out, out_len, sizeof(unsigned char)); + } + else + ptcache_file_write(pf, in, in_len, sizeof(unsigned char)); + + if(compressed == 2) + { + ptcache_file_write(pf, &sizeOfIt, 1, sizeof(unsigned int)); + ptcache_file_write(pf, props, sizeOfIt, sizeof(unsigned char)); + } + + MEM_freeN(props); + + return r; +} + +static int ptcache_write_smoke(PTCacheFile *pf, void *smoke_v) +{ + SmokeModifierData *smd= (SmokeModifierData *)smoke_v; + SmokeDomainSettings *sds = smd->domain; + + if(sds->fluid) { + size_t res = sds->res[0]*sds->res[1]*sds->res[2]; + float dt, dx, *dens, *densold, *heat, *heatold, *vx, *vy, *vz, *vxold, *vyold, *vzold; + unsigned char *obstacles; + unsigned int in_len = sizeof(float)*(unsigned int)res; + unsigned char *out = (unsigned char *)MEM_callocN(LZO_OUT_LEN(in_len)*4, "pointcache_lzo_buffer"); + int mode = res >= 1000000 ? 2 : 1; + + smoke_export(sds->fluid, &dt, &dx, &dens, &densold, &heat, &heatold, &vx, &vy, &vz, &vxold, &vyold, &vzold, &obstacles); + + ptcache_compress_write(pf, (unsigned char *)sds->view3d, in_len*4, out, mode); + ptcache_compress_write(pf, (unsigned char *)dens, in_len, out, mode); + ptcache_compress_write(pf, (unsigned char *)densold, in_len, out, mode); + ptcache_compress_write(pf, (unsigned char *)heat, in_len, out, mode); + ptcache_compress_write(pf, (unsigned char *)heatold, in_len, out, mode); + ptcache_compress_write(pf, (unsigned char *)vx, in_len, out, mode); + ptcache_compress_write(pf, (unsigned char *)vy, in_len, out, mode); + ptcache_compress_write(pf, (unsigned char *)vz, in_len, out, mode); + ptcache_compress_write(pf, (unsigned char *)vxold, in_len, out, mode); + ptcache_compress_write(pf, (unsigned char *)vyold, in_len, out, mode); + ptcache_compress_write(pf, (unsigned char *)vzold, in_len, out, mode); + ptcache_compress_write(pf, (unsigned char *)obstacles, (unsigned int)res, out, mode); + ptcache_file_write(pf, &dt, 1, sizeof(float)); + ptcache_file_write(pf, &dx, 1, sizeof(float)); + + MEM_freeN(out); + + return 1; + } + + return 0; +} + +/* +static int ptcache_write_smoke_turbulence(PTCacheFile *pf, void *smoke_v) +{ + SmokeModifierData *smd= (SmokeModifierData *)smoke_v; + SmokeDomainSettings *sds = smd->domain; + + if(sds->wt) { + unsigned int res_big[3]; + size_t res = sds->res[0]*sds->res[1]*sds->res[2]; + float *dens, *densold, *tcu, *tcv, *tcw; + unsigned int in_len = sizeof(float)*(unsigned int)res; + unsigned int in_len_big = sizeof(float) * (unsigned int)res_big; + unsigned char *out; + int mode; + + smoke_turbulence_get_res(sds->wt, res_big); + mode = res_big[0]*res_big[1]*res_big[2] >= 1000000 ? 2 : 1; + + smoke_turbulence_export(sds->wt, &dens, &densold, &tcu, &tcv, &tcw); + + out = (unsigned char *)MEM_callocN(LZO_OUT_LEN(in_len_big), "pointcache_lzo_buffer"); + + ptcache_compress_write(pf, (unsigned char *)dens, in_len_big, out, mode); + ptcache_compress_write(pf, (unsigned char *)densold, in_len_big, out, mode); + + MEM_freeN(out); + out = (unsigned char *)MEM_callocN(LZO_OUT_LEN(in_len), "pointcache_lzo_buffer"); + ptcache_compress_write(pf, (unsigned char *)tcu, in_len, out, mode); + ptcache_compress_write(pf, (unsigned char *)tcv, in_len, out, mode); + ptcache_compress_write(pf, (unsigned char *)tcw, in_len, out, mode); + MEM_freeN(out); + + return 1; + } + return 0; +} +*/ + +// forward decleration +static int ptcache_file_read(PTCacheFile *pf, void *f, size_t tot, int size); + +static int ptcache_compress_read(PTCacheFile *pf, unsigned char *result, unsigned int len) +{ + int r = 0; + unsigned char compressed = 0; + unsigned int in_len; + unsigned int out_len = len; + unsigned char *in; + unsigned char *props = MEM_callocN(16*sizeof(char), "tmp"); + size_t sizeOfIt = 5; + + ptcache_file_read(pf, &compressed, 1, sizeof(unsigned char)); + if(compressed) { + ptcache_file_read(pf, &in_len, 1, sizeof(unsigned int)); + in = (unsigned char *)MEM_callocN(sizeof(unsigned char)*in_len, "pointcache_compressed_buffer"); + ptcache_file_read(pf, in, in_len, sizeof(unsigned char)); + + if(compressed == 1) + r = lzo1x_decompress(in, (lzo_uint)in_len, result, (lzo_uint *)&out_len, NULL); + else if(compressed == 2) + { + size_t leni = in_len, leno = out_len; + ptcache_file_read(pf, &sizeOfIt, 1, sizeof(unsigned int)); + ptcache_file_read(pf, props, sizeOfIt, sizeof(unsigned char)); + r = LzmaUncompress(result, &leno, in, &leni, props, sizeOfIt); + } + + MEM_freeN(in); + } + else { + ptcache_file_read(pf, result, len, sizeof(unsigned char)); + } + + MEM_freeN(props); + + return r; +} + +static void ptcache_read_smoke(PTCacheFile *pf, void *smoke_v) +{ + SmokeModifierData *smd= (SmokeModifierData *)smoke_v; + SmokeDomainSettings *sds = smd->domain; + + if(sds->fluid) { + size_t res = sds->res[0]*sds->res[1]*sds->res[2]; + float dt, dx, *dens, *densold, *heat, *heatold, *vx, *vy, *vz, *vxold, *vyold, *vzold; + unsigned char *obstacles; + unsigned int out_len = (unsigned int)res * sizeof(float); + + smoke_export(sds->fluid, &dt, &dx, &dens, &densold, &heat, &heatold, &vx, &vy, &vz, &vxold, &vyold, &vzold, &obstacles); + + ptcache_compress_read(pf, (unsigned char *)sds->view3d, out_len*4); + ptcache_compress_read(pf, (unsigned char*)dens, out_len); + ptcache_compress_read(pf, (unsigned char*)densold, out_len); + ptcache_compress_read(pf, (unsigned char*)heat, out_len); + ptcache_compress_read(pf, (unsigned char*)heatold, out_len); + ptcache_compress_read(pf, (unsigned char*)vx, out_len); + ptcache_compress_read(pf, (unsigned char*)vy, out_len); + ptcache_compress_read(pf, (unsigned char*)vz, out_len); + ptcache_compress_read(pf, (unsigned char*)vxold, out_len); + ptcache_compress_read(pf, (unsigned char*)vyold, out_len); + ptcache_compress_read(pf, (unsigned char*)vzold, out_len); + ptcache_compress_read(pf, (unsigned char*)obstacles, (unsigned int)res); + ptcache_file_read(pf, &dt, 1, sizeof(float)); + ptcache_file_read(pf, &dx, 1, sizeof(float)); + } +} + +/* +static void ptcache_read_smoke_turbulence(PTCacheFile *pf, void *smoke_v) +{ + SmokeModifierData *smd= (SmokeModifierData *)smoke_v; + SmokeDomainSettings *sds = smd->domain; + + if(sds->fluid) { + unsigned int res[3]; + float *dens, *densold, *tcu, *tcv, *tcw; + unsigned int out_len = sizeof(float)*(unsigned int)res; + + smoke_turbulence_get_res(sds->wt, res); + + smoke_turbulence_export(sds->wt, &dens, &densold, &tcu, &tcv, &tcw); + + ptcache_compress_read(pf, (unsigned char*)dens, out_len); + + } +} +*/ + +void BKE_ptcache_id_from_smoke(PTCacheID *pid, struct Object *ob, struct SmokeModifierData *smd) +{ + SmokeDomainSettings *sds = smd->domain; + + memset(pid, 0, sizeof(PTCacheID)); + + pid->ob= ob; + pid->calldata= smd; + + pid->type= PTCACHE_TYPE_SMOKE_DOMAIN; + pid->stack_index= sds->point_cache[0]->index; + + pid->cache= sds->point_cache[0]; + pid->cache_ptr= &(sds->point_cache[0]); + pid->ptcaches= &(sds->ptcaches[0]); + + pid->totpoint= pid->totwrite= ptcache_totpoint_smoke; + + pid->write_elem= NULL; + pid->read_elem= NULL; + + pid->read_stream = ptcache_read_smoke; + pid->write_stream = ptcache_write_smoke; + + pid->interpolate_elem= NULL; + + pid->write_header= ptcache_write_basic_header; + pid->read_header= ptcache_read_basic_header; + + pid->data_types= (1<<BPHYS_DATA_LOCATION); // bogus values tot make pointcache happy + pid->info_types= 0; +} + +void BKE_ptcache_id_from_smoke_turbulence(PTCacheID *pid, struct Object *ob, struct SmokeModifierData *smd) +{ + SmokeDomainSettings *sds = smd->domain; + + memset(pid, 0, sizeof(PTCacheID)); + + pid->ob= ob; + pid->calldata= smd; + + pid->type= PTCACHE_TYPE_SMOKE_HIGHRES; + pid->stack_index= sds->point_cache[1]->index; + + pid->cache= sds->point_cache[1]; + pid->cache_ptr= &sds->point_cache[1]; + pid->ptcaches= &sds->ptcaches[1]; + + pid->totpoint= pid->totwrite= ptcache_totpoint_smoke; + + pid->write_elem= NULL; + pid->read_elem= NULL; + + pid->read_stream = ptcache_read_smoke; + pid->write_stream = ptcache_write_smoke; + + pid->interpolate_elem= NULL; + + pid->write_header= ptcache_write_basic_header; + pid->read_header= ptcache_read_basic_header; + + pid->data_types= (1<<BPHYS_DATA_LOCATION); // bogus values tot make pointcache happy + pid->info_types= 0; } void BKE_ptcache_id_from_cloth(PTCacheID *pid, Object *ob, ClothModifierData *clmd) @@ -124,10 +764,25 @@ void BKE_ptcache_id_from_cloth(PTCacheID *pid, Object *ob, ClothModifierData *cl memset(pid, 0, sizeof(PTCacheID)); pid->ob= ob; - pid->data= clmd; + pid->calldata= clmd; pid->type= PTCACHE_TYPE_CLOTH; - pid->stack_index= modifiers_indexInObject(ob, (ModifierData *)clmd); + pid->stack_index= clmd->point_cache->index; pid->cache= clmd->point_cache; + pid->cache_ptr= &clmd->point_cache; + pid->ptcaches= &clmd->ptcaches; + pid->totpoint= pid->totwrite= ptcache_totpoint_cloth; + + pid->write_elem= ptcache_write_cloth; + pid->write_stream = NULL; + pid->read_stream = NULL; + pid->read_elem= ptcache_read_cloth; + pid->interpolate_elem= ptcache_interpolate_cloth; + + pid->write_header= ptcache_write_basic_header; + pid->read_header= ptcache_read_basic_header; + + pid->data_types= (1<<BPHYS_DATA_LOCATION) | (1<<BPHYS_DATA_VELOCITY) | (1<<BPHYS_DATA_XCONST); + pid->info_types= 0; } void BKE_ptcache_ids_from_object(ListBase *lb, Object *ob) @@ -162,9 +817,21 @@ void BKE_ptcache_ids_from_object(ListBase *lb, Object *ob) BKE_ptcache_id_from_cloth(pid, ob, (ClothModifierData*)md); BLI_addtail(lb, pid); } + if(md->type == eModifierType_Smoke) { + SmokeModifierData *smd = (SmokeModifierData *)md; + if(smd->type & MOD_SMOKE_TYPE_DOMAIN) + { + pid= MEM_callocN(sizeof(PTCacheID), "PTCacheID"); + BKE_ptcache_id_from_smoke(pid, ob, (SmokeModifierData*)md); + BLI_addtail(lb, pid); + } + } } } + +/* File handling */ + /* Takes an Object ID and returns a unique name - id: object id - cfra: frame for the cache, can be negative @@ -177,7 +844,7 @@ void BKE_ptcache_ids_from_object(ListBase *lb, Object *ob) static int ptcache_path(PTCacheID *pid, char *filename) { Library *lib; - int i; + size_t i; lib= (pid)? pid->ob->id.lib: NULL; @@ -235,13 +902,17 @@ static int BKE_ptcache_id_filename(PTCacheID *pid, char *filename, int cfra, sho } } else { - int temp = strlen(pid->cache->name); + int temp = (int)strlen(pid->cache->name); strcpy(newname, pid->cache->name); newname+=temp; len += temp; } if (do_ext) { + + if(pid->cache->index < 0) + pid->cache->index = pid->stack_index = object_insert_ptcache(pid->ob); + if(pid->cache->flag & PTCACHE_EXTERNAL) { if(pid->cache->index >= 0) snprintf(newname, MAX_PTCACHE_FILE, "_%06d_%02d"PTCACHE_EXT, cfra, pid->stack_index); /* always 6 chars */ @@ -258,7 +929,7 @@ static int BKE_ptcache_id_filename(PTCacheID *pid, char *filename, int cfra, sho } /* youll need to close yourself after! */ -PTCacheFile *BKE_ptcache_file_open(PTCacheID *pid, int mode, int cfra) +static PTCacheFile *ptcache_file_open(PTCacheID *pid, int mode, int cfra) { PTCacheFile *pf; FILE *fp = NULL; @@ -291,136 +962,224 @@ PTCacheFile *BKE_ptcache_file_open(PTCacheID *pid, int mode, int cfra) return pf; } -void BKE_ptcache_file_close(PTCacheFile *pf) +static void ptcache_file_close(PTCacheFile *pf) { fclose(pf->fp); MEM_freeN(pf); } -int BKE_ptcache_file_read_floats(PTCacheFile *pf, float *f, int tot) +static int ptcache_file_read(PTCacheFile *pf, void *f, size_t tot, int size) { - return (fread(f, sizeof(float), tot, pf->fp) == tot); + return (fread(f, size, tot, pf->fp) == tot); } - -int BKE_ptcache_file_write_floats(PTCacheFile *pf, float *f, int tot) +static int ptcache_file_write(PTCacheFile *pf, void *f, size_t tot, int size) { - return (fwrite(f, sizeof(float), tot, pf->fp) == tot); + return (fwrite(f, size, tot, pf->fp) == tot); } - -static int ptcache_pid_elemsize(PTCacheID *pid) +static int ptcache_file_read_data(PTCacheFile *pf) { - if(pid->type==PTCACHE_TYPE_SOFTBODY) - return 6 * sizeof(float); - else if(pid->type==PTCACHE_TYPE_PARTICLES) - return sizeof(ParticleKey); - else if(pid->type==PTCACHE_TYPE_CLOTH) - return 9 * sizeof(float); + int i; - return 0; -} -static int ptcache_pid_totelem(PTCacheID *pid) -{ - if(pid->type==PTCACHE_TYPE_SOFTBODY) { - SoftBody *soft = pid->data; - return soft->totpoint; - } - else if(pid->type==PTCACHE_TYPE_PARTICLES) { - ParticleSystem *psys = pid->data; - return psys->totpart; + for(i=0; i<BPHYS_TOT_DATA; i++) { + if(pf->data_types & (1<<i) && !ptcache_file_read(pf, pf->cur[i], 1, BKE_ptcache_data_size(i))) + return 0; } - else if(pid->type==PTCACHE_TYPE_CLOTH) { - ClothModifierData *clmd = pid->data; - return clmd->clothObject->numverts; + + return 1; +} +static int ptcache_file_write_data(PTCacheFile *pf) +{ + int i; + + for(i=0; i<BPHYS_TOT_DATA; i++) { + if(pf->data_types & (1<<i) && !ptcache_file_write(pf, pf->cur[i], 1, BKE_ptcache_data_size(i))) + return 0; } + + return 1; +} +static int ptcache_file_read_header_begin(PTCacheFile *pf) +{ + int error=0; + char bphysics[8]; + + pf->data_types = 0; + + if(fread(bphysics, sizeof(char), 8, pf->fp) != 8) + error = 1; + + if(!error && strncmp(bphysics, "BPHYSICS", 8)) + error = 1; - return 0; + if(!error && !fread(&pf->type, sizeof(int), 1, pf->fp)) + error = 1; + + /* if there was an error set file as it was */ + if(error) + fseek(pf->fp, 0, SEEK_SET); + + return !error; } -void BKE_ptcache_update_info(PTCacheID *pid) + +static int ptcache_file_write_header_begin(PTCacheFile *pf) { - PointCache *cache = pid->cache; - int totframes = 0; - char mem_info[64]; + char *bphysics = "BPHYSICS"; + + if(fwrite(bphysics, sizeof(char), 8, pf->fp) != 8) + return 0; - if(cache->flag & PTCACHE_EXTERNAL) { - int cfra = cache->startframe; + if(!fwrite(&pf->type, sizeof(int), 1, pf->fp)) + return 0; + + return 1; +} - for(; cfra<=cache->endframe; cfra++) { - if(BKE_ptcache_id_exist(pid, cfra)) - totframes++; - } - if(totframes) - sprintf(cache->info, "%i points read for %i frames", cache->totpoint, totframes); +/* Data pointer handling */ +int BKE_ptcache_data_size(int data_type) +{ + switch(data_type) { + case BPHYS_DATA_INDEX: + return sizeof(int); + case BPHYS_DATA_LOCATION: + case BPHYS_DATA_VELOCITY: + case BPHYS_DATA_AVELOCITY: /* also BPHYS_DATA_XCONST */ + case BPHYS_DATA_TIMES: + return 3 * sizeof(float); + case BPHYS_DATA_ROTATION: + return 4 * sizeof(float); + case BPHYS_DATA_SIZE: + return sizeof(float); + case BPHYS_DATA_BOIDS: + return sizeof(BoidData); + default: + return 0; + } +} +static void ptcache_data_to(void **data, int type, int index, void *to) +{ + if(data[type]) { + if(index) + memcpy(to, (char*)data[type] + index * BKE_ptcache_data_size(type), BKE_ptcache_data_size(type)); else - sprintf(cache->info, "No valid data to read!"); - return; + memcpy(to, data[type], BKE_ptcache_data_size(type)); } +} - if(cache->flag & PTCACHE_DISK_CACHE) { - int cfra = cache->startframe; +static void ptcache_data_from(void **data, int type, void *from) +{ + if(data[type]) + memcpy(data[type], from, BKE_ptcache_data_size(type)); +} - for(; cfra<=cache->endframe; cfra++) { - if(BKE_ptcache_id_exist(pid, cfra)) - totframes++; - } +static void ptcache_file_init_pointers(PTCacheFile *pf) +{ + int data_types = pf->data_types; + + pf->cur[BPHYS_DATA_INDEX] = data_types & (1<<BPHYS_DATA_INDEX) ? &pf->data.index : NULL; + pf->cur[BPHYS_DATA_LOCATION] = data_types & (1<<BPHYS_DATA_LOCATION) ? &pf->data.loc : NULL; + pf->cur[BPHYS_DATA_VELOCITY] = data_types & (1<<BPHYS_DATA_VELOCITY) ? &pf->data.vel : NULL; + pf->cur[BPHYS_DATA_ROTATION] = data_types & (1<<BPHYS_DATA_ROTATION) ? &pf->data.rot : NULL; + pf->cur[BPHYS_DATA_AVELOCITY] = data_types & (1<<BPHYS_DATA_AVELOCITY) ? &pf->data.ave : NULL; + pf->cur[BPHYS_DATA_SIZE] = data_types & (1<<BPHYS_DATA_SIZE) ? &pf->data.size : NULL; + pf->cur[BPHYS_DATA_TIMES] = data_types & (1<<BPHYS_DATA_TIMES) ? &pf->data.times : NULL; + pf->cur[BPHYS_DATA_BOIDS] = data_types & (1<<BPHYS_DATA_BOIDS) ? &pf->data.boids : NULL; +} - sprintf(mem_info, "%i frames on disk", totframes); - } - else { - PTCacheMem *pm = cache->mem_cache.first; - float framesize = 0.0f, bytes = 0.0f; - int mb; +static void ptcache_mem_init_pointers(PTCacheMem *pm) +{ + int data_types = pm->data_types; + int i; - if(pm) - framesize = (float)ptcache_pid_elemsize(pid) * (float)pm->totpoint; - - for(; pm; pm=pm->next) - totframes++; + for(i=0; i<BPHYS_TOT_DATA; i++) + pm->cur[i] = data_types & (1<<i) ? pm->data[i] : NULL; +} - bytes = totframes * framesize; +static void ptcache_mem_incr_pointers(PTCacheMem *pm) +{ + int i; - mb = (bytes > 1024.0f * 1024.0f); + for(i=0; i<BPHYS_TOT_DATA; i++) { + if(pm->cur[i]) + pm->cur[i] = (char*)pm->cur[i] + BKE_ptcache_data_size(i); + } +} +static void ptcache_alloc_data(PTCacheMem *pm) +{ + int data_types = pm->data_types; + int totpoint = pm->totpoint; + int i; - sprintf(mem_info, "%i frames in memory (%.1f %s)", - totframes, - bytes / (mb ? 1024.0f * 1024.0f : 1024.0f), - mb ? "Mb" : "kb"); + for(i=0; i<BPHYS_TOT_DATA; i++) { + if(data_types & (1<<i)) + pm->data[i] = MEM_callocN(totpoint * BKE_ptcache_data_size(i), "PTCache Data"); } +} +static void ptcache_free_data(void *data[]) +{ + int i; - if(cache->flag & PTCACHE_OUTDATED) { - sprintf(cache->info, "%s, cache is outdated!", mem_info); + for(i=0; i<BPHYS_TOT_DATA; i++) { + if(data[i]) + MEM_freeN(data[i]); } - else if(cache->flag & PTCACHE_FRAMES_SKIPPED) { - sprintf(cache->info, "%s, not exact since frame %i.", mem_info, cache->last_exact); +} +static void ptcache_copy_data(void *from[], void *to[]) +{ + int i; + for(i=0; i<BPHYS_TOT_DATA; i++) { + if(from[i]) + memcpy(to[i], from[i], BKE_ptcache_data_size(i)); } - else - sprintf(cache->info, "%s.", mem_info); } + + + +static int ptcache_pid_old_elemsize(PTCacheID *pid) +{ + if(pid->type==PTCACHE_TYPE_SOFTBODY) + return 6 * sizeof(float); + else if(pid->type==PTCACHE_TYPE_PARTICLES) + return sizeof(ParticleKey); + else if(pid->type==PTCACHE_TYPE_CLOTH) + return 9 * sizeof(float); + + return 0; +} + /* reads cache from disk or memory */ /* possible to get old or interpolated result */ -int BKE_ptcache_read_cache(PTCacheReader *reader) +int BKE_ptcache_read_cache(PTCacheID *pid, float cfra, float frs_sec) { - PTCacheID *pid = reader->pid; PTCacheFile *pf=NULL, *pf2=NULL; PTCacheMem *pm=NULL, *pm2=NULL; - int totelem = reader->totelem; - float cfra = reader->cfra; + float old_data1[14], old_data2[14]; int cfrai = (int)cfra; - int elemsize = ptcache_pid_elemsize(pid); - int i, incr = elemsize / sizeof(float); - float frs_sec = reader->scene->r.frs_sec; - int cfra1=0, cfra2; - int ret = 0; + int old_elemsize = ptcache_pid_old_elemsize(pid); + int i; + + int cfra1 = 0, cfra2 = 0; + int totpoint = 0, totpoint2 = 0; + int *index = &i, *index2 = &i; + int use_old = 0, old_frame = 0; + + int ret = 0, error = 0; - if(totelem == 0) + /* nothing to read to */ + if(pid->totpoint(pid->calldata) == 0) return 0; + if(pid->cache->flag & PTCACHE_READ_INFO) { + pid->cache->flag &= ~PTCACHE_READ_INFO; + BKE_ptcache_read_cache(pid, 0, frs_sec); + } + /* first check if we have the actual frame cached */ if(cfra == (float)cfrai) { if(pid->cache->flag & PTCACHE_DISK_CACHE) { - pf= BKE_ptcache_file_open(pid, PTCACHE_FILE_READ, cfrai); + pf= ptcache_file_open(pid, PTCACHE_FILE_READ, cfrai); } else { pm = pid->cache->mem_cache.first; @@ -432,240 +1191,297 @@ int BKE_ptcache_read_cache(PTCacheReader *reader) } } - /* if found, use exact frame */ - if(pf || pm) { - float *data; - - if(pm) - data = pm->data; - else - data = MEM_callocN(elemsize, "pointcache read data"); + /* no exact cache frame found so try to find cached frames around cfra */ + if(!pm && !pf) { + if(pid->cache->flag & PTCACHE_DISK_CACHE) { + pf=NULL; + while(cfrai > pid->cache->startframe && !pf) { + cfrai--; + pf= ptcache_file_open(pid, PTCACHE_FILE_READ, cfrai); + cfra1 = cfrai; + } - for(i=0; i<totelem; i++) { - if(pf) { - if(!BKE_ptcache_file_read_floats(pf, data, incr)) { - BKE_ptcache_file_close(pf); - MEM_freeN(data); - return 0; - } + old_frame = cfrai; - reader->set_elem(i, reader->calldata, data); + cfrai = (int)cfra; + while(cfrai < pid->cache->endframe && !pf2) { + cfrai++; + pf2= ptcache_file_open(pid, PTCACHE_FILE_READ, cfrai); + cfra2 = cfrai; } - else { - reader->set_elem(i, reader->calldata, data); - data += incr; + + if(pf && !pf2) { + pf2 = pf; + pf = NULL; } } + else if(pid->cache->mem_cache.first){ + pm = pid->cache->mem_cache.first; - if(pf) { - BKE_ptcache_file_close(pf); - pf = NULL; - MEM_freeN(data); - } + while(pm->next && pm->next->frame < cfra) + pm= pm->next; - ret = PTCACHE_READ_EXACT; - } + if(pm) { + old_frame = pm->frame; + cfra1 = pm->frame; + } - if(ret) - ; - /* no exact cache frame found so try to find cached frames around cfra */ - else if(pid->cache->flag & PTCACHE_DISK_CACHE) { - pf=NULL; - while(cfrai > pid->cache->startframe && !pf) { - cfrai--; - pf= BKE_ptcache_file_open(pid, PTCACHE_FILE_READ, cfrai); - cfra1 = cfrai; - } + pm2 = pid->cache->mem_cache.last; - if(reader->old_frame) - *(reader->old_frame) = cfrai; + if(pm2 && pm2->frame < cfra) + pm2 = NULL; + else { + while(pm2->prev && pm2->prev->frame > cfra) + pm2= pm2->prev; - cfrai = (int)cfra; - while(cfrai < pid->cache->endframe && !pf2) { - cfrai++; - pf2= BKE_ptcache_file_open(pid, PTCACHE_FILE_READ, cfrai); - cfra2 = cfrai; + if(pm2) + cfra2 = pm2->frame; + } + + if(pm && !pm2) { + pm2 = pm; + pm = NULL; + } } } - else if(pid->cache->mem_cache.first){ - pm = pid->cache->mem_cache.first; - while(pm->next && pm->next->frame < cfra) - pm= pm->next; + if(!pm && !pm2 && !pf && !pf2) + return 0; - if(pm) { - if(reader->old_frame) - *(reader->old_frame) = pm->frame; - cfra1 = pm->frame; + if(pm) { + ptcache_mem_init_pointers(pm); + totpoint = pm->totpoint; + index = pm->data_types & (1<<BPHYS_DATA_INDEX) ? pm->cur[BPHYS_DATA_INDEX] : &i; + } + if(pm2) { + ptcache_mem_init_pointers(pm2); + totpoint2 = pm2->totpoint; + index2 = pm2->data_types & (1<<BPHYS_DATA_INDEX) ? pm2->cur[BPHYS_DATA_INDEX] : &i; + } + if(pf) { + if(ptcache_file_read_header_begin(pf)) { + if(pf->type != pid->type) { + /* todo report error */ + ptcache_file_close(pf); + pf = NULL; + } + else if(pid->read_header(pf)) { + ptcache_file_init_pointers(pf); + totpoint = pf->totpoint; + index = pf->data_types & BPHYS_DATA_INDEX ? &pf->data.index : &i; + } } - - pm2 = pid->cache->mem_cache.last; - - if(pm2 && pm2->frame < cfra) - pm2 = NULL; else { - while(pm2->prev && pm2->prev->frame > cfra) - pm2= pm2->prev; - - if(pm2) - cfra2 = pm2->frame; + /* fall back to old cache file format */ + use_old = 1; + totpoint = pid->totpoint(pid->calldata); } } - - if(ret) - ; - else if((pf && pf2) || (pm && pm2)) { - /* interpolate from nearest frames if cache isn't outdated */ - float *data1, *data2; - - if(pm) { - data1 = pm->data; - data2 = pm2->data; + if(pf2) { + if(ptcache_file_read_header_begin(pf2)) { + if(pf2->type != pid->type) { + /* todo report error */ + ptcache_file_close(pf2); + pf2 = NULL; + } + else if(pid->read_header(pf2)) { + ptcache_file_init_pointers(pf2); + totpoint2 = pf2->totpoint; + index2 = pf->data_types & BPHYS_DATA_INDEX ? &pf2->data.index : &i; + } } else { - data1 = MEM_callocN(elemsize, "pointcache read data1"); - data2 = MEM_callocN(elemsize, "pointcache read data2"); + /* fall back to old cache file format */ + use_old = 1; + totpoint2 = pid->totpoint(pid->calldata); } + } - for(i=0; i<totelem; i++) { - if(pf && pf2) { - if(!BKE_ptcache_file_read_floats(pf, data1, incr)) { - BKE_ptcache_file_close(pf); - BKE_ptcache_file_close(pf2); - MEM_freeN(data1); - MEM_freeN(data2); - return 0; - } - if(!BKE_ptcache_file_read_floats(pf2, data2, incr)) { - BKE_ptcache_file_close(pf); - BKE_ptcache_file_close(pf2); - MEM_freeN(data1); - MEM_freeN(data2); - return 0; - } - reader->interpolate_elem(i, reader->calldata, frs_sec, cfra, (float)cfra1, (float)cfra2, data1, data2); + /* don't read old cache if allready simulated past cached frame */ + if(!pm && !pf && cfra1 && cfra1 <= pid->cache->simframe) + error = 1; + if(cfra1 && cfra1==cfra2) + error = 1; + + if(!error) + { + if(pf && pid->read_stream) { + if(totpoint != pid->totpoint(pid->calldata)) + error = 1; + else + { + // we have stream writing here + pid->read_stream(pf, pid->calldata); + } + } + } + + totpoint = MIN2(totpoint, pid->totpoint(pid->calldata)); + + if(!error) + { + for(i=0; i<totpoint; i++) { + /* read old cache file format */ + if(use_old) { + if(pid->read_elem && ptcache_file_read(pf, (void*)old_data1, 1, old_elemsize)) + pid->read_elem(i, pid->calldata, NULL, frs_sec, cfra, old_data1); + else if(pid->read_elem) + { error = 1; break; } } else { - reader->interpolate_elem(i, reader->calldata, frs_sec, cfra, (float)cfra1, (float)cfra2, data1, data2); - data1 += incr; - data2 += incr; + if(pid->read_elem && (pm || ptcache_file_read_data(pf))) + pid->read_elem(*index, pid->calldata, pm ? pm->cur : pf->cur, frs_sec, cfra1 ? (float)cfra1 : (float)cfrai, NULL); + else if(pid->read_elem) + { error = 1; break; } } - } - if(pf) { - BKE_ptcache_file_close(pf); - pf = NULL; - BKE_ptcache_file_close(pf2); - pf2 = NULL; - MEM_freeN(data1); - MEM_freeN(data2); + if(pm) { + ptcache_mem_incr_pointers(pm); + index = pm->data_types & (1<<BPHYS_DATA_INDEX) ? pm->cur[BPHYS_DATA_INDEX] : &i; + } } - - ret = PTCACHE_READ_INTERPOLATED; } - else if(pf || pm) { - /* use last valid cache frame */ - float *data; - - /* don't read cache if allready simulated past cached frame */ - if(cfra1 && cfra1 <= pid->cache->simframe) { - if(pf) - BKE_ptcache_file_close(pf); - if(pf2) - BKE_ptcache_file_close(pf2); - return 0; + if(!error) + { + if(pf2 && pid->read_stream) { + if(totpoint2 != pid->totpoint(pid->calldata)) + error = 1; + else + { + // we have stream writing here + pid->read_stream(pf2, pid->calldata); + } } + } - if(pm) - data = pm->data; - else - data = MEM_callocN(elemsize, "pointcache read data"); - - for(i=0; i<totelem; i++) { - if(pf) { - if(!BKE_ptcache_file_read_floats(pf, data, incr)) { - BKE_ptcache_file_close(pf); - if(pf2) - BKE_ptcache_file_close(pf2); - return 0; + totpoint2 = MIN2(totpoint2, pid->totpoint(pid->calldata)); + + if(!error) + { + for(i=0; i<totpoint2; i++) { + /* read old cache file format */ + if(use_old) { + if(pid->read_elem && ptcache_file_read(pf2, (void*)old_data2, 1, old_elemsize)) { + if(!pf && pf2) + pid->read_elem(i, pid->calldata, NULL, frs_sec, (float)cfra2, old_data2); + else if(pid->interpolate_elem) + pid->interpolate_elem(i, pid->calldata, NULL, frs_sec, cfra, (float)cfra1, (float)cfra2, old_data2); + else + { error = 1; break; } } - reader->set_elem(i, reader->calldata, data); + else if(pid->read_elem) + { error = 1; break; } } else { - reader->set_elem(i, reader->calldata, data); - data += incr; + if(pid->read_elem && (pm2 || ptcache_file_read_data(pf2))) { + if((!pf && pf2) || (!pm && pm2)) + pid->read_elem(*index2, pid->calldata, pm2 ? pm2->cur : pf2->cur, frs_sec, (float)cfra2, NULL); + else if(pid->interpolate_elem) + pid->interpolate_elem(*index2, pid->calldata, pm2 ? pm2->cur : pf2->cur, frs_sec, cfra, (float)cfra1, (float)cfra2, NULL); + else + { error = 1; break; } + } + else if(pid->read_elem) + { error = 1; break; } } - } - if(pf) { - BKE_ptcache_file_close(pf); - pf = NULL; - MEM_freeN(data); - } - if(pf2) { - BKE_ptcache_file_close(pf2); - pf = NULL; + if(pm2) { + ptcache_mem_incr_pointers(pm2); + index2 = pm2->data_types & (1<<BPHYS_DATA_INDEX) ? pm2->cur[BPHYS_DATA_INDEX] : &i; + } } + } + if(pm || pf) + ret = (pm2 || pf2) ? PTCACHE_READ_INTERPOLATED : PTCACHE_READ_EXACT; + else if(pm2 || pf2) { ret = PTCACHE_READ_OLD; + pid->cache->simframe = old_frame; } - if(pf) - BKE_ptcache_file_close(pf); - if(pf2) - BKE_ptcache_file_close(pf2); + if(pf) { + ptcache_file_close(pf); + pf = NULL; + } + + if(pf2) { + ptcache_file_close(pf2); + pf = NULL; + } if((pid->cache->flag & PTCACHE_QUICK_CACHE)==0) { + cfrai = (int)cfra; /* clear invalid cache frames so that better stuff can be simulated */ if(pid->cache->flag & PTCACHE_OUTDATED) { - BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_AFTER, cfra); + BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_AFTER, cfrai); } else if(pid->cache->flag & PTCACHE_FRAMES_SKIPPED) { if(cfra <= pid->cache->last_exact) pid->cache->flag &= ~PTCACHE_FRAMES_SKIPPED; - BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_AFTER, MAX2(cfra,pid->cache->last_exact)); + BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_AFTER, MAX2(cfrai,pid->cache->last_exact)); } } - return ret; + return (error ? 0 : ret); } +/* TODO for later */ +//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; +//} /* writes cache to disk or memory */ -int BKE_ptcache_write_cache(PTCacheWriter *writer) +int BKE_ptcache_write_cache(PTCacheID *pid, int cfra) { - PointCache *cache = writer->pid->cache; + PointCache *cache = pid->cache; PTCacheFile *pf= NULL; - int elemsize = ptcache_pid_elemsize(writer->pid); - int i, incr = elemsize / sizeof(float); + int i; + int totpoint = pid->totpoint(pid->calldata); int add = 0, overwrite = 0; - float temp[14]; - if(writer->totelem == 0 || writer->cfra <= 0) + if(totpoint == 0 || cfra < 0 + || (cfra ? pid->data_types == 0 : pid->info_types == 0)) return 0; if(cache->flag & PTCACHE_DISK_CACHE) { - int cfra = cache->endframe; + int efra = cache->endframe; + if(cfra==0) + add = 1; /* allways start from scratch on the first frame */ - if(writer->cfra == cache->startframe) { - BKE_ptcache_id_clear(writer->pid, PTCACHE_CLEAR_ALL, writer->cfra); + else if(cfra == cache->startframe) { + BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, cfra); cache->flag &= ~PTCACHE_REDO_NEEDED; add = 1; } else { - int ocfra; + int ofra; /* find last cached frame */ - while(cfra > cache->startframe && !BKE_ptcache_id_exist(writer->pid, cfra)) - cfra--; + while(efra > cache->startframe && !BKE_ptcache_id_exist(pid, efra)) + efra--; /* find second last cached frame */ - ocfra = cfra-1; - while(ocfra > cache->startframe && !BKE_ptcache_id_exist(writer->pid, ocfra)) - ocfra--; + ofra = efra-1; + while(ofra > cache->startframe && !BKE_ptcache_id_exist(pid, ofra)) + ofra--; - if(cfra >= cache->startframe && writer->cfra > cfra) { - if(ocfra >= cache->startframe && cfra - ocfra < cache->step) + if(efra >= cache->startframe && cfra > efra) { + if(ofra >= cache->startframe && efra - ofra < cache->step) overwrite = 1; else add = 1; @@ -674,74 +1490,92 @@ int BKE_ptcache_write_cache(PTCacheWriter *writer) if(add || overwrite) { if(overwrite) - BKE_ptcache_id_clear(writer->pid, PTCACHE_CLEAR_FRAME, cfra); + BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_FRAME, efra); - pf = BKE_ptcache_file_open(writer->pid, PTCACHE_FILE_WRITE, writer->cfra); + pf = ptcache_file_open(pid, PTCACHE_FILE_WRITE, cfra); if(!pf) return 0; - for(i=0; i<writer->totelem; i++) { - writer->set_elem(i, writer->calldata, temp); - BKE_ptcache_file_write_floats(pf, temp, incr); + pf->type = pid->type; + pf->totpoint = cfra ? totpoint : pid->totwrite(pid->calldata); + pf->data_types = cfra ? pid->data_types : pid->info_types; + + if(!ptcache_file_write_header_begin(pf) || !pid->write_header(pf)) { + ptcache_file_close(pf); + return 0; + } + + ptcache_file_init_pointers(pf); + + if(pf && pid->write_stream) { + // we have stream writing here + pid->write_stream(pf, pid->calldata); } + else + for(i=0; i<totpoint; i++) { + if(pid->write_elem && pid->write_elem(i, pid->calldata, pf->cur)) + if(!ptcache_file_write_data(pf)) { + ptcache_file_close(pf); + return 0; + } + } } } else { PTCacheMem *pm; PTCacheMem *pm2; - float *pmdata; pm2 = cache->mem_cache.first; + /* don't write info file in memory */ + if(cfra==0) + return 1; /* allways start from scratch on the first frame */ - if(writer->cfra == cache->startframe) { - BKE_ptcache_id_clear(writer->pid, PTCACHE_CLEAR_ALL, writer->cfra); + if(cfra == cache->startframe) { + BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, cfra); cache->flag &= ~PTCACHE_REDO_NEEDED; add = 1; } - else { + else if (cache->mem_cache.last) { pm2 = cache->mem_cache.last; - if(pm2 && writer->cfra > pm2->frame) { + if(pm2 && cfra > pm2->frame) { if(pm2->prev && pm2->frame - pm2->prev->frame < cache->step) overwrite = 1; else add = 1; } } + else + add = 1; - if(overwrite) { - pm = cache->mem_cache.last; - pmdata = pm->data; - - for(i=0; i<writer->totelem; i++, pmdata+=incr) { - writer->set_elem(i, writer->calldata, temp); - memcpy(pmdata, temp, elemsize); - } + if(add || overwrite) { + if(overwrite) + BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_FRAME, pm2->frame); - pm->frame = writer->cfra; - } - else if(add) { pm = MEM_callocN(sizeof(PTCacheMem), "Pointcache mem"); - pm->data = MEM_callocN(elemsize * writer->totelem, "Pointcache mem data"); - pmdata = pm->data; - for(i=0; i<writer->totelem; i++, pmdata+=incr) { - writer->set_elem(i, writer->calldata, temp); - memcpy(pmdata, temp, elemsize); - } + pm->totpoint = pid->totwrite(pid->calldata); + pm->data_types = cfra ? pid->data_types : pid->info_types; - pm->frame = writer->cfra; - pm->totpoint = writer->totelem; + ptcache_alloc_data(pm); + ptcache_mem_init_pointers(pm); + for(i=0; i<totpoint; i++) { + if(pid->write_elem && pid->write_elem(i, pid->calldata, pm->cur)) + ptcache_mem_incr_pointers(pm); + } + //ptcache_make_index_array(pm, pid->totpoint(pid->calldata)); + + pm->frame = cfra; BLI_addtail(&cache->mem_cache, pm); } } if(add || overwrite) { - if(writer->cfra - cache->last_exact == 1 - || writer->cfra == cache->startframe) { - cache->last_exact = writer->cfra; + if(cfra - cache->last_exact == 1 + || cfra == cache->startframe) { + cache->last_exact = cfra; cache->flag &= ~PTCACHE_FRAMES_SKIPPED; } else @@ -749,9 +1583,9 @@ int BKE_ptcache_write_cache(PTCacheWriter *writer) } if(pf) - BKE_ptcache_file_close(pf); + ptcache_file_close(pf); - BKE_ptcache_update_info(writer->pid); + BKE_ptcache_update_info(pid); return 1; } @@ -759,7 +1593,7 @@ int BKE_ptcache_write_cache(PTCacheWriter *writer) * mode - PTCACHE_CLEAR_ALL, */ - +/* Clears & resets */ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, int cfra) { int len; /* store the length of the string */ @@ -806,7 +1640,7 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, int cfra) BLI_delete(path_full, 0, 0); } else { /* read the number of the file */ - int frame, len2 = strlen(de->d_name); + int frame, len2 = (int)strlen(de->d_name); char num[7]; if (len2 > 15) { /* could crash if trying to copy a string out of this range*/ @@ -833,7 +1667,7 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, int cfra) if(mode == PTCACHE_CLEAR_ALL) { pid->cache->last_exact = 0; for(; pm; pm=pm->next) - MEM_freeN(pm->data); + ptcache_free_data(pm->data); BLI_freelistN(&pid->cache->mem_cache); } else { while(pm) { @@ -841,7 +1675,7 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, int cfra) (mode==PTCACHE_CLEAR_AFTER && pm->frame > cfra) ) { link = pm; pm = pm->next; - MEM_freeN(link->data); + ptcache_free_data(link->data); BLI_freelinkN(&pid->cache->mem_cache, link); } else @@ -863,7 +1697,7 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, int cfra) for(; pm; pm=pm->next) { if(pm->frame == cfra) { - MEM_freeN(pm->data); + ptcache_free_data(pm->data); BLI_freelinkN(&pid->cache->mem_cache, pm); break; } @@ -985,11 +1819,13 @@ int BKE_ptcache_id_reset(Scene *scene, PTCacheID *pid, int mode) cache->last_exact= 0; if(pid->type == PTCACHE_TYPE_CLOTH) - cloth_free_modifier(pid->ob, pid->data); + cloth_free_modifier(pid->ob, pid->calldata); else if(pid->type == PTCACHE_TYPE_SOFTBODY) - sbFreeSimulation(pid->data); + sbFreeSimulation(pid->calldata); else if(pid->type == PTCACHE_TYPE_PARTICLES) - psys_reset(pid->data, PSYS_RESET_DEPSGRAPH); + psys_reset(pid->calldata, PSYS_RESET_DEPSGRAPH); + else if(pid->type == PTCACHE_TYPE_SMOKE_DOMAIN) + smokeModifier_reset(pid->calldata); } if(clear) BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, 0); @@ -1038,6 +1874,14 @@ int BKE_ptcache_object_reset(Scene *scene, Object *ob, int mode) BKE_ptcache_id_from_cloth(&pid, ob, (ClothModifierData*)md); reset |= BKE_ptcache_id_reset(scene, &pid, mode); } + if(md->type == eModifierType_Smoke) { + SmokeModifierData *smd = (SmokeModifierData *)md; + if(smd->type & MOD_SMOKE_TYPE_DOMAIN) + { + BKE_ptcache_id_from_smoke(&pid, ob, (SmokeModifierData*)md); + reset |= BKE_ptcache_id_reset(scene, &pid, mode); + } + } } return reset; @@ -1107,9 +1951,9 @@ int BKE_ptcache_get_continue_physics() return CONTINUE_PHYSICS; } -/* Point Cache */ +/* Point Cache handling */ -PointCache *BKE_ptcache_add() +PointCache *BKE_ptcache_add(ListBase *ptcaches) { PointCache *cache; @@ -1117,24 +1961,43 @@ PointCache *BKE_ptcache_add() cache->startframe= 1; cache->endframe= 250; cache->step= 10; + cache->index = -1; + + BLI_addtail(ptcaches, cache); return cache; } -void BKE_ptcache_free(PointCache *cache) +void BKE_ptache_free_mem(PointCache *cache) { PTCacheMem *pm = cache->mem_cache.first; + if(pm) { - for(; pm; pm=pm->next) - MEM_freeN(pm->data); + for(; pm; pm=pm->next) { + ptcache_free_data(pm->data); + if(pm->index_array) + MEM_freeN(pm->index_array); + } BLI_freelistN(&cache->mem_cache); } - +} +void BKE_ptcache_free(PointCache *cache) +{ + BKE_ptache_free_mem(cache); MEM_freeN(cache); } +void BKE_ptcache_free_list(ListBase *ptcaches) +{ + PointCache *cache = ptcaches->first; + + for(; cache; cache=cache->next) + BKE_ptache_free_mem(cache); -PointCache *BKE_ptcache_copy(PointCache *cache) + BLI_freelistN(ptcaches); +} + +static PointCache *ptcache_copy(PointCache *cache) { PointCache *ncache; @@ -1149,7 +2012,18 @@ PointCache *BKE_ptcache_copy(PointCache *cache) return ncache; } +/* returns first point cache */ +PointCache *BKE_ptcache_copy_list(ListBase *ptcaches_new, ListBase *ptcaches_old) +{ + PointCache *cache = ptcaches_old->first; + + ptcaches_new->first = ptcaches_new->last = NULL; + + for(; cache; cache=cache->next) + BLI_addtail(ptcaches_new, ptcache_copy(cache)); + return ptcaches_new->first; +} /* Baking */ @@ -1210,7 +2084,7 @@ void BKE_ptcache_make_cache(PTCacheBaker* baker) Base *base; ListBase pidlist; PTCacheID *pid = baker->pid; - PointCache *cache; + PointCache *cache = NULL; float frameleno = scene->r.framelen; int cfrao = CFRA; int startframe = MAXFRAME; @@ -1227,7 +2101,7 @@ void BKE_ptcache_make_cache(PTCacheBaker* baker) cache = pid->cache; if((cache->flag & PTCACHE_BAKED)==0) { if(pid->type==PTCACHE_TYPE_PARTICLES) - psys_get_pointcache_start_end(scene, pid->data, &cache->startframe, &cache->endframe); + psys_get_pointcache_start_end(scene, pid->calldata, &cache->startframe, &cache->endframe); if(bake || cache->flag & PTCACHE_REDO_NEEDED) BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, 0); @@ -1253,12 +2127,12 @@ void BKE_ptcache_make_cache(PTCacheBaker* baker) cache = pid->cache; if((cache->flag & PTCACHE_BAKED)==0) { if(pid->type==PTCACHE_TYPE_PARTICLES) { - ParticleSystem *psys = (ParticleSystem*)pid->data; + ParticleSystem *psys = (ParticleSystem*)pid->calldata; /* skip hair & keyed particles */ if(psys->part->type == PART_HAIR || psys->part->phystype == PART_PHYS_KEYED) continue; - psys_get_pointcache_start_end(scene, pid->data, &cache->startframe, &cache->endframe); + psys_get_pointcache_start_end(scene, pid->calldata, &cache->startframe, &cache->endframe); } if((cache->flag & PTCACHE_REDO_NEEDED || (cache->flag & PTCACHE_SIMULATION_VALID)==0) @@ -1285,10 +2159,10 @@ void BKE_ptcache_make_cache(PTCacheBaker* baker) scene->r.framelen = 1.0; for(; CFRA <= endframe; CFRA+=step) { - float prog; + int prog; if(bake) - prog = (int)(100.0 * (float)(CFRA - startframe)/(float)(endframe-startframe)); + prog = (int)(100.0f * (float)(CFRA - startframe)/(float)(endframe-startframe)); else prog = CFRA; @@ -1307,15 +2181,19 @@ void BKE_ptcache_make_cache(PTCacheBaker* baker) if(pid) { cache->flag &= ~(PTCACHE_BAKING|PTCACHE_REDO_NEEDED); cache->flag |= PTCACHE_SIMULATION_VALID; - if(bake) + if(bake) { cache->flag |= PTCACHE_BAKED; + /* write info file */ + if(cache->flag & PTCACHE_DISK_CACHE) + BKE_ptcache_write_cache(pid, 0); + } } else for(base=scene->base.first; base; base= base->next) { BKE_ptcache_ids_from_object(&pidlist, base->object); for(pid=pidlist.first; pid; pid=pid->next) { /* skip hair particles */ - if(pid->type==PTCACHE_TYPE_PARTICLES && ((ParticleSystem*)pid->data)->part->type == PART_HAIR) + if(pid->type==PTCACHE_TYPE_PARTICLES && ((ParticleSystem*)pid->calldata)->part->type == PART_HAIR) continue; cache = pid->cache; @@ -1327,8 +2205,11 @@ void BKE_ptcache_make_cache(PTCacheBaker* baker) cache->flag |= PTCACHE_SIMULATION_VALID; - if(bake) + if(bake) { cache->flag |= PTCACHE_BAKED; + if(cache->flag & PTCACHE_DISK_CACHE) + BKE_ptcache_write_cache(pid, 0); + } } BLI_freelistN(&pidlist); } @@ -1341,97 +2222,141 @@ void BKE_ptcache_make_cache(PTCacheBaker* baker) /* TODO: call redraw all windows somehow */ } - -void BKE_ptcache_toggle_disk_cache(PTCacheID *pid) { +/* Helpers */ +void BKE_ptcache_disk_to_mem(PTCacheID *pid) +{ PointCache *cache = pid->cache; PTCacheFile *pf; PTCacheMem *pm; - int totelem=0; - int float_count=0; - int tot; - int last_exact = cache->last_exact; - if (!G.relbase_valid){ - cache->flag &= ~PTCACHE_DISK_CACHE; - printf("File must be saved before using disk cache!\n"); - return; - } + int cfra, sfra = cache->startframe, efra = cache->endframe; + int i; - totelem = ptcache_pid_totelem(pid); - float_count = ptcache_pid_elemsize(pid) / sizeof(float); + BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, 0); - if(totelem==0 || float_count==0) - return; + for(cfra=sfra; cfra <= efra; cfra++) { + pf = ptcache_file_open(pid, PTCACHE_FILE_READ, cfra); - tot = totelem*float_count; + if(pf) { + if(!ptcache_file_read_header_begin(pf)) { + printf("Can't yet convert old cache format\n"); + cache->flag |= PTCACHE_DISK_CACHE; + ptcache_file_close(pf); + return; + } - /* MEM -> DISK */ - if(cache->flag & PTCACHE_DISK_CACHE) { - pm = cache->mem_cache.first; + if(pf->type != pid->type || !pid->read_header(pf)) { + cache->flag |= PTCACHE_DISK_CACHE; + ptcache_file_close(pf); + return; + } + + pm = MEM_callocN(sizeof(PTCacheMem), "Pointcache mem"); - BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, 0); + pm->totpoint = pf->totpoint; + pm->data_types = pf->data_types; + pm->frame = cfra; - for(; pm; pm=pm->next) { - pf = BKE_ptcache_file_open(pid, PTCACHE_FILE_WRITE, pm->frame); + ptcache_alloc_data(pm); + ptcache_mem_init_pointers(pm); + ptcache_file_init_pointers(pf); - if(pf) { - if(fwrite(pm->data, sizeof(float), tot, pf->fp) != tot) { - printf("Error writing to disk cache\n"); + for(i=0; i<pm->totpoint; i++) { + if(!ptcache_file_read_data(pf)) { + printf("Error reading from disk cache\n"); - cache->flag &= ~PTCACHE_DISK_CACHE; + cache->flag |= PTCACHE_DISK_CACHE; + + ptcache_free_data(pm->data); + MEM_freeN(pm); + ptcache_file_close(pf); - BKE_ptcache_file_close(pf); return; } - BKE_ptcache_file_close(pf); + ptcache_copy_data(pf->cur, pm->cur); + ptcache_mem_incr_pointers(pm); } - else - printf("Error creating disk cache file\n"); - } - cache->flag &= ~PTCACHE_DISK_CACHE; - BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, 0); - cache->flag |= PTCACHE_DISK_CACHE; + //ptcache_make_index_array(pm, pid->totpoint(pid->calldata)); + + BLI_addtail(&pid->cache->mem_cache, pm); + + ptcache_file_close(pf); + } } - /* DISK -> MEM */ - else { - int cfra; - int sfra = cache->startframe; - int efra = cache->endframe; - BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, 0); +} +void BKE_ptcache_mem_to_disk(PTCacheID *pid) +{ + PointCache *cache = pid->cache; + PTCacheFile *pf; + PTCacheMem *pm; + int i; - for(cfra=sfra; cfra <= efra; cfra++) { - pf = BKE_ptcache_file_open(pid, PTCACHE_FILE_READ, cfra); + pm = cache->mem_cache.first; - if(pf) { - pm = MEM_callocN(sizeof(PTCacheMem), "Pointcache mem"); - pm->data = MEM_callocN(sizeof(float)*tot, "Pointcache mem data"); + BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, 0); - if(fread(pm->data, sizeof(float), tot, pf->fp)!= tot) { - printf("Error reading from disk cache\n"); + for(; pm; pm=pm->next) { + pf = ptcache_file_open(pid, PTCACHE_FILE_WRITE, pm->frame); - cache->flag |= PTCACHE_DISK_CACHE; + if(pf) { + pf->data_types = pm->data_types; + pf->totpoint = pm->totpoint; + pf->type = pid->type; - MEM_freeN(pm->data); - MEM_freeN(pm); - BKE_ptcache_file_close(pf); - return; - } + ptcache_mem_init_pointers(pm); + ptcache_file_init_pointers(pf); - pm->frame = cfra; - pm->totpoint = totelem; + if(!ptcache_file_write_header_begin(pf) || !pid->write_header(pf)) { + printf("Error writing to disk cache\n"); + cache->flag &= ~PTCACHE_DISK_CACHE; - BLI_addtail(&pid->cache->mem_cache, pm); + ptcache_file_close(pf); + return; + } + + for(i=0; i<pm->totpoint; i++) { + ptcache_copy_data(pm->cur, pf->cur); + if(!ptcache_file_write_data(pf)) { + printf("Error writing to disk cache\n"); + cache->flag &= ~PTCACHE_DISK_CACHE; - BKE_ptcache_file_close(pf); + ptcache_file_close(pf); + return; + } + ptcache_mem_incr_pointers(pm); } + + ptcache_file_close(pf); + + /* write info file */ + if(cache->flag & PTCACHE_BAKED) + BKE_ptcache_write_cache(pid, 0); } + else + printf("Error creating disk cache file\n"); + } +} +void BKE_ptcache_toggle_disk_cache(PTCacheID *pid) +{ + PointCache *cache = pid->cache; + int last_exact = cache->last_exact; - cache->flag |= PTCACHE_DISK_CACHE; - BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, 0); + if (!G.relbase_valid){ cache->flag &= ~PTCACHE_DISK_CACHE; + printf("File must be saved before using disk cache!\n"); + return; } + + if(cache->flag & PTCACHE_DISK_CACHE) + BKE_ptcache_mem_to_disk(pid); + else + BKE_ptcache_disk_to_mem(pid); + + cache->flag ^= PTCACHE_DISK_CACHE; + BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, 0); + cache->flag ^= PTCACHE_DISK_CACHE; cache->last_exact = last_exact; @@ -1440,15 +2365,16 @@ void BKE_ptcache_toggle_disk_cache(PTCacheID *pid) { void BKE_ptcache_load_external(PTCacheID *pid) { + /*todo*/ PointCache *cache = pid->cache; int len; /* store the length of the string */ + int info = 0; /* mode is same as fopen's modes */ DIR *dir; struct dirent *de; char path[MAX_PTCACHE_PATH]; char filename[MAX_PTCACHE_FILE]; - char path_full[MAX_PTCACHE_FILE]; char ext[MAX_PTCACHE_PATH]; if(!cache) @@ -1475,15 +2401,19 @@ void BKE_ptcache_load_external(PTCacheID *pid) if (strstr(de->d_name, ext)) { /* do we have the right extension?*/ if (strncmp(filename, de->d_name, len ) == 0) { /* do we have the right prefix */ /* read the number of the file */ - int frame, len2 = strlen(de->d_name); + int frame, len2 = (int)strlen(de->d_name); char num[7]; if (len2 > 15) { /* could crash if trying to copy a string out of this range*/ BLI_strncpy(num, de->d_name + (strlen(de->d_name) - 15), sizeof(num)); frame = atoi(num); - cache->startframe = MIN2(cache->startframe, frame); - cache->endframe = MAX2(cache->endframe, frame); + if(frame) { + cache->startframe = MIN2(cache->startframe, frame); + cache->endframe = MAX2(cache->endframe, frame); + } + else + info = 1; } } } @@ -1492,18 +2422,36 @@ void BKE_ptcache_load_external(PTCacheID *pid) if(cache->startframe != MAXFRAME) { PTCacheFile *pf; - int elemsize = ptcache_pid_elemsize(pid); - int incr = elemsize / sizeof(float); - float *data = NULL; - pf= BKE_ptcache_file_open(pid, PTCACHE_FILE_READ, cache->startframe); - if(pf) { - data = MEM_callocN(elemsize, "pointcache read data"); - while(BKE_ptcache_file_read_floats(pf, data, incr)) - cache->totpoint++; - - BKE_ptcache_file_close(pf); - MEM_freeN(data); + /* read totpoint from info file (frame 0) */ + if(info) { + pf= ptcache_file_open(pid, PTCACHE_FILE_READ, 0); + + if(pf) { + if(ptcache_file_read_header_begin(pf)) { + if(pf->type == pid->type && pid->read_header(pf)) { + cache->totpoint = pf->totpoint; + cache->flag |= PTCACHE_READ_INFO; + } + else { + cache->totpoint = 0; + } + } + ptcache_file_close(pf); + } + } + /* or from any old format cache file */ + else { + float old_data[14]; + int elemsize = ptcache_pid_old_elemsize(pid); + pf= ptcache_file_open(pid, PTCACHE_FILE_READ, cache->startframe); + + if(pf) { + while(ptcache_file_read(pf, old_data, 1, elemsize)) + cache->totpoint++; + + ptcache_file_close(pf); + } } } @@ -1511,3 +2459,65 @@ void BKE_ptcache_load_external(PTCacheID *pid) BKE_ptcache_update_info(pid); } + +void BKE_ptcache_update_info(PTCacheID *pid) +{ + PointCache *cache = pid->cache; + int totframes = 0; + char mem_info[64]; + + if(cache->flag & PTCACHE_EXTERNAL) { + int cfra = cache->startframe; + + for(; cfra<=cache->endframe; cfra++) { + if(BKE_ptcache_id_exist(pid, cfra)) + totframes++; + } + + if(totframes && cache->totpoint) + sprintf(cache->info, "%i points found!", cache->totpoint); + else + sprintf(cache->info, "No valid data to read!"); + return; + } + + if(cache->flag & PTCACHE_DISK_CACHE) { + int cfra = cache->startframe; + + for(; cfra<=cache->endframe; cfra++) { + if(BKE_ptcache_id_exist(pid, cfra)) + totframes++; + } + + sprintf(mem_info, "%i frames on disk", totframes); + } + else { + PTCacheMem *pm = cache->mem_cache.first; + float framesize = 0.0f, bytes = 0.0f; + int mb; + + if(pm) + framesize = (float)ptcache_pid_old_elemsize(pid) * (float)pm->totpoint; + + for(; pm; pm=pm->next) + totframes++; + + bytes = totframes * framesize; + + mb = (bytes > 1024.0f * 1024.0f); + + sprintf(mem_info, "%i frames in memory (%.1f %s)", + totframes, + bytes / (mb ? 1024.0f * 1024.0f : 1024.0f), + mb ? "Mb" : "kb"); + } + + if(cache->flag & PTCACHE_OUTDATED) { + sprintf(cache->info, "%s, cache is outdated!", mem_info); + } + else if(cache->flag & PTCACHE_FRAMES_SKIPPED) { + sprintf(cache->info, "%s, not exact since frame %i.", mem_info, cache->last_exact); + } + else + sprintf(cache->info, "%s.", mem_info); +} diff --git a/source/blender/blenkernel/intern/sca.c b/source/blender/blenkernel/intern/sca.c index 74d2347ec39..139895bbdaf 100644 --- a/source/blender/blenkernel/intern/sca.c +++ b/source/blender/blenkernel/intern/sca.c @@ -35,6 +35,8 @@ #include <stdio.h> #include <string.h> +#include <float.h> + #include "MEM_guardedalloc.h" #include "DNA_text_types.h" @@ -410,6 +412,7 @@ void init_actuator(bActuator *act) { /* also use when actuator changes type */ bObjectActuator *oa; + bSoundActuator *sa; if(act->data) MEM_freeN(act->data); act->data= 0; @@ -422,10 +425,14 @@ void init_actuator(bActuator *act) break; #endif case ACT_SOUND: - act->data= MEM_callocN(sizeof(bSoundActuator), "soundact"); - break; - case ACT_CD: - act->data= MEM_callocN(sizeof(bCDActuator), "cdact"); + sa = act->data= MEM_callocN(sizeof(bSoundActuator), "soundact"); + sa->volume = 1.0f; + sa->sound3D.rolloff_factor = 1.0f; + sa->sound3D.reference_distance = 1.0f; + sa->sound3D.max_gain = 1.0f; + sa->sound3D.cone_inner_angle = 360.0f; + sa->sound3D.cone_outer_angle = 360.0f; + sa->sound3D.max_distance = FLT_MAX; break; case ACT_OBJECT: act->data= MEM_callocN(sizeof(bObjectActuator), "objectact"); diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index d629654c426..6dd362d15a8 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -54,6 +54,7 @@ #include "DNA_meta_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" +#include "DNA_screen_types.h" #include "DNA_texture_types.h" #include "DNA_userdef_types.h" @@ -75,8 +76,8 @@ #include "BKE_main.h" #include "BKE_node.h" #include "BKE_object.h" +#include "BKE_paint.h" #include "BKE_scene.h" -#include "BKE_sculpt.h" #include "BKE_sequence.h" #include "BKE_world.h" #include "BKE_utildefines.h" @@ -125,7 +126,113 @@ void free_qtcodecdata(QuicktimeCodecData *qcd) } } -/* copy_scene moved to src/header_info.c... should be back */ +Scene *copy_scene(Main *bmain, Scene *sce, int type) +{ + Scene *scen; + ToolSettings *ts; + Base *base, *obase; + + if(type == SCE_COPY_EMPTY) { + ListBase lb; + scen= add_scene(sce->id.name+2); + + lb= scen->r.layers; + scen->r= sce->r; + scen->r.layers= lb; + } + else { + scen= copy_libblock(sce); + BLI_duplicatelist(&(scen->base), &(sce->base)); + + clear_id_newpoins(); + + id_us_plus((ID *)scen->world); + id_us_plus((ID *)scen->set); + id_us_plus((ID *)scen->ima); + id_us_plus((ID *)scen->gm.dome.warptext); + + scen->ed= NULL; + scen->theDag= NULL; + scen->obedit= NULL; + scen->toolsettings= MEM_dupallocN(sce->toolsettings); + scen->stats= NULL; + + ts= scen->toolsettings; + if(ts) { + if(ts->vpaint) { + ts->vpaint= MEM_dupallocN(ts->vpaint); + ts->vpaint->paintcursor= NULL; + ts->vpaint->vpaint_prev= NULL; + ts->vpaint->wpaint_prev= NULL; + copy_paint(&ts->vpaint->paint, &ts->vpaint->paint); + } + if(ts->wpaint) { + ts->wpaint= MEM_dupallocN(ts->wpaint); + ts->wpaint->paintcursor= NULL; + ts->wpaint->vpaint_prev= NULL; + ts->wpaint->wpaint_prev= NULL; + copy_paint(&ts->wpaint->paint, &ts->wpaint->paint); + } + if(ts->sculpt) { + ts->sculpt= MEM_dupallocN(ts->sculpt); + copy_paint(&ts->sculpt->paint, &ts->sculpt->paint); + } + + copy_paint(&ts->imapaint.paint, &ts->imapaint.paint); + ts->imapaint.paintcursor= NULL; + + ts->particle.paintcursor= NULL; + } + + BLI_duplicatelist(&(scen->markers), &(sce->markers)); + BLI_duplicatelist(&(scen->transform_spaces), &(sce->transform_spaces)); + BLI_duplicatelist(&(scen->r.layers), &(sce->r.layers)); + BKE_keyingsets_copy(&(scen->keyingsets), &(sce->keyingsets)); + + scen->nodetree= ntreeCopyTree(sce->nodetree, 0); + + obase= sce->base.first; + base= scen->base.first; + while(base) { + id_us_plus(&base->object->id); + if(obase==sce->basact) scen->basact= base; + + obase= obase->next; + base= base->next; + } + } + + /* make a private copy of the avicodecdata */ + if(sce->r.avicodecdata) { + scen->r.avicodecdata = MEM_dupallocN(sce->r.avicodecdata); + scen->r.avicodecdata->lpFormat = MEM_dupallocN(scen->r.avicodecdata->lpFormat); + scen->r.avicodecdata->lpParms = MEM_dupallocN(scen->r.avicodecdata->lpParms); + } + + /* make a private copy of the qtcodecdata */ + if(sce->r.qtcodecdata) { + scen->r.qtcodecdata = MEM_dupallocN(sce->r.qtcodecdata); + scen->r.qtcodecdata->cdParms = MEM_dupallocN(scen->r.qtcodecdata->cdParms); + } + + /* NOTE: part of SCE_COPY_LINK_DATA and SCE_COPY_FULL operations + * are done outside of blenkernel with ED_objects_single_users! */ + + /* camera */ + if(type == SCE_COPY_LINK_DATA || type == SCE_COPY_FULL) { + ID_NEW(scen->camera); + } + + /* world */ + if(type == SCE_COPY_FULL) { + if(scen->world) { + id_us_plus((ID *)scen->world); + scen->world= copy_world(scen->world); + } + } + + return scen; +} /* do not free scene itself */ void free_scene(Scene *sce) @@ -140,7 +247,7 @@ void free_scene(Scene *sce) /* do not free objects! */ BLI_freelistN(&sce->base); - seq_free_editing(sce->ed); + seq_free_editing(sce); BKE_free_animdata((ID *)sce); BKE_keyingsets_free(&sce->keyingsets); @@ -166,15 +273,20 @@ void free_scene(Scene *sce) BLI_freelistN(&sce->r.layers); if(sce->toolsettings) { - if(sce->toolsettings->vpaint) + if(sce->toolsettings->vpaint) { + free_paint(&sce->toolsettings->vpaint->paint); MEM_freeN(sce->toolsettings->vpaint); - if(sce->toolsettings->wpaint) + } + if(sce->toolsettings->wpaint) { + free_paint(&sce->toolsettings->wpaint->paint); MEM_freeN(sce->toolsettings->wpaint); + } if(sce->toolsettings->sculpt) { - sculptsession_free(sce->toolsettings->sculpt); + free_paint(&sce->toolsettings->sculpt->paint); MEM_freeN(sce->toolsettings->sculpt); } - + free_paint(&sce->toolsettings->imapaint.paint); + MEM_freeN(sce->toolsettings); sce->toolsettings = NULL; } @@ -188,6 +300,9 @@ void free_scene(Scene *sce) ntreeFreeTree(sce->nodetree); MEM_freeN(sce->nodetree); } + + if(sce->stats) + MEM_freeN(sce->stats); } Scene *add_scene(char *name) @@ -280,6 +395,9 @@ Scene *add_scene(char *name) sce->toolsettings->proportional_size = 1.0f; + + sce->unit.scale_length = 1.0f; + pset= &sce->toolsettings->particle; pset->flag= PE_KEEP_LENGTHS|PE_LOCK_FIRST|PE_DEFLECT_EMITTER; pset->emitterdist= 0.25f; @@ -294,7 +412,7 @@ Scene *add_scene(char *name) pset->brush[PE_BRUSH_CUT].strength= 100; sce->jumpframe = 10; - sce->audio.mixrate = 44100; + sce->r.audio.mixrate = 44100; strcpy(sce->r.backbuf, "//backbuf"); strcpy(sce->r.pic, U.renderdir); @@ -328,6 +446,9 @@ Scene *add_scene(char *name) sce->gm.physubstep = 1; sce->gm.maxphystep = 5; + sce->gm.flag = GAME_DISPLAY_LISTS; + sce->gm.matmode = GAME_MAT_MULTITEX; + return sce; } @@ -387,7 +508,7 @@ void set_scene_bg(Scene *scene) base->flag |= flag; /* not too nice... for recovering objects with lost data */ - if(ob->pose==NULL) base->flag &= ~OB_POSEMODE; + //if(ob->pose==NULL) base->flag &= ~OB_POSEMODE; ob->flag= base->flag; ob->ctime= -1234567.0; /* force ipo to be calculated later */ @@ -410,6 +531,30 @@ void set_scene_name(char *name) //XXX error("Can't find scene: %s", name); } +void unlink_scene(Main *bmain, Scene *sce, Scene *newsce) +{ + Scene *sce1; + bScreen *sc; + + /* check all sets */ + for(sce1= bmain->scene.first; sce1; sce1= sce1->id.next) + if(sce1->set == sce) + sce1->set= NULL; + + /* check all sequences */ + clear_scene_in_allseqs(sce); + + /* check render layer nodes in other scenes */ + clear_scene_in_nodes(bmain, sce); + + /* al screens */ + for(sc= bmain->screen.first; sc; sc= sc->id.next) + if(sc->scene == sce) + sc->scene= newsce; + + free_libblock(&bmain->scene, sce); +} + /* used by metaballs * doesnt return the original duplicated object, only dupli's */ @@ -674,26 +819,6 @@ void scene_add_render_layer(Scene *sce) srl->passflag= SCE_PASS_COMBINED|SCE_PASS_Z; } -void sculptsession_free(Sculpt *sculpt) -{ - SculptSession *ss= sculpt->session; - if(ss) { - if(ss->projverts) - MEM_freeN(ss->projverts); - - if(ss->fmap) - MEM_freeN(ss->fmap); - - if(ss->fmap_mem) - MEM_freeN(ss->fmap_mem); - - if(ss->texcache) - MEM_freeN(ss->texcache); - MEM_freeN(ss); - sculpt->session= NULL; - } -} - /* render simplification */ int get_render_subsurf_level(RenderData *r, int lvl) diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c index 2ee95ed928e..078258092f7 100644 --- a/source/blender/blenkernel/intern/seqeffects.c +++ b/source/blender/blenkernel/intern/seqeffects.c @@ -2792,6 +2792,10 @@ void sequence_effect_speed_rebuild_map(Sequence * seq, int force) if (!(force || seq->len != v->length || !v->frameMap)) { return; } + if (!seq->seq1) { /* make coverity happy and check for (CID 598) + input strip ... */ + return; + } if (!v->frameMap || v->length != seq->len) { if (v->frameMap) MEM_freeN(v->frameMap); @@ -2807,7 +2811,7 @@ void sequence_effect_speed_rebuild_map(Sequence * seq, int force) /* if there is no IPO, try to make retiming easy by stretching the strip */ // XXX old animation system - seq - if (/*!seq->ipo &&*/ seq->seq1 && seq->seq1->enddisp != seq->seq1->start + if (/*!seq->ipo &&*/ seq->seq1->enddisp != seq->seq1->start && seq->seq1->len != 0) { fallback_fac = (float) seq->seq1->len / (float) (seq->seq1->enddisp - seq->seq1->start); diff --git a/source/blender/blenkernel/intern/sequence.c b/source/blender/blenkernel/intern/sequence.c index 3b675a87e59..159a60ad3af 100644 --- a/source/blender/blenkernel/intern/sequence.c +++ b/source/blender/blenkernel/intern/sequence.c @@ -52,6 +52,10 @@ #include "BLI_threads.h" #include <pthread.h> +#include "BKE_context.h" +#include "BKE_sound.h" +#include "AUD_C-API.h" + #ifdef WIN32 #define snprintf _snprintf #endif @@ -178,12 +182,16 @@ void seq_free_strip(Strip *strip) MEM_freeN(strip); } -void seq_free_sequence(Editing *ed, Sequence *seq) +void seq_free_sequence(Scene *scene, Sequence *seq) { + Editing *ed = scene->ed; + if(seq->strip) seq_free_strip(seq->strip); if(seq->anim) IMB_free_anim(seq->anim); - //XXX if(seq->hdaudio) sound_close_hdaudio(seq->hdaudio); + + if(seq->sound_handle) + sound_delete_handle(scene, seq->sound_handle); if (seq->type & SEQ_EFFECT) { struct SeqEffectHandle sh = get_sequence_effect(seq); @@ -208,8 +216,9 @@ Editing *seq_give_editing(Scene *scene, int alloc) return scene->ed; } -void seq_free_editing(Editing *ed) +void seq_free_editing(Scene *scene) { + Editing *ed = scene->ed; MetaStack *ms; Sequence *seq; @@ -217,7 +226,7 @@ void seq_free_editing(Editing *ed) return; SEQ_BEGIN(ed, seq) { - seq_free_sequence(ed, seq); + seq_free_sequence(scene, seq); } SEQ_END @@ -444,6 +453,8 @@ void calc_sequence_disp(Sequence *seq) else if(seq->enddisp-seq->startdisp > 250) { seq->handsize= (float)((seq->enddisp-seq->startdisp)/25); } + + seq_update_sound(seq); } void calc_sequence(Sequence *seq) @@ -515,8 +526,8 @@ void reload_sequence_new_file(Scene *scene, Sequence * seq) char str[FILE_MAXDIR+FILE_MAXFILE]; if (!(seq->type == SEQ_MOVIE || seq->type == SEQ_IMAGE || - seq->type == SEQ_HD_SOUND || seq->type == SEQ_RAM_SOUND || - seq->type == SEQ_SCENE || seq->type == SEQ_META)) { + seq->type == SEQ_SOUND || + seq->type == SEQ_SCENE || seq->type == SEQ_META)) { return; } @@ -558,23 +569,8 @@ void reload_sequence_new_file(Scene *scene, Sequence * seq) seq->len = 0; } seq->strip->len = seq->len; - } else if (seq->type == SEQ_HD_SOUND) { -// XXX if(seq->hdaudio) sound_close_hdaudio(seq->hdaudio); -// seq->hdaudio = sound_open_hdaudio(str); - - if (!seq->hdaudio) { - return; - } - -// XXX seq->len = sound_hdaudio_get_duration(seq->hdaudio, FPS) - seq->anim_startofs - seq->anim_endofs; - if (seq->len < 0) { - seq->len = 0; - } - seq->strip->len = seq->len; - } else if (seq->type == SEQ_RAM_SOUND) { - seq->len = (int) ( ((float)(seq->sound->streamlen-1)/ - ((float)scene->audio.mixrate*4.0 )) - * FPS); + } else if (seq->type == SEQ_SOUND) { + seq->len = AUD_getInfo(seq->sound->snd_sound).length * FPS; seq->len -= seq->anim_startofs; seq->len -= seq->anim_endofs; if (seq->len < 0) { @@ -693,8 +689,7 @@ char *give_seqname_by_type(int type) case SEQ_IMAGE: return "Image"; case SEQ_SCENE: return "Scene"; case SEQ_MOVIE: return "Movie"; - case SEQ_RAM_SOUND: return "Audio (RAM)"; - case SEQ_HD_SOUND: return "Audio (HD)"; + case SEQ_SOUND: return "Audio"; case SEQ_CROSS: return "Cross"; case SEQ_GAMCROSS: return "Gamma Cross"; case SEQ_ADD: return "Add"; @@ -1071,10 +1066,9 @@ int evaluate_seq_frame(Scene *scene, int cfra) static int video_seq_is_rendered(Sequence * seq) { - return (seq - && !(seq->flag & SEQ_MUTE) - && seq->type != SEQ_RAM_SOUND - && seq->type != SEQ_HD_SOUND); + return (seq + && !(seq->flag & SEQ_MUTE) + && seq->type != SEQ_SOUND); } static int get_shown_sequences( ListBase * seqbasep, int cfra, int chanshown, Sequence ** seq_arr_out) @@ -3309,7 +3303,7 @@ void seq_tx_handle_xlimits(Sequence *seq, int leftflag, int rightflag) } /* sounds cannot be extended past their endpoints */ - if (seq->type == SEQ_RAM_SOUND || seq->type == SEQ_HD_SOUND) { + if (seq->type == SEQ_SOUND) { seq->startstill= 0; seq->endstill= 0; } @@ -3406,3 +3400,15 @@ int shuffle_seq(ListBase * seqbasep, Sequence *test) return 1; } } + +void seq_update_sound(struct Sequence *seq) +{ + if(seq->type == SEQ_SOUND) + { + seq->sound_handle->startframe = seq->startdisp; + seq->sound_handle->endframe = seq->enddisp; + seq->sound_handle->frameskip = seq->startofs + seq->anim_startofs; + seq->sound_handle->mute = seq->flag & SEQ_MUTE ? 1 : 0; + seq->sound_handle->changed = -1; + } +} diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c index b461592f35f..888ba7c9a5e 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -1,5 +1,5 @@ /** - * BKE_cloth.h + * smoke.c * * $Id$ * @@ -54,10 +54,13 @@ #include "BKE_DerivedMesh.h" #include "BKE_modifier.h" #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" +#include "DNA_lamp_types.h" #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" #include "DNA_modifier_types.h" @@ -89,10 +92,10 @@ static void tend ( void ) { QueryPerformanceCounter ( &liCurrentTime ); } -static double tval() -{ - return ((double)( (liCurrentTime.QuadPart - liStartTime.QuadPart)* (double)1000.0/(double)liFrequency.QuadPart )); -} +//static double tval() +//{ +// return ((double)( (liCurrentTime.QuadPart - liStartTime.QuadPart)* (double)1000.0/(double)liFrequency.QuadPart )); +//} #else #include <sys/time.h> static struct timeval _tstart, _tend; @@ -120,88 +123,12 @@ struct DerivedMesh; struct SmokeModifierData; // forward declerations -static void get_cell(struct SmokeModifierData *smd, float *pos, int *cell, int correct); -static void get_bigcell(struct SmokeModifierData *smd, float *pos, int *cell, int correct); +static void get_cell(float *p0, int res[3], float dx, float *pos, int *cell, int correct); void calcTriangleDivs(Object *ob, MVert *verts, int numverts, MFace *tris, int numfaces, int numtris, int **tridivs, float cell_len); +void smoke_prepare_View(SmokeModifierData *smd, float framenr, float *light, int have_light); #define TRI_UVOFFSET (1./4.) - -BVHTree *bvhtree_build_from_smoke ( float mat[4][4], MFace *mfaces, unsigned int numfaces, MVert *x, unsigned int numverts, float epsilon ) -{ - BVHTree *tree; - float co[12]; - int i; - MFace *tface = mfaces; - - // calc quads - // todo - - tree = BLI_bvhtree_new ( numfaces, epsilon, 2, 6 ); - - // fill tree - for ( i = 0; i < numfaces; i++, tface++ ) - { - VECCOPY ( &co[0*3], x[tface->v1].co ); - Mat4MulVecfl (mat, &co[0*3]); - VECCOPY ( &co[1*3], x[tface->v2].co ); - Mat4MulVecfl (mat, &co[1*3]); - VECCOPY ( &co[2*3], x[tface->v3].co ); - Mat4MulVecfl (mat, &co[2*3]); - - if ( tface->v4 ) - { - VECCOPY ( &co[3*3], x[tface->v4].co ); - Mat4MulVecfl (mat, &co[3*3]); - } - - BLI_bvhtree_insert ( tree, i, co, ( mfaces->v4 ? 4 : 3 ) ); - } - - // balance tree - BLI_bvhtree_balance ( tree ); - - return tree; -} - -void bvhtree_update_from_smoke ( float mat[4][4], BVHTree * bvhtree, MFace *faces, int numfaces, MVert *x, int numverts) -{ - int i; - MFace *mfaces = faces; - float co[12]; - int ret = 0; - - if ( !bvhtree ) - return; - - if ( x ) - { - for ( i = 0; i < numfaces; i++, mfaces++ ) - { - VECCOPY ( &co[0*3], x[mfaces->v1].co ); - Mat4MulVecfl (mat, &co[0*3]); - VECCOPY ( &co[1*3], x[mfaces->v2].co ); - Mat4MulVecfl (mat, &co[1*3]); - VECCOPY ( &co[2*3], x[mfaces->v3].co ); - Mat4MulVecfl (mat, &co[2*3]); - - if ( mfaces->v4 ) - { - VECCOPY ( &co[3*3], x[mfaces->v4].co ); - Mat4MulVecfl (mat, &co[3*3]); - } - - ret = BLI_bvhtree_update_node ( bvhtree, i, co, NULL, ( mfaces->v4 ? 4 : 3 ) ); - - // check if tree is already full - if ( !ret ) - break; - } - - BLI_bvhtree_update_tree ( bvhtree ); - } -} - int smokeModifier_init (SmokeModifierData *smd, Object *ob, Scene *scene, DerivedMesh *dm) { if((smd->type & MOD_SMOKE_TYPE_DOMAIN) && smd->domain && !smd->domain->fluid) @@ -239,6 +166,10 @@ int smokeModifier_init (SmokeModifierData *smd, Object *ob, Scene *scene, Derive // calc other res with max_res provided VECSUB(size, max, min); + + if((size[0] < FLT_EPSILON) || (size[1] < FLT_EPSILON) || (size[2] < FLT_EPSILON)) + return 0; + if(size[0] > size[1]) { if(size[0] > size[1]) @@ -281,12 +212,23 @@ int smokeModifier_init (SmokeModifierData *smd, Object *ob, Scene *scene, Derive // TODO: put in failsafe if res<=0 - dg // printf("res[0]: %d, res[1]: %d, res[2]: %d\n", smd->domain->res[0], smd->domain->res[1], smd->domain->res[2]); - // dt max is 0.1 - smd->domain->fluid = smoke_init(smd->domain->res, smd->domain->amplify, smd->domain->p0, smd->domain->p1, 2.5 / FPS); + smd->domain->fluid = smoke_init(smd->domain->res, smd->domain->p0, 0.1); smd->time = scene->r.cfra; smd->domain->firstframe = smd->time; + if(!smd->domain->wt && (smd->domain->flags & MOD_SMOKE_HIGHRES)) + { + smd->domain->wt = smoke_turbulence_init(smd->domain->res, smd->domain->amplify + 1, smd->domain->noise); + smoke_turbulence_initBlenderRNA(smd->domain->wt, &smd->domain->strength); + } + + if(!smd->domain->view3d) + { + // TVox is for transparency + smd->domain->view3d = MEM_callocN(sizeof(float)*smd->domain->res[0]*smd->domain->res[1]*smd->domain->res[2]*4, "Smoke_tVox"); + } + smoke_initBlenderRNA(smd->domain->fluid, &(smd->domain->alpha), &(smd->domain->beta)); return 1; @@ -300,6 +242,17 @@ int smokeModifier_init (SmokeModifierData *smd, Object *ob, Scene *scene, Derive // update particle lifetime to be one frame // smd->flow->psys->part->lifetime = scene->r.efra + 1; +/* + if(!smd->flow->bvh) + { + // smd->flow->bvh = MEM_callocN(sizeof(BVHTreeFromMesh), "smoke_bvhfromfaces"); + // bvhtree_from_mesh_faces(smd->flow->bvh, dm, 0.0, 2, 6); + + // copy obmat + // Mat4CpyMat4(smd->flow->mat, ob->obmat); + // Mat4CpyMat4(smd->flow->mat_old, ob->obmat); + } +*/ return 1; } @@ -317,13 +270,18 @@ int smokeModifier_init (SmokeModifierData *smd, Object *ob, Scene *scene, Derive SmokeCollSettings *scs = smd->coll; MVert *mvert = dm->getVertArray(dm); MFace *mface = dm->getTessFaceArray(dm); - size_t i = 0, divs = 0; + size_t i = 0; + int divs = 0; int *tridivs = NULL; float cell_len = 1.0 / 50.0; // for res = 50 size_t newdivs = 0; - size_t max_points = 0; + //size_t max_points = 0; size_t quads = 0, facecounter = 0; + // copy obmat + Mat4CpyMat4(scs->mat, ob->obmat); + Mat4CpyMat4(scs->mat_old, ob->obmat); + // count quads for(i = 0; i < dm->getNumFaces(dm); i++) { @@ -359,7 +317,7 @@ int smokeModifier_init (SmokeModifierData *smd, Object *ob, Scene *scene, Derive size_t j, k; int divs1 = tridivs[3 * facecounter + 0]; int divs2 = tridivs[3 * facecounter + 1]; - int divs3 = tridivs[3 * facecounter + 2]; + //int divs3 = tridivs[3 * facecounter + 2]; float side1[3], side2[3], trinormorg[3], trinorm[3]; if(again == 1 && mface[i].v4) @@ -451,12 +409,12 @@ int smokeModifier_init (SmokeModifierData *smd, Object *ob, Scene *scene, Derive if(!smd->coll->bvhtree) { - smd->coll->bvhtree = bvhtree_build_from_smoke ( ob->obmat, dm->getTessFaceArray(dm), dm->getNumFaces(dm), dm->getVertArray(dm), dm->getNumVerts(dm), 0.0 ); + smd->coll->bvhtree = NULL; // bvhtree_build_from_smoke ( ob->obmat, dm->getFaceArray(dm), dm->getNumFaces(dm), dm->getVertArray(dm), dm->getNumVerts(dm), 0.0 ); } - + return 1; } - return 0; + return 1; } /*! init triangle divisions */ @@ -504,12 +462,12 @@ void calcTriangleDivs(Object *ob, MVert *verts, int numverts, MFace *faces, int if(INPR(side1, side1) > fsTri*fsTri) { float tmp = Normalize(side1); - divs1 = (int)(tmp/fsTri); + divs1 = (int)ceil(tmp/fsTri); } if(INPR(side2, side2) > fsTri*fsTri) { float tmp = Normalize(side2); - divs2 = (int)(tmp/fsTri); + divs2 = (int)ceil(tmp/fsTri); /* // debug @@ -529,9 +487,11 @@ void calcTriangleDivs(Object *ob, MVert *verts, int numverts, MFace *faces, int facecounter++; - VECCOPY(p1, verts[faces[i].v3].co); + VECCOPY(p0, verts[faces[i].v3].co); + Mat4MulVecfl (ob->obmat, p0); + VECCOPY(p1, verts[faces[i].v4].co); Mat4MulVecfl (ob->obmat, p1); - VECCOPY(p2, verts[faces[i].v4].co); + VECCOPY(p2, verts[faces[i].v1].co); Mat4MulVecfl (ob->obmat, p2); VECSUB(side1, p1, p0); @@ -541,12 +501,12 @@ void calcTriangleDivs(Object *ob, MVert *verts, int numverts, MFace *faces, int if(INPR(side1, side1) > fsTri*fsTri) { float tmp = Normalize(side1); - divs1 = (int)(tmp/fsTri); + divs1 = (int)ceil(tmp/fsTri); } if(INPR(side2, side2) > fsTri*fsTri) { float tmp = Normalize(side2); - divs2 = (int)(tmp/fsTri); + divs2 = (int)ceil(tmp/fsTri); } (*tridivs)[3 * facecounter + 0] = divs1; @@ -562,26 +522,20 @@ void smokeModifier_freeDomain(SmokeModifierData *smd) if(smd->domain) { // free visualisation buffers - if(smd->domain->bind) - { - glDeleteTextures(smd->domain->max_textures, (GLuint *)smd->domain->bind); - MEM_freeN(smd->domain->bind); - } - smd->domain->max_textures = 0; // unnecessary but let's be sure - - if(smd->domain->tray) - MEM_freeN(smd->domain->tray); - if(smd->domain->tvox) - MEM_freeN(smd->domain->tvox); - if(smd->domain->traybig) - MEM_freeN(smd->domain->traybig); - if(smd->domain->tvoxbig) - MEM_freeN(smd->domain->tvoxbig); + if(smd->domain->view3d) + MEM_freeN(smd->domain->view3d); if(smd->domain->fluid) - { smoke_free(smd->domain->fluid); - } + + if(smd->domain->wt) + smoke_turbulence_free(smd->domain->wt); + + BKE_ptcache_free_list(&(smd->domain->ptcaches[0])); + smd->domain->point_cache[0] = NULL; + BKE_ptcache_free_list(&(smd->domain->ptcaches[1])); + smd->domain->point_cache[1] = NULL; + MEM_freeN(smd->domain); smd->domain = NULL; } @@ -591,6 +545,14 @@ void smokeModifier_freeFlow(SmokeModifierData *smd) { if(smd->flow) { +/* + if(smd->flow->bvh) + { + free_bvhtree_from_mesh(smd->flow->bvh); + MEM_freeN(smd->flow->bvh); + } + smd->flow->bvh = NULL; +*/ MEM_freeN(smd->flow); smd->flow = NULL; } @@ -612,6 +574,10 @@ void smokeModifier_freeCollision(SmokeModifierData *smd) smd->coll->bvhtree = NULL; } + if(smd->coll->dm) + smd->coll->dm->release(smd->coll->dm); + smd->coll->dm = NULL; + MEM_freeN(smd->coll); smd->coll = NULL; } @@ -623,39 +589,46 @@ void smokeModifier_reset(struct SmokeModifierData *smd) { if(smd->domain) { - // free visualisation buffers - if(smd->domain->bind) - { - glDeleteTextures(smd->domain->max_textures, (GLuint *)smd->domain->bind); - MEM_freeN(smd->domain->bind); - smd->domain->bind = NULL; - } - smd->domain->max_textures = 0; - smd->domain->viewsettings = 0; // reset view for new frame - - if(smd->domain->tray) - MEM_freeN(smd->domain->tray); - if(smd->domain->tvox) - MEM_freeN(smd->domain->tvox); - if(smd->domain->traybig) - MEM_freeN(smd->domain->traybig); - if(smd->domain->tvoxbig) - MEM_freeN(smd->domain->tvoxbig); - - smd->domain->tvox = NULL; - smd->domain->tray = NULL; - smd->domain->tvoxbig = NULL; - smd->domain->traybig = NULL; + if(smd->domain->view3d) + MEM_freeN(smd->domain->view3d); + smd->domain->view3d = NULL; + + smd->domain->tex = NULL; if(smd->domain->fluid) { smoke_free(smd->domain->fluid); smd->domain->fluid = NULL; } + + if(smd->domain->wt) + { + smoke_turbulence_free(smd->domain->wt); + smd->domain->wt = NULL; + } + + smd->domain->point_cache[0]->flag &= ~PTCACHE_SIMULATION_VALID; + smd->domain->point_cache[0]->flag |= PTCACHE_OUTDATED; + smd->domain->point_cache[0]->simframe= 0; + smd->domain->point_cache[0]->last_exact= 0; + + smd->domain->point_cache[1]->flag &= ~PTCACHE_SIMULATION_VALID; + smd->domain->point_cache[1]->flag |= PTCACHE_OUTDATED; + smd->domain->point_cache[1]->simframe= 0; + smd->domain->point_cache[1]->last_exact= 0; + + // printf("reset_domain\n"); } else if(smd->flow) { - + /* + if(smd->flow->bvh) + { + free_bvhtree_from_mesh(smd->flow->bvh); + MEM_freeN(smd->flow->bvh); + } + smd->flow->bvh = NULL; + */ } else if(smd->coll) { @@ -670,6 +643,11 @@ void smokeModifier_reset(struct SmokeModifierData *smd) BLI_bvhtree_free(smd->coll->bvhtree); smd->coll->bvhtree = NULL; } + + if(smd->coll->dm) + smd->coll->dm->release(smd->coll->dm); + smd->coll->dm = NULL; + } } } @@ -697,28 +675,32 @@ void smokeModifier_createType(struct SmokeModifierData *smd) smd->domain->smd = smd; + smd->domain->point_cache[0] = BKE_ptcache_add(&(smd->domain->ptcaches[0])); + smd->domain->point_cache[0]->flag |= PTCACHE_DISK_CACHE; + smd->domain->point_cache[0]->step = 1; + + smd->domain->point_cache[1] = BKE_ptcache_add(&(smd->domain->ptcaches[1])); + smd->domain->point_cache[1]->flag |= PTCACHE_DISK_CACHE; + smd->domain->point_cache[1]->step = 1; + /* set some standard values */ smd->domain->fluid = NULL; smd->domain->eff_group = NULL; smd->domain->fluid_group = NULL; smd->domain->coll_group = NULL; smd->domain->maxres = 32; - smd->domain->amplify = 2; - smd->domain->omega = 1.0; smd->domain->alpha = -0.001; smd->domain->beta = 0.1; - smd->domain->flags = 0; + smd->domain->flags = MOD_SMOKE_DISSOLVE_LOG; + smd->domain->diss_speed = 5; + smd->domain->strength = 2.0f; + smd->domain->amplify = 1; smd->domain->noise = MOD_SMOKE_NOISEWAVE; - smd->domain->visibility = 1; + smd->domain->wt = NULL; // init 3dview buffer - smd->domain->tvox = NULL; - smd->domain->tray = NULL; - smd->domain->tvoxbig = NULL; - smd->domain->traybig = NULL; - smd->domain->viewsettings = 0; - smd->domain->bind = NULL; - smd->domain->max_textures = 0; + smd->domain->view3d = NULL; + smd->domain->tex = NULL; } else if(smd->type & MOD_SMOKE_TYPE_FLOW) { @@ -747,24 +729,31 @@ void smokeModifier_createType(struct SmokeModifierData *smd) smd->coll->points = NULL; smd->coll->numpoints = 0; smd->coll->bvhtree = NULL; + smd->coll->dm = NULL; } } } // forward declaration -void smoke_calc_transparency(struct SmokeModifierData *smd, float *light, int big); +void smoke_simulate_domain(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedMesh *dm); void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedMesh *dm, int useRenderParams, int isFinalCalc) { + if((smd->type & MOD_SMOKE_TYPE_FLOW)) + { if(scene->r.cfra >= smd->time) smokeModifier_init(smd, ob, scene, dm); - if((smd->type & MOD_SMOKE_TYPE_FLOW)) - { if(scene->r.cfra > smd->time) { // XXX TODO smd->time = scene->r.cfra; + + // rigid movement support + /* + Mat4CpyMat4(smd->flow->mat_old, smd->flow->mat); + Mat4CpyMat4(smd->flow->mat, ob->obmat); + */ } else if(scene->r.cfra < smd->time) { @@ -774,15 +763,22 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM } else if(smd->type & MOD_SMOKE_TYPE_COLL) { + if(scene->r.cfra >= smd->time) + smokeModifier_init(smd, ob, scene, dm); + if(scene->r.cfra > smd->time) { // XXX TODO smd->time = scene->r.cfra; - if(smd->coll->bvhtree) - bvhtree_update_from_smoke ( ob->obmat, smd->coll->bvhtree, dm->getTessFaceArray(dm), dm->getNumFaces(dm), dm->getVertArray(dm), dm->getNumVerts(dm)); - else - printf("smoke coll with no bvh\n"); + if(smd->coll->dm) + smd->coll->dm->release(smd->coll->dm); + + smd->coll->dm = CDDM_copy(dm); + + // rigid movement support + Mat4CpyMat4(smd->coll->mat_old, smd->coll->mat); + Mat4CpyMat4(smd->coll->mat, ob->obmat); } else if(scene->r.cfra < smd->time) { @@ -792,46 +788,194 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM } else if(smd->type & MOD_SMOKE_TYPE_DOMAIN) { + PointCache *cache; + PTCacheID pid; + float timescale; + int cache_result = 0; + int startframe, endframe, framenr; SmokeDomainSettings *sds = smd->domain; + float light[3] = {0.0,0.0,0.0}; + int have_lamp = 0; - if(scene->r.cfra > smd->time) + // printf("smd->type & MOD_SMOKE_TYPE_DOMAIN\n"); + + framenr = scene->r.cfra; + + cache = sds->point_cache[0]; + + BKE_ptcache_id_from_smoke(&pid, ob, smd); + BKE_ptcache_id_time(&pid, scene, framenr, &startframe, &endframe, ×cale); + + /* handle continuous simulation with the play button */ + if(BKE_ptcache_get_continue_physics()) { - GroupObject *go = NULL; - Base *base = NULL; - int cnt_domain = 0; + cache->flag &= ~PTCACHE_SIMULATION_VALID; + cache->simframe= 0; + cache->last_exact= 0; - tstart(); + if(!smokeModifier_init(smd, ob, scene, dm)) + return; + + if(!smd->domain->fluid) + return; - sds->viewsettings = 0; // reset view for new frame + smoke_simulate_domain(smd, scene, ob, dm); - // check for 2nd domain, if not there -> no groups are necessary - for(base = scene->base.first; base; base= base->next) { - Object *ob1= base->object; + Base *base_tmp = NULL; - if(ob1 && ob1 != ob) + for(base_tmp = scene->base.first; base_tmp; base_tmp= base_tmp->next) { - ModifierData *tmd = modifiers_findByType(ob1, eModifierType_Smoke); + if(base_tmp->object->type == OB_LAMP) + { + Lamp *la = (Lamp *)base_tmp->object->data; - if(tmd && tmd->mode & (eModifierMode_Realtime | eModifierMode_Render)) + if(la->type == LA_LOCAL) { - SmokeModifierData *tsmd = (SmokeModifierData *)tmd; + VECCOPY(light, base_tmp->object->obmat[3]); + have_lamp = 1; + break; + } + } + } + } + + smoke_prepare_View(smd, (float)framenr, light, have_lamp); - if((tsmd->type & MOD_SMOKE_TYPE_DOMAIN)) + return; + } + + if(framenr < startframe) { - cnt_domain++; + cache->flag &= ~PTCACHE_SIMULATION_VALID; + cache->simframe= 0; + cache->last_exact= 0; + + // we got back in time, reset smoke in this case (TODO: use cache later) + // smd->time = scene->r.cfra; + // smokeModifier_reset(smd); + + return; } + else if(framenr > endframe) + { + framenr = endframe; + } + + if(!(cache->flag & PTCACHE_SIMULATION_VALID)) + { + // printf("reseting\n"); + BKE_ptcache_id_reset(scene, &pid, PTCACHE_RESET_OUTDATED); + } + + if(!smokeModifier_init(smd, ob, scene, dm)) + return; + + if(!smd->domain->fluid) + return; + + /* try to read from cache */ + cache_result = BKE_ptcache_read_cache(&pid, (float)framenr, scene->r.frs_sec); + // printf("cache_result: %d\n", cache_result); + + if(cache_result == PTCACHE_READ_EXACT) + { + SmokeDomainSettings *sds = smd->domain; + + cache->flag |= PTCACHE_SIMULATION_VALID; + cache->simframe= framenr; + sds->v3dnum = framenr; + + // printf("PTCACHE_READ_EXACT\n"); + return; + } + else if(cache_result==PTCACHE_READ_OLD) + { + BKE_ptcache_id_reset(scene, &pid, PTCACHE_RESET_FREE); + + // printf("PTCACHE_READ_OLD\n"); + + cache->flag |= PTCACHE_SIMULATION_VALID; + } + else if(ob->id.lib || (cache->flag & PTCACHE_BAKED)) + { + /* if baked and nothing in cache, do nothing */ + cache->flag &= ~PTCACHE_SIMULATION_VALID; + cache->simframe= 0; + cache->last_exact= 0; + + // printf("PTCACHE_BAKED\n"); + return; + } + else if((cache_result==0) && (startframe!=framenr) && !(cache->flag & PTCACHE_SIMULATION_VALID)) + { + cache->flag &= ~PTCACHE_SIMULATION_VALID; + cache->simframe= 0; + cache->last_exact= 0; + + return; + } + + /* do simulation */ + + // low res + cache->flag |= PTCACHE_SIMULATION_VALID; + cache->simframe= framenr; + + smoke_simulate_domain(smd, scene, ob, dm); + + if(sds->wt) + smoke_turbulence_step(sds->wt, sds->fluid); + + { + Base *base_tmp = NULL; + + for(base_tmp = scene->base.first; base_tmp; base_tmp= base_tmp->next) + { + if(base_tmp->object->type == OB_LAMP) + { + Lamp *la = (Lamp *)base_tmp->object->data; + + if(la->type == LA_LOCAL) + { + VECCOPY(light, base_tmp->object->obmat[3]); + have_lamp = 1; + break; } } } + } + + smoke_prepare_View(smd, (float)framenr, light, have_lamp); + + BKE_ptcache_write_cache(&pid, framenr); + + // printf("Writing cache_low, %d\n", framenr); + + + tend(); + // printf ( "Frame: %d, Time: %f\n", (int)smd->time, ( float ) tval() ); + } +} + +void smoke_simulate_domain(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedMesh *dm) +{ + GroupObject *go = NULL; + Base *base = NULL; + SmokeDomainSettings *sds = smd->domain; + + tstart(); + + if(sds->flags & MOD_SMOKE_DISSOLVE) + smoke_dissolve(sds->fluid, sds->diss_speed, sds->flags & MOD_SMOKE_DISSOLVE_LOG); // do flows and fluids - if(sds->fluid_group || !cnt_domain) + if(1) { Object *otherobj = NULL; ModifierData *md = NULL; - if(cnt_domain && !sds->fluid_group) // we use groups since we have 2 domains + if(sds->fluid_group) // we use groups since we have 2 domains go = sds->fluid_group->gobject.first; else base = scene->base.first; @@ -840,7 +984,7 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM { otherobj = NULL; - if(cnt_domain && !sds->fluid_group) + if(sds->fluid_group) { if(go->ob) otherobj = go->ob; @@ -850,7 +994,7 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM if(!otherobj) { - if(cnt_domain && !sds->fluid_group) + if(sds->fluid_group) go = go->next; else base= base->next; @@ -878,14 +1022,14 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM ParticleData *pa = NULL; int p = 0; float *density = smoke_get_density(sds->fluid); - float *bigdensity = smoke_get_bigdensity(sds->fluid); + // float *bigdensity = smoke_turbulence_get_density(sds->wt); float *heat = smoke_get_heat(sds->fluid); float *velocity_x = smoke_get_velocity_x(sds->fluid); float *velocity_y = smoke_get_velocity_y(sds->fluid); float *velocity_z = smoke_get_velocity_z(sds->fluid); - int bigres[3]; + unsigned char *obstacle = smoke_get_obstacle(sds->fluid); - smoke_get_bigres(smd->domain->fluid, bigres); + // debug printf("found flow psys\n"); // mostly copied from particle code for(p=0, pa=psys->particles; p<psys->totpart; p++, pa++) @@ -904,7 +1048,7 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM // Mat4MulVecfl (ob->imat, pos); // 1. get corresponding cell - get_cell(smd, pa->state.co, cell, 0); + get_cell(sds->p0, sds->res, sds->dx, pa->state.co, cell, 0); // check if cell is valid (in the domain boundary) for(i = 0; i < 3; i++) @@ -922,56 +1066,49 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM // 2. set cell values (heat, density and velocity) index = smoke_get_index(cell[0], sds->res[0], cell[1], sds->res[1], cell[2]); - if(!(sfs->type & MOD_SMOKE_FLOW_TYPE_OUTFLOW)) // this is inflow + if(!(sfs->type & MOD_SMOKE_FLOW_TYPE_OUTFLOW) && !(obstacle[index] & 2)) // this is inflow { + // heat[index] += sfs->temp * 0.1; + // density[index] += sfs->density * 0.1; + heat[index] = sfs->temp; density[index] = sfs->density; + + /* velocity_x[index] = pa->state.vel[0]; velocity_y[index] = pa->state.vel[1]; velocity_z[index] = pa->state.vel[2]; - - // we need different handling for the high-res feature - if(bigdensity) - { - // init all surrounding cells according to amplification, too - int i, j, k; - for(i = 0; i < smd->domain->amplify; i++) - for(j = 0; j < smd->domain->amplify; j++) - for(k = 0; k < smd->domain->amplify; k++) - { - index = smoke_get_index(smd->domain->amplify * cell[0] + i, bigres[0], smd->domain->amplify * cell[1] + j, bigres[1], smd->domain->amplify * cell[2] + k); - bigdensity[index] = sfs->density; + */ + obstacle[index] |= 2; } - } - } - else // outflow + else if(sfs->type & MOD_SMOKE_FLOW_TYPE_OUTFLOW) // outflow { heat[index] = 0.f; density[index] = 0.f; velocity_x[index] = 0.f; velocity_y[index] = 0.f; velocity_z[index] = 0.f; - - // we need different handling for the high-res feature - if(bigdensity) - { - // init all surrounding cells according to amplification, too - int i, j, k; - for(i = 0; i < smd->domain->amplify; i++) - for(j = 0; j < smd->domain->amplify; j++) - for(k = 0; k < smd->domain->amplify; k++) - { - index = smoke_get_index(smd->domain->amplify * cell[0] + i, bigres[0], smd->domain->amplify * cell[1] + j, bigres[1], smd->domain->amplify * cell[2] + k); - bigdensity[index] = 0.f; } } } + else + { + /* + for() + { + // no psys + BVHTreeNearest nearest; + + nearest.index = -1; + nearest.dist = FLT_MAX; + + BLI_bvhtree_find_nearest(sfs->bvh->tree, pco, &nearest, sfs->bvh->nearest_callback, sfs->bvh); + }*/ } } } - } - if(cnt_domain && !sds->fluid_group) + if(sds->fluid_group) go = go->next; else base= base->next; @@ -996,12 +1133,12 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM */ // do collisions - if(sds->coll_group || !cnt_domain) + if(1) { Object *otherobj = NULL; ModifierData *md = NULL; - if(cnt_domain && !sds->coll_group) // we use groups since we have 2 domains + if(sds->coll_group) // we use groups since we have 2 domains go = sds->coll_group->gobject.first; else base = scene->base.first; @@ -1010,7 +1147,7 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM { otherobj = NULL; - if(cnt_domain && !sds->coll_group) + if(sds->coll_group) { if(go->ob) otherobj = go->ob; @@ -1020,7 +1157,7 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM if(!otherobj) { - if(cnt_domain && !sds->coll_group) + if(sds->coll_group) go = go->next; else base= base->next; @@ -1039,19 +1176,17 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM { // we got nice collision object SmokeCollSettings *scs = smd2->coll; - int cell[3]; - size_t index = 0; size_t i, j; unsigned char *obstacles = smoke_get_obstacle(smd->domain->fluid); - // int BLI_bvhtree_find_nearest(BVHTree *tree, const float *co, BVHTreeNearest *nearest, BVHTree_NearestPointCallback callback, void *userdata); - for(i = 0; i < scs->numpoints; i++) { int badcell = 0; + size_t index = 0; + int cell[3]; // 1. get corresponding cell - get_cell(smd, &scs->points[3 * i], cell, 0); + get_cell(sds->p0, sds->res, sds->dx, &scs->points[3 * i], cell, 0); // check if cell is valid (in the domain boundary) for(j = 0; j < 3; j++) @@ -1096,7 +1231,7 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM } } - if(cnt_domain && !sds->coll_group) + if(sds->coll_group) go = go->next; else base= base->next; @@ -1107,36 +1242,29 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM smd->time = scene->r.cfra; // simulate the actual smoke (c++ code in intern/smoke) - smoke_step(sds->fluid); - - tend(); - printf ( "Frame: %d, Time: %f\n", (int)smd->time, ( float ) tval() ); + smoke_step(sds->fluid, smd->time); } - else if(scene->r.cfra < smd->time) + +static int calc_voxel_transp(float *input, int res[3], int *pixel, float *tRay) { - // we got back in time, reset smoke in this case (TODO: use cache later) - smd->time = scene->r.cfra; - smokeModifier_reset(smd); + const size_t index = smoke_get_index(pixel[0], res[0], pixel[1], res[1], pixel[2]); + + // T_ray *= T_vox + *tRay *= input[index*4]; + + return *tRay; } - } -} + +// forward decleration +void smoke_calc_transparency(float *result, float *p0, float *p1, int res[3], float dx, float *light, bresenham_callback cb); // update necessary information for 3dview -void smoke_prepare_View(SmokeModifierData *smd, float *light) +void smoke_prepare_View(SmokeModifierData *smd, float framenr, float *light, int have_light) { float *density = NULL; int x, y, z; - - if(!smd->domain->tray) - { - // TRay is for self shadowing - smd->domain->tray = MEM_callocN(sizeof(float)*smd->domain->res[0]*smd->domain->res[1]*smd->domain->res[2], "Smoke_tRay"); - } - if(!smd->domain->tvox) - { - // TVox is for tranaparency - smd->domain->tvox = MEM_callocN(sizeof(float)*smd->domain->res[0]*smd->domain->res[1]*smd->domain->res[2], "Smoke_tVox"); - } + size_t cells, i; + SmokeDomainSettings *sds = smd->domain; // update 3dview density = smoke_get_density(smd->domain->fluid); @@ -1151,82 +1279,24 @@ void smoke_prepare_View(SmokeModifierData *smd, float *light) // formula taken from "Visual Simulation of Smoke" / Fedkiw et al. pg. 4 // T_vox = exp(-C_ext * h) // C_ext/sigma_t = density * C_ext - smoke_set_tvox(smd, index, exp(-density[index] * 7.0 * smd->domain->dx)); - } - smoke_calc_transparency(smd, light, 0); -} + smd->domain->view3d[index * 4] = smd->domain->view3d[index * 4 + 1] = + smd->domain->view3d[index * 4 + 2] = exp(-density[index] * 7.0 * smd->domain->dx); + smd->domain->view3d[index * 4 + 3] = 1.0 - smd->domain->view3d[index * 4]; -// update necessary information for 3dview ("high res" option) -void smoke_prepare_bigView(SmokeModifierData *smd, float *light) -{ - float *density = NULL; - size_t i = 0; - int bigres[3]; - - smoke_get_bigres(smd->domain->fluid, bigres); - - if(!smd->domain->traybig) - { - // TRay is for self shadowing - smd->domain->traybig = MEM_callocN(sizeof(float)*bigres[0]*bigres[1]*bigres[2], "Smoke_tRayBig"); - } - if(!smd->domain->tvoxbig) - { - // TVox is for tranaparency - smd->domain->tvoxbig = MEM_callocN(sizeof(float)*bigres[0]*bigres[1]*bigres[2], "Smoke_tVoxBig"); } - density = smoke_get_bigdensity(smd->domain->fluid); - for (i = 0; i < bigres[0] * bigres[1] * bigres[2]; i++) + if(have_light) { - // Transparency computation - // formula taken from "Visual Simulation of Smoke" / Fedkiw et al. pg. 4 - // T_vox = exp(-C_ext * h) - // C_ext/sigma_t = density * C_ext - smoke_set_bigtvox(smd, i, exp(-density[i] * 7.0 * smd->domain->dx / smd->domain->amplify) ); - } - smoke_calc_transparency(smd, light, 1); -} - + smoke_calc_transparency(sds->view3d, sds->p0, sds->p1, sds->res, sds->dx, light, calc_voxel_transp); -float smoke_get_tvox(SmokeModifierData *smd, size_t index) + cells = smd->domain->res[0]*smd->domain->res[1]*smd->domain->res[2]; + for(i = 0; i < cells; i++) { - return smd->domain->tvox[index]; + smd->domain->view3d[i * 4] = smd->domain->view3d[i * 4 + 1] = + smd->domain->view3d[i * 4 + 2] = smd->domain->view3d[i * 4 + 1] * smd->domain->view3d[i * 4 + 0]; } - -void smoke_set_tvox(SmokeModifierData *smd, size_t index, float tvox) -{ - smd->domain->tvox[index] = tvox; } - -float smoke_get_tray(SmokeModifierData *smd, size_t index) -{ - return smd->domain->tray[index]; -} - -void smoke_set_tray(SmokeModifierData *smd, size_t index, float transparency) -{ - smd->domain->tray[index] = transparency; -} - -float smoke_get_bigtvox(SmokeModifierData *smd, size_t index) -{ - return smd->domain->tvoxbig[index]; -} - -void smoke_set_bigtvox(SmokeModifierData *smd, size_t index, float tvox) -{ - smd->domain->tvoxbig[index] = tvox; -} - -float smoke_get_bigtray(SmokeModifierData *smd, size_t index) -{ - return smd->domain->traybig[index]; -} - -void smoke_set_bigtray(SmokeModifierData *smd, size_t index, float transparency) -{ - smd->domain->traybig[index] = transparency; + smd->domain->v3dnum = framenr; } long long smoke_get_mem_req(int xres, int yres, int zres, int amplify) @@ -1247,34 +1317,7 @@ long long smoke_get_mem_req(int xres, int yres, int zres, int amplify) return totalMB; } - -static void calc_voxel_transp(SmokeModifierData *smd, int *pixel, float *tRay) -{ - // printf("Pixel(%d, %d, %d)\n", pixel[0], pixel[1], pixel[2]); - const size_t index = smoke_get_index(pixel[0], smd->domain->res[0], pixel[1], smd->domain->res[1], pixel[2]); - - // T_ray *= T_vox - *tRay *= smoke_get_tvox(smd, index); -} - -static void calc_voxel_transp_big(SmokeModifierData *smd, int *pixel, float *tRay) -{ - int bigres[3]; - size_t index; - - smoke_get_bigres(smd->domain->fluid, bigres); - index = smoke_get_index(pixel[0], bigres[0], pixel[1], bigres[1], pixel[2]); - - /* - if(index > bigres[0]*bigres[1]*bigres[2]) - printf("pixel[0]: %d, [1]: %d, [2]: %d\n", pixel[0], pixel[1], pixel[2]); - */ - - // T_ray *= T_vox - *tRay *= smoke_get_bigtvox(smd, index); -} - -static void bresenham_linie_3D(SmokeModifierData *smd, int x1, int y1, int z1, int x2, int y2, int z2, float *tRay, int big) +static void bresenham_linie_3D(int x1, int y1, int z1, int x2, int y2, int z2, float *tRay, bresenham_callback cb, float *input, int res[3]) { int dx, dy, dz, i, l, m, n, x_inc, y_inc, z_inc, err_1, err_2, dx2, dy2, dz2; int pixel[3]; @@ -1301,11 +1344,7 @@ static void bresenham_linie_3D(SmokeModifierData *smd, int x1, int y1, int z1, i err_1 = dy2 - l; err_2 = dz2 - l; for (i = 0; i < l; i++) { - if(!big) - calc_voxel_transp(smd, pixel, tRay); - else - calc_voxel_transp_big(smd, pixel, tRay); - if(*tRay < 0.0f) + if(cb(input, res, pixel, tRay) < 0.0) return; if (err_1 > 0) { pixel[1] += y_inc; @@ -1323,11 +1362,7 @@ static void bresenham_linie_3D(SmokeModifierData *smd, int x1, int y1, int z1, i err_1 = dx2 - m; err_2 = dz2 - m; for (i = 0; i < m; i++) { - if(!big) - calc_voxel_transp(smd, pixel, tRay); - else - calc_voxel_transp_big(smd, pixel, tRay); - if(*tRay < 0.0f) + if(cb(input, res, pixel, tRay) < 0.0f) return; if (err_1 > 0) { pixel[0] += x_inc; @@ -1345,11 +1380,7 @@ static void bresenham_linie_3D(SmokeModifierData *smd, int x1, int y1, int z1, i err_1 = dy2 - n; err_2 = dx2 - n; for (i = 0; i < n; i++) { - if(!big) - calc_voxel_transp(smd, pixel, tRay); - else - calc_voxel_transp_big(smd, pixel, tRay); - if(*tRay < 0.0f) + if(cb(input, res, pixel, tRay) < 0.0f) return; if (err_1 > 0) { pixel[1] += y_inc; @@ -1364,41 +1395,15 @@ static void bresenham_linie_3D(SmokeModifierData *smd, int x1, int y1, int z1, i pixel[2] += z_inc; } } - if(!big) - calc_voxel_transp(smd, pixel, tRay); - else - calc_voxel_transp_big(smd, pixel, tRay); + cb(input, res, pixel, tRay); } -static void get_cell(struct SmokeModifierData *smd, float *pos, int *cell, int correct) -{ - float tmp[3]; - - VECSUB(tmp, pos, smd->domain->p0); - VecMulf(tmp, 1.0 / smd->domain->dx); - - if(correct) - { - cell[0] = MIN2(smd->domain->res[0] - 1, MAX2(0, (int)floor(tmp[0]))); - cell[1] = MIN2(smd->domain->res[1] - 1, MAX2(0, (int)floor(tmp[1]))); - cell[2] = MIN2(smd->domain->res[2] - 1, MAX2(0, (int)floor(tmp[2]))); - } - else - { - cell[0] = (int)floor(tmp[0]); - cell[1] = (int)floor(tmp[1]); - cell[2] = (int)floor(tmp[2]); - } -} -static void get_bigcell(struct SmokeModifierData *smd, float *pos, int *cell, int correct) +static void get_cell(float *p0, int res[3], float dx, float *pos, int *cell, int correct) { float tmp[3]; - int res[3]; - smoke_get_bigres(smd->domain->fluid, res); - VECSUB(tmp, pos, smd->domain->p0); - - VecMulf(tmp, smd->domain->amplify / smd->domain->dx ); + VECSUB(tmp, pos, p0); + VecMulf(tmp, 1.0 / dx); if(correct) { @@ -1414,43 +1419,22 @@ static void get_bigcell(struct SmokeModifierData *smd, float *pos, int *cell, in } } - -void smoke_calc_transparency(struct SmokeModifierData *smd, float *light, int big) +void smoke_calc_transparency(float *result, float *p0, float *p1, int res[3], float dx, float *light, bresenham_callback cb) { int x, y, z; float bv[6]; - int res[3]; - float bigfactor = 1.0; // x - bv[0] = smd->domain->p0[0]; - bv[1] = smd->domain->p1[0]; + bv[0] = p0[0]; + bv[1] = p1[0]; // y - bv[2] = smd->domain->p0[1]; - bv[3] = smd->domain->p1[1]; + bv[2] = p0[1]; + bv[3] = p1[1]; // z - bv[4] = smd->domain->p0[2]; - bv[5] = smd->domain->p1[2]; -/* - printf("bv[0]: %f, [1]: %f, [2]: %f, [3]: %f, [4]: %f, [5]: %f\n", bv[0], bv[1], bv[2], bv[3], bv[4], bv[5]); - - printf("p0[0]: %f, p0[1]: %f, p0[2]: %f\n", smd->domain->p0[0], smd->domain->p0[1], smd->domain->p0[2]); - printf("p1[0]: %f, p1[1]: %f, p1[2]: %f\n", smd->domain->p1[0], smd->domain->p1[1], smd->domain->p1[2]); - printf("dx: %f, amp: %d\n", smd->domain->dx, smd->domain->amplify); -*/ - if(!big) - { - res[0] = smd->domain->res[0]; - res[1] = smd->domain->res[1]; - res[2] = smd->domain->res[2]; - } - else - { - smoke_get_bigres(smd->domain->fluid, res); - bigfactor = 1.0 / smd->domain->amplify; - } + bv[4] = p0[2]; + bv[5] = p1[2]; -#pragma omp parallel for schedule(static) private(y, z) shared(big, smd, light, res, bigfactor) +// #pragma omp parallel for schedule(static) private(y, z) for(x = 0; x < res[0]; x++) for(y = 0; y < res[1]; y++) for(z = 0; z < res[2]; z++) @@ -1463,41 +1447,26 @@ void smoke_calc_transparency(struct SmokeModifierData *smd, float *light, int bi index = smoke_get_index(x, res[0], y, res[1], z); - // voxelCenter = m_voxelarray[i].GetCenter(); - voxelCenter[0] = smd->domain->p0[0] + smd->domain->dx * bigfactor * x + smd->domain->dx * bigfactor * 0.5; - voxelCenter[1] = smd->domain->p0[1] + smd->domain->dx * bigfactor * y + smd->domain->dx * bigfactor * 0.5; - voxelCenter[2] = smd->domain->p0[2] + smd->domain->dx * bigfactor * z + smd->domain->dx * bigfactor * 0.5; - - // printf("vc[0]: %f, vc[1]: %f, vc[2]: %f\n", voxelCenter[0], voxelCenter[1], voxelCenter[2]); - // printf("light[0]: %f, light[1]: %f, light[2]: %f\n", light[0], light[1], light[2]); + voxelCenter[0] = p0[0] + dx * x + dx * 0.5; + voxelCenter[1] = p0[1] + dx * y + dx * 0.5; + voxelCenter[2] = p0[2] + dx * z + dx * 0.5; // get starting position (in voxel coords) if(BLI_bvhtree_bb_raycast(bv, light, voxelCenter, pos) > FLT_EPSILON) { // we're ouside - // printf("out: pos[0]: %f, pos[1]: %f, pos[2]: %f\n", pos[0], pos[1], pos[2]); - if(!big) - get_cell(smd, pos, cell, 1); - else - get_bigcell(smd, pos, cell, 1); + get_cell(p0, res, dx, pos, cell, 1); } else { - // printf("in: pos[0]: %f, pos[1]: %f, pos[2]: %f\n", light[0], light[1], light[2]); // we're inside - if(!big) - get_cell(smd, light, cell, 1); - else - get_bigcell(smd, light, cell, 1); + get_cell(p0, res, dx, light, cell, 1); } - // printf("cell - [0]: %d, [1]: %d, [2]: %d\n", cell[0], cell[1], cell[2]); - bresenham_linie_3D(smd, cell[0], cell[1], cell[2], x, y, z, &tRay, big); + bresenham_linie_3D(cell[0], cell[1], cell[2], x, y, z, &tRay, cb, result, res); - if(!big) - smoke_set_tray(smd, index, tRay); - else - smoke_set_bigtray(smd, index, tRay); + // convention -> from a RGBA float array, use G value for tRay + result[index*4 + 1] = tRay; } } diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index 1eae6eba532..aeadbb05cb1 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -866,7 +866,8 @@ static void renew_softbody(Scene *scene, Object *ob, int totpoint, int totspring bp->frozen = 1.0f; bp->colball = 0.0f; bp->flag = 0; - + bp->springweight = 1.0f; + bp->mass = sb->nodemass; } } } @@ -3687,87 +3688,6 @@ static void softbody_to_object(Object *ob, float (*vertexCos)[3], int numVerts, } } -static void softbody_write_state(int index, void *soft_v, float *data) -{ - SoftBody *soft= soft_v; - BodyPoint *bp = soft->bpoint + index; - - memcpy(data, bp->pos, 3 * sizeof(float)); - memcpy(data + 3, bp->vec, 3 * sizeof(float)); -} -static void softbody_read_state(int index, void *soft_v, float *data) -{ - SoftBody *soft= soft_v; - BodyPoint *bp = soft->bpoint + index; - - memcpy(bp->pos, data, 3 * sizeof(float)); - memcpy(bp->vec, data + 3, 3 * sizeof(float)); -} -static void softbody_cache_interpolate(int index, void *soft_v, float frs_sec, float cfra, float cfra1, float cfra2, float *data1, float *data2) -{ - SoftBody *soft= soft_v; - BodyPoint *bp = soft->bpoint + index; - ParticleKey keys[4]; - float dfra; - - if(cfra1 == cfra2) { - softbody_read_state(index, soft, data1); - return; - } - - memcpy(keys[1].co, data1, 3 * sizeof(float)); - memcpy(keys[1].vel, data1 + 3, 3 * sizeof(float)); - - memcpy(keys[2].co, data2, 3 * sizeof(float)); - memcpy(keys[2].vel, data2 + 3, 3 * sizeof(float)); - - dfra = cfra2 - cfra1; - - VecMulf(keys[1].vel, dfra); - VecMulf(keys[2].vel, dfra); - - psys_interpolate_particle(-1, keys, (cfra - cfra1) / dfra, keys, 1); - - VecMulf(keys->vel, 1.0f / dfra); - - memcpy(bp->pos, keys->co, 3 * sizeof(float)); - memcpy(bp->vec, keys->vel, 3 * sizeof(float)); -} -void softbody_write_cache(Object *ob, SoftBody *soft, int cfra) -{ - PTCacheWriter writer; - PTCacheID pid; - - BKE_ptcache_id_from_softbody(&pid, ob, soft); - - writer.calldata = soft; - writer.cfra = cfra; - writer.set_elem = softbody_write_state; - writer.pid = &pid; - writer.totelem = soft->totpoint; - - BKE_ptcache_write_cache(&writer); -} - -int softbody_read_cache(Scene *scene, Object *ob, SoftBody *soft, float cfra, int *old_framenr) -{ - PTCacheReader reader; - PTCacheID pid; - - BKE_ptcache_id_from_softbody(&pid, ob, soft); - - reader.calldata = soft; - reader.cfra = cfra; - reader.interpolate_elem = softbody_cache_interpolate; - reader.old_frame = old_framenr; - reader.pid = &pid; - reader.scene = scene; - reader.set_elem = softbody_read_state; - reader.totelem = soft->totpoint; - - return BKE_ptcache_read_cache(&reader); -} - /* +++ ************ maintaining scratch *************** */ static void sb_new_scratch(SoftBody *sb) { @@ -3827,7 +3747,7 @@ SoftBody *sbNew(Scene *scene) sb->shearstiff = 1.0f; sb->solverflags |= SBSO_OLDERR; - sb->pointcache = BKE_ptcache_add(); + sb->pointcache = BKE_ptcache_add(&sb->ptcaches); return sb; } @@ -3836,7 +3756,8 @@ SoftBody *sbNew(Scene *scene) void sbFree(SoftBody *sb) { free_softbody_intern(sb); - BKE_ptcache_free(sb->pointcache); + BKE_ptcache_free_list(&sb->ptcaches); + sb->pointcache = NULL; MEM_freeN(sb); } @@ -4135,7 +4056,7 @@ void sbObjectStep(Scene *scene, Object *ob, float cfra, float (*vertexCos)[3], i PTCacheID pid; float dtime, timescale; int framedelta, framenr, startframe, endframe; - int cache_result, old_framenr; + int cache_result; cache= sb->pointcache; @@ -4221,7 +4142,7 @@ void sbObjectStep(Scene *scene, Object *ob, float cfra, float (*vertexCos)[3], i } /* try to read from cache */ - cache_result = softbody_read_cache(scene, ob, sb, framenr, &old_framenr); + cache_result = BKE_ptcache_read_cache(&pid, framenr, scene->r.frs_sec); if(cache_result == PTCACHE_READ_EXACT || cache_result == PTCACHE_READ_INTERPOLATED) { cache->flag |= PTCACHE_SIMULATION_VALID; @@ -4235,7 +4156,6 @@ void sbObjectStep(Scene *scene, Object *ob, float cfra, float (*vertexCos)[3], i else if(cache_result==PTCACHE_READ_OLD) { BKE_ptcache_id_reset(scene, &pid, PTCACHE_RESET_FREE); cache->flag |= PTCACHE_SIMULATION_VALID; - cache->simframe= old_framenr; } else if(ob->id.lib || (cache->flag & PTCACHE_BAKED)) { /* if baked and nothing in cache, do nothing */ @@ -4263,7 +4183,7 @@ void sbObjectStep(Scene *scene, Object *ob, float cfra, float (*vertexCos)[3], i else { /* if on second frame, write cache for first frame */ if(cache->simframe == startframe && (cache->flag & PTCACHE_OUTDATED || cache->last_exact==0)) - softbody_write_cache(ob, sb, startframe); + BKE_ptcache_write_cache(&pid, startframe); softbody_update_positions(ob, sb, vertexCos, numVerts); @@ -4279,7 +4199,7 @@ void sbObjectStep(Scene *scene, Object *ob, float cfra, float (*vertexCos)[3], i if(sb->particles==0) softbody_to_object(ob, vertexCos, numVerts, 0); - softbody_write_cache(ob, sb, framenr); + BKE_ptcache_write_cache(&pid, framenr); } } diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index 2c5b49246fb..c6f9db6fda9 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -1,6 +1,6 @@ /** * sound.c (mar-2001 nzc) - * + * * $Id$ */ @@ -14,125 +14,459 @@ #include "DNA_scene_types.h" #include "DNA_sound_types.h" #include "DNA_packedFile_types.h" +#include "DNA_screen_types.h" +#include "DNA_userdef_types.h" + +#include "AUD_C-API.h" #include "BKE_utildefines.h" #include "BKE_global.h" #include "BKE_main.h" #include "BKE_sound.h" +#include "BKE_context.h" +#include "BKE_library.h" #include "BKE_packedFile.h" #ifdef HAVE_CONFIG_H #include <config.h> #endif -ListBase _samples = {0,0}, *samples = &_samples; +void sound_init() +{ + AUD_Specs specs; + int device, buffersize, success; + + device = U.audiodevice; + buffersize = U.mixbufsize; + specs.channels = U.audiochannels; + specs.format = U.audioformat; + specs.rate = U.audiorate; + + if(buffersize < 128) + buffersize = AUD_DEFAULT_BUFFER_SIZE; + + if(specs.rate < AUD_RATE_8000) + specs.rate = AUD_RATE_44100; + + if(specs.format <= AUD_FORMAT_INVALID) + specs.format = AUD_FORMAT_S16; + + if(specs.channels <= AUD_CHANNELS_INVALID) + specs.channels = AUD_CHANNELS_STEREO; + + if(!AUD_init(device, specs, buffersize)) { + if(device == AUD_SDL_DEVICE) + success= AUD_init(AUD_OPENAL_DEVICE, specs, AUD_DEFAULT_BUFFER_SIZE*4); + else + success= AUD_init(AUD_SDL_DEVICE, specs, AUD_DEFAULT_BUFFER_SIZE*4); -void sound_free_sound(bSound *sound) + if(!success) + AUD_init(AUD_NULL_DEVICE, specs, buffersize); + } +} + +void sound_exit() { - /* when sounds have been loaded, but not played, the packedfile was not copied - to sample block and not freed otherwise */ - if(sound->sample==NULL) { - if (sound->newpackedfile) { - freePackedFile(sound->newpackedfile); - sound->newpackedfile = NULL; - } + AUD_exit(); +} + +struct bSound* sound_new_file(struct Main *main, char* filename) +{ + bSound* sound = NULL; + + char str[FILE_MAX]; + int len; + + strcpy(str, filename); + BLI_convertstringcode(str, main->name); + + len = strlen(filename); + while(len > 0 && filename[len-1] != '/' && filename[len-1] != '\\') + len--; + + sound = alloc_libblock(&main->sound, ID_SO, filename+len); + strcpy(sound->name, filename); + sound->type = SOUND_TYPE_FILE; + + sound_load(main, sound); + + if(!sound->snd_sound) + { + free_libblock(&main->sound, sound); + sound = NULL; + } + + return sound; +} + +// XXX unused currently +#if 0 +struct bSound* sound_new_buffer(struct bContext *C, struct bSound *source) +{ + bSound* sound = NULL; + + char name[25]; + strcpy(name, "buf_"); + strcpy(name + 4, source->id.name); + + sound = alloc_libblock(&CTX_data_main(C)->sound, ID_SO, name); + + sound->child_sound = source; + sound->type = SOUND_TYPE_BUFFER; + + sound_load(CTX_data_main(C), sound); + + if(!sound->snd_sound) + { + free_libblock(&CTX_data_main(C)->sound, sound); + sound = NULL; } - if (sound->stream) free(sound->stream); + + return sound; +} + +struct bSound* sound_new_limiter(struct bContext *C, struct bSound *source, float start, float end) +{ + bSound* sound = NULL; + + char name[25]; + strcpy(name, "lim_"); + strcpy(name + 4, source->id.name); + + sound = alloc_libblock(&CTX_data_main(C)->sound, ID_SO, name); + + sound->child_sound = source; + sound->start = start; + sound->end = end; + sound->type = SOUND_TYPE_LIMITER; + + sound_load(CTX_data_main(C), sound); + + if(!sound->snd_sound) + { + free_libblock(&CTX_data_main(C)->sound, sound); + sound = NULL; + } + + return sound; } +#endif -void sound_free_sample(bSample *sample) +void sound_delete(struct bContext *C, struct bSound* sound) { - if (sample) { - if (sample->data != &sample->fakedata[0] && sample->data != NULL) { - MEM_freeN(sample->data); - sample->data = &sample->fakedata[0]; + if(sound) + { + sound_free(sound); + + sound_unlink(C, sound); + + free_libblock(&CTX_data_main(C)->sound, sound); + } +} + +void sound_cache(struct bSound* sound, int ignore) +{ + if(sound->cache && !ignore) + AUD_unload(sound->cache); + + sound->cache = AUD_bufferSound(sound->snd_sound); +} + +void sound_load(struct Main *main, struct bSound* sound) +{ + if(sound) + { + if(sound->snd_sound) + { + AUD_unload(sound->snd_sound); + sound->snd_sound = NULL; } - - if (sample->packedfile) { - freePackedFile(sample->packedfile); //FIXME: crashes sometimes - sample->packedfile = NULL; + + switch(sound->type) + { + case SOUND_TYPE_FILE: + { + char fullpath[FILE_MAX]; + char *path; + + /* load sound */ + PackedFile* pf = sound->packedfile; + + /* dont modify soundact->sound->name, only change a copy */ + BLI_strncpy(fullpath, sound->name, sizeof(fullpath)); + + if(sound->id.lib) + path = sound->id.lib->filename; + else + path = main ? main->name : NULL; + + BLI_convertstringcode(fullpath, path); + + /* but we need a packed file then */ + if (pf) + sound->snd_sound = AUD_loadBuffer((unsigned char*) pf->data, pf->size); + /* or else load it from disk */ + else + sound->snd_sound = AUD_load(fullpath); + break; + } + case SOUND_TYPE_BUFFER: + if(sound->child_sound && sound->child_sound->snd_sound) + sound->snd_sound = AUD_bufferSound(sound->child_sound->snd_sound); + break; + case SOUND_TYPE_LIMITER: + if(sound->child_sound && sound->child_sound->snd_sound) + sound->snd_sound = AUD_limitSound(sound->child_sound, sound->start, sound->end); + break; + } + + if(sound->cache) + { + } - - if (sample->alindex != SAMPLE_INVALID) { -// AUD_free_sample(sample->snd_sample); - sample->alindex = SAMPLE_INVALID; + } +} + +void sound_free(struct bSound* sound) +{ + if (sound->packedfile) + { + freePackedFile(sound->packedfile); + sound->packedfile = NULL; + } + + if(sound->snd_sound) + { + AUD_unload(sound->snd_sound); + sound->snd_sound = NULL; + } +} + +void sound_unlink(struct bContext *C, struct bSound* sound) +{ + bSound *snd; + Scene *scene; + SoundHandle *handle; + + for(snd = CTX_data_main(C)->sound.first; snd; snd = snd->id.next) + { + if(snd->child_sound == sound) + { + snd->child_sound = NULL; + if(snd->snd_sound) + { + AUD_unload(sound->snd_sound); + snd->snd_sound = NULL; + } + + sound_unlink(C, snd); } + } - sample->type = SAMPLE_INVALID; + for(scene = CTX_data_main(C)->scene.first; scene; scene = scene->id.next) + { + for(handle = scene->sound_handles.first; handle; handle = handle->next) + { + if(handle->source == sound) + { + handle->source = NULL; + if(handle->handle) + AUD_stop(handle->handle); + } + } } } -/* this is called after file reading or undos */ -void sound_free_all_samples(void) +struct SoundHandle* sound_new_handle(struct Scene *scene, struct bSound* sound, int startframe, int endframe, int frameskip) +{ + ListBase* handles = &scene->sound_handles; + + SoundHandle* handle = MEM_callocN(sizeof(SoundHandle), "sound_handle"); + handle->source = sound; + handle->startframe = startframe; + handle->endframe = endframe; + handle->frameskip = frameskip; + handle->state = AUD_STATUS_INVALID; + handle->volume = 1.0f; + + BLI_addtail(handles, handle); + + return handle; +} + +void sound_delete_handle(struct Scene *scene, struct SoundHandle *handle) { - bSample *sample; - bSound *sound; - - /* ensure no sample pointers exist, and check packedfile */ - for(sound= G.main->sound.first; sound; sound= sound->id.next) { - if(sound->sample && sound->sample->packedfile==sound->newpackedfile) - sound->newpackedfile= NULL; - sound->sample= NULL; + if(handle == NULL) + return; + + if(handle->handle) + AUD_stop(handle->handle); + + BLI_freelinkN(&scene->sound_handles, handle); +} + +void sound_stop_all(struct bContext *C) +{ + SoundHandle *handle; + + for(handle = CTX_data_scene(C)->sound_handles.first; handle; handle = handle->next) + { + if(handle->state == AUD_STATUS_PLAYING) + { + AUD_pause(handle->handle); + handle->state = AUD_STATUS_PAUSED; + } } - - /* now free samples */ - for(sample= samples->first; sample; sample= sample->id.next) - sound_free_sample(sample); - BLI_freelistN(samples); - -} - -void sound_set_packedfile(bSample *sample, PackedFile *pf) -{ - bSound *sound; - - if (sample) { - sample->packedfile = pf; - sound = G.main->sound.first; - while (sound) { - if (sound->sample == sample) { - sound->newpackedfile = pf; - if (pf == NULL) { - strcpy(sound->name, sample->name); +} + +void sound_update_playing(struct bContext *C) +{ + SoundHandle *handle; + Scene* scene = CTX_data_scene(C); + int cfra = CFRA; + float fps = FPS; + int action; + + AUD_lock(); + + for(handle = scene->sound_handles.first; handle; handle = handle->next) + { + if(cfra < handle->startframe || cfra >= handle->endframe || handle->mute) + { + if(handle->state == AUD_STATUS_PLAYING) + { + AUD_pause(handle->handle); + handle->state = AUD_STATUS_PAUSED; + } + } + else + { + action = 0; + + if(handle->changed != handle->source->changed) + { + handle->changed = handle->source->changed; + action = 3; + if(handle->state != AUD_STATUS_INVALID) + { + AUD_stop(handle->handle); + handle->state = AUD_STATUS_INVALID; + } + } + else + { + if(handle->state != AUD_STATUS_PLAYING) + action = 3; + else + { + handle->state = AUD_getStatus(handle->handle); + if(handle->state != AUD_STATUS_PLAYING) + action = 3; + else + { + float diff = AUD_getPosition(handle->handle) * fps - cfra + handle->startframe; + if(diff < 0.0) + diff = -diff; + if(diff > 1.0f) + { + action = 2; + } + } + } + } + + if(action & 1) + { + if(handle->state == AUD_STATUS_INVALID) + { + if(handle->source && handle->source->snd_sound) + { + AUD_Sound* limiter = AUD_limitSound(handle->source->cache ? handle->source->cache : handle->source->snd_sound, handle->frameskip / fps, (handle->frameskip + handle->endframe - handle->startframe)/fps); + handle->handle = AUD_play(limiter, 1); + AUD_unload(limiter); + if(handle->handle) + handle->state = AUD_STATUS_PLAYING; + if(cfra == handle->startframe) + action &= ~2; + } } + else + if(AUD_resume(handle->handle)) + handle->state = AUD_STATUS_PLAYING; + else + handle->state = AUD_STATUS_INVALID; } - sound = sound->id.next; + + if(action & 2) + AUD_seek(handle->handle, (cfra - handle->startframe) / fps); } } + + AUD_unlock(); } -PackedFile* sound_find_packedfile(bSound *sound) -{ - bSound *search; - PackedFile *pf = NULL; - char soundname[FILE_MAXDIR + FILE_MAXFILE], searchname[FILE_MAXDIR + FILE_MAXFILE]; - - // convert sound->name to abolute filename - strcpy(soundname, sound->name); - BLI_convertstringcode(soundname, G.sce); - - search = G.main->sound.first; - while (search) { - if (search->sample && search->sample->packedfile) { - strcpy(searchname, search->sample->name); - BLI_convertstringcode(searchname, G.sce); - - if (BLI_streq(searchname, soundname)) { - pf = search->sample->packedfile; - break; +void sound_scrub(struct bContext *C) +{ + SoundHandle *handle; + Scene* scene = CTX_data_scene(C); + int cfra = CFRA; + float fps = FPS; + + if(scene->r.audio.flag & AUDIO_SCRUB && !CTX_wm_screen(C)->animtimer) + { + AUD_lock(); + + for(handle = scene->sound_handles.first; handle; handle = handle->next) + { + if(cfra >= handle->startframe && cfra < handle->endframe && !handle->mute) + { + if(handle->source && handle->source->snd_sound) + { + int frameskip = handle->frameskip + cfra - handle->startframe; + AUD_Sound* limiter = AUD_limitSound(handle->source->cache ? handle->source->cache : handle->source->snd_sound, frameskip / fps, (frameskip + 1)/fps); + AUD_play(limiter, 0); + AUD_unload(limiter); + } } - } - - if (search->newpackedfile) { - strcpy(searchname, search->name); - BLI_convertstringcode(searchname, G.sce); - if (BLI_streq(searchname, soundname)) { - pf = search->newpackedfile; - break; + } + + AUD_unlock(); + } +} + +AUD_Device* sound_mixdown(struct Scene *scene, AUD_Specs specs, int start, int end) +{ + AUD_Device* mixdown = AUD_openReadDevice(specs); + SoundHandle *handle; + float fps = FPS; + AUD_Sound *limiter, *delayer; + int frameskip, s, e; + + end++; + + for(handle = scene->sound_handles.first; handle; handle = handle->next) + { + if(start < handle->endframe && end > handle->startframe && !handle->mute && handle->source && handle->source->snd_sound) + { + frameskip = handle->frameskip; + s = handle->startframe - start; + e = handle->frameskip + AUD_MIN(handle->endframe, end) - handle->startframe; + + if(s < 0) + { + frameskip -= s; + s = 0; } + + limiter = AUD_limitSound(handle->source->snd_sound, frameskip / fps, e / fps); + delayer = AUD_delaySound(limiter, s / fps); + + AUD_playDevice(mixdown, delayer); + + AUD_unload(delayer); + AUD_unload(limiter); } - search = search->id.next; } - - return (pf); + + return mixdown; } diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index eeffbfe5ef6..61f62b2222d 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -43,6 +43,7 @@ #include "BLI_blenlib.h" #include "BLI_arithb.h" #include "BLI_rand.h" +#include "BLI_kdopbvh.h" #include "DNA_texture_types.h" #include "DNA_key_types.h" @@ -417,6 +418,8 @@ void free_texture(Tex *tex) free_plugin_tex(tex->plugin); if(tex->coba) MEM_freeN(tex->coba); if(tex->env) BKE_free_envmap(tex->env); + if(tex->pd) BKE_free_pointdensity(tex->pd); + if(tex->vd) BKE_free_voxeldata(tex->vd); BKE_previewimg_free(&tex->preview); BKE_icon_delete((struct ID*)tex); tex->id.icon_id = 0; @@ -486,6 +489,16 @@ void default_tex(Tex *tex) tex->env->depth=0; } + if (tex->pd) { + tex->pd->radius = 0.3f; + tex->pd->falloff_type = TEX_PD_FALLOFF_STD; + } + + if (tex->vd) { + tex->vd->resol[0] = tex->vd->resol[1] = tex->vd->resol[2] = 0; + tex->vd->interp_type=TEX_VD_LINEAR; + tex->vd->file_format=TEX_VD_SMOKE; + } pit = tex->plugin; if (pit) { varstr= pit->varstr; @@ -737,9 +750,9 @@ void make_local_texture(Tex *tex) void autotexname(Tex *tex) { - char texstr[20][12]= {"None" , "Clouds" , "Wood", "Marble", "Magic" , "Blend", + char texstr[20][15]= {"None" , "Clouds" , "Wood", "Marble", "Magic" , "Blend", "Stucci", "Noise" , "Image", "Plugin", "EnvMap" , "Musgrave", - "Voronoi", "DistNoise", "", "", "", "", "", ""}; + "Voronoi", "DistNoise", "Point Density", "Voxel Data", "", "", "", ""}; Image *ima; char di[FILE_MAXDIR], fi[FILE_MAXFILE]; @@ -888,6 +901,106 @@ void BKE_free_envmap(EnvMap *env) } /* ------------------------------------------------------------------------- */ + +PointDensity *BKE_add_pointdensity(void) +{ + PointDensity *pd; + + pd= MEM_callocN(sizeof(PointDensity), "pointdensity"); + pd->flag = 0; + pd->radius = 0.3f; + pd->falloff_type = TEX_PD_FALLOFF_STD; + pd->falloff_softness = 2.0; + pd->source = TEX_PD_PSYS; + pd->point_tree = NULL; + pd->point_data = NULL; + pd->noise_size = 0.5f; + pd->noise_depth = 1; + pd->noise_fac = 1.0f; + pd->noise_influence = TEX_PD_NOISE_STATIC; + pd->coba = add_colorband(1); + pd->speed_scale = 1.0f; + pd->totpoints = 0; + pd->coba = add_colorband(1); + pd->object = NULL; + pd->psys = NULL; + return pd; +} + +PointDensity *BKE_copy_pointdensity(PointDensity *pd) +{ + PointDensity *pdn; + + pdn= MEM_dupallocN(pd); + pdn->point_tree = NULL; + pdn->point_data = NULL; + if(pdn->coba) pdn->coba= MEM_dupallocN(pdn->coba); + + return pdn; +} + +void BKE_free_pointdensitydata(PointDensity *pd) +{ + if (pd->point_tree) { + BLI_bvhtree_free(pd->point_tree); + pd->point_tree = NULL; + } + if (pd->point_data) { + MEM_freeN(pd->point_data); + pd->point_data = NULL; + } + if(pd->coba) MEM_freeN(pd->coba); +} + +void BKE_free_pointdensity(PointDensity *pd) +{ + BKE_free_pointdensitydata(pd); + MEM_freeN(pd); +} + + +void BKE_free_voxeldatadata(struct VoxelData *vd) +{ + if (vd->dataset) { + MEM_freeN(vd->dataset); + vd->dataset = NULL; + } + +} + +void BKE_free_voxeldata(struct VoxelData *vd) +{ + BKE_free_voxeldatadata(vd); + MEM_freeN(vd); +} + +struct VoxelData *BKE_add_voxeldata(void) +{ + VoxelData *vd; + + vd= MEM_callocN(sizeof(struct VoxelData), "voxeldata"); + vd->dataset = NULL; + vd->resol[0] = vd->resol[1] = vd->resol[2] = 1; + vd->interp_type= TEX_VD_LINEAR; + vd->file_format= TEX_VD_SMOKE; + vd->int_multiplier = 1.0; + vd->object = NULL; + + return vd; + } + +struct VoxelData *BKE_copy_voxeldata(struct VoxelData *vd) +{ + VoxelData *vdn; + + vdn= MEM_dupallocN(vd); + vdn->dataset = NULL; + + return vdn; +} + + +/* ------------------------------------------------------------------------- */ int BKE_texture_dependsOnTime(const struct Tex *texture) { if(texture->plugin) { diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c new file mode 100644 index 00000000000..f8e3b3c5ad2 --- /dev/null +++ b/source/blender/blenkernel/intern/unit.c @@ -0,0 +1,585 @@ +/** + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * Contributor(s): Campbell Barton + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include <stdlib.h> +#include <stdio.h> +#include <ctype.h> +#include <string.h> +#include <math.h> + +#if defined(WIN32) && (!(defined snprintf)) +#define snprintf _snprintf +#endif + +#define TEMP_STR_SIZE 256 + +#define SEP_CHR '#' +#define SEP_STR "#" + +#define EUL 0.000001 + + +/* define a single unit */ +typedef struct bUnitDef { + char *name; + char *name_plural; /* abused a bit for the display name */ + char *name_short; /* this is used for display*/ + char *name_alt; /* can be NULL */ + + char *name_display; /* can be NULL */ + + double scalar; + double bias; /* not used yet, needed for converting temperature */ + int flag; +} bUnitDef; + +#define B_UNIT_DEF_NONE 0 +#define B_UNIT_DEF_SUPPRESS 1 /* Use for units that are not used enough to be translated into for common use */ + +/* define a single unit */ +typedef struct bUnitCollection { + struct bUnitDef *units; + int base_unit; /* use for 0.0, or none given */ + int flag; /* options for this system */ + int length; /* to quickly find the last item */ +} bUnitCollection; + +/* Dummy */ +static struct bUnitDef buDummyDef[] = { + {"", NULL, "", NULL, NULL, 1.0, 0.0}, + {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} +}; +static struct bUnitCollection buDummyCollecton = {buDummyDef, 0, 0, sizeof(buDummyDef)}; + + +/* Lengths */ +static struct bUnitDef buMetricLenDef[] = { + {"kilometer", "kilometers", "km", NULL, "Kilometers", 1000.0, 0.0, B_UNIT_DEF_NONE}, + {"hectometer", "hectometers", "hm", NULL, "10 Meters", 100.0, 0.0, B_UNIT_DEF_SUPPRESS}, + {"dekameter", "dekameters", "dkm",NULL, "10 Meters", 10.0, 0.0, B_UNIT_DEF_SUPPRESS}, + {"meter", "meters", "m", NULL, "Meters", 1.0, 0.0, B_UNIT_DEF_NONE}, /* base unit */ + {"decimetre", "decimetres", "dm", NULL, "10 Centimeters", 0.1, 0.0, B_UNIT_DEF_SUPPRESS}, + {"centimeter", "centimeters", "cm", NULL, "Centimeters", 0.01, 0.0, B_UNIT_DEF_NONE}, + {"millimeter", "millimeters", "mm", NULL, "Millimeters", 0.001, 0.0, B_UNIT_DEF_NONE}, + {"micrometer", "micrometers", "um", "µm", "Micrometers", 0.000001, 0.0, B_UNIT_DEF_NONE}, // micron too? + + /* These get displayed because of float precision problems in the transform header, + * could work around, but for now probably people wont use these */ + /* + {"nanometer", "Nanometers", "nm", NULL, 0.000000001, 0.0, B_UNIT_DEF_NONE}, + {"picometer", "Picometers", "pm", NULL, 0.000000000001, 0.0,B_UNIT_DEF_NONE}, + */ + {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} +}; +static struct bUnitCollection buMetricLenCollecton = {buMetricLenDef, 3, 0, sizeof(buMetricLenDef)/sizeof(bUnitDef)}; + +static struct bUnitDef buImperialLenDef[] = { + {"mile", "miles", "mi", "m", "Miles", 1609.344, 0.0, B_UNIT_DEF_NONE}, + {"furlong", "furlongs", "fur", NULL, "Furlongs",201.168, 0.0, B_UNIT_DEF_SUPPRESS}, + {"chain", "chains", "ch", NULL, "Chains", 0.9144*22.0, 0.0, B_UNIT_DEF_SUPPRESS}, + {"yard", "yards", "yd", NULL, "Yards", 0.9144, 0.0, B_UNIT_DEF_NONE}, + {"foot", "feet", "'", "ft", "Feet", 0.3048, 0.0, B_UNIT_DEF_NONE}, + {"inch", "inches", "\"", "in", "Inches", 0.0254, 0.0, B_UNIT_DEF_NONE}, /* base unit */ + {"thou", "thous", "mil", NULL, "Thous", 0.0000254, 0.0, B_UNIT_DEF_NONE}, + {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} +}; +static struct bUnitCollection buImperialLenCollecton = {buImperialLenDef, 4, 0, sizeof(buImperialLenDef)/sizeof(bUnitDef)}; + + +/* Time */ +static struct bUnitDef buNaturalTimeDef[] = { + /* weeks? - probably not needed for blender */ + {"day", "days", "d", NULL, "Days", 90000.0, 0.0, B_UNIT_DEF_NONE}, + {"hour", "hours", "hr", "h", "Hours", 3600.0, 0.0, B_UNIT_DEF_NONE}, + {"minute", "minutes", "min", "m", "Minutes", 60.0, 0.0, B_UNIT_DEF_NONE}, + {"second", "seconds", "sec", "s", "Seconds", 1.0, 0.0, B_UNIT_DEF_NONE}, /* base unit */ + {"millisecond", "milliseconds", "ms", NULL, "Milliseconds", 0.001, 0.0 , B_UNIT_DEF_NONE}, + {"microsecond", "microseconds", "us", NULL, "Microseconds", 0.000001, 0.0, B_UNIT_DEF_NONE}, + {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} +}; +static struct bUnitCollection buNaturalTimeCollecton = {buNaturalTimeDef, 3, 0, sizeof(buNaturalTimeDef)/sizeof(bUnitDef)}; + +#define UNIT_SYSTEM_MAX 3 +static struct bUnitCollection *bUnitSystems[][8] = { + {0,0,0,0,0,0,0,0}, + {0,&buMetricLenCollecton, 0,0,0,0, &buNaturalTimeCollecton,0}, /* metric */ + {0,&buImperialLenCollecton, 0,0,0,0, &buNaturalTimeCollecton,0}, /* imperial */ + {0,0,0,0,0,0,0,0} +}; + +/* internal, has some option not exposed */ +static bUnitCollection *unit_get_system(int system, int type) +{ + return bUnitSystems[system][type]; /* select system to use, metric/imperial/other? */ +} + +static bUnitDef *unit_default(bUnitCollection *usys) +{ + return &usys->units[usys->base_unit]; +} + +static bUnitDef *unit_best_fit(double value, bUnitCollection *usys, bUnitDef *unit_start, int suppress) +{ + bUnitDef *unit; + double value_abs= value>0.0?value:-value; + + for(unit= unit_start ? unit_start:usys->units; unit->name; unit++) { + + if(suppress && (unit->flag & B_UNIT_DEF_SUPPRESS)) + continue; + + if (value_abs >= unit->scalar*(1.0-EUL)) /* scale down scalar so 1cm doesnt convert to 10mm because of float error */ + return unit; + } + + return unit_default(usys); +} + + + +/* convert into 2 units and 2 values for "2ft, 3inch" syntax */ +static void unit_dual_convert(double value, bUnitCollection *usys, + bUnitDef **unit_a, bUnitDef **unit_b, double *value_a, double *value_b) +{ + bUnitDef *unit= unit_best_fit(value, usys, NULL, 1); + + *value_a= floor(value/unit->scalar) * unit->scalar; + *value_b= value - (*value_a); + + *unit_a= unit; + *unit_b= unit_best_fit(*value_b, usys, *unit_a, 1); +} + +static int unit_as_string(char *str, int len_max, double value, int prec, bUnitCollection *usys, + /* non exposed options */ + bUnitDef *unit, char pad) +{ + double value_conv; + int len, i; + + if(unit) { + /* use unit without finding the best one */ + } + else if(value == 0.0) { + /* use the default units since there is no way to convert */ + unit= unit_default(usys); + } + else { + unit= unit_best_fit(value, usys, NULL, 1); + } + + value_conv= value/unit->scalar; + + /* Convert to a string */ + { + char conv_str[6] = {'%', '.', '0'+prec, 'l', 'f', '\0'}; /* "%.2lf" when prec is 2, must be under 10 */ + len= snprintf(str, len_max, conv_str, (float)value_conv); + + if(len >= len_max) + len= len_max; + } + + /* Add unit prefix and strip zeros */ + + /* replace trailing zero's with spaces + * so the number is less complicated but allignment in a button wont + * jump about while dragging */ + i= len-1; + + while(i>0 && str[i]=='0') { /* 4.300 -> 4.3 */ + str[i--]= pad; + } + + if(i>0 && str[i]=='.') { /* 10. -> 10 */ + str[i--]= pad; + } + + /* Now add the suffix */ + if(i<len_max) { + int j=0; + i++; + while(unit->name_short[j] && (i < len_max)) { + str[i++]= unit->name_short[j++]; + } + + if(pad) { + /* this loop only runs if so many zeros were removed that + * the unit name only used padded chars, + * In that case add padding for the name. */ + + while(i<=len+j && (i < len_max)) { + str[i++]= pad; + } + } + } + + /* terminate no matter whats done with padding above */ + if(i >= len_max) + i= len_max-1; + + str[i] = '\0'; + return i; +} + + +/* Used for drawing number buttons, try keep fast */ +void bUnit_AsString(char *str, int len_max, double value, int prec, int system, int type, int split, int pad) +{ + bUnitCollection *usys = unit_get_system(system, type); + + if(usys==NULL || usys->units[0].name==NULL) + usys= &buDummyCollecton; + + if(split) { + int i; + bUnitDef *unit_a, *unit_b; + double value_a, value_b; + + unit_dual_convert(value, usys, &unit_a, &unit_b, &value_a, &value_b); + + /* check the 2 is a smaller unit */ + if(unit_b > unit_a) { + i= unit_as_string(str, len_max, value_a, prec, usys, unit_a, '\0'); + + /* is there enough space for at least 1 char of the next unit? */ + if(i+2 < len_max) { + str[i++]= ' '; + + /* use low precision since this is a smaller unit */ + unit_as_string(str+i, len_max-i, value_b, prec?1:0, usys, unit_b, '\0'); + } + return; + } + } + + unit_as_string(str, len_max, value, prec, usys, NULL, pad?' ':'\0'); +} + + +static char *unit_find_str(char *str, char *substr) +{ + char *str_found; + + if(substr && substr[0] != '\0') { + str_found= strstr(str, substr); + if(str_found) { + /* previous char cannot be a letter */ + if (str_found == str || isalpha(*(str_found-1))==0) { + /* next char cannot be alphanum */ + int len_name = strlen(substr); + + if (!isalpha(*(str_found+len_name))) { + return str_found; + } + } + } + + } + return NULL; + +} + +/* Note that numbers are added within brackets + * ") " - is used to detect numbers we added so we can detect if commas need to be added + * + * "1m1cm+2mm" - Original value + * "1*1#1*0.01#+2*0.001#" - Replace numbers + * "1*1,1*0.01 +2*0.001 " - Add comma's if ( - + * / % ^ < > ) not found in between + * + */ + +/* not too strict, (- = * /) are most common */ +static int ch_is_op(char op) +{ + switch(op) { + case '+': + case '-': + case '*': + case '/': + case '|': + case '&': + case '~': + case '<': + case '>': + case '^': + case '!': + case '=': + case '%': + return 1; + default: + return 0; + } +} + +static int unit_scale_str(char *str, int len_max, char *str_tmp, double scale_pref, bUnitDef *unit, char *replace_str) +{ + char *str_found; + + if((len_max>0) && (str_found= unit_find_str(str, replace_str))) { /* XXX - investigate, does not respect len_max properly */ + int len, len_num, len_name, len_move, found_ofs; + + found_ofs = (int)(str_found-str); + + len= strlen(str); + + len_name = strlen(replace_str); + len_move= (len - (found_ofs+len_name)) + 1; /* 1+ to copy the string terminator */ + len_num= snprintf(str_tmp, TEMP_STR_SIZE, "*%lg"SEP_STR, unit->scalar/scale_pref); /* # removed later */ + + if(len_num > len_max) + len_num= len_max; + + if(found_ofs+len_num+len_move > len_max) { + /* can't move the whole string, move just as much as will fit */ + len_move -= (found_ofs+len_num+len_move) - len_max; + } + + if(len_move>0) { + /* resize the last part of the string */ + memmove(str_found+len_num, str_found+len_name, len_move); /* may grow or shrink the string */ + } + + if(found_ofs+len_num > len_max) { + /* not even the number will fit into the string, only copy part of it */ + len_num -= (found_ofs+len_num) - len_max; + } + + if(len_num > 0) { + /* its possible none of the number could be copied in */ + memcpy(str_found, str_tmp, len_num); /* without the string terminator */ + } + + /* since the null terminator wont be moved if the stringlen_max + * was not long enough to fit everything in it */ + str[len_max-1]= '\0'; + return found_ofs + len_num; + } + return 0; +} + +static int unit_replace(char *str, int len_max, char *str_tmp, double scale_pref, bUnitDef *unit) +{ + int ofs= 0; + ofs += unit_scale_str(str+ofs, len_max-ofs, str_tmp, scale_pref, unit, unit->name_short); + ofs += unit_scale_str(str+ofs, len_max-ofs, str_tmp, scale_pref, unit, unit->name_plural); + ofs += unit_scale_str(str+ofs, len_max-ofs, str_tmp, scale_pref, unit, unit->name_alt); + ofs += unit_scale_str(str+ofs, len_max-ofs, str_tmp, scale_pref, unit, unit->name); + return ofs; +} + +static int unit_find(char *str, bUnitDef *unit) +{ + if (unit_find_str(str, unit->name_short)) return 1; + if (unit_find_str(str, unit->name_plural)) return 1; + if (unit_find_str(str, unit->name_alt)) return 1; + if (unit_find_str(str, unit->name)) return 1; + + return 0; +} + +/* make a copy of the string that replaces the units with numbers + * this is used before parsing + * This is only used when evaluating user input and can afford to be a bit slower + * + * This is to be used before python evaluation so.. + * 10.1km -> 10.1*1000.0 + * ...will be resolved by python. + * + * values will be split by a comma's + * 5'2" -> 5'0.0254, 2*0.3048 + * + * str_prev is optional, when valid it is used to get a base unit when none is set. + * + * return true of a change was made. + */ +int bUnit_ReplaceString(char *str, int len_max, char *str_prev, double scale_pref, int system, int type) +{ + bUnitCollection *usys = unit_get_system(system, type); + + bUnitDef *unit; + char str_tmp[TEMP_STR_SIZE]; + int change= 0; + + if(usys==NULL || usys->units[0].name==NULL) { + return 0; + } + + + { /* make lowercase */ + int i; + char *ch= str; + + for(i=0; (i>=len_max || *ch=='\0'); i++, ch++) + if((*ch>='A') && (*ch<='Z')) + *ch += ('a'-'A'); + } + + + for(unit= usys->units; unit->name; unit++) { + + if(unit->flag & B_UNIT_DEF_SUPPRESS) + continue; + + /* incase there are multiple instances */ + while(unit_replace(str, len_max, str_tmp, scale_pref, unit)) + change= 1; + } + unit= NULL; + + { + /* try other unit systems now, so we can evaluate imperial when metric is set for eg. */ + bUnitCollection *usys_iter; + int system_iter; + + for(system_iter= 1; system_iter<UNIT_SYSTEM_MAX; system_iter++) { + if (system_iter != system) { + usys_iter= unit_get_system(system_iter, type); + for(unit= usys_iter->units; unit->name; unit++) { + + if((unit->flag & B_UNIT_DEF_SUPPRESS) == 0) { + int ofs = 0; + /* incase there are multiple instances */ + while((ofs=unit_replace(str+ofs, len_max-ofs, str_tmp, scale_pref, unit))) + change= 1; + } + } + } + } + } + unit= NULL; + + if(change==0) { + /* no units given so infer a unit from the previous string or default */ + if(str_prev) { + /* see which units the original value had */ + for(unit= usys->units; unit->name; unit++) { + + if(unit->flag & B_UNIT_DEF_SUPPRESS) + continue; + + if (unit_find(str_prev, unit)) + break; + } + } + + if(unit==NULL) + unit= unit_default(usys); + + /* add the unit prefic and re-run, use brackets incase there was an expression given */ + if(snprintf(str_tmp, sizeof(str_tmp), "(%s)%s", str, unit->name) < sizeof(str_tmp)) { + strncpy(str, str_tmp, len_max); + return bUnit_ReplaceString(str, len_max, NULL, scale_pref, system, type); + } + else { + /* snprintf would not fit into str_tmp, cant do much in this case + * check for this because otherwise bUnit_ReplaceString could call its self forever */ + return 0; + } + + } + + /* replace # with commas when there is no operator between it and the next number + * + * "1*1# 3*100# * 3" -> "1 *1, 3 *100 * 3" + * + * */ + { + char *str_found= str; + char *ch= str; + + while((str_found= strchr(str_found, SEP_CHR))) { + + int op_found= 0; + /* any operators after this?*/ + for(ch= str_found+1; *ch!='\0'; ch++) { + + if(*ch==' ' || *ch=='\t') { + /* do nothing */ + } + else if (ch_is_op(*ch) || *ch==',') { /* found an op, no need to insert a ,*/ + op_found= 1; + break; + } + else { /* found a non-op character */ + op_found= 0; + break; + } + } + + *str_found++ = op_found ? ' ':','; + } + } + + // printf("replace %s\n", str); + return change; +} + + +double bUnit_ClosestScalar(double value, int system, int type) +{ + bUnitCollection *usys = unit_get_system(system, type); + bUnitDef *unit; + + if(usys==NULL) + return -1; + + unit= unit_best_fit(value, usys, NULL, 1); + if(unit==NULL) + return -1; + + return unit->scalar; +} + +double bUnit_BaseScalar(int system, int type) +{ + bUnitCollection *usys = unit_get_system(system, type); + return unit_default(usys)->scalar; +} + +/* external access */ +void bUnit_GetSystem(void **usys_pt, int *len, int system, int type) +{ + bUnitCollection *usys = unit_get_system(system, type); + *usys_pt= usys; + + if(usys==NULL) { + *len= 0; + return; + } + + *len= usys->length; +} + +char *bUnit_GetName(void *usys_pt, int index) +{ + return ((bUnitCollection *)usys_pt)->units[index].name; +} +char *bUnit_GetNameDisplay(void *usys_pt, int index) +{ + return ((bUnitCollection *)usys_pt)->units[index].name_display; +} + +double bUnit_GetScaler(void *usys_pt, int index) +{ + return ((bUnitCollection *)usys_pt)->units[index].scalar; +} diff --git a/source/blender/blenkernel/intern/writeavi.c b/source/blender/blenkernel/intern/writeavi.c index cfbe3f629d6..7c58a4f9499 100644 --- a/source/blender/blenkernel/intern/writeavi.c +++ b/source/blender/blenkernel/intern/writeavi.c @@ -127,7 +127,7 @@ void makeavistring (RenderData *rd, char *string) } } -void start_avi(RenderData *rd, int rectx, int recty) +void start_avi(struct Scene *scene, RenderData *rd, int rectx, int recty) { int x, y; char name[256]; diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index 5e3c8024524..e7164dc4794 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -65,6 +65,10 @@ #include "DNA_scene_types.h" +#include "AUD_C-API.h" +#include "BKE_sound.h" +#include "BKE_main.h" + #ifdef HAVE_CONFIG_H #include <config.h> #endif @@ -96,6 +100,8 @@ static int audio_input_frame_size = 0; static uint8_t* audio_output_buffer = 0; static int audio_outbuf_size = 0; +static AUD_Device* audio_mixdown_device = 0; + #define FFMPEG_AUTOSPLIT_SIZE 2000000000 /* Delete a picture buffer */ @@ -127,9 +133,8 @@ static int write_audio_frame(void) c = get_codec_from_stream(audio_stream); - //XXX audiostream_fill(audio_input_buffer, - // audio_input_frame_size - // * sizeof(short) * c->channels); + if(audio_mixdown_device) + AUD_readDevice(audio_mixdown_device, audio_input_buffer, audio_input_frame_size); av_init_packet(&pkt); @@ -827,11 +832,21 @@ static void makeffmpegstring(RenderData* rd, char* string) { } -void start_ffmpeg(RenderData *rd, int rectx, int recty) +void start_ffmpeg(struct Scene *scene, RenderData *rd, int rectx, int recty) { ffmpeg_autosplit_count = 0; start_ffmpeg_impl(rd, rectx, recty); + + if(ffmpeg_multiplex_audio && audio_stream) + { + AVCodecContext* c = get_codec_from_stream(audio_stream); + AUD_Specs specs; + specs.channels = c->channels; + specs.format = AUD_FORMAT_S16; + specs.rate = rd->audio.mixrate; + audio_mixdown_device = sound_mixdown(scene, specs, rd->sfra, rd->efra); + } } void end_ffmpeg(void); @@ -884,6 +899,12 @@ void end_ffmpeg(void) if (audio_stream && video_stream) { write_audio_frames(); } + + if(audio_mixdown_device) + { + AUD_closeReadDevice(audio_mixdown_device); + audio_mixdown_device = 0; + } if (outfile) { av_write_trailer(outfile); diff --git a/source/blender/blenkernel/intern/writeframeserver.c b/source/blender/blenkernel/intern/writeframeserver.c index 2d3a2e6b883..0780cd0dc48 100644 --- a/source/blender/blenkernel/intern/writeframeserver.c +++ b/source/blender/blenkernel/intern/writeframeserver.c @@ -101,7 +101,7 @@ static int closesocket(int fd) } #endif -void start_frameserver(RenderData *rd, int rectx, int recty) +void start_frameserver(struct Scene *scene, RenderData *rd, int rectx, int recty) { struct sockaddr_in addr; int arg = 1; diff --git a/source/blender/blenlib/BLI_arithb.h b/source/blender/blenlib/BLI_arithb.h index e66cf18b3c7..cbc7e9cc3af 100644 --- a/source/blender/blenlib/BLI_arithb.h +++ b/source/blender/blenlib/BLI_arithb.h @@ -327,6 +327,7 @@ void printvec4f(char *str, float v[4]); void VecAddf(float *v, float *v1, float *v2); void VecSubf(float *v, float *v1, float *v2); +void VecMulVecf(float *v, float *v1, float *v2); void VecLerpf(float *target, float *a, float *b, float t); void VecMidf(float *v, float *v1, float *v2); diff --git a/source/blender/blenlib/BLI_kdopbvh.h b/source/blender/blenlib/BLI_kdopbvh.h index 50462d531ef..fe6bc576fbd 100644 --- a/source/blender/blenlib/BLI_kdopbvh.h +++ b/source/blender/blenlib/BLI_kdopbvh.h @@ -71,6 +71,8 @@ typedef void (*BVHTree_NearestPointCallback) (void *userdata, int index, const f /* callback must update hit in case it finds a nearest successful hit */ typedef void (*BVHTree_RayCastCallback) (void *userdata, int index, const BVHTreeRay *ray, BVHTreeRayHit *hit); +/* callback to range search query */ +typedef void (*BVHTree_RangeQuery) (void *userdata, int index, float squared_dist); BVHTree *BLI_bvhtree_new(int maxsize, float epsilon, char tree_type, char axis); void BLI_bvhtree_free(BVHTree *tree); @@ -95,5 +97,9 @@ int BLI_bvhtree_ray_cast(BVHTree *tree, const float *co, const float *dir, float float BLI_bvhtree_bb_raycast(float *bv, float *light_start, float *light_end, float *pos); +/* range query */ +int BLI_bvhtree_range_query(BVHTree *tree, const float *co, float radius, BVHTree_RangeQuery callback, void *userdata); + + #endif // BLI_KDOPBVH_H diff --git a/source/blender/blenlib/BLI_voxel.h b/source/blender/blenlib/BLI_voxel.h new file mode 100644 index 00000000000..9b815ccbf42 --- /dev/null +++ b/source/blender/blenlib/BLI_voxel.h @@ -0,0 +1,40 @@ +/** + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): Matt Ebb, Raul Fernandez Hernandez (Farsthary). + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#ifndef BLI_VOXEL_H +#define BLI_VOXEL_H + +/* find the index number of a voxel, given x/y/z integer coords and resolution vector */ +#define V_I(x, y, z, res) ( (z)*(res)[1]*(res)[0] + (y)*(res)[0] + (x) ) + +/* all input coordinates must be in bounding box 0.0 - 1.0 */ +float voxel_sample_nearest(float *data, int *res, float *co); +float voxel_sample_trilinear(float *data, int *res, float *co); +float voxel_sample_tricubic(float *data, int *res, float *co); + +#endif /* BLI_VOXEL_H */ diff --git a/source/blender/blenlib/BLI_winstuff.h b/source/blender/blenlib/BLI_winstuff.h index 3e1b73e51be..fad45f1b6c3 100644 --- a/source/blender/blenlib/BLI_winstuff.h +++ b/source/blender/blenlib/BLI_winstuff.h @@ -65,20 +65,22 @@ extern "C" { #endif -#ifndef M_PI -#define M_PI 3.14159265358979323846 -#endif -#ifndef M_PI_2 -#define M_PI_2 1.57079632679489661923 -#endif -#ifndef M_SQRT2 -#define M_SQRT2 1.41421356237309504880 -#endif -#ifndef M_SQRT1_2 -#define M_SQRT1_2 0.70710678118654752440 -#endif -#ifndef M_1_PI -#define M_1_PI 0.318309886183790671538 +# ifndef _WIN64 + #ifndef M_PI + #define M_PI 3.14159265358979323846 + #endif + #ifndef M_PI_2 + #define M_PI_2 1.57079632679489661923 + #endif + #ifndef M_SQRT2 + #define M_SQRT2 1.41421356237309504880 + #endif + #ifndef M_SQRT1_2 + #define M_SQRT1_2 0.70710678118654752440 + #endif + #ifndef M_1_PI + #define M_1_PI 0.318309886183790671538 + #endif #endif #define MAXPATHLEN MAX_PATH diff --git a/source/blender/blenlib/CMakeLists.txt b/source/blender/blenlib/CMakeLists.txt index 334c8e6906b..a0bf2367b98 100644 --- a/source/blender/blenlib/CMakeLists.txt +++ b/source/blender/blenlib/CMakeLists.txt @@ -28,8 +28,7 @@ FILE(GLOB SRC intern/*.c) SET(INC . ../makesdna ../blenkernel ../../../intern/guardedalloc ../include - ${FREETYPE_INC} - ${SDL_INC} + ${FREETYPE_INCLUDE_DIRS} ${ZLIB_INC} ) diff --git a/source/blender/blenlib/intern/BLI_kdopbvh.c b/source/blender/blenlib/intern/BLI_kdopbvh.c index 84de9f9d862..61d9cce1a58 100644 --- a/source/blender/blenlib/intern/BLI_kdopbvh.c +++ b/source/blender/blenlib/intern/BLI_kdopbvh.c @@ -72,10 +72,10 @@ struct BVHTree char start_axis, stop_axis; // KDOP_AXES array indices according to axis }; -typedef struct BVHOverlapData -{ - BVHTree *tree1, *tree2; - BVHTreeOverlap *overlap; +typedef struct BVHOverlapData +{ + BVHTree *tree1, *tree2; + BVHTreeOverlap *overlap; int i, max_overlap; /* i is number of overlaps */ int start_axis, stop_axis; } BVHOverlapData; @@ -109,7 +109,7 @@ typedef struct BVHRayCastData //////////////////////////////////////////////////////////////////////// // Bounding Volume Hierarchy Definition -// +// // Notes: From OBB until 26-DOP --> all bounding volumes possible, just choose type below // Notes: You have to choose the type at compile time ITM // Notes: You can choose the tree type --> binary, quad, octree, choose below @@ -188,10 +188,10 @@ int ADJUST_MEMORY(void *local_memblock, void **memblock, int new_size, int *max_ ////////////////////////////////////////////////////////////////////////////////////////////////////// -// Introsort +// Introsort // with permission deriven from the following Java code: // http://ralphunden.net/content/tutorials/a-guide-to-introsort/ -// and he derived it from the SUN STL +// and he derived it from the SUN STL ////////////////////////////////////////////////////////////////////////////////////////////////////// static int size_threshold = 16; /* @@ -362,7 +362,7 @@ static void create_kdop_hull(BVHTree *tree, BVHNode *node, float *co, int numpoi float newminmax; float *bv = node->bv; int i, k; - + // don't init boudings for the moving case if(!moving) { @@ -372,7 +372,7 @@ static void create_kdop_hull(BVHTree *tree, BVHNode *node, float *co, int numpoi bv[2*i + 1] = -FLT_MAX; } } - + for(k = 0; k < numpoints; k++) { // for all Axes. @@ -394,7 +394,7 @@ static void refit_kdop_hull(BVHTree *tree, BVHNode *node, int start, int end) int i, j; float *bv = node->bv; - + for (i = tree->start_axis; i < tree->stop_axis; i++) { bv[2*i] = FLT_MAX; @@ -406,10 +406,10 @@ static void refit_kdop_hull(BVHTree *tree, BVHNode *node, int start, int end) // for all Axes. for (i = tree->start_axis; i < tree->stop_axis; i++) { - newmin = tree->nodes[j]->bv[(2 * i)]; + newmin = tree->nodes[j]->bv[(2 * i)]; if ((newmin < bv[(2 * i)])) bv[(2 * i)] = newmin; - + newmax = tree->nodes[j]->bv[(2 * i) + 1]; if ((newmax > bv[(2 * i) + 1])) bv[(2 * i) + 1] = newmax; @@ -427,14 +427,14 @@ static char get_largest_axis(float *bv) middle_point[0] = (bv[1]) - (bv[0]); // x axis middle_point[1] = (bv[3]) - (bv[2]); // y axis middle_point[2] = (bv[5]) - (bv[4]); // z axis - if (middle_point[0] > middle_point[1]) + if (middle_point[0] > middle_point[1]) { if (middle_point[0] > middle_point[2]) return 1; // max x axis else return 5; // max z axis } - else + else { if (middle_point[1] > middle_point[2]) return 3; // max y axis @@ -448,24 +448,24 @@ static char get_largest_axis(float *bv) static void node_join(BVHTree *tree, BVHNode *node) { int i, j; - + for (i = tree->start_axis; i < tree->stop_axis; i++) { node->bv[2*i] = FLT_MAX; node->bv[2*i + 1] = -FLT_MAX; } - + for (i = 0; i < tree->tree_type; i++) { - if (node->children[i]) + if (node->children[i]) { for (j = tree->start_axis; j < tree->stop_axis; j++) { - // update minimum - if (node->children[i]->bv[(2 * j)] < node->bv[(2 * j)]) + // update minimum + if (node->children[i]->bv[(2 * j)] < node->bv[(2 * j)]) node->bv[(2 * j)] = node->children[i]->bv[(2 * j)]; - - // update maximum + + // update maximum if (node->children[i]->bv[(2 * j) + 1] > node->bv[(2 * j) + 1]) node->bv[(2 * j) + 1] = node->children[i]->bv[(2 * j) + 1]; } @@ -518,7 +518,7 @@ static void bvhtree_info(BVHTree *tree) static void verify_tree(BVHTree *tree) { int i, j, check = 0; - + // check the pointer list for(i = 0; i < tree->totleaf; i++) { @@ -538,7 +538,7 @@ static void verify_tree(BVHTree *tree) check = 0; } } - + // check the leaf list for(i = 0; i < tree->totleaf; i++) { @@ -558,7 +558,7 @@ static void verify_tree(BVHTree *tree) check = 0; } } - + printf("branches: %d, leafs: %d, total: %d\n", tree->totbranch, tree->totleaf, tree->totbranch + tree->totleaf); } #endif @@ -703,7 +703,7 @@ static void non_recursive_bvh_div_nodes(BVHTree *tree, BVHNode *branches_array, BVHBuildHelper data; int depth; - + // set parent from root node to NULL BVHNode *tmp = branches_array+0; tmp->parent = NULL; @@ -722,7 +722,7 @@ static void non_recursive_bvh_div_nodes(BVHTree *tree, BVHNode *branches_array, } branches_array--; //Implicit trees use 1-based indexs - + build_implicit_tree_helper(tree, &data); //Loop tree levels (log N) loops @@ -806,11 +806,11 @@ BVHTree *BLI_bvhtree_new(int maxsize, float epsilon, char tree_type, char axis) { BVHTree *tree; int numnodes, i; - + // theres not support for trees below binary-trees :P if(tree_type < 2) return NULL; - + if(tree_type > MAX_TREETYPE) return NULL; @@ -820,13 +820,13 @@ BVHTree *BLI_bvhtree_new(int maxsize, float epsilon, char tree_type, char axis) //so that tangent rays can still hit a bounding volume.. //this bug would show up when casting a ray aligned with a kdop-axis and with an edge of 2 faces epsilon = MAX2(FLT_EPSILON, epsilon); - + if(tree) { tree->epsilon = epsilon; - tree->tree_type = tree_type; + tree->tree_type = tree_type; tree->axis = axis; - + if(axis == 26) { tree->start_axis = 0; @@ -863,13 +863,13 @@ BVHTree *BLI_bvhtree_new(int maxsize, float epsilon, char tree_type, char axis) numnodes = maxsize + implicit_needed_branches(tree_type, maxsize) + tree_type; tree->nodes = (BVHNode **)MEM_callocN(sizeof(BVHNode *)*numnodes, "BVHNodes"); - + if(!tree->nodes) { MEM_freeN(tree); return NULL; } - + tree->nodebv = (float*)MEM_callocN(sizeof(float)* axis * numnodes, "BVHNodeBV"); if(!tree->nodebv) { @@ -886,7 +886,7 @@ BVHTree *BLI_bvhtree_new(int maxsize, float epsilon, char tree_type, char axis) } tree->nodearray = (BVHNode *)MEM_callocN(sizeof(BVHNode)* numnodes, "BVHNodeArray"); - + if(!tree->nodearray) { MEM_freeN(tree->nodechild); @@ -902,14 +902,14 @@ BVHTree *BLI_bvhtree_new(int maxsize, float epsilon, char tree_type, char axis) tree->nodearray[i].bv = tree->nodebv + i * axis; tree->nodearray[i].children = tree->nodechild + i * tree_type; } - + } return tree; } void BLI_bvhtree_free(BVHTree *tree) -{ +{ if(tree) { MEM_freeN(tree->nodes); @@ -946,27 +946,27 @@ int BLI_bvhtree_insert(BVHTree *tree, int index, float *co, int numpoints) { int i; BVHNode *node = NULL; - + // insert should only possible as long as tree->totbranch is 0 if(tree->totbranch > 0) return 0; - + if(tree->totleaf+1 >= MEM_allocN_len(tree->nodes)/sizeof(*(tree->nodes))) return 0; - + // TODO check if have enough nodes in array - + node = tree->nodes[tree->totleaf] = &(tree->nodearray[tree->totleaf]); tree->totleaf++; - + create_kdop_hull(tree, node, co, numpoints, 0); node->index= index; - + // inflate the bv with some epsilon for (i = tree->start_axis; i < tree->stop_axis; i++) { - node->bv[(2 * i)] -= tree->epsilon; // minimum - node->bv[(2 * i) + 1] += tree->epsilon; // maximum + node->bv[(2 * i)] -= tree->epsilon; // minimum + node->bv[(2 * i) + 1] += tree->epsilon; // maximum } return 1; @@ -978,23 +978,23 @@ int BLI_bvhtree_update_node(BVHTree *tree, int index, float *co, float *co_movin { int i; BVHNode *node= NULL; - + // check if index exists if(index > tree->totleaf) return 0; - + node = tree->nodearray + index; - + create_kdop_hull(tree, node, co, numpoints, 0); - + if(co_moving) create_kdop_hull(tree, node, co_moving, numpoints, 1); - + // inflate the bv with some epsilon for (i = tree->start_axis; i < tree->stop_axis; i++) { - node->bv[(2 * i)] -= tree->epsilon; // minimum - node->bv[(2 * i) + 1] += tree->epsilon; // maximum + node->bv[(2 * i)] -= tree->epsilon; // minimum + node->bv[(2 * i) + 1] += tree->epsilon; // maximum } return 1; @@ -1030,24 +1030,24 @@ static int tree_overlap(BVHNode *node1, BVHNode *node2, int start_axis, int stop float *bv2 = node2->bv; float *bv1_end = bv1 + (stop_axis<<1); - + bv1 += start_axis<<1; bv2 += start_axis<<1; - + // test all axis if min + max overlap for (; bv1 != bv1_end; bv1+=2, bv2+=2) { - if ((*(bv1) > *(bv2 + 1)) || (*(bv2) > *(bv1 + 1))) + if ((*(bv1) > *(bv2 + 1)) || (*(bv2) > *(bv1 + 1))) return 0; } - + return 1; } static void traverse(BVHOverlapData *data, BVHNode *node1, BVHNode *node2) { int j; - + if(tree_overlap(node1, node2, data->start_axis, data->stop_axis)) { // check if node1 is a leaf @@ -1056,17 +1056,17 @@ static void traverse(BVHOverlapData *data, BVHNode *node1, BVHNode *node2) // check if node2 is a leaf if(!node2->totnode) { - + if(node1 == node2) { return; } - + if(data->i >= data->max_overlap) - { + { // try to make alloc'ed memory bigger data->overlap = realloc(data->overlap, sizeof(BVHTreeOverlap)*data->max_overlap*2); - + if(!data->overlap) { printf("Out of Memory in traverse\n"); @@ -1074,7 +1074,7 @@ static void traverse(BVHOverlapData *data, BVHNode *node1, BVHNode *node2) } data->max_overlap *= 2; } - + // both leafs, insert overlap! data->overlap[data->i].indexA = node1->index; data->overlap[data->i].indexB = node2->index; @@ -1092,7 +1092,7 @@ static void traverse(BVHOverlapData *data, BVHNode *node1, BVHNode *node2) } else { - + for(j = 0; j < data->tree2->tree_type; j++) { if(node1->children[j]) @@ -1108,21 +1108,21 @@ BVHTreeOverlap *BLI_bvhtree_overlap(BVHTree *tree1, BVHTree *tree2, int *result) int j, total = 0; BVHTreeOverlap *overlap = NULL, *to = NULL; BVHOverlapData **data; - + // check for compatibility of both trees (can't compare 14-DOP with 18-DOP) if((tree1->axis != tree2->axis) && (tree1->axis == 14 || tree2->axis == 14) && (tree1->axis == 18 || tree2->axis == 18)) return 0; - + // fast check root nodes for collision before doing big splitting + traversal if(!tree_overlap(tree1->nodes[tree1->totleaf], tree2->nodes[tree2->totleaf], MIN2(tree1->start_axis, tree2->start_axis), MIN2(tree1->stop_axis, tree2->stop_axis))) return 0; data = MEM_callocN(sizeof(BVHOverlapData *)* tree1->tree_type, "BVHOverlapData_star"); - + for(j = 0; j < tree1->tree_type; j++) { data[j] = (BVHOverlapData *)MEM_callocN(sizeof(BVHOverlapData), "BVHOverlapData"); - + // init BVHOverlapData data[j]->overlap = (BVHTreeOverlap *)malloc(sizeof(BVHTreeOverlap)*MAX2(tree1->totleaf, tree2->totleaf)); data[j]->tree1 = tree1; @@ -1138,25 +1138,25 @@ BVHTreeOverlap *BLI_bvhtree_overlap(BVHTree *tree1, BVHTree *tree2, int *result) { traverse(data[j], tree1->nodes[tree1->totleaf]->children[j], tree2->nodes[tree2->totleaf]); } - + for(j = 0; j < tree1->tree_type; j++) total += data[j]->i; - + to = overlap = (BVHTreeOverlap *)MEM_callocN(sizeof(BVHTreeOverlap)*total, "BVHTreeOverlap"); - + for(j = 0; j < tree1->tree_type; j++) { memcpy(to, data[j]->overlap, data[j]->i*sizeof(BVHTreeOverlap)); to+=data[j]->i; } - + for(j = 0; j < tree1->tree_type; j++) { free(data[j]->overlap); MEM_freeN(data[j]); } MEM_freeN(data); - + (*result) = total; return overlap; } @@ -1173,7 +1173,7 @@ static float squared_dist(const float *a, const float *b) } //Determines the nearest point of the given node BV. Returns the squared distance to that point. -static float calc_nearest_point(BVHNearestData *data, BVHNode *node, float *nearest) +static float calc_nearest_point(const float *proj, BVHNode *node, float *nearest) { int i; const float *bv = node->bv; @@ -1181,12 +1181,12 @@ static float calc_nearest_point(BVHNearestData *data, BVHNode *node, float *near //nearest on AABB hull for(i=0; i != 3; i++, bv += 2) { - if(bv[0] > data->proj[i]) + if(bv[0] > proj[i]) nearest[i] = bv[0]; - else if(bv[1] < data->proj[i]) + else if(bv[1] < proj[i]) nearest[i] = bv[1]; else - nearest[i] = data->proj[i]; + nearest[i] = proj[i]; } /* @@ -1208,7 +1208,7 @@ static float calc_nearest_point(BVHNearestData *data, BVHNode *node, float *near } } */ - return squared_dist(data->co, nearest); + return squared_dist(proj, nearest); } @@ -1231,7 +1231,7 @@ static void dfs_find_nearest_dfs(BVHNearestData *data, BVHNode *node) else { data->nearest.index = node->index; - data->nearest.dist = calc_nearest_point(data, node, data->nearest.co); + data->nearest.dist = calc_nearest_point(data->proj, node, data->nearest.co); } } else @@ -1240,12 +1240,12 @@ static void dfs_find_nearest_dfs(BVHNearestData *data, BVHNode *node) int i; float nearest[3]; - if(data->proj[ (int)node->main_axis ] <= node->children[0]->bv[(int)node->main_axis*2+1]) + if(data->proj[ node->main_axis ] <= node->children[0]->bv[node->main_axis*2+1]) { for(i=0; i != node->totnode; i++) { - if( calc_nearest_point(data, node->children[i], nearest) >= data->nearest.dist) continue; + if( calc_nearest_point(data->proj, node->children[i], nearest) >= data->nearest.dist) continue; dfs_find_nearest_dfs(data, node->children[i]); } } @@ -1253,7 +1253,7 @@ static void dfs_find_nearest_dfs(BVHNearestData *data, BVHNode *node) { for(i=node->totnode-1; i >= 0 ; i--) { - if( calc_nearest_point(data, node->children[i], nearest) >= data->nearest.dist) continue; + if( calc_nearest_point(data->proj, node->children[i], nearest) >= data->nearest.dist) continue; dfs_find_nearest_dfs(data, node->children[i]); } } @@ -1263,7 +1263,7 @@ static void dfs_find_nearest_dfs(BVHNearestData *data, BVHNode *node) static void dfs_find_nearest_begin(BVHNearestData *data, BVHNode *node) { float nearest[3], sdist; - sdist = calc_nearest_point(data, node, nearest); + sdist = calc_nearest_point(data->proj, node, nearest); if(sdist >= data->nearest.dist) return; dfs_find_nearest_dfs(data, node); } @@ -1301,7 +1301,7 @@ static void bfs_find_nearest(BVHNearestData *data, BVHNode *node) } current.node = node; - current.dist = calc_nearest_point(data, node, nearest); + current.dist = calc_nearest_point(data->proj, node, nearest); while(current.dist < data->nearest.dist) { @@ -1329,7 +1329,7 @@ static void bfs_find_nearest(BVHNearestData *data, BVHNode *node) } heap[heap_size].node = current.node->children[i]; - heap[heap_size].dist = calc_nearest_point(data, current.node->children[i], nearest); + heap[heap_size].dist = calc_nearest_point(data->proj, current.node->children[i], nearest); if(heap[heap_size].dist >= data->nearest.dist) continue; heap_size++; @@ -1339,7 +1339,7 @@ static void bfs_find_nearest(BVHNearestData *data, BVHNode *node) push_heaps++; } } - + if(heap_size == 0) break; current = heap[0]; @@ -1355,6 +1355,7 @@ static void bfs_find_nearest(BVHNearestData *data, BVHNode *node) } #endif + int BLI_bvhtree_find_nearest(BVHTree *tree, const float *co, BVHTreeNearest *nearest, BVHTree_NearestPointCallback callback, void *userdata) { int i; @@ -1435,7 +1436,7 @@ static float ray_nearest_hit(BVHRayCastData *data, float *bv) if(lu > low) low = lu; if(ll < upper) upper = ll; } - + if(low > upper) return FLT_MAX; } } @@ -1530,31 +1531,117 @@ float BLI_bvhtree_bb_raycast(float *bv, float *light_start, float *light_end, fl { BVHRayCastData data; float dist = 0.0; - int i; data.hit.dist = FLT_MAX; - + // get light direction data.ray.direction[0] = light_end[0] - light_start[0]; data.ray.direction[1] = light_end[1] - light_start[1]; data.ray.direction[2] = light_end[2] - light_start[2]; - + data.ray.radius = 0.0; - + data.ray.origin[0] = light_start[0]; data.ray.origin[1] = light_start[1]; data.ray.origin[2] = light_start[2]; - + Normalize(data.ray.direction); VECCOPY(data.ray_dot_axis, data.ray.direction); - + dist = ray_nearest_hit(&data, bv); - + if(dist > 0.0) { VECADDFAC(pos, light_start, data.ray.direction, dist); } return dist; + +} + +/* + * Range Query - as request by broken :P + * + * Allocs and fills an array with the indexs of node that are on the given spherical range (center, radius) + * Returns the size of the array. + */ +typedef struct RangeQueryData +{ + BVHTree *tree; + const float *center; + float radius; //squared radius + + int hits; + + BVHTree_RangeQuery callback; + void *userdata; + + +} RangeQueryData; + + +static void dfs_range_query(RangeQueryData *data, BVHNode *node) +{ + if(node->totnode == 0) + { + + //Calculate the node min-coords (if the node was a point then this is the point coordinates) + float co[3]; + co[0] = node->bv[0]; + co[1] = node->bv[2]; + co[2] = node->bv[4]; + } + else + { + int i; + for(i=0; i != node->totnode; i++) + { + float nearest[3]; + float dist = calc_nearest_point(data->center, node->children[i], nearest); + if(dist < data->radius) + { + //Its a leaf.. call the callback + if(node->children[i]->totnode == 0) + { + data->hits++; + data->callback( data->userdata, node->children[i]->index, dist ); + } + else + dfs_range_query( data, node->children[i] ); + } + } + } } +int BLI_bvhtree_range_query(BVHTree *tree, const float *co, float radius, BVHTree_RangeQuery callback, void *userdata) +{ + BVHNode * root = tree->nodes[tree->totleaf]; + + RangeQueryData data; + data.tree = tree; + data.center = co; + data.radius = radius*radius; + data.hits = 0; + + data.callback = callback; + data.userdata = userdata; + + if(root != NULL) + { + float nearest[3]; + float dist = calc_nearest_point(data.center, root, nearest); + if(dist < data.radius) + { + //Its a leaf.. call the callback + if(root->totnode == 0) + { + data.hits++; + data.callback( data.userdata, root->index, dist ); + } + else + dfs_range_query( &data, root ); + } + } + + return data.hits; +} diff --git a/source/blender/blenlib/intern/BLI_kdtree.c b/source/blender/blenlib/intern/BLI_kdtree.c index 79a46da4c66..1f3a861ba6a 100644 --- a/source/blender/blenlib/intern/BLI_kdtree.c +++ b/source/blender/blenlib/intern/BLI_kdtree.c @@ -374,7 +374,7 @@ int BLI_kdtree_range_search(KDTree *tree, float range, float *co, float *nor, KD KDTreeNode **stack, *defaultstack[100]; KDTreeNearest *foundstack=NULL; float range2 = range*range, dist2; - int i, totstack, cur=0, found=0, totfoundstack=0; + int totstack, cur=0, found=0, totfoundstack=0; if(!tree || !tree->root) return 0; diff --git a/source/blender/blenlib/intern/arithb.c b/source/blender/blenlib/intern/arithb.c index 258537568f3..5b08586ffdb 100644 --- a/source/blender/blenlib/intern/arithb.c +++ b/source/blender/blenlib/intern/arithb.c @@ -2225,6 +2225,13 @@ void VecSubf(float *v, float *v1, float *v2) v[2]= v1[2]- v2[2]; } +void VecMulVecf(float *v, float *v1, float *v2) +{ + v[0] = v1[0] * v2[0]; + v[1] = v1[1] * v2[1]; + v[2] = v1[2] * v2[2]; +} + void VecLerpf(float *target, float *a, float *b, float t) { float s = 1.0f-t; diff --git a/source/blender/blenlib/intern/boxpack2d.c b/source/blender/blenlib/intern/boxpack2d.c index db7bae8a91d..7d5e1eec53e 100644 --- a/source/blender/blenlib/intern/boxpack2d.c +++ b/source/blender/blenlib/intern/boxpack2d.c @@ -16,28 +16,22 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): Campbell barton + * Contributor(s): Campbell Barton * * ***** END GPL LICENSE BLOCK ***** */ -#include <stdlib.h> +#include <stdlib.h> /* for qsort */ -#include "BKE_utildefines.h" #include "MEM_guardedalloc.h" #include "BLI_boxpack2d.h" -/* BoxPacker ported from Python by Campbell Barton +/* BoxPacker for backing 2D rectangles into a square * * The defined Below are for internal use only */ /* free vert flags */ -#define eul 0.0000001 +#define eul 0.0000001f #define BLF 1 #define TRF 2 #define TLF 4 @@ -79,6 +73,9 @@ BOXRIGHT(b1)-eul<=BOXLEFT(b2) ||\ BOXTOP(b1)-eul<=BOXBOTTOM(b2) )) +#define MIN2(x,y) ( (x)<(y) ? (x) : (y) ) +#define MAX2(x,y) ( (x)>(y) ? (x) : (y) ) + /* #define BOXDEBUG(b)\ * printf("\tBox Debug i %i, w:%.3f h:%.3f x:%.3f y:%.3f\n",\ * b->index, b->w, b->h, b->x, b->y) */ @@ -141,11 +138,11 @@ void boxPack2D(boxPack *boxarray, int len, float *tot_width, float *tot_height) int box_index, verts_pack_len, i, j, k, isect; int quad_flags[4]= {BLF,TRF,TLF,BRF}; /* use for looping */ boxPack *box, *box_test; /*current box and another for intersection tests*/ - int *vertex_pack_indicies; /*an array of indicies used for sorting verts*/ + int *vertex_pack_indicies; /*an array of indices used for sorting verts*/ if (!len) { - *tot_width = 0.0; - *tot_height = 0.0; + *tot_width = 0.0f; + *tot_height = 0.0f; return; } @@ -153,8 +150,8 @@ void boxPack2D(boxPack *boxarray, int len, float *tot_width, float *tot_height) qsort(boxarray, len, sizeof(boxPack), box_areasort); /* add verts to the boxes, these are only used internally */ - vert = vertarray = MEM_mallocN( len*4*sizeof(boxVert), "boxPack verts"); - vertex_pack_indicies = MEM_mallocN( len*3*sizeof(int), "boxPack indicies"); + vert = vertarray = MEM_mallocN( len*4*sizeof(boxVert), "boxPack Verts"); + vertex_pack_indicies = MEM_mallocN( len*3*sizeof(int), "boxPack Indices"); for (box=boxarray, box_index=0, i=0; box_index < len; box_index++, box++) { @@ -194,11 +191,11 @@ void boxPack2D(boxPack *boxarray, int len, float *tot_width, float *tot_height) /* Pack the First box! - * then enter the main boxpacking loop */ + * then enter the main box-packing loop */ box = boxarray; /* get the first box */ /* First time, no boxes packed */ - box->v[BL]->free = 0; /* Cant use any if these */ + box->v[BL]->free = 0; /* Can't use any if these */ box->v[BR]->free &= ~(BLF|BRF); box->v[TL]->free &= ~(BLF|TLF); @@ -206,9 +203,9 @@ void boxPack2D(boxPack *boxarray, int len, float *tot_width, float *tot_height) *tot_height = box->h; /* This sets all the vertex locations */ - SET_BOXLEFT(box, 0.0); - SET_BOXBOTTOM(box, 0.0); - box->x = box->y = 0.0; + SET_BOXLEFT(box, 0.0f); + SET_BOXBOTTOM(box, 0.0f); + box->x = box->y = 0.0f; for (i=0; i<3; i++) vertex_pack_indicies[i] = box->v[i+1]->index; @@ -219,7 +216,7 @@ void boxPack2D(boxPack *boxarray, int len, float *tot_width, float *tot_height) /* Main boxpacking loop */ for (box_index=1; box_index < len; box_index++, box++) { - /* Sort the verts, these constants are used in sorting */ + /* These static floatds are used for sorting */ box_width = box->w; box_height = box->h; @@ -234,7 +231,7 @@ void boxPack2D(boxPack *boxarray, int len, float *tot_width, float *tot_height) /* printf("\ttesting vert %i %i %i %f %f\n", i, * vert->free, verts_pack_len, vert->x, vert->y); */ - /* This vert has a free quaderent + /* This vert has a free quadrant * Test if we can place the box here * vert->free & quad_flags[j] - Checks * */ @@ -266,7 +263,7 @@ void boxPack2D(boxPack *boxarray, int len, float *tot_width, float *tot_height) isect = 0; if (/* Constrain boxes to positive X/Y values */ - BOXLEFT(box)<0.0 || BOXBOTTOM(box) < 0.0 || + BOXLEFT(box)<0.0f || BOXBOTTOM(box) < 0.0f || /* check for last intersected */ ( vert->isect_cache[j] && BOXINTERSECT(box, vert->isect_cache[j]) ) @@ -274,13 +271,13 @@ void boxPack2D(boxPack *boxarray, int len, float *tot_width, float *tot_height) /* Here we check that the last intersected * box will intersect with this one using * isect_cache that can store a pointer to a - * box for each quaderent + * box for each quadrant * big speedup */ isect = 1; } else { - /* do a full saech for colliding box - * this is realy slow, some spacialy divided - * datastructure would be better */ + /* do a full search for colliding box + * this is really slow, some spacialy divided + * data-structure would be better */ for (box_test=boxarray; box_test != box; box_test++) { if BOXINTERSECT(box, box_test) { /* Store the last intersecting here as cache @@ -321,7 +318,7 @@ void boxPack2D(boxPack *boxarray, int len, float *tot_width, float *tot_height) } /* Mask free flags for verts that are - * on the bottom or side so we dont get + * on the bottom or side so we don't get * boxes outside the given rectangle ares * * We can do an else/if here because only the first @@ -392,7 +389,7 @@ void boxPack2D(boxPack *boxarray, int len, float *tot_width, float *tot_height) verts_pack_len++; } } - /* The Box verts are only used interially + /* The Box verts are only used internally * Update the box x and y since thats what external * functions will see */ box->x = BOXLEFT(box); @@ -403,8 +400,8 @@ void boxPack2D(boxPack *boxarray, int len, float *tot_width, float *tot_height) } } - /* free all the verts, not realy needed because they shouldebt be - * touched anymore but accessing the pointers woud crash blender */ + /* free all the verts, not really needed because they shouldn't be + * touched anymore but accessing the pointers would crash blender */ for (box_index=0; box_index < len; box_index++) { box = boxarray+box_index; box->v[0] = box->v[1] = box->v[2] = box->v[3] = NULL; diff --git a/source/blender/blenlib/intern/bpath.c b/source/blender/blenlib/intern/bpath.c index 85a95fa6e66..6c89afe7173 100644 --- a/source/blender/blenlib/intern/bpath.c +++ b/source/blender/blenlib/intern/bpath.c @@ -51,7 +51,7 @@ /* for sequence */ //XXX #include "BSE_sequence.h" //XXX define below from BSE_sequence.h - otherwise potentially odd behaviour -#define SEQ_HAS_PATH(seq) (seq->type==SEQ_MOVIE || seq->type==SEQ_HD_SOUND || seq->type==SEQ_RAM_SOUND || seq->type==SEQ_IMAGE) +#define SEQ_HAS_PATH(seq) (seq->type==SEQ_MOVIE || seq->type==SEQ_IMAGE) /* path/file handeling stuff */ #ifndef WIN32 diff --git a/source/blender/blenlib/intern/listbase.c b/source/blender/blenlib/intern/listbase.c index 1064c8ac1bf..3194593374f 100644 --- a/source/blender/blenlib/intern/listbase.c +++ b/source/blender/blenlib/intern/listbase.c @@ -347,11 +347,11 @@ void BLI_duplicatelist(ListBase *list1, ListBase *list2) /* copy from 2 to 1 */ { struct Link *link1, *link2; + /* in this order, to ensure it works if list1 == list2 */ + link2= list2->first; list1->first= list1->last= 0; - link2= list2->first; while(link2) { - link1= MEM_dupallocN(link2); BLI_addtail(list1, link1); diff --git a/source/blender/blenlib/intern/storage.c b/source/blender/blenlib/intern/storage.c index 0a416e624cb..e6e37c58805 100644 --- a/source/blender/blenlib/intern/storage.c +++ b/source/blender/blenlib/intern/storage.c @@ -47,13 +47,13 @@ #include <time.h> #include <sys/stat.h> -#if defined (__sun__) || defined (__sun) || defined (__sgi) +#if defined (__sun__) || defined (__sun) || defined (__sgi) || defined (__NetBSD__) #include <sys/statvfs.h> /* Other modern unix os's should probably use this also */ #elif !defined(__FreeBSD__) && !defined(linux) && (defined(__sparc) || defined(__sparc__)) #include <sys/statfs.h> #endif -#if defined (__FreeBSD__) || defined (__OpenBSD__) || defined (__NetBSD__) +#if defined (__FreeBSD__) || defined (__OpenBSD__) #include <sys/param.h> #include <sys/mount.h> #endif @@ -173,7 +173,7 @@ double BLI_diskfree(char *dir) return (double) (freec*bytesps*sectorspc); #else -#if defined (__sun__) || defined (__sun) || defined (__sgi) +#if defined (__sun__) || defined (__sun) || defined (__sgi) || defined (__NetBSD__) struct statvfs disk; #else struct statfs disk; @@ -195,7 +195,7 @@ double BLI_diskfree(char *dir) if (statfs(name, &disk)) return(-1); #endif -#if defined (__sun__) || defined (__sun) || defined (__sgi) +#if defined (__sun__) || defined (__sun) || defined (__sgi) || defined (__NetBSD__) if (statvfs(name, &disk)) return(-1); #elif !defined(__FreeBSD__) && !defined(linux) && (defined(__sparc) || defined(__sparc__)) /* WARNING - This may not be supported by geeneric unix os's - Campbell */ diff --git a/source/blender/blenlib/intern/voxel.c b/source/blender/blenlib/intern/voxel.c new file mode 100644 index 00000000000..b5b2ae793f9 --- /dev/null +++ b/source/blender/blenlib/intern/voxel.c @@ -0,0 +1,299 @@ +/** + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): Matt Ebb, Raul Fernandez Hernandez (Farsthary). + * + * ***** END GPL LICENSE BLOCK ***** + */ +#include <math.h> + +#include "BLI_voxel.h" + +#include "BKE_utildefines.h" + + +#if defined( _MSC_VER ) && !defined( __cplusplus ) +# define inline __inline +#endif // defined( _MSC_VER ) && !defined( __cplusplus ) + +static inline float D(float *data, int *res, int x, int y, int z) +{ + CLAMP(x, 0, res[0]-1); + CLAMP(y, 0, res[1]-1); + CLAMP(z, 0, res[2]-1); + return data[ V_I(x, y, z, res) ]; +} + +/* *** nearest neighbour *** */ +/* input coordinates must be in bounding box 0.0 - 1.0 */ +float voxel_sample_nearest(float *data, int *res, float *co) +{ + int xi, yi, zi; + + xi = co[0] * res[0]; + yi = co[1] * res[1]; + zi = co[2] * res[2]; + + return D(data, res, xi, yi, zi); +} + + +/* *** trilinear *** */ +/* input coordinates must be in bounding box 0.0 - 1.0 */ + +static inline float lerp(float t, float v1, float v2) { + return (1.f - t) * v1 + t * v2; +} + +/* trilinear interpolation - taken partly from pbrt's implementation: http://www.pbrt.org */ +float voxel_sample_trilinear(float *data, int *res, float *co) +{ + float voxx, voxy, voxz; + int vx, vy, vz; + float dx, dy, dz; + float d00, d10, d01, d11, d0, d1, d_final; + + if (!data) return 0.f; + + voxx = co[0] * res[0] - 0.5f; + voxy = co[1] * res[1] - 0.5f; + voxz = co[2] * res[2] - 0.5f; + + vx = (int)voxx; vy = (int)voxy; vz = (int)voxz; + + dx = voxx - vx; dy = voxy - vy; dz = voxz - vz; + + d00 = lerp(dx, D(data, res, vx, vy, vz), D(data, res, vx+1, vy, vz)); + d10 = lerp(dx, D(data, res, vx, vy+1, vz), D(data, res, vx+1, vy+1, vz)); + d01 = lerp(dx, D(data, res, vx, vy, vz+1), D(data, res, vx+1, vy, vz+1)); + d11 = lerp(dx, D(data, res, vx, vy+1, vz+1), D(data, res, vx+1, vy+1, vz+1)); + d0 = lerp(dy, d00, d10); + d1 = lerp(dy, d01, d11); + d_final = lerp(dz, d0, d1); + + return d_final; +} + +/* *** tricubic *** */ + +int C[64][64] = { +{ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{ 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{-3, 3, 0, 0, 0, 0, 0, 0,-2,-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{ 2,-2, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,-3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,-2,-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2,-2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{-3, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,-2, 0,-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{ 0, 0, 0, 0, 0, 0, 0, 0,-3, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,-2, 0,-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{ 9,-9,-9, 9, 0, 0, 0, 0, 6, 3,-6,-3, 0, 0, 0, 0, 6,-6, 3,-3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 2, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{-6, 6, 6,-6, 0, 0, 0, 0,-3,-3, 3, 3, 0, 0, 0, 0,-4, 4,-2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,-2,-2,-1,-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{ 2, 0,-2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{ 0, 0, 0, 0, 0, 0, 0, 0, 2, 0,-2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{-6, 6, 6,-6, 0, 0, 0, 0,-4,-2, 4, 2, 0, 0, 0, 0,-3, 3,-3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,-2,-1,-2,-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{ 4,-4,-4, 4, 0, 0, 0, 0, 2, 2,-2,-2, 0, 0, 0, 0, 2,-2, 2,-2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,-3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,-2,-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2,-2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0}, +{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,-3, 3, 0, 0, 0, 0, 0, 0,-2,-1, 0, 0, 0, 0, 0, 0}, +{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2,-2, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0}, +{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,-3, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,-2, 0,-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,-3, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,-2, 0,-1, 0, 0, 0, 0, 0}, +{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9,-9,-9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 3,-6,-3, 0, 0, 0, 0, 6,-6, 3,-3, 0, 0, 0, 0, 4, 2, 2, 1, 0, 0, 0, 0}, +{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,-6, 6, 6,-6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,-3,-3, 3, 3, 0, 0, 0, 0,-4, 4,-2, 2, 0, 0, 0, 0,-2,-2,-1,-1, 0, 0, 0, 0}, +{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0,-2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0,-2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0}, +{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,-6, 6, 6,-6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,-4,-2, 4, 2, 0, 0, 0, 0,-3, 3,-3, 3, 0, 0, 0, 0,-2,-1,-2,-1, 0, 0, 0, 0}, +{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4,-4,-4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2,-2,-2, 0, 0, 0, 0, 2,-2, 2,-2, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0}, +{-3, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,-2, 0, 0, 0,-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{ 0, 0, 0, 0, 0, 0, 0, 0,-3, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,-2, 0, 0, 0,-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{ 9,-9, 0, 0,-9, 9, 0, 0, 6, 3, 0, 0,-6,-3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6,-6, 0, 0, 3,-3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 2, 0, 0, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{-6, 6, 0, 0, 6,-6, 0, 0,-3,-3, 0, 0, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,-4, 4, 0, 0,-2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,-2,-2, 0, 0,-1,-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,-3, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,-2, 0, 0, 0,-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,-3, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,-2, 0, 0, 0,-1, 0, 0, 0}, +{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9,-9, 0, 0,-9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 3, 0, 0,-6,-3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6,-6, 0, 0, 3,-3, 0, 0, 4, 2, 0, 0, 2, 1, 0, 0}, +{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,-6, 6, 0, 0, 6,-6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,-3,-3, 0, 0, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,-4, 4, 0, 0,-2, 2, 0, 0,-2,-2, 0, 0,-1,-1, 0, 0}, +{ 9, 0,-9, 0,-9, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 3, 0,-6, 0,-3, 0, 6, 0,-6, 0, 3, 0,-3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 2, 0, 2, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{ 0, 0, 0, 0, 0, 0, 0, 0, 9, 0,-9, 0,-9, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 3, 0,-6, 0,-3, 0, 6, 0,-6, 0, 3, 0,-3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 2, 0, 2, 0, 1, 0}, +{-27,27,27,-27,27,-27,-27,27,-18,-9,18, 9,18, 9,-18,-9,-18,18,-9, 9,18,-18, 9,-9,-18,18,18,-18,-9, 9, 9,-9,-12,-6,-6,-3,12, 6, 6, 3,-12,-6,12, 6,-6,-3, 6, 3,-12,12,-6, 6,-6, 6,-3, 3,-8,-4,-4,-2,-4,-2,-2,-1}, +{18,-18,-18,18,-18,18,18,-18, 9, 9,-9,-9,-9,-9, 9, 9,12,-12, 6,-6,-12,12,-6, 6,12,-12,-12,12, 6,-6,-6, 6, 6, 6, 3, 3,-6,-6,-3,-3, 6, 6,-6,-6, 3, 3,-3,-3, 8,-8, 4,-4, 4,-4, 2,-2, 4, 4, 2, 2, 2, 2, 1, 1}, +{-6, 0, 6, 0, 6, 0,-6, 0, 0, 0, 0, 0, 0, 0, 0, 0,-3, 0,-3, 0, 3, 0, 3, 0,-4, 0, 4, 0,-2, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,-2, 0,-2, 0,-1, 0,-1, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{ 0, 0, 0, 0, 0, 0, 0, 0,-6, 0, 6, 0, 6, 0,-6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,-3, 0,-3, 0, 3, 0, 3, 0,-4, 0, 4, 0,-2, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0,-2, 0,-2, 0,-1, 0,-1, 0}, +{18,-18,-18,18,-18,18,18,-18,12, 6,-12,-6,-12,-6,12, 6, 9,-9, 9,-9,-9, 9,-9, 9,12,-12,-12,12, 6,-6,-6, 6, 6, 3, 6, 3,-6,-3,-6,-3, 8, 4,-8,-4, 4, 2,-4,-2, 6,-6, 6,-6, 3,-3, 3,-3, 4, 2, 4, 2, 2, 1, 2, 1}, +{-12,12,12,-12,12,-12,-12,12,-6,-6, 6, 6, 6, 6,-6,-6,-6, 6,-6, 6, 6,-6, 6,-6,-8, 8, 8,-8,-4, 4, 4,-4,-3,-3,-3,-3, 3, 3, 3, 3,-4,-4, 4, 4,-2,-2, 2, 2,-4, 4,-4, 4,-2, 2,-2, 2,-2,-2,-2,-2,-1,-1,-1,-1}, +{ 2, 0, 0, 0,-2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{ 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0,-2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{-6, 6, 0, 0, 6,-6, 0, 0,-4,-2, 0, 0, 4, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,-3, 3, 0, 0,-3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,-2,-1, 0, 0,-2,-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{ 4,-4, 0, 0,-4, 4, 0, 0, 2, 2, 0, 0,-2,-2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2,-2, 0, 0, 2,-2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0,-2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0,-2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0}, +{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,-6, 6, 0, 0, 6,-6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,-4,-2, 0, 0, 4, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,-3, 3, 0, 0,-3, 3, 0, 0,-2,-1, 0, 0,-2,-1, 0, 0}, +{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4,-4, 0, 0,-4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0,-2,-2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2,-2, 0, 0, 2,-2, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0}, +{-6, 0, 6, 0, 6, 0,-6, 0, 0, 0, 0, 0, 0, 0, 0, 0,-4, 0,-2, 0, 4, 0, 2, 0,-3, 0, 3, 0,-3, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,-2, 0,-1, 0,-2, 0,-1, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{ 0, 0, 0, 0, 0, 0, 0, 0,-6, 0, 6, 0, 6, 0,-6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,-4, 0,-2, 0, 4, 0, 2, 0,-3, 0, 3, 0,-3, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0,-2, 0,-1, 0,-2, 0,-1, 0}, +{18,-18,-18,18,-18,18,18,-18,12, 6,-12,-6,-12,-6,12, 6,12,-12, 6,-6,-12,12,-6, 6, 9,-9,-9, 9, 9,-9,-9, 9, 8, 4, 4, 2,-8,-4,-4,-2, 6, 3,-6,-3, 6, 3,-6,-3, 6,-6, 3,-3, 6,-6, 3,-3, 4, 2, 2, 1, 4, 2, 2, 1}, +{-12,12,12,-12,12,-12,-12,12,-6,-6, 6, 6, 6, 6,-6,-6,-8, 8,-4, 4, 8,-8, 4,-4,-6, 6, 6,-6,-6, 6, 6,-6,-4,-4,-2,-2, 4, 4, 2, 2,-3,-3, 3, 3,-3,-3, 3, 3,-4, 4,-2, 2,-4, 4,-2, 2,-2,-2,-1,-1,-2,-2,-1,-1}, +{ 4, 0,-4, 0,-4, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 2, 0,-2, 0,-2, 0, 2, 0,-2, 0, 2, 0,-2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{ 0, 0, 0, 0, 0, 0, 0, 0, 4, 0,-4, 0,-4, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 2, 0,-2, 0,-2, 0, 2, 0,-2, 0, 2, 0,-2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0}, +{-12,12,12,-12,12,-12,-12,12,-8,-4, 8, 4, 8, 4,-8,-4,-6, 6,-6, 6, 6,-6, 6,-6,-6, 6, 6,-6,-6, 6, 6,-6,-4,-2,-4,-2, 4, 2, 4, 2,-4,-2, 4, 2,-4,-2, 4, 2,-3, 3,-3, 3,-3, 3,-3, 3,-2,-1,-2,-1,-2,-1,-2,-1}, +{ 8,-8,-8, 8,-8, 8, 8,-8, 4, 4,-4,-4,-4,-4, 4, 4, 4,-4, 4,-4,-4, 4,-4, 4, 4,-4,-4, 4, 4,-4,-4, 4, 2, 2, 2, 2,-2,-2,-2,-2, 2, 2,-2,-2, 2, 2,-2,-2, 2,-2, 2,-2, 2,-2, 2,-2, 1, 1, 1, 1, 1, 1, 1, 1}}; + +static int ijk2n(int i, int j, int k) { + return(i+4*j+16*k); +} + +static void tricubic_get_coeff_stacked(float a[64], float x[64]) { + int i,j; + for (i=0;i<64;i++) { + a[i]=(float)(0.0); + for (j=0;j<64;j++) { + a[i]+=C[i][j]*x[j]; + } + } +} + + + + +static void tricubic_get_coeff(float a[64], float f[8], float dfdx[8], float dfdy[8], float dfdz[8], float d2fdxdy[8], float d2fdxdz[8], float d2fdydz[8], float d3fdxdydz[8]) { + int i; + float x[64]; + for (i=0;i<8;i++) { + x[0+i]=f[i]; + x[8+i]=dfdx[i]; + x[16+i]=dfdy[i]; + x[24+i]=dfdz[i]; + x[32+i]=d2fdxdy[i]; + x[40+i]=d2fdxdz[i]; + x[48+i]=d2fdydz[i]; + x[56+i]=d3fdxdydz[i]; + } + tricubic_get_coeff_stacked(a,x); +} + +static float tricubic_eval(float a[64], float x, float y, float z) { + int i,j,k; + float ret=(float)(0.0); + + for (i=0;i<4;i++) { + for (j=0;j<4;j++) { + for (k=0;k<4;k++) { + ret+=a[ijk2n(i,j,k)]*pow(x,i)*pow(y,j)*pow(z,k); + } + } + } + return(ret); +} + +/* tricubic interpolation + * from 'libtricubic': http://www.lekien.com/~francois/software/tricubic/ + * input coordinates must be in bounding box 0.0 - 1.0 */ +float voxel_sample_tricubic(float *data, int *res, float *co) +{ + float xx, yy, zz; + int xi,yi,zi; + int *n = res; + float dx,dy,dz; + float a[64]; + + xx = co[0] * res[0] - 0.5f; + yy = co[1] * res[1] - 0.5f; + zz = co[2] * res[2] - 0.5f; + + xi = (int)xx; yi = (int)yy; zi = (int)zz; + + { + float fval[8]={data[V_I(xi,yi,zi,n)],data[V_I(xi+1,yi,zi,n)],data[V_I(xi,yi+1,zi,n)],data[V_I(xi+1,yi+1,zi,n)],data[V_I(xi,yi,zi+1,n)],data[V_I(xi+1,yi,zi+1,n)],data[V_I(xi,yi+1,zi+1,n)],data[V_I(xi+1,yi+1,zi+1,n)]}; + + float dfdxval[8]={0.5f*(data[V_I(xi+1,yi,zi,n)]-data[V_I(xi-1,yi,zi,n)]),0.5f*(data[V_I(xi+2,yi,zi,n)]-data[V_I(xi,yi,zi,n)]), + 0.5f*(data[V_I(xi+1,yi+1,zi,n)]-data[V_I(xi-1,yi+1,zi,n)]),0.5f*(data[V_I(xi+2,yi+1,zi,n)]-data[V_I(xi,yi+1,zi,n)]), + 0.5f*(data[V_I(xi+1,yi,zi+1,n)]-data[V_I(xi-1,yi,zi+1,n)]),0.5f*(data[V_I(xi+2,yi,zi+1,n)]-data[V_I(xi,yi,zi+1,n)]), + 0.5f*(data[V_I(xi+1,yi+1,zi+1,n)]-data[V_I(xi-1,yi+1,zi+1,n)]), + 0.5f*(data[V_I(xi+2,yi+1,zi+1,n)]-data[V_I(xi,yi+1,zi+1,n)])}; + + float dfdyval[8]={0.5f*(data[V_I(xi,yi+1,zi,n)]-data[V_I(xi,yi-1,zi,n)]),0.5f*(data[V_I(xi+1,yi+1,zi,n)]-data[V_I(xi+1,yi-1,zi,n)]), + 0.5f*(data[V_I(xi,yi+2,zi,n)]-data[V_I(xi,yi,zi,n)]),0.5f*(data[V_I(xi+1,yi+2,zi,n)]-data[V_I(xi+1,yi,zi,n)]), + 0.5f*(data[V_I(xi,yi+1,zi+1,n)]-data[V_I(xi,yi-1,zi+1,n)]),0.5f*(data[V_I(xi+1,yi+1,zi+1,n)]-data[V_I(xi+1,yi-1,zi+1,n)]), + 0.5f*(data[V_I(xi,yi+2,zi+1,n)]-data[V_I(xi,yi,zi+1,n)]), + 0.5f*(data[V_I(xi+1,yi+2,zi+1,n)]-data[V_I(xi+1,yi,zi+1,n)])}; + + float dfdzval[8]={0.5f*(data[V_I(xi,yi,zi+1,n)]-data[V_I(xi,yi,zi-1,n)]),0.5f*(data[V_I(xi+1,yi,zi+1,n)]-data[V_I(xi+1,yi,zi-1,n)]), + 0.5f*(data[V_I(xi,yi+1,zi+1,n)]-data[V_I(xi,yi+1,zi-1,n)]),0.5f*(data[V_I(xi+1,yi+1,zi+1,n)]-data[V_I(xi+1,yi+1,zi-1,n)]), + 0.5f*(data[V_I(xi,yi,zi+2,n)]-data[V_I(xi,yi,zi,n)]),0.5f*(data[V_I(xi+1,yi,zi+2,n)]-data[V_I(xi+1,yi,zi,n)]), + 0.5f*(data[V_I(xi,yi+1,zi+2,n)]-data[V_I(xi,yi+1,zi,n)]), + 0.5f*(data[V_I(xi+1,yi+1,zi+2,n)]-data[V_I(xi+1,yi+1,zi,n)])}; + + float d2fdxdyval[8]={0.25*(data[V_I(xi+1,yi+1,zi,n)]-data[V_I(xi-1,yi+1,zi,n)]-data[V_I(xi+1,yi-1,zi,n)]+data[V_I(xi-1,yi-1,zi,n)]), + 0.25*(data[V_I(xi+2,yi+1,zi,n)]-data[V_I(xi,yi+1,zi,n)]-data[V_I(xi+2,yi-1,zi,n)]+data[V_I(xi,yi-1,zi,n)]), + 0.25*(data[V_I(xi+1,yi+2,zi,n)]-data[V_I(xi-1,yi+2,zi,n)]-data[V_I(xi+1,yi,zi,n)]+data[V_I(xi-1,yi,zi,n)]), + 0.25*(data[V_I(xi+2,yi+2,zi,n)]-data[V_I(xi,yi+2,zi,n)]-data[V_I(xi+2,yi,zi,n)]+data[V_I(xi,yi,zi,n)]), + 0.25*(data[V_I(xi+1,yi+1,zi+1,n)]-data[V_I(xi-1,yi+1,zi+1,n)]-data[V_I(xi+1,yi-1,zi+1,n)]+data[V_I(xi-1,yi-1,zi+1,n)]), + 0.25*(data[V_I(xi+2,yi+1,zi+1,n)]-data[V_I(xi,yi+1,zi+1,n)]-data[V_I(xi+2,yi-1,zi+1,n)]+data[V_I(xi,yi-1,zi+1,n)]), + 0.25*(data[V_I(xi+1,yi+2,zi+1,n)]-data[V_I(xi-1,yi+2,zi+1,n)]-data[V_I(xi+1,yi,zi+1,n)]+data[V_I(xi-1,yi,zi+1,n)]), + 0.25*(data[V_I(xi+2,yi+2,zi+1,n)]-data[V_I(xi,yi+2,zi+1,n)]-data[V_I(xi+2,yi,zi+1,n)]+data[V_I(xi,yi,zi+1,n)])}; + + float d2fdxdzval[8]={0.25f*(data[V_I(xi+1,yi,zi+1,n)]-data[V_I(xi-1,yi,zi+1,n)]-data[V_I(xi+1,yi,zi-1,n)]+data[V_I(xi-1,yi,zi-1,n)]), + 0.25f*(data[V_I(xi+2,yi,zi+1,n)]-data[V_I(xi,yi,zi+1,n)]-data[V_I(xi+2,yi,zi-1,n)]+data[V_I(xi,yi,zi-1,n)]), + 0.25f*(data[V_I(xi+1,yi+1,zi+1,n)]-data[V_I(xi-1,yi+1,zi+1,n)]-data[V_I(xi+1,yi+1,zi-1,n)]+data[V_I(xi-1,yi+1,zi-1,n)]), + 0.25f*(data[V_I(xi+2,yi+1,zi+1,n)]-data[V_I(xi,yi+1,zi+1,n)]-data[V_I(xi+2,yi+1,zi-1,n)]+data[V_I(xi,yi+1,zi-1,n)]), + 0.25f*(data[V_I(xi+1,yi,zi+2,n)]-data[V_I(xi-1,yi,zi+2,n)]-data[V_I(xi+1,yi,zi,n)]+data[V_I(xi-1,yi,zi,n)]), + 0.25f*(data[V_I(xi+2,yi,zi+2,n)]-data[V_I(xi,yi,zi+2,n)]-data[V_I(xi+2,yi,zi,n)]+data[V_I(xi,yi,zi,n)]), + 0.25f*(data[V_I(xi+1,yi+1,zi+2,n)]-data[V_I(xi-1,yi+1,zi+2,n)]-data[V_I(xi+1,yi+1,zi,n)]+data[V_I(xi-1,yi+1,zi,n)]), + 0.25f*(data[V_I(xi+2,yi+1,zi+2,n)]-data[V_I(xi,yi+1,zi+2,n)]-data[V_I(xi+2,yi+1,zi,n)]+data[V_I(xi,yi+1,zi,n)])}; + + + float d2fdydzval[8]={0.25f*(data[V_I(xi,yi+1,zi+1,n)]-data[V_I(xi,yi-1,zi+1,n)]-data[V_I(xi,yi+1,zi-1,n)]+data[V_I(xi,yi-1,zi-1,n)]), + 0.25f*(data[V_I(xi+1,yi+1,zi+1,n)]-data[V_I(xi+1,yi-1,zi+1,n)]-data[V_I(xi+1,yi+1,zi-1,n)]+data[V_I(xi+1,yi-1,zi-1,n)]), + 0.25f*(data[V_I(xi,yi+2,zi+1,n)]-data[V_I(xi,yi,zi+1,n)]-data[V_I(xi,yi+2,zi-1,n)]+data[V_I(xi,yi,zi-1,n)]), + 0.25f*(data[V_I(xi+1,yi+2,zi+1,n)]-data[V_I(xi+1,yi,zi+1,n)]-data[V_I(xi+1,yi+2,zi-1,n)]+data[V_I(xi+1,yi,zi-1,n)]), + 0.25f*(data[V_I(xi,yi+1,zi+2,n)]-data[V_I(xi,yi-1,zi+2,n)]-data[V_I(xi,yi+1,zi,n)]+data[V_I(xi,yi-1,zi,n)]), + 0.25f*(data[V_I(xi+1,yi+1,zi+2,n)]-data[V_I(xi+1,yi-1,zi+2,n)]-data[V_I(xi+1,yi+1,zi,n)]+data[V_I(xi+1,yi-1,zi,n)]), + 0.25f*(data[V_I(xi,yi+2,zi+2,n)]-data[V_I(xi,yi,zi+2,n)]-data[V_I(xi,yi+2,zi,n)]+data[V_I(xi,yi,zi,n)]), + 0.25f*(data[V_I(xi+1,yi+2,zi+2,n)]-data[V_I(xi+1,yi,zi+2,n)]-data[V_I(xi+1,yi+2,zi,n)]+data[V_I(xi+1,yi,zi,n)])}; + + + float d3fdxdydzval[8]={0.125f*(data[V_I(xi+1,yi+1,zi+1,n)]-data[V_I(xi-1,yi+1,zi+1,n)]-data[V_I(xi+1,yi-1,zi+1,n)]+data[V_I(xi-1,yi-1,zi+1,n)]-data[V_I(xi+1,yi+1,zi-1,n)]+data[V_I(xi-1,yi+1,zi-1,n)]+data[V_I(xi+1,yi-1,zi-1,n)]-data[V_I(xi-1,yi-1,zi-1,n)]), + 0.125f*(data[V_I(xi+2,yi+1,zi+1,n)]-data[V_I(xi,yi+1,zi+1,n)]-data[V_I(xi+2,yi-1,zi+1,n)]+data[V_I(xi,yi-1,zi+1,n)]-data[V_I(xi+2,yi+1,zi-1,n)]+data[V_I(xi,yi+1,zi-1,n)]+data[V_I(xi+2,yi-1,zi-1,n)]-data[V_I(xi,yi-1,zi-1,n)]), + 0.125f*(data[V_I(xi+1,yi+2,zi+1,n)]-data[V_I(xi-1,yi+2,zi+1,n)]-data[V_I(xi+1,yi,zi+1,n)]+data[V_I(xi-1,yi,zi+1,n)]-data[V_I(xi+1,yi+2,zi-1,n)]+data[V_I(xi-1,yi+2,zi-1,n)]+data[V_I(xi+1,yi,zi-1,n)]-data[V_I(xi-1,yi,zi-1,n)]), + 0.125f*(data[V_I(xi+2,yi+2,zi+1,n)]-data[V_I(xi,yi+2,zi+1,n)]-data[V_I(xi+2,yi,zi+1,n)]+data[V_I(xi,yi,zi+1,n)]-data[V_I(xi+2,yi+2,zi-1,n)]+data[V_I(xi,yi+2,zi-1,n)]+data[V_I(xi+2,yi,zi-1,n)]-data[V_I(xi,yi,zi-1,n)]), + 0.125f*(data[V_I(xi+1,yi+1,zi+2,n)]-data[V_I(xi-1,yi+1,zi+2,n)]-data[V_I(xi+1,yi-1,zi+2,n)]+data[V_I(xi-1,yi-1,zi+2,n)]-data[V_I(xi+1,yi+1,zi,n)]+data[V_I(xi-1,yi+1,zi,n)]+data[V_I(xi+1,yi-1,zi,n)]-data[V_I(xi-1,yi-1,zi,n)]), + 0.125f*(data[V_I(xi+2,yi+1,zi+2,n)]-data[V_I(xi,yi+1,zi+2,n)]-data[V_I(xi+2,yi-1,zi+2,n)]+data[V_I(xi,yi-1,zi+2,n)]-data[V_I(xi+2,yi+1,zi,n)]+data[V_I(xi,yi+1,zi,n)]+data[V_I(xi+2,yi-1,zi,n)]-data[V_I(xi,yi-1,zi,n)]), + 0.125f*(data[V_I(xi+1,yi+2,zi+2,n)]-data[V_I(xi-1,yi+2,zi+2,n)]-data[V_I(xi+1,yi,zi+2,n)]+data[V_I(xi-1,yi,zi+2,n)]-data[V_I(xi+1,yi+2,zi,n)]+data[V_I(xi-1,yi+2,zi,n)]+data[V_I(xi+1,yi,zi,n)]-data[V_I(xi-1,yi,zi,n)]), + 0.125f*(data[V_I(xi+2,yi+2,zi+2,n)]-data[V_I(xi,yi+2,zi+2,n)]-data[V_I(xi+2,yi,zi+2,n)]+data[V_I(xi,yi,zi+2,n)]-data[V_I(xi+2,yi+2,zi,n)]+data[V_I(xi,yi+2,zi,n)]+data[V_I(xi+2,yi,zi,n)]-data[V_I(xi,yi,zi,n)])}; + + + tricubic_get_coeff(a,fval,dfdxval,dfdyval,dfdzval,d2fdxdyval,d2fdxdzval,d2fdydzval,d3fdxdydzval); + } + + dx = xx-xi; + dy = yy-yi; + dz = zz-zi; + + return tricubic_eval(a,dx,dy,dz); + +} + diff --git a/source/blender/blenloader/BLO_sys_types.h b/source/blender/blenloader/BLO_sys_types.h index 49155260b31..4032f778f4b 100644 --- a/source/blender/blenloader/BLO_sys_types.h +++ b/source/blender/blenloader/BLO_sys_types.h @@ -78,7 +78,7 @@ typedef unsigned long uintptr_t; #define _UINTPTR_T_DEFINED #endif -#elif defined(__linux__) +#elif defined(__linux__) || defined(__NetBSD__) /* Linux-i386, Linux-Alpha, Linux-ppc */ #include <stdint.h> diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 9189d5140d7..1be2f074813 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -149,6 +149,8 @@ #include "BKE_utildefines.h" // SWITCH_INT DATA ENDB DNA1 O_BINARY GLOB USER TEST REND #include "BKE_idprop.h" +#include "BKE_sound.h" + //XXX #include "BIF_butspace.h" // badlevel, for do_versions, patching event codes //XXX #include "BIF_filelist.h" // badlevel too, where to move this? - elubie //XXX #include "BIF_previewrender.h" // bedlelvel, for struct RenderInfo @@ -1364,7 +1366,7 @@ void IDP_LibLinkProperty(IDProperty *prop, int switch_endian, FileData *fd); static void IDP_DirectLinkIDPArray(IDProperty *prop, int switch_endian, FileData *fd) { - IDProperty **array; + IDProperty *array; int i; /*since we didn't save the extra buffer, set totallen to len.*/ @@ -1372,11 +1374,10 @@ static void IDP_DirectLinkIDPArray(IDProperty *prop, int switch_endian, FileData prop->data.pointer = newdataadr(fd, prop->data.pointer); if (switch_endian) { - test_pointer_array(fd, prop->data.pointer); - array= (IDProperty**) prop->data.pointer; + array= (IDProperty*) prop->data.pointer; for(i=0; i<prop->len; i++) - IDP_DirectLinkProperty(array[i], switch_endian, fd); + IDP_DirectLinkProperty(&array[i], switch_endian, fd); } } @@ -2818,6 +2819,11 @@ static void lib_link_texture(FileData *fd, Main *main) tex->ima= newlibadr_us(fd, tex->id.lib, tex->ima); tex->ipo= newlibadr_us(fd, tex->id.lib, tex->ipo); if(tex->env) tex->env->object= newlibadr(fd, tex->id.lib, tex->env->object); + if(tex->pd) { + tex->pd->object= newlibadr(fd, tex->id.lib, tex->pd->object); + tex->pd->psys= newlibadr(fd, tex->id.lib, tex->pd->psys); + } + if(tex->vd) tex->vd->object= newlibadr(fd, tex->id.lib, tex->vd->object); if(tex->nodetree) lib_link_ntree(fd, &tex->id, tex->nodetree); @@ -2850,6 +2856,16 @@ static void direct_link_texture(FileData *fd, Tex *tex) memset(tex->env->cube, 0, 6*sizeof(void *)); tex->env->ok= 0; } + tex->pd= newdataadr(fd, tex->pd); + if(tex->pd) { + tex->pd->point_tree = NULL; + tex->pd->coba= newdataadr(fd, tex->pd->coba); + } + + tex->vd= newdataadr(fd, tex->vd); + if(tex->vd) { + tex->vd->dataset = NULL; + } tex->nodetree= newdataadr(fd, tex->nodetree); if(tex->nodetree) @@ -2927,13 +2943,21 @@ static void direct_link_pointcache(FileData *fd, PointCache *cache) { if((cache->flag & PTCACHE_DISK_CACHE)==0) { PTCacheMem *pm; + int i; link_list(fd, &cache->mem_cache); pm = cache->mem_cache.first; - for(; pm; pm=pm->next) - pm->data = newdataadr(fd, pm->data); + for(; pm; pm=pm->next) { + if(pm->index_array) + pm->index_array = newdataadr(fd, pm->index_array); + + for(i=0; i<BPHYS_TOT_DATA; i++) { + if(pm->data[i] && pm->data_types & (1<<i)) + pm->data[i] = newdataadr(fd, pm->data[i]); + } + } } else cache->mem_cache.first = cache->mem_cache.last = NULL; @@ -2942,6 +2966,26 @@ static void direct_link_pointcache(FileData *fd, PointCache *cache) cache->simframe= 0; } +static void direct_link_pointcache_list(FileData *fd, ListBase *ptcaches, PointCache **ocache) +{ + PointCache *cache; + + if(ptcaches->first) { + link_list(fd, ptcaches); + for(cache=ptcaches->first; cache; cache=cache->next) + direct_link_pointcache(fd, cache); + + *ocache = newdataadr(fd, *ocache); + } + else if(*ocache) { + /* old "single" caches need to be linked too */ + *ocache = newdataadr(fd, *ocache); + direct_link_pointcache(fd, *ocache); + + ptcaches->first = ptcaches->last = *ocache; + } +} + static void lib_link_particlesettings(FileData *fd, Main *main) { ParticleSettings *part; @@ -3064,7 +3108,7 @@ static void direct_link_particlesystems(FileData *fd, ListBase *particles) psys->flag &= ~PSYS_KEYED; } - if(psys->particles->boid) { + if(psys->particles && psys->particles->boid) { pa = psys->particles; pa->boid = newdataadr(fd, pa->boid); for(a=1,pa++; a<psys->totpart; a++, pa++) @@ -3087,9 +3131,7 @@ static void direct_link_particlesystems(FileData *fd, ListBase *particles) sb->bspring= NULL; sb->scratch= NULL; - sb->pointcache= newdataadr(fd, sb->pointcache); - if(sb->pointcache) - direct_link_pointcache(fd, sb->pointcache); + direct_link_pointcache_list(fd, &sb->ptcaches, &sb->pointcache); } link_list(fd, &psys->targets); @@ -3102,9 +3144,7 @@ static void direct_link_particlesystems(FileData *fd, ListBase *particles) psys->childcachebufs.first = psys->childcachebufs.last = 0; psys->reactevents.first = psys->reactevents.last = 0; - psys->pointcache= newdataadr(fd, psys->pointcache); - if(psys->pointcache) - direct_link_pointcache(fd, psys->pointcache); + direct_link_pointcache_list(fd, &psys->ptcaches, &psys->pointcache); psys->tree = NULL; } @@ -3555,7 +3595,7 @@ static void lib_link_object(FileData *fd, Main *main) if(ob->pose) { free_pose(ob->pose); ob->pose= NULL; - ob->flag &= ~OB_POSEMODE; + ob->mode &= ~OB_MODE_POSE; } } for(a=0; a<ob->totcol; a++) ob->mat[a]= newlibadr_us(fd, ob->id.lib, ob->mat[a]); @@ -3616,9 +3656,6 @@ static void lib_link_object(FileData *fd, Main *main) bSoundActuator *sa= act->data; sa->sound= newlibadr_us(fd, ob->id.lib, sa->sound); } - else if(act->type==ACT_CD) { - /* bCDActuator *cda= act->data; */ - } else if(act->type==ACT_GAME) { /* bGameActuator *ga= act->data; */ } @@ -3780,10 +3817,8 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb) clmd->sim_parms= newdataadr(fd, clmd->sim_parms); clmd->coll_parms= newdataadr(fd, clmd->coll_parms); - clmd->point_cache= newdataadr(fd, clmd->point_cache); - if(clmd->point_cache) - direct_link_pointcache(fd, clmd->point_cache); + direct_link_pointcache_list(fd, &clmd->ptcaches, &clmd->point_cache); if(clmd->sim_parms) { if(clmd->sim_parms->presets > 10) @@ -3800,8 +3835,6 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb) else if (md->type==eModifierType_Smoke) { SmokeModifierData *smd = (SmokeModifierData*) md; - smd->point_cache = NULL; - if(smd->type==MOD_SMOKE_TYPE_DOMAIN) { smd->flow = NULL; @@ -3810,13 +3843,11 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb) smd->domain->smd = smd; smd->domain->fluid = NULL; - smd->domain->tvox = NULL; - smd->domain->tray = NULL; - smd->domain->tvoxbig = NULL; - smd->domain->traybig = NULL; - smd->domain->bind = NULL; - smd->domain->max_textures = 0; - smd->domain->viewsettings = 0; // reset view for new frame + smd->domain->view3d = NULL; + smd->domain->tex = NULL; + + direct_link_pointcache_list(fd, &(smd->domain->ptcaches[0]), &(smd->domain->point_cache[0])); + direct_link_pointcache_list(fd, &(smd->domain->ptcaches[1]), &(smd->domain->point_cache[1])); } else if(smd->type==MOD_SMOKE_TYPE_FLOW) { @@ -4028,9 +4059,7 @@ static void direct_link_object(FileData *fd, Object *ob) } } - sb->pointcache= newdataadr(fd, sb->pointcache); - if(sb->pointcache) - direct_link_pointcache(fd, sb->pointcache); + direct_link_pointcache_list(fd, &sb->ptcaches, &sb->pointcache); } ob->bsoft= newdataadr(fd, ob->bsoft); ob->fluidsimSettings= newdataadr(fd, ob->fluidsimSettings); /* NT */ @@ -4116,6 +4145,10 @@ static void direct_link_object(FileData *fd, Object *ob) ob->derivedDeform= NULL; ob->derivedFinal= NULL; ob->gpulamp.first= ob->gpulamp.last= NULL; + link_list(fd, &ob->pc_ids); + + if(ob->sculpt) + ob->sculpt= MEM_callocN(sizeof(SculptSession), "reload sculpt session"); } /* ************ READ SCENE ***************** */ @@ -4130,6 +4163,14 @@ static void composite_patch(bNodeTree *ntree, Scene *scene) node->id= &scene->id; } +static void link_paint(FileData *fd, Scene *sce, Paint *p) +{ + if(p && p->brushes) { + int i; + for(i = 0; i < p->brush_count; ++i) + p->brushes[i]= newlibadr_us(fd, sce->id.lib, p->brushes[i]); + } +} static void lib_link_scene(FileData *fd, Main *main) { @@ -4153,18 +4194,11 @@ static void lib_link_scene(FileData *fd, Main *main) sce->set= newlibadr(fd, sce->id.lib, sce->set); sce->ima= newlibadr_us(fd, sce->id.lib, sce->ima); - sce->toolsettings->imapaint.brush= - newlibadr_us(fd, sce->id.lib, sce->toolsettings->imapaint.brush); - if(sce->toolsettings->sculpt) - sce->toolsettings->sculpt->brush= - newlibadr_us(fd, sce->id.lib, sce->toolsettings->sculpt->brush); - if(sce->toolsettings->vpaint) - sce->toolsettings->vpaint->brush= - newlibadr_us(fd, sce->id.lib, sce->toolsettings->vpaint->brush); - if(sce->toolsettings->wpaint) - sce->toolsettings->wpaint->brush= - newlibadr_us(fd, sce->id.lib, sce->toolsettings->wpaint->brush); - + link_paint(fd, sce, &sce->toolsettings->sculpt->paint); + link_paint(fd, sce, &sce->toolsettings->vpaint->paint); + link_paint(fd, sce, &sce->toolsettings->wpaint->paint); + link_paint(fd, sce, &sce->toolsettings->imapaint.paint); + sce->toolsettings->skgen_template = newlibadr(fd, sce->id.lib, sce->toolsettings->skgen_template); for(base= sce->base.first; base; base= next) { @@ -4193,14 +4227,16 @@ static void lib_link_scene(FileData *fd, Main *main) if(seq->ipo) seq->ipo= newlibadr_us(fd, sce->id.lib, seq->ipo); if(seq->scene) seq->scene= newlibadr(fd, sce->id.lib, seq->scene); if(seq->sound) { - seq->sound= newlibadr(fd, sce->id.lib, seq->sound); + if(seq->type == SEQ_HD_SOUND) + seq->type = SEQ_SOUND; + else + seq->sound= newlibadr(fd, sce->id.lib, seq->sound); if (seq->sound) { seq->sound->id.us++; - seq->sound->flags |= SOUND_FLAGS_SEQUENCE; + seq->sound_handle= sound_new_handle(sce, seq->sound, seq->startdisp, seq->enddisp, seq->startofs); } } seq->anim= 0; - seq->hdaudio = 0; } SEQ_END @@ -4235,6 +4271,13 @@ static void link_recurs_seq(FileData *fd, ListBase *lb) link_recurs_seq(fd, &seq->seqbase); } +static void direct_link_paint(FileData *fd, Paint **paint) +{ + (*paint)= newdataadr(fd, (*paint)); + if(*paint) + (*paint)->brushes= newdataadr(fd, (*paint)->brushes); +} + static void direct_link_scene(FileData *fd, Scene *sce) { Editing *ed; @@ -4244,7 +4287,10 @@ static void direct_link_scene(FileData *fd, Scene *sce) sce->theDag = NULL; sce->dagisvalid = 0; sce->obedit= NULL; - + sce->stats= 0; + + memset(&sce->sound_handles, 0, sizeof(sce->sound_handles)); + /* set users to one by default, not in lib-link, this will increase it for compo nodes */ sce->id.us= 1; @@ -4260,14 +4306,14 @@ static void direct_link_scene(FileData *fd, Scene *sce) sce->toolsettings= newdataadr(fd, sce->toolsettings); if(sce->toolsettings) { - sce->toolsettings->vpaint= newdataadr(fd, sce->toolsettings->vpaint); - sce->toolsettings->wpaint= newdataadr(fd, sce->toolsettings->wpaint); - sce->toolsettings->sculpt= newdataadr(fd, sce->toolsettings->sculpt); + direct_link_paint(fd, (Paint**)&sce->toolsettings->sculpt); + direct_link_paint(fd, (Paint**)&sce->toolsettings->vpaint); + direct_link_paint(fd, (Paint**)&sce->toolsettings->wpaint); + + sce->toolsettings->imapaint.paint.brushes= newdataadr(fd, sce->toolsettings->imapaint.paint.brushes); + sce->toolsettings->imapaint.paintcursor= NULL; sce->toolsettings->particle.paintcursor= NULL; - - if(sce->toolsettings->sculpt) - sce->toolsettings->sculpt->session= MEM_callocN(sizeof(SculptSession), "reload sculpt session"); } if(sce->ed) { @@ -5165,7 +5211,6 @@ static void fix_relpaths_library(const char *basepath, Main *main) static void direct_link_sound(FileData *fd, bSound *sound) { - sound->sample = NULL; sound->snd_sound = NULL; sound->packedfile = direct_link_packedfile(fd, sound->packedfile); @@ -5182,6 +5227,8 @@ static void lib_link_sound(FileData *fd, Main *main) sound->id.flag -= LIB_NEEDLINK; sound->ipo= newlibadr_us(fd, sound->id.lib, sound->ipo); // XXX depreceated - old animation system sound->stream = 0; + + sound_load(main, sound); } sound= sound->id.next; } @@ -5452,6 +5499,9 @@ static BHead *read_global(BlendFileData *bfd, FileData *fd, BHead *bhead) bfd->curscene= fg->curscene; MEM_freeN(fg); + + fd->globalf= bfd->globalf; + fd->fileflags= bfd->fileflags; return blo_nextbhead(fd, bhead); } @@ -5843,7 +5893,7 @@ static void alphasort_version_246(FileData *fd, Library *lib, Mesh *me) tf = ((MTFace*)me->fdata.layers[b].data) + a; tf->mode &= ~TF_ALPHASORT; - if(ma && (ma->mode & MA_ZTRA)) + if(ma && (ma->mode & MA_ZTRANSP)) if(ELEM(tf->transp, TF_ALPHA, TF_ADD) || (texalpha && (tf->transp != TF_CLIP))) tf->mode |= TF_ALPHASORT; } @@ -8438,20 +8488,20 @@ static void do_versions(FileData *fd, Library *lib, Main *main) /* add point caches */ for(ob=main->object.first; ob; ob=ob->id.next) { if(ob->soft && !ob->soft->pointcache) - ob->soft->pointcache= BKE_ptcache_add(); + ob->soft->pointcache= BKE_ptcache_add(&ob->soft->ptcaches); for(psys=ob->particlesystem.first; psys; psys=psys->next) { if(psys->soft && !psys->soft->pointcache) - psys->soft->pointcache= BKE_ptcache_add(); + psys->soft->pointcache= BKE_ptcache_add(&psys->soft->ptcaches); if(!psys->pointcache) - psys->pointcache= BKE_ptcache_add(); + psys->pointcache= BKE_ptcache_add(&psys->ptcaches); } for(md=ob->modifiers.first; md; md=md->next) { if(md->type==eModifierType_Cloth) { ClothModifierData *clmd = (ClothModifierData*) md; if(!clmd->point_cache) - clmd->point_cache= BKE_ptcache_add(); + clmd->point_cache= BKE_ptcache_add(&clmd->ptcaches); } } } @@ -8739,7 +8789,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main) /* create new particle system */ psys = MEM_callocN(sizeof(ParticleSystem), "particle_system"); - psys->pointcache = BKE_ptcache_add(); + psys->pointcache = BKE_ptcache_add(&psys->ptcaches); part = psys->part = psys_new_settings("ParticleSettings", main); @@ -9325,9 +9375,69 @@ static void do_versions(FileData *fd, Library *lib, Main *main) Tex *tx; ParticleSettings *part; Object *ob; - PTCacheID *pid; - ListBase pidlist; - + //PTCacheID *pid; + //ListBase pidlist; + + bSound *sound; + Sequence *seq; + bActuator *act; + + for(sound = main->sound.first; sound; sound = sound->id.next) + { + if(sound->newpackedfile) + { + sound->packedfile = sound->newpackedfile; + sound->newpackedfile = NULL; + } + } + + for(ob = main->object.first; ob; ob= ob->id.next) { + for(act= ob->actuators.first; act; act= act->next) { + if (act->type == ACT_SOUND) { + bSoundActuator *sAct = (bSoundActuator*) act->data; + if(sAct->sound) + { + sound = newlibadr(fd, lib, sAct->sound); + sAct->flag = sound->flags | SOUND_FLAGS_3D ? ACT_SND_3D_SOUND : 0; + sAct->pitch = sound->pitch; + sAct->volume = sound->volume; + sAct->sound3D.reference_distance = sound->distance; + sAct->sound3D.max_gain = sound->max_gain; + sAct->sound3D.min_gain = sound->min_gain; + sAct->sound3D.rolloff_factor = sound->attenuation; + } + else + { + sAct->sound3D.reference_distance = 1.0f; + sAct->volume = 1.0f; + sAct->sound3D.max_gain = 1.0f; + sAct->sound3D.rolloff_factor = 1.0f; + } + sAct->sound3D.cone_inner_angle = 360.0f; + sAct->sound3D.cone_outer_angle = 360.0f; + sAct->sound3D.max_distance = FLT_MAX; + } + } + } + + for(scene = main->scene.first; scene; scene = scene->id.next) + { + if(scene->ed && scene->ed->seqbasep) + { + for(seq = scene->ed->seqbasep->first; seq; seq = seq->next) + { + if(seq->type == SEQ_HD_SOUND) + { + char str[FILE_MAX]; + BLI_join_dirfile(str, seq->strip->dir, seq->strip->stripdata->name); + BLI_convertstringcode(str, G.sce); + BLI_convertstringframe(str, scene->r.cfra); + seq->sound = sound_new_file(main, str); + } + } + } + } + for(screen= main->screen.first; screen; screen= screen->id.next) { do_versions_windowmanager_2_50(screen); do_versions_gpencil_2_50(main, screen); @@ -9356,7 +9466,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main) /* move to cameras */ if(sce->r.scemode & R_PANORAMA) { - for(base=scene->base.first; base; base=base->next) { + for(base=sce->base.first; base; base=base->next) { ob= newlibadr(fd, lib, base->object); if(ob->type == OB_CAMERA && !ob->id.lib) { @@ -9400,30 +9510,34 @@ static void do_versions(FileData *fd, Library *lib, Main *main) /* set old pointcaches to have disk cache flag */ for(ob = main->object.first; ob; ob= ob->id.next) { - BKE_ptcache_ids_from_object(&pidlist, ob); + //BKE_ptcache_ids_from_object(&pidlist, ob); - for(pid=pidlist.first; pid; pid=pid->next) - pid->cache->flag |= PTCACHE_DISK_CACHE; + //for(pid=pidlist.first; pid; pid=pid->next) + // pid->cache->flag |= PTCACHE_DISK_CACHE; - BLI_freelistN(&pidlist); + //BLI_freelistN(&pidlist); } } if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 1)) { - } - - /* TODO: should be moved into one of the version blocks once this branch moves to trunk and we can - bump the version (or sub-version.) */ - { - World *wo; Object *ob; Material *ma; Tex *tex; Scene *sce; ToolSettings *ts; + //PTCacheID *pid; + //ListBase pidlist; int i, a; for(ob = main->object.first; ob; ob = ob->id.next) { + //BKE_ptcache_ids_from_object(&pidlist, ob); + + //for(pid=pidlist.first; pid; pid=pid->next) { + // if(pid->ptcaches->first == NULL) + // pid->ptcaches->first = pid->ptcaches->last = pid->cache; + //} + + //BLI_freelistN(&pidlist); if(ob->type == OB_MESH) { Mesh *me = newlibadr(fd, lib, ob->data); @@ -9470,7 +9584,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main) mmd->lvl = mmd->totlvl; orig = CDDM_from_mesh(me, NULL); - dm = multires_dm_create_from_derived(mmd, orig, me, 0, 0); + dm = multires_dm_create_from_derived(mmd, 0, orig, ob, 0, 0); multires_load_old(dm, me->mr); @@ -9511,15 +9625,45 @@ static void do_versions(FileData *fd, Library *lib, Main *main) ma->mode &= ~MA_HALO; } + if(ma->mode & (MA_ZTRANSP|MA_RAYTRANSP)) { + ma->mode |= MA_TRANSP; + } + else { + ma->mode |= MA_ZTRANSP; + ma->mode &= ~MA_TRANSP; + } + /* set new bump for unused slots */ for(a=0; a<MAX_MTEX; a++) { if(ma->mtex[a]) { - if(!ma->mtex[a]->tex) - ma->mtex[a]->texflag |= MTEX_NEW_BUMP; - else if(((Tex*)newlibadr(fd, ma->id.lib, ma->mtex[a]->tex))->type == 0) + tex= ma->mtex[a]->tex; + if(!tex) ma->mtex[a]->texflag |= MTEX_NEW_BUMP; + else { + tex= (Tex*)newlibadr(fd, ma->id.lib, tex); + if(tex && tex->type == 0) /* invalid type */ + ma->mtex[a]->texflag |= MTEX_NEW_BUMP; + } } } + + /* volume rendering settings */ + if (ma->vol.stepsize < 0.0001f) { + ma->vol.density = 1.0f; + ma->vol.emission = 0.0f; + ma->vol.absorption = 1.0f; + ma->vol.scattering = 1.0f; + ma->vol.emission_col[0] = ma->vol.emission_col[1] = ma->vol.emission_col[2] = 1.0f; + ma->vol.absorption_col[0] = ma->vol.absorption_col[1] = ma->vol.absorption_col[2] = 0.0f; + ma->vol.density_scale = 1.0f; + ma->vol.depth_cutoff = 0.01f; + ma->vol.stepsize_type = MA_VOL_STEP_RANDOMIZED; + ma->vol.stepsize = 0.2f; + ma->vol.shade_stepsize = 0.2f; + ma->vol.shade_type = MA_VOL_SHADE_SINGLE; + ma->vol.shadeflag |= MA_VOL_PRECACHESHADING; + ma->vol.precache_resolution = 50; + } } for(sce = main->scene.first; sce; sce = sce->id.next) { @@ -9591,6 +9735,46 @@ static void do_versions(FileData *fd, Library *lib, Main *main) } } + if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 2)) { + Scene *sce; + + for(sce = main->scene.first; sce; sce = sce->id.next) { + if(fd->fileflags & G_FILE_ENABLE_ALL_FRAMES) + sce->gm.flag |= GAME_ENABLE_ALL_FRAMES; + if(fd->fileflags & G_FILE_SHOW_DEBUG_PROPS) + sce->gm.flag |= GAME_SHOW_DEBUG_PROPS; + if(fd->fileflags & G_FILE_SHOW_FRAMERATE) + sce->gm.flag |= GAME_SHOW_FRAMERATE; + if(fd->fileflags & G_FILE_SHOW_PHYSICS) + sce->gm.flag |= GAME_SHOW_PHYSICS; + if(fd->fileflags & G_FILE_GLSL_NO_SHADOWS) + sce->gm.flag |= GAME_GLSL_NO_SHADOWS; + if(fd->fileflags & G_FILE_GLSL_NO_SHADERS) + sce->gm.flag |= GAME_GLSL_NO_SHADERS; + if(fd->fileflags & G_FILE_GLSL_NO_RAMPS) + sce->gm.flag |= GAME_GLSL_NO_RAMPS; + if(fd->fileflags & G_FILE_GLSL_NO_NODES) + sce->gm.flag |= GAME_GLSL_NO_NODES; + if(fd->fileflags & G_FILE_GLSL_NO_EXTRA_TEX) + sce->gm.flag |= GAME_GLSL_NO_EXTRA_TEX; + if(fd->fileflags & G_FILE_IGNORE_DEPRECATION_WARNINGS) + sce->gm.flag |= GAME_IGNORE_DEPRECATION_WARNINGS; + + if(fd->fileflags & G_FILE_GAME_MAT_GLSL) + sce->gm.matmode= GAME_MAT_GLSL; + else if(fd->fileflags & G_FILE_GAME_MAT) + sce->gm.matmode= GAME_MAT_MULTITEX; + else + sce->gm.matmode= GAME_MAT_TEXFACE; + + sce->gm.flag |= GAME_DISPLAY_LISTS; + } + } + + /* put 2.50 compatibility code here until next subversion bump */ + { + } + /* WATCH IT!!!: pointers from libdata have not been converted yet here! */ /* WATCH IT 2!: Userdef struct init has to be in src/usiblender.c! */ @@ -9641,7 +9825,17 @@ static BHead *read_userdef(BlendFileData *bfd, FileData *fd, BHead *bhead) // XXX bfd->user->uifonts.first= bfd->user->uifonts.last= NULL; bfd->user->uistyles.first= bfd->user->uistyles.last= NULL; - + + // AUD_XXX + if(bfd->user->audiochannels == 0) + bfd->user->audiochannels = 2; + if(bfd->user->audiodevice == 0) + bfd->user->audiodevice = 1; + if(bfd->user->audioformat == 0) + bfd->user->audioformat = 0x12; + if(bfd->user->audiorate == 0) + bfd->user->audiorate = 44100; + bhead = blo_nextbhead(fd, bhead); /* read all attached data */ @@ -10796,14 +10990,16 @@ static Library* library_append(Main *mainvar, Scene *scene, char* file, char *di fix_relpaths_library(G.sce, mainvar); /* make all relative paths, relative to the open blend file */ /* give a base to loose objects. If group append, do it for objects too */ - if(idcode==ID_GR) { - if (flag & FILE_LINK) { - give_base_to_objects(mainvar, scene, NULL, 0); + if(scene) { + if(idcode==ID_GR) { + if (flag & FILE_LINK) { + give_base_to_objects(mainvar, scene, NULL, 0); + } else { + give_base_to_objects(mainvar, scene, curlib, 1); + } } else { - give_base_to_objects(mainvar, scene, curlib, 1); - } - } else { - give_base_to_objects(mainvar, scene, NULL, 0); + give_base_to_objects(mainvar, scene, NULL, 0); + } } /* has been removed... erm, why? s..ton) */ /* 20040907: looks like they are give base already in append_named_part(); -Nathan L */ diff --git a/source/blender/blenloader/intern/readfile.h b/source/blender/blenloader/intern/readfile.h index f0e00b75b67..e39fefa8205 100644 --- a/source/blender/blenloader/intern/readfile.h +++ b/source/blender/blenloader/intern/readfile.h @@ -69,6 +69,7 @@ typedef struct FileData { int fileversion; int id_name_offs; /* used to retrieve ID names from (bhead+1) */ + int globalf, fileflags; /* for do_versions patching */ struct OldNewMap *datamap; struct OldNewMap *globmap; diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index f94d81f1f6e..73832be7a53 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -157,6 +157,7 @@ Any case: direct data is ALWAYS after the lib block #include "BKE_main.h" #include "BKE_node.h" #include "BKE_packedFile.h" // for packAll +#include "BKE_pointcache.h" #include "BKE_report.h" #include "BKE_screen.h" // for waitcursor #include "BKE_sequence.h" @@ -406,13 +407,13 @@ static void IDP_WriteIDPArray(IDProperty *prop, void *wd) { /*REMEMBER to set totalen to len in the linking code!!*/ if (prop->data.pointer) { - IDProperty **array = prop->data.pointer; + IDProperty *array = prop->data.pointer; int a; - writedata(wd, DATA, MEM_allocN_len(prop->data.pointer), prop->data.pointer); + writestruct(wd, DATA, "IDProperty", prop->len, array); for(a=0; a<prop->len; a++) - IDP_WriteProperty(array[a], wd); + IDP_WriteProperty_OnlyData(&array[a], wd); } } @@ -582,19 +583,27 @@ static void write_boid_state(WriteData *wd, BoidState *state) /* TODO: replace *cache with *cachelist once it's coded */ #define PTCACHE_WRITE_PSYS 0 #define PTCACHE_WRITE_CLOTH 1 -static void write_pointcaches(WriteData *wd, PointCache *cache, int type) +static void write_pointcaches(WriteData *wd, ListBase *ptcaches) { - writestruct(wd, DATA, "PointCache", 1, cache); + PointCache *cache = ptcaches->first; + int i; - if((cache->flag & PTCACHE_DISK_CACHE)==0) { - PTCacheMem *pm = cache->mem_cache.first; + for(; cache; cache=cache->next) { + writestruct(wd, DATA, "PointCache", 1, cache); - for(; pm; pm=pm->next) { - writestruct(wd, DATA, "PTCacheMem", 1, pm); - if(type==PTCACHE_WRITE_PSYS) - writestruct(wd, DATA, "ParticleKey", pm->totpoint, pm->data); - else if(type==PTCACHE_WRITE_CLOTH) - writedata(wd, DATA, 9 * sizeof(float) * pm->totpoint, pm->data); + if((cache->flag & PTCACHE_DISK_CACHE)==0) { + PTCacheMem *pm = cache->mem_cache.first; + + for(; pm; pm=pm->next) { + writestruct(wd, DATA, "PTCacheMem", 1, pm); + if(pm->index_array) + writedata(wd, DATA, sizeof(int) * pm->totpoint, pm->index_array); + + for(i=0; i<BPHYS_TOT_DATA; i++) { + if(pm->data[i] && pm->data_types & (1<<i)) + writedata(wd, DATA, BKE_ptcache_data_size(i) * pm->totpoint, pm->data[i]); + } + } } } } @@ -652,8 +661,8 @@ static void write_particlesystems(WriteData *wd, ListBase *particles) if(psys->child) writestruct(wd, DATA, "ChildParticle", psys->totchild ,psys->child); writestruct(wd, DATA, "SoftBody", 1, psys->soft); - if(psys->soft) write_pointcaches(wd, psys->soft->pointcache, PTCACHE_WRITE_PSYS); - write_pointcaches(wd, psys->pointcache, PTCACHE_WRITE_PSYS); + if(psys->soft) write_pointcaches(wd, &psys->soft->ptcaches); + write_pointcaches(wd, &psys->ptcaches); } } @@ -771,9 +780,6 @@ static void write_actuators(WriteData *wd, ListBase *lb) case ACT_SOUND: writestruct(wd, DATA, "bSoundActuator", 1, act->data); break; - case ACT_CD: - writestruct(wd, DATA, "bCDActuator", 1, act->data); - break; case ACT_OBJECT: writestruct(wd, DATA, "bObjectActuator", 1, act->data); break; @@ -1094,7 +1100,7 @@ static void write_defgroups(WriteData *wd, ListBase *defbase) writestruct(wd, DATA, "bDeformGroup", 1, defgroup); } -static void write_modifiers(WriteData *wd, ListBase *modbase, int write_undo) +static void write_modifiers(WriteData *wd, ListBase *modbase) { ModifierData *md; @@ -1115,19 +1121,25 @@ static void write_modifiers(WriteData *wd, ListBase *modbase, int write_undo) writestruct(wd, DATA, "ClothSimSettings", 1, clmd->sim_parms); writestruct(wd, DATA, "ClothCollSettings", 1, clmd->coll_parms); - write_pointcaches(wd, clmd->point_cache, PTCACHE_WRITE_CLOTH); + write_pointcaches(wd, &clmd->ptcaches); } else if(md->type==eModifierType_Smoke) { SmokeModifierData *smd = (SmokeModifierData*) md; - if(smd->type==MOD_SMOKE_TYPE_DOMAIN) + if(smd->type & MOD_SMOKE_TYPE_DOMAIN) writestruct(wd, DATA, "SmokeDomainSettings", 1, smd->domain); - else if(smd->type==MOD_SMOKE_TYPE_FLOW) + else if(smd->type & MOD_SMOKE_TYPE_FLOW) writestruct(wd, DATA, "SmokeFlowSettings", 1, smd->flow); /* - else if(smd->type==MOD_SMOKE_TYPE_COLL) + else if(smd->type & MOD_SMOKE_TYPE_COLL) writestruct(wd, DATA, "SmokeCollSettings", 1, smd->coll); */ + + if((smd->type & MOD_SMOKE_TYPE_DOMAIN) && smd->domain) + { + write_pointcaches(wd, &(smd->domain->ptcaches[0])); + write_pointcaches(wd, &(smd->domain->ptcaches[1])); + } } else if(md->type==eModifierType_Fluidsim) { FluidsimModifierData *fluidmd = (FluidsimModifierData*) md; @@ -1160,13 +1172,13 @@ static void write_modifiers(WriteData *wd, ListBase *modbase, int write_undo) else if (md->type==eModifierType_Multires) { MultiresModifierData *mmd = (MultiresModifierData*) md; - if(mmd->undo_verts && write_undo) + if(mmd->undo_verts) writestruct(wd, DATA, "MVert", mmd->undo_verts_tot, mmd->undo_verts); } } } -static void write_objects(WriteData *wd, ListBase *idbase, int write_undo) +static void write_objects(WriteData *wd, ListBase *idbase) { Object *ob; @@ -1200,7 +1212,7 @@ static void write_objects(WriteData *wd, ListBase *idbase, int write_undo) writestruct(wd, DATA, "BulletSoftBody", 1, ob->bsoft); write_particlesystems(wd, &ob->particlesystem); - write_modifiers(wd, &ob->modifiers, write_undo); + write_modifiers(wd, &ob->modifiers); } ob= ob->id.next; } @@ -1565,6 +1577,11 @@ static void write_textures(WriteData *wd, ListBase *idbase) if(tex->type == TEX_PLUGIN && tex->plugin) writestruct(wd, DATA, "PluginTex", 1, tex->plugin); if(tex->coba) writestruct(wd, DATA, "ColorBand", 1, tex->coba); if(tex->type == TEX_ENVMAP && tex->env) writestruct(wd, DATA, "EnvMap", 1, tex->env); + if(tex->type == TEX_POINTDENSITY && tex->pd) { + writestruct(wd, DATA, "PointDensity", 1, tex->pd); + if(tex->pd->coba) writestruct(wd, DATA, "ColorBand", 1, tex->pd->coba); + } + if(tex->type == TEX_VOXELDATA && tex->vd) writestruct(wd, DATA, "VoxelData", 1, tex->vd); /* nodetree is integral part of texture, no libdata */ if(tex->nodetree) { @@ -1672,6 +1689,11 @@ static void write_lamps(WriteData *wd, ListBase *idbase) } } +static void write_paint(WriteData *wd, Paint *p) +{ + if(p && p->brushes) + writedata(wd, DATA, p->brush_count * sizeof(Brush*), p->brushes); +} static void write_scenes(WriteData *wd, ListBase *scebase) { @@ -1684,6 +1706,7 @@ static void write_scenes(WriteData *wd, ListBase *scebase) TimeMarker *marker; TransformOrientation *ts; SceneRenderLayer *srl; + ToolSettings *tos; sce= scebase->first; while(sce) { @@ -1701,13 +1724,22 @@ static void write_scenes(WriteData *wd, ListBase *scebase) base= base->next; } - writestruct(wd, DATA, "ToolSettings", 1, sce->toolsettings); - if(sce->toolsettings->vpaint) - writestruct(wd, DATA, "VPaint", 1, sce->toolsettings->vpaint); - if(sce->toolsettings->wpaint) - writestruct(wd, DATA, "VPaint", 1, sce->toolsettings->wpaint); - if(sce->toolsettings->sculpt) - writestruct(wd, DATA, "Sculpt", 1, sce->toolsettings->sculpt); + tos = sce->toolsettings; + writestruct(wd, DATA, "ToolSettings", 1, tos); + if(tos->vpaint) { + writestruct(wd, DATA, "VPaint", 1, tos->vpaint); + write_paint(wd, &tos->vpaint->paint); + } + if(tos->wpaint) { + writestruct(wd, DATA, "VPaint", 1, tos->wpaint); + write_paint(wd, &tos->wpaint->paint); + } + if(tos->sculpt) { + writestruct(wd, DATA, "Sculpt", 1, tos->sculpt); + write_paint(wd, &tos->sculpt->paint); + } + + write_paint(wd, &tos->imapaint.paint); ed= sce->ed; if(ed) { @@ -2004,6 +2036,10 @@ static void write_screens(WriteData *wd, ListBase *scrbase) else if(sl->spacetype==SPACE_CONSOLE) { writestruct(wd, DATA, "SpaceConsole", 1, sl); } + else if(sl->spacetype==SPACE_USERPREF) { + writestruct(wd, DATA, "SpaceUserPref", 1, sl); + } + sl= sl->next; } } @@ -2139,45 +2175,21 @@ static void write_texts(WriteData *wd, ListBase *idbase) static void write_sounds(WriteData *wd, ListBase *idbase) { bSound *sound; - bSample *sample; PackedFile * pf; - // set all samples to unsaved status - - sample = samples->first; // samples is a global defined in sound.c - while (sample) { - sample->flags |= SAMPLE_NEEDS_SAVE; - sample = sample->id.next; - } - sound= idbase->first; while(sound) { if(sound->id.us>0 || wd->current) { - // do we need to save the packedfile as well ? - sample = sound->sample; - if (sample) { - if (sample->flags & SAMPLE_NEEDS_SAVE) { - sound->newpackedfile = sample->packedfile; - sample->flags &= ~SAMPLE_NEEDS_SAVE; - } else { - sound->newpackedfile = NULL; - } - } - /* write LibData */ writestruct(wd, ID_SO, "bSound", 1, sound); if (sound->id.properties) IDP_WriteProperty(sound->id.properties, wd); - if (sound->newpackedfile) { - pf = sound->newpackedfile; + if (sound->packedfile) { + pf = sound->packedfile; writestruct(wd, DATA, "PackedFile", 1, pf); writedata(wd, DATA, pf->size, pf->data); } - - if (sample) { - sound->newpackedfile = sample->packedfile; - } } sound= sound->id.next; } @@ -2321,7 +2333,7 @@ static int write_file_handle(Main *mainvar, int handle, MemFile *compare, MemFil write_groups (wd, &mainvar->group); write_armatures(wd, &mainvar->armature); write_actions (wd, &mainvar->action); - write_objects (wd, &mainvar->object, (current != NULL)); + write_objects (wd, &mainvar->object); write_materials(wd, &mainvar->mat); write_textures (wd, &mainvar->tex); write_meshs (wd, &mainvar->mesh); diff --git a/source/blender/editors/Makefile b/source/blender/editors/Makefile index dbd0ca779aa..bbbb3fb985f 100644 --- a/source/blender/editors/Makefile +++ b/source/blender/editors/Makefile @@ -65,5 +65,6 @@ DIRS = armature \ space_text \ space_sequencer \ space_logic \ + space_userpref \ include nan_subdirs.mk diff --git a/source/blender/editors/SConscript b/source/blender/editors/SConscript index 0a13082faaf..05f17dae1a1 100644 --- a/source/blender/editors/SConscript +++ b/source/blender/editors/SConscript @@ -32,6 +32,7 @@ SConscript(['datafiles/SConscript', 'space_sequencer/SConscript', 'space_logic/SConscript', 'space_console/SConscript', + 'space_userpref/SConscript', 'transform/SConscript', 'screen/SConscript', 'sculpt_paint/SConscript', diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c new file mode 100644 index 00000000000..b16420a7094 --- /dev/null +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -0,0 +1,2260 @@ +/** + * $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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2009 Blender Foundation, Joshua Leung + * All rights reserved. + * + * Contributor(s): Joshua Leung + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include <math.h> +#include <stdlib.h> +#include <string.h> +#include <float.h> + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include "MEM_guardedalloc.h" + +#include "BLI_blenlib.h" +#include "BLI_arithb.h" + +#include "DNA_listBase.h" +#include "DNA_anim_types.h" +#include "DNA_action_types.h" +#include "DNA_armature_types.h" +#include "DNA_camera_types.h" +#include "DNA_curve_types.h" +#include "DNA_object_types.h" +#include "DNA_particle_types.h" +#include "DNA_screen_types.h" +#include "DNA_scene_types.h" +#include "DNA_space_types.h" +#include "DNA_constraint_types.h" +#include "DNA_key_types.h" +#include "DNA_lamp_types.h" +#include "DNA_material_types.h" +#include "DNA_meta_types.h" +#include "DNA_userdef_types.h" +#include "DNA_gpencil_types.h" +#include "DNA_windowmanager_types.h" +#include "DNA_world_types.h" + +#include "RNA_access.h" +#include "RNA_define.h" + +#include "BKE_animsys.h" +#include "BKE_action.h" +#include "BKE_depsgraph.h" +#include "BKE_fcurve.h" +#include "BKE_key.h" +#include "BKE_material.h" +#include "BKE_object.h" +#include "BKE_context.h" +#include "BKE_utildefines.h" + +#include "UI_interface.h" +#include "UI_interface_icons.h" +#include "UI_resources.h" +#include "UI_view2d.h" + +#include "ED_anim_api.h" +#include "ED_keyframing.h" +#include "ED_keyframes_edit.h" // XXX move the select modes out of there! +#include "ED_screen.h" +#include "ED_space_api.h" + +#include "BIF_gl.h" + +#include "WM_api.h" +#include "WM_types.h" + +/* *********************************************** */ +// XXX constant defines to be moved elsewhere? + +/* extra padding for lengths (to go under scrollers) */ +#define EXTRA_SCROLL_PAD 100.0f + +/* size of indent steps */ +#define INDENT_STEP_SIZE 7 + +/* macros used for type defines */ + /* get the pointer used for some flag */ +#define GET_ACF_FLAG_PTR(ptr) \ + { \ + *type= sizeof((ptr)); \ + return &(ptr); \ + } + + +/* XXX */ +extern void gl_round_box(int mode, float minx, float miny, float maxx, float maxy, float rad); +extern void gl_round_box_shade(int mode, float minx, float miny, float maxx, float maxy, float rad, float shadetop, float shadedown); + + +/* *********************************************** */ +/* Generic Functions (Type independent) */ + +/* Draw Backdrop ---------------------------------- */ + +/* backdrop for top-level widgets (Scene and Object only) */ +static void acf_generic_root_backdrop(bAnimContext *ac, bAnimListElem *ale, float yminc, float ymaxc) +{ + bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale); + View2D *v2d= &ac->ar->v2d; + short expanded= ANIM_channel_setting_get(ac, ale, ACHANNEL_SETTING_EXPAND) != 0; + short offset= (acf->get_offset) ? acf->get_offset(ac, ale) : 0; + + /* darker blue for top-level widgets */ + UI_ThemeColor(TH_DOPESHEET_CHANNELOB); + + /* rounded corners on LHS only - top only when expanded, but bottom too when collapsed */ + uiSetRoundBox((expanded)? (1):(1|8)); + gl_round_box(GL_POLYGON, offset, yminc, v2d->cur.xmax+EXTRA_SCROLL_PAD, ymaxc, 8); +} + +/* backdrop for data expanders under top-level Scene/Object */ +static void acf_generic_dataexpand_backdrop(bAnimContext *ac, bAnimListElem *ale, float yminc, float ymaxc) +{ + bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale); + View2D *v2d= &ac->ar->v2d; + short offset= (acf->get_offset) ? acf->get_offset(ac, ale) : 0; + + /* lighter color than top-level widget */ + UI_ThemeColor(TH_DOPESHEET_CHANNELSUBOB); + + /* no rounded corner - just rectangular box */ + glRectf(offset, yminc, v2d->cur.xmax+EXTRA_SCROLL_PAD, ymaxc); +} + +/* backdrop for generic channels */ +static void acf_generic_channel_backdrop(bAnimContext *ac, bAnimListElem *ale, float yminc, float ymaxc) +{ + bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale); + View2D *v2d= &ac->ar->v2d; + SpaceAction *saction = NULL; + bActionGroup *grp = NULL; + short indent= (acf->get_indent_level) ? acf->get_indent_level(ac, ale) : 0; + short offset= (acf->get_offset) ? acf->get_offset(ac, ale) : 0; + + /* get context info needed... */ + if ((ac->sa) && (ac->sa->spacetype == SPACE_ACTION)) + saction= (SpaceAction *)ac->sa->spacedata.first; + + if (ale->type == ANIMTYPE_FCURVE) { + FCurve *fcu= (FCurve *)ale->data; + grp= fcu->grp; + } + + /* set color for normal channels + * - use 3 shades of color group/standard color for 3 indention level + * - only use group colors if allowed to, and if actually feasible + */ + if ( (saction && !(saction->flag & SACTION_NODRAWGCOLORS)) && + ((grp) && (grp->customCol)) ) + { + char cp[3]; + + if (indent == 2) { + VECCOPY(cp, grp->cs.solid); + } + else if (indent == 1) { + VECCOPY(cp, grp->cs.select); + } + else { + VECCOPY(cp, grp->cs.active); + } + + glColor3ub(cp[0], cp[1], cp[2]); + } + else // FIXME: what happens when the indention is 1 greater than what it should be (due to grouping)? + UI_ThemeColorShade(TH_HEADER, ((indent==0)?20: (indent==1)?-20: -40)); + + /* no rounded corners - just rectangular box */ + glRectf(offset, yminc, v2d->cur.xmax+EXTRA_SCROLL_PAD, ymaxc); +} + +/* Indention + Offset ------------------------------------------- */ + +/* indention level is always the value in the name */ +static short acf_generic_indention_0(bAnimContext *ac, bAnimListElem *ale) +{ + return 0; +} +static short acf_generic_indention_1(bAnimContext *ac, bAnimListElem *ale) +{ + return 1; +} +#if 0 // XXX not used +static short acf_generic_indention_2(bAnimContext *ac, bAnimListElem *ale) +{ + return 2; +} +#endif + +/* indention which varies with the grouping status */ +static short acf_generic_indention_flexible(bAnimContext *ac, bAnimListElem *ale) +{ + short indent= 0; + + if (ale->id) { + /* special exception for materials and particles */ + if (ELEM(GS(ale->id->name),ID_MA,ID_PA)) + indent++; + } + + /* grouped F-Curves need extra level of indention */ + if (ale->type == ANIMTYPE_FCURVE) { + FCurve *fcu= (FCurve *)ale->data; + + // TODO: we need some way of specifying that the indention color should be one less... + if (fcu->grp) + indent++; + } + + /* no indention */ + return indent; +} + +/* basic offset for channels derived from indention */ +static short acf_generic_basic_offset(bAnimContext *ac, bAnimListElem *ale) +{ + bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale); + + if (acf && acf->get_indent_level) + return acf->get_indent_level(ac, ale) * INDENT_STEP_SIZE; + else + return 0; +} + +/* offset for groups + grouped entities */ +static short acf_generic_group_offset(bAnimContext *ac, bAnimListElem *ale) +{ + short offset= acf_generic_basic_offset(ac, ale); + + if (ale->id) { + /* special exception for materials and particles */ + if (ELEM(GS(ale->id->name),ID_MA,ID_PA)) + offset += 21; + + /* if not in Action Editor mode, groupings must carry some offset too... */ + else if (ac->datatype != ANIMCONT_ACTION) + offset += 14; + } + + /* offset is just the normal type - i.e. based on indention */ + return offset; +} + +/* Name ------------------------------------------- */ + +/* name for ID block entries */ +static void acf_generic_idblock_name(bAnimListElem *ale, char *name) +{ + ID *id= (ID *)ale->data; /* data pointed to should be an ID block */ + + /* just copy the name... */ + if (id && name) + strcpy(name, id->name+2); +} + +/* Settings ------------------------------------------- */ + +/* check if some setting exists for this object-based data-expander (category only) */ +static short acf_generic_dsexpand_setting_valid(bAnimContext *ac, bAnimListElem *ale, int setting) +{ + switch (setting) { + /* only expand supported */ + case ACHANNEL_SETTING_EXPAND: + return 1; + + /* visible - only available in Graph Editor */ + case ACHANNEL_SETTING_VISIBLE: + return ((ac) && (ac->spacetype == SPACE_IPO)); + + default: + return 0; + } +} + +/* get pointer to the setting (category only) */ +static void *acf_generic_dsexpand_setting_ptr(bAnimListElem *ale, int setting, short *type) +{ + Object *ob= (Object *)ale->data; + + /* clear extra return data first */ + *type= 0; + + switch (setting) { + case ACHANNEL_SETTING_EXPAND: /* expanded */ + GET_ACF_FLAG_PTR(ob->nlaflag); // XXX + + default: /* unsupported */ + return NULL; + } +} + +/* check if some setting exists for this object-based data-expander (datablock only) */ +static short acf_generic_dataexpand_setting_valid(bAnimContext *ac, bAnimListElem *ale, int setting) +{ + switch (setting) { + /* expand is always supported */ + case ACHANNEL_SETTING_EXPAND: + return 1; + + /* mute is only supported for NLA */ + case ACHANNEL_SETTING_MUTE: + return ((ac) && (ac->spacetype == SPACE_NLA)); + + /* other flags are never supported */ + default: + return 0; + } +} + +/* *********************************************** */ +/* Type Specific Functions + Defines */ + +/* Scene ------------------------------------------- */ + +// TODO: just get this from RNA? +static int acf_scene_icon(bAnimListElem *ale) +{ + return ICON_SCENE_DATA; +} + +/* check if some setting exists for this channel */ +static short acf_scene_setting_valid(bAnimContext *ac, bAnimListElem *ale, int setting) +{ + switch (setting) { + /* muted only in NLA */ + case ACHANNEL_SETTING_MUTE: + return ((ac) && (ac->spacetype == SPACE_NLA)); + + /* visible only in Graph Editor */ + case ACHANNEL_SETTING_VISIBLE: + return ((ac) && (ac->spacetype == SPACE_IPO)); + + /* only select and expand supported otherwise */ + case ACHANNEL_SETTING_SELECT: + case ACHANNEL_SETTING_EXPAND: + return 1; + + default: + return 0; + } +} + +/* get the appropriate flag(s) for the setting when it is valid */ +static int acf_scene_setting_flag(int setting, short *neg) +{ + /* clear extra return data first */ + *neg= 0; + + switch (setting) { + case ACHANNEL_SETTING_SELECT: /* selected */ + return SCE_DS_SELECTED; + + case ACHANNEL_SETTING_EXPAND: /* expanded */ + *neg= 1; + return SCE_DS_COLLAPSED; + + 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; + + default: /* unsupported */ + return 0; + } +} + +/* get pointer to the setting */ +static void *acf_scene_setting_ptr(bAnimListElem *ale, int setting, short *type) +{ + Scene *scene= (Scene *)ale->data; + + /* clear extra return data first */ + *type= 0; + + switch (setting) { + case ACHANNEL_SETTING_SELECT: /* selected */ + GET_ACF_FLAG_PTR(scene->flag); + + case ACHANNEL_SETTING_EXPAND: /* expanded */ + GET_ACF_FLAG_PTR(scene->flag); + + case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */ + case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */ + if (scene->adt) + GET_ACF_FLAG_PTR(scene->adt->flag) + else + return NULL; + + default: /* unsupported */ + return 0; + } +} + +/* scene type define */ +static bAnimChannelType ACF_SCENE = +{ + acf_generic_root_backdrop, /* backdrop */ + acf_generic_indention_0, /* indent level */ + NULL, /* offset */ + + acf_generic_idblock_name, /* name */ + acf_scene_icon, /* icon */ + + acf_scene_setting_valid, /* has setting */ + acf_scene_setting_flag, /* flag for setting */ + acf_scene_setting_ptr /* pointer for setting */ +}; + +/* Object ------------------------------------------- */ + +static int acf_object_icon(bAnimListElem *ale) +{ + Base *base= (Base *)ale->data; + Object *ob= base->object; + + /* icon depends on object-type */ + if (ob->type == OB_ARMATURE) + return ICON_ARMATURE_DATA; + else + return ICON_OBJECT_DATA; +} + +/* name for object */ +static void acf_object_name(bAnimListElem *ale, char *name) +{ + Base *base= (Base *)ale->data; + Object *ob= base->object; + + /* just copy the name... */ + if (ob && name) + strcpy(name, ob->id.name+2); +} + +/* check if some setting exists for this channel */ +static short acf_object_setting_valid(bAnimContext *ac, bAnimListElem *ale, int setting) +{ + switch (setting) { + /* muted only in NLA */ + case ACHANNEL_SETTING_MUTE: + return ((ac) && (ac->spacetype == SPACE_NLA)); + + /* visible only in Graph Editor */ + case ACHANNEL_SETTING_VISIBLE: + return ((ac) && (ac->spacetype == SPACE_IPO)); + + /* only select and expand supported otherwise */ + case ACHANNEL_SETTING_SELECT: + case ACHANNEL_SETTING_EXPAND: + return 1; + + default: + return 0; + } +} + +/* get the appropriate flag(s) for the setting when it is valid */ +static int acf_object_setting_flag(int setting, short *neg) +{ + /* clear extra return data first */ + *neg= 0; + + switch (setting) { + case ACHANNEL_SETTING_SELECT: /* selected */ + return SELECT; + + case ACHANNEL_SETTING_EXPAND: /* expanded */ + *neg= 1; + return OB_ADS_COLLAPSED; + + 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; + + default: /* unsupported */ + return 0; + } +} + +/* get pointer to the setting */ +static void *acf_object_setting_ptr(bAnimListElem *ale, int setting, short *type) +{ + Base *base= (Base *)ale->data; + Object *ob= base->object; + + /* clear extra return data first */ + *type= 0; + + switch (setting) { + case ACHANNEL_SETTING_SELECT: /* selected */ + GET_ACF_FLAG_PTR(ob->flag); + + case ACHANNEL_SETTING_EXPAND: /* expanded */ + GET_ACF_FLAG_PTR(ob->nlaflag); // xxx + + case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */ + case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */ + if (ob->adt) + GET_ACF_FLAG_PTR(ob->adt->flag) + else + return NULL; + + default: /* unsupported */ + return 0; + } +} + +/* object type define */ +static bAnimChannelType ACF_OBJECT = +{ + acf_generic_root_backdrop, /* backdrop */ + acf_generic_indention_0, /* indent level */ + NULL, /* offset */ + + acf_object_name, /* name */ + acf_object_icon, /* icon */ + + acf_object_setting_valid, /* has setting */ + acf_object_setting_flag, /* flag for setting */ + acf_object_setting_ptr /* pointer for setting */ +}; + +/* Group ------------------------------------------- */ + +/* backdrop for group widget */ +static void acf_group_backdrop(bAnimContext *ac, bAnimListElem *ale, float yminc, float ymaxc) +{ + bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale); + View2D *v2d= &ac->ar->v2d; + short expanded= ANIM_channel_setting_get(ac, ale, ACHANNEL_SETTING_EXPAND) != 0; + short offset= (acf->get_offset) ? acf->get_offset(ac, ale) : 0; + + /* only for action group channels */ + if (ale->flag & AGRP_ACTIVE) + UI_ThemeColorShade(TH_GROUP_ACTIVE, 10); + else + UI_ThemeColorShade(TH_GROUP, 20); + + /* rounded corners on LHS only - top only when expanded, but bottom too when collapsed */ + uiSetRoundBox((expanded)? (1):(1|8)); + gl_round_box(GL_POLYGON, offset, yminc, v2d->cur.xmax+EXTRA_SCROLL_PAD, ymaxc, 8); +} + +/* name for group entries */ +static void acf_group_name(bAnimListElem *ale, char *name) +{ + bActionGroup *agrp= (bActionGroup *)ale->data; + + /* just copy the name... */ + if (agrp && name) + strcpy(name, agrp->name); +} + +/* check if some setting exists for this channel */ +static short acf_group_setting_valid(bAnimContext *ac, bAnimListElem *ale, int setting) +{ + /* for now, all settings are supported, though some are only conditionally */ + switch (setting) { + case ACHANNEL_SETTING_VISIBLE: /* Only available in Graph Editor */ + return ((ac->sa) && (ac->sa->spacetype==SPACE_IPO)); + + default: /* always supported */ + return 1; + } +} + +/* get the appropriate flag(s) for the setting when it is valid */ +static int acf_group_setting_flag(int setting, short *neg) +{ + /* clear extra return data first */ + *neg= 0; + + switch (setting) { + case ACHANNEL_SETTING_SELECT: /* selected */ + return AGRP_SELECTED; + + case ACHANNEL_SETTING_EXPAND: /* expanded */ + return AGRP_EXPANDED; + + case ACHANNEL_SETTING_MUTE: /* muted */ + return AGRP_MUTED; + + case ACHANNEL_SETTING_PROTECT: /* protected */ + //*neg= 1; - if we change this to edtiability + return AGRP_PROTECTED; + + case ACHANNEL_SETTING_VISIBLE: /* visiblity - graph editor */ + *neg= 1; + return AGRP_NOTVISIBLE; + } + + /* this shouldn't happen */ + return 0; +} + +/* get pointer to the setting */ +static void *acf_group_setting_ptr(bAnimListElem *ale, int setting, short *type) +{ + bActionGroup *agrp= (bActionGroup *)ale->data; + + /* all flags are just in agrp->flag for now... */ + GET_ACF_FLAG_PTR(agrp->flag); +} + +/* group type define */ +static bAnimChannelType ACF_GROUP = +{ + acf_group_backdrop, /* backdrop */ + acf_generic_indention_0, /* indent level */ + acf_generic_group_offset, /* offset */ + + acf_group_name, /* name */ + NULL, /* icon */ + + acf_group_setting_valid, /* has setting */ + acf_group_setting_flag, /* flag for setting */ + acf_group_setting_ptr /* pointer for setting */ +}; + +/* F-Curve ------------------------------------------- */ + +/* name for fcurve entries */ +static void acf_fcurve_name(bAnimListElem *ale, char *name) +{ + getname_anim_fcurve(name, ale->id, ale->data); +} + +/* check if some setting exists for this channel */ +static short acf_fcurve_setting_valid(bAnimContext *ac, bAnimListElem *ale, int setting) +{ + FCurve *fcu= (FCurve *)ale->data; + + switch (setting) { + /* unsupported */ + case ACHANNEL_SETTING_EXPAND: /* F-Curves are not containers */ + return 0; + + /* conditionally available */ + case ACHANNEL_SETTING_PROTECT: /* Protection is only valid when there's keyframes */ + if (fcu->bezt) + return 1; + else + return 0; // NOTE: in this special case, we need to draw ICON_ZOOMOUT + + case ACHANNEL_SETTING_VISIBLE: /* Only available in Graph Editor */ + return ((ac->sa) && (ac->sa->spacetype==SPACE_IPO)); + + /* always available */ + default: + return 1; + } +} + +/* get the appropriate flag(s) for the setting when it is valid */ +static int acf_fcurve_setting_flag(int setting, short *neg) +{ + /* clear extra return data first */ + *neg= 0; + + switch (setting) { + case ACHANNEL_SETTING_SELECT: /* selected */ + return FCURVE_SELECTED; + + case ACHANNEL_SETTING_MUTE: /* muted */ + return FCURVE_MUTED; + + case ACHANNEL_SETTING_PROTECT: /* protected */ + //*neg= 1; - if we change this to edtiability + return FCURVE_PROTECTED; + + case ACHANNEL_SETTING_VISIBLE: /* visiblity - graph editor */ + return FCURVE_VISIBLE; + + default: /* unsupported */ + return 0; + } +} + +/* get pointer to the setting */ +static void *acf_fcurve_setting_ptr(bAnimListElem *ale, int setting, short *type) +{ + FCurve *fcu= (FCurve *)ale->data; + + /* all flags are just in agrp->flag for now... */ + GET_ACF_FLAG_PTR(fcu->flag); +} + +/* fcurve type define */ +static bAnimChannelType ACF_FCURVE = +{ + acf_generic_channel_backdrop, /* backdrop */ + acf_generic_indention_flexible, /* indent level */ // xxx rename this to f-curves only? + acf_generic_group_offset, /* offset */ + + acf_fcurve_name, /* name */ + NULL, /* icon */ + + acf_fcurve_setting_valid, /* has setting */ + acf_fcurve_setting_flag, /* flag for setting */ + acf_fcurve_setting_ptr /* pointer for setting */ +}; + +/* Object Action Expander ------------------------------------------- */ + +// TODO: just get this from RNA? +static int acf_fillactd_icon(bAnimListElem *ale) +{ + return ICON_ACTION; +} + +/* check if some setting exists for this channel */ +static short acf_fillactd_setting_valid(bAnimContext *ac, bAnimListElem *ale, int setting) +{ + switch (setting) { + /* only select and expand supported */ + case ACHANNEL_SETTING_SELECT: + case ACHANNEL_SETTING_EXPAND: + return 1; + + default: + return 0; + } +} + +/* get the appropriate flag(s) for the setting when it is valid */ +static int acf_fillactd_setting_flag(int setting, short *neg) +{ + /* clear extra return data first */ + *neg= 0; + + switch (setting) { + case ACHANNEL_SETTING_SELECT: /* selected */ + return ACT_SELECTED; + + case ACHANNEL_SETTING_EXPAND: /* expanded */ + *neg= 1; + return ACT_COLLAPSED; + + default: /* unsupported */ + return 0; + } +} + +/* get pointer to the setting */ +static void *acf_fillactd_setting_ptr(bAnimListElem *ale, int setting, short *type) +{ + bAction *act= (bAction *)ale->data; + + /* clear extra return data first */ + *type= 0; + + switch (setting) { + case ACHANNEL_SETTING_SELECT: /* selected */ + GET_ACF_FLAG_PTR(act->flag); + + case ACHANNEL_SETTING_EXPAND: /* expanded */ + GET_ACF_FLAG_PTR(act->flag); + + default: /* unsupported */ + return 0; + } +} + +/* object action expander type define */ +static bAnimChannelType ACF_FILLACTD = +{ + acf_generic_dataexpand_backdrop,/* backdrop */ + acf_generic_indention_1, /* indent level */ + acf_generic_basic_offset, /* offset */ + + acf_generic_idblock_name, /* name */ + acf_fillactd_icon, /* icon */ + + acf_fillactd_setting_valid, /* has setting */ + acf_fillactd_setting_flag, /* flag for setting */ + acf_fillactd_setting_ptr /* pointer for setting */ +}; + +/* Drivers Expander ------------------------------------------- */ + +// TODO: just get this from RNA? +static int acf_filldrivers_icon(bAnimListElem *ale) +{ + return ICON_ANIM_DATA; +} + +static void acf_filldrivers_name(bAnimListElem *ale, char *name) +{ + strcpy(name, "Drivers"); +} + +/* check if some setting exists for this channel */ +// TODO: this could be made more generic +static short acf_filldrivers_setting_valid(bAnimContext *ac, bAnimListElem *ale, int setting) +{ + switch (setting) { + /* only expand supported */ + case ACHANNEL_SETTING_EXPAND: + return 1; + + default: + return 0; + } +} + +/* get the appropriate flag(s) for the setting when it is valid */ +static int acf_filldrivers_setting_flag(int setting, short *neg) +{ + /* clear extra return data first */ + *neg= 0; + + switch (setting) { + case ACHANNEL_SETTING_EXPAND: /* expanded */ + *neg= 1; + return ADT_DRIVERS_COLLAPSED; + + default: /* unsupported */ + return 0; + } +} + +/* get pointer to the setting */ +static void *acf_filldrivers_setting_ptr(bAnimListElem *ale, int setting, short *type) +{ + AnimData *adt= (AnimData *)ale->data; + + /* clear extra return data first */ + *type= 0; + + switch (setting) { + case ACHANNEL_SETTING_EXPAND: /* expanded */ + GET_ACF_FLAG_PTR(adt->flag); + + default: /* unsupported */ + return 0; + } +} + +/* drivers expander type define */ +static bAnimChannelType ACF_FILLDRIVERS = +{ + acf_generic_dataexpand_backdrop,/* backdrop */ + acf_generic_indention_1, /* indent level */ + acf_generic_basic_offset, /* offset */ + + acf_filldrivers_name, /* name */ + acf_filldrivers_icon, /* icon */ + + acf_filldrivers_setting_valid, /* has setting */ + acf_filldrivers_setting_flag, /* flag for setting */ + acf_filldrivers_setting_ptr /* pointer for setting */ +}; + +/* Materials Expander ------------------------------------------- */ + +// TODO: just get this from RNA? +static int acf_fillmatd_icon(bAnimListElem *ale) +{ + return ICON_MATERIAL_DATA; +} + +static void acf_fillmatd_name(bAnimListElem *ale, char *name) +{ + strcpy(name, "Materials"); +} + +/* get the appropriate flag(s) for the setting when it is valid */ +static int acf_fillmatd_setting_flag(int setting, short *neg) +{ + /* clear extra return data first */ + *neg= 0; + + switch (setting) { + case ACHANNEL_SETTING_EXPAND: /* expanded */ + *neg= 1; + return OB_ADS_SHOWMATS; + + default: /* unsupported */ + return 0; + } +} + +/* materials expander type define */ +static bAnimChannelType ACF_FILLMATD= +{ + acf_generic_dataexpand_backdrop,/* backdrop */ + acf_generic_indention_1, /* indent level */ + acf_generic_basic_offset, /* offset */ + + acf_fillmatd_name, /* name */ + acf_fillmatd_icon, /* icon */ + + acf_generic_dsexpand_setting_valid, /* has setting */ + acf_fillmatd_setting_flag, /* flag for setting */ + acf_generic_dsexpand_setting_ptr /* pointer for setting */ +}; + +/* Particles Expander ------------------------------------------- */ + +// TODO: just get this from RNA? +static int acf_fillpartd_icon(bAnimListElem *ale) +{ + return ICON_PARTICLE_DATA; +} + +static void acf_fillpartd_name(bAnimListElem *ale, char *name) +{ + strcpy(name, "Particles"); +} + +/* get the appropriate flag(s) for the setting when it is valid */ +static int acf_fillpartd_setting_flag(int setting, short *neg) +{ + /* clear extra return data first */ + *neg= 0; + + switch (setting) { + case ACHANNEL_SETTING_EXPAND: /* expanded */ + *neg= 1; + return OB_ADS_SHOWPARTS; + + default: /* unsupported */ + return 0; + } +} + +/* particles expander type define */ +static bAnimChannelType ACF_FILLPARTD= +{ + acf_generic_dataexpand_backdrop,/* backdrop */ + acf_generic_indention_1, /* indent level */ + acf_generic_basic_offset, /* offset */ + + acf_fillpartd_name, /* name */ + acf_fillpartd_icon, /* icon */ + + acf_generic_dsexpand_setting_valid, /* has setting */ + acf_fillpartd_setting_flag, /* flag for setting */ + acf_generic_dsexpand_setting_ptr /* pointer for setting */ +}; + +/* Material Expander ------------------------------------------- */ + +// TODO: just get this from RNA? +static int acf_dsmat_icon(bAnimListElem *ale) +{ + return ICON_MATERIAL_DATA; +} + +/* offset for material expanders */ +static short acf_dsmat_offset(bAnimContext *ac, bAnimListElem *ale) +{ + return 21; +} + +/* get the appropriate flag(s) for the setting when it is valid */ +static int acf_dsmat_setting_flag(int setting, short *neg) +{ + /* clear extra return data first */ + *neg= 0; + + switch (setting) { + case ACHANNEL_SETTING_EXPAND: /* expanded */ + return MA_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; + + default: /* unsupported */ + return 0; + } +} + +/* get pointer to the setting */ +static void *acf_dsmat_setting_ptr(bAnimListElem *ale, int setting, short *type) +{ + Material *ma= (Material *)ale->data; + + /* clear extra return data first */ + *type= 0; + + switch (setting) { + case ACHANNEL_SETTING_EXPAND: /* expanded */ + GET_ACF_FLAG_PTR(ma->flag); + + case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */ + case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */ + if (ma->adt) + GET_ACF_FLAG_PTR(ma->adt->flag) + else + return NULL; + + default: /* unsupported */ + return NULL; + } +} + +/* material expander type define */ +static bAnimChannelType ACF_DSMAT= +{ + acf_generic_channel_backdrop, /* backdrop */ + acf_generic_indention_0, /* indent level */ + acf_dsmat_offset, /* offset */ + + acf_generic_idblock_name, /* name */ + acf_dsmat_icon, /* icon */ + + acf_generic_dataexpand_setting_valid, /* has setting */ + acf_dsmat_setting_flag, /* flag for setting */ + acf_dsmat_setting_ptr /* pointer for setting */ +}; + +/* Lamp Expander ------------------------------------------- */ + +// TODO: just get this from RNA? +static int acf_dslam_icon(bAnimListElem *ale) +{ + return ICON_LAMP_DATA; +} + +/* get the appropriate flag(s) for the setting when it is valid */ +static int acf_dslam_setting_flag(int setting, short *neg) +{ + /* clear extra return data first */ + *neg= 0; + + switch (setting) { + case ACHANNEL_SETTING_EXPAND: /* expanded */ + return LA_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; + + default: /* unsupported */ + return 0; + } +} + +/* get pointer to the setting */ +static void *acf_dslam_setting_ptr(bAnimListElem *ale, int setting, short *type) +{ + Lamp *la= (Lamp *)ale->data; + + /* clear extra return data first */ + *type= 0; + + switch (setting) { + case ACHANNEL_SETTING_EXPAND: /* expanded */ + GET_ACF_FLAG_PTR(la->flag); + + case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */ + case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */ + if (la->adt) + GET_ACF_FLAG_PTR(la->adt->flag) + else + return NULL; + + default: /* unsupported */ + return NULL; + } +} + +/* lamp expander type define */ +static bAnimChannelType ACF_DSLAM= +{ + acf_generic_dataexpand_backdrop,/* backdrop */ + acf_generic_indention_1, /* indent level */ + acf_generic_basic_offset, /* offset */ + + acf_generic_idblock_name, /* name */ + acf_dslam_icon, /* icon */ + + acf_generic_dataexpand_setting_valid, /* has setting */ + acf_dslam_setting_flag, /* flag for setting */ + acf_dslam_setting_ptr /* pointer for setting */ +}; + +/* Camera Expander ------------------------------------------- */ + +// TODO: just get this from RNA? +static int acf_dscam_icon(bAnimListElem *ale) +{ + return ICON_CAMERA_DATA; +} + +/* get the appropriate flag(s) for the setting when it is valid */ +static int acf_dscam_setting_flag(int setting, short *neg) +{ + /* clear extra return data first */ + *neg= 0; + + switch (setting) { + case ACHANNEL_SETTING_EXPAND: /* expanded */ + return CAM_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; + + default: /* unsupported */ + return 0; + } +} + +/* get pointer to the setting */ +static void *acf_dscam_setting_ptr(bAnimListElem *ale, int setting, short *type) +{ + Camera *ca= (Camera *)ale->data; + + /* clear extra return data first */ + *type= 0; + + switch (setting) { + case ACHANNEL_SETTING_EXPAND: /* expanded */ + GET_ACF_FLAG_PTR(ca->flag); + + case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */ + case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */ + if (ca->adt) + GET_ACF_FLAG_PTR(ca->adt->flag) + else + return NULL; + + default: /* unsupported */ + return NULL; + } +} + +/* camera expander type define */ +static bAnimChannelType ACF_DSCAM= +{ + acf_generic_dataexpand_backdrop,/* backdrop */ + acf_generic_indention_1, /* indent level */ + acf_generic_basic_offset, /* offset */ + + acf_generic_idblock_name, /* name */ + acf_dscam_icon, /* icon */ + + acf_generic_dataexpand_setting_valid, /* has setting */ + acf_dscam_setting_flag, /* flag for setting */ + acf_dscam_setting_ptr /* pointer for setting */ +}; + +/* Curve Expander ------------------------------------------- */ + +// TODO: just get this from RNA? +static int acf_dscur_icon(bAnimListElem *ale) +{ + return ICON_CURVE_DATA; +} + +/* get the appropriate flag(s) for the setting when it is valid */ +static int acf_dscur_setting_flag(int setting, short *neg) +{ + /* clear extra return data first */ + *neg= 0; + + switch (setting) { + case ACHANNEL_SETTING_EXPAND: /* expanded */ + return CU_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; + + default: /* unsupported */ + return 0; + } +} + +/* get pointer to the setting */ +static void *acf_dscur_setting_ptr(bAnimListElem *ale, int setting, short *type) +{ + Curve *cu= (Curve *)ale->data; + + /* clear extra return data first */ + *type= 0; + + switch (setting) { + case ACHANNEL_SETTING_EXPAND: /* expanded */ + GET_ACF_FLAG_PTR(cu->flag); + + case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */ + case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */ + if (cu->adt) + GET_ACF_FLAG_PTR(cu->adt->flag) + else + return NULL; + + default: /* unsupported */ + return NULL; + } +} + +/* curve expander type define */ +static bAnimChannelType ACF_DSCUR= +{ + acf_generic_dataexpand_backdrop,/* backdrop */ + acf_generic_indention_1, /* indent level */ + acf_generic_basic_offset, /* offset */ + + acf_generic_idblock_name, /* name */ + acf_dscur_icon, /* icon */ + + acf_generic_dataexpand_setting_valid, /* has setting */ + acf_dscur_setting_flag, /* flag for setting */ + acf_dscur_setting_ptr /* pointer for setting */ +}; + +/* Shape Key Expander ------------------------------------------- */ + +// TODO: just get this from RNA? +static int acf_dsskey_icon(bAnimListElem *ale) +{ + return ICON_SHAPEKEY_DATA; +} + +/* get the appropriate flag(s) for the setting when it is valid */ +static int acf_dsskey_setting_flag(int setting, short *neg) +{ + /* clear extra return data first */ + *neg= 0; + + switch (setting) { + case ACHANNEL_SETTING_EXPAND: /* expanded */ + return KEYBLOCK_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; + + default: /* unsupported */ + return 0; + } +} + +/* get pointer to the setting */ +static void *acf_dsskey_setting_ptr(bAnimListElem *ale, int setting, short *type) +{ + Key *key= (Key *)ale->data; + + /* clear extra return data first */ + *type= 0; + + switch (setting) { + case ACHANNEL_SETTING_EXPAND: /* expanded */ + GET_ACF_FLAG_PTR(key->flag); + + case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */ + case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */ + if (key->adt) + GET_ACF_FLAG_PTR(key->adt->flag) + else + return NULL; + + default: /* unsupported */ + return NULL; + } +} + +/* shapekey expander type define */ +static bAnimChannelType ACF_DSSKEY= +{ + acf_generic_dataexpand_backdrop,/* backdrop */ + acf_generic_indention_1, /* indent level */ + acf_generic_basic_offset, /* offset */ + + acf_generic_idblock_name, /* name */ + acf_dsskey_icon, /* icon */ + + acf_generic_dataexpand_setting_valid, /* has setting */ + acf_dsskey_setting_flag, /* flag for setting */ + acf_dsskey_setting_ptr /* pointer for setting */ +}; + +/* World Expander ------------------------------------------- */ + +// TODO: just get this from RNA? +static int acf_dswor_icon(bAnimListElem *ale) +{ + return ICON_WORLD_DATA; +} + +/* get the appropriate flag(s) for the setting when it is valid */ +static int acf_dswor_setting_flag(int setting, short *neg) +{ + /* clear extra return data first */ + *neg= 0; + + switch (setting) { + case ACHANNEL_SETTING_EXPAND: /* expanded */ + return WO_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; + + default: /* unsupported */ + return 0; + } +} + +/* get pointer to the setting */ +static void *acf_dswor_setting_ptr(bAnimListElem *ale, int setting, short *type) +{ + World *wo= (World *)ale->data; + + /* clear extra return data first */ + *type= 0; + + switch (setting) { + case ACHANNEL_SETTING_EXPAND: /* expanded */ + GET_ACF_FLAG_PTR(wo->flag); + + case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */ + case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */ + if (wo->adt) + GET_ACF_FLAG_PTR(wo->adt->flag) + else + return NULL; + + default: /* unsupported */ + return NULL; + } +} + +/* world expander type define */ +static bAnimChannelType ACF_DSWOR= +{ + acf_generic_dataexpand_backdrop,/* backdrop */ + acf_generic_indention_1, /* indent level */ + acf_generic_basic_offset, /* offset */ + + acf_generic_idblock_name, /* name */ + acf_dswor_icon, /* icon */ + + acf_generic_dataexpand_setting_valid, /* has setting */ + acf_dswor_setting_flag, /* flag for setting */ + acf_dswor_setting_ptr /* pointer for setting */ +}; + +/* Particle Expander ------------------------------------------- */ + +// TODO: just get this from RNA? +static int acf_dspart_icon(bAnimListElem *ale) +{ + return ICON_PARTICLE_DATA; +} + +/* get the appropriate flag(s) for the setting when it is valid */ +static int acf_dspart_setting_flag(int setting, short *neg) +{ + /* clear extra return data first */ + *neg= 0; + + switch (setting) { + case ACHANNEL_SETTING_EXPAND: /* expanded */ + return PART_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; + + default: /* unsupported */ + return 0; + } +} + +/* get pointer to the setting */ +static void *acf_dspart_setting_ptr(bAnimListElem *ale, int setting, short *type) +{ + ParticleSettings *part= (ParticleSettings *)ale->data; + + /* clear extra return data first */ + *type= 0; + + switch (setting) { + case ACHANNEL_SETTING_EXPAND: /* expanded */ + GET_ACF_FLAG_PTR(part->flag); + + case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */ + case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */ + if (part->adt) + GET_ACF_FLAG_PTR(part->adt->flag) + else + return NULL; + + default: /* unsupported */ + return NULL; + } +} + +/* particle expander type define */ +static bAnimChannelType ACF_DSPART= +{ + acf_generic_dataexpand_backdrop,/* backdrop */ + acf_generic_indention_1, /* indent level */ + acf_generic_basic_offset, /* offset */ + + acf_generic_idblock_name, /* name */ + acf_dspart_icon, /* icon */ + + acf_generic_dataexpand_setting_valid, /* has setting */ + acf_dspart_setting_flag, /* flag for setting */ + acf_dspart_setting_ptr /* pointer for setting */ +}; + +/* MetaBall Expander ------------------------------------------- */ + +// TODO: just get this from RNA? +static int acf_dsmball_icon(bAnimListElem *ale) +{ + return ICON_META_DATA; +} + +/* get the appropriate flag(s) for the setting when it is valid */ +static int acf_dsmball_setting_flag(int setting, short *neg) +{ + /* clear extra return data first */ + *neg= 0; + + switch (setting) { + case ACHANNEL_SETTING_EXPAND: /* expanded */ + return MB_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; + + default: /* unsupported */ + return 0; + } +} + +/* get pointer to the setting */ +static void *acf_dsmball_setting_ptr(bAnimListElem *ale, int setting, short *type) +{ + MetaBall *mb= (MetaBall *)ale->data; + + /* clear extra return data first */ + *type= 0; + + switch (setting) { + case ACHANNEL_SETTING_EXPAND: /* expanded */ + GET_ACF_FLAG_PTR(mb->flag); + + case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */ + case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */ + if (mb->adt) + GET_ACF_FLAG_PTR(mb->adt->flag) + else + return NULL; + + default: /* unsupported */ + return NULL; + } +} + +/* metaball expander type define */ +static bAnimChannelType ACF_DSMBALL= +{ + acf_generic_dataexpand_backdrop,/* backdrop */ + acf_generic_indention_1, /* indent level */ + acf_generic_basic_offset, /* offset */ + + acf_generic_idblock_name, /* name */ + acf_dsmball_icon, /* icon */ + + acf_generic_dataexpand_setting_valid, /* has setting */ + acf_dsmball_setting_flag, /* flag for setting */ + acf_dsmball_setting_ptr /* pointer for setting */ +}; + +/* ShapeKey Entry ------------------------------------------- */ +// XXX ... this is currently obsolete... + +#if 0 +static void dummy_olddraw_shapekeys () +{ + case ANIMTYPE_SHAPEKEY: /* shapekey channel */ + { + KeyBlock *kb = (KeyBlock *)ale->data; + + indent = 0; + special = -1; + + offset= (ale->id) ? 21 : 0; + + if (kb->name[0] == '\0') + sprintf(name, "Key %d", ale->index); + else + strcpy(name, kb->name); + } + break; +} +#endif + +/* Grease Pencil entries ------------------------------------------- */ +// XXX ... this is currently not restored yet + +#if 0 +static void dummy_olddraw_gpencil () +{ + /* determine what needs to be drawn */ + switch (ale->type) { + case ANIMTYPE_GPDATABLOCK: /* gpencil datablock */ + { + bGPdata *gpd = (bGPdata *)ale->data; + ScrArea *sa = (ScrArea *)ale->owner; + + indent = 0; + group= 3; + + /* only show expand if there are any channels */ + if (gpd->layers.first) { + if (gpd->flag & GP_DATA_EXPAND) + expand = ICON_TRIA_DOWN; + else + expand = ICON_TRIA_RIGHT; + } + + switch (sa->spacetype) { + case SPACE_VIEW3D: + { + /* this shouldn't cause any overflow... */ + //sprintf(name, "3DView:%s", view3d_get_name(sa->spacedata.first)); // XXX missing func.. + strcpy(name, "3dView"); + special= ICON_VIEW3D; + } + break; + case SPACE_NODE: + { + SpaceNode *snode= sa->spacedata.first; + char treetype[12]; + + if (snode->treetype == 1) + strcpy(treetype, "Composite"); + else + strcpy(treetype, "Material"); + sprintf(name, "Nodes:%s", treetype); + + special= ICON_NODE; + } + break; + case SPACE_SEQ: + { + SpaceSeq *sseq= sa->spacedata.first; + char imgpreview[10]; + + switch (sseq->mainb) { + case 1: sprintf(imgpreview, "Image..."); break; + case 2: sprintf(imgpreview, "Luma..."); break; + case 3: sprintf(imgpreview, "Chroma..."); break; + case 4: sprintf(imgpreview, "Histogram"); break; + + default: sprintf(imgpreview, "Sequence"); break; + } + sprintf(name, "Sequencer:%s", imgpreview); + + special= ICON_SEQUENCE; + } + break; + case SPACE_IMAGE: + { + SpaceImage *sima= sa->spacedata.first; + + if (sima->image) + sprintf(name, "Image:%s", sima->image->id.name+2); + else + strcpy(name, "Image:<None>"); + + special= ICON_IMAGE_COL; + } + break; + + default: + { + sprintf(name, "<Unknown GP-Data Source>"); + special= -1; + } + break; + } + } + break; + case ANIMTYPE_GPLAYER: /* gpencil layer */ + { + bGPDlayer *gpl = (bGPDlayer *)ale->data; + + indent = 0; + special = -1; + expand = -1; + group = 1; + + if (EDITABLE_GPL(gpl)) + protect = ICON_UNLOCKED; + else + protect = ICON_LOCKED; + + if (gpl->flag & GP_LAYER_HIDE) + mute = ICON_MUTE_IPO_ON; + else + mute = ICON_MUTE_IPO_OFF; + + sel = SEL_GPL(gpl); + BLI_snprintf(name, 32, gpl->info); + } + break; + } + + if (group == 3) { + /* only for gp-data channels */ + UI_ThemeColorShade(TH_GROUP, 20); + uiSetRoundBox((expand == ICON_TRIA_DOWN)? (1):(1|8)); + gl_round_box(GL_POLYGON, x+offset, yminc, (float)ACHANNEL_NAMEWIDTH, ymaxc, 8); + } +} +#endif + +/* *********************************************** */ +/* Type Registration and General Access */ + +/* These globals only ever get directly accessed in this file */ +static bAnimChannelType *animchannelTypeInfo[ANIMTYPE_NUM_TYPES]; +static short ACF_INIT= 1; /* when non-zero, the list needs to be updated */ + +/* Initialise type info definitions */ +void ANIM_init_channel_typeinfo_data (void) +{ + int type= 0; + + /* start initialising if necessary... */ + if (ACF_INIT) { + ACF_INIT= 0; + + animchannelTypeInfo[type++]= NULL; /* None */ + animchannelTypeInfo[type++]= NULL; /* AnimData */ + animchannelTypeInfo[type++]= NULL; /* Special */ + + animchannelTypeInfo[type++]= &ACF_SCENE; /* Scene */ + animchannelTypeInfo[type++]= &ACF_OBJECT; /* Object */ + animchannelTypeInfo[type++]= &ACF_GROUP; /* Group */ + animchannelTypeInfo[type++]= &ACF_FCURVE; /* F-Curve */ + + animchannelTypeInfo[type++]= &ACF_FILLACTD; /* Object Action Expander */ + animchannelTypeInfo[type++]= &ACF_FILLDRIVERS; /* Drivers Expander */ + animchannelTypeInfo[type++]= &ACF_FILLMATD; /* Materials Expander */ + animchannelTypeInfo[type++]= &ACF_FILLPARTD; /* Particles Expander */ + + animchannelTypeInfo[type++]= &ACF_DSMAT; /* Material Channel */ + animchannelTypeInfo[type++]= &ACF_DSLAM; /* Lamp Channel */ + animchannelTypeInfo[type++]= &ACF_DSCAM; /* Camera Channel */ + animchannelTypeInfo[type++]= &ACF_DSCUR; /* Curve Channel */ + animchannelTypeInfo[type++]= &ACF_DSSKEY; /* ShapeKey Channel */ + animchannelTypeInfo[type++]= &ACF_DSWOR; /* World Channel */ + animchannelTypeInfo[type++]= &ACF_DSPART; /* Particle Channel */ + animchannelTypeInfo[type++]= &ACF_DSMBALL; /* MetaBall Channel */ + + animchannelTypeInfo[type++]= NULL; /* ShapeKey */ // XXX this is no longer used for now... + + // XXX not restored yet + animchannelTypeInfo[type++]= NULL; /* Grease Pencil Datablock */ + animchannelTypeInfo[type++]= NULL; /* Grease Pencil Layer */ + + // TODO: these types still need to be implemented!!! + // probably need a few extra flags for these special cases... + animchannelTypeInfo[type++]= NULL; /* NLA Track */ + animchannelTypeInfo[type++]= NULL; /* NLA Action */ + } +} + +/* Get type info from given channel type */ +bAnimChannelType *ANIM_channel_get_typeinfo (bAnimListElem *ale) +{ + /* santiy checks */ + if (ale == NULL) + return NULL; + + /* init the typeinfo if not available yet... */ + ANIM_init_channel_typeinfo_data(); + + /* check if type is in bounds... */ + if ((ale->type >= 0) && (ale->type < ANIMTYPE_NUM_TYPES)) + return animchannelTypeInfo[ale->type]; + else + return NULL; +} + +/* --------------------------- */ + +/* Check if some setting for a channel is enabled + * Returns: 1 = On, 0 = Off, -1 = Invalid + */ +short ANIM_channel_setting_get (bAnimContext *ac, bAnimListElem *ale, int setting) +{ + bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale); + + /* 1) check that the setting exists for the current context */ + if ( (acf) && (!acf->has_setting || acf->has_setting(ac, ale, setting)) ) + { + /* 2) get pointer to check for flag in, and the flag to check for */ + short negflag, ptrsize; + int flag; + void *ptr; + + flag= acf->setting_flag(setting, &negflag); + ptr= acf->setting_ptr(ale, setting, &ptrsize); + + /* check if flag is enabled */ + if (ptr && flag) { + switch (ptrsize) { + case sizeof(int): /* integer pointer for setting */ + { + int *val= (int *)ptr; + + if (negflag) + return ((*val) & flag) == 0; + else + return ((*val) & flag) != 0; + } + break; + + case sizeof(short): /* short pointer for setting */ + { + short *val= (short *)ptr; + + if (negflag) + return ((*val) & flag) == 0; + else + return ((*val) & flag) != 0; + } + break; + + case sizeof(char): /* char pointer for setting */ + { + char *val= (char *)ptr; + + if (negflag) + return ((*val) & flag) == 0; + else + return ((*val) & flag) != 0; + } + break; + } + } + } + + /* not found... */ + return -1; +} + + +/* quick macro for use in ANIM_channel_setting_set - set flag for setting according the mode given */ +#define ACF_SETTING_SET(sval, sflag, smode) \ + {\ + if (negflag) {\ + if (smode == ACHANNEL_SETFLAG_TOGGLE) (sval) ^= (sflag); \ + else if (smode == ACHANNEL_SETFLAG_ADD) (sval) &= ~(sflag); \ + else (sval) |= (sflag); \ + } \ + else {\ + if (smode == ACHANNEL_SETFLAG_TOGGLE) (sval) ^= (sflag); \ + else if (smode == ACHANNEL_SETFLAG_ADD) (sval) |= (sflag); \ + else (sval) &= ~(sflag); \ + }\ + } + +/* Change value of some setting for a channel + * - setting: eAnimChannel_Settings + * - mode: eAnimChannels_SetFlag + */ +void ANIM_channel_setting_set (bAnimContext *ac, bAnimListElem *ale, int setting, short mode) +{ + bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale); + + /* 1) check that the setting exists for the current context */ + if ( (acf) && (!acf->has_setting || acf->has_setting(ac, ale, setting)) ) + { + /* 2) get pointer to check for flag in, and the flag to check for */ + short negflag, ptrsize; + int flag; + void *ptr; + + flag= acf->setting_flag(setting, &negflag); + ptr= acf->setting_ptr(ale, setting, &ptrsize); + + /* check if flag is enabled */ + if (ptr && flag) { + switch (ptrsize) { + case sizeof(int): /* integer pointer for setting */ + { + int *val= (int *)ptr; + ACF_SETTING_SET(*val, flag, mode); + } + break; + + case sizeof(short): /* short pointer for setting */ + { + short *val= (short *)ptr; + ACF_SETTING_SET(*val, flag, mode); + } + break; + + case sizeof(char): /* char pointer for setting */ + { + char *val= (char *)ptr; + ACF_SETTING_SET(*val, flag, mode); + } + break; + } + } + } +} + +/* --------------------------- */ + +// XXX hardcoded size of icons +#define ICON_WIDTH 17 +// XXX hardcoded width of sliders +#define SLIDER_WIDTH 70 + +/* Draw the given channel */ +// TODO: make this use UI controls for the buttons +void ANIM_channel_draw (bAnimContext *ac, bAnimListElem *ale, float yminc, float ymaxc) +{ + bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale); + short selected, offset; + float y, ymid, ytext; + + /* sanity checks - don't draw anything */ + if ELEM(NULL, acf, ale) + return; + + /* get initial offset */ + if (acf->get_offset) + offset= acf->get_offset(ac, ale); + else + offset= 0; + + /* calculate appropriate y-coordinates for icon buttons + * 7 is hardcoded factor for half-height of icons + */ + y= (ymaxc - yminc)/2 + yminc; + ymid= y - 7; + /* y-coordinates for text is only 4 down from middle */ + ytext= y - 4; + + /* check if channel is selected */ + if (acf->has_setting(ac, ale, ACHANNEL_SETTING_SELECT)) + selected= ANIM_channel_setting_get(ac, ale, ACHANNEL_SETTING_SELECT); + else + selected= 0; + + /* set blending again, as may not be set in previous step */ + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_BLEND); + + /* step 1) draw backdrop ........................................... */ + if (acf->draw_backdrop) + acf->draw_backdrop(ac, ale, yminc, ymaxc); + + /* step 2) draw expand widget ....................................... */ + if (acf->has_setting(ac, ale, ACHANNEL_SETTING_EXPAND)) { + /* just skip - drawn as widget now */ + offset += ICON_WIDTH; + } + + /* step 3) draw icon ............................................... */ + if (acf->icon) { + UI_icon_draw(offset, ymid, acf->icon(ale)); + offset += ICON_WIDTH; + } + + /* step 4) draw special toggles ................................. + * - in Graph Editor, checkboxes for visibility in curves area + * - in NLA Editor, glowing dots for solo/not solo... + */ + if (ac->sa) { + if ((ac->spacetype == SPACE_IPO) && acf->has_setting(ac, ale, ACHANNEL_SETTING_VISIBLE)) { + /* for F-Curves, draw color-preview of curve behind checkbox */ + if (ale->type == ANIMTYPE_FCURVE) { + FCurve *fcu= (FCurve *)ale->data; + + /* F-Curve channels need to have a special 'color code' box drawn, which is colored with whatever + * color the curve has stored + */ + glColor3fv(fcu->color); + + /* just a solid color rect + * hardcoded 17 pixels width is slightly wider than icon width, so that + * there's a slight border around it + */ + glRectf(offset, yminc, offset+17, ymaxc); + } + + /* icon is drawn as widget now... */ + offset += ICON_WIDTH; + } + else if ((ac->spacetype == SPACE_NLA) && acf->has_setting(ac, ale, ACHANNEL_SETTING_SOLO)) { + /* just skip - drawn as widget now */ + offset += ICON_WIDTH; + } + } + + /* step 5) draw name ............................................... */ + if (acf->name) { + char name[256]; /* hopefully this will be enough! */ + + /* set text color */ + if (selected) + UI_ThemeColor(TH_TEXT_HI); + else + UI_ThemeColor(TH_TEXT); + + /* get name */ + acf->name(ale, name); + + offset += 3; + UI_DrawString(offset, ytext, name); + } +} + +/* ------------------ */ + +/* callback for widget settings - send notifiers */ +static void achannel_setting_widget_cb(bContext *C, void *poin, void *poin2) +{ + WM_event_add_notifier(C, NC_ANIMATION|ND_ANIMCHAN_EDIT, NULL); +} + +/* callback for widget sliders - insert keyframes */ +static void achannel_setting_slider_cb(bContext *C, void *id_poin, void *fcu_poin) +{ + ID *id= (ID *)id_poin; + FCurve *fcu= (FCurve *)fcu_poin; + + Scene *scene= CTX_data_scene(C); + PointerRNA id_ptr, ptr; + PropertyRNA *prop; + short flag=0, done=0; + float cfra; + + /* get current frame */ + // NOTE: this will do for now... + cfra= (float)CFRA; + + /* get flags for keyframing */ + if (IS_AUTOKEY_FLAG(INSERTNEEDED)) + flag |= INSERTKEY_NEEDED; + if (IS_AUTOKEY_FLAG(AUTOMATKEY)) + flag |= INSERTKEY_MATRIX; + + + /* get RNA pointer, and resolve the path */ + RNA_id_pointer_create(id, &id_ptr); + + /* try to resolve the path stored in the F-Curve */ + if (RNA_path_resolve(&id_ptr, fcu->rna_path, &ptr, &prop)) { + /* insert a keyframe for this F-Curve */ + done= insert_keyframe_direct(ptr, prop, fcu, cfra, flag); + + if (done) + WM_event_add_notifier(C, NC_ANIMATION|ND_ANIMCHAN_EDIT, NULL); + } +} + + + +/* Draw a widget for some setting */ +static void draw_setting_widget (bAnimContext *ac, bAnimListElem *ale, bAnimChannelType *acf, uiBlock *block, int xpos, int ypos, int setting) +{ + short negflag, ptrsize, enabled, butType; + int flag, icon; + void *ptr; + char *tooltip; + uiBut *but = NULL; + + /* get the flag and the pointer to that flag */ + flag= acf->setting_flag(setting, &negflag); + ptr= acf->setting_ptr(ale, setting, &ptrsize); + enabled= ANIM_channel_setting_get(ac, ale, setting); + + /* get the base icon for the setting */ + switch (setting) { + case ACHANNEL_SETTING_VISIBLE: /* visibility checkboxes */ + //icon= ((enabled)? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT); + icon= ICON_CHECKBOX_DEHLT; + + if (ale->type == ANIMTYPE_FCURVE) + tooltip= "F-Curve is visible in Graph Editor for editing."; + else + tooltip= "F-Curve(s) are visible in Graph Editor for editing."; + break; + + case ACHANNEL_SETTING_EXPAND: /* expanded triangle */ + //icon= ((enabled)? ICON_TRIA_DOWN : ICON_TRIA_RIGHT); + icon= ICON_TRIA_RIGHT; + tooltip= "Make channels grouped under this channel visible."; + break; + + case ACHANNEL_SETTING_SOLO: /* NLA Tracks only */ + //icon= ((enabled)? ICON_LAYER_ACTIVE : ICON_LAYER_USED); + icon= ICON_LAYER_USED; + tooltip= "NLA Track is the only one evaluated for the AnimData block it belongs to."; + break; + + /* --- */ + + case ACHANNEL_SETTING_PROTECT: /* protected lock */ + // TODO: what about when there's no protect needed? + //icon= ((enabled)? ICON_LOCKED : ICON_UNLOCKED); + icon= ICON_UNLOCKED; + tooltip= "Editability of keyframes for this channel."; + break; + + case ACHANNEL_SETTING_MUTE: /* muted eye */ + //icon= ((enabled)? ICON_MUTE_IPO_ON : ICON_MUTE_IPO_OFF); + icon= ICON_MUTE_IPO_OFF; + + if (ale->type == ALE_FCURVE) + tooltip= "Does F-Curve contribute to result."; + else + tooltip= "Do channels contribute to result."; + break; + + default: + tooltip= NULL; + icon= 0; + break; + } + + /* type of button */ + if (negflag) + butType= ICONTOGN; + else + butType= ICONTOG; + + /* draw button for setting */ + if (ptr && flag) { + switch (ptrsize) { + case sizeof(int): /* integer pointer for setting */ + but= uiDefIconButBitI(block, butType, flag, 0, icon, + xpos, ypos, ICON_WIDTH, ICON_WIDTH, ptr, 0, 0, 0, 0, tooltip); + break; + + case sizeof(short): /* short pointer for setting */ + but= uiDefIconButBitS(block, butType, flag, 0, icon, + xpos, ypos, ICON_WIDTH, ICON_WIDTH, ptr, 0, 0, 0, 0, tooltip); + break; + + case sizeof(char): /* char pointer for setting */ + but= uiDefIconButBitC(block, butType, flag, 0, icon, + xpos, ypos, ICON_WIDTH, ICON_WIDTH, ptr, 0, 0, 0, 0, tooltip); + break; + } + + /* set call to send relevant notifiers */ + // NOTE: for now, we only need to send 'edited' + if (but) + uiButSetFunc(but, achannel_setting_widget_cb, NULL, NULL); + } +} + +/* Draw UI widgets the given channel */ +// TODO: make this use UI controls for the buttons +void ANIM_channel_draw_widgets (bAnimContext *ac, bAnimListElem *ale, uiBlock *block, float yminc, float ymaxc) +{ + bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale); + View2D *v2d= &ac->ar->v2d; + float y, ymid, ytext; + short offset; + + /* sanity checks - don't draw anything */ + if ELEM3(NULL, acf, ale, block) + return; + + /* get initial offset */ + if (acf->get_offset) + offset= acf->get_offset(ac, ale); + else + offset= 0; + + /* calculate appropriate y-coordinates for icon buttons + * 7 is hardcoded factor for half-height of icons + */ + y= (ymaxc - yminc)/2 + yminc; + ymid= y - 7; + /* y-coordinates for text is only 4 down from middle */ + ytext= y - 4; + + /* no button backdrop behind icons */ + uiBlockSetEmboss(block, UI_EMBOSSN); + + /* step 1) draw expand widget ....................................... */ + if (acf->has_setting(ac, ale, ACHANNEL_SETTING_EXPAND)) { + draw_setting_widget(ac, ale, acf, block, offset, ymid, ACHANNEL_SETTING_EXPAND); + offset += ICON_WIDTH; + } + + /* step 2) draw icon ............................................... */ + if (acf->icon) { + /* icon is not drawn here (not a widget) */ + offset += ICON_WIDTH; + } + + /* step 3) draw special toggles ................................. + * - in Graph Editor, checkboxes for visibility in curves area + * - in NLA Editor, glowing dots for solo/not solo... + */ + if (ac->sa) { + if ((ac->spacetype == SPACE_IPO) && acf->has_setting(ac, ale, ACHANNEL_SETTING_VISIBLE)) { + /* visibility toggle */ + draw_setting_widget(ac, ale, acf, block, offset, ymid, ACHANNEL_SETTING_VISIBLE); + offset += ICON_WIDTH; + } + else if ((ac->spacetype == SPACE_NLA) && acf->has_setting(ac, ale, ACHANNEL_SETTING_SOLO)) { + /* 'solo' setting for NLA Tracks */ + draw_setting_widget(ac, ale, acf, block, offset, ymid, ACHANNEL_SETTING_SOLO); + offset += ICON_WIDTH; + } + } + + /* step 4) draw text... */ + /* NOTE: this is not done here, since nothing to be clicked on... */ + + /* step 5) draw mute+protection toggles + (sliders) ....................... */ + /* reset offset - now goes from RHS of panel */ + offset = 0; + + // TODO: when drawing sliders, make those draw instead of these toggles if not enough space + + if (v2d) { + short draw_sliders = 0; + + /* check if we need to show the sliders */ + if ((ac->sa) && ELEM(ac->spacetype, SPACE_ACTION, SPACE_IPO)) { + switch (ac->spacetype) { + case SPACE_ACTION: + { + SpaceAction *saction= (SpaceAction *)ac->sa->spacedata.first; + draw_sliders= (saction->flag & SACTION_SLIDERS); + } + break; + case SPACE_IPO: + { + SpaceIpo *sipo= (SpaceIpo *)ac->sa->spacedata.first; + draw_sliders= (sipo->flag & SIPO_SLIDERS); + } + break; + } + } + + /* check if there's enough space for the toggles if the sliders are drawn too */ + if ( !(draw_sliders) || ((v2d->mask.xmax-v2d->mask.xmin) > ACHANNEL_BUTTON_WIDTH/2) ) { + /* protect... */ + if (acf->has_setting(ac, ale, ACHANNEL_SETTING_PROTECT)) { + offset += ICON_WIDTH; + draw_setting_widget(ac, ale, acf, block, (int)v2d->cur.xmax-offset, ymid, ACHANNEL_SETTING_PROTECT); + } + /* mute... */ + if (acf->has_setting(ac, ale, ACHANNEL_SETTING_MUTE)) { + offset += ICON_WIDTH; + draw_setting_widget(ac, ale, acf, block, (int)v2d->cur.xmax-offset, ymid, ACHANNEL_SETTING_MUTE); + } + } + + /* draw slider + * - even if we can draw sliders for this view, we must also check that the channel-type supports them + * (only only F-Curves really can support them for now) + * - to make things easier, we use RNA-autobuts for this so that changes are reflected immediately, + * whereever they occurred. BUT, we don't use the layout engine, otherwise we'd get wrong alignment, + * and wouldn't be able to auto-keyframe... + * - slider should start before the toggles (if they're visible) to keep a clean line down the side + */ + if ((draw_sliders) && (ale->type == ANIMTYPE_FCURVE)) { + /* adjust offset */ + offset += SLIDER_WIDTH; + + /* need backdrop behind sliders... */ + uiBlockSetEmboss(block, UI_EMBOSS); + + if (ale->id) { /* Slider using RNA Access -------------------- */ + FCurve *fcu= (FCurve *)ale->data; + PointerRNA id_ptr, ptr; + PropertyRNA *prop; + + /* get RNA pointer, and resolve the path */ + RNA_id_pointer_create(ale->id, &id_ptr); + + /* try to resolve the path */ + if (RNA_path_resolve(&id_ptr, fcu->rna_path, &ptr, &prop)) { + uiBut *but; + + /* create the slider button, and assign relevant callback to ensure keyframes are inserted... */ + but= uiDefAutoButR(block, &ptr, prop, fcu->array_index, "", 0, (int)v2d->cur.xmax-offset, ymid, SLIDER_WIDTH, (int)ymaxc-yminc); + uiButSetFunc(but, achannel_setting_slider_cb, ale->id, fcu); + } + } + else { /* Special Slider for stuff without RNA Access ---------- */ + // TODO: only implement this case when we really need it... + } + } + } +} + +/* *********************************************** */ diff --git a/source/blender/editors/animation/anim_channels.c b/source/blender/editors/animation/anim_channels_edit.c index 235a3039b2c..72d8f71bc26 100644 --- a/source/blender/editors/animation/anim_channels.c +++ b/source/blender/editors/animation/anim_channels_edit.c @@ -17,11 +17,9 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * The Original Code is Copyright (C) 2009 Blender Foundation, Joshua Leung * All rights reserved. * - * The Original Code is: all of this file. - * * Contributor(s): Joshua Leung * * ***** END GPL LICENSE BLOCK ***** @@ -884,14 +882,6 @@ void ANIM_OT_channels_visibility_toggle (wmOperatorType *ot) /* ********************** Set Flags Operator *********************** */ -enum { -// ACHANNEL_SETTING_SELECT = 0, - ACHANNEL_SETTING_PROTECT = 1, - ACHANNEL_SETTING_MUTE, - ACHANNEL_SETTING_VISIBLE, - ACHANNEL_SETTING_EXPAND, -} eAnimChannel_Settings; - /* defines for setting animation-channel flags */ EnumPropertyItem prop_animchannel_setflag_types[] = { {ACHANNEL_SETFLAG_CLEAR, "DISABLE", 0, "Disable", ""}, @@ -901,6 +891,7 @@ EnumPropertyItem prop_animchannel_setflag_types[] = { }; /* defines for set animation-channel settings */ +// TODO: could add some more types, but those are really quite dependent on the mode... EnumPropertyItem prop_animchannel_settings_types[] = { {ACHANNEL_SETTING_PROTECT, "PROTECT", 0, "Protect", ""}, {ACHANNEL_SETTING_MUTE, "MUTE", 0, "Mute", ""}, @@ -932,213 +923,8 @@ static void setflag_anim_channels (bAnimContext *ac, short setting, short mode, /* affect selected channels */ for (ale= anim_data.first; ale; ale= ale->next) { - switch (ale->type) { - case ANIMTYPE_OBJECT: - { - Base *base= (Base *)ale->data; - Object *ob= base->object; - - if (setting == ACHANNEL_SETTING_EXPAND) { - // XXX - settings should really be moved out of ob->nlaflag - if (mode == ACHANNEL_SETFLAG_TOGGLE) ob->nlaflag ^= OB_ADS_COLLAPSED; - else if (mode == ACHANNEL_SETFLAG_ADD) ob->nlaflag &= ~OB_ADS_COLLAPSED; - else ob->nlaflag |= OB_ADS_COLLAPSED; - } - } - break; - - case ANIMTYPE_FILLACTD: - { - bAction *act= (bAction *)ale->data; - - if (ASUBCHANNEL_SEL_OK(ale)) { - if (setting == ACHANNEL_SETTING_EXPAND) { - ACHANNEL_SET_FLAG_NEG(act, mode, ACT_COLLAPSED); - } - } - } - break; - case ANIMTYPE_FILLDRIVERS: - { - AnimData *adt= (AnimData *)ale->data; - - if (ASUBCHANNEL_SEL_OK(ale)) { - if (setting == ACHANNEL_SETTING_EXPAND) { - ACHANNEL_SET_FLAG_NEG(adt, mode, ADT_DRIVERS_COLLAPSED); - } - } - } - break; - case ANIMTYPE_FILLMATD: - { - Object *ob= (Object *)ale->data; - - // XXX - settings should really be moved out of ob->nlaflag - if ((onlysel == 0) || (ob->flag & SELECT)) { - if (setting == ACHANNEL_SETTING_EXPAND) { - if (mode == ACHANNEL_SETFLAG_TOGGLE) ob->nlaflag ^= OB_ADS_SHOWMATS; - else if (mode == ACHANNEL_SETFLAG_ADD) ob->nlaflag |= OB_ADS_SHOWMATS; - else ob->nlaflag &= ~OB_ADS_SHOWMATS; - } - } - } - break; - case ANIMTYPE_FILLPARTD: - { - Object *ob= (Object *)ale->data; - - // XXX - settings should really be moved out of ob->nlaflag - if ((onlysel == 0) || (ob->flag & SELECT)) { - if (setting == ACHANNEL_SETTING_EXPAND) { - if (mode == ACHANNEL_SETFLAG_TOGGLE) ob->nlaflag ^= OB_ADS_SHOWPARTS; - else if (mode == ACHANNEL_SETFLAG_ADD) ob->nlaflag |= OB_ADS_SHOWPARTS; - else ob->nlaflag &= ~OB_ADS_SHOWPARTS; - } - } - } - break; - - case ANIMTYPE_DSMAT: - { - Material *ma= (Material *)ale->data; - - if (ASUBCHANNEL_SEL_OK(ale)) { - if (setting == ACHANNEL_SETTING_EXPAND) { - ACHANNEL_SET_FLAG(ma, mode, MA_DS_EXPAND); - } - } - } - break; - case ANIMTYPE_DSLAM: - { - Lamp *la= (Lamp *)ale->data; - - if (ASUBCHANNEL_SEL_OK(ale)) { - if (setting == ACHANNEL_SETTING_EXPAND) { - ACHANNEL_SET_FLAG(la, mode, LA_DS_EXPAND); - } - } - } - break; - case ANIMTYPE_DSCAM: - { - Camera *ca= (Camera *)ale->data; - - if (ASUBCHANNEL_SEL_OK(ale)) { - if (setting == ACHANNEL_SETTING_EXPAND) { - ACHANNEL_SET_FLAG(ca, mode, CAM_DS_EXPAND); - } - } - } - break; - case ANIMTYPE_DSCUR: - { - Curve *cu= (Curve *)ale->data; - - if (ASUBCHANNEL_SEL_OK(ale)) { - if (setting == ACHANNEL_SETTING_EXPAND) { - ACHANNEL_SET_FLAG(cu, mode, CU_DS_EXPAND); - } - } - } - break; - case ANIMTYPE_DSSKEY: - { - Key *key= (Key *)ale->data; - - if (ASUBCHANNEL_SEL_OK(ale)) { - if (setting == ACHANNEL_SETTING_EXPAND) { - ACHANNEL_SET_FLAG(key, mode, KEYBLOCK_DS_EXPAND); - } - } - } - break; - case ANIMTYPE_DSWOR: - { - World *wo= (World *)ale->data; - - if (ASUBCHANNEL_SEL_OK(ale)) { - if (setting == ACHANNEL_SETTING_EXPAND) { - ACHANNEL_SET_FLAG(wo, mode, WO_DS_EXPAND); - } - } - } - break; - case ANIMTYPE_DSPART: - { - ParticleSettings *part= (ParticleSettings*)ale->data; - - if (ASUBCHANNEL_SEL_OK(ale)) { - if (setting == ACHANNEL_SETTING_EXPAND) { - ACHANNEL_SET_FLAG(part, mode, PART_DS_EXPAND); - } - } - } - break; - case ANIMTYPE_DSMBALL: - { - MetaBall *mb= (MetaBall *)ale->data; - - if (ASUBCHANNEL_SEL_OK(ale)) { - if (setting == ACHANNEL_SETTING_EXPAND) { - ACHANNEL_SET_FLAG(mb, mode, MB_DS_EXPAND); - } - } - } - break; - - case ANIMTYPE_GROUP: - { - bActionGroup *agrp= (bActionGroup *)ale->data; - - switch (setting) { - case ACHANNEL_SETTING_PROTECT: - ACHANNEL_SET_FLAG(agrp, mode, AGRP_PROTECTED); - break; - case ACHANNEL_SETTING_EXPAND: - ACHANNEL_SET_FLAG(agrp, mode, AGRP_EXPANDED); - break; - case ACHANNEL_SETTING_MUTE: - ACHANNEL_SET_FLAG(agrp, mode, AGRP_MUTED); - break; - case ACHANNEL_SETTING_VISIBLE: - ACHANNEL_SET_FLAG_NEG(agrp, mode, AGRP_NOTVISIBLE); - break; - } - } - break; - case ANIMTYPE_FCURVE: - { - FCurve *fcu= (FCurve *)ale->data; - - switch (setting) { - case ACHANNEL_SETTING_MUTE: - ACHANNEL_SET_FLAG(fcu, mode, FCURVE_MUTED); - break; - case ACHANNEL_SETTING_PROTECT: - ACHANNEL_SET_FLAG(fcu, mode, FCURVE_PROTECTED); - break; - case ACHANNEL_SETTING_VISIBLE: - ACHANNEL_SET_FLAG(fcu, mode, FCURVE_VISIBLE); - break; - } - } - break; - case ANIMTYPE_GPLAYER: - { - bGPDlayer *gpl= (bGPDlayer *)ale->data; - - switch (setting) { - case ACHANNEL_SETTING_MUTE: - ACHANNEL_SET_FLAG(gpl, mode, GP_LAYER_HIDE); - break; - case ACHANNEL_SETTING_PROTECT: - ACHANNEL_SET_FLAG(gpl, mode, GP_LAYER_LOCKED); - break; - } - } - break; - } + /* set the setting in the appropriate way (if available) */ + ANIM_channel_setting_set(ac, ale, setting, mode); } BLI_freelistN(&anim_data); @@ -1407,47 +1193,19 @@ static void borderselect_anim_channels (bAnimContext *ac, rcti *rect, short sele /* if channel is within border-select region, alter it */ if (!((ymax < rectf.ymin) || (ymin > rectf.ymax))) { - /* only the following types can be selected */ + /* set selection flags only */ + ANIM_channel_setting_set(ac, ale, ACHANNEL_SETTING_SELECT, selectmode); + + /* type specific actions */ switch (ale->type) { - case ANIMTYPE_OBJECT: /* object */ - { - Base *base= (Base *)ale->data; - Object *ob= base->object; - - ACHANNEL_SET_FLAG(base, selectmode, SELECT); - ACHANNEL_SET_FLAG(ob, selectmode, SELECT); - } - break; - case ANIMTYPE_GROUP: /* action group */ + case ANIMTYPE_GROUP: { bActionGroup *agrp= (bActionGroup *)ale->data; - ACHANNEL_SET_FLAG(agrp, selectmode, AGRP_SELECTED); + /* always clear active flag after doing this */ agrp->flag &= ~AGRP_ACTIVE; } break; - case ANIMTYPE_FCURVE: /* F-Curve channel */ - { - FCurve *fcu = (FCurve *)ale->data; - - ACHANNEL_SET_FLAG(fcu, selectmode, FCURVE_SELECTED); - } - break; - case ANIMTYPE_GPLAYER: /* grease-pencil layer */ - { - bGPDlayer *gpl = (bGPDlayer *)ale->data; - - ACHANNEL_SET_FLAG(gpl, selectmode, GP_LAYER_SELECT); - } - break; - - case ANIMTYPE_NLATRACK: /* nla-track */ - { - NlaTrack *nlt= (NlaTrack *)ale->data; - - ACHANNEL_SET_FLAG(nlt, selectmode, NLATRACK_SELECTED); - } - break; } } @@ -1519,11 +1277,7 @@ void ANIM_OT_channels_select_border(wmOperatorType *ot) } /* ******************** Mouse-Click Operator *********************** */ -/* Depending on the channel that was clicked on, the mouse click will activate whichever - * part of the channel is relevant. - * - * NOTE: eventually, this should probably be phased out when many of these things are replaced with buttons - */ +/* Handle selection changes due to clicking on channels. Settings will get caught by UI code... */ static int mouse_anim_channels (bAnimContext *ac, float x, int channel_index, short selectmode) { @@ -1561,24 +1315,16 @@ static int mouse_anim_channels (bAnimContext *ac, float x, int channel_index, sh { Scene *sce= (Scene *)ale->data; - if (x < 16) { - /* toggle expand */ - sce->flag ^= SCE_DS_COLLAPSED; - - notifierFlags |= ND_ANIMCHAN_EDIT; + /* set selection status */ + if (selectmode == SELECT_INVERT) { + /* swap select */ + sce->flag ^= SCE_DS_SELECTED; } else { - /* set selection status */ - if (selectmode == SELECT_INVERT) { - /* swap select */ - sce->flag ^= SCE_DS_SELECTED; - } - else { - sce->flag |= SCE_DS_SELECTED; - } - - notifierFlags |= ND_ANIMCHAN_SELECT; + sce->flag |= SCE_DS_SELECTED; } + + notifierFlags |= ND_ANIMCHAN_SELECT; } break; case ANIMTYPE_OBJECT: @@ -1588,233 +1334,87 @@ static int mouse_anim_channels (bAnimContext *ac, float x, int channel_index, sh Base *base= (Base *)ale->data; Object *ob= base->object; - if (x < 16) { - /* toggle expand */ - ob->nlaflag ^= OB_ADS_COLLAPSED; // XXX - - notifierFlags |= ND_ANIMCHAN_EDIT; + /* set selection status */ + if (selectmode == SELECT_INVERT) { + /* swap select */ + base->flag ^= SELECT; + ob->flag= base->flag; } else { - /* set selection status */ - if (selectmode == SELECT_INVERT) { - /* swap select */ - base->flag ^= SELECT; - ob->flag= base->flag; - } - else { - Base *b; - - /* deleselect all */ - for (b= sce->base.first; b; b= b->next) { - b->flag &= ~SELECT; - b->object->flag= b->flag; - } - - /* select object now */ - base->flag |= SELECT; - ob->flag |= SELECT; - } + Base *b; - /* xxx should be ED_base_object_activate(), but we need context pointer for that... */ - //set_active_base(base); + /* deleselect all */ + for (b= sce->base.first; b; b= b->next) { + b->flag &= ~SELECT; + b->object->flag= b->flag; + } - notifierFlags |= ND_ANIMCHAN_SELECT; + /* select object now */ + base->flag |= SELECT; + ob->flag |= SELECT; } - } - break; - case ANIMTYPE_FILLACTD: - { - bAction *act= (bAction *)ale->data; - act->flag ^= ACT_COLLAPSED; - notifierFlags |= ND_ANIMCHAN_EDIT; - } - break; - case ANIMTYPE_FILLDRIVERS: - { - AnimData *adt= (AnimData* )ale->data; - adt->flag ^= ADT_DRIVERS_COLLAPSED; - notifierFlags |= ND_ANIMCHAN_EDIT; - } - break; - case ANIMTYPE_FILLMATD: - { - Object *ob= (Object *)ale->data; - ob->nlaflag ^= OB_ADS_SHOWMATS; // XXX - notifierFlags |= ND_ANIMCHAN_EDIT; - } - break; - case ANIMTYPE_FILLPARTD: - { - Object *ob= (Object *)ale->data; - ob->nlaflag ^= OB_ADS_SHOWPARTS; // XXX - notifierFlags |= ND_ANIMCHAN_EDIT; - } - break; - - case ANIMTYPE_DSMAT: - { - Material *ma= (Material *)ale->data; - ma->flag ^= MA_DS_EXPAND; - notifierFlags |= ND_ANIMCHAN_EDIT; - } - break; - case ANIMTYPE_DSLAM: - { - Lamp *la= (Lamp *)ale->data; - la->flag ^= LA_DS_EXPAND; - notifierFlags |= ND_ANIMCHAN_EDIT; - } - break; - case ANIMTYPE_DSCAM: - { - Camera *ca= (Camera *)ale->data; - ca->flag ^= CAM_DS_EXPAND; - notifierFlags |= ND_ANIMCHAN_EDIT; - } - break; - case ANIMTYPE_DSCUR: - { - Curve *cu= (Curve *)ale->data; - cu->flag ^= CU_DS_EXPAND; - notifierFlags |= ND_ANIMCHAN_EDIT; - } - break; - case ANIMTYPE_DSSKEY: - { - Key *key= (Key *)ale->data; - key->flag ^= KEYBLOCK_DS_EXPAND; - notifierFlags |= ND_ANIMCHAN_EDIT; - } - break; - case ANIMTYPE_DSWOR: - { - World *wo= (World *)ale->data; - wo->flag ^= WO_DS_EXPAND; - notifierFlags |= ND_ANIMCHAN_EDIT; - } - break; - case ANIMTYPE_DSPART: - { - ParticleSettings *part= (ParticleSettings *)ale->data; - part->flag ^= PART_DS_EXPAND; - notifierFlags |= ND_ANIMCHAN_EDIT; - } - break; - case ANIMTYPE_DSMBALL: - { - MetaBall *mb= (MetaBall *)ale->data; - mb->flag2 ^= MB_DS_EXPAND; - notifierFlags |= ND_ANIMCHAN_EDIT; + + /* xxx should be ED_base_object_activate(), but we need context pointer for that... */ + //set_active_base(base); + + notifierFlags |= ND_ANIMCHAN_SELECT; } break; case ANIMTYPE_GROUP: { bActionGroup *agrp= (bActionGroup *)ale->data; - short offset= (ELEM3(ac->datatype, ANIMCONT_DOPESHEET, ANIMCONT_FCURVES, ANIMCONT_DRIVERS))? 18 : 0; - if ((x < (offset+17)) && (agrp->channels.first)) { - /* toggle expand */ - agrp->flag ^= AGRP_EXPANDED; - notifierFlags |= ND_ANIMCHAN_EDIT; - } - else if ((x < (offset+32)) && (ac->spacetype==SPACE_IPO)) { - /* toggle visibility (of grouped F-Curves in Graph editor) */ - agrp->flag ^= AGRP_NOTVISIBLE; - notifierFlags |= ND_ANIMCHAN_EDIT; - } - else if (x >= (ACHANNEL_NAMEWIDTH-ACHANNEL_BUTTON_WIDTH)) { - /* toggle protection/locking */ - agrp->flag ^= AGRP_PROTECTED; - notifierFlags |= ND_ANIMCHAN_EDIT; + /* select/deselect group */ + if (selectmode == SELECT_INVERT) { + /* inverse selection status of this group only */ + agrp->flag ^= AGRP_SELECTED; } - else if (x >= (ACHANNEL_NAMEWIDTH-2*ACHANNEL_BUTTON_WIDTH)) { - /* toggle mute */ - agrp->flag ^= AGRP_MUTED; - notifierFlags |= ND_ANIMCHAN_EDIT; + else if (selectmode == -1) { + /* select all in group (and deselect everthing else) */ + FCurve *fcu; + + /* deselect all other channels */ + ANIM_deselect_anim_channels(ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR); + + /* only select channels in group and group itself */ + for (fcu= agrp->channels.first; fcu && fcu->grp==agrp; fcu= fcu->next) + fcu->flag |= FCURVE_SELECTED; + agrp->flag |= AGRP_SELECTED; } else { - /* select/deselect group */ - if (selectmode == SELECT_INVERT) { - /* inverse selection status of this group only */ - agrp->flag ^= AGRP_SELECTED; - } - else if (selectmode == -1) { - /* select all in group (and deselect everthing else) */ - FCurve *fcu; - - /* deselect all other channels */ - ANIM_deselect_anim_channels(ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR); - - /* only select channels in group and group itself */ - for (fcu= agrp->channels.first; fcu && fcu->grp==agrp; fcu= fcu->next) - fcu->flag |= FCURVE_SELECTED; - agrp->flag |= AGRP_SELECTED; - } - else { - /* select group by itself */ - ANIM_deselect_anim_channels(ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR); - agrp->flag |= AGRP_SELECTED; - } - - /* if group is selected now, make group the 'active' one in the visible list */ - if (agrp->flag & AGRP_SELECTED) - ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, agrp, ANIMTYPE_GROUP); - - notifierFlags |= ND_ANIMCHAN_SELECT; + /* select group by itself */ + ANIM_deselect_anim_channels(ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR); + agrp->flag |= AGRP_SELECTED; } + + /* if group is selected now, make group the 'active' one in the visible list */ + if (agrp->flag & AGRP_SELECTED) + ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, agrp, ANIMTYPE_GROUP); + + notifierFlags |= ND_ANIMCHAN_SELECT; } break; case ANIMTYPE_FCURVE: { FCurve *fcu= (FCurve *)ale->data; - short offset; - - if (ac->datatype != ANIMCONT_ACTION) { - /* for now, special case for materials */ - if (ale->ownertype == ANIMTYPE_DSMAT) - offset= 21; - else - offset= 18; - } - else - offset = 0; - if (x >= (ACHANNEL_NAMEWIDTH-ACHANNEL_BUTTON_WIDTH)) { - /* toggle protection (only if there's a toggle there) */ - if (fcu->bezt) { - fcu->flag ^= FCURVE_PROTECTED; - notifierFlags |= ND_ANIMCHAN_EDIT; - } - } - else if (x >= (ACHANNEL_NAMEWIDTH-2*ACHANNEL_BUTTON_WIDTH)) { - /* toggle mute */ - fcu->flag ^= FCURVE_MUTED; - notifierFlags |= ND_ANIMCHAN_EDIT; - } - else if ((x < (offset+17)) && (ac->spacetype==SPACE_IPO)) { - /* toggle visibility */ - fcu->flag ^= FCURVE_VISIBLE; - notifierFlags |= ND_ANIMCHAN_EDIT; + /* select/deselect */ + if (selectmode == SELECT_INVERT) { + /* inverse selection status of this F-Curve only */ + fcu->flag ^= FCURVE_SELECTED; } else { - /* select/deselect */ - if (selectmode == SELECT_INVERT) { - /* inverse selection status of this F-Curve only */ - fcu->flag ^= FCURVE_SELECTED; - } - else { - /* select F-Curve by itself */ - ANIM_deselect_anim_channels(ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR); - fcu->flag |= FCURVE_SELECTED; - } - - /* if F-Curve is selected now, make F-Curve the 'active' one in the visible list */ - if (fcu->flag & FCURVE_SELECTED) - ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, fcu, ANIMTYPE_FCURVE); - - notifierFlags |= ND_ANIMCHAN_SELECT; + /* select F-Curve by itself */ + ANIM_deselect_anim_channels(ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR); + fcu->flag |= FCURVE_SELECTED; } + + /* if F-Curve is selected now, make F-Curve the 'active' one in the visible list */ + if (fcu->flag & FCURVE_SELECTED) + ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, fcu, ANIMTYPE_FCURVE); + + notifierFlags |= ND_ANIMCHAN_SELECT; } break; case ANIMTYPE_GPDATABLOCK: diff --git a/source/blender/editors/animation/anim_deps.c b/source/blender/editors/animation/anim_deps.c index 13667159fe0..af2355b91a5 100644 --- a/source/blender/editors/animation/anim_deps.c +++ b/source/blender/editors/animation/anim_deps.c @@ -138,6 +138,7 @@ void ANIM_action_to_pose_sync (Object *ob) */ void ANIM_pose_to_action_sync (Object *ob, ScrArea *sa) { +#if 0 // XXX old animation system SpaceAction *saction= (SpaceAction *)sa->spacedata.first; bArmature *arm= (bArmature *)ob->data; bAction *act= (bAction *)ob->action; @@ -174,4 +175,5 @@ void ANIM_pose_to_action_sync (Object *ob, ScrArea *sa) // XXX step 2 needs to be coded still... currently missing action/bone group API to do any more work here... // XXX step 3 needs to be coded still... it's a messy case to deal with (we'll use the temp indices for this?) +#endif // XXX old animation system } diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c index 4797c7946a4..37c8aeac13a 100644 --- a/source/blender/editors/animation/anim_filter.c +++ b/source/blender/editors/animation/anim_filter.c @@ -374,27 +374,29 @@ short ANIM_animdata_get_context (const bContext *C, bAnimContext *ac) */ #define ANIMDATA_FILTER_CASES(id, adtOk, nlaOk, driversOk, keysOk) \ {\ - if (filter_mode & ANIMFILTER_ANIMDATA) {\ - if ((id)->adt) {\ - adtOk\ - }\ - }\ - else if (ads->filterflag & ADS_FILTER_ONLYNLA) {\ - if (ANIMDATA_HAS_NLA(id)) {\ - nlaOk\ - }\ - else if (!(ads->filterflag & ADS_FILTER_NLA_NOACT) && ANIMDATA_HAS_KEYS(id)) {\ - nlaOk\ - }\ - }\ - else if (ads->filterflag & ADS_FILTER_ONLYDRIVERS) {\ - if (ANIMDATA_HAS_DRIVERS(id)) {\ - driversOk\ - }\ - }\ - else {\ - if (ANIMDATA_HAS_KEYS(id)) {\ - keysOk\ + if ((id)->adt) {\ + if (!(filter_mode & ANIMFILTER_CURVEVISIBLE) || !((id)->adt->flag & ADT_CURVES_NOT_VISIBLE)) {\ + if (filter_mode & ANIMFILTER_ANIMDATA) {\ + adtOk\ + }\ + else if (ads->filterflag & ADS_FILTER_ONLYNLA) {\ + if (ANIMDATA_HAS_NLA(id)) {\ + nlaOk\ + }\ + else if (!(ads->filterflag & ADS_FILTER_NLA_NOACT) && ANIMDATA_HAS_KEYS(id)) {\ + nlaOk\ + }\ + }\ + else if (ads->filterflag & ADS_FILTER_ONLYDRIVERS) {\ + if (ANIMDATA_HAS_DRIVERS(id)) {\ + driversOk\ + }\ + }\ + else {\ + if (ANIMDATA_HAS_KEYS(id)) {\ + keysOk\ + }\ + }\ }\ }\ } @@ -1465,6 +1467,14 @@ static int animdata_filter_dopesheet (ListBase *anim_data, bDopeSheet *ads, int worOk= !(ads->filterflag & ADS_FILTER_NOWOR);) } + /* if only F-Curves with visible flags set can be shown, check that + * datablocks haven't been set to invisible + */ + if (filter_mode & ANIMFILTER_CURVEVISIBLE) { + if ((sce->adt) && (sce->adt->flag & ADT_CURVES_NOT_VISIBLE)) + sceOk= worOk= 0; + } + /* check if not all bad (i.e. so there is something to show) */ if ( !(!sceOk && !worOk) ) { /* add scene data to the list of filtered channels */ @@ -1481,7 +1491,7 @@ static int animdata_filter_dopesheet (ListBase *anim_data, bDopeSheet *ads, int Key *key= ob_get_key(ob); short actOk=1, keyOk=1, dataOk=1, matOk=1, partOk=1; - /* firstly, check if object can be included, by the following fanimors: + /* firstly, check if object can be included, by the following factors: * - if only visible, must check for layer and also viewport visibility * - if only selected, must check if object is selected * - there must be animation data to edit @@ -1495,6 +1505,14 @@ static int animdata_filter_dopesheet (ListBase *anim_data, bDopeSheet *ads, int if (ob->restrictflag & OB_RESTRICT_VIEW) continue; } + /* if only F-Curves with visible flags set can be shown, check that + * datablock hasn't been set to invisible + */ + if (filter_mode & ANIMFILTER_CURVEVISIBLE) { + if ((ob->adt) && (ob->adt->flag & ADT_CURVES_NOT_VISIBLE)) + continue; + } + /* additionally, dopesheet filtering also affects what objects to consider */ if (ads->filterflag) { /* check selection and object type filters */ diff --git a/source/blender/editors/animation/anim_ipo_utils.c b/source/blender/editors/animation/anim_ipo_utils.c index aecf437a30b..26edf930f0b 100644 --- a/source/blender/editors/animation/anim_ipo_utils.c +++ b/source/blender/editors/animation/anim_ipo_utils.c @@ -93,9 +93,8 @@ int geticon_anim_blocktype(short blocktype) } /* Write into "name" buffer, the name of the property (retrieved using RNA from the curve's settings) - * WARNING: name buffer we're writing to cannot exceed 128 chars (check action_draw.c for details) + * WARNING: name buffer we're writing to cannot exceed 256 chars (check anim_channels_defines.c for details) */ -// TODO: have an extra var to indicate if prop was valid? void getname_anim_fcurve(char *name, ID *id, FCurve *fcu) { /* sanity checks */ @@ -148,26 +147,14 @@ void getname_anim_fcurve(char *name, ID *id, FCurve *fcu) propname= (char *)RNA_property_ui_name(prop); /* Array Index - only if applicable */ - if (RNA_property_array_length(prop)) { - static char *vectoritem[4]= {"X ", "Y ", "Z ", "W "}; - static char *quatitem[4]= {"W ", "X ", "Y ", "Z "}; - static char *coloritem[4]= {"R ", "G ", "B ", "A "}; + if (RNA_property_array_length(&ptr, prop)) { + char c= RNA_property_array_item_char(prop, fcu->array_index); - int tot= RNA_property_array_length(prop); - int propsubtype= RNA_property_subtype(prop); - - /* get string to use for array index */ - if ((tot == 4) && (propsubtype == PROP_ROTATION)) - arrayname= quatitem[fcu->array_index]; - else if ( (tot <= 4) && ((propsubtype == PROP_VECTOR) || (propsubtype == PROP_ROTATION)) ) - arrayname= vectoritem[fcu->array_index]; - else if ((tot <= 4) && (propsubtype == PROP_COLOR)) - arrayname= coloritem[fcu->array_index]; - else { - /* we need to write the index to a temp buffer (in py syntax), as it is a number... */ - sprintf(arrayindbuf, "[%d]", fcu->array_index); - arrayname= &arrayindbuf[0]; - } + /* we need to write the index to a temp buffer (in py syntax) */ + if(c) sprintf(arrayindbuf, "%c ", c); + else sprintf(arrayindbuf, "[%d]", fcu->array_index); + + arrayname= &arrayindbuf[0]; } else { /* no array index */ diff --git a/source/blender/editors/animation/anim_ops.c b/source/blender/editors/animation/anim_ops.c index 9c039693b72..72fee937e25 100644 --- a/source/blender/editors/animation/anim_ops.c +++ b/source/blender/editors/animation/anim_ops.c @@ -56,6 +56,8 @@ #include "ED_markers.h" #include "ED_screen.h" +#include "BKE_sound.h" + /* ********************** frame change operator ***************************/ /* Set any flags that are necessary to indicate modal time-changing operation */ @@ -91,6 +93,8 @@ static void change_frame_apply(bContext *C, wmOperator *op) if (cfra < MINAFRAME) cfra= MINAFRAME; CFRA= cfra; + sound_scrub(C); + WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene); } @@ -121,6 +125,7 @@ static int change_frame_exec(bContext *C, wmOperator *op) change_frame_apply(C, op); change_frame_exit(C, op); + return OPERATOR_FINISHED; } @@ -393,9 +398,6 @@ void ED_operatortypes_anim(void) WM_operatortype_append(ANIM_OT_add_driver_button); WM_operatortype_append(ANIM_OT_remove_driver_button); - - WM_operatortype_append(ANIM_OT_keyingset_add_new); - WM_operatortype_append(ANIM_OT_keyingset_add_destination); } void ED_keymap_anim(wmWindowManager *wm) diff --git a/source/blender/editors/animation/drivers.c b/source/blender/editors/animation/drivers.c index 849e2d2eede..e7b7d785d7b 100644 --- a/source/blender/editors/animation/drivers.c +++ b/source/blender/editors/animation/drivers.c @@ -157,7 +157,7 @@ short ANIM_add_driver (ID *id, const char rna_path[], int array_index, short fla /* fill in current value for python */ if(type == DRIVER_TYPE_PYTHON) { PropertyType proptype= RNA_property_type(prop); - int array= RNA_property_array_length(prop); + int array= RNA_property_array_length(&ptr, prop); char *expression= fcu->driver->expression; int val, maxlen= sizeof(fcu->driver->expression); float fval; @@ -241,7 +241,7 @@ static int add_driver_button_exec (bContext *C, wmOperator *op) if (path) { if (all) { - length= RNA_property_array_length(prop); + length= RNA_property_array_length(&ptr, prop); if (length) index= 0; else length= 1; @@ -303,7 +303,7 @@ static int remove_driver_button_exec (bContext *C, wmOperator *op) if (path) { if (all) { - length= RNA_property_array_length(prop); + length= RNA_property_array_length(&ptr, prop); if(length) index= 0; else length= 1; diff --git a/source/blender/editors/animation/fmodifier_ui.c b/source/blender/editors/animation/fmodifier_ui.c index 7a618f4d222..4aff26105f3 100644 --- a/source/blender/editors/animation/fmodifier_ui.c +++ b/source/blender/editors/animation/fmodifier_ui.c @@ -258,14 +258,14 @@ static void draw_modifier__fn_generator(uiLayout *layout, ID *id, FModifier *fcm /* add the settings */ col= uiLayoutColumn(layout, 1); - uiItemR(col, "", 0, &ptr, "type", 0, 0, 0); - uiItemR(col, NULL, 0, &ptr, "additive", 0, 0, 1); + uiItemR(col, "", 0, &ptr, "type", 0); + uiItemR(col, NULL, 0, &ptr, "additive", UI_ITEM_R_TOGGLE); col= uiLayoutColumn(layout, 0); // no grouping for now - uiItemR(col, NULL, 0, &ptr, "amplitude", 0, 0, 0); - uiItemR(col, NULL, 0, &ptr, "phase_multiplier", 0, 0, 0); - uiItemR(col, NULL, 0, &ptr, "phase_offset", 0, 0, 0); - uiItemR(col, NULL, 0, &ptr, "value_offset", 0, 0, 0); + uiItemR(col, NULL, 0, &ptr, "amplitude", 0); + uiItemR(col, NULL, 0, &ptr, "phase_multiplier", 0); + uiItemR(col, NULL, 0, &ptr, "phase_offset", 0); + uiItemR(col, NULL, 0, &ptr, "value_offset", 0); } /* --------------- */ @@ -287,14 +287,14 @@ static void draw_modifier__cycles(uiLayout *layout, ID *id, FModifier *fcm, shor /* before range */ col= uiLayoutColumn(split, 1); uiItemL(col, "Before:", 0); - uiItemR(col, "", 0, &ptr, "before_mode", 0, 0, 0); - uiItemR(col, NULL, 0, &ptr, "before_cycles", 0, 0, 0); + uiItemR(col, "", 0, &ptr, "before_mode", 0); + uiItemR(col, NULL, 0, &ptr, "before_cycles", 0); /* after range */ col= uiLayoutColumn(split, 1); uiItemL(col, "After:", 0); - uiItemR(col, "", 0, &ptr, "after_mode", 0, 0, 0); - uiItemR(col, NULL, 0, &ptr, "after_cycles", 0, 0, 0); + uiItemR(col, "", 0, &ptr, "after_mode", 0); + uiItemR(col, NULL, 0, &ptr, "after_cycles", 0); } /* --------------- */ @@ -309,20 +309,20 @@ static void draw_modifier__noise(uiLayout *layout, ID *id, FModifier *fcm, short RNA_pointer_create(id, &RNA_FModifierNoise, fcm, &ptr); /* blending mode */ - uiItemR(layout, NULL, 0, &ptr, "modification", 0, 0, 0); + uiItemR(layout, NULL, 0, &ptr, "modification", 0); /* split into 2 columns */ split= uiLayoutSplit(layout, 0.5f); /* col 1 */ col= uiLayoutColumn(split, 0); - uiItemR(col, NULL, 0, &ptr, "size", 0, 0, 0); - uiItemR(col, NULL, 0, &ptr, "strength", 0, 0, 0); + uiItemR(col, NULL, 0, &ptr, "size", 0); + uiItemR(col, NULL, 0, &ptr, "strength", 0); /* col 2 */ col= uiLayoutColumn(split, 0); - uiItemR(col, NULL, 0, &ptr, "phase", 0, 0, 0); - uiItemR(col, NULL, 0, &ptr, "depth", 0, 0, 0); + uiItemR(col, NULL, 0, &ptr, "phase", 0); + uiItemR(col, NULL, 0, &ptr, "depth", 0); } /* --------------- */ @@ -503,11 +503,11 @@ static void draw_modifier__envelope(uiLayout *layout, ID *id, FModifier *fcm, sh /* general settings */ col= uiLayoutColumn(layout, 1); uiItemL(col, "Envelope:", 0); - uiItemR(col, NULL, 0, &ptr, "reference_value", 0, 0, 0); + uiItemR(col, NULL, 0, &ptr, "reference_value", 0); row= uiLayoutRow(col, 1); - uiItemR(row, "Min", 0, &ptr, "default_minimum", 0, 0, 0); - uiItemR(row, "Max", 0, &ptr, "default_maximum", 0, 0, 0); + uiItemR(row, "Min", 0, &ptr, "default_minimum", 0); + uiItemR(row, "Max", 0, &ptr, "default_maximum", 0); /* control points header */ // TODO: move this control-point control stuff to using the new special widgets for lists @@ -559,13 +559,13 @@ static void draw_modifier__limits(uiLayout *layout, ID *id, FModifier *fcm, shor /* x-minimum */ col= uiLayoutColumn(split, 1); - uiItemR(col, NULL, 0, &ptr, "use_minimum_x", 0, 0, 0); - uiItemR(col, NULL, 0, &ptr, "minimum_x", 0, 0, 0); + uiItemR(col, NULL, 0, &ptr, "use_minimum_x", 0); + uiItemR(col, NULL, 0, &ptr, "minimum_x", 0); /* y-minimum*/ col= uiLayoutColumn(split, 1); - uiItemR(col, NULL, 0, &ptr, "use_minimum_y", 0, 0, 0); - uiItemR(col, NULL, 0, &ptr, "minimum_y", 0, 0, 0); + uiItemR(col, NULL, 0, &ptr, "use_minimum_y", 0); + uiItemR(col, NULL, 0, &ptr, "minimum_y", 0); } /* row 2: minimum */ @@ -577,13 +577,13 @@ static void draw_modifier__limits(uiLayout *layout, ID *id, FModifier *fcm, shor /* x-minimum */ col= uiLayoutColumn(split, 1); - uiItemR(col, NULL, 0, &ptr, "use_maximum_x", 0, 0, 0); - uiItemR(col, NULL, 0, &ptr, "maximum_x", 0, 0, 0); + uiItemR(col, NULL, 0, &ptr, "use_maximum_x", 0); + uiItemR(col, NULL, 0, &ptr, "maximum_x", 0); /* y-minimum*/ col= uiLayoutColumn(split, 1); - uiItemR(col, NULL, 0, &ptr, "use_maximum_y", 0, 0, 0); - uiItemR(col, NULL, 0, &ptr, "maximum_y", 0, 0, 0); + uiItemR(col, NULL, 0, &ptr, "use_maximum_y", 0); + uiItemR(col, NULL, 0, &ptr, "maximum_y", 0); } } diff --git a/source/blender/editors/animation/keyframes_general.c b/source/blender/editors/animation/keyframes_general.c index fc67ee34a2e..ced3c117700 100644 --- a/source/blender/editors/animation/keyframes_general.c +++ b/source/blender/editors/animation/keyframes_general.c @@ -127,11 +127,11 @@ void duplicate_fcurve_keys(FCurve *fcu) { BezTriple *newbezt; int i; - - if (fcu == NULL) + + /* this can only work when there is an F-Curve, and also when there are some BezTriples */ + if ELEM(NULL, fcu, fcu->bezt) return; - // XXX this does not take into account sample data... for (i=0; i < fcu->totvert; i++) { /* If a key is selected */ if (fcu->bezt[i].f2 & SELECT) { @@ -160,7 +160,7 @@ void duplicate_fcurve_keys(FCurve *fcu) /* **************************************************** */ /* Various Tools */ -/* Basic IPO-Curve 'cleanup' function that removes 'double points' and unnecessary keyframes on linear-segments only */ +/* Basic F-Curve 'cleanup' function that removes 'double points' and unnecessary keyframes on linear-segments only */ void clean_fcurve(FCurve *fcu, float thresh) { BezTriple *old_bezts, *bezt, *beztn; @@ -285,74 +285,74 @@ void smooth_fcurve (FCurve *fcu) } } - /* if any points were selected, allocate tSmooth_Bezt points to work on */ - if (totSel >= 3) { - tSmooth_Bezt *tarray, *tsb; - - /* allocate memory in one go */ - tsb= tarray= MEM_callocN(totSel*sizeof(tSmooth_Bezt), "tSmooth_Bezt Array"); - - /* populate tarray with data of selected points */ - bezt= fcu->bezt; - for (i=0, x=0; (i < fcu->totvert) && (x < totSel); i++, bezt++) { - if (BEZSELECTED(bezt)) { - /* tsb simply needs pointer to vec, and index */ - tsb->h1 = &bezt->vec[0][1]; - tsb->h2 = &bezt->vec[1][1]; - tsb->h3 = &bezt->vec[2][1]; - - /* advance to the next tsb to populate */ - if (x < totSel- 1) - tsb++; - else - break; - } + /* if any points were selected, allocate tSmooth_Bezt points to work on */ + if (totSel >= 3) { + tSmooth_Bezt *tarray, *tsb; + + /* allocate memory in one go */ + tsb= tarray= MEM_callocN(totSel*sizeof(tSmooth_Bezt), "tSmooth_Bezt Array"); + + /* populate tarray with data of selected points */ + bezt= fcu->bezt; + for (i=0, x=0; (i < fcu->totvert) && (x < totSel); i++, bezt++) { + if (BEZSELECTED(bezt)) { + /* tsb simply needs pointer to vec, and index */ + tsb->h1 = &bezt->vec[0][1]; + tsb->h2 = &bezt->vec[1][1]; + tsb->h3 = &bezt->vec[2][1]; + + /* advance to the next tsb to populate */ + if (x < totSel- 1) + tsb++; + else + break; } + } - /* calculate the new smoothed F-Curve's with weighted averages: - * - this is done with two passes - * - uses 5 points for each operation (which stores in the relevant handles) - * - previous: w/a ratio = 3:5:2:1:1 - * - next: w/a ratio = 1:1:2:5:3 - */ - - /* round 1: calculate previous and next */ - tsb= tarray; - for (i=0; i < totSel; i++, tsb++) { - /* don't touch end points (otherwise, curves slowly explode) */ - if (ELEM(i, 0, (totSel-1)) == 0) { - const tSmooth_Bezt *tP1 = tsb - 1; - const tSmooth_Bezt *tP2 = (i-2 > 0) ? (tsb - 2) : (NULL); - const tSmooth_Bezt *tN1 = tsb + 1; - const tSmooth_Bezt *tN2 = (i+2 < totSel) ? (tsb + 2) : (NULL); - - const float p1 = *tP1->h2; - const float p2 = (tP2) ? (*tP2->h2) : (*tP1->h2); - const float c1 = *tsb->h2; - const float n1 = *tN1->h2; - const float n2 = (tN2) ? (*tN2->h2) : (*tN1->h2); + /* calculate the new smoothed F-Curve's with weighted averages: + * - this is done with two passes + * - uses 5 points for each operation (which stores in the relevant handles) + * - previous: w/a ratio = 3:5:2:1:1 + * - next: w/a ratio = 1:1:2:5:3 + */ + + /* round 1: calculate previous and next */ + tsb= tarray; + for (i=0; i < totSel; i++, tsb++) { + /* don't touch end points (otherwise, curves slowly explode) */ + if (ELEM(i, 0, (totSel-1)) == 0) { + const tSmooth_Bezt *tP1 = tsb - 1; + const tSmooth_Bezt *tP2 = (i-2 > 0) ? (tsb - 2) : (NULL); + const tSmooth_Bezt *tN1 = tsb + 1; + const tSmooth_Bezt *tN2 = (i+2 < totSel) ? (tsb + 2) : (NULL); + + const float p1 = *tP1->h2; + const float p2 = (tP2) ? (*tP2->h2) : (*tP1->h2); + const float c1 = *tsb->h2; + const float n1 = *tN1->h2; + const float n2 = (tN2) ? (*tN2->h2) : (*tN1->h2); + + /* calculate previous and next */ + *tsb->h1= (3*p2 + 5*p1 + 2*c1 + n1 + n2) / 12; + *tsb->h3= (p2 + p1 + 2*c1 + 5*n1 + 3*n2) / 12; + } + } + + /* round 2: calculate new values and reset handles */ + tsb= tarray; + for (i=0; i < totSel; i++, tsb++) { + /* calculate new position by averaging handles */ + *tsb->h2 = (*tsb->h1 + *tsb->h3) / 2; - /* calculate previous and next */ - *tsb->h1= (3*p2 + 5*p1 + 2*c1 + n1 + n2) / 12; - *tsb->h3= (p2 + p1 + 2*c1 + 5*n1 + 3*n2) / 12; + /* reset handles now */ + *tsb->h1 = *tsb->h2; + *tsb->h3 = *tsb->h2; } - } - - /* round 2: calculate new values and reset handles */ - tsb= tarray; - for (i=0; i < totSel; i++, tsb++) { - /* calculate new position by averaging handles */ - *tsb->h2 = (*tsb->h1 + *tsb->h3) / 2; - /* reset handles now */ - *tsb->h1 = *tsb->h2; - *tsb->h3 = *tsb->h2; + /* free memory required for tarray */ + MEM_freeN(tarray); } - /* free memory required for tarray */ - MEM_freeN(tarray); -} - /* recalculate handles */ calchandles_fcurve(fcu); } @@ -371,7 +371,6 @@ ListBase animcopybuf = {NULL, NULL}; static float animcopy_firstframe= 999999999.0f; /* datatype for use in copy/paste buffer */ -// XXX F-Curve editor should use this too typedef struct tAnimCopybufItem { struct tAnimCopybufItem *next, *prev; diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index 2da082a9b7c..dc73011549c 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -503,19 +503,19 @@ static float setting_get_rna_value (PointerRNA *ptr, PropertyRNA *prop, int inde switch (RNA_property_type(prop)) { case PROP_BOOLEAN: - if (RNA_property_array_length(prop)) + if (RNA_property_array_length(ptr, prop)) value= (float)RNA_property_boolean_get_index(ptr, prop, index); else value= (float)RNA_property_boolean_get(ptr, prop); break; case PROP_INT: - if (RNA_property_array_length(prop)) + if (RNA_property_array_length(ptr, prop)) value= (float)RNA_property_int_get_index(ptr, prop, index); else value= (float)RNA_property_int_get(ptr, prop); break; case PROP_FLOAT: - if (RNA_property_array_length(prop)) + if (RNA_property_array_length(ptr, prop)) value= RNA_property_float_get_index(ptr, prop, index); else value= RNA_property_float_get(ptr, prop); @@ -740,6 +740,12 @@ short insert_keyframe_direct (PointerRNA ptr, PropertyRNA *prop, FCurve *fcu, fl printf("ERROR: no F-Curve to add keyframes to \n"); return 0; } + /* F-Curve not editable? */ + if ( (fcu->flag & FCURVE_PROTECTED) || ((fcu->grp) && (fcu->grp->flag & AGRP_PROTECTED)) ) { + if (G.f & G_DEBUG) + printf("WARNING: not inserting keyframe for locked F-Curve \n"); + return 0; + } /* if no property given yet, try to validate from F-Curve info */ if ((ptr.id.data == NULL) && (ptr.data==NULL)) { @@ -911,8 +917,19 @@ short delete_keyframe (ID *id, bAction *act, const char group[], const char rna_ /* we don't check the validity of the path here yet, but it should be ok... */ fcu= verify_fcurve(act, group, rna_path, array_index, 0); - /* only continue if we have an F-Curve to remove keyframes from */ - if (act && fcu) { + /* check if F-Curve exists and/or whether it can be edited */ + if ELEM(NULL, act, fcu) { + printf("ERROR: no F-Curve and/or Action to delete keyframe from \n"); + return 0; + } + if ( (fcu->flag & FCURVE_PROTECTED) || ((fcu->grp) && (fcu->grp->flag & AGRP_PROTECTED)) ) { + if (G.f & G_DEBUG) + printf("WARNING: not inserting keyframe for locked F-Curve \n"); + return 0; + } + + /* it should be fine to continue now... */ + { short found = -1; int i; @@ -1296,7 +1313,7 @@ static int insert_key_button_exec (bContext *C, wmOperator *op) if (path) { if (all) { - length= RNA_property_array_length(prop); + length= RNA_property_array_length(&ptr, prop); if(length) index= 0; else length= 1; @@ -1379,7 +1396,7 @@ static int delete_key_button_exec (bContext *C, wmOperator *op) if (path) { if (all) { - length= RNA_property_array_length(prop); + length= RNA_property_array_length(&ptr, prop); if(length) index= 0; else length= 1; diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c index ffc93340f8c..21f969467aa 100644 --- a/source/blender/editors/animation/keyingsets.c +++ b/source/blender/editors/animation/keyingsets.c @@ -80,137 +80,6 @@ /* ************************************************** */ /* KEYING SETS - EDITING API */ -/* Operators ------------------------------------------- */ - -/* These operators are only provided for scripting/macro usage, not for direct - * calling from the UI since they wrap some of the data-access API code for these - * (defined in blenkernel) which have quite a few properties. - */ - -/* ----- */ - -static int keyingset_add_destination_exec (bContext *C, wmOperator *op) -{ - PointerRNA ptr; - KeyingSet *ks= NULL; - ID *id= NULL; - char rna_path[256], group_name[64]; // xxx - short groupmode=0, flag=0; - int array_index=0; - - /* get settings from operator properties */ - ptr = RNA_pointer_get(op->ptr, "keyingset"); - if (ptr.data) - ks= (KeyingSet *)ptr.data; - - ptr = RNA_pointer_get(op->ptr, "id"); - if (ptr.data) - id= (ID *)ptr.data; - - groupmode= RNA_enum_get(op->ptr, "grouping_method"); - RNA_string_get(op->ptr, "group_name", group_name); - - RNA_string_get(op->ptr, "rna_path", rna_path); - array_index= RNA_int_get(op->ptr, "array_index"); - - if (RNA_boolean_get(op->ptr, "entire_array")) - flag |= KSP_FLAG_WHOLE_ARRAY; - - /* if enough args are provided, call API method */ - if (ks) { - BKE_keyingset_add_destination(ks, id, group_name, rna_path, array_index, flag, groupmode); - return OPERATOR_FINISHED; - } - else { - BKE_report(op->reports, RPT_ERROR, "Keying Set could not be added."); - return OPERATOR_CANCELLED; - } -} - -void ANIM_OT_keyingset_add_destination (wmOperatorType *ot) -{ - // XXX: this is also defined in rna_animation.c - static EnumPropertyItem prop_mode_grouping_items[] = { - {KSP_GROUP_NAMED, "NAMED", 0, "Named Group", ""}, - {KSP_GROUP_NONE, "NONE", 0, "None", ""}, - {KSP_GROUP_KSNAME, "KEYINGSET", 0, "Keying Set Name", ""}, - {0, NULL, 0, NULL, NULL}}; - - /* identifiers */ - ot->name= "Add Keying Set Destination"; - ot->idname= "ANIM_OT_keyingset_add_destination"; - - /* callbacks */ - ot->exec= keyingset_add_destination_exec; - ot->poll= ED_operator_scene_editable; - - /* props */ - /* pointers */ // xxx - do we want to directly expose these? - RNA_def_pointer_runtime(ot->srna, "keyingset", &RNA_KeyingSet, "Keying Set", "Keying Set to add destination to."); - RNA_def_pointer_runtime(ot->srna, "id", &RNA_ID, "ID", "ID-block for the destination."); - /* grouping */ - RNA_def_enum(ot->srna, "grouping_method", prop_mode_grouping_items, KSP_GROUP_NAMED, "Grouping Method", "Method used to define which Group-name to use."); - RNA_def_string(ot->srna, "group_name", "", 64, "Group Name", "Name of Action Group to assign destination to (only if grouping mode is to use this name)."); - /* rna-path */ - RNA_def_string(ot->srna, "rna_path", "", 256, "RNA-Path", "RNA-Path to destination property."); // xxx hopefully this is long enough - RNA_def_int(ot->srna, "array_index", 0, 0, INT_MAX, "Array Index", "If applicable, the index ", 0, INT_MAX); - /* flags */ - RNA_def_boolean(ot->srna, "entire_array", 1, "Entire Array", "hen an 'array/vector' type is chosen (Location, Rotation, Color, etc.), entire array is to be used."); - -} - -/* ----- */ - -static int keyingset_add_new_exec (bContext *C, wmOperator *op) -{ - Scene *sce= CTX_data_scene(C); - KeyingSet *ks= NULL; - short flag=0, keyingflag=0; - char name[64]; - - /* get settings from operator properties */ - RNA_string_get(op->ptr, "name", name); - - if (RNA_boolean_get(op->ptr, "absolute")) - flag |= KEYINGSET_ABSOLUTE; - if (RNA_boolean_get(op->ptr, "insertkey_needed")) - keyingflag |= INSERTKEY_NEEDED; - if (RNA_boolean_get(op->ptr, "insertkey_visual")) - keyingflag |= INSERTKEY_MATRIX; - - /* call the API func, and set the active keyingset index */ - ks= BKE_keyingset_add(&sce->keyingsets, name, flag, keyingflag); - - if (ks) { - sce->active_keyingset= BLI_countlist(&sce->keyingsets); - return OPERATOR_FINISHED; - } - else { - BKE_report(op->reports, RPT_ERROR, "Keying Set could not be added."); - return OPERATOR_CANCELLED; - } -} - -void ANIM_OT_keyingset_add_new (wmOperatorType *ot) -{ - /* identifiers */ - ot->name= "Add Keying Set"; - ot->idname= "ANIM_OT_keyingset_add_new"; - - /* callbacks */ - ot->exec= keyingset_add_new_exec; - ot->poll= ED_operator_scene_editable; - - /* props */ - /* name */ - RNA_def_string(ot->srna, "name", "KeyingSet", 64, "Name", "Name of Keying Set"); - /* flags */ - RNA_def_boolean(ot->srna, "absolute", 1, "Absolute", "Keying Set defines specific paths/settings to be keyframed (i.e. is not reliant on context info)"); - /* keying flags */ - RNA_def_boolean(ot->srna, "insertkey_needed", 0, "Insert Keyframes - Only Needed", "Only insert keyframes where they're needed in the relevant F-Curves."); - RNA_def_boolean(ot->srna, "insertkey_visual", 0, "Insert Keyframes - Visual", "Insert keyframes based on 'visual transforms'."); -} - /* UI API --------------------------------------------- */ /* Build menu-string of available keying-sets (allocates memory for string) @@ -899,7 +768,7 @@ short keyingset_context_ok_poll (bContext *C, KeyingSet *ks) Object *obact= CTX_data_active_object(C); /* if in posemode, check if 'pose-channels' requested for in KeyingSet */ - if ((obact && obact->pose) && (obact->flag & OB_POSEMODE)) { + if ((obact && obact->pose) && (obact->mode & OB_MODE_POSE)) { /* check for posechannels */ } @@ -930,7 +799,7 @@ static short modifykey_get_context_v3d_data (bContext *C, ListBase *dsources, Ke /* check if the active object is in PoseMode (i.e. only deal with bones) */ // TODO: check with the templates to see what we really need to store - if ((obact && obact->pose) && (obact->flag & OB_POSEMODE)) { + if ((obact && obact->pose) && (obact->mode & OB_MODE_POSE)) { /* Pose Mode: Selected bones */ #if 0 //set_pose_keys(ob); /* sets pchan->flag to POSE_KEY if bone selected, and clears if not */ @@ -1047,7 +916,7 @@ int modify_keyframes (bContext *C, ListBase *dsources, bAction *act, KeyingSet * * normal non-array entries get keyframed correctly */ i= ksp->array_index; - arraylen= i+1; + arraylen= i; /* get length of array if whole array option is enabled */ if (ksp->flag & KSP_FLAG_WHOLE_ARRAY) { @@ -1056,9 +925,13 @@ int modify_keyframes (bContext *C, ListBase *dsources, bAction *act, KeyingSet * RNA_id_pointer_create(ksp->id, &id_ptr); if (RNA_path_resolve(&id_ptr, ksp->rna_path, &ptr, &prop) && prop) - arraylen= RNA_property_array_length(prop); + arraylen= RNA_property_array_length(&ptr, prop); } + /* we should do at least one step */ + if (arraylen == i) + arraylen++; + /* for each possible index, perform operation * - assume that arraylen is greater than index */ @@ -1175,7 +1048,7 @@ int modify_keyframes (bContext *C, ListBase *dsources, bAction *act, KeyingSet * RNA_id_pointer_create(cks->id, &id_ptr); if (RNA_path_resolve(&id_ptr, path, &ptr, &prop) && prop) - arraylen= RNA_property_array_length(prop); + arraylen= RNA_property_array_length(&ptr, prop); } /* for each possible index, perform operation diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c index c1b24375b3d..632f037679f 100644 --- a/source/blender/editors/armature/editarmature.c +++ b/source/blender/editors/armature/editarmature.c @@ -713,7 +713,7 @@ int join_armature_exec(bContext *C, wmOperator *op) /* get pose of active object and move it out of posemode */ pose= ob->pose; - ob->flag &= ~OB_POSEMODE; + ob->mode &= ~OB_MODE_POSE; CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) { if ((base->object->type==OB_ARMATURE) && (base->object!=ob)) { @@ -724,8 +724,8 @@ int join_armature_exec(bContext *C, wmOperator *op) /* Get Pose of current armature */ opose= base->object->pose; - base->object->flag &= ~OB_POSEMODE; - BASACT->flag &= ~OB_POSEMODE; + base->object->mode &= ~OB_MODE_POSE; + //BASACT->flag &= ~OB_MODE_POSE; /* Find the difference matrix */ Mat4Invert(oimat, ob->obmat); @@ -1034,8 +1034,8 @@ static int separate_armature_exec (bContext *C, wmOperator *op) /* 1) store starting settings and exit editmode */ oldob= obedit; oldbase= BASACT; - oldob->flag &= ~OB_POSEMODE; - oldbase->flag &= ~OB_POSEMODE; + oldob->mode &= ~OB_MODE_POSE; + //oldbase->flag &= ~OB_POSEMODE; ED_armature_from_edit(scene, obedit); ED_armature_edit_free(obedit); @@ -4332,7 +4332,7 @@ int ED_do_pose_selectbuffer(Scene *scene, Base *base, unsigned int *buffer, shor } /* in weightpaint we select the associated vertex group too */ - if (G.f & G_WEIGHTPAINT) { + if (ob->mode & OB_MODE_WEIGHT_PAINT) { if (nearBone->flag & BONE_ACTIVE) { vertexgroup_select_by_name(OBACT, nearBone->name); DAG_object_flush_update(scene, OBACT, OB_RECALC_DATA); @@ -4424,7 +4424,7 @@ static int bone_skinnable(Object *ob, Bone *bone, void *datap) int a, segments; struct { Object *armob; void *list; int heat; } *data = datap; - if(!(G.f & G_WEIGHTPAINT) || !(bone->flag & BONE_HIDDEN_P)) { + if(!(ob->mode & OB_MODE_WEIGHT_PAINT) || !(bone->flag & BONE_HIDDEN_P)) { if (!(bone->flag & BONE_NO_DEFORM)) { if (data->heat && data->armob->pose && get_pose_channel(data->armob->pose, bone->name)) segments = bone->segments; @@ -4489,7 +4489,7 @@ static int dgroup_skinnable(Object *ob, Bone *bone, void *datap) int a, segments; struct { Object *armob; void *list; int heat; } *data= datap; - if (!(G.f & G_WEIGHTPAINT) || !(bone->flag & BONE_HIDDEN_P)) { + if (!(ob->mode & OB_MODE_WEIGHT_PAINT) || !(bone->flag & BONE_HIDDEN_P)) { if (!(bone->flag & BONE_NO_DEFORM)) { if (data->heat && data->armob->pose && get_pose_channel(data->armob->pose, bone->name)) segments = bone->segments; @@ -4588,7 +4588,7 @@ void add_verts_to_dgroups(Scene *scene, Object *ob, Object *par, int heat, int m float (*root)[3], (*tip)[3], (*verts)[3]; int *selected; int numbones, vertsfilled = 0, i, j, segments = 0; - int wpmode = (G.f & G_WEIGHTPAINT); + int wpmode = (ob->mode & OB_MODE_WEIGHT_PAINT); struct { Object *armob; void *list; int heat; } looper_data; looper_data.armob = par; diff --git a/source/blender/editors/armature/editarmature_sketch.c b/source/blender/editors/armature/editarmature_sketch.c index f3f7bccde04..79d3d7b1366 100644 --- a/source/blender/editors/armature/editarmature_sketch.c +++ b/source/blender/editors/armature/editarmature_sketch.c @@ -2320,7 +2320,7 @@ void sk_drawSketch(Scene *scene, View3D *v3d, SK_Sketch *sketch, int with_names) for (p = sketch->depth_peels.first; p; p = p->next) { - int index = (int)(p->ob); + int index = GET_INT_FROM_POINTER(p->ob); index = (index >> 5) & 7; glColor3fv(colors[index]); @@ -2466,8 +2466,10 @@ static int sketch_delete(bContext *C, wmOperator *op, wmEvent *event) void BIF_sk_selectStroke(bContext *C, short mval[2], short extend) { + ToolSettings *ts = CTX_data_tool_settings(C); SK_Sketch *sketch = contextSketch(C, 0); - if (sketch) + + if (sketch != NULL && ts->bone_sketching & BONE_SKETCHING) { sk_selectStroke(C, sketch, mval, extend); } diff --git a/source/blender/editors/armature/poselib.c b/source/blender/editors/armature/poselib.c index ef2e5188487..021bec05a3b 100644 --- a/source/blender/editors/armature/poselib.c +++ b/source/blender/editors/armature/poselib.c @@ -342,7 +342,7 @@ static int poselib_add_menu_invoke (bContext *C, wmOperator *op, wmEvent *evt) uiItemIntO(layout, "Add New (Current Frame)", 0, "POSELIB_OT_pose_add", "frame", CFRA); /* replace existing - submenu */ - uiItemMenuF(layout, "Replace Existing...", 0, poselib_add_menu_invoke__replacemenu); + uiItemMenuF(layout, "Replace Existing...", 0, poselib_add_menu_invoke__replacemenu, NULL); } uiPupMenuEnd(C, pup); diff --git a/source/blender/editors/armature/poseobject.c b/source/blender/editors/armature/poseobject.c index 174bb39d7b9..5b378878f91 100644 --- a/source/blender/editors/armature/poseobject.c +++ b/source/blender/editors/armature/poseobject.c @@ -126,7 +126,7 @@ void ED_armature_enter_posemode(bContext *C, Base *base) switch (ob->type){ case OB_ARMATURE: - ob->flag |= OB_POSEMODE; + ob->mode |= OB_MODE_POSE; base->flag= ob->flag; WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_MODE_POSE, NULL); @@ -135,7 +135,8 @@ void ED_armature_enter_posemode(bContext *C, Base *base) default: return; } - ED_view3d_exit_paint_modes(C); + + ED_object_toggle_modes(C, ob->mode); } void ED_armature_exit_posemode(bContext *C, Base *base) @@ -143,7 +144,7 @@ void ED_armature_exit_posemode(bContext *C, Base *base) if(base) { Object *ob= base->object; - ob->flag &= ~OB_POSEMODE; + ob->mode &= ~OB_MODE_POSE; base->flag= ob->flag; WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_MODE_OBJECT, NULL); @@ -527,7 +528,7 @@ void pose_select_constraint_target(Scene *scene) /* paranoia checks */ if (!ob && !ob->pose) return; - if (ob==obedit || (ob->flag & OB_POSEMODE)==0) return; + if (ob==obedit || (ob->mode & OB_MODE_POSE)==0) return; for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { if (arm->layer & pchan->bone->layer) { @@ -715,7 +716,7 @@ void pose_copy_menu(Scene *scene) /* paranoia checks */ if (ELEM(NULL, ob, ob->pose)) return; - if ((ob==obedit) || (ob->flag & OB_POSEMODE)==0) return; + if ((ob==obedit) || (ob->mode & OB_MODE_POSE)==0) return; /* find active */ for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { @@ -1105,7 +1106,7 @@ void pose_adds_vgroups(Scene *scene, Object *meshobj, int heatweights) // XXX extern VPaint Gwp; /* from vpaint */ Object *poseobj= modifiers_isDeformedByArmature(meshobj); - if(poseobj==NULL || (poseobj->flag & OB_POSEMODE)==0) { + if(poseobj==NULL || (poseobj->mode & OB_MODE_POSE)==0) { error("The active object must have a deforming armature in pose mode"); return; } @@ -1646,10 +1647,10 @@ void pose_activate_flipped_bone(Scene *scene) if(ob==NULL) return; - if(G.f & G_WEIGHTPAINT) { + if(ob->mode && OB_MODE_WEIGHT_PAINT) { ob= modifiers_isDeformedByArmature(ob); } - if(ob && (ob->flag & OB_POSEMODE)) { + if(ob && (ob->mode & OB_MODE_POSE)) { bPoseChannel *pchan, *pchanf; for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { @@ -1670,7 +1671,7 @@ void pose_activate_flipped_bone(Scene *scene) pchanf->bone->flag |= (BONE_SELECTED|BONE_ACTIVE); /* in weightpaint we select the associated vertex group too */ - if(G.f & G_WEIGHTPAINT) { + if(ob->mode & OB_MODE_WEIGHT_PAINT) { vertexgroup_select_by_name(OBACT, name); DAG_object_flush_update(scene, OBACT, OB_RECALC_DATA); } @@ -2150,7 +2151,7 @@ void pose_special_editmenu(Scene *scene) /* paranoia checks */ if(!ob && !ob->pose) return; - if(ob==obedit || (ob->flag & OB_POSEMODE)==0) return; + if(ob==obedit || (ob->mode & OB_MODE_POSE)==0) return; nr= pupmenu("Specials%t|Select Constraint Target%x1|Flip Left-Right Names%x2|Calculate Paths%x3|Clear Paths%x4|Clear User Transform %x5|Relax Pose %x6|%l|AutoName Left-Right%x7|AutoName Front-Back%x8|AutoName Top-Bottom%x9"); if(nr==1) { diff --git a/source/blender/editors/curve/curve_ops.c b/source/blender/editors/curve/curve_ops.c index 6006c7e656b..d3bcdcb69bb 100644 --- a/source/blender/editors/curve/curve_ops.c +++ b/source/blender/editors/curve/curve_ops.c @@ -202,8 +202,11 @@ void ED_keymap_curve(wmWindowManager *wm) RNA_int_set(WM_keymap_add_item(keymap, "FONT_OT_change_character", DOWNARROWKEY, KM_PRESS, KM_ALT, 0)->ptr, "delta", -1); WM_keymap_add_item(keymap, "FONT_OT_text_copy", CKEY, KM_PRESS, KM_CTRL, 0); + WM_keymap_add_item(keymap, "FONT_OT_text_copy", CKEY, KM_PRESS, KM_OSKEY, 0); WM_keymap_add_item(keymap, "FONT_OT_text_cut", XKEY, KM_PRESS, KM_CTRL, 0); - WM_keymap_add_item(keymap, "FONT_OT_text_paste", PKEY, KM_PRESS, KM_CTRL, 0); + WM_keymap_add_item(keymap, "FONT_OT_text_cut", XKEY, KM_PRESS, KM_OSKEY, 0); + WM_keymap_add_item(keymap, "FONT_OT_text_paste", VKEY, KM_PRESS, KM_CTRL, 0); + WM_keymap_add_item(keymap, "FONT_OT_text_paste", VKEY, KM_PRESS, KM_OSKEY, 0); WM_keymap_add_item(keymap, "FONT_OT_line_break", RETKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "FONT_OT_text_insert", KM_TEXTINPUT, KM_ANY, KM_ANY, 0); // last! diff --git a/source/blender/editors/include/ED_anim_api.h b/source/blender/editors/include/ED_anim_api.h index 0786d0f9be0..179f362b13f 100644 --- a/source/blender/editors/include/ED_anim_api.h +++ b/source/blender/editors/include/ED_anim_api.h @@ -46,6 +46,8 @@ struct bActionGroup; struct FCurve; struct FModifier; +struct uiBlock; + /* ************************************************ */ /* ANIMATION CHANNEL FILTERING */ /* anim_filter.c */ @@ -107,7 +109,10 @@ typedef struct bAnimListElem { } bAnimListElem; -/* Some types for easier type-testing */ +/* Some types for easier type-testing + * NOTE: need to keep the order of these synchronised with the channels define code + * which is used for drawing and handling channel lists for + */ // XXX was ACTTYPE_* typedef enum eAnim_ChannelType { ANIMTYPE_NONE= 0, @@ -140,6 +145,9 @@ typedef enum eAnim_ChannelType { ANIMTYPE_NLATRACK, ANIMTYPE_NLAACTION, + + /* always as last item, the total number of channel types... */ + ANIMTYPE_NUM_TYPES, } eAnim_ChannelType; /* types of keyframe data in bAnimListElem */ @@ -275,25 +283,89 @@ short ANIM_animdata_context_getdata(bAnimContext *ac); /* ************************************************ */ /* ANIMATION CHANNELS LIST */ -/* anim_channels.c */ +/* anim_channels_*.c */ -/* ------------------------ API -------------------------- */ - -/* Deselect all animation channels */ -void ANIM_deselect_anim_channels(void *data, short datatype, short test, short sel); - -/* Set the 'active' channel of type channel_type, in the given action */ -void ANIM_set_active_channel(bAnimContext *ac, void *data, short datatype, int filter, void *channel_data, short channel_type); - -/* --------------- Settings and/or Defines -------------- */ +/* ------------------------ Drawing TypeInfo -------------------------- */ /* flag-setting behaviour */ -enum { +typedef enum eAnimChannels_SetFlag { ACHANNEL_SETFLAG_CLEAR = 0, ACHANNEL_SETFLAG_ADD, ACHANNEL_SETFLAG_TOGGLE } eAnimChannels_SetFlag; +/* types of settings for AnimChanels */ +typedef enum eAnimChannel_Settings { + ACHANNEL_SETTING_SELECT = 0, + ACHANNEL_SETTING_PROTECT, // warning: for drawing UI's, need to check if this is off (maybe inverse this later) + ACHANNEL_SETTING_MUTE, + ACHANNEL_SETTING_EXPAND, + ACHANNEL_SETTING_VISIBLE, /* only for Graph Editor */ + ACHANNEL_SETTING_SOLO, /* only for NLA Tracks */ +} eAnimChannel_Settings; + + +/* Drawing, mouse handling, and flag setting behaviour... */ +typedef struct bAnimChannelType { + /* drawing */ + /* draw backdrop strip for channel */ + void (*draw_backdrop)(bAnimContext *ac, bAnimListElem *ale, float yminc, float ymaxc); + /* get depth of indention (relative to the depth channel is nested at) */ + short (*get_indent_level)(bAnimContext *ac, bAnimListElem *ale); + /* get offset in pixels for the start of the channel (in addition to the indent depth) */ + short (*get_offset)(bAnimContext *ac, bAnimListElem *ale); + + + /* get name (for channel lists) */ + void (*name)(bAnimListElem *ale, char *name); + /* get icon (for channel lists) */ + int (*icon)(bAnimListElem *ale); + + /* settings */ + /* check if the given setting is valid in the current context */ + short (*has_setting)(bAnimContext *ac, bAnimListElem *ale, int setting); + /* get the flag used for this setting */ + int (*setting_flag)(int setting, short *neg); + /* get the pointer to int/short where data is stored, + * with type being sizeof(ptr_data) which should be fine for runtime use... + * - assume that setting has been checked to be valid for current context + */ + void *(*setting_ptr)(bAnimListElem *ale, int setting, short *type); +} bAnimChannelType; + +/* ------------------------ Drawing API -------------------------- */ + +/* Get typeinfo for the given channel */ +bAnimChannelType *ANIM_channel_get_typeinfo(bAnimListElem *ale); + +/* Draw the given channel */ +void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float ymaxc); +/* Draw the widgets for the given channel */ +void ANIM_channel_draw_widgets(bAnimContext *ac, bAnimListElem *ale, struct uiBlock *block, float yminc, float ymaxc); + + +/* ------------------------ Editing API -------------------------- */ + +/* Check if some setting for a channel is enabled + * Returns: 1 = On, 0 = Off, -1 = Invalid + * + * - setting: eAnimChannel_Settings + */ +short ANIM_channel_setting_get(bAnimContext *ac, bAnimListElem *ale, int setting); + +/* Change value of some setting for a channel + * - setting: eAnimChannel_Settings + * - mode: eAnimChannels_SetFlag + */ +void ANIM_channel_setting_set(bAnimContext *ac, bAnimListElem *ale, int setting, short mode); + + +/* Deselect all animation channels */ +void ANIM_deselect_anim_channels(void *data, short datatype, short test, short sel); + +/* Set the 'active' channel of type channel_type, in the given action */ +void ANIM_set_active_channel(bAnimContext *ac, void *data, short datatype, int filter, void *channel_data, short channel_type); + /* ************************************************ */ /* DRAWING API */ /* anim_draw.c */ @@ -334,14 +406,16 @@ void ANIM_uiTemplate_fmodifier_draw(struct uiLayout *layout, struct ID *id, List /* ------------ Animation F-Curves <-> Icons/Names Mapping ------------ */ /* anim_ipo_utils.c */ +/* Get icon for type of setting F-Curve is for */ +// XXX include this in the getname() method via RNA? int geticon_anim_blocktype(short blocktype); +/* Get name for channel-list displays for F-Curve */ void getname_anim_fcurve(char *name, struct ID *id, struct FCurve *fcu); - +/* Automatically determine a color for the nth F-Curve */ void ipo_rainbow(int cur, int tot, float *out); - /* ------------- NLA-Mapping ----------------------- */ /* anim_draw.c */ diff --git a/source/blender/editors/include/ED_fileselect.h b/source/blender/editors/include/ED_fileselect.h index c56807ad09a..57ab6a5f8f6 100644 --- a/source/blender/editors/include/ED_fileselect.h +++ b/source/blender/editors/include/ED_fileselect.h @@ -65,6 +65,7 @@ typedef struct FileLayout short height; short flag; short dirty; + short textheight; float column_widths[MAX_FILE_COLUMN]; } FileLayout; diff --git a/source/blender/editors/include/ED_info.h b/source/blender/editors/include/ED_info.h new file mode 100644 index 00000000000..d09e174d71d --- /dev/null +++ b/source/blender/editors/include/ED_info.h @@ -0,0 +1,32 @@ +/** + * $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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2009, Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#ifndef ED_INFO_H +#define ED_INFO_H + +/* info_stats.c */ +void ED_info_stats_clear(struct Scene *scene); +char *ED_info_stats_string(struct Scene *scene); + +#endif /* ED_INFO_H */ diff --git a/source/blender/editors/include/ED_keyframing.h b/source/blender/editors/include/ED_keyframing.h index 64672e3502b..4bc24a0adeb 100644 --- a/source/blender/editors/include/ED_keyframing.h +++ b/source/blender/editors/include/ED_keyframing.h @@ -154,15 +154,6 @@ struct KeyingSet *ANIM_builtin_keyingset_get_named(struct KeyingSet *prevKS, cha /* Initialise builtin KeyingSets on startup */ void init_builtin_keyingsets(void); -/* -------- */ - -/* KeyingSet Editing Operators: - * These can add a new KeyingSet and/or add 'destinations' to the KeyingSets, - * acting as a means by which they can be added outside the Outliner. - */ -void ANIM_OT_keyingset_add_new(struct wmOperatorType *ot); -void ANIM_OT_keyingset_add_destination(struct wmOperatorType *ot); - /* ************ Drivers ********************** */ /* Main Driver Management API calls: diff --git a/source/blender/editors/include/ED_node.h b/source/blender/editors/include/ED_node.h index 0cd5551f17f..bf4632dc3da 100644 --- a/source/blender/editors/include/ED_node.h +++ b/source/blender/editors/include/ED_node.h @@ -28,8 +28,17 @@ #ifndef ED_NODE_H #define ED_NODE_H +struct Material; +struct Scene; +struct Tex; + /* drawnode.c */ void ED_init_node_butfuncs(void); +/* node_edit.c */ +void ED_node_shader_default(struct Material *ma); +void ED_node_composit_default(struct Scene *sce); +void ED_node_texture_default(struct Tex *tex);; + #endif /* ED_NODE_H */ diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h index c8a72a2aa97..d31f85d08ea 100644 --- a/source/blender/editors/include/ED_object.h +++ b/source/blender/editors/include/ED_object.h @@ -59,6 +59,8 @@ struct Base *ED_object_add_duplicate(struct Scene *scene, struct Base *base, int void ED_object_parent(struct Object *ob, struct Object *parent, int type, const char *substr); +void ED_object_toggle_modes(struct bContext *C, int mode); + /* bitflags for enter/exit editmode */ #define EM_FREEDATA 1 #define EM_FREEUNDO 2 @@ -69,6 +71,8 @@ void ED_object_enter_editmode(struct bContext *C, int flag); void ED_object_base_init_from_view(struct bContext *C, struct Base *base); +void ED_object_single_users(struct Scene *scene, int full); + /* cleanup */ int object_is_libdata(struct Object *ob); int object_data_is_libdata(struct Object *ob); @@ -89,6 +93,9 @@ void ED_object_constraint_set_active(struct Object *ob, struct bConstraint *con) void mouse_lattice(struct bContext *C, short mval[2], int extend); void undo_push_lattice(struct bContext *C, char *name); +/* editmball.c */ +void undo_push_mball(struct bContext *C, char *name); + /* editkey.c */ void insert_shapekey(struct Scene *scene, struct Object *ob); void delete_key(struct Scene *scene, struct Object *ob); diff --git a/source/blender/editors/include/ED_previewrender.h b/source/blender/editors/include/ED_previewrender.h index 41cbecb5353..7e0d71db7e1 100644 --- a/source/blender/editors/include/ED_previewrender.h +++ b/source/blender/editors/include/ED_previewrender.h @@ -34,6 +34,7 @@ struct Image; struct Render; struct bContext; struct ID; +struct MTex; #define PREVIEW_RENDERSIZE 140 @@ -70,9 +71,9 @@ pr_method: void ED_preview_init_dbase(void); void ED_preview_free_dbase(void); -void ED_preview_shader_job(const struct bContext *C, void *owner, struct ID *id, struct ID *parent, int sizex, int sizey); +void ED_preview_shader_job(const struct bContext *C, void *owner, struct ID *id, struct ID *parent, struct MTex *slot, int sizex, int sizey); void ED_preview_iconrender(struct Scene *scene, struct ID *id, unsigned int *rect, int sizex, int sizey); -void ED_preview_draw(const struct bContext *C, void *idp, void *parentp, rcti *rect); +void ED_preview_draw(const struct bContext *C, void *idp, void *parentp, void *slot, rcti *rect); #endif diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h index fc29d64eb37..22a3e737277 100644 --- a/source/blender/editors/include/ED_screen.h +++ b/source/blender/editors/include/ED_screen.h @@ -58,6 +58,7 @@ void ED_region_panels_init(struct wmWindowManager *wm, struct ARegion *ar); void ED_region_panels(const struct bContext *C, struct ARegion *ar, int vertical, char *context, int contextnr); void ED_region_header_init(struct ARegion *ar); void ED_region_header(const struct bContext *C, struct ARegion *ar); +void region_scissor_winrct(struct ARegion *ar, struct rcti *winrct); /* spaces */ void ED_spacetypes_init(void); @@ -89,10 +90,13 @@ void ED_screen_do_listen(struct wmWindow *win, struct wmNotifier *note); bScreen *ED_screen_duplicate(struct wmWindow *win, struct bScreen *sc); bScreen *ED_screen_add(struct wmWindow *win, struct Scene *scene, char *name); void ED_screen_set(struct bContext *C, struct bScreen *sc); +void ED_screen_delete(struct bContext *C, struct bScreen *sc); void ED_screen_set_scene(struct bContext *C, struct Scene *scene); +void ED_screen_delete_scene(struct bContext *C, struct Scene *scene); void ED_screen_set_subwinactive(struct wmWindow *win, struct wmEvent *event); void ED_screen_exit(struct bContext *C, struct wmWindow *window, struct bScreen *screen); -void ED_screen_animation_timer(struct bContext *C, int redraws, int enable); +void ED_screen_animation_timer(struct bContext *C, int redraws, int sync, int enable); +void ED_screen_animation_timer_update(struct bContext *C, int redraws); int ED_screen_full_newspace(struct bContext *C, ScrArea *sa, int type); void ED_screen_full_prevspace(struct bContext *C); diff --git a/source/blender/editors/include/ED_screen_types.h b/source/blender/editors/include/ED_screen_types.h index 76a2a55c29e..72afe7704b4 100644 --- a/source/blender/editors/include/ED_screen_types.h +++ b/source/blender/editors/include/ED_screen_types.h @@ -31,9 +31,9 @@ /* for animplayer */ typedef struct ScreenAnimData { - ARegion *ar; /* do not read from this, only for comparing if region exists */ + ARegion *ar; /* do not read from this, only for comparing if region exists */ int redraws; - int flag; /* flags for playback */ + int flag; /* flags for playback */ } ScreenAnimData; /* for animplayer */ @@ -42,6 +42,10 @@ enum { ANIMPLAY_FLAG_REVERSE = (1<<0), /* temporary - playback just jumped to the start/end */ ANIMPLAY_FLAG_JUMPED = (1<<1), + /* drop frames as needed to maintain framerate */ + ANIMPLAY_FLAG_SYNC = (1<<2), + /* don't drop frames (and ignore AUDIO_SYNC flag) */ + ANIMPLAY_FLAG_NO_SYNC = (1<<3), }; diff --git a/source/blender/editors/include/ED_space_api.h b/source/blender/editors/include/ED_space_api.h index efaf0f56f92..04b6be3bcaa 100644 --- a/source/blender/editors/include/ED_space_api.h +++ b/source/blender/editors/include/ED_space_api.h @@ -52,6 +52,7 @@ void ED_spacetype_text(void); void ED_spacetype_sequencer(void); void ED_spacetype_logic(void); void ED_spacetype_console(void); +void ED_spacetype_userpref(void); /* calls for instancing and freeing spacetype static data called in WM_init_exit */ diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index 6360bf49f1a..07890d88c22 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -70,6 +70,7 @@ float *give_cursor(struct Scene *scene, struct View3D *v3d); void initgrabz(struct RegionView3D *rv3d, float x, float y, float z); void window_to_3d(struct ARegion *ar, float *vec, short mx, short my); void window_to_3d_delta(struct ARegion *ar, float *vec, short mx, short my); +void view3d_unproject(struct bglMats *mats, float out[3], const short x, const short y, const float z); /* Depth buffer */ float read_cached_depth(struct ViewContext *vc, int x, int y); @@ -130,8 +131,6 @@ int edge_inside_circle(short centx, short centy, short rad, short x1, short y1, int lasso_inside(short mcords[][2], short moves, short sx, short sy); int lasso_inside_edge(short mcords[][2], short moves, int x0, int y0, int x1, int y1); -/* modes */ -void ED_view3d_exit_paint_modes(struct bContext *C); /* get 3d region from context, also if mouse is in header or toolbar */ struct RegionView3D *ED_view3d_context_rv3d(struct bContext *C); diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index 70fbad3216d..0cb6964b39e 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -60,6 +60,7 @@ struct Image; struct ImageUser; struct uiWidgetColors; struct Tex; +struct MTex; typedef struct uiBut uiBut; typedef struct uiBlock uiBlock; @@ -99,6 +100,8 @@ typedef struct uiLayout uiLayout; #define UI_BLOCK_KEEP_OPEN 256 #define UI_BLOCK_POPUP 512 #define UI_BLOCK_OUT_1 1024 +#define UI_BLOCK_NO_FLIP 2048 +#define UI_BLOCK_POPUP_MEMORY 4096 /* uiPopupBlockHandle->menuretval */ #define UI_RETURN_CANCEL 1 /* cancel all menus cascading */ @@ -253,8 +256,6 @@ void uiPupMenuNotice(struct bContext *C, char *str, ...); void uiPupMenuError(struct bContext *C, char *str, ...); void uiPupMenuReports(struct bContext *C, struct ReportList *reports); -void uiPupMenuSetActive(int val); - /* Popup Blocks * * Functions used to create popup blocks. These are like popup menus @@ -490,7 +491,7 @@ void uiButSetNFunc (uiBut *but, uiButHandleNFunc func, void *argN, void *arg2) void uiButSetCompleteFunc(uiBut *but, uiButCompleteFunc func, void *arg); -void uiBlockSetDrawExtraFunc(uiBlock *block, void (*func)(const struct bContext *C, void *, void *, struct rcti *rect), void *arg); +void uiBlockSetDrawExtraFunc(uiBlock *block, void (*func)(const struct bContext *C, void *, void *, void *, struct rcti *rect), void *arg1, void *arg2); /* Autocomplete * @@ -545,6 +546,7 @@ void autocomplete_vgroup(struct bContext *C, char *str, void *arg_v); struct rctf; void curvemap_buttons(uiBlock *block, struct CurveMapping *cumap, char labeltype, short event, short redraw, struct rctf *rect); +void curvemap_layout(uiLayout *layout, struct CurveMapping *cumap, char labeltype, short event, short redraw, struct rctf *rect); void colorband_buttons(uiBlock *block, struct ColorBand *coba, struct rctf *rect, int small); @@ -583,16 +585,21 @@ void UI_exit(void); #define UI_LAYOUT_ALIGN_CENTER 2 #define UI_LAYOUT_ALIGN_RIGHT 3 +#define UI_ITEM_O_RETURN_PROPS 1 +#define UI_ITEM_R_EXPAND 2 +#define UI_ITEM_R_SLIDER 4 +#define UI_ITEM_R_TOGGLE 8 + uiLayout *uiBlockLayout(uiBlock *block, int dir, int type, int x, int y, int size, int em, struct uiStyle *style); void uiBlockSetCurLayout(uiBlock *block, uiLayout *layout); void uiBlockLayoutResolve(const struct bContext *C, uiBlock *block, int *x, int *y); uiBlock *uiLayoutGetBlock(uiLayout *layout); -void uiLayoutSetOperatorContext(uiLayout *layout, int opcontext); void uiLayoutSetFunc(uiLayout *layout, uiMenuHandleFunc handlefunc, void *argv); void uiLayoutSetContextPointer(uiLayout *layout, char *name, struct PointerRNA *ptr); +void uiLayoutSetOperatorContext(uiLayout *layout, int opcontext); void uiLayoutSetActive(uiLayout *layout, int active); void uiLayoutSetEnabled(uiLayout *layout, int enabled); void uiLayoutSetRedAlert(uiLayout *layout, int redalert); @@ -607,6 +614,7 @@ int uiLayoutGetEnabled(uiLayout *layout); int uiLayoutGetRedAlert(uiLayout *layout); int uiLayoutGetAlignment(uiLayout *layout); int uiLayoutGetKeepAspect(uiLayout *layout); +int uiLayoutGetWidth(uiLayout *layout); float uiLayoutGetScaleX(uiLayout *layout); float uiLayoutGetScaleY(uiLayout *layout); ListBase *uiLayoutBoxGetList(uiLayout *layout); @@ -623,20 +631,21 @@ uiLayout *uiLayoutSplit(uiLayout *layout, float percentage); uiBlock *uiLayoutFreeBlock(uiLayout *layout); /* templates */ -void uiTemplateHeader(uiLayout *layout, struct bContext *C); +void uiTemplateHeader(uiLayout *layout, struct bContext *C, int menus); void uiTemplateID(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, char *propname, char *newop, char *unlinkop); uiLayout *uiTemplateModifier(uiLayout *layout, struct PointerRNA *ptr); uiLayout *uiTemplateConstraint(uiLayout *layout, struct PointerRNA *ptr); -void uiTemplatePreview(uiLayout *layout, struct ID *id, struct ID *parent); +void uiTemplatePreview(uiLayout *layout, struct ID *id, struct ID *parent, struct MTex *slot); void uiTemplateColorRamp(uiLayout *layout, struct ColorBand *coba, int expand); -void uiTemplateCurveMapping(uiLayout *layout, struct CurveMapping *cumap, int type); +void uiTemplateCurveMapping(uiLayout *layout, struct CurveMapping *cumap, int type, int compact); void uiTemplateTriColorSet(uiLayout *layout, struct PointerRNA *ptr, char *propname); void uiTemplateLayers(uiLayout *layout, struct PointerRNA *ptr, char *propname); void uiTemplateImageLayers(uiLayout *layout, struct bContext *C, struct Image *ima, struct ImageUser *iuser); void uiTemplateRunningJobs(uiLayout *layout, struct bContext *C); void uiTemplateOperatorSearch(uiLayout *layout); void uiTemplateHeader3D(uiLayout *layout, struct bContext *C); +void uiTemplate_view3d_select_faceselmenu(uiLayout *layout, struct bContext *C); void uiTemplateTextureImage(uiLayout *layout, struct bContext *C, struct Tex *tex); typedef struct uiListItem { @@ -657,10 +666,10 @@ void uiItemBooleanO(uiLayout *layout, char *name, int icon, char *opname, char * void uiItemIntO(uiLayout *layout, char *name, int icon, char *opname, char *propname, int value); void uiItemFloatO(uiLayout *layout, char *name, int icon, char *opname, char *propname, float value); void uiItemStringO(uiLayout *layout, char *name, int icon, char *opname, char *propname, char *value); -void uiItemFullO(uiLayout *layout, char *name, int icon, char *idname, struct IDProperty *properties, int context); +PointerRNA uiItemFullO(uiLayout *layout, char *name, int icon, char *idname, struct IDProperty *properties, int context, int flag); -void uiItemR(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, char *propname, int expand, int slider, int toggle); -void uiItemFullR(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, struct PropertyRNA *prop, int index, int value, int expand, int slider, int toggle); +void uiItemR(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, char *propname, int flag); +void uiItemFullR(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, struct PropertyRNA *prop, int index, int value, int flag); void uiItemEnumR(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, char *propname, int value); void uiItemEnumR_string(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, char *propname, char *value); void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, char *propname); @@ -671,7 +680,7 @@ void uiItemM(uiLayout *layout, struct bContext *C, char *name, int icon, char *m void uiItemV(uiLayout *layout, char *name, int icon, int argval); /* value */ void uiItemS(uiLayout *layout); /* separator */ -void uiItemMenuF(uiLayout *layout, char *name, int icon, uiMenuCreateFunc func); +void uiItemMenuF(uiLayout *layout, char *name, int icon, uiMenuCreateFunc func, void *arg); void uiItemMenuEnumO(uiLayout *layout, char *name, int icon, char *opname, char *propname); void uiItemMenuEnumR(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, char *propname); diff --git a/source/blender/editors/interface/Makefile b/source/blender/editors/interface/Makefile index a3d0692f1e1..5968660eb91 100644 --- a/source/blender/editors/interface/Makefile +++ b/source/blender/editors/interface/Makefile @@ -48,6 +48,7 @@ CPPFLAGS += -I../../makesdna CPPFLAGS += -I../../makesrna CPPFLAGS += -I../../imbuf CPPFLAGS += -I../../blenfont +CPPFLAGS += -I../../python # own include diff --git a/source/blender/editors/interface/SConscript b/source/blender/editors/interface/SConscript index bac3742c12f..e44de5410f1 100644 --- a/source/blender/editors/interface/SConscript +++ b/source/blender/editors/interface/SConscript @@ -9,6 +9,7 @@ for source in env.Glob('*_api.c'): incs = '../include ../../blenlib ../../blenfont ../../blenkernel ../../makesdna ../../imbuf' incs += ' ../../makesrna ../../windowmanager #/intern/guardedalloc' incs += ' #/extern/glew/include' +incs += ' ../../python/' # python button eval defs = [] diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 9e9b6165a73..3c6e12905d6 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -48,6 +48,7 @@ #include "BKE_screen.h" #include "BKE_texture.h" #include "BKE_utildefines.h" +#include "BKE_unit.h" #include "BIF_gl.h" #include "BIF_glutil.h" @@ -66,6 +67,8 @@ #include "RNA_access.h" #include "RNA_types.h" +#include "BPY_extern.h" + #include "interface_intern.h" #define MENU_WIDTH 120 @@ -222,6 +225,7 @@ static void ui_text_bounds_block(uiBlock *block, float offset) uiStyle *style= U.uistyles.first; // XXX pass on as arg uiBut *bt; int i = 0, j, x1addval= offset, nextcol; + int lastcol= 0, col= 0; uiStyleFontSet(&style->widget); @@ -234,18 +238,26 @@ static void ui_text_bounds_block(uiBlock *block, float offset) if(j > i) i = j; } + + if(bt->next && bt->x1 < bt->next->x1) + lastcol++; } /* cope with multi collumns */ bt= block->buttons.first; while(bt) { - if(bt->next && bt->x1 < bt->next->x1) + if(bt->next && bt->x1 < bt->next->x1) { nextcol= 1; + col++; + } else nextcol= 0; bt->x1 = x1addval; bt->x2 = bt->x1 + i + block->bounds; + if(col == lastcol) + bt->x2= MAX2(bt->x2, offset + block->minbounds); + ui_check_but(bt); // clips text again if(nextcol) @@ -278,7 +290,7 @@ void ui_bounds_block(uiBlock *block) if(bt->x2 > block->maxx) block->maxx= bt->x2; if(bt->y2 > block->maxy) block->maxy= bt->y2; - + bt= bt->next; } @@ -288,6 +300,8 @@ void ui_bounds_block(uiBlock *block) block->maxy += block->bounds; } + block->maxx= block->minx + MAX2(block->maxx - block->minx, block->minbounds); + /* hardcoded exception... but that one is annoying with larger safety */ bt= block->buttons.first; if(bt && strncmp(bt->str, "ERROR", 5)==0) xof= 10; @@ -1075,7 +1089,7 @@ void ui_get_but_vectorf(uiBut *but, float *vec) vec[0]= vec[1]= vec[2]= 0.0f; if(RNA_property_type(prop) == PROP_FLOAT) { - tot= RNA_property_array_length(prop); + tot= RNA_property_array_length(&but->rnapoin, prop); tot= MIN2(tot, 3); for(a=0; a<tot; a++) @@ -1109,7 +1123,7 @@ void ui_set_but_vectorf(uiBut *but, float *vec) prop= but->rnaprop; if(RNA_property_type(prop) == PROP_FLOAT) { - tot= RNA_property_array_length(prop); + tot= RNA_property_array_length(&but->rnapoin, prop); tot= MIN2(tot, 3); for(a=0; a<tot; a++) @@ -1139,6 +1153,21 @@ int ui_is_but_float(uiBut *but) return 0; } +int ui_is_but_unit(uiBut *but) +{ + Scene *scene= CTX_data_scene((bContext *)but->block->evil_C); + if(scene->unit.system == USER_UNIT_NONE) + return 0; + + if(but->rnaprop==NULL) + return 0; + + if(RNA_SUBTYPE_UNIT_VALUE(RNA_property_subtype(but->rnaprop))==0) + return 0; + + return 1; +} + double ui_get_but_val(uiBut *but) { PropertyRNA *prop; @@ -1152,19 +1181,19 @@ double ui_get_but_val(uiBut *but) switch(RNA_property_type(prop)) { case PROP_BOOLEAN: - if(RNA_property_array_length(prop)) + if(RNA_property_array_length(&but->rnapoin, prop)) value= RNA_property_boolean_get_index(&but->rnapoin, prop, but->rnaindex); else value= RNA_property_boolean_get(&but->rnapoin, prop); break; case PROP_INT: - if(RNA_property_array_length(prop)) + if(RNA_property_array_length(&but->rnapoin, prop)) value= RNA_property_int_get_index(&but->rnapoin, prop, but->rnaindex); else value= RNA_property_int_get(&but->rnapoin, prop); break; case PROP_FLOAT: - if(RNA_property_array_length(prop)) + if(RNA_property_array_length(&but->rnapoin, prop)) value= RNA_property_float_get_index(&but->rnapoin, prop, but->rnaindex); else value= RNA_property_float_get(&but->rnapoin, prop); @@ -1216,19 +1245,19 @@ void ui_set_but_val(uiBut *but, double value) if(RNA_property_editable(&but->rnapoin, prop)) { switch(RNA_property_type(prop)) { case PROP_BOOLEAN: - if(RNA_property_array_length(prop)) + if(RNA_property_array_length(&but->rnapoin, prop)) RNA_property_boolean_set_index(&but->rnapoin, prop, but->rnaindex, value); else RNA_property_boolean_set(&but->rnapoin, prop, value); break; case PROP_INT: - if(RNA_property_array_length(prop)) + if(RNA_property_array_length(&but->rnapoin, prop)) RNA_property_int_set_index(&but->rnapoin, prop, but->rnaindex, value); else RNA_property_int_set(&but->rnapoin, prop, value); break; case PROP_FLOAT: - if(RNA_property_array_length(prop)) + if(RNA_property_array_length(&but->rnapoin, prop)) RNA_property_float_set_index(&but->rnapoin, prop, but->rnaindex, value); else RNA_property_float_set(&but->rnapoin, prop, value); @@ -1305,6 +1334,55 @@ int ui_get_but_string_max_length(uiBut *but) return UI_MAX_DRAW_STR; } +static double ui_get_but_scale_unit(uiBut *but, double value) +{ + Scene *scene= CTX_data_scene((bContext *)but->block->evil_C); + int subtype= RNA_property_subtype(but->rnaprop); + + if(subtype & PROP_UNIT_LENGTH) { + return value * scene->unit.scale_length; + } + else if(subtype & PROP_UNIT_TIME) { /* WARNING - using evil_C :| */ + return FRA2TIME(value); + } + else { + return value; + } +} + +static void ui_get_but_string_unit(uiBut *but, char *str, int len_max, double value, int pad) +{ + Scene *scene= CTX_data_scene((bContext *)but->block->evil_C); + int do_split= scene->unit.flag & USER_UNIT_OPT_SPLIT; + int unit_type= RNA_SUBTYPE_UNIT_VALUE(RNA_property_subtype(but->rnaprop)); + int precission= but->a2; + + if(scene->unit.scale_length<0.0001) scene->unit.scale_length= 1.0; // XXX do_versions + + /* Sanity checks */ + if(precission>4) precission= 4; + else if(precission==0) precission= 2; + + bUnit_AsString(str, len_max, ui_get_but_scale_unit(but, value), precission, scene->unit.system, unit_type, do_split, pad); +} + +static float ui_get_but_step_unit(uiBut *but, double value, float step_default) +{ + Scene *scene= CTX_data_scene((bContext *)but->block->evil_C); + int unit_type= RNA_SUBTYPE_UNIT_VALUE(RNA_property_subtype(but->rnaprop)); + float step; + + step = bUnit_ClosestScalar(ui_get_but_scale_unit(but, value), scene->unit.system, unit_type); + + if(step > 0.0) { /* -1 is an error value */ + return (step/ui_get_but_scale_unit(but, 1.0))*100; + } + else { + return step_default; + } +} + + void ui_get_but_string(uiBut *but, char *str, int maxlen) { if(but->rnaprop && ELEM3(but->type, TEX, IDPOIN, SEARCH_MENU)) { @@ -1360,7 +1438,10 @@ void ui_get_but_string(uiBut *but, char *str, int maxlen) value= ui_get_but_val(but); if(ui_is_but_float(but)) { - if(but->a2) { /* amount of digits defined */ + if(ui_is_but_unit(but)) { + ui_get_but_string_unit(but, str, maxlen, value, 0); + } + else if(but->a2) { /* amount of digits defined */ if(but->a2==1) BLI_snprintf(str, maxlen, "%.1f", value); else if(but->a2==2) BLI_snprintf(str, maxlen, "%.2f", value); else if(but->a2==3) BLI_snprintf(str, maxlen, "%.3f", value); @@ -1433,14 +1514,30 @@ int ui_set_but_string(bContext *C, uiBut *but, const char *str) /* number editing */ double value; - /* XXX 2.50 missing python api */ -#if 0 - if(BPY_button_eval(str, &value)) { - BKE_report(CTX_reports(C), RPT_WARNING, "Invalid Python expression, check console"); - value = 0.0f; /* Zero out value on error */ - - if(str[0]) - return 0; +#ifndef DISABLE_PYTHON + { + char str_unit_convert[256]; + int unit_type; + Scene *scene= CTX_data_scene((bContext *)but->block->evil_C); + + if(but->rnaprop) + unit_type= RNA_SUBTYPE_UNIT_VALUE(RNA_property_subtype(but->rnaprop)); + else + unit_type= 0; + + BLI_strncpy(str_unit_convert, str, sizeof(str_unit_convert)); + + if(scene->unit.system != USER_UNIT_NONE && unit_type) { + /* ugly, use the draw string to get the value, this could cause problems if it includes some text which resolves to a unit */ + bUnit_ReplaceString(str_unit_convert, sizeof(str_unit_convert), but->drawstr, ui_get_but_scale_unit(but, 1.0), scene->unit.system, unit_type); + } + + if(BPY_button_eval(C, str_unit_convert, &value)) { + value = ui_get_but_val(but); /* use its original value */ + + if(str[0]) + return 0; + } } #else value= atof(str); @@ -1786,6 +1883,12 @@ void ui_check_but(uiBut *but) if(ui_is_but_float(but)) { if(value == FLT_MAX) sprintf(but->drawstr, "%sinf", but->str); else if(value == -FLT_MAX) sprintf(but->drawstr, "%s-inf", but->str); + /* support length type buttons */ + else if(ui_is_but_unit(but)) { + char new_str[sizeof(but->drawstr)]; + ui_get_but_string_unit(but, new_str, sizeof(new_str), value, TRUE); + BLI_snprintf(but->drawstr, sizeof(but->drawstr), "%s%s", but->str, new_str); + } else if(but->a2) { /* amount of digits defined */ if(but->a2==1) sprintf(but->drawstr, "%s%.1f", but->str, value); else if(but->a2==2) sprintf(but->drawstr, "%s%.2f", but->str, value); @@ -2194,8 +2297,12 @@ uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, char *str, short x1, dynstr= BLI_dynstr_new(); BLI_dynstr_appendf(dynstr, "%s%%t", RNA_property_ui_name(prop)); for(i=0; i<totitem; i++) { - if(!item[i].identifier[0]) - BLI_dynstr_append(dynstr, "|%l"); + if(!item[i].identifier[0]) { + if(item[i].name) + BLI_dynstr_appendf(dynstr, "|%s%%l", item[i].name); + else + BLI_dynstr_append(dynstr, "|%l"); + } else if(item[i].icon) BLI_dynstr_appendf(dynstr, "|%s %%i%d %%x%d", item[i].name, item[i].icon, item[i].value); else @@ -2307,7 +2414,7 @@ uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, char *str, short x1, but->rnapoin= *ptr; but->rnaprop= prop; - if(RNA_property_array_length(but->rnaprop)) + if(RNA_property_array_length(&but->rnapoin, but->rnaprop)) but->rnaindex= index; else but->rnaindex= 0; @@ -2325,6 +2432,10 @@ uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, char *str, short x1, but->lockstr = ""; } + /* If this button uses units, calculate the step from this */ + if(ui_is_but_unit(but)) + but->a1= ui_get_but_step_unit(but, ui_get_but_val(but), but->a1); + if(freestr) MEM_freeN(str); @@ -2743,6 +2854,8 @@ void uiBlockFlipOrder(uiBlock *block) if(U.uiflag & USER_MENUFIXEDORDER) return; + else if(block->flag & UI_BLOCK_NO_FLIP) + return; for(but= block->buttons.first; but; but= but->next) { if(but->flag & UI_BUT_ALIGN) return; @@ -2835,10 +2948,11 @@ void uiButSetRenameFunc(uiBut *but, uiButHandleRenameFunc func, void *arg1) but->rename_arg1= arg1; } -void uiBlockSetDrawExtraFunc(uiBlock *block, void (*func)(const bContext *C, void *idv, void *argv, rcti *rect), void *arg) +void uiBlockSetDrawExtraFunc(uiBlock *block, void (*func)(const bContext *C, void *idv, void *arg1, void *arg2, rcti *rect), void *arg1, void *arg2) { block->drawextra= func; - block->drawextra_arg= arg; + block->drawextra_arg1= arg1; + block->drawextra_arg2= arg2; } void uiButSetFunc(uiBut *but, uiButHandleFunc func, void *arg1, void *arg2) @@ -2952,7 +3066,6 @@ uiBut *uiDefIconBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg, int but->flag|= UI_HAS_ICON; but->flag|= UI_ICON_LEFT; - but->flag|= UI_ICON_SUBMENU; but->block_create_func= func; ui_check_but(but); diff --git a/source/blender/editors/interface/interface_anim.c b/source/blender/editors/interface/interface_anim.c index 2993a1aba15..784d820ea52 100644 --- a/source/blender/editors/interface/interface_anim.c +++ b/source/blender/editors/interface/interface_anim.c @@ -217,7 +217,7 @@ void ui_but_anim_menu(bContext *C, uiBut *but) pup= uiPupMenuBegin(C, RNA_property_ui_name(but->rnaprop), 0); layout= uiPupMenuLayout(pup); - length= RNA_property_array_length(but->rnaprop); + length= RNA_property_array_length(&but->rnapoin, but->rnaprop); if(but->flag & UI_BUT_ANIMATED_KEY) { if(length) { diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 30cfafb24f8..b69e8319956 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -315,6 +315,7 @@ static void ui_apply_autokey_undo(bContext *C, uiBut *but) static void ui_apply_but_funcs_after(bContext *C) { uiAfterFunc *afterf, after; + PointerRNA opptr; ListBase funcs; /* copy to avoid recursive calls */ @@ -328,13 +329,18 @@ static void ui_apply_but_funcs_after(bContext *C) if(after.context) CTX_store_set(C, after.context); - if(after.optype) - WM_operator_name_call(C, after.optype->idname, after.opcontext, after.opptr); if(after.opptr) { - WM_operator_properties_free(after.opptr); + /* free in advance to avoid leak on exit */ + opptr= *after.opptr, MEM_freeN(after.opptr); } + if(after.optype) + WM_operator_name_call(C, after.optype->idname, after.opcontext, (after.opptr)? &opptr: NULL); + + if(after.opptr) + WM_operator_properties_free(&opptr); + if(after.rnapoin.data) RNA_property_update(C, &after.rnapoin, after.rnaprop); @@ -968,7 +974,7 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data, char *str; opptr= uiButGetOperatorPtrRNA(but); /* allocated when needed, the button owns it */ - str= WM_operator_pystring(but->optype, opptr, 0); + str= WM_operator_pystring(C, but->optype, opptr, 0); WM_clipboard_text_set(str, 0); @@ -1714,6 +1720,7 @@ static void ui_blockopen_begin(bContext *C, uiBut *but, uiHandleButtonData *data uiBlockCreateFunc func= NULL; uiBlockHandleCreateFunc handlefunc= NULL; uiMenuCreateFunc menufunc= NULL; + char *menustr= NULL; void *arg= NULL; switch(but->type) { @@ -1738,16 +1745,15 @@ static void ui_blockopen_begin(bContext *C, uiBut *but, uiHandleButtonData *data data->value= data->origvalue; but->editval= &data->value; - handlefunc= ui_block_func_MENU; - arg= but; + menustr= but->str; } break; case ICONROW: - handlefunc= ui_block_func_ICONROW; + menufunc= ui_block_func_ICONROW; arg= but; break; case ICONTEXTROW: - handlefunc= ui_block_func_ICONTEXTROW; + menufunc= ui_block_func_ICONTEXTROW; arg= but; break; case COL: @@ -1765,8 +1771,8 @@ static void ui_blockopen_begin(bContext *C, uiBut *but, uiHandleButtonData *data if(but->block->handle) data->menu->popup= but->block->handle->popup; } - else if(menufunc) { - data->menu= ui_popup_menu_create(C, data->region, but, menufunc, arg); + else if(menufunc || menustr) { + data->menu= ui_popup_menu_create(C, data->region, but, menufunc, arg, menustr); if(but->block->handle) data->menu->popup= but->block->handle->popup; } @@ -3723,10 +3729,15 @@ static void button_activate_exit(bContext *C, uiHandleButtonData *data, uiBut *b } } - /* autokey & undo push */ - if(!data->cancel) + if(!data->cancel) { + /* autokey & undo push */ ui_apply_autokey_undo(C, but); + /* popup menu memory */ + if(block->flag & UI_BLOCK_POPUP_MEMORY) + ui_popup_menu_memory(block, but); + } + /* disable tooltips until mousemove + last active flag */ for(block=data->region->uiblocks.first; block; block=block->next) { for(bt=block->buttons.first; bt; bt=bt->next) diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index 04c0c417fdb..806b40b8646 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -273,8 +273,9 @@ struct uiBlock { int (*block_event_func)(const struct bContext *C, struct uiBlock *, struct wmEvent *); /* extra draw function for custom blocks */ - void (*drawextra)(const struct bContext *C, void *idv, void *argv, rcti *rect); - void *drawextra_arg; + void (*drawextra)(const struct bContext *C, void *idv, void *arg1, void *arg2, rcti *rect); + void *drawextra_arg1; + void *drawextra_arg2; int afterval, flag; @@ -286,7 +287,8 @@ struct uiBlock { char *lockstr; float xofs, yofs; // offset to parent button - int bounds, dobounds, mx, my; // for doing delayed + int dobounds, mx, my; // for doing delayed + int bounds, minbounds; // for doing delayed int endblock; // uiEndBlock done? rctf safety; // pulldowns, to detect outside, can differ per case how it is created @@ -296,6 +298,7 @@ struct uiBlock { int tooltipdisabled; // to avoid tooltip after click int active; // to keep blocks while drawing and free them afterwards + int puphash; // popup menu hash for memory void *evil_C; // XXX hack for dynamic operator enums }; @@ -337,6 +340,7 @@ extern void ui_set_but_soft_range(uiBut *but, double value); extern void ui_check_but(uiBut *but); extern int ui_is_but_float(uiBut *but); +extern int ui_is_but_unit(uiBut *but); extern void ui_update_block_buts_hsv(uiBlock *block, float *hsv); extern void ui_bounds_block(uiBlock *block); @@ -370,14 +374,15 @@ struct uiPopupBlockHandle { float retvec[3]; }; -uiBlock *ui_block_func_MENU(struct bContext *C, uiPopupBlockHandle *handle, void *arg_but); -uiBlock *ui_block_func_ICONROW(struct bContext *C, uiPopupBlockHandle *handle, void *arg_but); -uiBlock *ui_block_func_ICONTEXTROW(struct bContext *C, uiPopupBlockHandle *handle, void *arg_but); uiBlock *ui_block_func_COL(struct bContext *C, uiPopupBlockHandle *handle, void *arg_but); +void ui_block_func_ICONROW(struct bContext *C, uiLayout *layout, void *arg_but); +void ui_block_func_ICONTEXTROW(struct bContext *C, uiLayout *layout, void *arg_but); struct ARegion *ui_tooltip_create(struct bContext *C, struct ARegion *butregion, uiBut *but); void ui_tooltip_free(struct bContext *C, struct ARegion *ar); +uiBut *ui_popup_menu_memory(uiBlock *block, uiBut *but); + /* searchbox for string button */ ARegion *ui_searchbox_create(struct bContext *C, struct ARegion *butregion, uiBut *but); int ui_searchbox_inside(struct ARegion *ar, int x, int y); @@ -392,7 +397,8 @@ typedef uiBlock* (*uiBlockHandleCreateFunc)(struct bContext *C, struct uiPopupBl uiPopupBlockHandle *ui_popup_block_create(struct bContext *C, struct ARegion *butregion, uiBut *but, uiBlockCreateFunc create_func, uiBlockHandleCreateFunc handle_create_func, void *arg); uiPopupBlockHandle *ui_popup_menu_create(struct bContext *C, struct ARegion *butregion, uiBut *but, - uiMenuCreateFunc create_func, void *arg); + uiMenuCreateFunc create_func, void *arg, char *str); + void ui_popup_block_free(struct bContext *C, uiPopupBlockHandle *handle); void ui_set_name_menu(uiBut *but, int value); diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 6932ad350b0..a52afcb1a92 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -215,16 +215,16 @@ static int ui_layout_vary_direction(uiLayout *layout) } /* estimated size of text + icon */ -static int ui_text_icon_width(uiLayout *layout, char *name, int icon) +static int ui_text_icon_width(uiLayout *layout, char *name, int icon, int compact) { int variable = ui_layout_vary_direction(layout) == UI_ITEM_VARY_X; if(icon && !name[0]) return UI_UNIT_X; /* icon only */ else if(icon) - return (variable)? UI_GetStringWidth(name) + 4 + UI_UNIT_X: 10*UI_UNIT_X; /* icon + text */ + return (variable)? UI_GetStringWidth(name) + (compact? 5: 10) + UI_UNIT_X: 10*UI_UNIT_X; /* icon + text */ else - return (variable)? UI_GetStringWidth(name) + 4 + UI_UNIT_X: 10*UI_UNIT_X; /* text only */ + return (variable)? UI_GetStringWidth(name) + (compact? 5: 10) + UI_UNIT_X: 10*UI_UNIT_X; /* text only */ } static void ui_item_size(uiItem *item, int *r_w, int *r_h) @@ -379,31 +379,25 @@ static void ui_item_array(uiLayout *layout, uiBlock *block, char *name, int icon but->type= NUMSLI; } } - else if(len <= 4 && ELEM3(subtype, PROP_ROTATION, PROP_VECTOR, PROP_COLOR)) { - if(subtype == PROP_COLOR) + else { + if(ELEM(subtype, PROP_COLOR, PROP_RGB)) uiDefAutoButR(block, ptr, prop, -1, "", 0, 0, 0, w, UI_UNIT_Y); - if(subtype != PROP_COLOR || expand) { + if(!ELEM(subtype, PROP_COLOR, PROP_RGB) || expand) { /* layout for known array subtypes */ - static char vectoritem[4]= {'X', 'Y', 'Z', 'W'}; - static char quatitem[4]= {'W', 'X', 'Y', 'Z'}; - static char coloritem[4]= {'R', 'G', 'B', 'A'}; char str[3]; for(a=0; a<len; a++) { - if(len == 4 && subtype == PROP_ROTATION) - str[0]= quatitem[a]; - else if(subtype == PROP_VECTOR || subtype == PROP_ROTATION) - str[0]= vectoritem[a]; - else - str[0]= coloritem[a]; - - if(type == PROP_BOOLEAN) { - str[1]= '\0'; - } - else { - str[1]= ':'; - str[2]= '\0'; + str[0]= RNA_property_array_item_char(prop, a); + + if(str[0]) { + if(type == PROP_BOOLEAN) { + str[1]= '\0'; + } + else { + str[1]= ':'; + str[2]= '\0'; + } } but= uiDefAutoButR(block, ptr, prop, a, str, 0, 0, 0, w, UI_UNIT_Y); @@ -411,19 +405,12 @@ static void ui_item_array(uiLayout *layout, uiBlock *block, char *name, int icon but->type= NUMSLI; } } - else if(subtype == PROP_COLOR && len == 4) { + else if(ELEM(subtype, PROP_COLOR, PROP_RGB) && len == 4) { but= uiDefAutoButR(block, ptr, prop, 3, "A:", 0, 0, 0, w, UI_UNIT_Y); if(slider && but->type==NUM) but->type= NUMSLI; } } - else { - for(a=0; a<len; a++) { - but= uiDefAutoButR(block, ptr, prop, a, "", 0, 0, 0, w, UI_UNIT_Y); - if(slider && but->type==NUM) - but->type= NUMSLI; - } - } uiBlockSetCurLayout(block, layout); } @@ -446,7 +433,7 @@ static void ui_item_enum_row(uiLayout *layout, uiBlock *block, PointerRNA *ptr, name= (!uiname || uiname[0])? (char*)item[a].name: ""; icon= item[a].icon; value= item[a].value; - itemw= ui_text_icon_width(block->curlayout, name, icon); + itemw= ui_text_icon_width(block->curlayout, name, icon, 0); if(icon && strcmp(name, "") != 0) uiDefIconTextButR(block, ROW, 0, icon, name, 0, 0, itemw, h, ptr, identifier, -1, 0, value, -1, -1, NULL); @@ -539,7 +526,7 @@ static void ui_item_disabled(uiLayout *layout, char *name) if(!name) name= ""; - w= ui_text_icon_width(layout, name, 0); + w= ui_text_icon_width(layout, name, 0, 0); but= uiDefBut(block, LABEL, 0, (char*)name, 0, 0, w, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, ""); but->flag |= UI_BUT_DISABLED; @@ -548,7 +535,7 @@ static void ui_item_disabled(uiLayout *layout, char *name) } /* operator items */ -void uiItemFullO(uiLayout *layout, char *name, int icon, char *idname, IDProperty *properties, int context) +PointerRNA uiItemFullO(uiLayout *layout, char *name, int icon, char *idname, IDProperty *properties, int context, int flag) { uiBlock *block= layout->root->block; wmOperatorType *ot= WM_operatortype_find(idname, 0); @@ -557,7 +544,7 @@ void uiItemFullO(uiLayout *layout, char *name, int icon, char *idname, IDPropert if(!ot) { ui_item_disabled(layout, idname); - return; + return PointerRNA_NULL; } if(!name) @@ -568,7 +555,7 @@ void uiItemFullO(uiLayout *layout, char *name, int icon, char *idname, IDPropert /* create button */ uiBlockSetCurLayout(block, layout); - w= ui_text_icon_width(layout, name, icon); + w= ui_text_icon_width(layout, name, icon, 0); if(icon && strcmp(name, "") != 0) but= uiDefIconTextButO(block, BUT, ot->idname, context, icon, (char*)name, 0, 0, w, UI_UNIT_Y, NULL); @@ -578,10 +565,21 @@ void uiItemFullO(uiLayout *layout, char *name, int icon, char *idname, IDPropert but= uiDefButO(block, BUT, ot->idname, context, (char*)name, 0, 0, w, UI_UNIT_Y, NULL); /* assign properties */ - if(properties) { + if(properties || (flag & UI_ITEM_O_RETURN_PROPS)) { PointerRNA *opptr= uiButGetOperatorPtrRNA(but); - opptr->data= properties; + + if(properties) { + opptr->data= properties; + } + else { + IDPropertyTemplate val = {0}; + opptr->data= IDP_New(IDP_GROUP, val, "wmOperatorProperties"); + } + + return *opptr; } + + return PointerRNA_NULL; } static char *ui_menu_enumpropname(uiLayout *layout, char *opname, char *propname, int retval) @@ -624,7 +622,7 @@ void uiItemEnumO(uiLayout *layout, char *name, int icon, char *opname, char *pro if(!name) name= ui_menu_enumpropname(layout, opname, propname, value); - uiItemFullO(layout, name, icon, opname, ptr.data, layout->root->opcontext); + uiItemFullO(layout, name, icon, opname, ptr.data, layout->root->opcontext, 0); } void uiItemsEnumO(uiLayout *layout, char *opname, char *propname) @@ -632,6 +630,8 @@ void uiItemsEnumO(uiLayout *layout, char *opname, char *propname) wmOperatorType *ot= WM_operatortype_find(opname, 0); PointerRNA ptr; PropertyRNA *prop; + uiBut *bt; + uiBlock *block= layout->root->block; if(!ot || !ot->srna) { ui_item_disabled(layout, opname); @@ -644,14 +644,31 @@ void uiItemsEnumO(uiLayout *layout, char *opname, char *propname) if(prop && RNA_property_type(prop) == PROP_ENUM) { EnumPropertyItem *item; int totitem, i, free; + uiLayout *split= uiLayoutSplit(layout, 0); + uiLayout *column= uiLayoutColumn(split, 0); - RNA_property_enum_items(layout->root->block->evil_C, &ptr, prop, &item, &totitem, &free); + RNA_property_enum_items(block->evil_C, &ptr, prop, &item, &totitem, &free); - for(i=0; i<totitem; i++) - if(item[i].identifier[0]) - uiItemEnumO(layout, (char*)item[i].name, item[i].icon, opname, propname, item[i].value); - else - uiItemS(layout); + for(i=0; i<totitem; i++) { + if(item[i].identifier[0]) { + uiItemEnumO(column, (char*)item[i].name, item[i].icon, opname, propname, item[i].value); + } + else { + if(item[i].name) { + if(i != 0) { + column= uiLayoutColumn(split, 0); + /* inconsistent, but menus with labels do not look good flipped */ + block->flag |= UI_BLOCK_NO_FLIP; + } + + uiItemL(column, (char*)item[i].name, 0); + bt= block->buttons.last; + bt->flag= UI_TEXT_LEFT; + } + else + uiItemS(column); + } + } if(free) MEM_freeN(item); @@ -693,7 +710,7 @@ void uiItemEnumO_string(uiLayout *layout, char *name, int icon, char *opname, ch if(!name) name= ui_menu_enumpropname(layout, opname, propname, value); - uiItemFullO(layout, name, icon, opname, ptr.data, layout->root->opcontext); + uiItemFullO(layout, name, icon, opname, ptr.data, layout->root->opcontext, 0); } void uiItemBooleanO(uiLayout *layout, char *name, int icon, char *opname, char *propname, int value) @@ -703,7 +720,7 @@ void uiItemBooleanO(uiLayout *layout, char *name, int icon, char *opname, char * WM_operator_properties_create(&ptr, opname); RNA_boolean_set(&ptr, propname, value); - uiItemFullO(layout, name, icon, opname, ptr.data, layout->root->opcontext); + uiItemFullO(layout, name, icon, opname, ptr.data, layout->root->opcontext, 0); } void uiItemIntO(uiLayout *layout, char *name, int icon, char *opname, char *propname, int value) @@ -713,7 +730,7 @@ void uiItemIntO(uiLayout *layout, char *name, int icon, char *opname, char *prop WM_operator_properties_create(&ptr, opname); RNA_int_set(&ptr, propname, value); - uiItemFullO(layout, name, icon, opname, ptr.data, layout->root->opcontext); + uiItemFullO(layout, name, icon, opname, ptr.data, layout->root->opcontext, 0); } void uiItemFloatO(uiLayout *layout, char *name, int icon, char *opname, char *propname, float value) @@ -723,7 +740,7 @@ void uiItemFloatO(uiLayout *layout, char *name, int icon, char *opname, char *pr WM_operator_properties_create(&ptr, opname); RNA_float_set(&ptr, propname, value); - uiItemFullO(layout, name, icon, opname, ptr.data, layout->root->opcontext); + uiItemFullO(layout, name, icon, opname, ptr.data, layout->root->opcontext, 0); } void uiItemStringO(uiLayout *layout, char *name, int icon, char *opname, char *propname, char *value) @@ -733,17 +750,17 @@ void uiItemStringO(uiLayout *layout, char *name, int icon, char *opname, char *p WM_operator_properties_create(&ptr, opname); RNA_string_set(&ptr, propname, value); - uiItemFullO(layout, name, icon, opname, ptr.data, layout->root->opcontext); + uiItemFullO(layout, name, icon, opname, ptr.data, layout->root->opcontext, 0); } void uiItemO(uiLayout *layout, char *name, int icon, char *opname) { - uiItemFullO(layout, name, icon, opname, NULL, layout->root->opcontext); + uiItemFullO(layout, name, icon, opname, NULL, layout->root->opcontext, 0); } /* RNA property items */ -static void ui_item_rna_size(uiLayout *layout, char *name, int icon, PropertyRNA *prop, int index, int *r_w, int *r_h) +static void ui_item_rna_size(uiLayout *layout, char *name, int icon, PointerRNA *ptr, PropertyRNA *prop, int index, int *r_w, int *r_h) { PropertyType type; PropertySubType subtype; @@ -752,14 +769,14 @@ static void ui_item_rna_size(uiLayout *layout, char *name, int icon, PropertyRNA /* arbitrary extended width by type */ type= RNA_property_type(prop); subtype= RNA_property_subtype(prop); - len= RNA_property_array_length(prop); + len= RNA_property_array_length(ptr, prop); if(ELEM3(type, PROP_STRING, PROP_POINTER, PROP_ENUM) && !name[0]) name= "non-empty text"; else if(type == PROP_BOOLEAN && !name[0]) icon= ICON_DOT; - w= ui_text_icon_width(layout, name, icon); + w= ui_text_icon_width(layout, name, icon, 0); h= UI_UNIT_Y; /* increase height for arrays */ @@ -776,22 +793,24 @@ static void ui_item_rna_size(uiLayout *layout, char *name, int icon, PropertyRNA } else if(ui_layout_vary_direction(layout) == UI_ITEM_VARY_X) { if(type == PROP_BOOLEAN && strcmp(name, "") != 0) - w += UI_UNIT_X; + w += UI_UNIT_X/5; else if(type == PROP_ENUM) w += UI_UNIT_X/2; + else if(type == PROP_FLOAT || type == PROP_INT) + w += UI_UNIT_X*3; } *r_w= w; *r_h= h; } -void uiItemFullR(uiLayout *layout, char *name, int icon, PointerRNA *ptr, PropertyRNA *prop, int index, int value, int expand, int slider, int toggle) +void uiItemFullR(uiLayout *layout, char *name, int icon, PointerRNA *ptr, PropertyRNA *prop, int index, int value, int flag) { uiBlock *block= layout->root->block; uiBut *but; PropertyType type; char namestr[UI_MAX_NAME_STR]; - int len, w, h; + int len, w, h, slider, toggle, expand; if(!ptr->data || !prop) return; @@ -800,7 +819,7 @@ void uiItemFullR(uiLayout *layout, char *name, int icon, PointerRNA *ptr, Proper /* retrieve info */ type= RNA_property_type(prop); - len= RNA_property_array_length(prop); + len= RNA_property_array_length(ptr, prop); /* set name and icon */ if(!name) @@ -822,8 +841,12 @@ void uiItemFullR(uiLayout *layout, char *name, int icon, PointerRNA *ptr, Proper icon= (RNA_property_enum_get(ptr, prop) == value)? ICON_CHECKBOX_HLT: ICON_CHECKBOX_DEHLT; } + slider= (flag & UI_ITEM_R_SLIDER); + toggle= (flag & UI_ITEM_R_TOGGLE); + expand= (flag & UI_ITEM_R_EXPAND); + /* get size */ - ui_item_rna_size(layout, name, icon, prop, index, &w, &h); + ui_item_rna_size(layout, name, icon, ptr, prop, index, &w, &h); /* array property */ if(index == RNA_NO_INDEX && len > 0) @@ -859,7 +882,7 @@ void uiItemFullR(uiLayout *layout, char *name, int icon, PointerRNA *ptr, Proper } } -void uiItemR(uiLayout *layout, char *name, int icon, PointerRNA *ptr, char *propname, int expand, int slider, int toggle) +void uiItemR(uiLayout *layout, char *name, int icon, PointerRNA *ptr, char *propname, int flag) { PropertyRNA *prop; @@ -874,7 +897,7 @@ void uiItemR(uiLayout *layout, char *name, int icon, PointerRNA *ptr, char *prop return; } - uiItemFullR(layout, name, icon, ptr, prop, RNA_NO_INDEX, 0, expand, slider, toggle); + uiItemFullR(layout, name, icon, ptr, prop, RNA_NO_INDEX, 0, flag); } void uiItemEnumR(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, char *propname, int value) @@ -892,7 +915,7 @@ void uiItemEnumR(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, return; } - uiItemFullR(layout, name, icon, ptr, prop, RNA_ENUM_VALUE, value, 0, 0, 0); + uiItemFullR(layout, name, icon, ptr, prop, RNA_ENUM_VALUE, value, 0); } void uiItemEnumR_string(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, char *propname, char *value) @@ -923,7 +946,7 @@ void uiItemEnumR_string(uiLayout *layout, char *name, int icon, struct PointerRN for(a=0; item[a].identifier; a++) { if(item[a].value == ivalue) { - uiItemFullR(layout, (char*)item[a].name, item[a].icon, ptr, prop, RNA_ENUM_VALUE, ivalue, 0, 0, 0); + uiItemFullR(layout, (char*)item[a].name, item[a].icon, ptr, prop, RNA_ENUM_VALUE, ivalue, 0); break; } } @@ -935,6 +958,8 @@ void uiItemEnumR_string(uiLayout *layout, char *name, int icon, struct PointerRN void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, char *propname) { PropertyRNA *prop; + uiBlock *block= layout->root->block; + uiBut *bt; prop= RNA_struct_find_property(ptr, propname); @@ -946,14 +971,31 @@ void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, char *propname) if(RNA_property_type(prop) == PROP_ENUM) { EnumPropertyItem *item; int totitem, i, free; + uiLayout *split= uiLayoutSplit(layout, 0); + uiLayout *column= uiLayoutColumn(split, 0); - RNA_property_enum_items(layout->root->block->evil_C, ptr, prop, &item, &totitem, &free); + RNA_property_enum_items(block->evil_C, ptr, prop, &item, &totitem, &free); - for(i=0; i<totitem; i++) - if(item[i].identifier[0]) - uiItemEnumR(layout, (char*)item[i].name, 0, ptr, propname, item[i].value); - else - uiItemS(layout); + for(i=0; i<totitem; i++) { + if(item[i].identifier[0]) { + uiItemEnumR(column, (char*)item[i].name, 0, ptr, propname, item[i].value); + } + else { + if(item[i].name) { + if(i != 0) { + column= uiLayoutColumn(split, 0); + /* inconsistent, but menus with labels do not look good flipped */ + block->flag |= UI_BLOCK_NO_FLIP; + } + + uiItemL(column, (char*)item[i].name, 0); + bt= block->buttons.last; + bt->flag= UI_TEXT_LEFT; + } + else + uiItemS(column); + } + } if(free) MEM_freeN(item); @@ -1090,7 +1132,7 @@ void uiItemPointerR(uiLayout *layout, char *name, int icon, struct PointerRNA *p /* create button */ block= uiLayoutGetBlock(layout); - ui_item_rna_size(layout, name, icon, prop, 0, &w, &h); + ui_item_rna_size(layout, name, icon, ptr, prop, 0, &w, &h); but= ui_item_with_label(layout, block, name, icon, ptr, prop, 0, 0, 0, w, h); ui_but_add_search(but, ptr, prop, searchptr, searchprop); @@ -1123,7 +1165,7 @@ static void ui_item_menu(uiLayout *layout, char *name, int icon, uiMenuCreateFun if(layout->root->type == UI_LAYOUT_MENU && !icon) icon= ICON_BLANK1; - w= ui_text_icon_width(layout, name, icon); + w= ui_text_icon_width(layout, name, icon, 1); h= UI_UNIT_Y; if(layout->root->type == UI_LAYOUT_HEADER) /* ugly .. */ @@ -1181,7 +1223,7 @@ void uiItemL(uiLayout *layout, char *name, int icon) if(layout->root->type == UI_LAYOUT_MENU && !icon) icon= ICON_BLANK1; - w= ui_text_icon_width(layout, name, icon); + w= ui_text_icon_width(layout, name, icon, 0); if(icon && strcmp(name, "") != 0) but= uiDefIconTextBut(block, LABEL, 0, icon, (char*)name, 0, 0, w, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, ""); @@ -1206,7 +1248,7 @@ void uiItemV(uiLayout *layout, char *name, int icon, int argval) if(layout->root->type == UI_LAYOUT_MENU && !icon) icon= ICON_BLANK1; - w= ui_text_icon_width(layout, name, icon); + w= ui_text_icon_width(layout, name, icon, 0); if(icon && strcmp(name, "") != 0) uiDefIconTextButF(block, BUTM, 0, icon, (char*)name, 0, 0, w, UI_UNIT_Y, retvalue, 0.0, 0.0, 0, argval, ""); @@ -1226,12 +1268,12 @@ void uiItemS(uiLayout *layout) } /* level items */ -void uiItemMenuF(uiLayout *layout, char *name, int icon, uiMenuCreateFunc func) +void uiItemMenuF(uiLayout *layout, char *name, int icon, uiMenuCreateFunc func, void *arg) { if(!func) return; - ui_item_menu(layout, name, icon, func, NULL, NULL); + ui_item_menu(layout, name, icon, func, arg, NULL); } typedef struct MenuItemLevel { @@ -1984,6 +2026,11 @@ int uiLayoutGetAlignment(uiLayout *layout) return layout->alignment; } +int uiLayoutGetWidth(uiLayout *layout) +{ + return layout->w; +} + float uiLayoutGetScaleX(uiLayout *layout) { return layout->scale[0]; diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index 846fbe75072..05001109b53 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -104,7 +104,7 @@ static int panel_aligned(ScrArea *sa, ARegion *ar) SpaceButs *sbuts= sa->spacedata.first; return sbuts->align; } - else if(sa->spacetype==SPACE_INFO && ar->regiontype == RGN_TYPE_WINDOW) + else if(sa->spacetype==SPACE_USERPREF && ar->regiontype == RGN_TYPE_WINDOW) return BUT_VERTICAL; else if(sa->spacetype==SPACE_FILE && ar->regiontype == RGN_TYPE_CHANNELS) return BUT_VERTICAL; @@ -1247,7 +1247,7 @@ int ui_handler_panel_region(bContext *C, wmEvent *event) if(!pa || pa->paneltab!=NULL) continue; - if(pa->type && pa->type->flag & PNL_NO_HEADER) + if(pa->type && pa->type->flag & PNL_NO_HEADER) // XXX - accessed freed panels when scripts reload, need to fix. continue; if(block->minx <= mx && block->maxx >= mx) diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index b59db055647..1d911fef418 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -38,6 +38,7 @@ #include "BLI_arithb.h" #include "BLI_blenlib.h" #include "BLI_dynstr.h" +#include "BLI_ghash.h" #include "BKE_context.h" #include "BKE_icons.h" @@ -75,13 +76,14 @@ /*********************** Menu Data Parsing ********************* */ -typedef struct { +typedef struct MenuEntry { char *str; int retval; int icon; + int sepr; } MenuEntry; -typedef struct { +typedef struct MenuData { char *instr; char *title; int titleicon; @@ -111,7 +113,7 @@ static void menudata_set_title(MenuData *md, char *title, int titleicon) md->titleicon= titleicon; } -static void menudata_add_item(MenuData *md, char *str, int retval, int icon) +static void menudata_add_item(MenuData *md, char *str, int retval, int icon, int sepr) { if (md->nitems==md->itemssize) { int nsize= md->itemssize?(md->itemssize<<1):1; @@ -129,6 +131,7 @@ static void menudata_add_item(MenuData *md, char *str, int retval, int icon) md->items[md->nitems].str= str; md->items[md->nitems].retval= retval; md->items[md->nitems].icon= icon; + md->items[md->nitems].sepr= sepr; md->nitems++; } @@ -142,12 +145,13 @@ void menudata_free(MenuData *md) /** * Parse menu description strings, string is of the - * form "[sss%t|]{(sss[%xNN]|), (%l|)}", ssss%t indicates the + * form "[sss%t|]{(sss[%xNN]|), (%l|), (sss%l|)}", ssss%t indicates the * menu title, sss or sss%xNN indicates an option, * if %xNN is given then NN is the return value if * that option is selected otherwise the return value * is the index of the option (starting with 1). %l - * indicates a seperator. + * indicates a seperator, sss%l indicates a label and + * new column. * * @param str String to be parsed. * @retval new menudata structure, free with menudata_free() @@ -157,7 +161,7 @@ MenuData *decompose_menu_string(char *str) char *instr= BLI_strdup(str); MenuData *md= menudata_new(instr); char *nitem= NULL, *s= instr; - int nicon=0, nretval= 1, nitem_is_title= 0; + int nicon=0, nretval= 1, nitem_is_title= 0, nitem_is_sepr= 0; while (1) { char c= *s; @@ -174,7 +178,10 @@ MenuData *decompose_menu_string(char *str) *s= '\0'; s++; } else if (s[1]=='l') { - nitem= "%l"; + nitem_is_sepr= 1; + if(!nitem) nitem= ""; + + *s= '\0'; s++; } else if (s[1]=='i') { nicon= atoi(s+2); @@ -186,15 +193,18 @@ MenuData *decompose_menu_string(char *str) if (nitem) { *s= '\0'; - if (nitem_is_title) { + if(nitem_is_title) { menudata_set_title(md, nitem, nicon); nitem_is_title= 0; - } else { + } + else if(nitem_is_sepr) { /* prevent separator to get a value */ - if(nitem[0]=='%' && nitem[1]=='l') - menudata_add_item(md, nitem, -1, nicon); - else - menudata_add_item(md, nitem, nretval, nicon); + menudata_add_item(md, nitem, -1, nicon, 1); + nretval= md->nitems+1; + nitem_is_sepr= 0; + } + else { + menudata_add_item(md, nitem, nretval, nicon, 0); nretval= md->nitems+1; } @@ -396,7 +406,7 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but) char *str; opptr= uiButGetOperatorPtrRNA(but); /* allocated when needed, the button owns it */ - str= WM_operator_pystring(but->optype, opptr, 0); + str= WM_operator_pystring(C, but->optype, opptr, 0); /* operator info */ BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), "Python: %s", str); @@ -827,6 +837,8 @@ static void ui_searchbox_region_free(ARegion *ar) ar->regiondata= NULL; } +static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but, uiBlock *block); + ARegion *ui_searchbox_create(bContext *C, ARegion *butregion, uiBut *but) { uiStyle *style= U.uistyles.first; // XXX pass on as arg @@ -847,7 +859,7 @@ ARegion *ui_searchbox_create(bContext *C, ARegion *butregion, uiBut *but) /* create searchbox data */ data= MEM_callocN(sizeof(uiSearchboxData), "uiSearchboxData"); - + /* set font, get bb */ data->fstyle= style->widget; /* copy struct */ data->fstyle.align= UI_STYLE_TEXT_CENTER; @@ -929,10 +941,14 @@ ARegion *ui_searchbox_create(bContext *C, ARegion *butregion, uiBut *but) } } if(y1 < 0) { - y1 += 36; - y2 += 36; + int newy1; + UI_view2d_to_region_no_clip(&butregion->v2d, 0, but->y2 + ofsy, 0, &newy1); + newy1 += butregion->winrct.ymin; + + y2= y2-y1 + newy1; + y1= newy1; } - + /* widget rect, in region coords */ data->bbox.xmin= MENU_SHADOW_SIDE; data->bbox.xmax= x2-x1 + MENU_SHADOW_SIDE; @@ -1310,24 +1326,21 @@ void ui_popup_block_free(bContext *C, uiPopupBlockHandle *handle) /***************************** Menu Button ***************************/ -uiBlock *ui_block_func_MENU(bContext *C, uiPopupBlockHandle *handle, void *arg_but) +static void ui_block_func_MENUSTR(bContext *C, uiLayout *layout, void *arg_str) { - uiBut *but= arg_but; - uiBlock *block; + uiBlock *block= uiLayoutGetBlock(layout); + uiPopupBlockHandle *handle= block->handle; + uiLayout *split, *column=NULL; uiBut *bt; MenuData *md; - ListBase lb; - float aspect; - int width, height, boxh, columns, rows, startx, starty, x1, y1, xmax, a; - - /* create the block */ - block= uiBeginBlock(C, handle->region, "menu", UI_EMBOSSP); - block->flag= UI_BLOCK_LOOP|UI_BLOCK_REDRAW|UI_BLOCK_NUMSELECT; + MenuEntry *entry; + char *instr= arg_str; + int columns, rows, a, b; /* compute menu data */ - md= decompose_menu_string(but->str); + md= decompose_menu_string(instr); - /* columns and row calculation */ + /* columns and row estimation */ columns= (md->nitems+20)/20; if(columns<1) columns= 1; @@ -1339,180 +1352,114 @@ uiBlock *ui_block_func_MENU(bContext *C, uiPopupBlockHandle *handle, void *arg_b rows= 1; while(rows*columns<md->nitems) rows++; - - /* prevent scaling up of pupmenu */ - aspect= but->block->aspect; - if(aspect < 1.0f) - aspect = 1.0f; - - /* size and location */ - if(md->title) - width= 1.5*aspect*strlen(md->title)+UI_GetStringWidth(md->title); - else - width= 0; - for(a=0; a<md->nitems; a++) { - xmax= aspect*UI_GetStringWidth(md->items[a].str); - if(md->items[a].icon) - xmax += 20*aspect; - if(xmax>width) - width= xmax; - } - - width+= 10; - if(width < (but->x2 - but->x1)) - width = (but->x2 - but->x1); - if(width<50) - width=50; - - boxh= MENU_BUTTON_HEIGHT; - - height= rows*boxh; - if(md->title) - height+= boxh; - - /* here we go! */ - startx= but->x1; - starty= but->y1; - + /* create title */ if(md->title) { - uiBut *bt; - - if (md->titleicon) { - bt= uiDefIconTextBut(block, LABEL, 0, md->titleicon, md->title, startx, (short)(starty+rows*boxh), (short)width, (short)boxh, NULL, 0.0, 0.0, 0, 0, ""); - } else { - bt= uiDefBut(block, LABEL, 0, md->title, startx, (short)(starty+rows*boxh), (short)width, (short)boxh, NULL, 0.0, 0.0, 0, 0, ""); + if(md->titleicon) { + uiItemL(layout, md->title, md->titleicon); + } + else { + uiItemL(layout, md->title, 0); + bt= block->buttons.last; bt->flag= UI_TEXT_LEFT; } } - for(a=0; a<md->nitems; a++) { + /* inconsistent, but menus with labels do not look good flipped */ + for(a=0, b=0; a<md->nitems; a++, b++) { + entry= &md->items[a]; + + if(entry->sepr && entry->str[0]) + block->flag |= UI_BLOCK_NO_FLIP; + } + + /* create items */ + split= uiLayoutSplit(layout, 0); + + for(a=0, b=0; a<md->nitems; a++, b++) { + if(block->flag & UI_BLOCK_NO_FLIP) + entry= &md->items[a]; + else + entry= &md->items[md->nitems-a-1]; - x1= startx + width*((int)(md->nitems-a-1)/rows); - y1= starty - boxh*(rows - ((md->nitems - a - 1)%rows)) + (rows*boxh); + /* new column on N rows or on separation label */ + if((b % rows == 0) || (entry->sepr && entry->str[0])) { + column= uiLayoutColumn(split, 0); + b= 0; + } - if (strcmp(md->items[md->nitems-a-1].str, "%l")==0) { - bt= uiDefBut(block, SEPR, B_NOP, "", x1, y1,(short)(width-(rows>1)), (short)(boxh-1), NULL, 0.0, 0.0, 0, 0, ""); + if(entry->sepr) { + uiItemL(column, entry->str, entry->icon); + bt= block->buttons.last; + bt->flag= UI_TEXT_LEFT; } - else if(md->items[md->nitems-a-1].icon) { - bt= uiDefIconTextButF(block, BUTM|FLO, B_NOP, md->items[md->nitems-a-1].icon ,md->items[md->nitems-a-1].str, x1, y1,(short)(width-(rows>1)), (short)(boxh-1), &handle->retvalue, (float) md->items[md->nitems-a-1].retval, 0.0, 0, 0, ""); + else if(entry->icon) { + uiDefIconTextButF(block, BUTM|FLO, B_NOP, entry->icon, entry->str, 0, 0, + UI_UNIT_X*5, UI_UNIT_Y, &handle->retvalue, (float) entry->retval, 0.0, 0, 0, ""); } else { - bt= uiDefButF(block, BUTM|FLO, B_NOP, md->items[md->nitems-a-1].str, x1, y1,(short)(width-(rows>1)), (short)(boxh-1), &handle->retvalue, (float) md->items[md->nitems-a-1].retval, 0.0, 0, 0, ""); + uiDefButF(block, BUTM|FLO, B_NOP, entry->str, 0, 0, + UI_UNIT_X*5, UI_UNIT_X, &handle->retvalue, (float) entry->retval, 0.0, 0, 0, ""); } } menudata_free(md); - - /* the code up here has flipped locations, because of change of preferred order */ - /* thats why we have to switch list order too, to make arrowkeys work */ - - lb.first= lb.last= NULL; - bt= block->buttons.first; - while(bt) { - uiBut *next= bt->next; - BLI_remlink(&block->buttons, bt); - BLI_addhead(&lb, bt); - bt= next; - } - block->buttons= lb; - - block->direction= UI_TOP; - uiEndBlock(C, block); - - return block; } -uiBlock *ui_block_func_ICONROW(bContext *C, uiPopupBlockHandle *handle, void *arg_but) +void ui_block_func_ICONROW(bContext *C, uiLayout *layout, void *arg_but) { + uiBlock *block= uiLayoutGetBlock(layout); + uiPopupBlockHandle *handle= block->handle; uiBut *but= arg_but; - uiBlock *block; int a; - block= uiBeginBlock(C, handle->region, "menu", UI_EMBOSSP); - block->flag= UI_BLOCK_LOOP|UI_BLOCK_REDRAW|UI_BLOCK_NUMSELECT; - - for(a=(int)but->hardmin; a<=(int)but->hardmax; a++) { - uiDefIconButF(block, BUTM|FLO, B_NOP, but->icon+(a-but->hardmin), 0, (short)(18*a), (short)(but->x2-but->x1-4), 18, &handle->retvalue, (float)a, 0.0, 0, 0, ""); - } - - block->direction= UI_TOP; - - uiEndBlock(C, block); - - return block; + for(a=(int)but->hardmin; a<=(int)but->hardmax; a++) + uiDefIconButF(block, BUTM|FLO, B_NOP, but->icon+(a-but->hardmin), 0, 0, UI_UNIT_X*5, UI_UNIT_Y, + &handle->retvalue, (float)a, 0.0, 0, 0, ""); } -uiBlock *ui_block_func_ICONTEXTROW(bContext *C, uiPopupBlockHandle *handle, void *arg_but) +void ui_block_func_ICONTEXTROW(bContext *C, uiLayout *layout, void *arg_but) { - uiBut *but= arg_but; - uiBlock *block; + uiBlock *block= uiLayoutGetBlock(layout); + uiPopupBlockHandle *handle= block->handle; + uiBut *but= arg_but, *bt; MenuData *md; - int width, xmax, ypos, a; - - block= uiBeginBlock(C, handle->region, "menu", UI_EMBOSSP); - block->flag= UI_BLOCK_LOOP|UI_BLOCK_REDRAW|UI_BLOCK_NUMSELECT; + MenuEntry *entry; + int a; md= decompose_menu_string(but->str); - /* size and location */ - /* expand menu width to fit labels */ - if(md->title) - width= 2*strlen(md->title)+UI_GetStringWidth(md->title); - else - width= 0; - - for(a=0; a<md->nitems; a++) { - xmax= UI_GetStringWidth(md->items[a].str); - if(xmax>width) width= xmax; + /* title */ + if(md->title) { + bt= uiDefBut(block, LABEL, 0, md->title, 0, 0, UI_UNIT_X*5, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, ""); + bt->flag= UI_TEXT_LEFT; } - width+= 30; - if (width<50) width=50; - - ypos = 1; - /* loop through the menu options and draw them out with icons & text labels */ for(a=0; a<md->nitems; a++) { + entry= &md->items[md->nitems-a-1]; - /* add a space if there's a separator (%l) */ - if (strcmp(md->items[a].str, "%l")==0) { - ypos +=3; - } - else { - uiDefIconTextButF(block, BUTM|FLO, B_NOP, (short)((but->icon)+(md->items[a].retval-but->hardmin)), md->items[a].str, 0, ypos,(short)width, 19, &handle->retvalue, (float) md->items[a].retval, 0.0, 0, 0, ""); - ypos += 20; - } + if(entry->sepr) + uiItemS(layout); + else + uiDefIconTextButF(block, BUTM|FLO, B_NOP, (short)((but->icon)+(entry->retval-but->hardmin)), entry->str, + 0, 0, UI_UNIT_X*5, UI_UNIT_Y, &handle->retvalue, (float) entry->retval, 0.0, 0, 0, ""); } - - if(md->title) { - uiBut *bt; - bt= uiDefBut(block, LABEL, 0, md->title, 0, ypos, (short)width, 19, NULL, 0.0, 0.0, 0, 0, ""); - bt->flag= UI_TEXT_LEFT; - } - menudata_free(md); - - block->direction= UI_TOP; - - uiBoundsBlock(block, 3); - uiEndBlock(C, block); - - return block; } +#if 0 static void ui_warp_pointer(short x, short y) { /* XXX 2.50 which function to use for this? */ -#if 0 /* OSX has very poor mousewarp support, it sends events; this causes a menu being pressed immediately ... */ #ifndef __APPLE__ warp_pointer(x, y); #endif -#endif } +#endif /********************* Color Button ****************/ @@ -2158,406 +2105,115 @@ void uiBlockColorbandButtons(uiBlock *block, ColorBand *coba, rctf *butr, int ev } -/* ******************** PUPmenu ****************** */ - -static int pupmenu_set= 0; +/************************ Popup Menu Memory ****************************/ -void uiPupMenuSetActive(int val) +static int ui_popup_menu_hash(char *str) { - pupmenu_set= val; + return BLI_ghashutil_strhash(str); } -/* value== -1 read, otherwise set */ -static int pupmenu_memory(char *str, int value) +/* but == NULL read, otherwise set */ +uiBut *ui_popup_menu_memory(uiBlock *block, uiBut *but) { static char mem[256], first=1; - int val=0, nr=0; + int hash= block->puphash; if(first) { - memset(mem, 0, 256); + /* init */ + memset(mem, -1, sizeof(mem)); first= 0; } - while(str[nr]) { - val+= str[nr]; - nr++; - } - - if(value >= 0) mem[ val & 255 ]= value; - else return mem[ val & 255 ]; - - return 0; -} - -#define PUP_LABELH 6 - -typedef struct uiPupMenuInfo { - char *instr; - int mx, my; - int startx, starty; - int maxrow; -} uiPupMenuInfo; - -uiBlock *ui_block_func_PUPMENU(bContext *C, uiPopupBlockHandle *handle, void *arg_info) -{ - uiBlock *block; - uiPupMenuInfo *info; - int columns, rows, mousemove[2]= {0, 0}, mousewarp= 0; - int width, height, xmax, ymax, maxrow; - int a, startx, starty, endx, endy, x1, y1; - int lastselected; - MenuData *md; - - info= arg_info; - maxrow= info->maxrow; - height= 0; - - /* block stuff first, need to know the font */ - block= uiBeginBlock(C, handle->region, "menu", UI_EMBOSSP); - uiBlockSetFlag(block, UI_BLOCK_LOOP|UI_BLOCK_REDRAW|UI_BLOCK_RET_1|UI_BLOCK_NUMSELECT); - block->direction= UI_DOWN; - - md= decompose_menu_string(info->instr); - - rows= md->nitems; - if(rows<1) - rows= 1; - - columns= 1; - - /* size and location, title slightly bigger for bold */ - if(md->title) { - width= 2*strlen(md->title)+UI_GetStringWidth(md->title); - width /= columns; - } - else width= 0; - - for(a=0; a<md->nitems; a++) { - xmax= UI_GetStringWidth(md->items[a].str); - if(xmax>width) width= xmax; - - if(strcmp(md->items[a].str, "%l")==0) height+= PUP_LABELH; - else height+= MENU_BUTTON_HEIGHT; - } - - width+= 10; - if (width<50) width=50; - - wm_window_get_size(CTX_wm_window(C), &xmax, &ymax); - - /* set first item */ - lastselected= 0; - if(pupmenu_set) { - lastselected= pupmenu_set-1; - pupmenu_set= 0; - } - else if(md->nitems>1) { - lastselected= pupmenu_memory(info->instr, -1); - } - - startx= info->mx-(0.8*(width)); - starty= info->my-height+MENU_BUTTON_HEIGHT/2; - if(lastselected>=0 && lastselected<md->nitems) { - for(a=0; a<md->nitems; a++) { - if(a==lastselected) break; - if( strcmp(md->items[a].str, "%l")==0) starty+= PUP_LABELH; - else starty+=MENU_BUTTON_HEIGHT; - } - - //starty= info->my-height+MENU_BUTTON_HEIGHT/2+lastselected*MENU_BUTTON_HEIGHT; - } - - if(startx<10) { - startx= 10; - } - if(starty<10) { - mousemove[1]= 10-starty; - starty= 10; - } - - endx= startx+width*columns; - endy= starty+height; - if(endx>xmax) { - endx= xmax-10; - startx= endx-width*columns; - } - if(endy>ymax-20) { - mousemove[1]= ymax-endy-20; - endy= ymax-20; - starty= endy-height; - } - - if(mousemove[0] || mousemove[1]) { - ui_warp_pointer(info->mx+mousemove[0], info->my+mousemove[1]); - mousemove[0]= info->mx; - mousemove[1]= info->my; - mousewarp= 1; + if(but) { + /* set */ + mem[hash & 255 ]= BLI_findindex(&block->buttons, but); + return NULL; } - - /* here we go! */ - if(md->title) { - uiBut *bt; - char titlestr[256]; - - if(md->titleicon) { - width+= 20; - sprintf(titlestr, " %s", md->title); - uiDefIconTextBut(block, LABEL, 0, md->titleicon, titlestr, startx, (short)(starty+height), width, MENU_BUTTON_HEIGHT, NULL, 0.0, 0.0, 0, 0, ""); - } - else { - bt= uiDefBut(block, LABEL, 0, md->title, startx, (short)(starty+height), columns*width, MENU_BUTTON_HEIGHT, NULL, 0.0, 0.0, 0, 0, ""); - bt->flag= UI_TEXT_LEFT; - } - - //uiDefBut(block, SEPR, 0, "", startx, (short)(starty+height)-MENU_SEPR_HEIGHT, width, MENU_SEPR_HEIGHT, NULL, 0.0, 0.0, 0, 0, ""); + else { + /* get */ + return BLI_findlink(&block->buttons, mem[hash & 255]); } +} - x1= startx + width*((int)a/rows); - y1= starty + height - MENU_BUTTON_HEIGHT; // - MENU_SEPR_HEIGHT; - - for(a=0; a<md->nitems; a++) { - char *name= md->items[a].str; - int icon = md->items[a].icon; +/******************** Popup Menu with callback or string **********************/ - if(strcmp(name, "%l")==0) { - uiDefBut(block, SEPR, B_NOP, "", x1, y1, width, PUP_LABELH, NULL, 0, 0.0, 0, 0, ""); - y1 -= PUP_LABELH; - } - else if (icon) { - uiDefIconButF(block, BUTM, B_NOP, icon, x1, y1, width+16, MENU_BUTTON_HEIGHT-1, &handle->retvalue, (float) md->items[a].retval, 0.0, 0, 0, ""); - y1 -= MENU_BUTTON_HEIGHT; - } - else { - uiDefButF(block, BUTM, B_NOP, name, x1, y1, width, MENU_BUTTON_HEIGHT-1, &handle->retvalue, (float) md->items[a].retval, 0.0, 0, 0, ""); - y1 -= MENU_BUTTON_HEIGHT; - } - } - - uiBoundsBlock(block, 1); - uiEndBlock(C, block); - - menudata_free(md); +struct uiPopupMenu { + uiBlock *block; + uiLayout *layout; + uiBut *but; - /* XXX 2.5 need to store last selected */ -#if 0 - /* calculate last selected */ - if(event & ui_return_ok) { - lastselected= 0; - for(a=0; a<md->nitems; a++) { - if(val==md->items[a].retval) lastselected= a; - } - - pupmenu_memory(info->instr, lastselected); - } -#endif - - /* XXX 2.5 need to warp back */ -#if 0 - if(mousemove[1] && (event & ui_return_out)==0) - ui_warp_pointer(mousemove[0], mousemove[1]); - return val; -#endif + int mx, my, popup, slideout; + int startx, starty, maxrow; - return block; -} + uiMenuCreateFunc menu_func; + void *menu_arg; +}; -uiBlock *ui_block_func_PUPMENUCOL(bContext *C, uiPopupBlockHandle *handle, void *arg_info) +static uiBlock *ui_block_func_POPUP(bContext *C, uiPopupBlockHandle *handle, void *arg_pup) { uiBlock *block; - uiPupMenuInfo *info; - int columns, rows, mousemove[2]= {0, 0}, mousewarp; - int width, height, xmax, ymax, maxrow; - int a, startx, starty, endx, endy, x1, y1; - float fvalue; - MenuData *md; - - info= arg_info; - maxrow= info->maxrow; - height= 0; - - /* block stuff first, need to know the font */ - block= uiBeginBlock(C, handle->region, "menu", UI_EMBOSSP); - uiBlockSetFlag(block, UI_BLOCK_LOOP|UI_BLOCK_REDRAW|UI_BLOCK_RET_1|UI_BLOCK_NUMSELECT); - block->direction= UI_DOWN; - - md= decompose_menu_string(info->instr); - - /* columns and row calculation */ - columns= (md->nitems+maxrow)/maxrow; - if (columns<1) columns= 1; - - if(columns > 8) { - maxrow += 5; - columns= (md->nitems+maxrow)/maxrow; - } - - rows= (int) md->nitems/columns; - if (rows<1) rows= 1; - - while (rows*columns<(md->nitems+columns) ) rows++; - - /* size and location, title slightly bigger for bold */ - if(md->title) { - width= 2*strlen(md->title)+UI_GetStringWidth(md->title); - width /= columns; - } - else width= 0; - - for(a=0; a<md->nitems; a++) { - xmax= UI_GetStringWidth(md->items[a].str); - if(xmax>width) width= xmax; - } - - width+= 10; - if (width<50) width=50; - - height= rows*MENU_BUTTON_HEIGHT; - if (md->title) height+= MENU_BUTTON_HEIGHT; - - wm_window_get_size(CTX_wm_window(C), &xmax, &ymax); - - /* find active item */ - fvalue= handle->retvalue; - for(a=0; a<md->nitems; a++) { - if( md->items[a].retval== (int)fvalue ) break; - } - - /* no active item? */ - if(a==md->nitems) { - if(md->title) a= -1; - else a= 0; - } - - if(a>0) - startx = info->mx-width/2 - ((int)(a)/rows)*width; - else - startx= info->mx-width/2; - starty = info->my-height + MENU_BUTTON_HEIGHT/2 + ((a)%rows)*MENU_BUTTON_HEIGHT; - - if (md->title) starty+= MENU_BUTTON_HEIGHT; - - if(startx<10) { - mousemove[0]= 10-startx; - startx= 10; - } - if(starty<10) { - mousemove[1]= 10-starty; - starty= 10; - } - - endx= startx+width*columns; - endy= starty+height; - - if(endx>xmax) { - mousemove[0]= xmax-endx-10; - endx= xmax-10; - startx= endx-width*columns; - } - if(endy>ymax) { - mousemove[1]= ymax-endy-10; - endy= ymax-10; - starty= endy-height; - } + uiBut *bt; + ScrArea *sa; + ARegion *ar; + uiPopupMenu *pup= arg_pup; + int offset, direction, minwidth, flip; - if(mousemove[0] || mousemove[1]) { - ui_warp_pointer(info->mx+mousemove[0], info->my+mousemove[1]); - mousemove[0]= info->mx; - mousemove[1]= info->my; - mousewarp= 1; + if(pup->menu_func) { + pup->block->handle= handle; + pup->menu_func(C, pup->layout, pup->menu_arg); + pup->block->handle= NULL; } - /* here we go! */ - if(md->title) { - uiBut *bt; + if(pup->but) { + /* minimum width to enforece */ + minwidth= pup->but->x2 - pup->but->x1; - if(md->titleicon) { + if(pup->but->type == PULLDOWN || pup->but->menu_create_func) { + direction= UI_DOWN; + flip= 1; } else { - bt= uiDefBut(block, LABEL, 0, md->title, startx, (short)(starty+rows*MENU_BUTTON_HEIGHT), columns*width, MENU_BUTTON_HEIGHT, NULL, 0.0, 0.0, 0, 0, ""); - bt->flag= UI_TEXT_LEFT; + direction= UI_TOP; + flip= 0; } } - - for(a=0; a<md->nitems; a++) { - char *name= md->items[a].str; - int icon = md->items[a].icon; - - x1= startx + width*((int)a/rows); - y1= starty - MENU_BUTTON_HEIGHT*(a%rows) + (rows-1)*MENU_BUTTON_HEIGHT; - - if(strcmp(name, "%l")==0) { - uiDefBut(block, SEPR, B_NOP, "", x1, y1, width, PUP_LABELH, NULL, 0, 0.0, 0, 0, ""); - y1 -= PUP_LABELH; - } - else if (icon) { - uiDefIconButF(block, BUTM, B_NOP, icon, x1, y1, width+16, MENU_BUTTON_HEIGHT-1, &handle->retvalue, (float) md->items[a].retval, 0.0, 0, 0, ""); - y1 -= MENU_BUTTON_HEIGHT; - } - else { - uiDefButF(block, BUTM, B_NOP, name, x1, y1, width, MENU_BUTTON_HEIGHT-1, &handle->retvalue, (float) md->items[a].retval, 0.0, 0, 0, ""); - y1 -= MENU_BUTTON_HEIGHT; - } + else { + minwidth= 50; + direction= UI_DOWN; + flip= 1; } - - uiBoundsBlock(block, 1); - uiEndBlock(C, block); - - menudata_free(md); - - /* XXX 2.5 need to warp back */ -#if 0 - if((event & UI_RETURN_OUT)==0) - ui_warp_pointer(mousemove[0], mousemove[1]); -#endif - - return block; -} -/************************** Menu Definitions ***************************/ - -/* prototype */ -static uiBlock *ui_block_func_MENU_ITEM(bContext *C, uiPopupBlockHandle *handle, void *arg_info); - -struct uiPopupMenu { - uiBlock *block; - uiLayout *layout; -}; - -typedef struct uiMenuInfo { - uiPopupMenu *pup; - int mx, my, popup, slideout; - int startx, starty; -} uiMenuInfo; - -/************************ Menu Definitions to uiBlocks ***********************/ - -static uiBlock *ui_block_func_MENU_ITEM(bContext *C, uiPopupBlockHandle *handle, void *arg_info) -{ - uiBlock *block; - uiMenuInfo *info= arg_info; - uiPopupMenu *pup; - ScrArea *sa; - ARegion *ar; - - pup= info->pup; block= pup->block; - /* block stuff first, need to know the font */ - uiBlockSetRegion(block, handle->region); - block->direction= UI_DOWN; + /* in some cases we create the block before the region, + so we set it delayed here if necessary */ + if(BLI_findindex(&handle->region->uiblocks, block) == -1) + uiBlockSetRegion(block, handle->region); + + block->direction= direction; uiBlockLayoutResolve(C, block, NULL, NULL); - if(info->popup) { + if(pup->popup) { uiBlockSetFlag(block, UI_BLOCK_LOOP|UI_BLOCK_REDRAW|UI_BLOCK_NUMSELECT|UI_BLOCK_RET_1); - uiBlockSetDirection(block, UI_DOWN); + uiBlockSetDirection(block, direction); + + /* offset the mouse position, possibly based on earlier selection */ + offset= 1.5*MENU_BUTTON_HEIGHT; - /* here we set an offset for the mouse position */ - uiMenuPopupBoundsBlock(block, 1, 0, 1.5*MENU_BUTTON_HEIGHT); + if(block->flag & UI_BLOCK_POPUP_MEMORY) { + bt= ui_popup_menu_memory(block, NULL); + + if(bt) + offset= -bt->y1 - 0.5f*MENU_BUTTON_HEIGHT; + } + + block->minbounds= minwidth; + uiMenuPopupBoundsBlock(block, 1, 20, offset); } else { /* for a header menu we set the direction automatic */ - if(!info->slideout) { + if(!pup->slideout && flip) { sa= CTX_wm_area(C); ar= CTX_wm_region(C); @@ -2569,59 +2225,77 @@ static uiBlock *ui_block_func_MENU_ITEM(bContext *C, uiPopupBlockHandle *handle, } } - uiTextBoundsBlock(block, 50); + block->minbounds= minwidth; + uiTextBoundsBlock(block, 40); } /* if menu slides out of other menu, override direction */ - if(info->slideout) + if(pup->slideout) uiBlockSetDirection(block, UI_RIGHT); uiEndBlock(C, block); - - return block; + + return pup->block; } -uiPopupBlockHandle *ui_popup_menu_create(bContext *C, ARegion *butregion, uiBut *but, uiMenuCreateFunc menu_func, void *arg) +uiPopupBlockHandle *ui_popup_menu_create(bContext *C, ARegion *butregion, uiBut *but, uiMenuCreateFunc menu_func, void *arg, char *str) { + wmWindow *window= CTX_wm_window(C); uiStyle *style= U.uistyles.first; uiPopupBlockHandle *handle; uiPopupMenu *pup; - uiMenuInfo info; pup= MEM_callocN(sizeof(uiPopupMenu), "menu dummy"); - pup->block= uiBeginBlock(C, NULL, "ui_popup_menu_create", UI_EMBOSSP); + pup->block= uiBeginBlock(C, NULL, "ui_button_menu_create", UI_EMBOSSP); pup->layout= uiBlockLayout(pup->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_MENU, 0, 0, 200, 0, style); + pup->slideout= (but && (but->block->flag & UI_BLOCK_LOOP)); + pup->but= but; uiLayoutSetOperatorContext(pup->layout, WM_OP_INVOKE_REGION_WIN); - /* create in advance so we can let buttons point to retval already */ - pup->block->handle= MEM_callocN(sizeof(uiPopupBlockHandle), "uiPopupBlockHandle"); + if(!but) { + /* no button to start from, means we are a popup */ + pup->mx= window->eventstate->x; + pup->my= window->eventstate->y; + pup->popup= 1; + } - menu_func(C, pup->layout, arg); - - memset(&info, 0, sizeof(info)); - info.pup= pup; - info.slideout= (but && (but->block->flag & UI_BLOCK_LOOP)); + if(str) { + /* menu is created from a string */ + pup->menu_func= ui_block_func_MENUSTR; + pup->menu_arg= str; + } + else { + /* menu is created from a callback */ + pup->menu_func= menu_func; + pup->menu_arg= arg; + } - handle= ui_popup_block_create(C, butregion, but, NULL, ui_block_func_MENU_ITEM, &info); + handle= ui_popup_block_create(C, butregion, but, NULL, ui_block_func_POPUP, pup); + + if(!but) { + handle->popup= 1; + + UI_add_popup_handlers(C, &window->handlers, handle); + WM_event_add_mousemove(C); + } MEM_freeN(pup); return handle; } -/*************************** Menu Creating API **************************/ - - -/*************************** Popup Menu API **************************/ +/******************** Popup Menu API with begin and end ***********************/ /* only return handler, and set optional title */ uiPopupMenu *uiPupMenuBegin(bContext *C, const char *title, int icon) { uiStyle *style= U.uistyles.first; - uiPopupMenu *pup= MEM_callocN(sizeof(uiPopupMenu), "menu start"); + uiPopupMenu *pup= MEM_callocN(sizeof(uiPopupMenu), "popup menu"); uiBut *but; pup->block= uiBeginBlock(C, NULL, "uiPupMenuBegin", UI_EMBOSSP); + pup->block->flag |= UI_BLOCK_POPUP_MEMORY; + pup->block->puphash= ui_popup_menu_hash((char*)title); pup->layout= uiBlockLayout(pup->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_MENU, 0, 0, 200, 0, style); uiLayoutSetOperatorContext(pup->layout, WM_OP_EXEC_REGION_WIN); @@ -2640,8 +2314,6 @@ uiPopupMenu *uiPupMenuBegin(bContext *C, const char *title, int icon) but= uiDefBut(pup->block, LABEL, 0, (char*)title, 0, 0, 200, MENU_BUTTON_HEIGHT, NULL, 0.0, 0.0, 0, 0, ""); but->flag= UI_TEXT_LEFT; } - - //uiDefBut(block, SEPR, 0, "", startx, (short)(starty+height)-MENU_SEPR_HEIGHT, width, MENU_SEPR_HEIGHT, NULL, 0.0, 0.0, 0, 0, ""); } return pup; @@ -2651,16 +2323,13 @@ uiPopupMenu *uiPupMenuBegin(bContext *C, const char *title, int icon) void uiPupMenuEnd(bContext *C, uiPopupMenu *pup) { wmWindow *window= CTX_wm_window(C); - uiMenuInfo info; uiPopupBlockHandle *menu; - memset(&info, 0, sizeof(info)); - info.popup= 1; - info.mx= window->eventstate->x; - info.my= window->eventstate->y; - info.pup= pup; + pup->popup= 1; + pup->mx= window->eventstate->x; + pup->my= window->eventstate->y; - menu= ui_popup_block_create(C, NULL, NULL, NULL, ui_block_func_MENU_ITEM, &info); + menu= ui_popup_block_create(C, NULL, NULL, NULL, ui_block_func_POPUP, pup); menu->popup= 1; UI_add_popup_handlers(C, &window->handlers, menu); @@ -2674,32 +2343,7 @@ uiLayout *uiPupMenuLayout(uiPopupMenu *pup) return pup->layout; } -/* ************** standard pupmenus *************** */ - -/* this one can called with operatortype name and operators */ -static uiPopupBlockHandle *ui_pup_menu(bContext *C, int maxrow, uiMenuHandleFunc func, void *arg, char *str, ...) -{ - wmWindow *window= CTX_wm_window(C); - uiPupMenuInfo info; - uiPopupBlockHandle *menu; - - memset(&info, 0, sizeof(info)); - info.mx= window->eventstate->x; - info.my= window->eventstate->y; - info.maxrow= maxrow; - info.instr= str; - - menu= ui_popup_block_create(C, NULL, NULL, NULL, ui_block_func_PUPMENU, &info); - menu->popup= 1; - - UI_add_popup_handlers(C, &window->handlers, menu); - WM_event_add_mousemove(C); - - menu->popup_func= func; - menu->popup_arg= arg; - - return menu; -} +/*************************** Standard Popup Menus ****************************/ static void operator_name_cb(bContext *C, void *arg, int retval) { @@ -2709,17 +2353,6 @@ static void operator_name_cb(bContext *C, void *arg, int retval) WM_operator_name_call(C, opname, WM_OP_EXEC_DEFAULT, NULL); } -static void vconfirm_opname(bContext *C, char *opname, char *title, char *itemfmt, va_list ap) -{ - char *s, buf[512]; - - s= buf; - if (title) s+= sprintf(s, "%s%%t|", title); - vsprintf(s, itemfmt, ap); - - ui_pup_menu(C, 0, operator_name_cb, opname, buf); -} - static void operator_cb(bContext *C, void *arg, int retval) { wmOperator *op= arg; @@ -2735,6 +2368,21 @@ static void confirm_cancel_operator(void *opv) WM_operator_free(opv); } +static void vconfirm_opname(bContext *C, char *opname, char *title, char *itemfmt, va_list ap) +{ + uiPopupBlockHandle *handle; + char *s, buf[512]; + + s= buf; + if (title) s+= sprintf(s, "%s%%t|", title); + vsprintf(s, itemfmt, ap); + + handle= ui_popup_menu_create(C, NULL, NULL, NULL, NULL, buf); + + handle->popup_func= operator_name_cb; + handle->popup_arg= opname; +} + static void confirm_operator(bContext *C, wmOperator *op, char *title, char *item) { uiPopupBlockHandle *handle; @@ -2743,11 +2391,13 @@ static void confirm_operator(bContext *C, wmOperator *op, char *title, char *ite s= buf; if (title) s+= sprintf(s, "%s%%t|%s", title, item); - handle= ui_pup_menu(C, 0, operator_cb, op, buf); + handle= ui_popup_menu_create(C, NULL, NULL, NULL, NULL, buf); + + handle->popup_func= operator_cb; + handle->popup_arg= op; handle->cancel_func= confirm_cancel_operator; } - void uiPupMenuOkee(bContext *C, char *opname, char *str, ...) { va_list ap; @@ -2760,7 +2410,6 @@ void uiPupMenuOkee(bContext *C, char *opname, char *str, ...) va_end(ap); } - void uiPupMenuSaveOver(bContext *C, wmOperator *op, char *filename) { size_t len= strlen(filename); @@ -2776,7 +2425,7 @@ void uiPupMenuSaveOver(bContext *C, wmOperator *op, char *filename) if(BLI_exists(filename)==0) operator_cb(C, op, 1); else - confirm_operator(C, op, "Save over", filename); + confirm_operator(C, op, "Save Over", filename); } void uiPupMenuNotice(bContext *C, char *str, ...) @@ -2826,7 +2475,7 @@ void uiPupMenuReports(bContext *C, ReportList *reports) } str= BLI_dynstr_get_cstring(ds); - ui_pup_menu(C, 0, NULL, NULL, str); + ui_popup_menu_create(C, NULL, NULL, NULL, NULL, str); MEM_freeN(str); BLI_dynstr_free(ds); @@ -2870,3 +2519,4 @@ void uiPupBlockOperator(bContext *C, uiBlockCreateFunc func, wmOperator *op, int UI_add_popup_handlers(C, &window->handlers, handle); WM_event_add_mousemove(C); } + diff --git a/source/blender/editors/interface/interface_style.c b/source/blender/editors/interface/interface_style.c index 67ee29a1d3c..cb9216ec1c5 100644 --- a/source/blender/editors/interface/interface_style.c +++ b/source/blender/editors/interface/interface_style.c @@ -248,9 +248,6 @@ void uiStyleInit(void) BLF_size(11, U.dpi); BLF_size(12, U.dpi); BLF_size(14, U.dpi); - - if (!(U.transopts & USER_USETEXTUREFONT)) - BLF_mode(BLF_MODE_BITMAP); } } diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index edf01f4da2c..6aa5f5efc41 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -56,12 +56,13 @@ void ui_template_fix_linking() /********************** Header Template *************************/ -void uiTemplateHeader(uiLayout *layout, bContext *C) +void uiTemplateHeader(uiLayout *layout, bContext *C, int menus) { uiBlock *block; block= uiLayoutFreeBlock(layout); - ED_area_header_standardbuttons(C, block, 0); + if(menus) ED_area_header_standardbuttons(C, block, 0); + else ED_area_header_switchbutton(C, block, 0); } /********************** Search Callbacks *************************/ @@ -236,11 +237,11 @@ static void template_ID(bContext *C, uiBlock *block, TemplateID *template, Struc int w= idptr.data?UI_UNIT_X:UI_UNIT_X*6; if(newop) { - but= uiDefIconTextButO(block, BUT, newop, WM_OP_EXEC_REGION_WIN, ICON_ZOOMIN, "Add New", 0, 0, w, UI_UNIT_Y, NULL); + but= uiDefIconTextButO(block, BUT, newop, WM_OP_INVOKE_REGION_WIN, ICON_ZOOMIN, (idptr.data)? "": "Add New", 0, 0, w, UI_UNIT_Y, NULL); uiButSetNFunc(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_ADD_NEW)); } else { - but= uiDefIconTextBut(block, BUT, 0, ICON_ZOOMIN, "Add New", 0, 0, w, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL); + but= uiDefIconTextBut(block, BUT, 0, ICON_ZOOMIN, (idptr.data)? "": "Add New", 0, 0, w, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL); uiButSetNFunc(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_ADD_NEW)); } } @@ -248,7 +249,7 @@ static void template_ID(bContext *C, uiBlock *block, TemplateID *template, Struc /* delete button */ if(idptr.data && (flag & UI_ID_DELETE)) { if(unlinkop) { - but= uiDefIconButO(block, BUT, unlinkop, WM_OP_EXEC_REGION_WIN, ICON_X, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL); + but= uiDefIconButO(block, BUT, unlinkop, WM_OP_INVOKE_REGION_WIN, ICON_X, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL); } else { but= uiDefIconBut(block, BUT, 0, ICON_X, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL); @@ -427,15 +428,15 @@ static uiLayout *draw_modifier(uiLayout *layout, Object *ob, ModifierData *md, i else { /* real modifier */ uiBlockBeginAlign(block); - uiItemR(row, "", 0, &ptr, "name", 0, 0, 0); + uiItemR(row, "", 0, &ptr, "name", 0); /* Softbody not allowed in this situation, enforce! */ if(((md->type!=eModifierType_Softbody && md->type!=eModifierType_Collision) || !(ob->pd && ob->pd->deflect)) && (md->type!=eModifierType_Surface)) { - uiItemR(row, "", ICON_SCENE, &ptr, "render", 0, 0, 0); - uiItemR(row, "", ICON_RESTRICT_VIEW_OFF, &ptr, "realtime", 0, 0, 0); + uiItemR(row, "", ICON_SCENE, &ptr, "render", 0); + uiItemR(row, "", ICON_RESTRICT_VIEW_OFF, &ptr, "realtime", 0); if(mti->flags & eModifierTypeFlag_SupportsEditmode) - uiItemR(row, "", ICON_EDITMODE_HLT, &ptr, "editmode", 0, 0, 0); + uiItemR(row, "", ICON_EDITMODE_HLT, &ptr, "editmode", 0); } @@ -483,7 +484,7 @@ static uiLayout *draw_modifier(uiLayout *layout, Object *ob, ModifierData *md, i if(md->type==eModifierType_ParticleSystem) { ParticleSystem *psys= ((ParticleSystemModifierData *)md)->psys; - if(!(G.f & G_PARTICLEEDIT)) + if(!(ob->mode & OB_MODE_PARTICLE_EDIT)) if(ELEM3(psys->part->ren_as, PART_DRAW_PATH, PART_DRAW_GR, PART_DRAW_OB) && psys->pathcache) uiItemO(row, "Convert", 0, "OBJECT_OT_modifier_convert"); } @@ -628,7 +629,7 @@ static void verify_constraint_name_func (bContext *C, void *con_v, void *name_v) /* some commonly used macros in the constraints drawing code */ #define is_armature_target(target) (target && target->type==OB_ARMATURE) -#define is_armature_owner(ob) ((ob->type == OB_ARMATURE) && (ob->flag & OB_POSEMODE)) +#define is_armature_owner(ob) ((ob->type == OB_ARMATURE) && (ob->mode & OB_MODE_POSE)) #define is_geom_target(target) (target && (ELEM(target->type, OB_MESH, OB_LATTICE)) ) /* Helper function for draw constraint - draws constraint space stuff @@ -911,82 +912,7 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con) draw_constraint_spaceselect(block, con, xco, yco-(73+theight), is_armature_owner(ob), -1); } break; -#endif /* DISABLE_PYTHON */ - - /*case CONSTRAINT_TYPE_RIGIDBODYJOINT: - { - if (data->type==CONSTRAINT_RB_GENERIC6DOF) { - // Draw Pairs of LimitToggle+LimitValue - uiBlockBeginAlign(block); - uiDefButBitS(block, TOG, 1, B_CONSTRAINT_TEST, "LinMinX", xco, yco-offsetY, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use minimum x limit"); - uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", xco+togButWidth, yco-offsetY, (textButWidth-5), 18, &(data->minLimit[0]), -extremeLin, extremeLin, 0.1,0.5,"min x limit"); - uiBlockEndAlign(block); - - uiBlockBeginAlign(block); - uiDefButBitS(block, TOG, 1, B_CONSTRAINT_TEST, "LinMaxX", xco+(width-(textButWidth-5)-togButWidth), yco-offsetY, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use maximum x limit"); - uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", xco+(width-textButWidth-5), yco-offsetY, (textButWidth), 18, &(data->maxLimit[0]), -extremeLin, extremeLin, 0.1,0.5,"max x limit"); - uiBlockEndAlign(block); - - offsetY += 20; - uiBlockBeginAlign(block); - uiDefButBitS(block, TOG, 2, B_CONSTRAINT_TEST, "LinMinY", xco, yco-offsetY, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use minimum y limit"); - uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", xco+togButWidth, yco-offsetY, (textButWidth-5), 18, &(data->minLimit[1]), -extremeLin, extremeLin, 0.1,0.5,"min y limit"); - uiBlockEndAlign(block); - - uiBlockBeginAlign(block); - uiDefButBitS(block, TOG, 2, B_CONSTRAINT_TEST, "LinMaxY", xco+(width-(textButWidth-5)-togButWidth), yco-offsetY, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use maximum y limit"); - uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", xco+(width-textButWidth-5), yco-offsetY, (textButWidth), 18, &(data->maxLimit[1]), -extremeLin, extremeLin, 0.1,0.5,"max y limit"); - uiBlockEndAlign(block); - - offsetY += 20; - uiBlockBeginAlign(block); - uiDefButBitS(block, TOG, 4, B_CONSTRAINT_TEST, "LinMinZ", xco, yco-offsetY, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use minimum z limit"); - uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", xco+togButWidth, yco-offsetY, (textButWidth-5), 18, &(data->minLimit[2]), -extremeLin, extremeLin, 0.1,0.5,"min z limit"); - uiBlockEndAlign(block); - - uiBlockBeginAlign(block); - uiDefButBitS(block, TOG, 4, B_CONSTRAINT_TEST, "LinMaxZ", xco+(width-(textButWidth-5)-togButWidth), yco-offsetY, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use maximum z limit"); - uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", xco+(width-textButWidth-5), yco-offsetY, (textButWidth), 18, &(data->maxLimit[2]), -extremeLin, extremeLin, 0.1,0.5,"max z limit"); - uiBlockEndAlign(block); - offsetY += 20; - } - if ((data->type==CONSTRAINT_RB_GENERIC6DOF) || (data->type==CONSTRAINT_RB_CONETWIST)) { - // Draw Pairs of LimitToggle+LimitValue / - uiBlockBeginAlign(block); - uiDefButBitS(block, TOG, 8, B_CONSTRAINT_TEST, "AngMinX", xco, yco-offsetY, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use minimum x limit"); - uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", xco+togButWidth, yco-offsetY, (textButWidth-5), 18, &(data->minLimit[3]), -extremeAngX, extremeAngX, 0.1,0.5,"min x limit"); - uiBlockEndAlign(block); - uiBlockBeginAlign(block); - uiDefButBitS(block, TOG, 8, B_CONSTRAINT_TEST, "AngMaxX", xco+(width-(textButWidth-5)-togButWidth), yco-offsetY, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use maximum x limit"); - uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", xco+(width-textButWidth-5), yco-offsetY, (textButWidth), 18, &(data->maxLimit[3]), -extremeAngX, extremeAngX, 0.1,0.5,"max x limit"); - uiBlockEndAlign(block); - - offsetY += 20; - uiBlockBeginAlign(block); - uiDefButBitS(block, TOG, 16, B_CONSTRAINT_TEST, "AngMinY", xco, yco-offsetY, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use minimum y limit"); - uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", xco+togButWidth, yco-offsetY, (textButWidth-5), 18, &(data->minLimit[4]), -extremeAngY, extremeAngY, 0.1,0.5,"min y limit"); - uiBlockEndAlign(block); - - uiBlockBeginAlign(block); - uiDefButBitS(block, TOG, 16, B_CONSTRAINT_TEST, "AngMaxY", xco+(width-(textButWidth-5)-togButWidth), yco-offsetY, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use maximum y limit"); - uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", xco+(width-textButWidth-5), yco-offsetY, (textButWidth), 18, &(data->maxLimit[4]), -extremeAngY, extremeAngY, 0.1,0.5,"max y limit"); - uiBlockEndAlign(block); - - offsetY += 20; - uiBlockBeginAlign(block); - uiDefButBitS(block, TOG, 32, B_CONSTRAINT_TEST, "AngMinZ", xco, yco-offsetY, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use minimum z limit"); - uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", xco+togButWidth, yco-offsetY, (textButWidth-5), 18, &(data->minLimit[5]), -extremeAngZ, extremeAngZ, 0.1,0.5,"min z limit"); - uiBlockEndAlign(block); - - uiBlockBeginAlign(block); - uiDefButBitS(block, TOG, 32, B_CONSTRAINT_TEST, "AngMaxZ", xco+(width-(textButWidth-5)-togButWidth), yco-offsetY, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use maximum z limit"); - uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", xco+(width-textButWidth-5), yco-offsetY, (textButWidth), 18, &(data->maxLimit[5]), -extremeAngZ, extremeAngZ, 0.1,0.5,"max z limit"); - uiBlockEndAlign(block); - } - - } - break; - */ +#endif case CONSTRAINT_TYPE_NULL: { @@ -1162,7 +1088,7 @@ static void do_preview_buttons(bContext *C, void *arg, int event) } } -void uiTemplatePreview(uiLayout *layout, ID *id, ID *parent) +void uiTemplatePreview(uiLayout *layout, ID *id, ID *parent, MTex *slot) { uiLayout *row, *col; uiBlock *block; @@ -1203,7 +1129,7 @@ void uiTemplatePreview(uiLayout *layout, ID *id, ID *parent) /* add preview */ uiDefBut(block, BUT_EXTRA, 0, "", 0, 0, UI_UNIT_X*6, UI_UNIT_Y*6, pid, 0.0, 0.0, 0, 0, ""); - uiBlockSetDrawExtraFunc(block, ED_preview_draw, pparent); + uiBlockSetDrawExtraFunc(block, ED_preview_draw, pparent, slot); uiBlockSetHandleFunc(block, do_preview_buttons, NULL); /* add buttons */ @@ -1257,17 +1183,21 @@ void uiTemplateColorRamp(uiLayout *layout, ColorBand *coba, int expand) #include "DNA_color_types.h" -void uiTemplateCurveMapping(uiLayout *layout, CurveMapping *cumap, int type) +void uiTemplateCurveMapping(uiLayout *layout, CurveMapping *cumap, int type, int compact) { - uiBlock *block; rctf rect; if(cumap) { - rect.xmin= 0; rect.xmax= 200; - rect.ymin= 0; rect.ymax= 190; + if(compact) { + rect.xmin= 0; rect.xmax= 150; + rect.ymin= 0; rect.ymax= 140; + } + else { + rect.xmin= 0; rect.xmax= 200; + rect.ymin= 0; rect.ymax= 190; + } - block= uiLayoutFreeBlock(layout); - curvemap_buttons(block, cumap, type, 0, 0, &rect); + curvemap_layout(layout, cumap, type, 0, 0, &rect); } } @@ -1294,9 +1224,9 @@ void uiTemplateTriColorSet(uiLayout *layout, PointerRNA *ptr, char *propname) /* nselected, selected, active color swatches */ csPtr= RNA_property_pointer_get(ptr, prop); - uiItemR(row, "", 0, &csPtr, "normal", 0, 0, 0); - uiItemR(row, "", 0, &csPtr, "selected", 0, 0, 0); - uiItemR(row, "", 0, &csPtr, "active", 0, 0, 0); + uiItemR(row, "", 0, &csPtr, "normal", 0); + uiItemR(row, "", 0, &csPtr, "selected", 0); + uiItemR(row, "", 0, &csPtr, "active", 0); } /********************* Layer Buttons Template ************************/ @@ -1328,7 +1258,7 @@ void uiTemplateLayers(uiLayout *layout, PointerRNA *ptr, char *propname) * the 'remainder' is added to this, as it will be ok to have first row slightly wider if need be * - for now, only split into groups if if group will have at least 5 items */ - layers= RNA_property_array_length(prop); + layers= RNA_property_array_length(ptr, prop); cols= (layers / 2) + (layers % 2); groups= ((cols / 2) < 5) ? (1) : (cols / 2); @@ -1348,7 +1278,7 @@ void uiTemplateLayers(uiLayout *layout, PointerRNA *ptr, char *propname) /* add layers as toggle buts */ for (col= 0; (col < cols) && (layer < layers); col++, layer++) { int icon=0; // XXX - add some way of setting this... - uiItemFullR(uRow, "", icon, ptr, prop, layer, 0, 0, 0, 1); + uiItemFullR(uRow, "", icon, ptr, prop, layer, 0, UI_ITEM_R_TOGGLE); } } } @@ -1388,7 +1318,7 @@ ListBase uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, char *pr Panel *pa; ListBase lb, *itemlb; char *name, str[32]; - int icon=0, i= 0, activei= 0, len, items, found, min, max; + int icon=0, i= 0, activei= 0, len= 0, items, found, min, max; lb.first= lb.last= NULL; @@ -1524,7 +1454,8 @@ ListBase uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, char *pr /* init numbers */ RNA_property_int_range(activeptr, activeprop, &min, &max); - len= max - min + 1; + if(prop) + len= RNA_property_collection_length(ptr, prop); items= CLAMPIS(len, rows, 5); pa->list_scroll= MIN2(pa->list_scroll, len-items); @@ -1650,7 +1581,7 @@ static void do_running_jobs(bContext *C, void *arg, int event) WM_jobs_stop(CTX_wm_manager(C), CTX_wm_screen(C)); break; case B_STOPANIM: - ED_screen_animation_timer(C, 0, 0); + WM_operator_name_call(C, "SCREEN_OT_animation_play", WM_OP_INVOKE_SCREEN, NULL); break; } } diff --git a/source/blender/editors/interface/interface_utils.c b/source/blender/editors/interface/interface_utils.c index 8ff9e857407..5b44f6544d1 100644 --- a/source/blender/editors/interface/interface_utils.c +++ b/source/blender/editors/interface/interface_utils.c @@ -72,7 +72,7 @@ uiBut *uiDefAutoButR(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int ind { uiBut *but=NULL; const char *propname= RNA_property_identifier(prop); - int arraylen= RNA_property_array_length(prop); + int arraylen= RNA_property_array_length(ptr, prop); switch(RNA_property_type(prop)) { case PROP_BOOLEAN: { @@ -81,7 +81,7 @@ uiBut *uiDefAutoButR(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int ind if(arraylen && index == -1) return NULL; - length= RNA_property_array_length(prop); + length= RNA_property_array_length(ptr, prop); if(length) value= RNA_property_boolean_get_index(ptr, prop, index); @@ -152,8 +152,6 @@ void uiDefAutoButsRNA(const bContext *C, uiLayout *layout, PointerRNA *ptr, int uiLayout *split, *col; char *name; - uiItemL(layout, (char*)RNA_struct_ui_name(ptr->type), 0); - RNA_STRUCT_BEGIN(ptr, prop) { if(strcmp(RNA_property_identifier(prop), "rna_type") == 0) continue; @@ -177,7 +175,7 @@ void uiDefAutoButsRNA(const bContext *C, uiLayout *layout, PointerRNA *ptr, int if(strcmp(name, "Axis")==0) { uiDefButR(uiLayoutGetBlock(col), BUT_NORMAL, 0, name, 0, 0, 100, 100, ptr, "axis", -1, 0, 0, -1, -1, NULL); } - else uiItemFullR(col, "", 0, ptr, prop, -1, 0, 0, 0, 0); + else uiItemFullR(col, "", 0, ptr, prop, -1, 0, 0); } RNA_STRUCT_END; } @@ -446,6 +444,20 @@ int uiDefIDPoinButs(uiBlock *block, Main *bmain, ID *parid, ID *id, int id_code, uiBlockClearButLock(block); } + /* add button */ + if(events & UI_ID_ADD_NEW) { + uiBlockSetButLock(block, (events & UI_ID_PIN) && *pin_p, "Can't unlink pinned data"); + if(parid && parid->lib); + else { + dup_params= MEM_dupallocN(params); + but= uiDefIconBut(block, BUT, 0, ICON_ZOOMIN, x,y,DEF_ICON_BUT_WIDTH,DEF_BUT_HEIGHT, &dup_params->browsenr, params->browsenr, 32767.0, 0, 0, "Add new data block"); + uiButSetNFunc(but, idpoin_cb, MEM_dupallocN(params), SET_INT_IN_POINTER(UI_ID_ADD_NEW)); + x+= DEF_ICON_BUT_WIDTH; + } + + uiBlockClearButLock(block); + } + /* delete button */ if(events & UI_ID_DELETE) { uiBlockSetButLock(block, (events & UI_ID_PIN) && *pin_p, "Can't unlink pinned data"); @@ -945,6 +957,72 @@ void curvemap_buttons(uiBlock *block, CurveMapping *cumap, char labeltype, short cumap, 0.0f, 1.0f, 0, 0, ""); } +/* still unsure how this call evolves... we use labeltype for defining what curve-channels to show */ +void curvemap_layout(uiLayout *layout, CurveMapping *cumap, char labeltype, short event, short redraw, rctf *rect) +{ + uiLayout *row; + uiBlock *block; + uiBut *bt; + float dx, fy= rect->ymax-18.0f; + int icon; + + block= uiLayoutGetBlock(layout); + + /* curve choice options + tools/settings, 8 icons + spacer */ + dx= UI_UNIT_X; + + row= uiLayoutRow(layout, 0); + uiLayoutSetAlignment(row, UI_LAYOUT_ALIGN_RIGHT); + + if(labeltype=='v') { /* vector */ + row= uiLayoutRow(layout, 1); + + if(cumap->cm[0].curve) + uiDefButI(block, ROW, redraw, "X", 0, 0, dx, 16, &cumap->cur, 0.0, 0.0, 0.0, 0.0, ""); + if(cumap->cm[1].curve) + uiDefButI(block, ROW, redraw, "Y", 0, 0, dx, 16, &cumap->cur, 0.0, 1.0, 0.0, 0.0, ""); + if(cumap->cm[2].curve) + uiDefButI(block, ROW, redraw, "Z", 0, 0, dx, 16, &cumap->cur, 0.0, 2.0, 0.0, 0.0, ""); + } + else if(labeltype=='c') { /* color */ + row= uiLayoutRow(layout, 1); + + if(cumap->cm[3].curve) + uiDefButI(block, ROW, redraw, "C", 0, 0, dx, 16, &cumap->cur, 0.0, 3.0, 0.0, 0.0, ""); + if(cumap->cm[0].curve) + uiDefButI(block, ROW, redraw, "R", 0, 0, dx, 16, &cumap->cur, 0.0, 0.0, 0.0, 0.0, ""); + if(cumap->cm[1].curve) + uiDefButI(block, ROW, redraw, "G", 0, 0, dx, 16, &cumap->cur, 0.0, 1.0, 0.0, 0.0, ""); + if(cumap->cm[2].curve) + uiDefButI(block, ROW, redraw, "B", 0, 0, dx, 16, &cumap->cur, 0.0, 2.0, 0.0, 0.0, ""); + } + + row= uiLayoutRow(row, 1); + + uiBlockSetEmboss(block, UI_EMBOSSN); + bt= uiDefIconBut(block, BUT, redraw, ICON_ZOOMIN, 0, 0, dx, 14, NULL, 0.0, 0.0, 0.0, 0.0, "Zoom in"); + uiButSetFunc(bt, curvemap_buttons_zoom_in, cumap, NULL); + + bt= uiDefIconBut(block, BUT, redraw, ICON_ZOOMOUT, 0, 0, dx, 14, NULL, 0.0, 0.0, 0.0, 0.0, "Zoom out"); + uiButSetFunc(bt, curvemap_buttons_zoom_out, cumap, NULL); + + bt= uiDefIconBlockBut(block, curvemap_tools_func, cumap, event, ICON_MODIFIER, 0, 0, dx, 18, "Tools"); + + if(cumap->flag & CUMA_DO_CLIP) icon= ICON_CLIPUV_HLT; else icon= ICON_CLIPUV_DEHLT; + bt= uiDefIconBlockBut(block, curvemap_clipping_func, cumap, event, icon, 0, 0, dx, 18, "Clipping Options"); + + bt= uiDefIconBut(block, BUT, event, ICON_X, 0, 0, dx, 18, NULL, 0.0, 0.0, 0.0, 0.0, "Delete points"); + uiButSetFunc(bt, curvemap_buttons_delete, cumap, NULL); + + uiBlockSetEmboss(block, UI_EMBOSS); + + row= uiLayoutRow(layout, 0); + uiDefBut(block, BUT_CURVE, event, "", + rect->xmin, rect->ymin, rect->xmax-rect->xmin, fy-rect->ymin, + cumap, 0.0f, 1.0f, 0, 0, ""); +} + + #define B_BANDCOL 1 static int vergcband(const void *a1, const void *a2) diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index eed4425b7ad..f0085f71373 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -835,9 +835,11 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b // else transopts= ui_translate_buttons(); /* cut string in 2 parts - only for menu entries */ - if(ELEM5(but->type, SLI, NUM, TEX, NUMSLI, NUMABS)==0) { - cpoin= strchr(but->drawstr, '|'); - if(cpoin) *cpoin= 0; + if((but->block->flag & UI_BLOCK_LOOP)) { + if(ELEM5(but->type, SLI, NUM, TEX, NUMSLI, NUMABS)==0) { + cpoin= strchr(but->drawstr, '|'); + if(cpoin) *cpoin= 0; + } } glColor3ubv((unsigned char*)wcol->text); @@ -889,7 +891,7 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiB rect->xmin += UI_icon_get_width(but->icon+but->iconadd); if(but->editstr || (but->flag & UI_TEXT_LEFT)) - rect->xmin += 10; + rect->xmin += 5; } else if((but->flag & UI_TEXT_LEFT)) rect->xmin += 5; @@ -1083,7 +1085,7 @@ static struct uiWidgetColors wcol_tool= { {255, 255, 255, 255}, 1, - 25, -25 + 15, -15 }; static struct uiWidgetColors wcol_box= { @@ -1895,7 +1897,7 @@ static void widget_swatch(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat widget_init(&wtb); /* half rounded */ - round_box_edges(&wtb, roundboxalign, rect, 4.0f); + round_box_edges(&wtb, roundboxalign, rect, 5.0f); ui_get_but_vectorf(but, col); wcol->inner[0]= FTOCHAR(col[0]); @@ -1914,7 +1916,7 @@ static void widget_textbut(uiWidgetColors *wcol, rcti *rect, int state, int roun widget_init(&wtb); /* half rounded */ - round_box_edges(&wtb, roundboxalign, rect, 5.0f); + round_box_edges(&wtb, roundboxalign, rect, 4.0f); widgetbase_draw(&wtb, wcol); @@ -1944,12 +1946,12 @@ static void widget_pulldownbut(uiWidgetColors *wcol, rcti *rect, int state, int { if(state & UI_ACTIVE) { uiWidgetBase wtb; - float rad= 0.5f*(rect->ymax - rect->ymin); + float rad= 0.5f*(rect->ymax - rect->ymin); // 4.0f widget_init(&wtb); - /* fully rounded */ - round_box_edges(&wtb, roundboxalign, rect, rad); + /* half rounded */ + round_box_edges(&wtb, 15, rect, rad); widgetbase_draw(&wtb, wcol); } @@ -2043,11 +2045,11 @@ static void widget_but(uiWidgetColors *wcol, rcti *rect, int state, int roundbox static void widget_roundbut(uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign) { uiWidgetBase wtb; - float rad= 0.5f*(rect->ymax - rect->ymin); + float rad= 5.0f; //0.5f*(rect->ymax - rect->ymin); widget_init(&wtb); - /* fully rounded */ + /* half rounded */ round_box_edges(&wtb, roundboxalign, rect, rad); widgetbase_draw(&wtb, wcol); @@ -2065,7 +2067,7 @@ static void widget_draw_extra_mask(const bContext *C, uiBut *but, uiWidgetType * if(but->block->drawextra) { /* note: drawextra can change rect +1 or -1, to match round errors of existing previews */ - but->block->drawextra(C, but->poin, but->block->drawextra_arg, rect); + but->block->drawextra(C, but->poin, but->block->drawextra_arg1, but->block->drawextra_arg2, rect); /* make mask to draw over image */ UI_GetThemeColor3ubv(TH_BACK, col); diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index 297e22610a6..8aaede7515a 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -150,6 +150,9 @@ char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colorid) case SPACE_INFO: ts= &btheme->tinfo; break; + case SPACE_USERPREF: + ts= &btheme->tuserpref; + break; case SPACE_TIME: ts= &btheme->ttime; break; @@ -402,6 +405,7 @@ static void ui_theme_init_new(bTheme *btheme) ui_theme_init_new_do(&btheme->ttime); ui_theme_init_new_do(&btheme->tnode); ui_theme_init_new_do(&btheme->tlogic); + ui_theme_init_new_do(&btheme->tuserpref); } @@ -441,6 +445,7 @@ void ui_theme_init_userdef(void) SETCOL(btheme->tv3d.text_hi, 255, 255, 255, 255); SETCOLF(btheme->tv3d.header, 0.45, 0.45, 0.45, 1.0); + SETCOLF(btheme->tv3d.button, 0.45, 0.45, 0.45, 1.0); SETCOL(btheme->tv3d.panel, 165, 165, 165, 127); SETCOL(btheme->tv3d.shade1, 160, 160, 160, 100); @@ -583,6 +588,10 @@ void ui_theme_init_userdef(void) btheme->tinfo= btheme->tv3d; SETCOLF(btheme->tinfo.back, 0.45, 0.45, 0.45, 1.0); + /* space user preferences */ + btheme->tuserpref= btheme->tv3d; + SETCOLF(btheme->tuserpref.back, 0.45, 0.45, 0.45, 1.0); + /* space sound */ btheme->tsnd= btheme->tv3d; SETCOLF(btheme->tsnd.back, 0.45, 0.45, 0.45, 1.0); @@ -1233,6 +1242,7 @@ void init_userdef_do_versions(void) } SETCOLF(btheme->tinfo.back, 0.45, 0.45, 0.45, 1.0); + SETCOLF(btheme->tuserpref.back, 0.45, 0.45, 0.45, 1.0); } } diff --git a/source/blender/editors/mesh/bmesh_select.c b/source/blender/editors/mesh/bmesh_select.c index cd14b5c1e33..8eeb209ad63 100644 --- a/source/blender/editors/mesh/bmesh_select.c +++ b/source/blender/editors/mesh/bmesh_select.c @@ -245,7 +245,7 @@ int EDBM_mask_init_backbuf_border(ViewContext *vc, short mcords[][2], short tot, /* method in use for face selecting too */ if(vc->obedit==NULL) { - if(FACESEL_PAINT_TEST); + if(paint_facesel_test(vc->obact)); else return 0; } else if(vc->v3d->drawtype<OB_SOLID || (vc->v3d->flag & V3D_ZBUF_SELECT)==0) return 0; @@ -300,7 +300,7 @@ int EDBM_init_backbuf_circle(ViewContext *vc, short xs, short ys, short rads) /* method in use for face selecting too */ if(vc->obedit==NULL) { - if(FACESEL_PAINT_TEST); + if(paint_facesel_test(vc->obact)); else return 0; } else if(vc->v3d->drawtype<OB_SOLID || (vc->v3d->flag & V3D_ZBUF_SELECT)==0) return 0; @@ -1163,6 +1163,7 @@ void MESH_OT_select_similar(wmOperatorType *ot) ot->invoke= WM_menu_invoke; ot->exec= select_similar_exec; ot->poll= ED_operator_editmesh; + ot->description= "Select similar vertices, edges or faces by property types."; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -1406,6 +1407,7 @@ void MESH_OT_loop_multi_select(wmOperatorType *ot) /* api callbacks */ ot->exec= loop_multiselect; ot->poll= ED_operator_editmesh; + ot->description= "Select a loop of connected edges by connection type."; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -1484,6 +1486,7 @@ void MESH_OT_loop_select(wmOperatorType *ot) /* api callbacks */ ot->invoke= mesh_select_loop_invoke; ot->poll= ED_operator_editmesh; + ot->description= "Select a loop of connected edges."; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -1585,6 +1588,7 @@ void MESH_OT_select_shortest_path(wmOperatorType *ot) /* api callbacks */ ot->invoke= mesh_shortest_path_select_invoke; ot->poll= ED_operator_editmesh; + ot->description= "Select shortest path between two selections."; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -1705,9 +1709,9 @@ void EDBM_selectmode_set(BMEditMesh *em) EDBM_strip_selections(em); /*strip BMEditSelections from em->selected that are not relevant to new mode*/ if(em->selectmode & SCE_SELECT_VERTEX) { - BMIter iter; + /*BMIter iter; - /*eed = BMIter_New(&iter, em->bm, BM_EDGES_OF_MESH, NULL); + eed = BMIter_New(&iter, em->bm, BM_EDGES_OF_MESH, NULL); for ( ; eed; eed=BMIter_Step(&iter)) BM_Select(em->bm, eed, 0); efa = BMIter_New(&iter, em->bm, BM_FACES_OF_MESH, NULL); @@ -1847,6 +1851,7 @@ void MESH_OT_select_inverse(wmOperatorType *ot) /* identifiers */ ot->name= "Select Inverse"; ot->idname= "MESH_OT_select_inverse"; + ot->description= "Select inverse of (un)selected vertices, edges or faces."; /* api callbacks */ ot->exec= select_inverse_mesh_exec; @@ -1928,6 +1933,7 @@ void MESH_OT_select_linked_pick(wmOperatorType *ot) /* api callbacks */ ot->invoke= select_linked_pick_invoke; ot->poll= ED_operator_editmesh; + ot->description= "select/deselect all vertices linked to the edge under the mouse cursor."; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -1983,6 +1989,7 @@ void MESH_OT_select_linked(wmOperatorType *ot) /* api callbacks */ ot->exec= select_linked_exec; ot->poll= ED_operator_editmesh; + ot->description= "Select all vertices linked to the active mesh."; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -2019,6 +2026,7 @@ void MESH_OT_select_more(wmOperatorType *ot) /* identifiers */ ot->name= "Select More"; ot->idname= "MESH_OT_select_more"; + ot->description= "Select more vertices, edges or faces connected to initial selection."; /* api callbacks */ ot->exec= select_more; @@ -2055,6 +2063,7 @@ void MESH_OT_select_less(wmOperatorType *ot) /* identifiers */ ot->name= "Select Less"; ot->idname= "MESH_OT_select_less"; + ot->description= "Deselect vertices, edges or faces at the boundary of each selection region."; /* api callbacks */ ot->exec= select_less; diff --git a/source/blender/editors/mesh/bmesh_tools.c b/source/blender/editors/mesh/bmesh_tools.c index 5e5452c5cc9..85d48a7c605 100644 --- a/source/blender/editors/mesh/bmesh_tools.c +++ b/source/blender/editors/mesh/bmesh_tools.c @@ -138,6 +138,7 @@ void MESH_OT_subdivide(wmOperatorType *ot) { /* identifiers */ ot->name= "Subdivide"; + ot->description= "Subdivide selected edges."; ot->idname= "MESH_OT_subdivide"; /* api callbacks */ @@ -554,6 +555,7 @@ void MESH_OT_extrude_repeat(wmOperatorType *ot) { /* identifiers */ ot->name= "Extrude Repeat Mesh"; + ot->description= "Extrude selected vertices, edges or faces repeatedly."; ot->idname= "MESH_OT_extrude_repeat"; /* api callbacks */ @@ -993,6 +995,7 @@ void MESH_OT_extrude(wmOperatorType *ot) { /* identifiers */ ot->name= "Extrude"; + ot->description= "Extrude selected vertices, edges or faces."; ot->idname= "MESH_OT_extrude"; /* api callbacks */ @@ -1027,6 +1030,7 @@ void MESH_OT_select_all_toggle(wmOperatorType *ot) /* identifiers */ ot->name= "Select/Deselect All"; ot->idname= "MESH_OT_select_all_toggle"; + ot->description= "(de)select all vertices, edges or faces."; /* api callbacks */ ot->exec= toggle_select_all_exec; @@ -1156,6 +1160,7 @@ void MESH_OT_dupli_extrude_cursor(wmOperatorType *ot) /* api callbacks */ ot->invoke= dupli_extrude_cursor; + ot->description= "Duplicate and extrude selected vertices, edges or faces towards the mouse cursor."; ot->poll= ED_operator_editmesh; /* flags */ @@ -1247,6 +1252,7 @@ void MESH_OT_delete(wmOperatorType *ot) { /* identifiers */ ot->name= "Delete"; + ot->description= "Delete selected vertices, edges or faces."; ot->idname= "MESH_OT_delete"; /* api callbacks */ @@ -1288,6 +1294,7 @@ void MESH_OT_edge_face_add(wmOperatorType *ot) { /* identifiers */ ot->name= "Make Edge/Face"; + ot->description= "Add an edge or face to selected."; ot->idname= "MESH_OT_edge_face_add"; /* api callbacks */ @@ -1337,6 +1344,7 @@ void MESH_OT_selection_type(wmOperatorType *ot) { /* identifiers */ ot->name= "Selection Mode"; + ot->description= "Set the selection mode type."; ot->idname= "MESH_OT_selection_type"; /* api callbacks */ @@ -1393,6 +1401,7 @@ void MESH_OT_mark_seam(wmOperatorType *ot) /* identifiers */ ot->name= "Mark Seam"; ot->idname= "MESH_OT_mark_seam"; + ot->description= "(un)mark selected edges as a seam."; /* api callbacks */ ot->exec= editbmesh_mark_seam; @@ -1442,6 +1451,7 @@ void MESH_OT_mark_sharp(wmOperatorType *ot) /* identifiers */ ot->name= "Mark Sharp"; ot->idname= "MESH_OT_mark_sharp"; + ot->description= "(un)mark selected edges as sharp."; /* api callbacks */ ot->exec= editbmesh_mark_sharp; @@ -1564,6 +1574,7 @@ void MESH_OT_duplicate(wmOperatorType *ot) { /* identifiers */ ot->name= "Duplicate"; + ot->description= "Duplicate selected vertices, edges or faces."; ot->idname= "MESH_OT_duplicate"; /* api callbacks */ @@ -1595,6 +1606,7 @@ void MESH_OT_flip_normals(wmOperatorType *ot) { /* identifiers */ ot->name= "Flip Normals"; + ot->description= "Flip the direction of selected face's vertex and face normals"; ot->idname= "MESH_OT_flip_normals"; /* api callbacks */ @@ -1678,6 +1690,7 @@ void MESH_OT_edge_rotate(wmOperatorType *ot) { /* identifiers */ ot->name= "Rotate Selected Edge"; + ot->description= "Rotate selected edge or adjoining faces."; ot->idname= "MESH_OT_edge_rotate"; /* api callbacks */ @@ -1745,7 +1758,8 @@ void MESH_OT_hide(wmOperatorType *ot) /* api callbacks */ ot->exec= hide_mesh_exec; ot->poll= ED_operator_editmesh; - + ot->description= "Hide (un)selected vertices, edges or faces."; + /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -1794,6 +1808,7 @@ void MESH_OT_reveal(wmOperatorType *ot) /* identifiers */ ot->name= "Reveal Hidden"; ot->idname= "MESH_OT_reveal"; + ot->description= "Reveal all hidden vertices, edges and faces."; /* api callbacks */ ot->exec= reveal_mesh_exec; @@ -1825,6 +1840,7 @@ void MESH_OT_normals_make_consistent(wmOperatorType *ot) { /* identifiers */ ot->name= "Make Normals Consistent"; + ot->description= "Make face and vertex normals point either outside or inside the mesh"; ot->idname= "MESH_OT_normals_make_consistent"; /* api callbacks */ @@ -1891,6 +1907,7 @@ void MESH_OT_vertices_smooth(wmOperatorType *ot) { /* identifiers */ ot->name= "Smooth Vertex"; + ot->description= "Flatten angles of selected vertices."; ot->idname= "MESH_OT_vertices_smooth"; /* api callbacks */ @@ -2003,6 +2020,7 @@ void MESH_OT_faces_shade_smooth(wmOperatorType *ot) { /* identifiers */ ot->name= "Shade Smooth"; + ot->description= "Display faces smooth (using vertex normals)."; ot->idname= "MESH_OT_faces_shade_smooth"; /* api callbacks */ @@ -2031,6 +2049,7 @@ void MESH_OT_faces_shade_flat(wmOperatorType *ot) { /* identifiers */ ot->name= "Shade Flat"; + ot->description= "Display faces flat."; ot->idname= "MESH_OT_faces_shade_flat"; /* api callbacks */ diff --git a/source/blender/editors/mesh/editmesh.c b/source/blender/editors/mesh/editmesh.c index 5892af0060b..d8bcf43e978 100644 --- a/source/blender/editors/mesh/editmesh.c +++ b/source/blender/editors/mesh/editmesh.c @@ -68,6 +68,7 @@ #include "BKE_mesh.h" #include "BKE_modifier.h" #include "BKE_object.h" +#include "BKE_paint.h" #include "BKE_pointcache.h" #include "BKE_softbody.h" #include "BKE_texture.h" @@ -821,11 +822,11 @@ EditMesh *make_editMesh(Scene *scene, Object *ob) if(cacheedit) { if(pid.type == PTCACHE_TYPE_CLOTH) { - cloth= ((ClothModifierData*)pid.data)->clothObject; + cloth= ((ClothModifierData*)pid.calldata)->clothObject; VECCOPY(cacheco, cloth->verts[a].x) } else if(pid.type == PTCACHE_TYPE_SOFTBODY) { - sb= (SoftBody*)pid.data; + sb= (SoftBody*)pid.calldata; VECCOPY(cacheco, sb->bpoint[a].pos) } @@ -839,7 +840,7 @@ EditMesh *make_editMesh(Scene *scene, Object *ob) evlist[a]= eve; // face select sets selection in next loop - if( (FACESEL_PAINT_TEST)==0 ) + if(!paint_facesel_test(ob)) eve->f |= (mvert->flag & 1); if (mvert->flag & ME_HIDE) eve->h= 1; @@ -914,7 +915,7 @@ EditMesh *make_editMesh(Scene *scene, Object *ob) if(mface->flag & ME_FACE_SEL) { efa->f |= SELECT; - if(FACESEL_PAINT_TEST) { + if(paint_facesel_test(ob)) { EM_select_face(efa, 1); /* flush down */ } } @@ -1041,7 +1042,7 @@ void load_editMesh(Scene *scene, Object *ob, EditMesh *em) while(eve) { if(cacheedit) { if(pid.type == PTCACHE_TYPE_CLOTH) { - clmd= (ClothModifierData*)pid.data; + clmd= (ClothModifierData*)pid.calldata; cloth= clmd->clothObject; /* assign position */ @@ -1056,7 +1057,7 @@ void load_editMesh(Scene *scene, Object *ob, EditMesh *em) VECADD(cloth->verts[a].v, cloth->verts[a].v, cacheco); } else if(pid.type == PTCACHE_TYPE_SOFTBODY) { - sb= (SoftBody*)pid.data; + sb= (SoftBody*)pid.calldata; /* assign position */ VECCOPY(cacheco, sb->bpoint[a].pos) @@ -1102,12 +1103,8 @@ void load_editMesh(Scene *scene, Object *ob, EditMesh *em) } /* write changes to cache */ - if(cacheedit) { - if(pid.type == PTCACHE_TYPE_CLOTH) - cloth_write_cache(ob, pid.data, pid.cache->editframe); - else if(pid.type == PTCACHE_TYPE_SOFTBODY) - softbody_write_cache(ob, pid.data, pid.cache->editframe); - } + if(cacheedit) + BKE_ptcache_write_cache(&pid, pid.cache->editframe); /* the edges */ a= 0; @@ -1572,6 +1569,7 @@ void MESH_OT_separate(wmOperatorType *ot) { /* identifiers */ ot->name= "Separate"; + ot->description= "Separate selected geometry into a new mesh."; ot->idname= "MESH_OT_separate"; /* api callbacks */ diff --git a/source/blender/editors/mesh/editmesh_add.c b/source/blender/editors/mesh/editmesh_add.c index ff0814661eb..fbeb1636114 100644 --- a/source/blender/editors/mesh/editmesh_add.c +++ b/source/blender/editors/mesh/editmesh_add.c @@ -119,7 +119,6 @@ static short icoface[20][3] = { {10,9,11} }; - /* ********************** */ /* selected faces get hidden edges */ @@ -240,6 +239,7 @@ void MESH_OT_fgon_make(struct wmOperatorType *ot) { /* identifiers */ ot->name= "Make F-gon"; + ot->description= "Make fgon from selected faces."; ot->idname= "MESH_OT_fgon_make"; /* api callbacks */ @@ -272,6 +272,7 @@ void MESH_OT_fgon_clear(struct wmOperatorType *ot) { /* identifiers */ ot->name= "Clear F-gon"; + ot->description= "Clear fgon from selected face."; ot->idname= "MESH_OT_fgon_clear"; /* api callbacks */ @@ -711,6 +712,7 @@ static void addedgeface_mesh(Mesh *me, BMEditMesh *bem, wmOperator *op) BKE_mesh_end_editmesh(me, em); } + /* ************************ primitives ******************* */ // HACK: these can also be found in cmoview.tga.c, but are here so that they can be found by linker @@ -1226,6 +1228,7 @@ void MESH_OT_primitive_plane_add(wmOperatorType *ot) { /* identifiers */ ot->name= "Add Plane"; + ot->description= "Construct a filled planar mesh with 4 vertices."; ot->idname= "MESH_OT_primitive_plane_add"; /* api callbacks */ @@ -1258,6 +1261,7 @@ void MESH_OT_primitive_cube_add(wmOperatorType *ot) { /* identifiers */ ot->name= "Add Cube"; + ot->description= "Construct a cube mesh."; ot->idname= "MESH_OT_primitive_cube_add"; /* api callbacks */ @@ -1290,6 +1294,7 @@ void MESH_OT_primitive_circle_add(wmOperatorType *ot) { /* identifiers */ ot->name= "Add Circle"; + ot->description= "Construct a circle mesh."; ot->idname= "MESH_OT_primitive_circle_add"; /* api callbacks */ @@ -1327,6 +1332,7 @@ void MESH_OT_primitive_cylinder_add(wmOperatorType *ot) { /* identifiers */ ot->name= "Add Cylinder"; + ot->description= "Construct a cylindrical mesh (ends filled)."; ot->idname= "MESH_OT_primitive_cylinder_add"; /* api callbacks */ @@ -1364,6 +1370,7 @@ void MESH_OT_primitive_tube_add(wmOperatorType *ot) { /* identifiers */ ot->name= "Add Tube"; + ot->description= "Construct a cylindrical mesh (ends not filled)."; ot->idname= "MESH_OT_primitive_tube_add"; /* api callbacks */ @@ -1401,6 +1408,7 @@ void MESH_OT_primitive_cone_add(wmOperatorType *ot) { /* identifiers */ ot->name= "Add Cone"; + ot->description= "Construct a conic mesh (ends filled)."; ot->idname= "MESH_OT_primitive_cone_add"; /* api callbacks */ @@ -1440,6 +1448,7 @@ void MESH_OT_primitive_grid_add(wmOperatorType *ot) { /* identifiers */ ot->name= "Add Grid"; + ot->description= "Construct a grid mesh."; ot->idname= "MESH_OT_primitive_grid_add"; /* api callbacks */ @@ -1475,6 +1484,7 @@ void MESH_OT_primitive_monkey_add(wmOperatorType *ot) { /* identifiers */ ot->name= "Add Monkey"; + ot->description= "Construct a Suzanne mesh."; ot->idname= "MESH_OT_primitive_monkey_add"; /* api callbacks */ @@ -1507,6 +1517,7 @@ void MESH_OT_primitive_uv_sphere_add(wmOperatorType *ot) { /* identifiers */ ot->name= "Add UV Sphere"; + ot->description= "Construct a UV sphere mesh."; ot->idname= "MESH_OT_primitive_uv_sphere_add"; /* api callbacks */ @@ -1544,6 +1555,7 @@ void MESH_OT_primitive_ico_sphere_add(wmOperatorType *ot) { /* identifiers */ ot->name= "Add Ico Sphere"; + ot->description= "Construct an Icosphere mesh."; ot->idname= "MESH_OT_primitive_ico_sphere_add"; /* api callbacks */ diff --git a/source/blender/editors/mesh/editmesh_loop.c b/source/blender/editors/mesh/editmesh_loop.c index b59c46a8068..7e741831133 100644 --- a/source/blender/editors/mesh/editmesh_loop.c +++ b/source/blender/editors/mesh/editmesh_loop.c @@ -882,6 +882,7 @@ void MESH_OT_knife_cut(wmOperatorType *ot) PropertyRNA *prop; ot->name= "Knife Cut"; + ot->description= "Cut selected edges and faces into parts."; ot->idname= "MESH_OT_knife_cut"; ot->invoke= WM_gesture_lines_invoke; diff --git a/source/blender/editors/mesh/editmesh_mods.c b/source/blender/editors/mesh/editmesh_mods.c index 06870915e1d..b38f35ed529 100644 --- a/source/blender/editors/mesh/editmesh_mods.c +++ b/source/blender/editors/mesh/editmesh_mods.c @@ -65,6 +65,7 @@ editmesh_mods.c, UI level access, no geometry changes #include "BKE_global.h" #include "BKE_mesh.h" #include "BKE_material.h" +#include "BKE_paint.h" #include "BKE_texture.h" #include "BKE_utildefines.h" #include "BKE_report.h" @@ -245,7 +246,7 @@ int EM_mask_init_backbuf_border(ViewContext *vc, short mcords[][2], short tot, s /* method in use for face selecting too */ if(vc->obedit==NULL) { - if(FACESEL_PAINT_TEST); + if(paint_facesel_test(vc->obact)); else return 0; } else if(vc->v3d->drawtype<OB_SOLID || (vc->v3d->flag & V3D_ZBUF_SELECT)==0) return 0; @@ -300,7 +301,7 @@ int EM_init_backbuf_circle(ViewContext *vc, short xs, short ys, short rads) /* method in use for face selecting too */ if(vc->obedit==NULL) { - if(FACESEL_PAINT_TEST); + if(paint_facesel_test(vc->obact)); else return 0; } else if(vc->v3d->drawtype<OB_SOLID || (vc->v3d->flag & V3D_ZBUF_SELECT)==0) return 0; @@ -1044,6 +1045,7 @@ void MESH_OT_loop_multi_select(wmOperatorType *ot) { /* identifiers */ ot->name= "Multi Select Loops"; + ot->description= "Select a loop of connected edges by connection type."; ot->idname= "MESH_OT_loop_multi_select"; /* api callbacks */ @@ -1061,8 +1063,6 @@ void MESH_OT_loop_multi_select(wmOperatorType *ot) /* ***************** MAIN MOUSE SELECTION ************** */ -/* ******************* mesh shortest path select, uses prev-selected edge ****************** */ - /* ************************************************** */ /* *********** select linked ************* */ @@ -1272,6 +1272,7 @@ void MESH_OT_select_by_number_vertices(wmOperatorType *ot) /* identifiers */ ot->name= "Select by Number of Vertices"; + ot->description= "Select vertices or faces by vertex count."; ot->idname= "MESH_OT_select_by_number_vertices"; /* api callbacks */ @@ -1392,6 +1393,7 @@ void MESH_OT_edges_select_sharp(wmOperatorType *ot) { /* identifiers */ ot->name= "Select Sharp Edges"; + ot->description= "Marked selected edges as sharp."; ot->idname= "MESH_OT_edges_select_sharp"; /* api callbacks */ @@ -1559,6 +1561,7 @@ void MESH_OT_faces_select_linked_flat(wmOperatorType *ot) { /* identifiers */ ot->name= "Select Linked Flat Faces"; + ot->description= "Select linked faces by angle."; ot->idname= "MESH_OT_faces_select_linked_flat"; /* api callbacks */ @@ -1659,6 +1662,7 @@ void MESH_OT_select_non_manifold(wmOperatorType *ot) { /* identifiers */ ot->name= "Select Non Manifold"; + ot->description= "Select all non-manifold vertices or edges."; ot->idname= "MESH_OT_select_non_manifold"; /* api callbacks */ @@ -1687,7 +1691,6 @@ void MESH_OT_bmesh_test(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } - static void selectrandom_mesh(EditMesh *em, float perc) /* randomly selects a user-set % of vertices/edges/faces */ { EditVert *eve; @@ -1747,6 +1750,7 @@ void MESH_OT_select_random(wmOperatorType *ot) { /* identifiers */ ot->name= "Select Random"; + ot->description= "Randomly select vertices."; ot->idname= "MESH_OT_select_random"; /* api callbacks */ @@ -1814,7 +1818,6 @@ static void mesh_selection_type(Scene *scene, EditMesh *em, int val) } /* **************** NORMALS ************** */ - /* XXX value of select is messed up, it means two things */ void righthandfaces(EditMesh *em, int select) /* makes faces righthand turning */ { @@ -2457,6 +2460,8 @@ void MESH_OT_vertices_transform_to_sphere(wmOperatorType *ot) { /* identifiers */ ot->name= "Vertices to Sphere"; + //added "around cursor" to differentiate between "TFM_OT_tosphere()" + ot->description= "Move selected vertices outward in a spherical shape around cursor."; ot->idname= "MESH_OT_vertices_transform_to_sphere"; /* api callbacks */ diff --git a/source/blender/editors/mesh/mesh_layers.c b/source/blender/editors/mesh/mesh_layers.c index 302251dde9f..2b4ba03270f 100644 --- a/source/blender/editors/mesh/mesh_layers.c +++ b/source/blender/editors/mesh/mesh_layers.c @@ -55,14 +55,16 @@ #include "WM_types.h" #include "ED_mesh.h" +#include "ED_object.h" #include "ED_view3d.h" #include "mesh_intern.h" #include "bmesh.h" -static void delete_customdata_layer(Mesh *me, CustomDataLayer *layer, int loop) +static void delete_customdata_layer(bContext *C, Object *ob, CustomDataLayer *layer, int loop) { CustomData *data; + Mesh *me = ob->data; void *actlayerdata, *rndlayerdata, *clonelayerdata, *masklayerdata, *layerdata=layer->data; int type= layer->type; int index; @@ -96,9 +98,8 @@ static void delete_customdata_layer(Mesh *me, CustomDataLayer *layer, int loop) mesh_update_customdata_pointers(me); } - if(!CustomData_has_layer(data, type)) - if(type == CD_MLOOPCOL && (G.f & G_VERTEXPAINT)) - G.f &= ~G_VERTEXPAINT; /* get out of vertexpaint mode */ + if(!CustomData_has_layer(data, type) && (type == CD_MLOOPCOL && (ob->mode & OB_MODE_VERTEX_PAINT))) + ED_object_toggle_modes(C, OB_MODE_VERTEX_PAINT); /* reconstruct active layer */ if (actlayerdata != layerdata) { @@ -211,6 +212,7 @@ void MESH_OT_uv_texture_add(wmOperatorType *ot) { /* identifiers */ ot->name= "Add UV Texture"; + ot->description= "Add UV texture layer."; ot->idname= "MESH_OT_uv_texture_add"; /* api callbacks */ @@ -241,8 +243,8 @@ static int uv_texture_remove_exec(bContext *C, wmOperator *op) if(!cdl) return OPERATOR_CANCELLED; - delete_customdata_layer(me, cdl, 0); - delete_customdata_layer(me, cdl2, 1); + delete_customdata_layer(C, ob, cdl, 0); + delete_customdata_layer(C, ob, cdl2, 1); DAG_object_flush_update(scene, ob, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, ob); @@ -254,6 +256,7 @@ void MESH_OT_uv_texture_remove(wmOperatorType *ot) { /* identifiers */ ot->name= "Remove UV Texture"; + ot->description= "Remove UV texture layer."; ot->idname= "MESH_OT_uv_texture_remove"; /* api callbacks */ @@ -318,6 +321,7 @@ void MESH_OT_vertex_color_add(wmOperatorType *ot) { /* identifiers */ ot->name= "Add Vertex Color"; + ot->description= "Add vertex color layer."; ot->idname= "MESH_OT_vertex_color_add"; /* api callbacks */ @@ -345,7 +349,7 @@ static int vertex_color_remove_exec(bContext *C, wmOperator *op) if(!cdl) return OPERATOR_CANCELLED; - delete_customdata_layer(me, cdl, 1); + delete_customdata_layer(C, ob, cdl, 1); DAG_object_flush_update(scene, ob, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, ob); @@ -357,6 +361,7 @@ void MESH_OT_vertex_color_remove(wmOperatorType *ot) { /* identifiers */ ot->name= "Remove Vertex Color"; + ot->description= "Remove vertex color layer."; ot->idname= "MESH_OT_vertex_color_remove"; /* api callbacks */ @@ -394,6 +399,7 @@ void MESH_OT_sticky_add(wmOperatorType *ot) { /* identifiers */ ot->name= "Add Sticky"; + ot->description= "Add sticky UV texture layer."; ot->idname= "MESH_OT_sticky_add"; /* api callbacks */ @@ -430,6 +436,7 @@ void MESH_OT_sticky_remove(wmOperatorType *ot) { /* identifiers */ ot->name= "Remove Sticky"; + ot->description= "Remove sticky UV texture layer."; ot->idname= "MESH_OT_sticky_remove"; /* api callbacks */ diff --git a/source/blender/editors/mesh/mesh_ops.c b/source/blender/editors/mesh/mesh_ops.c index 01cf15cb9f1..1498f3573f1 100644 --- a/source/blender/editors/mesh/mesh_ops.c +++ b/source/blender/editors/mesh/mesh_ops.c @@ -91,6 +91,7 @@ static void MESH_OT_vertex_specials(wmOperatorType *ot) { /* identifiers */ ot->name= "Vertex Specials"; + //ot->description= "Perform special vertex operations."; ot->idname= "MESH_OT_vertex_specials"; /* api callbacks */ @@ -129,6 +130,7 @@ static void MESH_OT_edge_specials(wmOperatorType *ot) { /* identifiers */ ot->name= "Edge Specials"; + //ot->description= "Perform special edge operations."; ot->idname= "MESH_OT_edge_specials"; /* api callbacks */ @@ -179,6 +181,7 @@ static void MESH_OT_face_specials(wmOperatorType *ot) { /* identifiers */ ot->name= "Face Specials"; + //ot->description= "Perform special face operations."; ot->idname= "MESH_OT_face_specials"; /* api callbacks */ @@ -220,6 +223,7 @@ static void MESH_OT_specials(wmOperatorType *ot) { /* identifiers */ ot->name= "Specials"; + //ot->description= "Perform special vertice, edge or face operations."; ot->idname= "MESH_OT_specials"; /* api callbacks */ diff --git a/source/blender/editors/object/editconstraint.c b/source/blender/editors/object/editconstraint.c index 9e8205e58ab..23b3caf8e26 100644 --- a/source/blender/editors/object/editconstraint.c +++ b/source/blender/editors/object/editconstraint.c @@ -87,7 +87,7 @@ ListBase *get_active_constraints (Object *ob) if (ob == NULL) return NULL; - if (ob->flag & OB_POSEMODE) { + if (ob->mode & OB_MODE_POSE) { bPoseChannel *pchan; pchan = get_active_posechannel(ob); @@ -1065,7 +1065,7 @@ static int constraint_add_exec(bContext *C, wmOperator *op, Object *ob, ListBase { /* if this constraint is being added to a posechannel, make sure * the constraint gets evaluated in pose-space */ - if (ob->flag & OB_POSEMODE) { + if (ob->mode & OB_MODE_POSE) { con->ownspace = CONSTRAINT_SPACE_POSE; con->flag |= CONSTRAINT_SPACEONCE; } diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 780fa526b33..db94dfb1ec8 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -99,6 +99,7 @@ #include "BKE_tessmesh.h" #include "BKE_nla.h" #include "BKE_object.h" +#include "BKE_paint.h" #include "BKE_particle.h" #include "BKE_property.h" #include "BKE_report.h" @@ -127,6 +128,7 @@ #include "RNA_access.h" #include "RNA_define.h" +#include "RNA_enum_types.h" /* for menu/popup icons etc etc*/ #include "UI_interface.h" @@ -178,10 +180,6 @@ void ED_base_object_activate(bContext *C, Base *base) Scene *scene= CTX_data_scene(C); Base *tbase; - /* activating a non-mesh, should end a couple of modes... */ - if(base && base->object->type!=OB_MESH) - ED_view3d_exit_paint_modes(C); - /* sets scene->basact */ BASACT= base; @@ -273,9 +271,6 @@ static Object *object_add_type(bContext *C, int type) Scene *scene= CTX_data_scene(C); Object *ob; - /* XXX hrms, this is editor level operator, remove? */ - ED_view3d_exit_paint_modes(C); - /* for as long scene has editmode... */ if (CTX_data_edit_object(C)) ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR); /* freedata, and undo */ @@ -752,8 +747,6 @@ static int object_delete_exec(bContext *C, wmOperator *op) if(CTX_data_edit_object(C)) return OPERATOR_CANCELLED; - ED_view3d_exit_paint_modes(C); - CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) { if(base->object->type==OB_LAMP) islamp= 1; @@ -989,6 +982,8 @@ static void select_editmesh_hook(Object *ob, HookModifierData *hmd) BMIter iter; int index=0, nr=0; + if (hmd->indexar == NULL) + return; BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL) { if(nr==hmd->indexar[index]) { BM_Select(em->bm, eve, 1); @@ -1158,7 +1153,7 @@ void ED_object_apply_obmat(Object *ob) } -int hook_getIndexArray(Object *obedit, int *tot, int **indexar, char *name, float *cent_r) +int object_hook_index_array(Object *obedit, int *tot, int **indexar, char *name, float *cent_r) { *indexar= NULL; *tot= 0; @@ -1237,9 +1232,8 @@ static void select_editcurve_hook(Object *obedit, HookModifierData *hmd) } } -void obedit_hook_select(Object *ob, HookModifierData *hmd) +void object_hook_select(Object *ob, HookModifierData *hmd) { - if(ob->type==OB_MESH) select_editmesh_hook(ob, hmd); else if(ob->type==OB_LATTICE) select_editlattice_hook(ob, hmd); else if(ob->type==OB_CURVE) select_editcurve_hook(ob, hmd); @@ -1323,7 +1317,7 @@ void add_hook(Scene *scene, View3D *v3d, int mode) int tot, ok, *indexar; char name[32]; - ok = hook_getIndexArray(obedit, &tot, &indexar, name, cent); + ok = object_hook_index_array(obedit, &tot, &indexar, name, cent); if(ok==0) { error("Requires selected vertices or active Vertex Group"); @@ -1367,6 +1361,7 @@ void add_hook(Scene *scene, View3D *v3d, int mode) hmd->totindex= tot; BLI_strncpy(hmd->name, name, 32); + // TODO: need to take into account bone targets here too now... if(mode==1 || mode==2) { /* matrix calculus */ /* vert x (obmat x hook->imat) x hook->obmat x ob->imat */ @@ -1386,9 +1381,11 @@ void add_hook(Scene *scene, View3D *v3d, int mode) modifier_free(md); } else if(mode==5) { /* select */ - obedit_hook_select(obedit, hmd); + // FIXME: this is now OBJECT_OT_hook_select + object_hook_select(obedit, hmd); } else if(mode==6) { /* clear offset */ + // FIXME: this is now OBJECT_OT_hook_reset operator where_is_object(scene, ob); /* ob is hook->parent */ Mat4Invert(ob->imat, ob->obmat); @@ -1400,6 +1397,25 @@ void add_hook(Scene *scene, View3D *v3d, int mode) DAG_scene_sort(scene); } +void add_hook_menu(Scene *scene, View3D *v3d) +{ + Object *obedit= scene->obedit; // XXX get from context + int mode; + + if(obedit==NULL) return; + + if(modifiers_findByType(obedit, eModifierType_Hook)) + mode= pupmenu("Hooks %t|Add, To New Empty %x1|Add, To Selected Object %x2|Remove... %x3|Reassign... %x4|Select... %x5|Clear Offset...%x6"); + else + mode= pupmenu("Hooks %t|Add, New Empty %x1|Add, To Selected Object %x2"); + + if(mode<1) return; + + /* do operations */ + add_hook(scene, v3d, mode); +} + + /* use this when the loc/size/rot of the parent has changed but the children should stay in the same place * apply-size-rot or object center for eg */ @@ -1418,25 +1434,6 @@ static void ignore_parent_tx(Scene *scene, Object *ob ) } } - -void add_hook_menu(Scene *scene, View3D *v3d) -{ - Object *obedit= scene->obedit; // XXX get from context - int mode; - - if(obedit==NULL) return; - - if(modifiers_findByType(obedit, eModifierType_Hook)) - mode= pupmenu("Hooks %t|Add, To New Empty %x1|Add, To Selected Object %x2|Remove... %x3|Reassign... %x4|Select... %x5|Clear Offset...%x6"); - else - mode= pupmenu("Hooks %t|Add, New Empty %x1|Add, To Selected Object %x2"); - - if(mode<1) return; - - /* do operations */ - add_hook(scene, v3d, mode); -} - /* ******************** clear parent operator ******************* */ static EnumPropertyItem prop_clear_parent_types[] = { @@ -2244,7 +2241,7 @@ static int object_location_clear_exec(bContext *C, wmOperator *op) int armature_clear= 0; CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) { - if((G.f & G_WEIGHTPAINT)==0) { + if(!(ob->mode & OB_MODE_WEIGHT_PAINT)) { if ((ob->protectflag & OB_LOCK_LOCX)==0) ob->loc[0]= ob->dloc[0]= 0.0f; if ((ob->protectflag & OB_LOCK_LOCY)==0) @@ -2287,7 +2284,7 @@ static int object_rotation_clear_exec(bContext *C, wmOperator *op) int armature_clear= 0; CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) { - if((G.f & G_WEIGHTPAINT)==0) { + if(!(ob->mode & OB_MODE_WEIGHT_PAINT)) { /* eulers can only get cleared if they are not protected */ if ((ob->protectflag & OB_LOCK_ROTX)==0) ob->rot[0]= ob->drot[0]= 0.0f; @@ -2331,7 +2328,7 @@ static int object_scale_clear_exec(bContext *C, wmOperator *op) int armature_clear= 0; CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) { - if((G.f & G_WEIGHTPAINT)==0) { + if(!(ob->mode & OB_MODE_WEIGHT_PAINT)) { if ((ob->protectflag & OB_LOCK_SCALEX)==0) { ob->dsize[0]= 0.0f; ob->size[0]= 1.0f; @@ -2758,13 +2755,10 @@ static void proxy_group_objects_menu (bContext *C, wmOperator *op, Object *ob, G if (go->ob) { PointerRNA props_ptr; - /* create operator properties, and assign the relevant pointers to that, - * and add a menu entry which uses these props - */ - WM_operator_properties_create(&props_ptr, op->idname); + /* create operator menu item with relevant properties filled in */ + props_ptr= uiItemFullO(layout, go->ob->id.name+2, 0, op->idname, NULL, WM_OP_EXEC_REGION_WIN, UI_ITEM_O_RETURN_PROPS); RNA_string_set(&props_ptr, "object", go->ob->id.name+2); RNA_string_set(&props_ptr, "group_object", go->ob->id.name+2); - uiItemFullO(layout, go->ob->id.name+2, 0, op->idname, props_ptr.data, WM_OP_EXEC_REGION_WIN); } } @@ -2792,12 +2786,9 @@ static int make_proxy_invoke (bContext *C, wmOperator *op, wmEvent *evt) uiLayout *layout= uiPupMenuLayout(pup); PointerRNA props_ptr; - /* create operator properties, and assign the relevant pointers to that, - * and add a menu entry which uses these props - */ - WM_operator_properties_create(&props_ptr, op->idname); + /* create operator menu item with relevant properties filled in */ + props_ptr= uiItemFullO(layout, op->type->name, 0, op->idname, props_ptr.data, WM_OP_EXEC_REGION_WIN, UI_ITEM_O_RETURN_PROPS); RNA_string_set(&props_ptr, "object", ob->id.name+2); - uiItemFullO(layout, op->type->name, 0, op->idname, props_ptr.data, WM_OP_EXEC_REGION_WIN); /* present the menu and be done... */ uiPupMenuEnd(C, pup); @@ -3696,7 +3687,7 @@ void ED_object_exit_editmode(bContext *C, int flag) me->edit_btmesh= NULL; } - if(G.f & G_WEIGHTPAINT) + if(obedit->restore_mode & OB_MODE_WEIGHT_PAINT) mesh_octree_table(obedit, NULL, NULL, 'e'); } else if (obedit->type==OB_ARMATURE) { @@ -3735,6 +3726,9 @@ void ED_object_exit_editmode(bContext *C, int flag) WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_MODE_OBJECT, scene); } + + obedit->mode &= ~OB_MODE_EDIT; + ED_object_toggle_modes(C, obedit->restore_mode); } @@ -3768,7 +3762,10 @@ void ED_object_enter_editmode(bContext *C, int flag) if(flag & EM_WAITCURSOR) waitcursor(1); - ED_view3d_exit_paint_modes(C); + ob->restore_mode = ob->mode; + ED_object_toggle_modes(C, ob->mode); + + ob->mode |= OB_MODE_EDIT; if(ob->type==OB_MESH) { Mesh *me= ob->data; @@ -3856,6 +3853,16 @@ static int editmode_toggle_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } +static int editmode_toggle_poll(bContext *C) +{ + Object *ob = CTX_data_active_object(C); + + return ob && (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); +} + void OBJECT_OT_editmode_toggle(wmOperatorType *ot) { @@ -3867,7 +3874,7 @@ void OBJECT_OT_editmode_toggle(wmOperatorType *ot) /* api callbacks */ ot->exec= editmode_toggle_exec; - ot->poll= ED_operator_object_active; + ot->poll= editmode_toggle_poll; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -3884,7 +3891,7 @@ static int posemode_exec(bContext *C, wmOperator *op) ED_object_exit_editmode(C, EM_FREEDATA); ED_armature_enter_posemode(C, base); } - else if(base->object->flag & OB_POSEMODE) + else if(base->object->mode & OB_MODE_POSE) ED_armature_exit_posemode(C, base); else ED_armature_enter_posemode(C, base); @@ -4107,10 +4114,10 @@ void special_editmenu(Scene *scene, View3D *v3d) if(obedit==NULL) { - if(ob->flag & OB_POSEMODE) { + if(ob->mode & OB_MODE_POSE) { // XXX pose_special_editmenu(); } - else if(FACESEL_PAINT_TEST) { + else if(paint_facesel_test(ob)) { Mesh *me= get_mesh(ob); MTFace *tface; MFace *mface; @@ -4156,7 +4163,7 @@ void special_editmenu(Scene *scene, View3D *v3d) } DAG_object_flush_update(scene, ob, OB_RECALC_DATA); } - else if(G.f & G_VERTEXPAINT) { + else if(ob->mode & OB_MODE_VERTEX_PAINT) { Mesh *me= get_mesh(ob); if(me==0 || (me->mcol==NULL && me->mtface==NULL) ) return; @@ -4169,17 +4176,17 @@ void special_editmenu(Scene *scene, View3D *v3d) DAG_object_flush_update(scene, ob, OB_RECALC_DATA); } } - else if(G.f & G_WEIGHTPAINT) { + else if(ob->mode & OB_MODE_WEIGHT_PAINT) { Object *par= modifiers_isDeformedByArmature(ob); - if(par && (par->flag & OB_POSEMODE)) { + if(par && (par->mode & OB_MODE_POSE)) { nr= pupmenu("Specials%t|Apply Bone Envelopes to Vertex Groups %x1|Apply Bone Heat Weights to Vertex Groups %x2"); // XXX if(nr==1 || nr==2) // XXX pose_adds_vgroups(ob, (nr == 2)); } } - else if(G.f & G_PARTICLEEDIT) { + else if(ob->mode & OB_MODE_PARTICLE_EDIT) { #if 0 // XXX ParticleSystem *psys = PE_get_current(ob); @@ -5721,7 +5728,7 @@ void new_id_matar(Material **matar, int totcol) } } -void single_obdata_users(Scene *scene, View3D *v3d, int flag) +void single_obdata_users(Scene *scene, int flag) { Object *ob; Lamp *la; @@ -5844,7 +5851,7 @@ void single_obdata_users(Scene *scene, View3D *v3d, int flag) } } -void single_ipo_users(Scene *scene, View3D *v3d, int flag) +void single_ipo_users(Scene *scene, int flag) { #if 0 // XXX old animation system Object *ob; @@ -5867,7 +5874,7 @@ void single_ipo_users(Scene *scene, View3D *v3d, int flag) #endif // XXX old animation system } -void single_mat_users(Scene *scene, View3D *v3d, int flag) +void single_mat_users(Scene *scene, int flag) { Object *ob; Base *base; @@ -6053,19 +6060,19 @@ void single_user(Scene *scene, View3D *v3d) else if(nr==2) { single_object_users(scene, v3d, 1); - single_obdata_users(scene, v3d, 1); + single_obdata_users(scene, 1); } else if(nr==3) { single_object_users(scene, v3d, 1); - single_obdata_users(scene, v3d, 1); - single_mat_users(scene, v3d, 1); /* also tex */ + single_obdata_users(scene, 1); + single_mat_users(scene, 1); /* also tex */ } else if(nr==4) { - single_mat_users(scene, v3d, 1); + single_mat_users(scene, 1); } else if(nr==5) { - single_ipo_users(scene, v3d, 1); + single_ipo_users(scene, 1); } @@ -6074,6 +6081,20 @@ void single_user(Scene *scene, View3D *v3d) } } +/* used for copying scenes */ +void ED_object_single_users(Scene *scene, int full) +{ + single_object_users(scene, NULL, 0); + + if(full) { + single_obdata_users(scene, 0); + single_mat_users_expand(); + single_tex_users_expand(); + } + + clear_id_newpoins(); +} + /* ************************************************************* */ /* helper for below, ma was checked to be not NULL */ @@ -6278,7 +6299,7 @@ static Base *object_add_duplicate_internal(Scene *scene, Base *base, int dupflag int a, didit; ob= base->object; - if(ob->flag & OB_POSEMODE) { + if(ob->mode & OB_MODE_POSE) { ; /* nothing? */ } else { @@ -7014,3 +7035,124 @@ void hookmenu(Scene *scene, View3D *v3d) if (changed) { } } + +static EnumPropertyItem *object_mode_set_itemsf(bContext *C, PointerRNA *ptr, int *free) +{ + EnumPropertyItem *input = object_mode_items; + EnumPropertyItem *item= NULL; + Object *ob; + int totitem= 0; + + if(!C) /* needed for docs */ + return object_mode_items; + + ob = CTX_data_active_object(C); + while(ob && input->identifier) { + if((input->value == OB_MODE_EDIT && ((ob->type == OB_MESH) || (ob->type == OB_ARMATURE) || + (ob->type == OB_CURVE) || (ob->type == OB_SURF) || + (ob->type == OB_FONT) || (ob->type == OB_MBALL) || (ob->type == OB_LATTICE))) || + (input->value == OB_MODE_POSE && (ob->type == OB_ARMATURE)) || + (input->value == OB_MODE_PARTICLE_EDIT && ob->particlesystem.first) || + ((input->value == OB_MODE_SCULPT || input->value == OB_MODE_VERTEX_PAINT || + input->value == OB_MODE_WEIGHT_PAINT || input->value == OB_MODE_TEXTURE_PAINT) && (ob->type == OB_MESH)) || + (input->value == OB_MODE_OBJECT)) + RNA_enum_item_add(&item, &totitem, input); + ++input; + } + + RNA_enum_item_end(&item, &totitem); + + *free= 1; + + return item; +} + +static const char *object_mode_op_string(int mode) +{ + if(mode == OB_MODE_EDIT) + return "OBJECT_OT_editmode_toggle"; + if(mode == OB_MODE_SCULPT) + return "SCULPT_OT_sculptmode_toggle"; + if(mode == OB_MODE_VERTEX_PAINT) + return "PAINT_OT_vertex_paint_toggle"; + if(mode == OB_MODE_WEIGHT_PAINT) + return "PAINT_OT_weight_paint_toggle"; + if(mode == OB_MODE_TEXTURE_PAINT) + return "PAINT_OT_texture_paint_toggle"; + if(mode == OB_MODE_PARTICLE_EDIT) + return "PARTICLE_OT_particle_edit_toggle"; + if(mode == OB_MODE_POSE) + return "OBJECT_OT_posemode_toggle"; + return NULL; +} + +static int object_mode_set_exec(bContext *C, wmOperator *op) +{ + Object *ob= CTX_data_active_object(C); + ObjectMode mode = RNA_enum_get(op->ptr, "mode"); + ObjectMode restore_mode = ob->mode; + int toggle = RNA_boolean_get(op->ptr, "toggle"); + + if(!ob) + return OPERATOR_CANCELLED; + + /* Exit current mode if it's not the mode we're setting */ + if(ob->mode != OB_MODE_OBJECT && ob->mode != mode) + WM_operator_name_call(C, object_mode_op_string(ob->mode), WM_OP_EXEC_REGION_WIN, NULL); + + if(mode != OB_MODE_OBJECT) { + /* Enter new mode */ + if(ob->mode != mode || toggle) + WM_operator_name_call(C, object_mode_op_string(mode), WM_OP_EXEC_REGION_WIN, NULL); + + if(toggle) { + if(ob->mode == mode) + /* For toggling, store old mode so we know what to go back to */ + ob->restore_mode = restore_mode; + else if(ob->restore_mode != OB_MODE_OBJECT && ob->restore_mode != mode) { + WM_operator_name_call(C, object_mode_op_string(ob->restore_mode), WM_OP_EXEC_REGION_WIN, NULL); + } + } + } + + return OPERATOR_FINISHED; +} + +void OBJECT_OT_mode_set(wmOperatorType *ot) +{ + PropertyRNA *prop; + + /* identifiers */ + ot->name= "Set Object Mode"; + ot->description = "Sets the object interaction mode."; + ot->idname= "OBJECT_OT_mode_set"; + + /* api callbacks */ + ot->exec= object_mode_set_exec; + + ot->poll= ED_operator_object_active; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + prop= RNA_def_enum(ot->srna, "mode", object_mode_items, 0, "Mode", ""); + RNA_def_enum_funcs(prop, object_mode_set_itemsf); + + RNA_def_boolean(ot->srna, "toggle", 0, "Toggle", ""); +} + + + +void ED_object_toggle_modes(bContext *C, int mode) +{ + if(mode & OB_MODE_SCULPT) + WM_operator_name_call(C, "SCULPT_OT_sculptmode_toggle", WM_OP_EXEC_REGION_WIN, NULL); + if(mode & OB_MODE_VERTEX_PAINT) + WM_operator_name_call(C, "PAINT_OT_vertex_paint_toggle", WM_OP_EXEC_REGION_WIN, NULL); + if(mode & OB_MODE_WEIGHT_PAINT) + WM_operator_name_call(C, "PAINT_OT_weight_paint_toggle", WM_OP_EXEC_REGION_WIN, NULL); + if(mode & OB_MODE_TEXTURE_PAINT) + WM_operator_name_call(C, "PAINT_OT_texture_paint_toggle", WM_OP_EXEC_REGION_WIN, NULL); + if(mode & OB_MODE_PARTICLE_EDIT) + WM_operator_name_call(C, "PARTICLE_OT_particle_edit_toggle", WM_OP_EXEC_REGION_WIN, NULL); +} diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h index 17d4f5deaae..2f164102be2 100644 --- a/source/blender/editors/object/object_intern.h +++ b/source/blender/editors/object/object_intern.h @@ -34,11 +34,13 @@ struct Lattice; struct Curve; struct Object; struct Mesh; +struct HookModifierData; /* internal exports only */ /* object_edit.c */ +void OBJECT_OT_mode_set(struct wmOperatorType *ot); void OBJECT_OT_editmode_toggle(struct wmOperatorType *ot); void OBJECT_OT_posemode_toggle(struct wmOperatorType *ot); void OBJECT_OT_parent_set(struct wmOperatorType *ot); @@ -79,6 +81,9 @@ void OBJECT_OT_armature_add(struct wmOperatorType *ot); /* only used as menu */ void OBJECT_OT_primitive_add(struct wmOperatorType *ot); +int object_hook_index_array(Object *obedit, int *tot, int **indexar, char *name, float *cent_r); +void object_hook_select(Object *obedit, struct HookModifierData *hmd); + /* editlattice.c */ void free_editLatt(Object *ob); void make_editLatt(Object *obedit); @@ -103,7 +108,12 @@ void OBJECT_OT_modifier_apply(struct wmOperatorType *ot); void OBJECT_OT_modifier_convert(struct wmOperatorType *ot); void OBJECT_OT_modifier_copy(struct wmOperatorType *ot); void OBJECT_OT_multires_subdivide(struct wmOperatorType *ot); -void OBJECT_OT_modifier_mdef_bind(struct wmOperatorType *ot); +void OBJECT_OT_meshdeform_bind(struct wmOperatorType *ot); +void OBJECT_OT_hook_reset(struct wmOperatorType *ot); +void OBJECT_OT_hook_recenter(struct wmOperatorType *ot); +void OBJECT_OT_hook_select(struct wmOperatorType *ot); +void OBJECT_OT_hook_assign(struct wmOperatorType *ot); +void OBJECT_OT_explode_refresh(struct wmOperatorType *ot); /* editconstraint.c */ void OBJECT_OT_constraint_add(struct wmOperatorType *ot); diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index 6b9f2db0d96..0b8fedd2eda 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -31,6 +31,7 @@ #include "MEM_guardedalloc.h" +#include "DNA_action_types.h" #include "DNA_curve_types.h" #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" @@ -39,8 +40,10 @@ #include "DNA_object_force.h" #include "DNA_scene_types.h" +#include "BLI_arithb.h" #include "BLI_listbase.h" +#include "BKE_action.h" #include "BKE_curve.h" #include "BKE_context.h" #include "BKE_depsgraph.h" @@ -226,7 +229,7 @@ int ED_object_modifier_convert(ReportList *reports, Scene *scene, Object *ob, Mo int totpart=0, totchild=0; if(md->type != eModifierType_ParticleSystem) return 0; - if(G.f & G_PARTICLEEDIT) return 0; + if(ob && ob->mode & OB_MODE_PARTICLE_EDIT) return 0; psys=((ParticleSystemModifierData *)md)->psys; part= psys->part; @@ -403,6 +406,11 @@ int ED_object_modifier_copy(ReportList *reports, Object *ob, ModifierData *md) /***************************** OPERATORS ****************************/ +static int modifier_poll(bContext *C) +{ + return (CTX_data_pointer_get_type(C, "modifier", &RNA_Modifier).data != NULL); +} + /************************ add modifier operator *********************/ static int modifier_add_exec(bContext *C, wmOperator *op) @@ -419,8 +427,46 @@ static int modifier_add_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } +static EnumPropertyItem *modifier_add_itemf(bContext *C, PointerRNA *ptr, int *free) +{ + EnumPropertyItem *item= NULL, *md_item; + ModifierTypeInfo *mti; + Object *ob; + int totitem= 0, a; + + if(!C) /* needed for docs */ + return modifier_type_items; + + ob= CTX_data_active_object(C); + + for(a=0; modifier_type_items[a].identifier; a++) { + md_item= &modifier_type_items[a]; + + if(md_item->identifier[0]) { + mti= modifierType_getInfo(md_item->value); + + if(mti->flags & eModifierTypeFlag_NoUserAdd) + continue; + + if(!((mti->flags & eModifierTypeFlag_AcceptsCVs) || + (ob->type==OB_MESH && (mti->flags & eModifierTypeFlag_AcceptsMesh)))) + continue; + } + + RNA_enum_item_add(&item, &totitem, md_item); + } + + RNA_enum_item_end(&item, &totitem); + + *free= 1; + + return item; +} + void OBJECT_OT_modifier_add(wmOperatorType *ot) { + PropertyRNA *prop; + /* identifiers */ ot->name= "Add Modifier"; ot->description = "Add a modifier to the active object."; @@ -429,14 +475,14 @@ void OBJECT_OT_modifier_add(wmOperatorType *ot) /* api callbacks */ ot->invoke= WM_menu_invoke; ot->exec= modifier_add_exec; - ot->poll= ED_operator_object_active; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - /* XXX only some types should be here */ - RNA_def_enum(ot->srna, "type", modifier_type_items, 0, "Type", ""); + /* properties */ + prop= RNA_def_enum(ot->srna, "type", modifier_type_items, eModifierType_Subsurf, "Type", ""); + RNA_def_enum_funcs(prop, modifier_add_itemf); } /************************ remove modifier operator *********************/ @@ -448,7 +494,7 @@ static int modifier_remove_exec(bContext *C, wmOperator *op) Object *ob= ptr.id.data; ModifierData *md= ptr.data; - if(!ob || !md || !ED_object_modifier_remove(op->reports, scene, ob, md)) + if(!ED_object_modifier_remove(op->reports, scene, ob, md)) return OPERATOR_CANCELLED; WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); @@ -464,6 +510,7 @@ void OBJECT_OT_modifier_remove(wmOperatorType *ot) ot->poll= ED_operator_object_active; ot->exec= modifier_remove_exec; + ot->poll= modifier_poll; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -478,7 +525,7 @@ static int modifier_move_up_exec(bContext *C, wmOperator *op) Object *ob= ptr.id.data; ModifierData *md= ptr.data; - if(!ob || !md || !ED_object_modifier_move_up(op->reports, ob, md)) + if(!ED_object_modifier_move_up(op->reports, ob, md)) return OPERATOR_CANCELLED; DAG_object_flush_update(scene, ob, OB_RECALC_DATA); @@ -495,6 +542,7 @@ void OBJECT_OT_modifier_move_up(wmOperatorType *ot) ot->poll= ED_operator_object_active; ot->exec= modifier_move_up_exec; + ot->poll= modifier_poll; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -526,6 +574,7 @@ void OBJECT_OT_modifier_move_down(wmOperatorType *ot) ot->poll= ED_operator_object_active; ot->exec= modifier_move_down_exec; + ot->poll= modifier_poll; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -557,6 +606,7 @@ void OBJECT_OT_modifier_apply(wmOperatorType *ot) ot->poll= ED_operator_object_active; ot->exec= modifier_apply_exec; + ot->poll= modifier_poll; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -588,6 +638,7 @@ void OBJECT_OT_modifier_convert(wmOperatorType *ot) ot->poll= ED_operator_object_active; ot->exec= modifier_convert_exec; + ot->poll= modifier_poll; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -619,6 +670,7 @@ void OBJECT_OT_modifier_copy(wmOperatorType *ot) ot->poll= ED_operator_object_active; ot->exec= modifier_copy_exec; + ot->poll= modifier_poll; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -632,22 +684,26 @@ static int multires_subdivide_exec(bContext *C, wmOperator *op) Object *ob= ptr.id.data; MultiresModifierData *mmd= ptr.data; - if(mmd) { - multiresModifier_subdivide(mmd, ob, 1, 0, mmd->simple); - WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); - } + multiresModifier_subdivide(mmd, ob, 1, 0, mmd->simple); + WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); return OPERATOR_FINISHED; } +static int multires_subdivide_poll(bContext *C) +{ + return (CTX_data_pointer_get_type(C, "modifier", &RNA_MultiresModifier).data != NULL) && + CTX_data_edit_object(C) == NULL; +} + void OBJECT_OT_multires_subdivide(wmOperatorType *ot) { ot->name= "Multires Subdivide"; ot->description= "Add a new level of subdivision."; ot->idname= "OBJECT_OT_multires_subdivide"; - ot->poll= ED_operator_object_active; ot->exec= multires_subdivide_exec; + ot->poll= multires_subdivide_poll; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -655,12 +711,12 @@ void OBJECT_OT_multires_subdivide(wmOperatorType *ot) /************************ mdef bind operator *********************/ -static int modifier_mdef_bind_poll(bContext *C) +static int meshdeform_poll(bContext *C) { return CTX_data_pointer_get_type(C, "modifier", &RNA_MeshDeformModifier).data != NULL; } -static int modifier_mdef_bind_exec(bContext *C, wmOperator *op) +static int meshdeform_bind_exec(bContext *C, wmOperator *op) { Scene *scene= CTX_data_scene(C); PointerRNA ptr= CTX_data_pointer_get(C, "modifier"); @@ -711,41 +767,22 @@ static int modifier_mdef_bind_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -void OBJECT_OT_modifier_mdef_bind(wmOperatorType *ot) +void OBJECT_OT_meshdeform_bind(wmOperatorType *ot) { /* identifiers */ ot->name= "Mesh Deform Bind"; ot->description = "Bind mesh to cage in mesh deform modifier."; - ot->idname= "OBJECT_OT_modifier_mdef_bind"; + ot->idname= "OBJECT_OT_meshdeform_bind"; /* api callbacks */ - ot->poll= modifier_mdef_bind_poll; - ot->exec= modifier_mdef_bind_exec; + ot->poll= meshdeform_poll; + ot->exec= meshdeform_bind_exec; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } #if 0 -static void modifiers_add(void *ob_v, int type) -{ - Object *ob = ob_v; - ModifierTypeInfo *mti = modifierType_getInfo(type); - - if (mti->flags&eModifierTypeFlag_RequiresOriginalData) { - ModifierData *md = ob->modifiers.first; - - while (md && modifierType_getInfo(md->type)->type==eModifierTypeType_OnlyDeform) { - md = md->next; - } - - BLI_insertlinkbefore(&ob->modifiers, md, modifier_new(type)); - } else { - BLI_addtail(&ob->modifiers, modifier_new(type)); - } - ED_undo_push("Add modifier"); -} - typedef struct MenuEntry { char *name; int ID; @@ -797,89 +834,189 @@ static uiBlock *modifiers_add_menu(void *ob_v) } #endif -#if 0 -static void modifiers_clearHookOffset(bContext *C, void *ob_v, void *md_v) +/******************** hook operators ************************/ + +static int hook_poll(bContext *C) { - Object *ob = ob_v; - ModifierData *md = md_v; - HookModifierData *hmd = (HookModifierData*) md; - - if (hmd->object) { - Mat4Invert(hmd->object->imat, hmd->object->obmat); - Mat4MulSerie(hmd->parentinv, hmd->object->imat, ob->obmat, NULL, NULL, NULL, NULL, NULL, NULL); - ED_undo_push(C, "Clear hook offset"); + return CTX_data_pointer_get_type(C, "modifier", &RNA_HookModifier).data != NULL; +} + +static int hook_reset_exec(bContext *C, wmOperator *op) +{ + Scene *scene= CTX_data_scene(C); + PointerRNA ptr= CTX_data_pointer_get_type(C, "modifier", &RNA_HookModifier); + Object *ob= ptr.id.data; + HookModifierData *hmd= ptr.data; + + if(hmd->object) { + bPoseChannel *pchan= get_pose_channel(hmd->object->pose, hmd->subtarget); + + if(hmd->subtarget[0] && pchan) { + float imat[4][4], mat[4][4]; + + /* calculate the world-space matrix for the pose-channel target first, then carry on as usual */ + Mat4MulMat4(mat, pchan->pose_mat, hmd->object->obmat); + + Mat4Invert(imat, mat); + Mat4MulSerie(hmd->parentinv, imat, ob->obmat, NULL, NULL, NULL, NULL, NULL, NULL); + } + else { + Mat4Invert(hmd->object->imat, hmd->object->obmat); + Mat4MulSerie(hmd->parentinv, hmd->object->imat, ob->obmat, NULL, NULL, NULL, NULL, NULL, NULL); + } } + + DAG_object_flush_update(scene, ob, OB_RECALC_DATA); + WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); + + return OPERATOR_FINISHED; } -static void modifiers_cursorHookCenter(bContext *C, void *ob_v, void *md_v) +void OBJECT_OT_hook_reset(wmOperatorType *ot) { - /* XXX - Object *ob = ob_v; - ModifierData *md = md_v; - HookModifierData *hmd = (HookModifierData*) md; + ot->name= "Hook Reset"; + ot->description= "Recalculate and and clear offset transformation."; + ot->idname= "OBJECT_OT_hook_reset"; - if(G.vd) { - float *curs = give_cursor(); - float bmat[3][3], imat[3][3]; + ot->exec= hook_reset_exec; + ot->poll= hook_poll; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} - where_is_object(ob); +static int hook_recenter_exec(bContext *C, wmOperator *op) +{ + Scene *scene= CTX_data_scene(C); + PointerRNA ptr= CTX_data_pointer_get_type(C, "modifier", &RNA_HookModifier); + Object *ob= ptr.id.data; + HookModifierData *hmd= ptr.data; + float bmat[3][3], imat[3][3]; + + Mat3CpyMat4(bmat, ob->obmat); + Mat3Inv(imat, bmat); + + VECSUB(hmd->cent, scene->cursor, ob->obmat[3]); + Mat3MulVecfl(imat, hmd->cent); + + DAG_object_flush_update(scene, ob, OB_RECALC_DATA); + WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); - Mat3CpyMat4(bmat, ob->obmat); - Mat3Inv(imat, bmat); + return OPERATOR_FINISHED; +} - curs= give_cursor(); - hmd->cent[0]= curs[0]-ob->obmat[3][0]; - hmd->cent[1]= curs[1]-ob->obmat[3][1]; - hmd->cent[2]= curs[2]-ob->obmat[3][2]; - Mat3MulVecfl(imat, hmd->cent); +void OBJECT_OT_hook_recenter(wmOperatorType *ot) +{ + ot->name= "Hook Recenter"; + ot->description= "Set hook center to cursor position."; + ot->idname= "OBJECT_OT_hook_recenter"; - ED_undo_push(C, "Hook cursor center"); - }*/ + ot->exec= hook_recenter_exec; + ot->poll= hook_poll; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } -static void modifiers_selectHook(bContext *C, void *ob_v, void *md_v) +static int hook_select_exec(bContext *C, wmOperator *op) { - /* XXX ModifierData *md = md_v; - HookModifierData *hmd = (HookModifierData*) md; + PointerRNA ptr= CTX_data_pointer_get_type(C, "modifier", &RNA_HookModifier); + Object *ob= ptr.id.data; + HookModifierData *hmd= ptr.data; + + object_hook_select(ob, hmd); - hook_select(hmd);*/ + WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, ob); + + return OPERATOR_FINISHED; +} + +void OBJECT_OT_hook_select(wmOperatorType *ot) +{ + ot->name= "Hook Select"; + ot->description= "Selects effected vertices on mesh."; + ot->idname= "OBJECT_OT_hook_select"; + + ot->exec= hook_select_exec; + ot->poll= hook_poll; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } -static void modifiers_reassignHook(bContext *C, void *ob_v, void *md_v) +static int hook_assign_exec(bContext *C, wmOperator *op) { - /* XXX ModifierData *md = md_v; - HookModifierData *hmd = (HookModifierData*) md; + Scene *scene= CTX_data_scene(C); + PointerRNA ptr= CTX_data_pointer_get_type(C, "modifier", &RNA_HookModifier); + Object *ob= ptr.id.data; + HookModifierData *hmd= ptr.data; float cent[3]; - int *indexar, tot, ok; char name[32]; + int *indexar, tot; - ok= hook_getIndexArray(&tot, &indexar, name, cent); + if(!object_hook_index_array(ob, &tot, &indexar, name, cent)) { + BKE_report(op->reports, RPT_WARNING, "Requires selected vertices or active vertex group"); + return OPERATOR_CANCELLED; + } - if (!ok) { - uiPupMenuError(C, "Requires selected vertices or active Vertex Group"); - } else { - if (hmd->indexar) { - MEM_freeN(hmd->indexar); - } + if(hmd->indexar) + MEM_freeN(hmd->indexar); - VECCOPY(hmd->cent, cent); - hmd->indexar = indexar; - hmd->totindex = tot; - }*/ + VECCOPY(hmd->cent, cent); + hmd->indexar= indexar; + hmd->totindex= tot; + + DAG_object_flush_update(scene, ob, OB_RECALC_DATA); + WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); + + return OPERATOR_FINISHED; } -void modifiers_explodeFacepa(bContext *C, void *arg1, void *arg2) +void OBJECT_OT_hook_assign(wmOperatorType *ot) { - ExplodeModifierData *emd=arg1; + ot->name= "Hook Assign"; + ot->description= "Reassigns selected vertices to hook."; + ot->idname= "OBJECT_OT_hook_assign"; - emd->flag |= eExplodeFlag_CalcFaces; + ot->exec= hook_assign_exec; + ot->poll= hook_poll; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } -void modifiers_explodeDelVg(bContext *C, void *arg1, void *arg2) +/****************** explode refresh operator *********************/ + +static int explode_refresh_poll(bContext *C) { - ExplodeModifierData *emd=arg1; - emd->vgroup = 0; + return CTX_data_pointer_get_type(C, "modifier", &RNA_ExplodeModifier).data != NULL; } -#endif +static int explode_refresh_exec(bContext *C, wmOperator *op) +{ + Scene *scene= CTX_data_scene(C); + PointerRNA ptr= CTX_data_pointer_get_type(C, "modifier", &RNA_ExplodeModifier); + Object *ob= ptr.id.data; + ExplodeModifierData *emd= ptr.data; + + emd->flag |= eExplodeFlag_CalcFaces; + + DAG_object_flush_update(scene, ob, OB_RECALC_DATA); + WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); + + return OPERATOR_FINISHED; +} + +void OBJECT_OT_explode_refresh(wmOperatorType *ot) +{ + ot->name= "Explode Refresh"; + ot->description= "Refresh data in the Explode modifier."; + ot->idname= "OBJECT_OT_explode_refresh"; + + ot->exec= explode_refresh_exec; + ot->poll= explode_refresh_poll; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c index c1509e78502..239b162c14f 100644 --- a/source/blender/editors/object/object_ops.c +++ b/source/blender/editors/object/object_ops.c @@ -65,6 +65,7 @@ void ED_operatortypes_object(void) { wmOperatorType *ot; + WM_operatortype_append(OBJECT_OT_mode_set); WM_operatortype_append(OBJECT_OT_editmode_toggle); WM_operatortype_append(OBJECT_OT_posemode_toggle); WM_operatortype_append(OBJECT_OT_parent_set); @@ -117,7 +118,12 @@ void ED_operatortypes_object(void) WM_operatortype_append(OBJECT_OT_modifier_convert); WM_operatortype_append(OBJECT_OT_modifier_copy); WM_operatortype_append(OBJECT_OT_multires_subdivide); - WM_operatortype_append(OBJECT_OT_modifier_mdef_bind); + WM_operatortype_append(OBJECT_OT_meshdeform_bind); + WM_operatortype_append(OBJECT_OT_hook_reset); + WM_operatortype_append(OBJECT_OT_hook_recenter); + WM_operatortype_append(OBJECT_OT_hook_select); + WM_operatortype_append(OBJECT_OT_hook_assign); + WM_operatortype_append(OBJECT_OT_explode_refresh); WM_operatortype_append(OBJECT_OT_constraint_add); WM_operatortype_append(OBJECT_OT_constraint_add_with_targets); @@ -161,10 +167,19 @@ void ED_operatortypes_object(void) void ED_keymap_object(wmWindowManager *wm) { ListBase *keymap= WM_keymap_listbase(wm, "Object Non-modal", 0, 0); + wmKeymapItem *kmi; /* Note: this keymap works disregarding mode */ WM_keymap_add_item(keymap, "OBJECT_OT_editmode_toggle", TABKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "OBJECT_OT_posemode_toggle", TABKEY, KM_PRESS, KM_CTRL, 0); + + kmi = WM_keymap_add_item(keymap, "OBJECT_OT_mode_set", VKEY, KM_PRESS, 0, 0); + RNA_enum_set(kmi->ptr, "mode", OB_MODE_VERTEX_PAINT); + RNA_boolean_set(kmi->ptr, "toggle", 1); + kmi = WM_keymap_add_item(keymap, "OBJECT_OT_mode_set", TABKEY, KM_PRESS, KM_CTRL, 0); + RNA_enum_set(kmi->ptr, "mode", OB_MODE_WEIGHT_PAINT); + RNA_boolean_set(kmi->ptr, "toggle", 1); + WM_keymap_add_item(keymap, "OBJECT_OT_center_set", CKEY, KM_PRESS, KM_ALT|KM_SHIFT|KM_CTRL, 0); /* Note: this keymap gets disabled in non-objectmode, */ diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index 3d3e29bcc22..154ab14df60 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -57,6 +57,7 @@ #include "BKE_global.h" #include "BKE_lattice.h" #include "BKE_mesh.h" +#include "BKE_paint.h" #include "BKE_utildefines.h" #include "RNA_access.h" @@ -1028,11 +1029,11 @@ void vgroup_assign_with_menu(Scene *scene, Object *ob) switch (mode) { case 1: /* add to new group */ add_defgroup(ob); - assign_verts_defgroup(ob, wp->brush->alpha); + assign_verts_defgroup(ob, paint_brush(&wp->paint)->alpha); BIF_undo_push("Assign to vertex group"); break; case 2: /* add to current group */ - assign_verts_defgroup(ob, wp->brush->alpha); + assign_verts_defgroup(ob, paint_brush(&wp->paint)->alpha); BIF_undo_push("Assign to vertex group"); break; case 3: /* remove from current group */ diff --git a/source/blender/editors/physics/ed_pointcache.c b/source/blender/editors/physics/ed_pointcache.c index 5d0a6d21fac..917e2b40d72 100644 --- a/source/blender/editors/physics/ed_pointcache.c +++ b/source/blender/editors/physics/ed_pointcache.c @@ -61,7 +61,6 @@ static int cache_break_test(void *cbd) { return G.afbreek==1; } -/**************************** general **********************************/ static int ptcache_bake_all_poll(bContext *C) { Scene *scene= CTX_data_scene(C); @@ -130,7 +129,7 @@ void PTCACHE_OT_bake_all(wmOperatorType *ot) /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - RNA_def_boolean(ot->srna, "bake", 0, "Bake", ""); + RNA_def_boolean(ot->srna, "bake", 1, "Bake", ""); } void PTCACHE_OT_free_bake_all(wmOperatorType *ot) { @@ -145,32 +144,25 @@ void PTCACHE_OT_free_bake_all(wmOperatorType *ot) /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } - -/**************************** softbody **********************************/ -static int ptcache_bake_softbody_poll(bContext *C) -{ - Scene *scene= CTX_data_scene(C); - Object *ob= CTX_data_active_object(C); - SoftBody *sb = ob->soft; - - if(!scene || !ob || ob->id.lib || !sb) - return 0; - - return 1; -} - -static int ptcache_bake_softbody_exec(bContext *C, wmOperator *op) +static int ptcache_bake_exec(bContext *C, wmOperator *op) { - Scene *scene= CTX_data_scene(C); - Object *ob= CTX_data_active_object(C); - SoftBody *sb = ob->soft; - PTCacheID pid; + Scene *scene = CTX_data_scene(C); + PointerRNA ptr= CTX_data_pointer_get_type(C, "PointCache", &RNA_PointCache); + Object *ob= ptr.id.data; + PointCache *cache= ptr.data; PTCacheBaker baker; + PTCacheID *pid; + ListBase pidlist; - BKE_ptcache_id_from_softbody(&pid, ob, sb); + BKE_ptcache_ids_from_object(&pidlist, ob); + + for(pid=pidlist.first; pid; pid=pid->next) { + if(pid->cache == cache) + break; + } baker.scene = scene; - baker.pid = &pid; + baker.pid = pid; baker.bake = RNA_boolean_get(op->ptr, "bake"); baker.render = 0; baker.anim_init = 0; @@ -182,305 +174,160 @@ static int ptcache_bake_softbody_exec(bContext *C, wmOperator *op) BKE_ptcache_make_cache(&baker); - WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene); - - return OPERATOR_FINISHED; -} -static int ptcache_free_bake_softbody_exec(bContext *C, wmOperator *op) -{ - Scene *scene= CTX_data_scene(C); - Object *ob= CTX_data_active_object(C); - SoftBody *sb = ob->soft; - PTCacheID pid; - - BKE_ptcache_id_from_softbody(&pid, ob, sb); - pid.cache->flag &= ~PTCACHE_BAKED; + BLI_freelistN(&pidlist); WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene); return OPERATOR_FINISHED; } -void PTCACHE_OT_cache_softbody(wmOperatorType *ot) +static int ptcache_free_bake_exec(bContext *C, wmOperator *op) { - /* identifiers */ - ot->name= "Bake Softbody"; - ot->idname= "PTCACHE_OT_cache_softbody"; + PointerRNA ptr= CTX_data_pointer_get_type(C, "PointCache", &RNA_PointCache); + PointCache *cache= ptr.data; - /* api callbacks */ - ot->exec= ptcache_bake_softbody_exec; - ot->poll= ptcache_bake_softbody_poll; - - /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - - RNA_def_boolean(ot->srna, "bake", 0, "Bake", ""); -} -void PTCACHE_OT_free_bake_softbody(wmOperatorType *ot) -{ - /* identifiers */ - ot->name= "Free SoftBody Bake"; - ot->idname= "PTCACHE_OT_free_bake_softbody"; - - /* api callbacks */ - ot->exec= ptcache_free_bake_softbody_exec; - ot->poll= ptcache_bake_softbody_poll; - - /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; -} -static int ptcache_bake_from_softbody_cache_exec(bContext *C, wmOperator *op) -{ - Object *ob= CTX_data_active_object(C); - SoftBody *sb = ob->soft; - PTCacheID pid; - - BKE_ptcache_id_from_softbody(&pid, ob, sb); - pid.cache->flag |= PTCACHE_BAKED; + cache->flag &= ~PTCACHE_BAKED; return OPERATOR_FINISHED; } -void PTCACHE_OT_bake_from_softbody_cache(wmOperatorType *ot) +static int ptcache_bake_from_cache_exec(bContext *C, wmOperator *op) { - /* identifiers */ - ot->name= "Bake From Cache"; - ot->idname= "PTCACHE_OT_bake_from_softbody_cache"; - - /* api callbacks */ - ot->exec= ptcache_bake_from_softbody_cache_exec; - ot->poll= ptcache_bake_softbody_poll; - - /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; -} - -/**************************** cloth **********************************/ -static int ptcache_bake_cloth_poll(bContext *C) -{ - Scene *scene= CTX_data_scene(C); - Object *ob= CTX_data_active_object(C); - ClothModifierData *clmd = (ClothModifierData *)modifiers_findByType(ob, eModifierType_Cloth); - - if(!scene || !ob || ob->id.lib || !clmd) - return 0; + PointerRNA ptr= CTX_data_pointer_get_type(C, "PointCache", &RNA_PointCache); + PointCache *cache= ptr.data; - return 1; -} - -static int ptcache_bake_cloth_exec(bContext *C, wmOperator *op) -{ - Scene *scene= CTX_data_scene(C); - Object *ob= CTX_data_active_object(C); - ClothModifierData *clmd = (ClothModifierData *)modifiers_findByType(ob, eModifierType_Cloth); - PTCacheID pid; - PTCacheBaker baker; - - BKE_ptcache_id_from_cloth(&pid, ob, clmd); - - baker.scene = scene; - baker.pid = &pid; - baker.bake = RNA_boolean_get(op->ptr, "bake"); - baker.render = 0; - baker.anim_init = 0; - baker.quick_step = 1; - baker.break_test = cache_break_test; - baker.break_data = NULL; - baker.progressbar = (void (*)(void *, int))WM_timecursor; - baker.progresscontext = CTX_wm_window(C); - - BKE_ptcache_make_cache(&baker); - - WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene); + cache->flag |= PTCACHE_BAKED; return OPERATOR_FINISHED; } -static int ptcache_free_bake_cloth_exec(bContext *C, wmOperator *op) -{ - Scene *scene= CTX_data_scene(C); - Object *ob= CTX_data_active_object(C); - ClothModifierData *clmd = (ClothModifierData *)modifiers_findByType(ob, eModifierType_Cloth); - PTCacheID pid; - - BKE_ptcache_id_from_cloth(&pid, ob, clmd); - pid.cache->flag &= ~PTCACHE_BAKED; - - WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene); - - return OPERATOR_FINISHED; -} -void PTCACHE_OT_cache_cloth(wmOperatorType *ot) +void PTCACHE_OT_bake(wmOperatorType *ot) { /* identifiers */ - ot->name= "Bake Cloth"; - ot->idname= "PTCACHE_OT_cache_cloth"; + ot->name= "Bake Physics"; + ot->idname= "PTCACHE_OT_bake"; /* api callbacks */ - ot->exec= ptcache_bake_cloth_exec; - ot->poll= ptcache_bake_cloth_poll; + ot->exec= ptcache_bake_exec; + ot->poll= ptcache_bake_all_poll; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - RNA_def_boolean(ot->srna, "bake", 0, "Bake", ""); + RNA_def_boolean(ot->srna, "bake", 1, "Bake", ""); } -void PTCACHE_OT_free_bake_cloth(wmOperatorType *ot) +void PTCACHE_OT_free_bake(wmOperatorType *ot) { /* identifiers */ - ot->name= "Free Cloth Bake"; - ot->idname= "PTCACHE_OT_free_bake_cloth"; + ot->name= "Free Physics Bake"; + ot->idname= "PTCACHE_OT_free_bake"; /* api callbacks */ - ot->exec= ptcache_free_bake_cloth_exec; - ot->poll= ptcache_bake_cloth_poll; + ot->exec= ptcache_free_bake_exec; + ot->poll= ptcache_bake_all_poll; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } -static int ptcache_bake_from_cloth_cache_exec(bContext *C, wmOperator *op) -{ - Object *ob= CTX_data_active_object(C); - ClothModifierData *clmd = (ClothModifierData *)modifiers_findByType(ob, eModifierType_Cloth); - PTCacheID pid; - - BKE_ptcache_id_from_cloth(&pid, ob, clmd); - pid.cache->flag |= PTCACHE_BAKED; - - return OPERATOR_FINISHED; -} -void PTCACHE_OT_bake_from_cloth_cache(wmOperatorType *ot) +void PTCACHE_OT_bake_from_cache(wmOperatorType *ot) { /* identifiers */ ot->name= "Bake From Cache"; - ot->idname= "PTCACHE_OT_bake_from_cloth_cache"; + ot->idname= "PTCACHE_OT_bake_from_cache"; /* api callbacks */ - ot->exec= ptcache_bake_from_cloth_cache_exec; - ot->poll= ptcache_bake_cloth_poll; + ot->exec= ptcache_bake_from_cache_exec; + ot->poll= ptcache_bake_all_poll; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } -/**************************** particles **********************************/ -static int ptcache_bake_particle_system_poll(bContext *C) +static int ptcache_add_new_exec(bContext *C, wmOperator *op) { - Scene *scene= CTX_data_scene(C); - Object *ob= CTX_data_active_object(C); + Scene *scene = CTX_data_scene(C); + PointerRNA ptr= CTX_data_pointer_get_type(C, "PointCache", &RNA_PointCache); + Object *ob= ptr.id.data; + PointCache *cache= ptr.data; + PTCacheID *pid; + ListBase pidlist; - if(!scene || !ob || ob->id.lib) - return 0; + BKE_ptcache_ids_from_object(&pidlist, ob); - return (ob->particlesystem.first != NULL); -} - -static int ptcache_bake_particle_system_exec(bContext *C, wmOperator *op) -{ - Scene *scene= CTX_data_scene(C); - Object *ob= CTX_data_active_object(C); - ParticleSystem *psys =psys_get_current(ob); - PTCacheID pid; - PTCacheBaker baker; - - BKE_ptcache_id_from_particles(&pid, ob, psys); - - baker.scene = scene; - baker.pid = &pid; - baker.bake = RNA_boolean_get(op->ptr, "bake"); - baker.render = 0; - baker.anim_init = 0; - baker.quick_step = 1; - baker.break_test = cache_break_test; - baker.break_data = NULL; - baker.progressbar = (void (*)(void *, int))WM_timecursor; - baker.progresscontext = CTX_wm_window(C); + for(pid=pidlist.first; pid; pid=pid->next) { + if(pid->cache == cache) { + *(pid->cache_ptr) = BKE_ptcache_add(pid->ptcaches); + break; + } + } - BKE_ptcache_make_cache(&baker); + BLI_freelistN(&pidlist); WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene); return OPERATOR_FINISHED; } -static int ptcache_free_bake_particle_system_exec(bContext *C, wmOperator *op) +static int ptcache_remove_exec(bContext *C, wmOperator *op) { - Scene *scene= CTX_data_scene(C); - Object *ob= CTX_data_active_object(C); - ParticleSystem *psys= psys_get_current(ob); - PTCacheID pid; + PointerRNA ptr= CTX_data_pointer_get_type(C, "PointCache", &RNA_PointCache); + Object *ob= ptr.id.data; + PointCache *cache= ptr.data; + PTCacheID *pid; + ListBase pidlist; - BKE_ptcache_id_from_particles(&pid, ob, psys); - psys->pointcache->flag &= ~PTCACHE_BAKED; + BKE_ptcache_ids_from_object(&pidlist, ob); + + for(pid=pidlist.first; pid; pid=pid->next) { + if(pid->cache == cache) { + if(pid->ptcaches->first == pid->ptcaches->last) + continue; /* don't delete last cache */ - WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene); + BLI_remlink(pid->ptcaches, pid->cache); + BKE_ptcache_free(pid->cache); + *(pid->cache_ptr) = pid->ptcaches->first; - return OPERATOR_FINISHED; -} -void PTCACHE_OT_cache_particle_system(wmOperatorType *ot) -{ - /* identifiers */ - ot->name= "Bake Particles"; - ot->idname= "PTCACHE_OT_cache_particle_system"; - - /* api callbacks */ - ot->exec= ptcache_bake_particle_system_exec; - ot->poll= ptcache_bake_particle_system_poll; + break; + } + } - /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + BLI_freelistN(&pidlist); - RNA_def_boolean(ot->srna, "bake", 0, "Bake", ""); + return OPERATOR_FINISHED; } -void PTCACHE_OT_free_bake_particle_system(wmOperatorType *ot) +void PTCACHE_OT_add_new(wmOperatorType *ot) { /* identifiers */ - ot->name= "Free Particles Bake"; - ot->idname= "PTCACHE_OT_free_bake_particle_system"; + ot->name= "Add new cache"; + ot->idname= "PTCACHE_OT_add_new"; /* api callbacks */ - ot->exec= ptcache_free_bake_particle_system_exec; - ot->poll= ptcache_bake_particle_system_poll; + ot->exec= ptcache_add_new_exec; + ot->poll= ptcache_bake_all_poll; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } -static int ptcache_bake_from_particles_cache_exec(bContext *C, wmOperator *op) -{ - Object *ob= CTX_data_active_object(C); - ParticleSystem *psys= psys_get_current(ob); - PTCacheID pid; - - BKE_ptcache_id_from_particles(&pid, ob, psys); - psys->pointcache->flag |= PTCACHE_BAKED; - - return OPERATOR_FINISHED; -} -void PTCACHE_OT_bake_from_particles_cache(wmOperatorType *ot) +void PTCACHE_OT_remove(wmOperatorType *ot) { /* identifiers */ - ot->name= "Bake From Cache"; - ot->idname= "PTCACHE_OT_bake_from_particles_cache"; + ot->name= "Delete current cache"; + ot->idname= "PTCACHE_OT_remove"; /* api callbacks */ - ot->exec= ptcache_bake_from_particles_cache_exec; - ot->poll= ptcache_bake_particle_system_poll; + ot->exec= ptcache_remove_exec; + ot->poll= ptcache_bake_all_poll; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } - /**************************** registration **********************************/ void ED_operatortypes_pointcache(void) { WM_operatortype_append(PTCACHE_OT_bake_all); WM_operatortype_append(PTCACHE_OT_free_bake_all); - WM_operatortype_append(PTCACHE_OT_cache_particle_system); - WM_operatortype_append(PTCACHE_OT_free_bake_particle_system); - WM_operatortype_append(PTCACHE_OT_bake_from_particles_cache); - WM_operatortype_append(PTCACHE_OT_cache_cloth); - WM_operatortype_append(PTCACHE_OT_free_bake_cloth); - WM_operatortype_append(PTCACHE_OT_bake_from_cloth_cache); - WM_operatortype_append(PTCACHE_OT_cache_softbody); - WM_operatortype_append(PTCACHE_OT_free_bake_softbody); - WM_operatortype_append(PTCACHE_OT_bake_from_softbody_cache); + WM_operatortype_append(PTCACHE_OT_bake); + WM_operatortype_append(PTCACHE_OT_free_bake); + WM_operatortype_append(PTCACHE_OT_bake_from_cache); + WM_operatortype_append(PTCACHE_OT_add_new); + WM_operatortype_append(PTCACHE_OT_remove); } //void ED_keymap_pointcache(wmWindowManager *wm) diff --git a/source/blender/editors/physics/editparticle.c b/source/blender/editors/physics/editparticle.c index 499162ecdb8..faf03d1f0e2 100644 --- a/source/blender/editors/physics/editparticle.c +++ b/source/blender/editors/physics/editparticle.c @@ -104,21 +104,13 @@ static int PE_poll(bContext *C) psys= PE_get_current(scene, ob); - return (psys && psys->edit && (G.f & G_PARTICLEEDIT)); + return (psys && psys->edit && (ob && ob->mode & OB_MODE_PARTICLE_EDIT)); } static int PE_poll_3dview(bContext *C) { - Scene *scene= CTX_data_scene(C); - Object *ob= CTX_data_active_object(C); - ParticleSystem *psys; - - if(!scene || !ob || !CTX_wm_region_view3d(C)) - return 0; - - psys= PE_get_current(scene, ob); - - return (psys && psys->edit && (G.f & G_PARTICLEEDIT)); + return PE_poll(C) && CTX_wm_area(C)->spacetype == SPACE_VIEW3D && + CTX_wm_region(C)->regiontype == RGN_TYPE_WINDOW; } static void PE_free_particle_edit(ParticleSystem *psys) @@ -164,7 +156,7 @@ static void PE_free_particle_edit(ParticleSystem *psys) int PE_can_edit(ParticleSystem *psys) { - return (psys && psys->edit && (G.f & G_PARTICLEEDIT)); + return (psys && psys->edit); } ParticleEditSettings *PE_settings(Scene *scene) @@ -194,7 +186,7 @@ ParticleSystem *PE_get_current(Scene *scene, Object *ob) /* this happens when Blender is started with particle * edit mode enabled XXX there's a draw error then? */ - if(psys && psys_check_enabled(ob, psys) && (ob == OBACT) && (G.f & G_PARTICLEEDIT)) + if(psys && psys_check_enabled(ob, psys) && (ob == OBACT) && (ob->mode & OB_MODE_PARTICLE_EDIT)) if(psys->part->type == PART_HAIR && psys->flag & PSYS_EDITED) if(psys->edit == NULL) PE_create_particle_edit(scene, ob, psys); @@ -2269,7 +2261,7 @@ static void toggle_particle_cursor(bContext *C, int enable) pset->paintcursor = NULL; } else if(enable) - pset->paintcursor= WM_paint_cursor_activate(CTX_wm_manager(C), PE_poll, brush_drawcursor, NULL); + pset->paintcursor= WM_paint_cursor_activate(CTX_wm_manager(C), PE_poll_3dview, brush_drawcursor, NULL); } /********************* radial control operator *********************/ @@ -3076,11 +3068,13 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) ParticleSystemModifierData *psmd= psys_get_modifier(ob, psys); ParticleBrushData *brush= &pset->brush[pset->brushtype]; ARegion *ar= CTX_wm_region(C); - float vec1[3], vec2[3]; + float vec1[3], vec2[3], mousef[2]; short mval[2], mvalo[2]; int flip, mouse[2], dx, dy, removed= 0, selected= 0; - RNA_int_get_array(itemptr, "mouse", mouse); + RNA_float_get_array(itemptr, "mouse", mousef); + mouse[0] = mousef[0]; + mouse[1] = mousef[1]; flip= RNA_boolean_get(itemptr, "flip"); if(bedit->first) { @@ -3291,7 +3285,7 @@ static void brush_edit_apply_event(bContext *C, wmOperator *op, wmEvent *event) { ARegion *ar= CTX_wm_region(C); PointerRNA itemptr; - int mouse[2]; + float mouse[2]; mouse[0]= event->x - ar->winrct.xmin; mouse[1]= event->y - ar->winrct.ymin; @@ -3299,7 +3293,7 @@ static void brush_edit_apply_event(bContext *C, wmOperator *op, wmEvent *event) /* fill in stroke */ RNA_collection_add(op->ptr, "stroke", &itemptr); - RNA_int_set_array(&itemptr, "mouse", mouse); + RNA_float_set_array(&itemptr, "mouse", mouse); RNA_boolean_set(&itemptr, "flip", event->shift != 0); // XXX hardcoded /* apply */ @@ -3710,7 +3704,7 @@ static int particle_edit_toggle_exec(bContext *C, wmOperator *op) psys->flag |= PSYS_CURRENT; } - if(!(G.f & G_PARTICLEEDIT)) { + if(!(ob->mode & OB_MODE_PARTICLE_EDIT)) { if(psys && psys->part->type == PART_HAIR && psys->flag & PSYS_EDITED) { if(psys_check_enabled(ob, psys)) { if(psys->edit==NULL) @@ -3720,12 +3714,12 @@ static int particle_edit_toggle_exec(bContext *C, wmOperator *op) } } - G.f |= G_PARTICLEEDIT; + ob->mode |= OB_MODE_PARTICLE_EDIT; toggle_particle_cursor(C, 1); WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_MODE_PARTICLE, NULL); } else { - G.f &= ~G_PARTICLEEDIT; + ob->mode &= ~OB_MODE_PARTICLE_EDIT; toggle_particle_cursor(C, 0); WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_MODE_OBJECT, NULL); } @@ -3773,7 +3767,7 @@ static int set_editable_exec(bContext *C, wmOperator *op) if(psys_check_enabled(ob, psys)) { psys->flag |= PSYS_EDITED; - if(G.f & G_PARTICLEEDIT) + if(ob->mode & OB_MODE_PARTICLE_EDIT) PE_create_particle_edit(scene, ob, psys); } else @@ -3814,7 +3808,7 @@ void PE_change_act(void *ob_v, void *act_v) psys->flag |= PSYS_CURRENT; if(psys_check_enabled(ob, psys)) { - if(G.f & G_PARTICLEEDIT && !psys->edit) + if(ob->mode & OB_MODE_PARTICLE_EDIT && !psys->edit) PE_create_particle_edit(scene, ob, psys); psys_update_world_cos(ob, psys); } @@ -3832,7 +3826,7 @@ void PE_change_act_psys(Scene *scene, Object *ob, ParticleSystem *psys) psys->flag |= PSYS_CURRENT; if(psys_check_enabled(ob, psys)) { - if(G.f & G_PARTICLEEDIT && !psys->edit) + if(ob->mode & OB_MODE_PARTICLE_EDIT && !psys->edit) PE_create_particle_edit(scene, ob, psys); psys_update_world_cos(ob, psys); diff --git a/source/blender/editors/physics/physics_boids.c b/source/blender/editors/physics/physics_boids.c index 2d3b11080e7..148359068ad 100644 --- a/source/blender/editors/physics/physics_boids.c +++ b/source/blender/editors/physics/physics_boids.c @@ -249,7 +249,6 @@ void BOID_OT_boidrule_move_down(wmOperatorType *ot) /************************ add/del boid state operators *********************/ static int boidstate_add_exec(bContext *C, wmOperator *op) { - Scene *scene = CTX_data_scene(C); PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem); ParticleSystem *psys= ptr.data; Object *ob= ptr.id.data; @@ -344,7 +343,6 @@ void BOID_OT_boidstate_del(wmOperatorType *ot) /************************ move up/down boid state operators *********************/ static int boidstate_move_up_exec(bContext *C, wmOperator *op) { - Scene *scene= CTX_data_scene(C); PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem); ParticleSystem *psys= ptr.data; Object *ob = ptr.id.data; @@ -385,7 +383,6 @@ static int boidstate_move_down_exec(bContext *C, wmOperator *op) Scene *scene= CTX_data_scene(C); PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem); ParticleSystem *psys= ptr.data; - Object *ob = ptr.id.data; BoidSettings *boids; BoidState *state; @@ -430,4 +427,4 @@ void ED_operatortypes_boids(void) WM_operatortype_append(BOID_OT_boidstate_del); WM_operatortype_append(BOID_OT_boidstate_move_up); WM_operatortype_append(BOID_OT_boidstate_move_down); -}
\ No newline at end of file +} diff --git a/source/blender/editors/preview/previewrender.c b/source/blender/editors/preview/previewrender.c index c5a741b11ed..d17391811bb 100644 --- a/source/blender/editors/preview/previewrender.c +++ b/source/blender/editors/preview/previewrender.c @@ -113,6 +113,7 @@ typedef struct ShaderPreview { Scene *scene; ID *id; ID *parent; + MTex *slot; int sizex, sizey; int *pr_rect; @@ -304,7 +305,11 @@ static Scene *preview_prepare_scene(Scene *scene, ID *id, int id_type, ShaderPre end_render_material(mat); /* turn on raytracing if needed */ - if(mat->mode_l & (MA_RAYTRANSP|MA_RAYMIRROR)) + if(mat->mode_l & MA_RAYMIRROR) + sce->r.mode |= R_RAYTRACE; + if(mat->material_type == MA_TYPE_VOLUME) + sce->r.mode |= R_RAYTRACE; + if((mat->mode_l & MA_RAYTRANSP) && (mat->mode_l & MA_TRANSP)) sce->r.mode |= R_RAYTRACE; if(mat->sss_flag & MA_DIFF_SSS) sce->r.mode |= R_SSS; @@ -362,6 +367,10 @@ static Scene *preview_prepare_scene(Scene *scene, ID *id, int id_type, ShaderPre Material *mat= give_current_material(base->object, base->object->actcol); if(mat && mat->mtex[0]) { mat->mtex[0]->tex= tex; + + if(sp && sp->slot) + mat->mtex[0]->which_output = sp->slot->which_output; + /* show alpha in this case */ if(tex==NULL || (tex->flag & TEX_PRV_ALPHA)) { mat->mtex[0]->mapto |= MAP_ALPHA; @@ -455,13 +464,14 @@ static int ed_preview_draw_rect(ScrArea *sa, Scene *sce, ID *id, int split, int return 0; } -void ED_preview_draw(const bContext *C, void *idp, void *parentp, rcti *rect) +void ED_preview_draw(const bContext *C, void *idp, void *parentp, void *slotp, rcti *rect) { if(idp) { ScrArea *sa= CTX_wm_area(C); Scene *sce = CTX_data_scene(C); ID *id = (ID *)idp; ID *parent= (ID *)parentp; + MTex *slot= (MTex *)slotp; SpaceButs *sbuts= sa->spacedata.first; rcti newrect; int ok; @@ -489,7 +499,7 @@ void ED_preview_draw(const bContext *C, void *idp, void *parentp, rcti *rect) } if(ok==0) { - ED_preview_shader_job(C, sa, id, parent, newx, newy); + ED_preview_shader_job(C, sa, id, parent, slot, newx, newy); } } } @@ -930,7 +940,7 @@ static void shader_preview_free(void *customdata) MEM_freeN(sp); } -void ED_preview_shader_job(const bContext *C, void *owner, ID *id, ID *parent, int sizex, int sizey) +void ED_preview_shader_job(const bContext *C, void *owner, ID *id, ID *parent, MTex *slot, int sizex, int sizey) { wmJob *steve; ShaderPreview *sp; @@ -938,7 +948,11 @@ void ED_preview_shader_job(const bContext *C, void *owner, ID *id, ID *parent, i /* XXX ugly global still, but we can't do preview while rendering */ if(G.rendering) return; - + + if(GS(id->name) == ID_TE) { + ntreeTexSetPreviewFlag(1); + } + steve= WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), owner); sp= MEM_callocN(sizeof(ShaderPreview), "shader preview"); @@ -950,6 +964,7 @@ void ED_preview_shader_job(const bContext *C, void *owner, ID *id, ID *parent, i sp->pr_method= PR_DO_RENDER; sp->id = id; sp->parent= parent; + sp->slot= slot; /* setup job */ WM_jobs_customdata(steve, sp, shader_preview_free); diff --git a/source/blender/editors/screen/CMakeLists.txt b/source/blender/editors/screen/CMakeLists.txt index 4ed1e59a87f..7429f45c00f 100644 --- a/source/blender/editors/screen/CMakeLists.txt +++ b/source/blender/editors/screen/CMakeLists.txt @@ -35,13 +35,11 @@ SET(INC ../../windowmanager ../../blenlib ../../makesdna ../../makesrna ../../blenkernel ../../include ../../imbuf ../../render/extern/include ../../../../intern/bsp/extern - ../../radiosity/extern/include ../../../intern/decimation/extern ../../blenloader - ../../../kernel/gen_system ../../../../intern/SoundSystem ../../readstreamglue - ../../quicktime ../../../../intern/elbeem/extern + ../../../kernel/gen_system ../../readstreamglue + ../../../../intern/elbeem/extern ../../../../intern/ghost ../../../../intern/opennl/extern ../../nodes - ${SDL_INC} ) IF(WITH_INTERNATIONAL) @@ -53,7 +51,7 @@ IF(WITH_OPENEXR) ENDIF(WITH_OPENEXR) IF(WITH_QUICKTIME) - SET(INC ${INC} ${QUICKTIME_INC}) + SET(INC ${INC} ../../quicktime ${QUICKTIME_INC}) ADD_DEFINITIONS(-DWITH_QUICKTIME) ENDIF(WITH_QUICKTIME) diff --git a/source/blender/editors/screen/Makefile b/source/blender/editors/screen/Makefile index ce6c59b69ed..c88e53f5f97 100644 --- a/source/blender/editors/screen/Makefile +++ b/source/blender/editors/screen/Makefile @@ -55,3 +55,8 @@ CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include # own include CPPFLAGS += -I../include + +ifeq ($(WITH_OPENEXR), true) + CPPFLAGS += -DWITH_OPENEXR +endif + diff --git a/source/blender/editors/screen/SConscript b/source/blender/editors/screen/SConscript index affc6192290..00a5f08b70d 100644 --- a/source/blender/editors/screen/SConscript +++ b/source/blender/editors/screen/SConscript @@ -12,5 +12,7 @@ defs = '' if not env['WITH_BF_PYTHON']: defs += 'DISABLE_PYTHON' +if env['WITH_BF_OPENEXR']: + defs += ' WITH_OPENEXR' env.BlenderLib ( 'bf_editors_screen', sources, Split(incs), Split(defs), libtype=['core'], priority=[105] ) diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 79ba11a5c55..f714a291bd7 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -249,7 +249,7 @@ void ED_area_overdraw(bContext *C) } /* get scissor rect, checking overlapping regions */ -static void region_scissor_winrct(ARegion *ar, rcti *winrct) +void region_scissor_winrct(ARegion *ar, rcti *winrct) { *winrct= ar->winrct; @@ -499,7 +499,7 @@ static void region_azone_initialize(ScrArea *sa, ARegion *ar, char edge) /* if more azones on 1 spot, set offset */ for(azt= sa->actionzones.first; azt; azt= azt->next) { if(az!=azt) { - if(az->x1==azt->x1 && az->y1==azt->y1) { + if( ABS(az->x1-azt->x1) < 2 && ABS(az->y1-azt->y1) < 2) { if(edge=='t' || edge=='b') { az->x1+= AZONESPOT; az->x2+= AZONESPOT; @@ -1041,39 +1041,38 @@ void ED_area_prevspace(bContext *C) static char *windowtype_pup(void) { return( - "Window type:%t" //14 - "|3D View %x1" //30 - - "|%l" // 33 - - "|Graph Editor %x2" //54 - "|DopeSheet %x12" //73 - "|NLA Editor %x13" //94 - - "|%l" //97 - - "|UV/Image Editor %x6" //117 + "Window type:%t" + "|3D View %x1" + + "|%l" - "|Video Sequence Editor %x8" //143 - "|Timeline %x15" //163 - // "|Audio Window %x11" //163 - "|Text Editor %x9" //179 + "|Timeline %x15" + "|Graph Editor %x2" + "|DopeSheet %x12" + "|NLA Editor %x13" - "|%l" //192 + "|%l" + "|UV/Image Editor %x6" - "|User Preferences %x7" //213 - "|Outliner %x3" //232 - "|Buttons Window %x4" //251 + "|Video Sequence Editor %x8" + "|Text Editor %x9" "|Node Editor %x16" "|Logic Editor %x17" - "|%l" //254 - "|File Browser %x5" //290 + "|%l" - "|%l" //293 + "|Properties %x4" + "|Outliner %x3" + "|User Preferences %x19" + "|Info%x7" + + "|%l" + + "|File Browser %x5" + + "|%l" - // "|Scripts Window %x14"//313 "|Console %x18" ); } @@ -1309,7 +1308,7 @@ void ED_region_header(const bContext *C, ARegion *ar) HeaderType *ht; Header header = {0}; float col[3]; - int xco, yco; + int maxco, xco, yco; /* clear */ if(ED_screen_area_active(C)) @@ -1323,7 +1322,7 @@ void ED_region_header(const bContext *C, ARegion *ar) /* set view2d view matrix for scrolling (without scrollers) */ UI_view2d_view_ortho(C, &ar->v2d); - xco= 8; + xco= maxco= 8; yco= HEADERY-3; /* draw all headers types */ @@ -1335,15 +1334,25 @@ void ED_region_header(const bContext *C, ARegion *ar) header.type= ht; header.layout= layout; ht->draw(C, &header); + + /* for view2d */ + xco= uiLayoutGetWidth(layout); + if(xco > maxco) + maxco= xco; } uiBlockLayoutResolve(C, block, &xco, &yco); + + /* for view2d */ + if(xco > maxco) + maxco= xco; + uiEndBlock(C, block); uiDrawBlock(C, block); } /* always as last */ - UI_view2d_totRect_set(&ar->v2d, xco+XIC+80, ar->v2d.tot.ymax-ar->v2d.tot.ymin); + UI_view2d_totRect_set(&ar->v2d, maxco+XIC+80, ar->v2d.tot.ymax-ar->v2d.tot.ymin); /* restore view matrix? */ UI_view2d_view_restore(C); diff --git a/source/blender/editors/screen/screen_context.c b/source/blender/editors/screen/screen_context.c index 3842dd3d62f..1e36a32b9e1 100644 --- a/source/blender/editors/screen/screen_context.c +++ b/source/blender/editors/screen/screen_context.c @@ -44,6 +44,10 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult bScreen *sc= CTX_wm_screen(C); Scene *scene= sc->scene; Base *base; + Object *ob = NULL; + + if(scene && scene->basact) + ob = scene->basact->object; if(CTX_data_dir(member)) { static const char *dir[] = { @@ -112,32 +116,32 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult return 1; } else if(CTX_data_equals(member, "sculpt_object")) { - if(G.f & G_SCULPTMODE && scene->basact) - CTX_data_id_pointer_set(result, &scene->basact->object->id); + if(ob && (ob->mode & OB_MODE_SCULPT)) + CTX_data_id_pointer_set(result, &ob->id); return 1; } else if(CTX_data_equals(member, "vertex_paint_object")) { - if(G.f & G_VERTEXPAINT && scene->basact) - CTX_data_id_pointer_set(result, &scene->basact->object->id); + if(ob && (ob->mode & OB_MODE_VERTEX_PAINT)) + CTX_data_id_pointer_set(result, &ob->id); return 1; } else if(CTX_data_equals(member, "weight_paint_object")) { - if(G.f & G_WEIGHTPAINT && scene->basact) - CTX_data_id_pointer_set(result, &scene->basact->object->id); + if(ob && (ob->mode & OB_MODE_WEIGHT_PAINT)) + CTX_data_id_pointer_set(result, &ob->id); return 1; } else if(CTX_data_equals(member, "texture_paint_object")) { - if(G.f & G_TEXTUREPAINT && scene->basact) - CTX_data_id_pointer_set(result, &scene->basact->object->id); + if(ob && (ob->mode & OB_MODE_TEXTURE_PAINT)) + CTX_data_id_pointer_set(result, &ob->id); return 1; } else if(CTX_data_equals(member, "particle_edit_object")) { - if(G.f & G_PARTICLEEDIT && scene->basact) - CTX_data_id_pointer_set(result, &scene->basact->object->id); + if(ob && (ob->mode & OB_MODE_PARTICLE_EDIT)) + CTX_data_id_pointer_set(result, &ob->id); return 1; } diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index 926768c98ab..aa36675fb90 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -923,12 +923,6 @@ bScreen *ED_screen_duplicate(wmWindow *win, bScreen *sc) newsc= ED_screen_add(win, sc->scene, sc->id.name+2); /* copy all data */ screen_copy(newsc, sc); - /* set in window */ - win->screen= newsc; - - /* store identifier */ - win->screen->winid= win->winid; - BLI_strncpy(win->screenname, win->screen->id.name+2, 21); return newsc; } @@ -1289,6 +1283,49 @@ void ED_screen_set(bContext *C, bScreen *sc) } } +static int ed_screen_used(wmWindowManager *wm, bScreen *sc) +{ + wmWindow *win; + + for(win=wm->windows.first; win; win=win->next) + if(win->screen == sc) + return 1; + + return 0; +} + +/* only call outside of area/region loops */ +void ED_screen_delete(bContext *C, bScreen *sc) +{ + Main *bmain= CTX_data_main(C); + wmWindowManager *wm= CTX_wm_manager(C); + wmWindow *win= CTX_wm_window(C); + bScreen *newsc; + int delete= 1; + + /* screen can only be in use by one window at a time, so as + long as we are able to find a screen that is unused, we + can safely assume ours is not in use anywhere an delete it */ + + for(newsc= sc->id.prev; newsc; newsc=newsc->id.prev) + if(!ed_screen_used(wm, newsc)) + break; + + if(!newsc) { + for(newsc= sc->id.next; newsc; newsc=newsc->id.next) + if(!ed_screen_used(wm, newsc)) + break; + } + + if(!newsc) + return; + + ED_screen_set(C, newsc); + + if(delete && win->screen != sc) + free_libblock(&bmain->screen, sc); +} + /* only call outside of area/region loops */ void ED_screen_set_scene(bContext *C, Scene *scene) { @@ -1346,6 +1383,24 @@ void ED_screen_set_scene(bContext *C, Scene *scene) } +/* only call outside of area/region loops */ +void ED_screen_delete_scene(bContext *C, Scene *scene) +{ + Main *bmain= CTX_data_main(C); + Scene *newscene; + + if(scene->id.prev) + newscene= scene->id.prev; + else if(scene->id.next) + newscene= scene->id.next; + else + return; + + ED_screen_set_scene(C, newscene); + + unlink_scene(bmain, scene, newscene); +} + /* this function toggles: if area is full then the parent will be restored */ void ed_screen_fullarea(bContext *C, ScrArea *sa) { @@ -1461,7 +1516,7 @@ void ED_screen_full_prevspace(bContext *C) /* redraws: uses defines from stime->redraws * enable: 1 - forward on, -1 - backwards on, 0 - off */ -void ED_screen_animation_timer(bContext *C, int redraws, int enable) +void ED_screen_animation_timer(bContext *C, int redraws, int sync, int enable) { bScreen *screen= CTX_wm_screen(C); wmWindow *win= CTX_wm_window(C); @@ -1472,12 +1527,13 @@ void ED_screen_animation_timer(bContext *C, int redraws, int enable) screen->animtimer= NULL; if(enable) { - struct ScreenAnimData *sad= MEM_mallocN(sizeof(ScreenAnimData), "ScreenAnimData"); + struct ScreenAnimData *sad= MEM_callocN(sizeof(ScreenAnimData), "ScreenAnimData"); screen->animtimer= WM_event_add_window_timer(win, TIMER0, (1.0/FPS)); sad->ar= CTX_wm_region(C); sad->redraws= redraws; - sad->flag= (enable < 0) ? ANIMPLAY_FLAG_REVERSE : 0; + sad->flag |= (enable < 0)? ANIMPLAY_FLAG_REVERSE: 0; + sad->flag |= (sync == 0)? ANIMPLAY_FLAG_NO_SYNC: (sync == 1)? ANIMPLAY_FLAG_SYNC: 0; screen->animtimer->customdata= sad; } @@ -1485,6 +1541,45 @@ void ED_screen_animation_timer(bContext *C, int redraws, int enable) WM_event_add_notifier(C, NC_SCREEN|ND_ANIMPLAY, screen); } +/* helper for screen_animation_play() - only to be used for TimeLine */ +static ARegion *time_top_left_3dwindow(bScreen *screen) +{ + ARegion *aret= NULL; + ScrArea *sa; + int min= 10000; + + for(sa= screen->areabase.first; sa; sa= sa->next) { + if(sa->spacetype==SPACE_VIEW3D) { + ARegion *ar; + for(ar= sa->regionbase.first; ar; ar= ar->next) { + if(ar->regiontype==RGN_TYPE_WINDOW) { + if(ar->winrct.xmin - ar->winrct.ymin < min) { + aret= ar; + min= ar->winrct.xmin - ar->winrct.ymin; + } + } + } + } + } + + return aret; +} + +void ED_screen_animation_timer_update(bContext *C, int redraws) +{ + bScreen *screen= CTX_wm_screen(C); + + if(screen && screen->animtimer) { + wmTimer *wt= screen->animtimer; + ScreenAnimData *sad= wt->customdata; + + sad->redraws= redraws; + sad->ar= NULL; + if(redraws & TIME_REGION) + sad->ar= time_top_left_3dwindow(screen); + } +} + unsigned int ED_screen_view3d_layers(bScreen *screen) { if(screen) { @@ -1503,7 +1598,6 @@ unsigned int ED_screen_view3d_layers(bScreen *screen) /* results in fully updated anim system */ -/* in future sound should be on WM level, only 1 sound can play! */ void ED_update_for_newframe(const bContext *C, int mute) { bScreen *screen= CTX_wm_screen(C); @@ -1515,7 +1609,7 @@ void ED_update_for_newframe(const bContext *C, int mute) /* XXX future: do all windows */ scene_update_for_newframe(scene, ED_screen_view3d_layers(screen)); /* BKE_scene.h */ - //if ( (CFRA>1) && (!mute) && (scene->audio.flag & AUDIO_SCRUB)) + //if ( (CFRA>1) && (!mute) && (scene->r.audio.flag & AUDIO_SCRUB)) // audiostream_scrub( CFRA ); /* 3d window, preview */ diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 57fd96c8b39..bcf4ab16f81 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -54,9 +54,11 @@ #include "BKE_mesh.h" #include "BKE_multires.h" #include "BKE_report.h" +#include "BKE_scene.h" #include "BKE_screen.h" #include "BKE_utildefines.h" #include "BKE_tessmesh.h" +#include "BKE_sound.h" #include "WM_api.h" #include "WM_types.h" @@ -231,7 +233,7 @@ int ED_operator_posemode(bContext *C) Object *obedit= CTX_data_edit_object(C); if ((obact != obedit) && (obact) && (obact->type==OB_ARMATURE)) - return (obact->flag & OB_POSEMODE)!=0; + return (obact->mode & OB_MODE_POSE)!=0; return 0; } @@ -1572,7 +1574,6 @@ static void SCREEN_OT_screen_set(wmOperatorType *ot) ot->poll= ED_operator_screenactive; /* rna */ - RNA_def_pointer_runtime(ot->srna, "screen", &RNA_Screen, "Screen", ""); RNA_def_int(ot->srna, "delta", 0, INT_MIN, INT_MAX, "Delta", "", INT_MIN, INT_MAX); } @@ -2217,8 +2218,15 @@ static int screen_animation_step(bContext *C, wmOperator *op, wmEvent *event) wmTimer *wt= screen->animtimer; ScreenAnimData *sad= wt->customdata; ScrArea *sa; + int sync; - if(scene->audio.flag & AUDIO_SYNC) { + /* sync, don't sync, or follow scene setting */ + if(sad->flag & ANIMPLAY_FLAG_SYNC) sync= 1; + else if(sad->flag & ANIMPLAY_FLAG_NO_SYNC) sync= 0; + else sync= (scene->r.audio.flag & AUDIO_SYNC); + + if(sync) { + /* skip frames */ int step = floor(wt->duration * FPS); if (sad->flag & ANIMPLAY_FLAG_REVERSE) // XXX does this option work with audio? scene->r.cfra -= step; @@ -2227,6 +2235,7 @@ static int screen_animation_step(bContext *C, wmOperator *op, wmEvent *event) wt->duration -= ((float)step)/FPS; } else { + /* one frame +/- */ if (sad->flag & ANIMPLAY_FLAG_REVERSE) scene->r.cfra--; else @@ -2270,6 +2279,8 @@ static int screen_animation_step(bContext *C, wmOperator *op, wmEvent *event) /* since we follow drawflags, we can't send notifier but tag regions ourselves */ ED_update_for_newframe(C, 1); + sound_update_playing(C); + for(sa= screen->areabase.first; sa; sa= sa->next) { ARegion *ar; for(ar= sa->regionbase.first; ar; ar= ar->next) { @@ -2303,38 +2314,34 @@ static void SCREEN_OT_animation_step(wmOperatorType *ot) /* ****************** anim player, starts or ends timer ***************** */ -/* helper for screen_animation_play() - only to be used for TimeLine */ -// NOTE: defined in time_header.c for now... -extern ARegion *time_top_left_3dwindow(bScreen *screen); - /* toggle operator */ static int screen_animation_play(bContext *C, wmOperator *op, wmEvent *event) { bScreen *screen= CTX_wm_screen(C); if(screen->animtimer) { - ED_screen_animation_timer(C, 0, 0); + ED_screen_animation_timer(C, 0, 0, 0); + sound_stop_all(C); } else { ScrArea *sa= CTX_wm_area(C); int mode= (RNA_boolean_get(op->ptr, "reverse")) ? -1 : 1; + int sync= -1; + + if(RNA_property_is_set(op->ptr, "sync")) + sync= (RNA_boolean_get(op->ptr, "sync")); /* timeline gets special treatment since it has it's own menu for determining redraws */ if ((sa) && (sa->spacetype == SPACE_TIME)) { SpaceTime *stime= (SpaceTime *)sa->spacedata.first; - ED_screen_animation_timer(C, stime->redraws, mode); + ED_screen_animation_timer(C, stime->redraws, sync, mode); /* update region if TIME_REGION was set, to leftmost 3d window */ - if(screen->animtimer && (stime->redraws & TIME_REGION)) { - wmTimer *wt= screen->animtimer; - ScreenAnimData *sad= wt->customdata; - - sad->ar= time_top_left_3dwindow(screen); + ED_screen_animation_timer_update(C, stime->redraws); } - } else { - ED_screen_animation_timer(C, TIME_REGION|TIME_ALL_3D_WIN, mode); + ED_screen_animation_timer(C, TIME_REGION|TIME_ALL_3D_WIN, sync, mode); if(screen->animtimer) { wmTimer *wt= screen->animtimer; @@ -2360,6 +2367,7 @@ static void SCREEN_OT_animation_play(wmOperatorType *ot) ot->poll= ED_operator_screenactive; RNA_def_boolean(ot->srna, "reverse", 0, "Play in Reverse", "Animation is played backwards"); + RNA_def_boolean(ot->srna, "sync", 0, "Sync", "Drop frames to maintain framerate and stay in sync with audio."); } /* ************** border select operator (template) ***************************** */ @@ -2868,10 +2876,13 @@ static int screen_render_invoke(bContext *C, wmOperator *op, wmEvent *event) RenderJob *rj; Image *ima; - /* only one job at a time */ + /* only one render job at a time */ if(WM_jobs_test(CTX_wm_manager(C), scene)) return OPERATOR_CANCELLED; + /* stop all running jobs, currently previews frustrate Render */ + WM_jobs_stop_all(CTX_wm_manager(C)); + /* handle UI stuff */ WM_cursor_wait(1); @@ -3075,7 +3086,124 @@ static void SCREEN_OT_userpref_show(struct wmOperatorType *ot) ot->poll= ED_operator_screenactive; } +/********************* new screen operator *********************/ + +static int screen_new_exec(bContext *C, wmOperator *op) +{ + wmWindow *win= CTX_wm_window(C); + bScreen *sc= CTX_wm_screen(C); + + sc= ED_screen_duplicate(win, sc); + WM_event_add_notifier(C, NC_SCREEN|ND_SCREENBROWSE, sc); + + return OPERATOR_FINISHED; +} + +void SCREEN_OT_new(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "New Screen"; + ot->idname= "SCREEN_OT_new"; + + /* api callbacks */ + ot->exec= screen_new_exec; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} + +/********************* delete screen operator *********************/ + +static int screen_delete_exec(bContext *C, wmOperator *op) +{ + bScreen *sc= CTX_wm_screen(C); + + WM_event_add_notifier(C, NC_SCREEN|ND_SCREENDELETE, sc); + return OPERATOR_FINISHED; +} + +void SCREEN_OT_delete(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Delete Scene"; + ot->idname= "SCREEN_OT_delete"; + + /* api callbacks */ + ot->exec= screen_delete_exec; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} + +/********************* new scene operator *********************/ + +static int scene_new_exec(bContext *C, wmOperator *op) +{ + Scene *newscene, *scene= CTX_data_scene(C); + Main *bmain= CTX_data_main(C); + int type= RNA_enum_get(op->ptr, "type"); + + newscene= copy_scene(bmain, scene, type); + + /* these can't be handled in blenkernel curently, so do them here */ + if(type == SCE_COPY_LINK_DATA) + ED_object_single_users(newscene, 0); + else if(type == SCE_COPY_FULL) + ED_object_single_users(newscene, 1); + + WM_event_add_notifier(C, NC_SCENE|ND_SCENEBROWSE, newscene); + + return OPERATOR_FINISHED; +} + +void SCENE_OT_new(wmOperatorType *ot) +{ + static EnumPropertyItem type_items[]= { + {SCE_COPY_EMPTY, "EMPTY", 0, "Empty", "Add empty scene."}, + {SCE_COPY_LINK_OB, "LINK_OBJECTS", 0, "Link Objects", "Link to the objects from the current scene."}, + {SCE_COPY_LINK_DATA, "LINK_OBJECT_DATA", 0, "Link Object Data", "Copy objects linked to data from the current scene."}, + {SCE_COPY_FULL, "FULL_COPY", 0, "Full Copy", "Make a full copy of the current scene."}, + {0, NULL, 0, NULL, NULL}}; + + /* identifiers */ + ot->name= "New Scene"; + ot->idname= "SCENE_OT_new"; + + /* api callbacks */ + ot->exec= scene_new_exec; + ot->invoke= WM_menu_invoke; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + /* properties */ + RNA_def_enum(ot->srna, "type", type_items, 0, "Type", ""); +} + +/********************* delete scene operator *********************/ + +static int scene_delete_exec(bContext *C, wmOperator *op) +{ + Scene *scene= CTX_data_scene(C); + + WM_event_add_notifier(C, NC_SCENE|ND_SCENEDELETE, scene); + + return OPERATOR_FINISHED; +} + +void SCENE_OT_delete(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Delete Scene"; + ot->idname= "SCENE_OT_delete"; + + /* api callbacks */ + ot->exec= scene_delete_exec; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} /* **************** Assigning operatortypes to global list, adding handlers **************** */ @@ -3117,6 +3245,12 @@ void ED_operatortypes_screen(void) WM_operatortype_append(SCREEN_OT_render_view_cancel); WM_operatortype_append(SCREEN_OT_render_view_show); + /* new/delete */ + WM_operatortype_append(SCREEN_OT_new); + WM_operatortype_append(SCREEN_OT_delete); + WM_operatortype_append(SCENE_OT_new); + WM_operatortype_append(SCENE_OT_delete); + /* tools shared by more space types */ WM_operatortype_append(ED_OT_undo); WM_operatortype_append(ED_OT_redo); @@ -3156,6 +3290,7 @@ void ED_keymap_screen(wmWindowManager *wm) /* Screen General ------------------------------------------------ */ keymap= WM_keymap_listbase(wm, "Screen", 0, 0); + /* standard timers */ WM_keymap_add_item(keymap, "SCREEN_OT_animation_step", TIMER0, KM_ANY, KM_ANY, 0); @@ -3184,7 +3319,8 @@ void ED_keymap_screen(wmWindowManager *wm) WM_keymap_add_item(keymap, "SCREEN_OT_region_foursplit", SKEY, KM_PRESS, KM_CTRL|KM_ALT|KM_SHIFT, 0); WM_keymap_verify_item(keymap, "SCREEN_OT_repeat_history", F3KEY, KM_PRESS, 0, 0); - WM_keymap_verify_item(keymap, "SCREEN_OT_repeat_last", F4KEY, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "SCREEN_OT_repeat_last", RKEY, KM_PRESS, KM_CTRL, 0); + WM_keymap_add_item(keymap, "SCREEN_OT_repeat_last", RKEY, KM_PRESS, KM_OSKEY, 0); WM_keymap_add_item(keymap, "SCREEN_OT_region_flip", F5KEY, KM_PRESS, 0, 0); WM_keymap_verify_item(keymap, "SCREEN_OT_redo_last", F6KEY, KM_PRESS, 0, 0); @@ -3203,12 +3339,17 @@ void ED_keymap_screen(wmWindowManager *wm) /* render */ WM_keymap_add_item(keymap, "SCREEN_OT_render", F12KEY, KM_PRESS, 0, 0); +// WM_keymap_add_item(keymap, "SCREEN_OT_render", RETKEY, KM_PRESS, KM_CTRL, 0); +// WM_keymap_add_item(keymap, "SCREEN_OT_render", RETKEY, KM_PRESS, KM_OSKEY, 0); RNA_boolean_set(WM_keymap_add_item(keymap, "SCREEN_OT_render", F12KEY, KM_PRESS, KM_CTRL, 0)->ptr, "animation", 1); +// RNA_boolean_set(WM_keymap_add_item(keymap, "SCREEN_OT_render", RETKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0)->ptr, "animation", 1); +// RNA_boolean_set(WM_keymap_add_item(keymap, "SCREEN_OT_render", RETKEY, KM_PRESS, KM_OSKEY|KM_SHIFT, 0)->ptr, "animation", 1); WM_keymap_add_item(keymap, "SCREEN_OT_render_view_cancel", ESCKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "SCREEN_OT_render_view_show", F11KEY, KM_PRESS, 0, 0); /* user prefs */ - WM_keymap_add_item(keymap, "SCREEN_OT_userpref_show", UKEY, KM_PRESS, KM_ALT, 0); + WM_keymap_add_item(keymap, "SCREEN_OT_userpref_show", COMMAKEY, KM_PRESS, KM_CTRL, 0); + WM_keymap_add_item(keymap, "SCREEN_OT_userpref_show", COMMAKEY, KM_PRESS, KM_OSKEY, 0); /* Anim Playback ------------------------------------------------ */ keymap= WM_keymap_listbase(wm, "Frames", 0, 0); @@ -3220,13 +3361,15 @@ void ED_keymap_screen(wmWindowManager *wm) RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_offset", RIGHTARROWKEY, KM_PRESS, 0, 0)->ptr, "delta", 1); WM_keymap_add_item(keymap, "SCREEN_OT_frame_jump", DOWNARROWKEY, KM_PRESS, KM_SHIFT, 0); - RNA_boolean_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_jump", UPARROWKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "end", 1); + RNA_boolean_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_jump", RIGHTARROWKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "end", 1); + RNA_boolean_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_jump", LEFTARROWKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "end", 0); WM_keymap_add_item(keymap, "SCREEN_OT_keyframe_jump", PAGEUPKEY, KM_PRESS, KM_CTRL, 0); RNA_boolean_set(WM_keymap_add_item(keymap, "SCREEN_OT_keyframe_jump", PAGEDOWNKEY, KM_PRESS, KM_CTRL, 0)->ptr, "next", 0); /* play (forward and backwards) */ WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", AKEY, KM_PRESS, KM_ALT, 0); + WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", KKEY, KM_PRESS, 0, LKEY); RNA_boolean_set(WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", AKEY, KM_PRESS, KM_ALT|KM_SHIFT, 0)->ptr, "reverse", 1); keymap_modal_set(wm); diff --git a/source/blender/editors/screen/screendump.c b/source/blender/editors/screen/screendump.c index 2ae2712d02d..5ae1bdf84aa 100644 --- a/source/blender/editors/screen/screendump.c +++ b/source/blender/editors/screen/screendump.c @@ -228,7 +228,7 @@ static void screenshot_startjob(void *sjv, short *stop, short *do_update) rd.frs_sec_base= 1.0f; if(BKE_imtype_is_movie(rd.imtype)) - mh->start_movie(&rd, sj->dumpsx, sj->dumpsy); + mh->start_movie(sj->scene, &rd, sj->dumpsx, sj->dumpsy); else mh= NULL; diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index 1b33f340d5e..128455a8487 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -71,6 +71,7 @@ #include "BKE_main.h" #include "BKE_mesh.h" #include "BKE_node.h" +#include "BKE_paint.h" #include "BKE_utildefines.h" #include "BKE_DerivedMesh.h" #include "BKE_report.h" @@ -3706,7 +3707,7 @@ static void *do_projectpaint_thread(void *ph_v) ProjPaintImage *last_projIma= NULL; ImagePaintPartialRedraw *last_partial_redraw_cell; - float rgba[4], alpha, dist_nosqrt; + float rgba[4], alpha, dist_nosqrt, dist; float brush_size_sqared; float falloff; @@ -3720,6 +3721,7 @@ static void *do_projectpaint_thread(void *ph_v) float co[2]; float mask = 1.0f; /* airbrush wont use mask */ unsigned short mask_short; + float size_half = ((float)ps->brush->size) * 0.5f; LinkNode *smearPixels = NULL; LinkNode *smearPixels_f = NULL; @@ -3754,8 +3756,8 @@ static void *do_projectpaint_thread(void *ph_v) dist_nosqrt = Vec2Lenf_nosqrt(projPixel->projCoSS, pos); /*if (dist < s->brush->size) {*/ /* correct but uses a sqrtf */ - if (dist_nosqrt < brush_size_sqared) { - falloff = brush_sample_falloff_noalpha(ps->brush, sqrtf(dist_nosqrt)); + if (dist_nosqrt < brush_size_sqared && (dist=sqrtf(dist_nosqrt)) < size_half) { + falloff = brush_curve_strength(ps->brush, dist, size_half); if (falloff > 0.0f) { if (ps->is_texbrush) { brush_sample_tex(ps->brush, projPixel->projCoSS, rgba); @@ -4023,7 +4025,7 @@ static void imapaint_image_update(SpaceImage *sima, Image *image, ImBuf *ibuf, s if(texpaint || (sima && sima->lock)) { int w = imapaintpartial.x2 - imapaintpartial.x1; int h = imapaintpartial.y2 - imapaintpartial.y1; - GPU_paint_update_image(image, imapaintpartial.x1, imapaintpartial.y1, w, h); + GPU_paint_update_image(image, imapaintpartial.x1, imapaintpartial.y1, w, h, !texpaint); } } @@ -4375,15 +4377,17 @@ static Brush *image_paint_brush(bContext *C) Scene *scene= CTX_data_scene(C); ToolSettings *settings= scene->toolsettings; - return settings->imapaint.brush; + return paint_brush(&settings->imapaint.paint); } static int image_paint_poll(bContext *C) { + Object *obact = CTX_data_active_object(C); + if(!image_paint_brush(C)) return 0; - if((G.f & G_TEXTUREPAINT) && CTX_wm_region_view3d(C)) { + if((obact && obact->mode & OB_MODE_TEXTURE_PAINT) && CTX_wm_region_view3d(C)) { return 1; } else { @@ -4484,11 +4488,12 @@ static void paint_redraw(bContext *C, ImagePaintState *s, int final) } } -static int paint_init(bContext *C, wmOperator *op) +static int texture_paint_init(bContext *C, wmOperator *op) { Scene *scene= CTX_data_scene(C); ToolSettings *settings= scene->toolsettings; PaintOperation *pop; + Brush *brush; pop= MEM_callocN(sizeof(PaintOperation), "PaintOperation"); pop->first= 1; @@ -4516,10 +4521,11 @@ static int paint_init(bContext *C, wmOperator *op) pop->ps.ar= CTX_wm_region(C); /* intialize brush */ - if(!settings->imapaint.brush) + brush= paint_brush(&settings->imapaint.paint); + if(!brush) return 0; - pop->s.brush = settings->imapaint.brush; + pop->s.brush = brush; pop->s.tool = settings->imapaint.tool; if(pop->mode == PAINT_MODE_3D && (pop->s.tool == PAINT_TOOL_CLONE)) pop->s.tool = PAINT_TOOL_DRAW; @@ -4607,11 +4613,13 @@ static int paint_init(bContext *C, wmOperator *op) static void paint_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) { PaintOperation *pop= op->customdata; - float time; + float time, mousef[2]; float pressure; int mouse[2], redraw; - RNA_int_get_array(itemptr, "mouse", mouse); + RNA_float_get_array(itemptr, "mouse", mousef); + mouse[0] = mousef[0]; + mouse[1] = mousef[1]; time= RNA_float_get(itemptr, "time"); pressure= RNA_float_get(itemptr, "pressure"); @@ -4670,7 +4678,7 @@ static void paint_exit(bContext *C, wmOperator *op) static int paint_exec(bContext *C, wmOperator *op) { - if(!paint_init(C, op)) { + if(!texture_paint_init(C, op)) { MEM_freeN(op->customdata); return OPERATOR_CANCELLED; } @@ -4691,7 +4699,7 @@ static void paint_apply_event(bContext *C, wmOperator *op, wmEvent *event) PaintOperation *pop= op->customdata; wmTabletData *wmtab; PointerRNA itemptr; - float pressure; + float pressure, mousef[2]; double time; int tablet, mouse[2]; @@ -4712,7 +4720,7 @@ static void paint_apply_event(bContext *C, wmOperator *op, wmEvent *event) tablet= (wmtab->Active != EVT_TABLET_NONE); pressure= wmtab->Pressure; if(wmtab->Active == EVT_TABLET_ERASER) - pop->s.blend= BRUSH_BLEND_ERASE_ALPHA; + pop->s.blend= IMB_BLEND_ERASE_ALPHA; } else pressure= 1.0f; @@ -4732,7 +4740,9 @@ static void paint_apply_event(bContext *C, wmOperator *op, wmEvent *event) /* fill in stroke */ RNA_collection_add(op->ptr, "stroke", &itemptr); - RNA_int_set_array(&itemptr, "mouse", mouse); + mousef[0] = mouse[0]; + mousef[1] = mouse[1]; + RNA_float_set_array(&itemptr, "mouse", mousef); RNA_float_set(&itemptr, "time", (float)(time - pop->starttime)); RNA_float_set(&itemptr, "pressure", pressure); @@ -4744,7 +4754,7 @@ static int paint_invoke(bContext *C, wmOperator *op, wmEvent *event) { PaintOperation *pop; - if(!paint_init(C, op)) { + if(!texture_paint_init(C, op)) { MEM_freeN(op->customdata); return OPERATOR_CANCELLED; } @@ -4872,7 +4882,7 @@ static int paint_radial_control_invoke(bContext *C, wmOperator *op, wmEvent *eve ToolSettings *ts = CTX_data_scene(C)->toolsettings; get_imapaint_zoom(C, &zoom, &zoom); toggle_paint_cursor(C, !ts->imapaint.paintcursor); - brush_radial_control_invoke(op, ts->imapaint.brush, 0.5 * zoom); + brush_radial_control_invoke(op, paint_brush(&ts->imapaint.paint), 0.5 * zoom); return WM_radial_control_invoke(C, op, event); } @@ -4891,7 +4901,7 @@ static int paint_radial_control_exec(bContext *C, wmOperator *op) int ret; char str[256]; get_imapaint_zoom(C, &zoom, &zoom); - ret = brush_radial_control_exec(op, CTX_data_scene(C)->toolsettings->imapaint.brush, 2.0 / zoom); + ret = brush_radial_control_exec(op, paint_brush(&CTX_data_scene(C)->toolsettings->imapaint.paint), 2.0 / zoom); WM_radial_control_string(op, str, 256); return ret; @@ -5144,13 +5154,13 @@ static int texture_paint_toggle_exec(bContext *C, wmOperator *op) me= get_mesh(ob); - if(!(G.f & G_TEXTUREPAINT) && !me) { + if(!(ob->mode & OB_MODE_TEXTURE_PAINT) && !me) { BKE_report(op->reports, RPT_ERROR, "Can only enter texture paint mode for mesh objects."); return OPERATOR_CANCELLED; } - if(G.f & G_TEXTUREPAINT) { - G.f &= ~G_TEXTUREPAINT; + if(ob->mode & OB_MODE_TEXTURE_PAINT) { + ob->mode &= ~OB_MODE_TEXTURE_PAINT; if(U.glreslimit != 0) GPU_free_images(); @@ -5159,13 +5169,13 @@ static int texture_paint_toggle_exec(bContext *C, wmOperator *op) toggle_paint_cursor(C, 0); } else { - G.f |= G_TEXTUREPAINT; + ob->mode |= OB_MODE_TEXTURE_PAINT; if(me->mtface==NULL) me->mtface= CustomData_add_layer(&me->fdata, CD_MTFACE, CD_DEFAULT, NULL, me->totface); - brush_check_exists(&scene->toolsettings->imapaint.brush); + paint_init(&scene->toolsettings->imapaint.paint, PAINT_CURSOR_TEXTURE_PAINT); if(U.glreslimit != 0) GPU_free_images(); @@ -5200,13 +5210,13 @@ static int texture_paint_radial_control_invoke(bContext *C, wmOperator *op, wmEv { ToolSettings *ts = CTX_data_scene(C)->toolsettings; toggle_paint_cursor(C, !ts->imapaint.paintcursor); - brush_radial_control_invoke(op, ts->imapaint.brush, 0.5); + brush_radial_control_invoke(op, paint_brush(&ts->imapaint.paint), 0.5); return WM_radial_control_invoke(C, op, event); } static int texture_paint_radial_control_exec(bContext *C, wmOperator *op) { - int ret = brush_radial_control_exec(op, CTX_data_scene(C)->toolsettings->imapaint.brush, 2); + int ret = brush_radial_control_exec(op, paint_brush(&CTX_data_scene(C)->toolsettings->imapaint.paint), 2); char str[256]; WM_radial_control_string(op, str, 256); @@ -5216,7 +5226,7 @@ static int texture_paint_radial_control_exec(bContext *C, wmOperator *op) static int texture_paint_poll(bContext *C) { if(texture_paint_toggle_poll(C)) - if(G.f & G_TEXTUREPAINT) + if(CTX_data_active_object(C)->mode & OB_MODE_TEXTURE_PAINT) return 1; return 0; diff --git a/source/blender/editors/sculpt_paint/paint_intern.h b/source/blender/editors/sculpt_paint/paint_intern.h index b630975c934..ba1b57a1bef 100644 --- a/source/blender/editors/sculpt_paint/paint_intern.h +++ b/source/blender/editors/sculpt_paint/paint_intern.h @@ -29,14 +29,37 @@ #ifndef ED_PAINT_INTERN_H #define ED_PAINT_INTERN_H +struct bContext; struct Scene; struct Object; struct Mesh; +struct PaintStroke; +struct PointerRNA; struct ViewContext; +struct wmEvent; +struct wmOperator; struct wmOperatorType; struct ARegion; +/* paint_stroke.c */ +typedef int (*StrokeTestStart)(struct bContext *C, struct wmOperator *op, struct wmEvent *event); +typedef void (*StrokeUpdateStep)(struct bContext *C, struct PaintStroke *stroke, struct PointerRNA *itemptr); +typedef void (*StrokeDone)(struct bContext *C, struct PaintStroke *stroke); + +struct PaintStroke *paint_stroke_new(bContext *C, StrokeTestStart test_start, + StrokeUpdateStep update_step, StrokeDone done); +int paint_stroke_modal(struct bContext *C, struct wmOperator *op, struct wmEvent *event); +int paint_stroke_exec(struct bContext *C, struct wmOperator *op); +struct ViewContext *paint_stroke_view_context(struct PaintStroke *stroke); +void *paint_stroke_mode_data(struct PaintStroke *stroke); +void paint_stroke_set_mode_data(struct PaintStroke *stroke, void *mode_data); +int paint_poll(bContext *C); +void paint_cursor_start(struct bContext *C, int (*poll)(struct bContext *C)); + /* paint_vertex.c */ +int vertex_paint_mode_poll(bContext *C); +void clear_vpaint(Scene *scene, int selected); + void PAINT_OT_weight_paint_toggle(struct wmOperatorType *ot); void PAINT_OT_weight_paint_radial_control(struct wmOperatorType *ot); void PAINT_OT_weight_paint(struct wmOperatorType *ot); @@ -59,6 +82,7 @@ int imapaint_pick_face(struct ViewContext *vc, struct Mesh *me, int *mval, unsig void imapaint_pick_uv(struct Scene *scene, struct Object *ob, struct Mesh *mesh, unsigned int faceindex, int *xy, float *uv); void paint_sample_color(struct Scene *scene, struct ARegion *ar, int x, int y); +void BRUSH_OT_curve_preset(struct wmOperatorType *ot); #endif /* ED_PAINT_INTERN_H */ diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c index e9263ddabf0..c38b36007e9 100644 --- a/source/blender/editors/sculpt_paint/paint_ops.c +++ b/source/blender/editors/sculpt_paint/paint_ops.c @@ -1,15 +1,116 @@ +/** + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include "DNA_brush_types.h" +#include "DNA_object_types.h" +#include "DNA_scene_types.h" + +#include "BKE_brush.h" +#include "BKE_context.h" +#include "BKE_paint.h" #include "ED_sculpt.h" +#include "UI_resources.h" #include "WM_api.h" #include "WM_types.h" +#include "RNA_access.h" +#include "RNA_define.h" +#include "RNA_enum_types.h" + #include "paint_intern.h" +#include <string.h> + +/* Brush operators */ +static int brush_add_exec(bContext *C, wmOperator *op) +{ + /*int type = RNA_enum_get(op->ptr, "type");*/ + Brush *br = NULL; + + br = add_brush("Brush"); + + if(br) + paint_brush_set(paint_get_active(CTX_data_scene(C)), br); + + return OPERATOR_FINISHED; +} + +static EnumPropertyItem brush_type_items[] = { + {OB_MODE_SCULPT, "SCULPT", ICON_SCULPTMODE_HLT, "Sculpt", ""}, + {OB_MODE_VERTEX_PAINT, "VERTEX_PAINT", ICON_VPAINT_HLT, "Vertex Paint", ""}, + {OB_MODE_WEIGHT_PAINT, "WEIGHT_PAINT", ICON_WPAINT_HLT, "Weight Paint", ""}, + {OB_MODE_TEXTURE_PAINT, "TEXTURE_PAINT", ICON_TPAINT_HLT, "Texture Paint", ""}, + {0, NULL, 0, NULL, NULL}}; + +void BRUSH_OT_add(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Add Brush"; + ot->idname= "BRUSH_OT_add"; + + /* api callbacks */ + ot->exec= brush_add_exec; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + RNA_def_enum(ot->srna, "type", brush_type_items, OB_MODE_VERTEX_PAINT, "Type", "Which paint mode to create the brush for."); +} + +static int vertex_color_set_exec(bContext *C, wmOperator *op) +{ + int selected = RNA_boolean_get(op->ptr, "selected"); + Scene *scene = CTX_data_scene(C); + + clear_vpaint(scene, selected); + + return OPERATOR_FINISHED; +} + +void PAINT_OT_vertex_color_set(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Set Vertex Colors"; + ot->idname= "PAINT_OT_vertex_color_set"; + + /* api callbacks */ + ot->exec= vertex_color_set_exec; + ot->poll= vertex_paint_mode_poll; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + RNA_def_boolean(ot->srna, "selected", 0, "Type", "Only color selected faces."); +} + /**************************** registration **********************************/ void ED_operatortypes_paint(void) { + /* brush */ + WM_operatortype_append(BRUSH_OT_add); + WM_operatortype_append(BRUSH_OT_curve_preset); + /* image */ WM_operatortype_append(PAINT_OT_texture_paint_toggle); WM_operatortype_append(PAINT_OT_texture_paint_radial_control); @@ -28,5 +129,6 @@ void ED_operatortypes_paint(void) WM_operatortype_append(PAINT_OT_vertex_paint_radial_control); WM_operatortype_append(PAINT_OT_vertex_paint_toggle); WM_operatortype_append(PAINT_OT_vertex_paint); + WM_operatortype_append(PAINT_OT_vertex_color_set); } diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c new file mode 100644 index 00000000000..bd9ea50e0f8 --- /dev/null +++ b/source/blender/editors/sculpt_paint/paint_stroke.c @@ -0,0 +1,330 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2009 by Nicholas Bishop + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + * + */ + +#include "MEM_guardedalloc.h" + +#include "DNA_brush_types.h" +#include "DNA_object_types.h" +#include "DNA_scene_types.h" +#include "DNA_screen_types.h" + +#include "RNA_access.h" + +#include "BKE_context.h" +#include "BKE_paint.h" + +#include "WM_api.h" +#include "WM_types.h" + +#include "BLI_arithb.h" + +#include "PIL_time.h" + +#include "BIF_gl.h" +#include "BIF_glutil.h" + +#include "ED_screen.h" +#include "ED_view3d.h" + +#include "paint_intern.h" + +#include <float.h> +#include <math.h> + +typedef struct PaintStroke { + void *mode_data; + void *smooth_stroke_cursor; + wmTimer *timer; + + /* Cached values */ + ViewContext vc; + bglMats mats; + Brush *brush; + + float last_mouse_position[2]; + + /* Set whether any stroke step has yet occured + e.g. in sculpt mode, stroke doesn't start until cursor + passes over the mesh */ + int stroke_started; + + StrokeTestStart test_start; + StrokeUpdateStep update_step; + StrokeDone done; +} PaintStroke; + +/*** Cursor ***/ +static void paint_draw_smooth_stroke(bContext *C, int x, int y, void *customdata) +{ + Brush *brush = paint_brush(paint_get_active(CTX_data_scene(C))); + PaintStroke *stroke = customdata; + + glColor4ubv(paint_get_active(CTX_data_scene(C))->paint_cursor_col); + glEnable(GL_LINE_SMOOTH); + glEnable(GL_BLEND); + + if(stroke && brush && (brush->flag & BRUSH_SMOOTH_STROKE)) { + ARegion *ar = CTX_wm_region(C); + sdrawline(x, y, (int)stroke->last_mouse_position[0] - ar->winrct.xmin, + (int)stroke->last_mouse_position[1] - ar->winrct.ymin); + } + + glDisable(GL_BLEND); + glDisable(GL_LINE_SMOOTH); +} + +static void paint_draw_cursor(bContext *C, int x, int y, void *customdata) +{ + Brush *brush = paint_brush(paint_get_active(CTX_data_scene(C))); + + glColor4ubv(paint_get_active(CTX_data_scene(C))->paint_cursor_col); + 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, 40); + glTranslatef((float)-x, (float)-y, 0.0f); + + glDisable(GL_BLEND); + glDisable(GL_LINE_SMOOTH); +} + +/* 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[2]) +{ + PointerRNA itemptr; + float cur_depth, pressure = 1; + float center[3]; + PaintStroke *stroke = op->customdata; + + cur_depth = read_cached_depth(&stroke->vc, mouse[0], mouse[1]); + view3d_unproject(&stroke->mats, center, mouse[0], mouse[1], cur_depth); + + /* Tablet */ + if(event->custom == EVT_DATA_TABLET) { + wmTabletData *wmtab= event->customdata; + if(wmtab->Active != EVT_TABLET_NONE) + pressure= wmtab->Pressure; + } + + /* Add to stroke */ + RNA_collection_add(op->ptr, "stroke", &itemptr); + RNA_float_set_array(&itemptr, "location", center); + RNA_float_set_array(&itemptr, "mouse", mouse); + RNA_boolean_set(&itemptr, "flip", event->shift); + RNA_float_set(&itemptr, "pressure", pressure); + + stroke->last_mouse_position[0] = mouse[0]; + stroke->last_mouse_position[1] = mouse[1]; + + stroke->update_step(C, stroke, &itemptr); +} + +/* Returns zero if no sculpt changes should be made, non-zero otherwise */ +static int paint_smooth_stroke(PaintStroke *stroke, float output[2], wmEvent *event) +{ + output[0] = event->x; + output[1] = event->y; + + if(stroke->brush->flag & BRUSH_SMOOTH_STROKE && stroke->brush->sculpt_tool != SCULPT_TOOL_GRAB) { + float u = stroke->brush->smooth_stroke_factor, v = 1.0 - u; + float dx = stroke->last_mouse_position[0] - event->x, dy = stroke->last_mouse_position[1] - event->y; + + /* If the mouse is moving within the radius of the last move, + don't update the mouse position. This allows sharp turns. */ + if(dx*dx + dy*dy < stroke->brush->smooth_stroke_radius * stroke->brush->smooth_stroke_radius) + return 0; + + output[0] = event->x * v + stroke->last_mouse_position[0] * u; + output[1] = event->y * v + stroke->last_mouse_position[1] * u; + } + + return 1; +} + +/* Returns zero if the stroke dots should not be spaced, non-zero otherwise */ +static int paint_space_stroke_enabled(Brush *br) +{ + return (br->flag & BRUSH_SPACE) && !(br->flag & BRUSH_ANCHORED) && (br->sculpt_tool != SCULPT_TOOL_GRAB); +} + +/* For brushes with stroke spacing enabled, moves mouse in steps + towards the final mouse location. */ +static int paint_space_stroke(bContext *C, wmOperator *op, wmEvent *event, const float final_mouse[2]) +{ + PaintStroke *stroke = op->customdata; + int cnt = 0; + + if(paint_space_stroke_enabled(stroke->brush)) { + float mouse[2] = {stroke->last_mouse_position[0], stroke->last_mouse_position[1]}; + float vec[2] = {final_mouse[0] - mouse[0], final_mouse[1] - mouse[1]}; + float length, scale; + int steps = 0, i; + + /* Normalize the vector between the last stroke dot and the goal */ + length = sqrt(vec[0]*vec[0] + vec[1]*vec[1]); + + if(length > FLT_EPSILON) { + scale = stroke->brush->spacing / length; + vec[0] *= scale; + vec[1] *= scale; + + steps = (int)(length / stroke->brush->spacing); + for(i = 0; i < steps; ++i, ++cnt) { + mouse[0] += vec[0]; + mouse[1] += vec[1]; + paint_brush_stroke_add_step(C, op, event, mouse); + } + } + } + + return cnt; +} + +/**** Public API ****/ + +PaintStroke *paint_stroke_new(bContext *C, StrokeTestStart test_start, + StrokeUpdateStep update_step, StrokeDone done) +{ + PaintStroke *stroke = MEM_callocN(sizeof(PaintStroke), "PaintStroke"); + + stroke->brush = paint_brush(paint_get_active(CTX_data_scene(C))); + view3d_set_viewcontext(C, &stroke->vc); + view3d_get_transformation(&stroke->vc, stroke->vc.obact, &stroke->mats); + + stroke->test_start = test_start; + stroke->update_step = update_step; + stroke->done = done; + + return stroke; +} + +int paint_stroke_modal(bContext *C, wmOperator *op, wmEvent *event) +{ + ARegion *ar = CTX_wm_region(C); + PaintStroke *stroke = op->customdata; + float mouse[2]; + + if(event->type == TIMER && (event->customdata != stroke->timer)) + return OPERATOR_RUNNING_MODAL; + + if(!stroke->stroke_started) { + stroke->last_mouse_position[0] = event->x; + stroke->last_mouse_position[1] = event->y; + stroke->stroke_started = stroke->test_start(C, op, event); + + if(stroke->stroke_started) { + stroke->smooth_stroke_cursor = + WM_paint_cursor_activate(CTX_wm_manager(C), paint_poll, paint_draw_smooth_stroke, stroke); + + if(stroke->brush->flag & BRUSH_AIRBRUSH) + stroke->timer = WM_event_add_window_timer(CTX_wm_window(C), TIMER, stroke->brush->rate); + } + + ED_region_tag_redraw(ar); + } + + if(stroke->stroke_started) { + if(paint_smooth_stroke(stroke, mouse, event)) { + if(paint_space_stroke_enabled(stroke->brush)) { + if(!paint_space_stroke(C, op, event, mouse)) + ED_region_tag_redraw(ar); + } + else + paint_brush_stroke_add_step(C, op, event, mouse); + } + else + ED_region_tag_redraw(ar); + } + + /* TODO: fix hardcoded event here */ + if(event->type == LEFTMOUSE && event->val == 0) { + /* Exit stroke, free data */ + + if(stroke->smooth_stroke_cursor) + WM_paint_cursor_end(CTX_wm_manager(C), stroke->smooth_stroke_cursor); + + if(stroke->timer) + WM_event_remove_window_timer(CTX_wm_window(C), stroke->timer); + + stroke->done(C, stroke); + MEM_freeN(stroke); + return OPERATOR_FINISHED; + } + else + return OPERATOR_RUNNING_MODAL; +} + +int paint_stroke_exec(bContext *C, wmOperator *op) +{ + PaintStroke *stroke = op->customdata; + + RNA_BEGIN(op->ptr, itemptr, "stroke") { + stroke->update_step(C, stroke, &itemptr); + } + RNA_END; + + MEM_freeN(stroke); + op->customdata = NULL; + + return OPERATOR_FINISHED; +} + +ViewContext *paint_stroke_view_context(PaintStroke *stroke) +{ + return &stroke->vc; +} + +void *paint_stroke_mode_data(struct PaintStroke *stroke) +{ + return stroke->mode_data; +} + +void paint_stroke_set_mode_data(PaintStroke *stroke, void *mode_data) +{ + stroke->mode_data = mode_data; +} + +int paint_poll(bContext *C) +{ + Paint *p = paint_get_active(CTX_data_scene(C)); + Object *ob = CTX_data_active_object(C); + + return p && ob && paint_brush(p) && + CTX_wm_area(C)->spacetype == SPACE_VIEW3D && + CTX_wm_region(C)->regiontype == RGN_TYPE_WINDOW; +} + +void paint_cursor_start(bContext *C, int (*poll)(bContext *C)) +{ + Paint *p = paint_get_active(CTX_data_scene(C)); + + if(p && !p->paint_cursor) + p->paint_cursor = WM_paint_cursor_activate(CTX_wm_manager(C), poll, paint_draw_cursor, NULL); +} + diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c index 46d41c043bd..68c5232e249 100644 --- a/source/blender/editors/sculpt_paint/paint_utils.c +++ b/source/blender/editors/sculpt_paint/paint_utils.c @@ -5,21 +5,31 @@ #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" #include "DNA_object_types.h" + #include "DNA_scene_types.h" #include "DNA_screen_types.h" #include "DNA_view3d_types.h" +#include "RNA_access.h" +#include "RNA_define.h" + #include "BLI_arithb.h" #include "BKE_brush.h" +#include "BKE_context.h" #include "BKE_DerivedMesh.h" #include "BKE_global.h" +#include "BKE_paint.h" + #include "BKE_utildefines.h" #include "BIF_gl.h" #include "ED_view3d.h" +#include "WM_api.h" +#include "WM_types.h" + #include "paint_intern.h" /* 3D Paint */ @@ -160,7 +170,7 @@ int imapaint_pick_face(ViewContext *vc, Mesh *me, int *mval, unsigned int *index /* used for both 3d view and image window */ void paint_sample_color(Scene *scene, ARegion *ar, int x, int y) /* frontbuf */ { - Brush **br = current_brush_source(scene); + Brush *br = paint_brush(paint_get_active(scene)); unsigned int col; char *cp; @@ -173,10 +183,43 @@ void paint_sample_color(Scene *scene, ARegion *ar, int x, int y) /* frontbuf */ cp = (char *)&col; - if(br && *br) { - (*br)->rgb[0]= cp[0]/255.0f; - (*br)->rgb[1]= cp[1]/255.0f; - (*br)->rgb[2]= cp[2]/255.0f; + if(br) { + br->rgb[0]= cp[0]/255.0f; + br->rgb[1]= cp[1]/255.0f; + br->rgb[2]= cp[2]/255.0f; } } +static int brush_curve_preset_exec(bContext *C, wmOperator *op) +{ + Brush *br = paint_brush(paint_get_active(CTX_data_scene(C))); + brush_curve_preset(br, RNA_enum_get(op->ptr, "shape")); + + return OPERATOR_FINISHED; +} + +static int brush_curve_preset_poll(bContext *C) +{ + Brush *br = paint_brush(paint_get_active(CTX_data_scene(C))); + + return br && br->curve; +} + +void BRUSH_OT_curve_preset(wmOperatorType *ot) +{ + static EnumPropertyItem prop_shape_items[] = { + {BRUSH_PRESET_SHARP, "SHARP", 0, "Sharp", ""}, + {BRUSH_PRESET_SMOOTH, "SMOOTH", 0, "Smooth", ""}, + {BRUSH_PRESET_MAX, "MAX", 0, "Max", ""}, + {0, NULL, 0, NULL, NULL}}; + + ot->name= "Preset"; + ot->idname= "BRUSH_OT_curve_preset"; + + ot->exec= brush_curve_preset_exec; + ot->poll= brush_curve_preset_poll; + + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + RNA_def_enum(ot->srna, "shape", prop_shape_items, BRUSH_PRESET_SHARP, "Mode", ""); +} diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index 812c41f430e..ee3d9e5baa1 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -62,6 +62,7 @@ #include "DNA_userdef_types.h" #include "RNA_access.h" +#include "RNA_define.h" #include "BKE_armature.h" #include "BKE_brush.h" @@ -76,6 +77,7 @@ #include "BKE_mesh.h" #include "BKE_modifier.h" #include "BKE_object.h" +#include "BKE_paint.h" #include "BKE_utildefines.h" #include "WM_api.h" @@ -90,6 +92,8 @@ #include "ED_util.h" #include "ED_view3d.h" +#include "paint_intern.h" + /* vp->mode */ #define VP_MIX 0 #define VP_ADD 1 @@ -106,9 +110,19 @@ static void error() {} /* polling - retrieve whether cursor should be set or operator should be done */ + +/* Returns true if vertex paint mode is active */ +int vertex_paint_mode_poll(bContext *C) +{ + Object *ob = CTX_data_active_object(C); + + return ob && ob->mode == OB_MODE_VERTEX_PAINT; +} + static int vp_poll(bContext *C) { - if(G.f & G_VERTEXPAINT) { + if(vertex_paint_mode_poll(C) && + paint_brush(&CTX_data_tool_settings(C)->vpaint->paint)) { ScrArea *sa= CTX_wm_area(C); if(sa->spacetype==SPACE_VIEW3D) { ARegion *ar= CTX_wm_region(C); @@ -121,7 +135,10 @@ static int vp_poll(bContext *C) static int wp_poll(bContext *C) { - if(G.f & G_WEIGHTPAINT) { + Object *ob = CTX_data_active_object(C); + + if(ob && ob->mode & OB_MODE_WEIGHT_PAINT && + paint_brush(&CTX_data_tool_settings(C)->wpaint->paint)) { ScrArea *sa= CTX_wm_area(C); if(sa->spacetype==SPACE_VIEW3D) { ARegion *ar= CTX_wm_region(C); @@ -132,56 +149,6 @@ static int wp_poll(bContext *C) return 0; } - -/* Cursors */ -static void vp_drawcursor(bContext *C, int x, int y, void *customdata) -{ - ToolSettings *ts= CTX_data_tool_settings(C); - - glTranslatef((float)x, (float)y, 0.0f); - - glColor4ub(255, 255, 255, 128); - glEnable( GL_LINE_SMOOTH ); - glEnable(GL_BLEND); - glutil_draw_lined_arc(0.0, M_PI*2.0, ts->vpaint->brush->size, 40); - glDisable(GL_BLEND); - glDisable( GL_LINE_SMOOTH ); - - glTranslatef((float)-x, (float)-y, 0.0f); -} - -static void wp_drawcursor(bContext *C, int x, int y, void *customdata) -{ - ToolSettings *ts= CTX_data_tool_settings(C); - - glTranslatef((float)x, (float)y, 0.0f); - - glColor4ub(200, 200, 255, 128); - glEnable( GL_LINE_SMOOTH ); - glEnable(GL_BLEND); - glutil_draw_lined_arc(0.0, M_PI*2.0, ts->wpaint->brush->size, 40); - glDisable(GL_BLEND); - glDisable( GL_LINE_SMOOTH ); - - glTranslatef((float)-x, (float)-y, 0.0f); -} - -static void toggle_paint_cursor(bContext *C, int wpaint) -{ - ToolSettings *ts = CTX_data_scene(C)->toolsettings; - VPaint *vp = wpaint ? ts->wpaint : ts->vpaint; - - if(vp->paintcursor) { - WM_paint_cursor_end(CTX_wm_manager(C), vp->paintcursor); - vp->paintcursor = NULL; - } - else { - vp->paintcursor = wpaint ? - WM_paint_cursor_activate(CTX_wm_manager(C), wp_poll, wp_drawcursor, NULL) : - WM_paint_cursor_activate(CTX_wm_manager(C), vp_poll, vp_drawcursor, NULL); - } -} - static VPaint *new_vpaint(int wpaint) { VPaint *vp= MEM_callocN(sizeof(VPaint), "VPaint"); @@ -232,7 +199,8 @@ unsigned int rgba_to_mcol(float r, float g, float b, float a) static unsigned int vpaint_get_current_col(VPaint *vp) { - return rgba_to_mcol(vp->brush->rgb[0], vp->brush->rgb[1], vp->brush->rgb[2], 1.0f); + Brush *brush = paint_brush(&vp->paint); + return rgba_to_mcol(brush->rgb[0], brush->rgb[1], brush->rgb[2], 1.0f); } void do_shared_vertexcol(Mesh *me) @@ -362,34 +330,7 @@ static void copy_wpaint_prev (VPaint *wp, MDeformVert *dverts, int dcount) } -void clear_vpaint(Scene *scene) -{ - Mesh *me; - Object *ob; - unsigned int *to, paintcol; - int a; - - if((G.f & G_VERTEXPAINT)==0) return; - - ob= OBACT; - me= get_mesh(ob); - if(!ob || ob->id.lib) return; - - if(me==0 || me->mcol==0 || me->totface==0) return; - - paintcol= vpaint_get_current_col(scene->toolsettings->vpaint); - - to= (unsigned int *)me->mcol; - a= 4*me->totface; - while(a--) { - *to= paintcol; - to++; - } - DAG_object_flush_update(scene, ob, OB_RECALC_DATA); - -} - -void clear_vpaint_selectedfaces(Scene *scene) +void clear_vpaint(Scene *scene, int selected) { Mesh *me; MFace *mf; @@ -409,7 +350,7 @@ void clear_vpaint_selectedfaces(Scene *scene) mf = me->mface; mcol = (unsigned int*)me->mcol; for (i = 0; i < me->totface; i++, mf++, mcol+=4) { - if (mf->flag & ME_FACE_SEL) { + if (!selected || mf->flag & ME_FACE_SEL) { mcol[0] = paintcol; mcol[1] = paintcol; mcol[2] = paintcol; @@ -540,10 +481,10 @@ void vpaint_dogamma(Scene *scene) int a, temp; unsigned char *cp, gamtab[256]; - if((G.f & G_VERTEXPAINT)==0) return; - ob= OBACT; me= get_mesh(ob); + + if(!(ob->mode & OB_MODE_VERTEX_PAINT)) return; if(me==0 || me->mcol==0 || me->totface==0) return; igam= 1.0/vp->gamma; @@ -721,6 +662,7 @@ static unsigned int mcol_darken(unsigned int col1, unsigned int col2, int fac) static void vpaint_blend(VPaint *vp, unsigned int *col, unsigned int *colorig, unsigned int paintcol, int alpha) { + Brush *brush = paint_brush(&vp->paint); if(vp->mode==VP_MIX || vp->mode==VP_BLUR) *col= mcol_blend( *col, paintcol, alpha); else if(vp->mode==VP_ADD) *col= mcol_add( *col, paintcol, alpha); @@ -734,7 +676,7 @@ static void vpaint_blend(VPaint *vp, unsigned int *col, unsigned int *colorig, u unsigned int testcol=0, a; char *cp, *ct, *co; - alpha= (int)(255.0*vp->brush->alpha); + alpha= (int)(255.0*brush->alpha); if(vp->mode==VP_MIX || vp->mode==VP_BLUR) testcol= mcol_blend( *colorig, paintcol, alpha); else if(vp->mode==VP_ADD) testcol= mcol_add( *colorig, paintcol, alpha); @@ -798,8 +740,9 @@ static int sample_backbuf_area(ViewContext *vc, int *indexar, int totface, int x return tot; } -static int calc_vp_alpha_dl(VPaint *vp, ViewContext *vc, float vpimat[][3], float *vert_nor, short *mval) +static int calc_vp_alpha_dl(VPaint *vp, ViewContext *vc, float vpimat[][3], float *vert_nor, float *mval) { + Brush *brush = paint_brush(&vp->paint); float fac, dx, dy; int alpha; short vertco[2]; @@ -810,14 +753,14 @@ static int calc_vp_alpha_dl(VPaint *vp, ViewContext *vc, float vpimat[][3], floa dy= mval[1]-vertco[1]; fac= sqrt(dx*dx + dy*dy); - if(fac > vp->brush->size) return 0; + if(fac > brush->size) return 0; if(vp->flag & VP_HARD) alpha= 255; else - alpha= 255.0*vp->brush->alpha*(1.0-fac/vp->brush->size); + alpha= 255.0*brush->alpha*(1.0-fac/brush->size); } else { - alpha= 255.0*vp->brush->alpha; + alpha= 255.0*brush->alpha; } if(vp->flag & VP_NORMALS) { @@ -839,6 +782,7 @@ static int calc_vp_alpha_dl(VPaint *vp, ViewContext *vc, float vpimat[][3], floa static void wpaint_blend(VPaint *wp, MDeformWeight *dw, MDeformWeight *uw, float alpha, float paintval) { + Brush *brush = paint_brush(&wp->paint); if(dw==NULL || uw==NULL) return; @@ -864,7 +808,7 @@ static void wpaint_blend(VPaint *wp, MDeformWeight *dw, MDeformWeight *uw, float if((wp->flag & VP_SPRAY)==0) { float testw=0.0f; - alpha= wp->brush->alpha; + alpha= brush->alpha; if(wp->mode==VP_MIX || wp->mode==VP_BLUR) testw = paintval*alpha + uw->weight*(1.0-alpha); else if(wp->mode==VP_ADD) @@ -1092,12 +1036,12 @@ static int set_wpaint(bContext *C, wmOperator *op) /* toggle */ if(me && me->totface>=MAXINDEX) { error("Maximum number of faces: %d", MAXINDEX-1); - G.f &= ~G_WEIGHTPAINT; + ob->mode &= ~OB_MODE_WEIGHT_PAINT; return OPERATOR_CANCELLED; } - if(G.f & G_WEIGHTPAINT) G.f &= ~G_WEIGHTPAINT; - else G.f |= G_WEIGHTPAINT; + if(ob->mode & OB_MODE_WEIGHT_PAINT) ob->mode &= ~OB_MODE_WEIGHT_PAINT; + else ob->mode |= OB_MODE_WEIGHT_PAINT; /* Weightpaint works by overriding colors in mesh, @@ -1107,21 +1051,20 @@ static int set_wpaint(bContext *C, wmOperator *op) /* toggle */ */ DAG_object_flush_update(scene, ob, OB_RECALC_DATA); - if(G.f & G_WEIGHTPAINT) { + if(ob->mode & OB_MODE_WEIGHT_PAINT) { Object *par; if(wp==NULL) wp= scene->toolsettings->wpaint= new_vpaint(1); - brush_check_exists(&wp->brush); - - toggle_paint_cursor(C, 1); + paint_init(&wp->paint, PAINT_CURSOR_WEIGHT_PAINT); + paint_cursor_start(C, wp_poll); mesh_octree_table(ob, NULL, NULL, 's'); /* verify if active weight group is also active bone */ par= modifiers_isDeformedByArmature(ob); - if(par && (par->flag & OB_POSEMODE)) { + if(par && (par->mode & OB_MODE_POSE)) { bPoseChannel *pchan; for(pchan= par->pose->chanbase.first; pchan; pchan= pchan->next) if(pchan->bone->flag & BONE_ACTIVE) @@ -1131,9 +1074,6 @@ static int set_wpaint(bContext *C, wmOperator *op) /* toggle */ } } else { - if(wp) - toggle_paint_cursor(C, 1); - mesh_octree_table(ob, NULL, NULL, 'e'); } @@ -1174,8 +1114,12 @@ void PAINT_OT_weight_paint_toggle(wmOperatorType *ot) static int vpaint_radial_control_invoke(bContext *C, wmOperator *op, wmEvent *event) { - toggle_paint_cursor(C, 0); - brush_radial_control_invoke(op, CTX_data_scene(C)->toolsettings->vpaint->brush, 1); + Paint *p = paint_get_active(CTX_data_scene(C)); + Brush *brush = paint_brush(p); + + WM_paint_cursor_end(CTX_wm_manager(C), p->paint_cursor); + p->paint_cursor = NULL; + brush_radial_control_invoke(op, brush, 1); return WM_radial_control_invoke(C, op, event); } @@ -1183,19 +1127,24 @@ static int vpaint_radial_control_modal(bContext *C, wmOperator *op, wmEvent *eve { int ret = WM_radial_control_modal(C, op, event); if(ret != OPERATOR_RUNNING_MODAL) - toggle_paint_cursor(C, 0); + paint_cursor_start(C, vp_poll); return ret; } static int vpaint_radial_control_exec(bContext *C, wmOperator *op) { - return brush_radial_control_exec(op, CTX_data_scene(C)->toolsettings->vpaint->brush, 1); + Brush *brush = paint_brush(&CTX_data_scene(C)->toolsettings->vpaint->paint); + return brush_radial_control_exec(op, brush, 1); } static int wpaint_radial_control_invoke(bContext *C, wmOperator *op, wmEvent *event) { - toggle_paint_cursor(C, 1); - brush_radial_control_invoke(op, CTX_data_scene(C)->toolsettings->wpaint->brush, 1); + Paint *p = paint_get_active(CTX_data_scene(C)); + Brush *brush = paint_brush(p); + + WM_paint_cursor_end(CTX_wm_manager(C), p->paint_cursor); + p->paint_cursor = NULL; + brush_radial_control_invoke(op, brush, 1); return WM_radial_control_invoke(C, op, event); } @@ -1203,13 +1152,14 @@ static int wpaint_radial_control_modal(bContext *C, wmOperator *op, wmEvent *eve { int ret = WM_radial_control_modal(C, op, event); if(ret != OPERATOR_RUNNING_MODAL) - toggle_paint_cursor(C, 1); + paint_cursor_start(C, wp_poll); return ret; } static int wpaint_radial_control_exec(bContext *C, wmOperator *op) { - return brush_radial_control_exec(op, CTX_data_scene(C)->toolsettings->wpaint->brush, 1); + Brush *brush = paint_brush(&CTX_data_scene(C)->toolsettings->wpaint->paint); + return brush_radial_control_exec(op, brush, 1); } void PAINT_OT_weight_paint_radial_control(wmOperatorType *ot) @@ -1254,206 +1204,10 @@ struct WPaintData { float wpimat[3][3]; }; -static void wpaint_exit(bContext *C, wmOperator *op) -{ - ToolSettings *ts= CTX_data_tool_settings(C); - Object *ob= CTX_data_active_object(C); - struct WPaintData *wpd= op->customdata; - - if(wpd->vertexcosnos) - MEM_freeN(wpd->vertexcosnos); - MEM_freeN(wpd->indexar); - - /* frees prev buffer */ - copy_wpaint_prev(ts->wpaint, NULL, 0); - - /* and particles too */ - if(ob->particlesystem.first) { - ParticleSystem *psys; - int i; - - for(psys= ob->particlesystem.first; psys; psys= psys->next) { - for(i=0; i<PSYS_TOT_VG; i++) { - if(psys->vgroup[i]==ob->actdef) { - psys->recalc |= PSYS_RECALC_RESET; - break; - } - } - } - } - - DAG_object_flush_update(CTX_data_scene(C), ob, OB_RECALC_DATA); - - MEM_freeN(wpd); - op->customdata= NULL; -} - - -static int wpaint_modal(bContext *C, wmOperator *op, wmEvent *event) -{ - ToolSettings *ts= CTX_data_tool_settings(C); - VPaint *wp= ts->wpaint; - - switch(event->type) { - case LEFTMOUSE: - if(event->val==0) { /* release */ - wpaint_exit(C, op); - return OPERATOR_FINISHED; - } - /* pass on, first press gets painted too */ - - case MOUSEMOVE: - { - struct WPaintData *wpd= op->customdata; - ViewContext *vc= &wpd->vc; - Object *ob= vc->obact; - Mesh *me= ob->data; - float mat[4][4]; - float paintweight= ts->vgroup_weight; - int *indexar= wpd->indexar; - int totindex, index, alpha, totw; - short mval[2]; - - view3d_operator_needs_opengl(C); - - /* load projection matrix */ - wmMultMatrix(ob->obmat); - wmGetSingleMatrix(mat); - wmLoadMatrix(wpd->vc.rv3d->viewmat); - - MTC_Mat4SwapMat4(wpd->vc.rv3d->persmat, mat); - - mval[0]= event->x - vc->ar->winrct.xmin; - mval[1]= event->y - vc->ar->winrct.ymin; - - /* which faces are involved */ - if(wp->flag & VP_AREA) { - totindex= sample_backbuf_area(vc, indexar, me->totface, mval[0], mval[1], wp->brush->size); - } - else { - indexar[0]= view3d_sample_backbuf(vc, mval[0], mval[1]); - if(indexar[0]) totindex= 1; - else totindex= 0; - } - - if(wp->flag & VP_COLINDEX) { - for(index=0; index<totindex; index++) { - if(indexar[index] && indexar[index]<=me->totface) { - MFace *mface= ((MFace *)me->mface) + (indexar[index]-1); - - if(mface->mat_nr!=ob->actcol-1) { - indexar[index]= 0; - } - } - } - } - - if((G.f & G_FACESELECT) && me->mface) { - for(index=0; index<totindex; index++) { - if(indexar[index] && indexar[index]<=me->totface) { - MFace *mface= ((MFace *)me->mface) + (indexar[index]-1); - - if((mface->flag & ME_FACE_SEL)==0) { - indexar[index]= 0; - } - } - } - } - - /* make sure each vertex gets treated only once */ - /* and calculate filter weight */ - totw= 0; - if(wp->mode==VP_BLUR) - paintweight= 0.0f; - else - paintweight= ts->vgroup_weight; - - for(index=0; index<totindex; index++) { - if(indexar[index] && indexar[index]<=me->totface) { - MFace *mface= me->mface + (indexar[index]-1); - - (me->dvert+mface->v1)->flag= 1; - (me->dvert+mface->v2)->flag= 1; - (me->dvert+mface->v3)->flag= 1; - if(mface->v4) (me->dvert+mface->v4)->flag= 1; - - if(wp->mode==VP_BLUR) { - MDeformWeight *dw, *(*dw_func)(MDeformVert *, int) = verify_defweight; - - if(wp->flag & VP_ONLYVGROUP) - dw_func= get_defweight; - - dw= dw_func(me->dvert+mface->v1, ob->actdef-1); - if(dw) {paintweight+= dw->weight; totw++;} - dw= dw_func(me->dvert+mface->v2, ob->actdef-1); - if(dw) {paintweight+= dw->weight; totw++;} - dw= dw_func(me->dvert+mface->v3, ob->actdef-1); - if(dw) {paintweight+= dw->weight; totw++;} - if(mface->v4) { - dw= dw_func(me->dvert+mface->v4, ob->actdef-1); - if(dw) {paintweight+= dw->weight; totw++;} - } - } - } - } - - if(wp->mode==VP_BLUR) - paintweight/= (float)totw; - - for(index=0; index<totindex; index++) { - - if(indexar[index] && indexar[index]<=me->totface) { - MFace *mface= me->mface + (indexar[index]-1); - - if((me->dvert+mface->v1)->flag) { - alpha= calc_vp_alpha_dl(wp, vc, wpd->wpimat, wpd->vertexcosnos+6*mface->v1, mval); - if(alpha) { - do_weight_paint_vertex(wp, ob, mface->v1, alpha, paintweight, wpd->vgroup_mirror); - } - (me->dvert+mface->v1)->flag= 0; - } - - if((me->dvert+mface->v2)->flag) { - alpha= calc_vp_alpha_dl(wp, vc, wpd->wpimat, wpd->vertexcosnos+6*mface->v2, mval); - if(alpha) { - do_weight_paint_vertex(wp, ob, mface->v2, alpha, paintweight, wpd->vgroup_mirror); - } - (me->dvert+mface->v2)->flag= 0; - } - - if((me->dvert+mface->v3)->flag) { - alpha= calc_vp_alpha_dl(wp, vc, wpd->wpimat, wpd->vertexcosnos+6*mface->v3, mval); - if(alpha) { - do_weight_paint_vertex(wp, ob, mface->v3, alpha, paintweight, wpd->vgroup_mirror); - } - (me->dvert+mface->v3)->flag= 0; - } - - if((me->dvert+mface->v4)->flag) { - if(mface->v4) { - alpha= calc_vp_alpha_dl(wp, vc, wpd->wpimat, wpd->vertexcosnos+6*mface->v4, mval); - if(alpha) { - do_weight_paint_vertex(wp, ob, mface->v4, alpha, paintweight, wpd->vgroup_mirror); - } - (me->dvert+mface->v4)->flag= 0; - } - } - } - } - - MTC_Mat4SwapMat4(vc->rv3d->persmat, mat); - - DAG_object_flush_update(vc->scene, ob, OB_RECALC_DATA); - ED_region_tag_redraw(vc->ar); - } - } - - return OPERATOR_RUNNING_MODAL; -} - -static int wpaint_invoke(bContext *C, wmOperator *op, wmEvent *event) +static int wpaint_stroke_test_start(bContext *C, wmOperator *op, wmEvent *event) { Scene *scene= CTX_data_scene(C); + struct PaintStroke *stroke = op->customdata; ToolSettings *ts= CTX_data_tool_settings(C); VPaint *wp= ts->wpaint; Object *ob= CTX_data_active_object(C); @@ -1462,7 +1216,6 @@ static int wpaint_invoke(bContext *C, wmOperator *op, wmEvent *event) float mat[4][4], imat[4][4]; if(scene->obedit) return OPERATOR_CANCELLED; - // XXX if(multires_level1_test()) return; me= get_mesh(ob); if(me==NULL || me->totface==0) return OPERATOR_PASS_THROUGH; @@ -1471,8 +1224,9 @@ static int wpaint_invoke(bContext *C, wmOperator *op, wmEvent *event) if (!me->dvert) create_dverts(&me->id); - /* make customdata storage */ - op->customdata= wpd= MEM_callocN(sizeof(struct WPaintData), "WPaintData"); + /* make mode data storage */ + wpd= MEM_callocN(sizeof(struct WPaintData), "WPaintData"); + paint_stroke_set_mode_data(stroke, wpd); view3d_set_viewcontext(C, &wpd->vc); wpd->vgroup_mirror= -1; @@ -1544,11 +1298,203 @@ static int wpaint_invoke(bContext *C, wmOperator *op, wmEvent *event) } } - /* do paint once for click only paint */ - wpaint_modal(C, op, event); + return 1; +} + +static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, PointerRNA *itemptr) +{ + ToolSettings *ts= CTX_data_tool_settings(C); + VPaint *wp= ts->wpaint; + Brush *brush = paint_brush(&wp->paint); + struct WPaintData *wpd= paint_stroke_mode_data(stroke); + ViewContext *vc= &wpd->vc; + Object *ob= vc->obact; + Mesh *me= ob->data; + float mat[4][4]; + float paintweight= ts->vgroup_weight; + int *indexar= wpd->indexar; + int totindex, index, alpha, totw; + float mval[2]; + + view3d_operator_needs_opengl(C); + + /* load projection matrix */ + wmMultMatrix(ob->obmat); + wmGetSingleMatrix(mat); + wmLoadMatrix(wpd->vc.rv3d->viewmat); + + RNA_float_get_array(itemptr, "mouse", mval); + mval[0]-= vc->ar->winrct.xmin; + mval[1]-= vc->ar->winrct.ymin; + + MTC_Mat4SwapMat4(wpd->vc.rv3d->persmat, mat); + + /* which faces are involved */ + if(wp->flag & VP_AREA) { + totindex= sample_backbuf_area(vc, indexar, me->totface, mval[0], mval[1], brush->size); + } + else { + indexar[0]= view3d_sample_backbuf(vc, mval[0], mval[1]); + if(indexar[0]) totindex= 1; + else totindex= 0; + } + + if(wp->flag & VP_COLINDEX) { + for(index=0; index<totindex; index++) { + if(indexar[index] && indexar[index]<=me->totface) { + MFace *mface= ((MFace *)me->mface) + (indexar[index]-1); + + if(mface->mat_nr!=ob->actcol-1) { + indexar[index]= 0; + } + } + } + } + + if((G.f & G_FACESELECT) && me->mface) { + for(index=0; index<totindex; index++) { + if(indexar[index] && indexar[index]<=me->totface) { + MFace *mface= ((MFace *)me->mface) + (indexar[index]-1); + + if((mface->flag & ME_FACE_SEL)==0) { + indexar[index]= 0; + } + } + } + } + + /* make sure each vertex gets treated only once */ + /* and calculate filter weight */ + totw= 0; + if(wp->mode==VP_BLUR) + paintweight= 0.0f; + else + paintweight= ts->vgroup_weight; + + for(index=0; index<totindex; index++) { + if(indexar[index] && indexar[index]<=me->totface) { + MFace *mface= me->mface + (indexar[index]-1); + + (me->dvert+mface->v1)->flag= 1; + (me->dvert+mface->v2)->flag= 1; + (me->dvert+mface->v3)->flag= 1; + if(mface->v4) (me->dvert+mface->v4)->flag= 1; + + if(wp->mode==VP_BLUR) { + MDeformWeight *dw, *(*dw_func)(MDeformVert *, int) = verify_defweight; + + if(wp->flag & VP_ONLYVGROUP) + dw_func= get_defweight; + + dw= dw_func(me->dvert+mface->v1, ob->actdef-1); + if(dw) {paintweight+= dw->weight; totw++;} + dw= dw_func(me->dvert+mface->v2, ob->actdef-1); + if(dw) {paintweight+= dw->weight; totw++;} + dw= dw_func(me->dvert+mface->v3, ob->actdef-1); + if(dw) {paintweight+= dw->weight; totw++;} + if(mface->v4) { + dw= dw_func(me->dvert+mface->v4, ob->actdef-1); + if(dw) {paintweight+= dw->weight; totw++;} + } + } + } + } + + if(wp->mode==VP_BLUR) + paintweight/= (float)totw; + + for(index=0; index<totindex; index++) { + + if(indexar[index] && indexar[index]<=me->totface) { + MFace *mface= me->mface + (indexar[index]-1); + + if((me->dvert+mface->v1)->flag) { + alpha= calc_vp_alpha_dl(wp, vc, wpd->wpimat, wpd->vertexcosnos+6*mface->v1, mval); + if(alpha) { + do_weight_paint_vertex(wp, ob, mface->v1, alpha, paintweight, wpd->vgroup_mirror); + } + (me->dvert+mface->v1)->flag= 0; + } + + if((me->dvert+mface->v2)->flag) { + alpha= calc_vp_alpha_dl(wp, vc, wpd->wpimat, wpd->vertexcosnos+6*mface->v2, mval); + if(alpha) { + do_weight_paint_vertex(wp, ob, mface->v2, alpha, paintweight, wpd->vgroup_mirror); + } + (me->dvert+mface->v2)->flag= 0; + } + + if((me->dvert+mface->v3)->flag) { + alpha= calc_vp_alpha_dl(wp, vc, wpd->wpimat, wpd->vertexcosnos+6*mface->v3, mval); + if(alpha) { + do_weight_paint_vertex(wp, ob, mface->v3, alpha, paintweight, wpd->vgroup_mirror); + } + (me->dvert+mface->v3)->flag= 0; + } + + if((me->dvert+mface->v4)->flag) { + if(mface->v4) { + alpha= calc_vp_alpha_dl(wp, vc, wpd->wpimat, wpd->vertexcosnos+6*mface->v4, mval); + if(alpha) { + do_weight_paint_vertex(wp, ob, mface->v4, alpha, paintweight, wpd->vgroup_mirror); + } + (me->dvert+mface->v4)->flag= 0; + } + } + } + } + + MTC_Mat4SwapMat4(vc->rv3d->persmat, mat); + + DAG_object_flush_update(vc->scene, ob, OB_RECALC_DATA); + ED_region_tag_redraw(vc->ar); +} + +static void wpaint_stroke_done(bContext *C, struct PaintStroke *stroke) +{ + ToolSettings *ts= CTX_data_tool_settings(C); + Object *ob= CTX_data_active_object(C); + struct WPaintData *wpd= paint_stroke_mode_data(stroke); + + if(wpd->vertexcosnos) + MEM_freeN(wpd->vertexcosnos); + MEM_freeN(wpd->indexar); + + /* frees prev buffer */ + copy_wpaint_prev(ts->wpaint, NULL, 0); + + /* and particles too */ + if(ob->particlesystem.first) { + ParticleSystem *psys; + int i; + + for(psys= ob->particlesystem.first; psys; psys= psys->next) { + for(i=0; i<PSYS_TOT_VG; i++) { + if(psys->vgroup[i]==ob->actdef) { + psys->recalc |= PSYS_RECALC_RESET; + break; + } + } + } + } + + DAG_object_flush_update(CTX_data_scene(C), ob, OB_RECALC_DATA); + + MEM_freeN(wpd); +} + + +static int wpaint_invoke(bContext *C, wmOperator *op, wmEvent *event) +{ + + op->customdata = paint_stroke_new(C, wpaint_stroke_test_start, + wpaint_stroke_update_step, + wpaint_stroke_done); /* add modal handler */ WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op); + + op->type->modal(C, op, event); return OPERATOR_RUNNING_MODAL; } @@ -1562,13 +1508,14 @@ void PAINT_OT_weight_paint(wmOperatorType *ot) /* api callbacks */ ot->invoke= wpaint_invoke; - ot->modal= wpaint_modal; + ot->modal= paint_stroke_modal; /* ot->exec= vpaint_exec; <-- needs stroke property */ ot->poll= wp_poll; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING; - + + RNA_def_collection_runtime(ot->srna, "stroke", &RNA_OperatorStrokeElement, "Stroke", ""); } /* ************ set / clear vertex paint mode ********** */ @@ -1584,40 +1531,35 @@ static int set_vpaint(bContext *C, wmOperator *op) /* toggle */ me= get_mesh(ob); if(me==NULL || object_data_is_libdata(ob)) { - G.f &= ~G_VERTEXPAINT; + ob->mode &= ~OB_MODE_VERTEX_PAINT; return OPERATOR_PASS_THROUGH; } if(me && me->totface>=MAXINDEX) { error("Maximum number of faces: %d", MAXINDEX-1); - G.f &= ~G_VERTEXPAINT; + ob->mode &= ~OB_MODE_VERTEX_PAINT; return OPERATOR_FINISHED; } if(me && me->mcol==NULL) make_vertexcol(scene, 0); /* toggle: end vpaint */ - if(G.f & G_VERTEXPAINT) { + if(ob->mode & OB_MODE_VERTEX_PAINT) { - G.f &= ~G_VERTEXPAINT; - - if(vp) { - toggle_paint_cursor(C, 0); - vp->paintcursor= NULL; - } + ob->mode &= ~OB_MODE_VERTEX_PAINT; } else { - - G.f |= G_VERTEXPAINT; + ob->mode |= OB_MODE_VERTEX_PAINT; /* Turn off weight painting */ - if (G.f & G_WEIGHTPAINT) + if (ob->mode & OB_MODE_WEIGHT_PAINT) set_wpaint(C, op); if(vp==NULL) vp= scene->toolsettings->vpaint= new_vpaint(0); - toggle_paint_cursor(C, 0); - brush_check_exists(&scene->toolsettings->vpaint->brush); + paint_cursor_start(C, vp_poll); + + paint_init(&vp->paint, PAINT_CURSOR_VERTEX_PAINT); } if (me) @@ -1676,177 +1618,175 @@ struct VPaintData { float vpimat[3][3]; }; -static void vpaint_exit(bContext *C, wmOperator *op) +static int vpaint_stroke_test_start(bContext *C, struct wmOperator *op, wmEvent *event) { ToolSettings *ts= CTX_data_tool_settings(C); - struct VPaintData *vpd= op->customdata; + struct PaintStroke *stroke = op->customdata; + VPaint *vp= ts->vpaint; + struct VPaintData *vpd; + Object *ob= CTX_data_active_object(C); + Mesh *me; + float mat[4][4], imat[4][4]; + + /* context checks could be a poll() */ + me= get_mesh(ob); + if(me==NULL || me->totface==0) return OPERATOR_PASS_THROUGH; - if(vpd->vertexcosnos) - MEM_freeN(vpd->vertexcosnos); - MEM_freeN(vpd->indexar); + if(me->mcol==NULL) make_vertexcol(CTX_data_scene(C), 0); + if(me->mcol==NULL) return OPERATOR_CANCELLED; - /* frees prev buffer */ - copy_vpaint_prev(ts->vpaint, NULL, 0); + /* make mode data storage */ + vpd= MEM_callocN(sizeof(struct VPaintData), "VPaintData"); + paint_stroke_set_mode_data(stroke, vpd); + view3d_set_viewcontext(C, &vpd->vc); - MEM_freeN(vpd); - op->customdata= NULL; + vpd->vertexcosnos= mesh_get_mapped_verts_nors(vpd->vc.scene, ob); + vpd->indexar= get_indexarray(); + vpd->paintcol= vpaint_get_current_col(vp); + + /* for filtering */ + copy_vpaint_prev(vp, (unsigned int *)me->mcol, me->totface); + + /* some old cruft to sort out later */ + Mat4MulMat4(mat, ob->obmat, vpd->vc.rv3d->viewmat); + Mat4Invert(imat, mat); + Mat3CpyMat4(vpd->vpimat, imat); + + return 1; } -static int vpaint_modal(bContext *C, wmOperator *op, wmEvent *event) +static void vpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, PointerRNA *itemptr) { ToolSettings *ts= CTX_data_tool_settings(C); + struct VPaintData *vpd = paint_stroke_mode_data(stroke); VPaint *vp= ts->vpaint; - - switch(event->type) { - case LEFTMOUSE: - if(event->val==0) { /* release */ - vpaint_exit(C, op); - return OPERATOR_FINISHED; - } - /* pass on, first press gets painted too */ - - case MOUSEMOVE: - { - struct VPaintData *vpd= op->customdata; - ViewContext *vc= &vpd->vc; - Object *ob= vc->obact; - Mesh *me= ob->data; - float mat[4][4]; - int *indexar= vpd->indexar; - int totindex, index; - short mval[2]; + Brush *brush = paint_brush(&vp->paint); + ViewContext *vc= &vpd->vc; + Object *ob= vc->obact; + Mesh *me= ob->data; + float mat[4][4]; + int *indexar= vpd->indexar; + int totindex, index; + float mval[2]; + + RNA_float_get_array(itemptr, "mouse", mval); - view3d_operator_needs_opengl(C); + view3d_operator_needs_opengl(C); - /* load projection matrix */ - wmMultMatrix(ob->obmat); - wmGetSingleMatrix(mat); - wmLoadMatrix(vc->rv3d->viewmat); + /* load projection matrix */ + wmMultMatrix(ob->obmat); + wmGetSingleMatrix(mat); + wmLoadMatrix(vc->rv3d->viewmat); + + mval[0]-= vc->ar->winrct.xmin; + mval[1]-= vc->ar->winrct.ymin; + - mval[0]= event->x - vc->ar->winrct.xmin; - mval[1]= event->y - vc->ar->winrct.ymin; - - /* which faces are involved */ - if(vp->flag & VP_AREA) { - totindex= sample_backbuf_area(vc, indexar, me->totface, mval[0], mval[1], vp->brush->size); - } - else { - indexar[0]= view3d_sample_backbuf(vc, mval[0], mval[1]); - if(indexar[0]) totindex= 1; - else totindex= 0; - } + /* which faces are involved */ + if(vp->flag & VP_AREA) { + totindex= sample_backbuf_area(vc, indexar, me->totface, mval[0], mval[1], brush->size); + } + else { + indexar[0]= view3d_sample_backbuf(vc, mval[0], mval[1]); + if(indexar[0]) totindex= 1; + else totindex= 0; + } - MTC_Mat4SwapMat4(vc->rv3d->persmat, mat); + MTC_Mat4SwapMat4(vc->rv3d->persmat, mat); - if(vp->flag & VP_COLINDEX) { - for(index=0; index<totindex; index++) { - if(indexar[index] && indexar[index]<=me->totface) { - MFace *mface= ((MFace *)me->mface) + (indexar[index]-1); + if(vp->flag & VP_COLINDEX) { + for(index=0; index<totindex; index++) { + if(indexar[index] && indexar[index]<=me->totface) { + MFace *mface= ((MFace *)me->mface) + (indexar[index]-1); - if(mface->mat_nr!=ob->actcol-1) { - indexar[index]= 0; - } - } + if(mface->mat_nr!=ob->actcol-1) { + indexar[index]= 0; } - } - if((G.f & G_FACESELECT) && me->mface) { - for(index=0; index<totindex; index++) { - if(indexar[index] && indexar[index]<=me->totface) { - MFace *mface= ((MFace *)me->mface) + (indexar[index]-1); + } + } + } + if((G.f & G_FACESELECT) && me->mface) { + for(index=0; index<totindex; index++) { + if(indexar[index] && indexar[index]<=me->totface) { + MFace *mface= ((MFace *)me->mface) + (indexar[index]-1); - if((mface->flag & ME_FACE_SEL)==0) - indexar[index]= 0; - } - } - } + if((mface->flag & ME_FACE_SEL)==0) + indexar[index]= 0; + } + } + } - for(index=0; index<totindex; index++) { + for(index=0; index<totindex; index++) { - if(indexar[index] && indexar[index]<=me->totface) { - MFace *mface= ((MFace *)me->mface) + (indexar[index]-1); - unsigned int *mcol= ( (unsigned int *)me->mcol) + 4*(indexar[index]-1); - unsigned int *mcolorig= ( (unsigned int *)vp->vpaint_prev) + 4*(indexar[index]-1); - int alpha; + if(indexar[index] && indexar[index]<=me->totface) { + MFace *mface= ((MFace *)me->mface) + (indexar[index]-1); + unsigned int *mcol= ( (unsigned int *)me->mcol) + 4*(indexar[index]-1); + unsigned int *mcolorig= ( (unsigned int *)vp->vpaint_prev) + 4*(indexar[index]-1); + int alpha; - if(vp->mode==VP_BLUR) { - unsigned int fcol1= mcol_blend( mcol[0], mcol[1], 128); - if(mface->v4) { - unsigned int fcol2= mcol_blend( mcol[2], mcol[3], 128); - vpd->paintcol= mcol_blend( fcol1, fcol2, 128); - } - else { - vpd->paintcol= mcol_blend( mcol[2], fcol1, 170); - } + if(vp->mode==VP_BLUR) { + unsigned int fcol1= mcol_blend( mcol[0], mcol[1], 128); + if(mface->v4) { + unsigned int fcol2= mcol_blend( mcol[2], mcol[3], 128); + vpd->paintcol= mcol_blend( fcol1, fcol2, 128); + } + else { + vpd->paintcol= mcol_blend( mcol[2], fcol1, 170); + } - } + } - alpha= calc_vp_alpha_dl(vp, vc, vpd->vpimat, vpd->vertexcosnos+6*mface->v1, mval); - if(alpha) vpaint_blend(vp, mcol, mcolorig, vpd->paintcol, alpha); + alpha= calc_vp_alpha_dl(vp, vc, vpd->vpimat, vpd->vertexcosnos+6*mface->v1, mval); + if(alpha) vpaint_blend(vp, mcol, mcolorig, vpd->paintcol, alpha); - alpha= calc_vp_alpha_dl(vp, vc, vpd->vpimat, vpd->vertexcosnos+6*mface->v2, mval); - if(alpha) vpaint_blend(vp, mcol+1, mcolorig+1, vpd->paintcol, alpha); + alpha= calc_vp_alpha_dl(vp, vc, vpd->vpimat, vpd->vertexcosnos+6*mface->v2, mval); + if(alpha) vpaint_blend(vp, mcol+1, mcolorig+1, vpd->paintcol, alpha); - alpha= calc_vp_alpha_dl(vp, vc, vpd->vpimat, vpd->vertexcosnos+6*mface->v3, mval); - if(alpha) vpaint_blend(vp, mcol+2, mcolorig+2, vpd->paintcol, alpha); + alpha= calc_vp_alpha_dl(vp, vc, vpd->vpimat, vpd->vertexcosnos+6*mface->v3, mval); + if(alpha) vpaint_blend(vp, mcol+2, mcolorig+2, vpd->paintcol, alpha); - if(mface->v4) { - alpha= calc_vp_alpha_dl(vp, vc, vpd->vpimat, vpd->vertexcosnos+6*mface->v4, mval); - if(alpha) vpaint_blend(vp, mcol+3, mcolorig+3, vpd->paintcol, alpha); - } - } + if(mface->v4) { + alpha= calc_vp_alpha_dl(vp, vc, vpd->vpimat, vpd->vertexcosnos+6*mface->v4, mval); + if(alpha) vpaint_blend(vp, mcol+3, mcolorig+3, vpd->paintcol, alpha); } + } + } - MTC_Mat4SwapMat4(vc->rv3d->persmat, mat); + MTC_Mat4SwapMat4(vc->rv3d->persmat, mat); - do_shared_vertexcol(me); + do_shared_vertexcol(me); - ED_region_tag_redraw(vc->ar); + ED_region_tag_redraw(vc->ar); - DAG_object_flush_update(vc->scene, ob, OB_RECALC_DATA); - } - break; - } - - return OPERATOR_RUNNING_MODAL; + DAG_object_flush_update(vc->scene, ob, OB_RECALC_DATA); } -static int vpaint_invoke(bContext *C, wmOperator *op, wmEvent *event) +static void vpaint_stroke_done(bContext *C, struct PaintStroke *stroke) { ToolSettings *ts= CTX_data_tool_settings(C); - VPaint *vp= ts->vpaint; - struct VPaintData *vpd; - Object *ob= CTX_data_active_object(C); - Mesh *me; - float mat[4][4], imat[4][4]; + struct VPaintData *vpd= paint_stroke_mode_data(stroke); - /* context checks could be a poll() */ - me= get_mesh(ob); - if(me==NULL || me->totface==0) return OPERATOR_PASS_THROUGH; - - if(me->mcol==NULL) make_vertexcol(CTX_data_scene(C), 0); - if(me->mcol==NULL) return OPERATOR_CANCELLED; - - /* make customdata storage */ - op->customdata= vpd= MEM_callocN(sizeof(struct VPaintData), "VPaintData"); - view3d_set_viewcontext(C, &vpd->vc); - - vpd->vertexcosnos= mesh_get_mapped_verts_nors(vpd->vc.scene, ob); - vpd->indexar= get_indexarray(); - vpd->paintcol= vpaint_get_current_col(vp); + if(vpd->vertexcosnos) + MEM_freeN(vpd->vertexcosnos); + MEM_freeN(vpd->indexar); - /* for filtering */ - copy_vpaint_prev(vp, (unsigned int *)me->mcol, me->totface); + /* frees prev buffer */ + copy_vpaint_prev(ts->vpaint, NULL, 0); - /* some old cruft to sort out later */ - Mat4MulMat4(mat, ob->obmat, vpd->vc.rv3d->viewmat); - Mat4Invert(imat, mat); - Mat3CpyMat4(vpd->vpimat, imat); + MEM_freeN(vpd); +} + +static int vpaint_invoke(bContext *C, wmOperator *op, wmEvent *event) +{ - /* do paint once for click only paint */ - vpaint_modal(C, op, event); + op->customdata = paint_stroke_new(C, vpaint_stroke_test_start, + vpaint_stroke_update_step, + vpaint_stroke_done); /* add modal handler */ WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op); + + op->type->modal(C, op, event); return OPERATOR_RUNNING_MODAL; } @@ -1859,11 +1799,13 @@ void PAINT_OT_vertex_paint(wmOperatorType *ot) /* api callbacks */ ot->invoke= vpaint_invoke; - ot->modal= vpaint_modal; + ot->modal= paint_stroke_modal; /* ot->exec= vpaint_exec; <-- needs stroke property */ ot->poll= vp_poll; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING; + + RNA_def_collection_runtime(ot->srna, "stroke", &RNA_OperatorStrokeElement, "Stroke", ""); } diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 8cca135d99d..ba48bebce78 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -64,6 +64,7 @@ #include "BKE_mesh.h" #include "BKE_modifier.h" #include "BKE_multires.h" +#include "BKE_paint.h" #include "BKE_sculpt.h" #include "BKE_texture.h" #include "BKE_utildefines.h" @@ -79,6 +80,7 @@ #include "ED_space_api.h" #include "ED_util.h" #include "ED_view3d.h" +#include "paint_intern.h" #include "sculpt_intern.h" #include "RNA_access.h" @@ -124,29 +126,27 @@ typedef enum StrokeFlags { */ typedef struct StrokeCache { /* Invariants */ - float radius; + float initial_radius; float scale[3]; int flag; float clip_tolerance[3]; - int initial_mouse[2]; + float initial_mouse[2]; float depth; /* Variants */ + float radius; float true_location[3]; float location[3]; float flip; float pressure; - int mouse[2]; + float mouse[2]; /* The rest is temporary storage that isn't saved as a property */ int first_time; /* Beginning of stroke may do some things special */ - ViewContext vc; bglMats *mats; - float *layer_disps; /* Displacements for each vertex */ - float (*mesh_store)[3]; /* Copy of the mesh vertices' locations */ short (*orig_norms)[3]; /* Copy of the mesh vertices' normals */ float (*face_norms)[3]; /* Copy of the mesh faces' normals */ float rotation; /* Texture rotation (radians) for anchored and rake modes */ @@ -178,19 +178,6 @@ typedef struct ProjVert { * Simple functions to get data from the GL */ -/* Uses window coordinates (x,y) and depth component z to find a point in - modelspace */ -static void unproject(bglMats *mats, float out[3], const short x, const short y, const float z) -{ - double ux, uy, uz; - - gluUnProject(x,y,z, mats->modelview, mats->projection, - (GLint *)mats->viewport, &ux, &uy, &uz ); - out[0] = ux; - out[1] = uy; - out[2] = uz; -} - /* Convert a point in model coordinates to 2D screen coordinates. */ static void projectf(bglMats *mats, const float v[3], float p[2]) { @@ -215,36 +202,23 @@ static void project(bglMats *mats, const float v[3], short p[2]) * */ -/* Return modified brush size. Uses current tablet pressure (if available) to - shrink the brush. Skipped for grab brush because only the first mouse down - size is used, which is small if the user has just touched the pen to the - tablet */ -static char brush_size(Sculpt *sd) -{ - float size= sd->brush->size; - - if((sd->brush->sculpt_tool != SCULPT_TOOL_GRAB) && (sd->brush->flag & BRUSH_SIZE_PRESSURE)) - size *= sd->session->cache->pressure; - - return size; -} - /* Return modified brush strength. Includes the direction of the brush, positive values pull vertices, negative values push. Uses tablet pressure and a special multiplier found experimentally to scale the strength factor. */ static float brush_strength(Sculpt *sd, StrokeCache *cache) { + Brush *brush = paint_brush(&sd->paint); /* Primary strength input; square it to make lower values more sensitive */ - float alpha = sd->brush->alpha * sd->brush->alpha; + float alpha = brush->alpha * brush->alpha; - float dir= sd->brush->flag & BRUSH_DIR_IN ? -1 : 1; + float dir= brush->flag & BRUSH_DIR_IN ? -1 : 1; float pressure= 1; float flip= cache->flip ? -1:1; - if(sd->brush->flag & BRUSH_ALPHA_PRESSURE) + if(brush->flag & BRUSH_ALPHA_PRESSURE) pressure *= cache->pressure; - switch(sd->brush->sculpt_tool){ + switch(brush->sculpt_tool){ case SCULPT_TOOL_DRAW: case SCULPT_TOOL_INFLATE: case SCULPT_TOOL_CLAY: @@ -263,7 +237,7 @@ static float brush_strength(Sculpt *sd, StrokeCache *cache) } /* Handles clipping against a mirror modifier and SCULPT_LOCK axis flags */ -static void sculpt_clip(Sculpt *sd, float *co, const float val[3]) +static void sculpt_clip(Sculpt *sd, SculptSession *ss, float *co, const float val[3]) { int i; @@ -271,7 +245,7 @@ static void sculpt_clip(Sculpt *sd, float *co, const float val[3]) if(sd->flags & (SCULPT_LOCK_X << i)) continue; - if((sd->session->cache->flag & (CLIP_X << i)) && (fabs(co[i]) <= sd->session->cache->clip_tolerance[i])) + if((ss->cache->flag & (CLIP_X << i)) && (fabs(co[i]) <= ss->cache->clip_tolerance[i])) co[i]= 0.0f; else co[i]= val[i]; @@ -293,23 +267,24 @@ static void add_norm_if(float view_vec[3], float out[3], float out_flip[3], cons /* Currently only for the draw brush; finds average normal for all active vertices */ -static void calc_area_normal(Sculpt *sd, float out[3], const ListBase* active_verts) +static void calc_area_normal(Sculpt *sd, SculptSession *ss, float out[3], const ListBase* active_verts) { - StrokeCache *cache = sd->session->cache; + Brush *brush = paint_brush(&sd->paint); + StrokeCache *cache = ss->cache; ActiveData *node = active_verts->first; - const int view = 0; /* XXX: should probably be a flag, not number: sd->brush_type==SCULPT_TOOL_DRAW ? sculptmode_brush()->view : 0; */ + const int view = 0; /* XXX: should probably be a flag, not number: brush_type==SCULPT_TOOL_DRAW ? sculptmode_brush()->view : 0; */ float out_flip[3]; float *out_dir = cache->view_normal_symmetry; out[0]=out[1]=out[2] = out_flip[0]=out_flip[1]=out_flip[2] = 0; - if(sd->brush->flag & BRUSH_ANCHORED) { + if(brush->flag & BRUSH_ANCHORED) { for(; node; node = node->next) add_norm_if(out_dir, out, out_flip, cache->orig_norms[node->Index]); } else { for(; node; node = node->next) - add_norm_if(out_dir, out, out_flip, sd->session->mvert[node->Index].no); + add_norm_if(out_dir, out, out_flip, ss->mvert[node->Index].no); } if (out[0]==0.0 && out[1]==0.0 && out[2]==0.0) { @@ -332,7 +307,7 @@ static void do_draw_brush(Sculpt *sd, SculptSession *ss, const ListBase* active_ float area_normal[3]; ActiveData *node= active_verts->first; - calc_area_normal(sd, area_normal, active_verts); + calc_area_normal(sd, ss, area_normal, active_verts); while(node){ float *co= ss->mvert[node->Index].co; @@ -341,7 +316,7 @@ static void do_draw_brush(Sculpt *sd, SculptSession *ss, const ListBase* active_ co[1]+area_normal[1]*ss->cache->radius*node->Fade*ss->cache->scale[1], co[2]+area_normal[2]*ss->cache->radius*node->Fade*ss->cache->scale[2]}; - sculpt_clip(sd, co, val); + sculpt_clip(sd, ss, co, val); node= node->next; } @@ -391,37 +366,37 @@ static void neighbor_average(SculptSession *ss, float avg[3], const int vert) VecCopyf(avg, ss->mvert[vert].co); } -static void do_smooth_brush(Sculpt *s, const ListBase* active_verts) +static void do_smooth_brush(Sculpt *s, SculptSession *ss, const ListBase* active_verts) { ActiveData *node= active_verts->first; int i; for(i = 0; i < 2; ++i) { while(node){ - float *co= s->session->mvert[node->Index].co; + float *co= ss->mvert[node->Index].co; float avg[3], val[3]; - neighbor_average(s->session, avg, node->Index); + neighbor_average(ss, avg, node->Index); val[0] = co[0]+(avg[0]-co[0])*node->Fade; val[1] = co[1]+(avg[1]-co[1])*node->Fade; val[2] = co[2]+(avg[2]-co[2])*node->Fade; - sculpt_clip(s, co, val); + sculpt_clip(s, ss, co, val); node= node->next; } } } -static void do_pinch_brush(Sculpt *s, const ListBase* active_verts) +static void do_pinch_brush(Sculpt *s, SculptSession *ss, const ListBase* active_verts) { ActiveData *node= active_verts->first; while(node) { - float *co= s->session->mvert[node->Index].co; - const float val[3]= {co[0]+(s->session->cache->location[0]-co[0])*node->Fade, - co[1]+(s->session->cache->location[1]-co[1])*node->Fade, - co[2]+(s->session->cache->location[2]-co[2])*node->Fade}; - sculpt_clip(s, co, val); + float *co= ss->mvert[node->Index].co; + const float val[3]= {co[0]+(ss->cache->location[0]-co[0])*node->Fade, + co[1]+(ss->cache->location[1]-co[1])*node->Fade, + co[2]+(ss->cache->location[2]-co[2])*node->Fade}; + sculpt_clip(s, ss, co, val); node= node->next; } } @@ -440,7 +415,7 @@ static void do_grab_brush(Sculpt *sd, SculptSession *ss) VecCopyf(add, grab_delta); VecMulf(add, node->Fade); VecAddf(add, add, co); - sculpt_clip(sd, co, add); + sculpt_clip(sd, ss, co, add); node= node->next; } @@ -456,10 +431,10 @@ static void do_layer_brush(Sculpt *sd, SculptSession *ss, const ListBase *active if(ss->cache->flip) lim = -lim; - calc_area_normal(sd, area_normal, active_verts); + calc_area_normal(sd, ss, area_normal, active_verts); while(node){ - float *disp= &ss->cache->layer_disps[node->Index]; + float *disp= &ss->layer_disps[node->Index]; float *co= ss->mvert[node->Index].co; float val[3]; @@ -469,20 +444,19 @@ static void do_layer_brush(Sculpt *sd, SculptSession *ss, const ListBase *active if((lim < 0 && *disp < lim) || (lim > 0 && *disp > lim)) *disp = lim; - val[0] = ss->cache->mesh_store[node->Index][0]+area_normal[0] * *disp*ss->cache->scale[0]; - val[1] = ss->cache->mesh_store[node->Index][1]+area_normal[1] * *disp*ss->cache->scale[1]; - val[2] = ss->cache->mesh_store[node->Index][2]+area_normal[2] * *disp*ss->cache->scale[2]; + val[0] = ss->mesh_co_orig[node->Index][0]+area_normal[0] * *disp*ss->cache->scale[0]; + val[1] = ss->mesh_co_orig[node->Index][1]+area_normal[1] * *disp*ss->cache->scale[1]; + val[2] = ss->mesh_co_orig[node->Index][2]+area_normal[2] * *disp*ss->cache->scale[2]; - sculpt_clip(sd, co, val); + sculpt_clip(sd, ss, co, val); node= node->next; } } -static void do_inflate_brush(Sculpt *s, const ListBase *active_verts) +static void do_inflate_brush(Sculpt *s, SculptSession *ss, const ListBase *active_verts) { ActiveData *node= active_verts->first; - SculptSession *ss = s->session; float add[3]; while(node) { @@ -498,7 +472,7 @@ static void do_inflate_brush(Sculpt *s, const ListBase *active_verts) add[2]*= ss->cache->scale[2]; VecAddf(add, add, co); - sculpt_clip(s, co, add); + sculpt_clip(s, ss, co, add); node= node->next; } @@ -527,46 +501,86 @@ static void calc_flatten_center(SculptSession *ss, ActiveData *node, float co[3] VecMulf(co, 1.0f / FLATTEN_SAMPLE_SIZE); } +/* Projects a point onto a plane along the plane's normal */ +static void point_plane_project(float intr[3], float co[3], float plane_normal[3], float plane_center[3]) +{ + float p1[3], sub1[3], sub2[3]; + + /* Find the intersection between squash-plane and vertex (along the area normal) */ + VecSubf(p1, co, plane_normal); + VecSubf(sub1, plane_center, p1); + VecSubf(sub2, co, p1); + VecSubf(intr, co, p1); + VecMulf(intr, Inpf(plane_normal, sub1) / Inpf(plane_normal, sub2)); + VecAddf(intr, intr, p1); +} + +static int plane_point_side(float co[3], float plane_normal[3], float plane_center[3], int flip) +{ + float delta[3]; + float d; + + VecSubf(delta, co, plane_center); + d = Inpf(plane_normal, delta); + + if(flip) + d = -d; + + return d <= 0.0f; +} + static void do_flatten_clay_brush(Sculpt *sd, SculptSession *ss, const ListBase *active_verts, int clay) { ActiveData *node= active_verts->first; /* area_normal and cntr define the plane towards which vertices are squashed */ float area_normal[3]; - float cntr[3]; + float cntr[3], cntr2[3], bstr = 0; + int flip = 0; - calc_area_normal(sd, area_normal, active_verts); + calc_area_normal(sd, ss, area_normal, active_verts); calc_flatten_center(ss, node, cntr); + if(clay) { + bstr= brush_strength(sd, ss->cache); + /* Limit clay application to here */ + cntr2[0]=cntr[0]+area_normal[0]*bstr*ss->cache->scale[0]; + cntr2[1]=cntr[1]+area_normal[1]*bstr*ss->cache->scale[1]; + cntr2[2]=cntr[2]+area_normal[2]*bstr*ss->cache->scale[2]; + flip = bstr < 0; + } + while(node){ float *co= ss->mvert[node->Index].co; - float p1[3], sub1[3], sub2[3], intr[3], val[3]; - - /* Find the intersection between squash-plane and vertex (along the area normal) */ - VecSubf(p1, co, area_normal); - VecSubf(sub1, cntr, p1); - VecSubf(sub2, co, p1); - VecSubf(intr, co, p1); - VecMulf(intr, Inpf(area_normal, sub1) / Inpf(area_normal, sub2)); - VecAddf(intr, intr, p1); - - VecSubf(val, intr, co); - VecMulf(val, fabs(node->Fade)); - VecAddf(val, val, co); + float intr[3], val[3]; - if(clay) { - /* Clay brush displaces after flattening */ - float tmp[3]; - VecCopyf(tmp, area_normal); - VecMulf(tmp, ss->cache->radius * node->Fade * 0.1); - VecAddf(val, val, tmp); - } + if(!clay || plane_point_side(co, area_normal, cntr2, flip)) { + /* Find the intersection between squash-plane and vertex (along the area normal) */ + point_plane_project(intr, co, area_normal, cntr); + + VecSubf(val, intr, co); - sculpt_clip(sd, co, val); + if(clay) { + if(bstr > FLT_EPSILON) + VecMulf(val, node->Fade / bstr); + else + VecMulf(val, node->Fade); + /* Clay displacement */ + val[0]+=area_normal[0] * ss->cache->scale[0]*node->Fade; + val[1]+=area_normal[1] * ss->cache->scale[1]*node->Fade; + val[2]+=area_normal[2] * ss->cache->scale[2]*node->Fade; + } + else + VecMulf(val, fabs(node->Fade)); + + VecAddf(val, val, co); + + sculpt_clip(sd, ss, co, val); + } node= node->next; } } - + /* Uses symm to selectively flip any axis of a coordinate. */ static void flip_coord(float out[3], float in[3], const char symm) { @@ -622,35 +636,29 @@ static float get_texcache_pixel_bilinear(const SculptSession *ss, float u, float } /* Return a multiplier for brush strength on a particular vertex. */ -static float tex_strength(Sculpt *sd, float *point, const float len) +static float tex_strength(Sculpt *sd, SculptSession *ss, float *point, const float len) { - SculptSession *ss= sd->session; - Brush *br = sd->brush; + Brush *br = paint_brush(&sd->paint); + MTex *tex = NULL; float avg= 1; - if(br->texact==-1 || !br->mtex[br->texact]) + if(br->texact >= 0) + tex = br->mtex[br->texact]; + + if(!tex) { avg= 1; - else if(br->tex_mode==BRUSH_TEX_3D) { - /* Get strength by feeding the vertex location directly - into a texture */ + } + else if(tex->brush_map_mode == MTEX_MAP_MODE_3D) { float jnk; - const float factor= 0.01; - MTex mtex; - memset(&mtex,0,sizeof(MTex)); - mtex.tex= br->mtex[br->texact]->tex; - mtex.projx= 1; - mtex.projy= 2; - mtex.projz= 3; - VecCopyf(mtex.size, br->mtex[br->texact]->size); - VecMulf(mtex.size, factor); - if(!sd->texsep) - mtex.size[1]= mtex.size[2]= mtex.size[0]; - - externtex(&mtex,point,&avg,&jnk,&jnk,&jnk,&jnk); + + /* Get strength by feeding the vertex + location directly into a texture */ + externtex(tex, point, &avg, + &jnk, &jnk, &jnk, &jnk); } else if(ss->texcache) { const float bsize= ss->cache->pixel_radius * 2; - const float rot= sd->brush->rot + ss->cache->rotation; + const float rot= tex->rot + ss->cache->rotation; int px, py; float flip[3], point_2d[2]; @@ -663,9 +671,9 @@ static float tex_strength(Sculpt *sd, float *point, const float len) /* For Tile and Drag modes, get the 2D screen coordinates of the and scale them up or down to the texture size. */ - if(br->tex_mode==BRUSH_TEX_TILE) { - const int sx= (const int)br->mtex[br->texact]->size[0]; - const int sy= (const int)sd->texsep ? br->mtex[br->texact]->size[1] : sx; + if(tex->brush_map_mode == MTEX_MAP_MODE_TILED) { + const int sx= (const int)tex->size[0]; + const int sy= (const int)tex->size[1]; float fx= point_2d[0]; float fy= point_2d[1]; @@ -685,7 +693,8 @@ static float tex_strength(Sculpt *sd, float *point, const float len) if(sy != 1) py %= sy-1; avg= get_texcache_pixel_bilinear(ss, ss->texcache_side*px/sx, ss->texcache_side*py/sy); - } else { + } + else if(tex->brush_map_mode == MTEX_MAP_MODE_FIXED) { float fx= (point_2d[0] - ss->cache->mouse[0]) / bsize; float fy= (point_2d[1] - ss->cache->mouse[1]) / bsize; @@ -699,7 +708,7 @@ static float tex_strength(Sculpt *sd, float *point, const float len) } } - avg*= brush_curve_strength(sd->brush, len, ss->cache->radius); /* Falloff curve */ + avg*= brush_curve_strength(br, len, ss->cache->radius); /* Falloff curve */ return avg; } @@ -737,9 +746,9 @@ static void sculpt_add_damaged_rect(SculptSession *ss) } } -static void do_brush_action(Sculpt *sd, StrokeCache *cache) +static void do_brush_action(Sculpt *sd, SculptSession *ss, StrokeCache *cache) { - SculptSession *ss = sd->session; + Brush *brush = paint_brush(&sd->paint); float av_dist; ListBase active_verts={0,0}; ListBase *grab_active_verts = &ss->cache->grab_active_verts[ss->cache->symmetry]; @@ -748,7 +757,7 @@ static void do_brush_action(Sculpt *sd, StrokeCache *cache) Mesh *me= NULL; /*XXX: get_mesh(OBACT); */ const float bstrength= brush_strength(sd, cache); KeyBlock *keyblock= NULL; /*XXX: ob_get_keyblock(OBACT); */ - Brush *b = sd->brush; + Brush *b = brush; int i; sculpt_add_damaged_rect(ss); @@ -768,7 +777,7 @@ static void do_brush_action(Sculpt *sd, StrokeCache *cache) adata->Index = i; /* Fade is used to store the final strength at which the brush should modify a particular vertex. */ - adata->Fade= tex_strength(sd, vert, av_dist) * bstrength; + adata->Fade= tex_strength(sd, ss, vert, av_dist) * bstrength; adata->dist = av_dist; if(b->sculpt_tool == SCULPT_TOOL_GRAB && cache->first_time) @@ -788,13 +797,13 @@ static void do_brush_action(Sculpt *sd, StrokeCache *cache) do_draw_brush(sd, ss, &active_verts); break; case SCULPT_TOOL_SMOOTH: - do_smooth_brush(sd, &active_verts); + do_smooth_brush(sd, ss, &active_verts); break; case SCULPT_TOOL_PINCH: - do_pinch_brush(sd, &active_verts); + do_pinch_brush(sd, ss, &active_verts); break; case SCULPT_TOOL_INFLATE: - do_inflate_brush(sd, &active_verts); + do_inflate_brush(sd, ss, &active_verts); break; case SCULPT_TOOL_GRAB: do_grab_brush(sd, ss); @@ -843,20 +852,21 @@ static void calc_brushdata_symm(StrokeCache *cache, const char symm) cache->symmetry= symm; } -static void do_symmetrical_brush_actions(Sculpt *sd, StrokeCache *cache) +static void do_symmetrical_brush_actions(Sculpt *sd, SculptSession *ss) { + StrokeCache *cache = ss->cache; const char symm = sd->flags & 7; int i; VecCopyf(cache->location, cache->true_location); VecCopyf(cache->grab_delta_symmetry, cache->grab_delta); cache->symmetry = 0; - do_brush_action(sd, cache); + do_brush_action(sd, ss, cache); for(i = 1; i <= symm; ++i) { if(symm & i && (symm != 5 || i != 3) && (symm != 6 || (i != 3 && i != 5))) { calc_brushdata_symm(cache, i); - do_brush_action(sd, cache); + do_brush_action(sd, ss, cache); } } @@ -929,9 +939,9 @@ static void projverts_clear_inside(SculptSession *ss) } #endif -static void sculpt_update_tex(Sculpt *sd) +static void sculpt_update_tex(Sculpt *sd, SculptSession *ss) { - SculptSession *ss= sd->session; + Brush *brush = paint_brush(&sd->paint); if(ss->texcache) { MEM_freeN(ss->texcache); @@ -939,9 +949,9 @@ static void sculpt_update_tex(Sculpt *sd) } /* Need to allocate a bigger buffer for bigger brush size */ - ss->texcache_side = sd->brush->size * 2; + ss->texcache_side = brush->size * 2; if(!ss->texcache || ss->texcache_side > ss->texcache_actual) { - ss->texcache = brush_gen_texture_cache(sd->brush, sd->brush->size); + ss->texcache = brush_gen_texture_cache(brush, brush->size); ss->texcache_actual = ss->texcache_side; } } @@ -992,8 +1002,8 @@ static struct MultiresModifierData *sculpt_multires_active(Object *ob) static void sculpt_update_mesh_elements(bContext *C) { - SculptSession *ss = CTX_data_tool_settings(C)->sculpt->session; Object *ob = CTX_data_active_object(C); + SculptSession *ss = ob->sculpt; int oldtotvert = ss->totvert; if((ss->multires = sculpt_multires_active(ob))) { @@ -1026,54 +1036,20 @@ static void sculpt_update_mesh_elements(bContext *C) static int sculpt_mode_poll(bContext *C) { - return G.f & G_SCULPTMODE; + Object *ob = CTX_data_active_object(C); + return ob && ob->mode & OB_MODE_SCULPT; } static int sculpt_poll(bContext *C) { - return G.f & G_SCULPTMODE && CTX_wm_area(C)->spacetype == SPACE_VIEW3D && - CTX_wm_region(C)->regiontype == RGN_TYPE_WINDOW; -} - -/*** Sculpt Cursor ***/ -static void draw_paint_cursor(bContext *C, int x, int y, void *customdata) -{ - Sculpt *sd= CTX_data_tool_settings(C)->sculpt; - - glColor4ub(255, 100, 100, 128); - glEnable( GL_LINE_SMOOTH ); - glEnable(GL_BLEND); - - glTranslatef((float)x, (float)y, 0.0f); - glutil_draw_lined_arc(0.0, M_PI*2.0, sd->brush->size, 40); - glTranslatef((float)-x, (float)-y, 0.0f); - - if(sd->session && sd->session->cache && sd->brush && (sd->brush->flag & BRUSH_SMOOTH_STROKE)) { - ARegion *ar = CTX_wm_region(C); - sdrawline(x, y, sd->session->cache->mouse[0] - ar->winrct.xmin, sd->session->cache->mouse[1] - ar->winrct.ymin); - } - - glDisable(GL_BLEND); - glDisable( GL_LINE_SMOOTH ); -} - -static void toggle_paint_cursor(bContext *C) -{ - Sculpt *s = CTX_data_scene(C)->toolsettings->sculpt; - - if(s->session->cursor) { - WM_paint_cursor_end(CTX_wm_manager(C), s->session->cursor); - s->session->cursor = NULL; - } - else { - s->session->cursor = - WM_paint_cursor_activate(CTX_wm_manager(C), sculpt_poll, draw_paint_cursor, NULL); - } + return sculpt_mode_poll(C) && paint_poll(C); } static void sculpt_undo_push(bContext *C, Sculpt *sd) { - switch(sd->brush->sculpt_tool) { + Brush *brush = paint_brush(&sd->paint); + + switch(brush->sculpt_tool) { case SCULPT_TOOL_DRAW: ED_undo_push(C, "Draw Brush"); break; case SCULPT_TOOL_SMOOTH: @@ -1093,36 +1069,15 @@ static void sculpt_undo_push(bContext *C, Sculpt *sd) } } -static int sculpt_brush_curve_preset_exec(bContext *C, wmOperator *op) -{ - brush_curve_preset(CTX_data_scene(C)->toolsettings->sculpt->brush, RNA_enum_get(op->ptr, "mode")); - return OPERATOR_FINISHED; -} - -static void SCULPT_OT_brush_curve_preset(wmOperatorType *ot) -{ - static EnumPropertyItem prop_mode_items[] = { - {BRUSH_PRESET_SHARP, "SHARP", 0, "Sharp Curve", ""}, - {BRUSH_PRESET_SMOOTH, "SMOOTH", 0, "Smooth Curve", ""}, - {BRUSH_PRESET_MAX, "MAX", 0, "Max Curve", ""}, - {0, NULL, 0, NULL, NULL}}; - - ot->name= "Preset"; - ot->idname= "SCULPT_OT_brush_curve_preset"; - - ot->exec= sculpt_brush_curve_preset_exec; - ot->poll= sculpt_mode_poll; - - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - - RNA_def_enum(ot->srna, "mode", prop_mode_items, BRUSH_PRESET_SHARP, "Mode", ""); -} - /**** Radial control ****/ static int sculpt_radial_control_invoke(bContext *C, wmOperator *op, wmEvent *event) { - toggle_paint_cursor(C); - brush_radial_control_invoke(op, CTX_data_scene(C)->toolsettings->sculpt->brush, 1); + Paint *p = paint_get_active(CTX_data_scene(C)); + Brush *brush = paint_brush(p); + + WM_paint_cursor_end(CTX_wm_manager(C), p->paint_cursor); + p->paint_cursor = NULL; + brush_radial_control_invoke(op, brush, 1); return WM_radial_control_invoke(C, op, event); } @@ -1130,13 +1085,15 @@ static int sculpt_radial_control_modal(bContext *C, wmOperator *op, wmEvent *eve { int ret = WM_radial_control_modal(C, op, event); if(ret != OPERATOR_RUNNING_MODAL) - toggle_paint_cursor(C); + paint_cursor_start(C, sculpt_poll); return ret; } static int sculpt_radial_control_exec(bContext *C, wmOperator *op) { - return brush_radial_control_exec(op, CTX_data_scene(C)->toolsettings->sculpt->brush, 1); + Brush *brush = paint_brush(&CTX_data_tool_settings(C)->sculpt->paint); + + return brush_radial_control_exec(op, brush, 1); } static void SCULPT_OT_radial_control(wmOperatorType *ot) @@ -1162,7 +1119,7 @@ static float unproject_brush_radius(SculptSession *ss, float offset) float brush_edge[3]; /* In anchored mode, brush size changes with mouse loc, otherwise it's fixed using the brush radius */ - unproject(ss->cache->mats, brush_edge, ss->cache->initial_mouse[0] + offset, + view3d_unproject(ss->cache->mats, brush_edge, ss->cache->initial_mouse[0] + offset, ss->cache->initial_mouse[1], ss->cache->depth); return VecLenf(ss->cache->true_location, brush_edge); @@ -1170,31 +1127,32 @@ static float unproject_brush_radius(SculptSession *ss, float offset) static void sculpt_cache_free(StrokeCache *cache) { - if(cache->layer_disps) - MEM_freeN(cache->layer_disps); - if(cache->mesh_store) - MEM_freeN(cache->mesh_store); + int i; if(cache->orig_norms) MEM_freeN(cache->orig_norms); if(cache->face_norms) MEM_freeN(cache->face_norms); if(cache->mats) MEM_freeN(cache->mats); + for(i = 0; i < 8; ++i) + BLI_freelistN(&cache->grab_active_verts[i]); MEM_freeN(cache); } /* Initialize the stroke cache invariants from operator properties */ -static void sculpt_update_cache_invariants(Sculpt *sd, bContext *C, wmOperator *op) +static void sculpt_update_cache_invariants(Sculpt *sd, SculptSession *ss, bContext *C, wmOperator *op) { StrokeCache *cache = MEM_callocN(sizeof(StrokeCache), "stroke cache"); + Brush *brush = paint_brush(&sd->paint); + ViewContext *vc = paint_stroke_view_context(op->customdata); int i; - sd->session->cache = cache; + ss->cache = cache; RNA_float_get_array(op->ptr, "scale", cache->scale); cache->flag = RNA_int_get(op->ptr, "flag"); RNA_float_get_array(op->ptr, "clip_tolerance", cache->clip_tolerance); - RNA_int_get_array(op->ptr, "initial_mouse", cache->initial_mouse); + RNA_float_get_array(op->ptr, "initial_mouse", cache->initial_mouse); cache->depth = RNA_float_get(op->ptr, "depth"); cache->mouse[0] = cache->initial_mouse[0]; @@ -1202,70 +1160,88 @@ static void sculpt_update_cache_invariants(Sculpt *sd, bContext *C, wmOperator * /* Truly temporary data that isn't stored in properties */ - view3d_set_viewcontext(C, &cache->vc); - cache->mats = MEM_callocN(sizeof(bglMats), "sculpt bglMats"); - view3d_get_transformation(&cache->vc, cache->vc.obact, cache->mats); + view3d_get_transformation(vc, vc->obact, cache->mats); sculpt_update_mesh_elements(C); - if(sd->brush->sculpt_tool == SCULPT_TOOL_LAYER) - cache->layer_disps = MEM_callocN(sizeof(float) * sd->session->totvert, "layer brush displacements"); + /* Initialize layer brush displacements */ + if(brush->sculpt_tool == SCULPT_TOOL_LAYER && + (!ss->layer_disps || !(brush->flag & BRUSH_PERSISTENT))) { + if(ss->layer_disps) + MEM_freeN(ss->layer_disps); + ss->layer_disps = MEM_callocN(sizeof(float) * ss->totvert, "layer brush displacements"); + } /* Make copies of the mesh vertex locations and normals for some tools */ - if(sd->brush->sculpt_tool == SCULPT_TOOL_LAYER || (sd->brush->flag & BRUSH_ANCHORED)) { - cache->mesh_store= MEM_mallocN(sizeof(float) * 3 * sd->session->totvert, "sculpt mesh vertices copy"); - for(i = 0; i < sd->session->totvert; ++i) - VecCopyf(cache->mesh_store[i], sd->session->mvert[i].co); - - if(sd->brush->flag & BRUSH_ANCHORED) { - cache->orig_norms= MEM_mallocN(sizeof(short) * 3 * sd->session->totvert, "Sculpt orig norm"); - for(i = 0; i < sd->session->totvert; ++i) { - cache->orig_norms[i][0] = sd->session->mvert[i].no[0]; - cache->orig_norms[i][1] = sd->session->mvert[i].no[1]; - cache->orig_norms[i][2] = sd->session->mvert[i].no[2]; + if(brush->sculpt_tool == SCULPT_TOOL_LAYER || (brush->flag & BRUSH_ANCHORED)) { + if(brush->sculpt_tool != SCULPT_TOOL_LAYER || + !ss->mesh_co_orig || !(brush->flag & BRUSH_PERSISTENT)) { + if(!ss->mesh_co_orig) + ss->mesh_co_orig= MEM_mallocN(sizeof(float) * 3 * ss->totvert, + "sculpt mesh vertices copy"); + for(i = 0; i < ss->totvert; ++i) + VecCopyf(ss->mesh_co_orig[i], ss->mvert[i].co); + } + + if(brush->flag & BRUSH_ANCHORED) { + cache->orig_norms= MEM_mallocN(sizeof(short) * 3 * ss->totvert, "Sculpt orig norm"); + for(i = 0; i < ss->totvert; ++i) { + cache->orig_norms[i][0] = ss->mvert[i].no[0]; + cache->orig_norms[i][1] = ss->mvert[i].no[1]; + cache->orig_norms[i][2] = ss->mvert[i].no[2]; } - if(sd->session->face_normals) { - float *fn = sd->session->face_normals; - cache->face_norms= MEM_mallocN(sizeof(float) * 3 * sd->session->totface, "Sculpt face norms"); - for(i = 0; i < sd->session->totface; ++i, fn += 3) + if(ss->face_normals) { + float *fn = ss->face_normals; + cache->face_norms= MEM_mallocN(sizeof(float) * 3 * ss->totface, "Sculpt face norms"); + for(i = 0; i < ss->totface; ++i, fn += 3) VecCopyf(cache->face_norms[i], fn); } } } - unproject(cache->mats, cache->true_location, cache->initial_mouse[0], cache->initial_mouse[1], cache->depth); - cache->radius = unproject_brush_radius(sd->session, brush_size(sd)); + view3d_unproject(cache->mats, cache->true_location, cache->initial_mouse[0], cache->initial_mouse[1], cache->depth); + cache->initial_radius = unproject_brush_radius(ss, brush->size); cache->rotation = 0; cache->first_time = 1; } /* Initialize the stroke cache variants from operator properties */ -static void sculpt_update_cache_variants(Sculpt *sd, PointerRNA *ptr) +static void sculpt_update_cache_variants(Sculpt *sd, SculptSession *ss, PointerRNA *ptr) { - StrokeCache *cache = sd->session->cache; + StrokeCache *cache = ss->cache; + Brush *brush = paint_brush(&sd->paint); float grab_location[3]; + int dx, dy; - if(!(sd->brush->flag & BRUSH_ANCHORED)) + if(!(brush->flag & BRUSH_ANCHORED)) RNA_float_get_array(ptr, "location", cache->true_location); cache->flip = RNA_boolean_get(ptr, "flip"); - RNA_int_get_array(ptr, "mouse", cache->mouse); + RNA_float_get_array(ptr, "mouse", cache->mouse); + cache->pressure = RNA_float_get(ptr, "pressure"); /* Truly temporary data that isn't stored in properties */ cache->previous_pixel_radius = cache->pixel_radius; - cache->pixel_radius = brush_size(sd); + cache->pixel_radius = brush->size; + + if(brush->flag & BRUSH_SIZE_PRESSURE) { + cache->pixel_radius *= cache->pressure; + cache->radius = cache->initial_radius * cache->pressure; + } + else + cache->radius = cache->initial_radius; - if(sd->brush->flag & BRUSH_ANCHORED) { + if(brush->flag & BRUSH_ANCHORED) { dx = cache->mouse[0] - cache->initial_mouse[0]; dy = cache->mouse[1] - cache->initial_mouse[1]; cache->pixel_radius = sqrt(dx*dx + dy*dy); - cache->radius = unproject_brush_radius(sd->session, cache->pixel_radius); + cache->radius = unproject_brush_radius(ss, cache->pixel_radius); cache->rotation = atan2(dy, dx); } - else if(sd->brush->flag & BRUSH_RAKE) { + else if(brush->flag & BRUSH_RAKE) { int update; dx = cache->last_rake[0] - cache->mouse[0]; @@ -1284,8 +1260,8 @@ static void sculpt_update_cache_variants(Sculpt *sd, PointerRNA *ptr) } /* Find the grab delta */ - if(sd->brush->sculpt_tool == SCULPT_TOOL_GRAB) { - unproject(cache->mats, grab_location, cache->mouse[0], cache->mouse[1], cache->depth); + if(brush->sculpt_tool == SCULPT_TOOL_GRAB) { + view3d_unproject(cache->mats, grab_location, cache->mouse[0], cache->mouse[1], cache->depth); if(!cache->first_time) VecSubf(cache->grab_delta, grab_location, cache->old_grab_location); VecCopyf(cache->old_grab_location, grab_location); @@ -1298,9 +1274,9 @@ static void sculpt_brush_stroke_init_properties(bContext *C, wmOperator *op, wmE Sculpt *sd = CTX_data_tool_settings(C)->sculpt; Object *ob= CTX_data_active_object(C); ModifierData *md; - ViewContext vc; float scale[3], clip_tolerance[3] = {0,0,0}; - int mouse[2], flag = 0; + float mouse[2]; + int flag = 0; /* Set scaling adjustment */ scale[0] = 1.0f / ob->size[0]; @@ -1327,42 +1303,39 @@ static void sculpt_brush_stroke_init_properties(bContext *C, wmOperator *op, wmE /* Initial mouse location */ mouse[0] = event->x; mouse[1] = event->y; - RNA_int_set_array(op->ptr, "initial_mouse", mouse); + RNA_float_set_array(op->ptr, "initial_mouse", mouse); /* Initial screen depth under the mouse */ - view3d_set_viewcontext(C, &vc); - RNA_float_set(op->ptr, "depth", read_cached_depth(&vc, event->x, event->y)); + RNA_float_set(op->ptr, "depth", read_cached_depth(paint_stroke_view_context(op->customdata), event->x, event->y)); - sculpt_update_cache_invariants(sd, C, op); + sculpt_update_cache_invariants(sd, ss, C, op); } -static int sculpt_brush_stroke_invoke(bContext *C, wmOperator *op, wmEvent *event) +static void sculpt_brush_stroke_init(bContext *C) { Sculpt *sd = CTX_data_tool_settings(C)->sculpt; + SculptSession *ss = CTX_data_active_object(C)->sculpt; view3d_operator_needs_opengl(C); /* TODO: Shouldn't really have to do this at the start of every stroke, but sculpt would need some sort of notification when changes are made to the texture. */ - sculpt_update_tex(sd); + sculpt_update_tex(sd, ss); - /* add modal handler */ - WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op); - - return OPERATOR_RUNNING_MODAL; + sculpt_update_mesh_elements(C); } -static void sculpt_restore_mesh(Sculpt *sd) +static void sculpt_restore_mesh(Sculpt *sd, SculptSession *ss) { - SculptSession *ss = sd->session; StrokeCache *cache = ss->cache; + Brush *brush = paint_brush(&sd->paint); int i; /* Restore the mesh before continuing with anchored stroke */ - if((sd->brush->flag & BRUSH_ANCHORED) && cache->mesh_store) { + if((brush->flag & BRUSH_ANCHORED) && ss->mesh_co_orig) { for(i = 0; i < ss->totvert; ++i) { - VecCopyf(ss->mvert[i].co, cache->mesh_store[i]); + VecCopyf(ss->mvert[i].co, ss->mesh_co_orig[i]); ss->mvert[i].no[0] = cache->orig_norms[i][0]; ss->mvert[i].no[1] = cache->orig_norms[i][1]; ss->mvert[i].no[2] = cache->orig_norms[i][2]; @@ -1374,8 +1347,8 @@ static void sculpt_restore_mesh(Sculpt *sd) VecCopyf(fn, cache->face_norms[i]); } - if(sd->brush->sculpt_tool == SCULPT_TOOL_LAYER) - memset(cache->layer_disps, 0, sizeof(float) * ss->totvert); + if(brush->sculpt_tool == SCULPT_TOOL_LAYER) + memset(ss->layer_disps, 0, sizeof(float) * ss->totvert); } } @@ -1387,187 +1360,107 @@ static void sculpt_post_stroke_free(SculptSession *ss) static void sculpt_flush_update(bContext *C) { - Sculpt *s = CTX_data_tool_settings(C)->sculpt; + Object *ob = CTX_data_active_object(C); + SculptSession *ss = ob->sculpt; ARegion *ar = CTX_wm_region(C); - MultiresModifierData *mmd = s->session->multires; + MultiresModifierData *mmd = ss->multires; - calc_damaged_verts(s->session); + calc_damaged_verts(ss); if(mmd) { - if(mmd->undo_verts && mmd->undo_verts != s->session->mvert) + if(mmd->undo_verts && mmd->undo_verts != ss->mvert) MEM_freeN(mmd->undo_verts); - mmd->undo_verts = s->session->mvert; - mmd->undo_verts_tot = s->session->totvert; - multires_mark_as_modified(CTX_data_active_object(C)); + mmd->undo_verts = ss->mvert; + mmd->undo_verts_tot = ss->totvert; + multires_mark_as_modified(ob); } ED_region_tag_redraw(ar); } -/* Returns zero if no sculpt changes should be made, non-zero otherwise */ -static int sculpt_smooth_stroke(Sculpt *s, int output[2], wmEvent *event) +static int sculpt_stroke_test_start(bContext *C, struct wmOperator *op, wmEvent *event) { - output[0] = event->x; - output[1] = event->y; - - if(s->brush->flag & BRUSH_SMOOTH_STROKE && s->brush->sculpt_tool != SCULPT_TOOL_GRAB) { - StrokeCache *cache = s->session->cache; - float u = .9, v = 1.0 - u; - int dx = cache->mouse[0] - event->x, dy = cache->mouse[1] - event->y; - int radius = 50; - - /* If the mouse is moving within the radius of the last move, - don't update the mouse position. This allows sharp turns. */ - if(dx*dx + dy*dy < radius*radius) - return 0; - - output[0] = event->x * v + cache->mouse[0] * u; - output[1] = event->y * v + cache->mouse[1] * u; - } + ViewContext vc; + float cur_depth; - return 1; -} + view3d_set_viewcontext(C, &vc); + cur_depth = read_cached_depth(&vc, event->x, event->y); + + /* Don't start the stroke until a valid depth is found */ + if(cur_depth < 1.0 - FLT_EPSILON) { + SculptSession *ss = CTX_data_active_object(C)->sculpt; -/* Returns zero if the stroke dots should not be spaced, non-zero otherwise */ -int sculpt_space_stroke_enabled(Sculpt *s) -{ - Brush *br = s->brush; - return (br->flag & BRUSH_SPACE) && !(br->flag & BRUSH_ANCHORED) && (br->sculpt_tool != SCULPT_TOOL_GRAB); + sculpt_brush_stroke_init_properties(C, op, event, ss); + sculptmode_update_all_projverts(ss); + + return 1; + } + else + return 0; } -/* Put the location of the next sculpt stroke dot into the stroke RNA and apply it to the mesh */ -static void sculpt_brush_stroke_add_step(bContext *C, wmOperator *op, wmEvent *event, int mouse[2]) +static void sculpt_stroke_update_step(bContext *C, struct PaintStroke *stroke, PointerRNA *itemptr) { Sculpt *sd = CTX_data_tool_settings(C)->sculpt; - StrokeCache *cache = sd->session->cache; - PointerRNA itemptr; - float cur_depth; - float center[3]; - - cur_depth = read_cached_depth(&cache->vc, mouse[0], mouse[1]); - unproject(sd->session->cache->mats, center, mouse[0], mouse[1], cur_depth); - - /* Add to stroke */ - RNA_collection_add(op->ptr, "stroke", &itemptr); - RNA_float_set_array(&itemptr, "location", center); - RNA_int_set_array(&itemptr, "mouse", mouse); - RNA_boolean_set(&itemptr, "flip", event->shift); - sculpt_update_cache_variants(sd, &itemptr); - - sculpt_restore_mesh(sd); - do_symmetrical_brush_actions(sd, cache); -} + SculptSession *ss = CTX_data_active_object(C)->sculpt; -/* For brushes with stroke spacing enabled, moves mouse in steps - towards the final mouse location. */ -static int sculpt_space_stroke(bContext *C, wmOperator *op, wmEvent *event, Sculpt *s, const int final_mouse[2]) -{ - StrokeCache *cache = s->session->cache; - int cnt = 0; - - if(sculpt_space_stroke_enabled(s)) { - float vec[2] = {final_mouse[0] - cache->mouse[0], final_mouse[1] - cache->mouse[1]}; - int mouse[2] = {cache->mouse[0], cache->mouse[1]}; - float length, scale; - int steps = 0, i; - - /* Normalize the vector between the last stroke dot and the goal */ - length = sqrt(vec[0]*vec[0] + vec[1]*vec[1]); - - if(length > FLT_EPSILON) { - scale = s->brush->spacing / length; - vec[0] *= scale; - vec[1] *= scale; - - steps = (int)(length / s->brush->spacing); - for(i = 0; i < steps; ++i, ++cnt) { - mouse[0] += vec[0]; - mouse[1] += vec[1]; - sculpt_brush_stroke_add_step(C, op, event, mouse); - } - } - } + sculpt_update_cache_variants(sd, ss, itemptr); + sculpt_restore_mesh(sd, ss); + do_symmetrical_brush_actions(sd, ss); - return cnt; + /* Cleanup */ + sculpt_flush_update(C); + sculpt_post_stroke_free(ss); } -static int sculpt_brush_stroke_modal(bContext *C, wmOperator *op, wmEvent *event) +static void sculpt_stroke_done(bContext *C, struct PaintStroke *stroke) { - Sculpt *sd = CTX_data_tool_settings(C)->sculpt; - ARegion *ar = CTX_wm_region(C); - float cur_depth; - - sculpt_update_mesh_elements(C); + SculptSession *ss = CTX_data_active_object(C)->sculpt; - if(!sd->session->cache) { - ViewContext vc; - view3d_set_viewcontext(C, &vc); - cur_depth = read_cached_depth(&vc, event->x, event->y); - - /* Don't start the stroke until a valid depth is found */ - if(cur_depth < 1.0 - FLT_EPSILON) { - sculpt_brush_stroke_init_properties(C, op, event, sd->session); - sculptmode_update_all_projverts(sd->session); - } + /* Finished */ + if(ss->cache) { + Sculpt *sd = CTX_data_tool_settings(C)->sculpt; - ED_region_tag_redraw(ar); + request_depth_update(paint_stroke_view_context(stroke)->rv3d); + sculpt_cache_free(ss->cache); + ss->cache = NULL; + sculpt_undo_push(C, sd); } +} - if(sd->session->cache) { - int mouse[2]; - - if(sculpt_smooth_stroke(sd, mouse, event)) { - if(sculpt_space_stroke_enabled(sd)) { - if(!sculpt_space_stroke(C, op, event, sd, mouse)) - ED_region_tag_redraw(ar); - } - else - sculpt_brush_stroke_add_step(C, op, event, mouse); - - sculpt_flush_update(C); - sculpt_post_stroke_free(sd->session); - } - else - ED_region_tag_redraw(ar); - } +static int sculpt_brush_stroke_invoke(bContext *C, wmOperator *op, wmEvent *event) +{ + sculpt_brush_stroke_init(C); - /* Finished */ - if(event->type == LEFTMOUSE && event->val == 0) { - if(sd->session->cache) { - request_depth_update(sd->session->cache->vc.rv3d); - sculpt_cache_free(sd->session->cache); - sd->session->cache = NULL; - sculpt_undo_push(C, sd); - } + op->customdata = paint_stroke_new(C, sculpt_stroke_test_start, + sculpt_stroke_update_step, + sculpt_stroke_done); - return OPERATOR_FINISHED; - } + /* add modal handler */ + WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op); + op->type->modal(C, op, event); + return OPERATOR_RUNNING_MODAL; } static int sculpt_brush_stroke_exec(bContext *C, wmOperator *op) { Sculpt *sd = CTX_data_tool_settings(C)->sculpt; + SculptSession *ss = CTX_data_active_object(C)->sculpt; - view3d_operator_needs_opengl(C); - sculpt_update_cache_invariants(sd, C, op); - sculptmode_update_all_projverts(sd->session); - sculpt_update_tex(sd); + op->customdata = paint_stroke_new(C, sculpt_stroke_test_start, sculpt_stroke_update_step, sculpt_stroke_done); - RNA_BEGIN(op->ptr, itemptr, "stroke") { - sculpt_update_cache_variants(sd, &itemptr); + sculpt_brush_stroke_init(C); - sculpt_restore_mesh(sd); - do_symmetrical_brush_actions(sd, sd->session->cache); + sculpt_update_cache_invariants(sd, ss, C, op); + sculptmode_update_all_projverts(ss); - sculpt_post_stroke_free(sd->session); - } - RNA_END; + paint_stroke_exec(C, op); sculpt_flush_update(C); - sculpt_cache_free(sd->session->cache); + sculpt_cache_free(ss->cache); sculpt_undo_push(C, sd); @@ -1584,7 +1477,7 @@ static void SCULPT_OT_brush_stroke(wmOperatorType *ot) /* api callbacks */ ot->invoke= sculpt_brush_stroke_invoke; - ot->modal= sculpt_brush_stroke_modal; + ot->modal= paint_stroke_modal; ot->exec= sculpt_brush_stroke_exec; ot->poll= sculpt_poll; @@ -1604,46 +1497,76 @@ static void SCULPT_OT_brush_stroke(wmOperatorType *ot) RNA_def_float_vector(ot->srna, "clip_tolerance", 3, NULL, 0.0f, FLT_MAX, "clip_tolerance", "", 0.0f, 1000.0f); /* The initial 2D location of the mouse */ - RNA_def_int_vector(ot->srna, "initial_mouse", 2, NULL, INT_MIN, INT_MAX, "initial_mouse", "", INT_MIN, INT_MAX); + RNA_def_float_vector(ot->srna, "initial_mouse", 2, NULL, INT_MIN, INT_MAX, "initial_mouse", "", INT_MIN, INT_MAX); /* The initial screen depth of the mouse */ RNA_def_float(ot->srna, "depth", 0.0f, 0.0f, FLT_MAX, "depth", "", 0.0f, FLT_MAX); } +/**** Reset the copy of the mesh that is being sculpted on (currently just for the layer brush) ****/ + +static int sculpt_set_persistent_base(bContext *C, wmOperator *op) +{ + SculptSession *ss = CTX_data_active_object(C)->sculpt; + + if(ss) { + if(ss->layer_disps) + MEM_freeN(ss->layer_disps); + ss->layer_disps = NULL; + + if(ss->mesh_co_orig) + MEM_freeN(ss->mesh_co_orig); + ss->mesh_co_orig = NULL; + } + + return OPERATOR_FINISHED; +} + +static void SCULPT_OT_set_persistent_base(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Set Persistent Base"; + ot->idname= "SCULPT_OT_set_persistent_base"; + + /* api callbacks */ + ot->exec= sculpt_set_persistent_base; + ot->poll= sculpt_mode_poll; + + ot->flag= OPTYPE_REGISTER; +} + /**** Toggle operator for turning sculpt mode on or off ****/ static int sculpt_toggle_mode(bContext *C, wmOperator *op) { ToolSettings *ts = CTX_data_tool_settings(C); + Object *ob = CTX_data_active_object(C); - if(G.f & G_SCULPTMODE) { - multires_force_update(CTX_data_active_object(C)); + if(ob->mode & OB_MODE_SCULPT) { + multires_force_update(ob); /* Leave sculptmode */ - G.f &= ~G_SCULPTMODE; - - toggle_paint_cursor(C); + ob->mode &= ~OB_MODE_SCULPT; - sculptsession_free(ts->sculpt); + free_sculptsession(&ob->sculpt); } else { /* Enter sculptmode */ - G.f |= G_SCULPTMODE; + ob->mode |= OB_MODE_SCULPT; /* Create persistent sculpt mode data */ if(!ts->sculpt) ts->sculpt = MEM_callocN(sizeof(Sculpt), "sculpt mode data"); /* Create sculpt mode session data */ - if(ts->sculpt->session) - MEM_freeN(ts->sculpt->session); - ts->sculpt->session = MEM_callocN(sizeof(SculptSession), "sculpt session"); + if(ob->sculpt) + free_sculptsession(&ob->sculpt); + ob->sculpt = MEM_callocN(sizeof(SculptSession), "sculpt session"); - toggle_paint_cursor(C); - - /* If there's no brush, create one */ - brush_check_exists(&ts->sculpt->brush); + paint_init(&ts->sculpt->paint, PAINT_CURSOR_SCULPT); + + paint_cursor_start(C, sculpt_poll); WM_event_add_notifier(C, NC_SCENE|ND_MODE, CTX_data_scene(C)); } @@ -1669,5 +1592,5 @@ void ED_operatortypes_sculpt() WM_operatortype_append(SCULPT_OT_radial_control); WM_operatortype_append(SCULPT_OT_brush_stroke); WM_operatortype_append(SCULPT_OT_sculptmode_toggle); - WM_operatortype_append(SCULPT_OT_brush_curve_preset); + WM_operatortype_append(SCULPT_OT_set_persistent_base); } diff --git a/source/blender/editors/sculpt_paint/sculpt_stroke.c b/source/blender/editors/sculpt_paint/sculpt_stroke.c deleted file mode 100644 index 554ff580358..00000000000 --- a/source/blender/editors/sculpt_paint/sculpt_stroke.c +++ /dev/null @@ -1,274 +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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * The Original Code is Copyright (C) 2007 by Nicholas Bishop - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - * - * Storage and manipulation of sculptmode brush strokes. - * - */ - -#include "MEM_guardedalloc.h" - -#include "DNA_listBase.h" -#include "DNA_scene_types.h" - -#include "BKE_sculpt.h" -#include "BLI_blenlib.h" -#include "BIF_gl.h" - -#include "sculpt_intern.h" - -#include <math.h> - -/* Temporary storage of input stroke control points */ -typedef struct StrokePoint { - struct StrokePoint *next, *prev; - short x, y; -} StrokePoint; -typedef struct SculptStroke { - short (*loc)[2]; - int max; - int index; - float length; - ListBase final; - StrokePoint *final_mem; - float offset; -} SculptStroke; - -SculptStroke *sculpt_stroke_new(const int max) -{ - SculptStroke *stroke = MEM_callocN(sizeof(SculptStroke), "SculptStroke"); - stroke->loc = MEM_callocN(sizeof(short) * 4 * max, "SculptStroke.loc"); - stroke->max = max; - stroke->index = -1; - return stroke; -} - -void sculpt_stroke_free(SculptStroke *stroke) -{ - if(stroke) { - if(stroke->loc) MEM_freeN(stroke->loc); - if(stroke->final_mem) MEM_freeN(stroke->final_mem); - - MEM_freeN(stroke); - } -} - -void sculpt_stroke_add_point(SculptStroke *stroke, const short x, const short y) -{ - const int next = stroke->index + 1; - - if(stroke->index == -1) { - stroke->loc[0][0] = x; - stroke->loc[0][1] = y; - stroke->index = 0; - } - else if(next < stroke->max) { - const int dx = x - stroke->loc[stroke->index][0]; - const int dy = y - stroke->loc[stroke->index][1]; - stroke->loc[next][0] = x; - stroke->loc[next][1] = y; - stroke->length += sqrt(dx*dx + dy*dy); - stroke->index = next; - } -} - -static void sculpt_stroke_smooth(SculptStroke *stroke) -{ - /* Apply smoothing (exclude the first and last points)*/ - StrokePoint *p = stroke->final.first; - if(p && p->next && p->next->next) { - for(p = p->next->next; p && p->next && p->next->next; p = p->next) { - p->x = p->prev->prev->x*0.1 + p->prev->x*0.2 + p->x*0.4 + p->next->x*0.2 + p->next->next->x*0.1; - p->y = p->prev->prev->y*0.1 + p->prev->y*0.2 + p->y*0.4 + p->next->y*0.2 + p->next->next->y*0.1; - } - } -} - -static void sculpt_stroke_create_final(SculptStroke *stroke) -{ - if(stroke) { - StrokePoint *p, *pnext; - int i; - - /* Copy loc into final */ - if(stroke->final_mem) - MEM_freeN(stroke->final_mem); - stroke->final_mem = MEM_callocN(sizeof(StrokePoint) * (stroke->index + 1) * 2, "SculptStroke.final"); - stroke->final.first = stroke->final.last = NULL; - for(i = 0; i <= stroke->index; ++i) { - p = &stroke->final_mem[i]; - p->x = stroke->loc[i][0]; - p->y = stroke->loc[i][1]; - BLI_addtail(&stroke->final, p); - } - - /* Remove shortest edges */ - if(stroke->final.first) { - for(p = ((StrokePoint*)stroke->final.first)->next; p && p->next; p = pnext) { - const int dx = p->x - p->prev->x; - const int dy = p->y - p->prev->y; - const float len = sqrt(dx*dx + dy*dy); - pnext = p->next; - if(len < 10) { - BLI_remlink(&stroke->final, p); - } - } - } - - sculpt_stroke_smooth(stroke); - - /* Subdivide edges */ - for(p = stroke->final.first; p && p->next; p = pnext) { - StrokePoint *np = &stroke->final_mem[i++]; - - pnext = p->next; - np->x = (p->x + p->next->x) / 2; - np->y = (p->y + p->next->y) / 2; - BLI_insertlink(&stroke->final, p, np); - } - - sculpt_stroke_smooth(stroke); - } -} - -static float sculpt_stroke_seglen(StrokePoint *p1, StrokePoint *p2) -{ - int dx = p2->x - p1->x; - int dy = p2->y - p1->y; - return sqrt(dx*dx + dy*dy); -} - -static float sculpt_stroke_final_length(SculptStroke *stroke) -{ - StrokePoint *p; - float len = 0; - for(p = stroke->final.first; p && p->next; ++p) - len += sculpt_stroke_seglen(p, p->next); - return len; -} - -/* If partial is nonzero, cuts off apply after that length has been processed */ -static StrokePoint *sculpt_stroke_apply_generic(Sculpt *sd, SculptStroke *stroke, const int partial) -{ - const int sdspace = 0; //XXX: sd->spacing; - const short spacing = sdspace > 0 ? sdspace : 2; - const int dots = sculpt_stroke_final_length(stroke) / spacing; - int i; - StrokePoint *p = stroke->final.first; - float startloc = stroke->offset; - - for(i = 0; i < dots && p && p->next; ++i) { - const float dotloc = spacing * i; - short co[2]; - float len = sculpt_stroke_seglen(p, p->next); - float u, v; - - /* Find edge containing dot */ - while(dotloc > startloc + len && p && p->next && p->next->next) { - p = p->next; - startloc += len; - len = sculpt_stroke_seglen(p, p->next); - } - - if(!p || !p->next || dotloc > startloc + len) - break; - - if(partial && startloc > partial) { - /* Calculate offset for next stroke segment */ - stroke->offset = startloc + len - dotloc; - break; - } - - u = (dotloc - startloc) / len; - v = 1 - u; - - co[0] = p->x*v + p->next->x*u; - co[1] = p->y*v + p->next->y*u; - - //do_symmetrical_brush_actions(sd, a, co, NULL); - } - - return p ? p->next : NULL; -} - -void sculpt_stroke_apply(Sculpt *sd, SculptStroke *stroke) -{ - /* TODO: make these values user-modifiable? */ - const int partial_len = 100; - const int min_len = 200; - - if(stroke) { - sculpt_stroke_create_final(stroke); - - if(sculpt_stroke_final_length(stroke) > min_len) { - StrokePoint *p = sculpt_stroke_apply_generic(sd, stroke, partial_len); - - /* Replace remaining values in stroke->loc with remaining stroke->final values */ - stroke->index = -1; - stroke->length = 0; - for(; p; p = p->next) { - ++stroke->index; - stroke->loc[stroke->index][0] = p->x; - stroke->loc[stroke->index][1] = p->y; - if(p->next) { - stroke->length += sculpt_stroke_seglen(p, p->next); - } - } - } - } -} - -void sculpt_stroke_apply_all(Sculpt *sd, SculptStroke *stroke) -{ - sculpt_stroke_create_final(stroke); - - if(stroke) { - sculpt_stroke_apply_generic(sd, stroke, 0); - } -} - -/* XXX: drawing goes elsewhere */ -void sculpt_stroke_draw(SculptStroke *stroke) -{ - if(stroke) { - StrokePoint *p; - - /* Draws the original stroke */ - /*glColor3f(1, 0, 0); - glBegin(GL_LINE_STRIP); - for(i = 0; i <= stroke->index; ++i) - glVertex2s(stroke->loc[i][0], stroke->loc[i][1]); - glEnd();*/ - - /* Draws the smoothed stroke */ - glColor3f(0, 1, 0); - glBegin(GL_LINE_STRIP); - for(p = stroke->final.first; p; p = p->next) - glVertex2s(p->x, p->y); - glEnd(); - } -} diff --git a/source/blender/editors/space_action/action_draw.c b/source/blender/editors/space_action/action_draw.c index 6e86748adae..4288cc10a26 100644 --- a/source/blender/editors/space_action/action_draw.c +++ b/source/blender/editors/space_action/action_draw.c @@ -92,319 +92,19 @@ #include "ED_screen.h" #include "ED_space_api.h" -#if 0 // XXX old includes for reference only - #include "BIF_editaction.h" - #include "BIF_editkey.h" - #include "BIF_editnla.h" - #include "BIF_drawgpencil.h" - #include "BIF_keyframing.h" - #include "BIF_language.h" - #include "BIF_space.h" - - #include "BDR_editcurve.h" - #include "BDR_gpencil.h" - - #include "BSE_drawnla.h" - #include "BSE_drawipo.h" - #include "BSE_drawview.h" - #include "BSE_editaction_types.h" - #include "BSE_editipo.h" - #include "BSE_headerbuttons.h" - #include "BSE_time.h" - #include "BSE_view.h" -#endif // XXX old defines for reference only - -/* XXX */ -extern void gl_round_box(int mode, float minx, float miny, float maxx, float maxy, float rad); - -/********************************** Slider Stuff **************************** */ - -#if 0 // XXX all of this slider stuff will need a rethink! -/* sliders for shapekeys */ -static void meshactionbuts(SpaceAction *saction, Object *ob, Key *key) -{ - int i; - char str[64]; - float x, y; - uiBlock *block; - uiBut *but; - - /* lets make the shapekey sliders */ - - /* reset the damn myortho2 or the sliders won't draw/redraw - * correctly *grumble* - */ - mywinset(curarea->win); - myortho2(-0.375f, curarea->winx-0.375f, G.v2d->cur.ymin, G.v2d->cur.ymax); - - sprintf(str, "actionbuttonswin %d", curarea->win); - block= uiNewBlock (&curarea->uiblocks, str, UI_EMBOSS); - - x = ACHANNEL_NAMEWIDTH + 1; - y = 0.0f; - - uiBlockSetEmboss(block, UI_EMBOSSN); - - if (!(G.saction->flag & SACTION_SLIDERS)) { - ACTWIDTH = ACHANNEL_NAMEWIDTH; - but=uiDefIconButBitS(block, TOG, SACTION_SLIDERS, B_REDR, - ICON_DISCLOSURE_TRI_RIGHT, - ACHANNEL_NAMEWIDTH - XIC - 5, (short)y + CHANNELHEIGHT, - XIC,YIC-2, - &(G.saction->flag), 0, 0, 0, 0, - "Show action window sliders"); - /* no hilite, the winmatrix is not correct later on... */ - uiButSetFlag(but, UI_NO_HILITE); - } - else { - but= uiDefIconButBitS(block, TOG, SACTION_SLIDERS, B_REDR, - ICON_DISCLOSURE_TRI_DOWN, - ACHANNEL_NAMEWIDTH - XIC - 5, (short)y + CHANNELHEIGHT, - XIC,YIC-2, - &(G.saction->flag), 0, 0, 0, 0, - "Hide action window sliders"); - /* no hilite, the winmatrix is not correct later on... */ - uiButSetFlag(but, UI_NO_HILITE); - - ACTWIDTH = ACHANNEL_NAMEWIDTH + SLIDERWIDTH; - - /* sliders are open so draw them */ - BIF_ThemeColor(TH_FACE); - - glRects(ACHANNEL_NAMEWIDTH, 0, ACHANNEL_NAMEWIDTH+SLIDERWIDTH, curarea->winy); - uiBlockSetEmboss(block, UI_EMBOSS); - for (i=1; i < key->totkey; i++) { - make_rvk_slider(block, ob, i, - (int)x, (int)y, SLIDERWIDTH-2, CHANNELHEIGHT-1, "Slider to control Shape Keys"); - - y-=CHANNELHEIGHT+CHANNELSKIP; - - /* see sliderval array in editkey.c */ - if (i >= 255) break; - } - } - uiDrawBlock(C, block); -} - -static void icu_slider_func(void *voidicu, void *voidignore) -{ - /* the callback for the icu sliders ... copies the - * value from the icu->curval into a bezier at the - * right frame on the right ipo curve (creating both the - * ipo curve and the bezier if needed). - */ - IpoCurve *icu= voidicu; - BezTriple *bezt=NULL; - float cfra, icuval; - - cfra = frame_to_float(CFRA); - if (G.saction->pin==0 && OBACT) - cfra= get_action_frame(OBACT, cfra); - - /* if the ipocurve exists, try to get a bezier - * for this frame - */ - bezt = get_bezt_icu_time(icu, &cfra, &icuval); - - /* create the bezier triple if one doesn't exist, - * otherwise modify it's value - */ - if (bezt == NULL) { - insert_vert_icu(icu, cfra, icu->curval, 0); - } - else { - bezt->vec[1][1] = icu->curval; - } - - /* make sure the Ipo's are properly processed and - * redraw as necessary - */ - sort_time_ipocurve(icu); - testhandles_ipocurve(icu); - - /* nla-update (in case this affects anything) */ - synchronize_action_strips(); - - /* do redraw pushes, and also the depsgraph flushes */ - if (OBACT->pose || ob_get_key(OBACT)) - DAG_object_flush_update(G.scene, OBACT, OB_RECALC); - else - DAG_object_flush_update(G.scene, OBACT, OB_RECALC_OB); - - allqueue(REDRAWVIEW3D, 0); - allqueue(REDRAWACTION, 0); - allqueue(REDRAWNLA, 0); - allqueue(REDRAWIPO, 0); - allspace(REMAKEIPO, 0); - allqueue(REDRAWBUTSALL, 0); -} - -static void make_icu_slider(uiBlock *block, IpoCurve *icu, - int x, int y, int w, int h, char *tip) -{ - /* create a slider for the ipo-curve*/ - uiBut *but; - - if(icu == NULL) return; - - if (IS_EQ(icu->slide_max, icu->slide_min)) { - if (IS_EQ(icu->ymax, icu->ymin)) { - if (ELEM(icu->blocktype, ID_CO, ID_KE)) { - /* hack for constraints and shapekeys (and maybe a few others) */ - icu->slide_min= 0.0; - icu->slide_max= 1.0; - } - else { - icu->slide_min= -100; - icu->slide_max= 100; - } - } - else { - icu->slide_min= icu->ymin; - icu->slide_max= icu->ymax; - } - } - if (icu->slide_min >= icu->slide_max) { - SWAP(float, icu->slide_min, icu->slide_max); - } - - but=uiDefButF(block, NUMSLI, REDRAWVIEW3D, "", - x, y , w, h, - &(icu->curval), icu->slide_min, icu->slide_max, - 10, 2, tip); - - uiButSetFunc(but, icu_slider_func, icu, NULL); - - // no hilite, the winmatrix is not correct later on... - uiButSetFlag(but, UI_NO_HILITE); -} - -/* sliders for ipo-curves of active action-channel */ -static void action_icu_buts(SpaceAction *saction) -{ - ListBase act_data = {NULL, NULL}; - bActListElem *ale; - int filter; - void *data; - short datatype; - - char str[64]; - float x, y; - uiBlock *block; - - /* lets make the action sliders */ - - /* reset the damn myortho2 or the sliders won't draw/redraw - * correctly *grumble* - */ - mywinset(curarea->win); - myortho2(-0.375f, curarea->winx-0.375f, G.v2d->cur.ymin, G.v2d->cur.ymax); - - sprintf(str, "actionbuttonswin %d", curarea->win); - block= uiNewBlock (&curarea->uiblocks, str, UI_EMBOSS); - - x = (float)ACHANNEL_NAMEWIDTH + 1; - y = 0.0f; - - uiBlockSetEmboss(block, UI_EMBOSSN); - - if (G.saction->flag & SACTION_SLIDERS) { - /* sliders are open so draw them */ - - /* get editor data */ - data= get_action_context(&datatype); - if (data == NULL) return; - - /* build list of channels to draw */ - filter= (ACTFILTER_FORDRAWING|ACTFILTER_VISIBLE|ACTFILTER_CHANNELS); - actdata_filter(&act_data, filter, data, datatype); - - /* draw backdrop first */ - BIF_ThemeColor(TH_FACE); // change this color... it's ugly - glRects(ACHANNEL_NAMEWIDTH, (short)G.v2d->cur.ymin, ACHANNEL_NAMEWIDTH+SLIDERWIDTH, (short)G.v2d->cur.ymax); - - uiBlockSetEmboss(block, UI_EMBOSS); - for (ale= act_data.first; ale; ale= ale->next) { - const float yminc= y-CHANNELHEIGHT/2; - const float ymaxc= y+CHANNELHEIGHT/2; - - /* check if visible */ - if ( IN_RANGE(yminc, G.v2d->cur.ymin, G.v2d->cur.ymax) || - IN_RANGE(ymaxc, G.v2d->cur.ymin, G.v2d->cur.ymax) ) - { - /* determine what needs to be drawn */ - switch (ale->type) { - case ACTTYPE_CONCHAN: /* constraint channel */ - { - bActionChannel *achan = (bActionChannel *)ale->owner; - IpoCurve *icu = (IpoCurve *)ale->key_data; - - /* only show if owner is selected */ - if ((ale->ownertype == ACTTYPE_OBJECT) || SEL_ACHAN(achan)) { - make_icu_slider(block, icu, - (int)x, (int)y, SLIDERWIDTH-2, CHANNELHEIGHT-2, - "Slider to control current value of Constraint Influence"); - } - } - break; - case ACTTYPE_ICU: /* ipo-curve channel */ - { - bActionChannel *achan = (bActionChannel *)ale->owner; - IpoCurve *icu = (IpoCurve *)ale->key_data; - - /* only show if owner is selected */ - if ((ale->ownertype == ACTTYPE_OBJECT) || SEL_ACHAN(achan)) { - make_icu_slider(block, icu, - (int)x, (int)y, SLIDERWIDTH-2, CHANNELHEIGHT-2, - "Slider to control current value of IPO-Curve"); - } - } - break; - case ACTTYPE_SHAPEKEY: /* shapekey channel */ - { - Object *ob= (Object *)ale->id; - IpoCurve *icu= (IpoCurve *)ale->key_data; - - // TODO: only show if object is active - if (icu) { - make_icu_slider(block, icu, - (int)x, (int)y, SLIDERWIDTH-2, CHANNELHEIGHT-2, - "Slider to control ShapeKey"); - } - else if (ob && ale->index) { - make_rvk_slider(block, ob, ale->index, - (int)x, (int)y, SLIDERWIDTH-2, CHANNELHEIGHT-1, "Slider to control Shape Keys"); - } - } - break; - } - } - - /* adjust y-position for next one */ - y-=CHANNELHEIGHT+CHANNELSKIP; - } - - /* free tempolary channels */ - BLI_freelistN(&act_data); - } - uiDrawBlock(C, block); -} - -#endif // XXX all of this slider stuff will need a rethink - /* ************************************************************************* */ /* Channel List */ /* left hand part */ -void draw_channel_names(bAnimContext *ac, SpaceAction *saction, ARegion *ar) +void draw_channel_names(bContext *C, bAnimContext *ac, SpaceAction *saction, ARegion *ar) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; View2D *v2d= &ar->v2d; - float x= 0.0f, y= 0.0f; + float y= 0.0f; int items, height; /* build list of channels to draw */ @@ -428,582 +128,48 @@ void draw_channel_names(bAnimContext *ac, SpaceAction *saction, ARegion *ar) UI_view2d_sync(NULL, ac->sa, v2d, V2D_VIEWSYNC_AREA_VERTICAL); /* loop through channels, and set up drawing depending on their type */ - y= (float)ACHANNEL_FIRST; - - for (ale= anim_data.first; ale; ale= ale->next) { - const float yminc= (float)(y - ACHANNEL_HEIGHT_HALF); - const float ymaxc= (float)(y + ACHANNEL_HEIGHT_HALF); + { /* first pass: just the standard GL-drawing for backdrop + text */ + y= (float)ACHANNEL_FIRST; - /* check if visible */ - if ( IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || - IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) ) - { - bActionGroup *grp = NULL; - short indent= 0, offset= 0, sel= 0, group= 0; - int expand= -1, protect = -1, special= -1, mute = -1; - char name[128]; - - /* determine what needs to be drawn */ - switch (ale->type) { - case ANIMTYPE_SCENE: /* scene */ - { - Scene *sce= (Scene *)ale->data; - - group= 4; - indent= 0; - - special= ICON_SCENE_DATA; - - /* only show expand if there are any channels */ - if (EXPANDED_SCEC(sce)) - expand= ICON_TRIA_DOWN; - else - expand= ICON_TRIA_RIGHT; - - sel = SEL_SCEC(sce); - strcpy(name, sce->id.name+2); - } - break; - case ANIMTYPE_OBJECT: /* object */ - { - Base *base= (Base *)ale->data; - Object *ob= base->object; - - group= 4; - indent= 0; - - /* icon depends on object-type */ - if (ob->type == OB_ARMATURE) - special= ICON_ARMATURE_DATA; - else - special= ICON_OBJECT_DATA; - - /* only show expand if there are any channels */ - if (EXPANDED_OBJC(ob)) - expand= ICON_TRIA_DOWN; - else - expand= ICON_TRIA_RIGHT; - - sel = SEL_OBJC(base); - strcpy(name, ob->id.name+2); - } - break; - case ANIMTYPE_FILLACTD: /* action widget */ - { - bAction *act= (bAction *)ale->data; - - group = 4; - indent= 1; - special= ICON_ACTION; - - if (EXPANDED_ACTC(act)) - expand= ICON_TRIA_DOWN; - else - expand= ICON_TRIA_RIGHT; - - sel = SEL_ACTC(act); - strcpy(name, act->id.name+2); - } - break; - case ANIMTYPE_FILLMATD: /* object materials (dopesheet) expand widget */ - { - Object *ob = (Object *)ale->data; - - group = 4; - indent = 1; - special = ICON_MATERIAL_DATA; - - if (FILTER_MAT_OBJC(ob)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - strcpy(name, "Materials"); - } - break; - case ANIMTYPE_FILLPARTD: /* object particles (dopesheet) expand widget */ - { - Object *ob = (Object *)ale->data; - - group = 4; - indent = 1; - special = ICON_PARTICLE_DATA; - - if (FILTER_PART_OBJC(ob)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - strcpy(name, "Particles"); - } - break; - - - case ANIMTYPE_DSMAT: /* single material (dopesheet) expand widget */ - { - Material *ma = (Material *)ale->data; - - group = 0; - indent = 0; - special = ICON_MATERIAL_DATA; - offset = 21; - - if (FILTER_MAT_OBJD(ma)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - strcpy(name, ma->id.name+2); - } - break; - case ANIMTYPE_DSLAM: /* lamp (dopesheet) expand widget */ - { - Lamp *la = (Lamp *)ale->data; - - group = 4; - indent = 1; - special = ICON_LAMP_DATA; - - if (FILTER_LAM_OBJD(la)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - strcpy(name, la->id.name+2); - } - break; - case ANIMTYPE_DSCAM: /* camera (dopesheet) expand widget */ - { - Camera *ca = (Camera *)ale->data; - - group = 4; - indent = 1; - special = ICON_CAMERA_DATA; - - if (FILTER_CAM_OBJD(ca)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - strcpy(name, ca->id.name+2); - } - break; - case ANIMTYPE_DSCUR: /* curve (dopesheet) expand widget */ - { - Curve *cu = (Curve *)ale->data; - - group = 4; - indent = 1; - special = ICON_CURVE_DATA; - - if (FILTER_CUR_OBJD(cu)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - strcpy(name, cu->id.name+2); - } - break; - case ANIMTYPE_DSSKEY: /* shapekeys (dopesheet) expand widget */ - { - Key *key= (Key *)ale->data; - - group = 4; - indent = 1; - special = ICON_SHAPEKEY_DATA; // XXX - - if (FILTER_SKE_OBJD(key)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - //sel = SEL_OBJC(base); - strcpy(name, "Shape Keys"); - } - break; - case ANIMTYPE_DSWOR: /* world (dopesheet) expand widget */ - { - World *wo= (World *)ale->data; - - group = 4; - indent = 1; - special = ICON_WORLD_DATA; - - if (FILTER_WOR_SCED(wo)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - strcpy(name, wo->id.name+2); - } - break; - case ANIMTYPE_DSPART: /* particle (dopesheet) expand widget */ - { - ParticleSettings *part= (ParticleSettings*)ale->data; - - group = 0; - indent = 0; - special = ICON_PARTICLE_DATA; - offset = 21; - - if (FILTER_PART_OBJD(part)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - strcpy(name, part->id.name+2); - } - break; - case ANIMTYPE_DSMBALL: /* metaball (dopesheet) expand widget */ - { - MetaBall *mb = (MetaBall *)ale->data; - - group = 4; - indent = 1; - special = ICON_META_DATA; - - if (FILTER_MBALL_OBJD(mb)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - strcpy(name, mb->id.name+2); - } - break; - - - case ANIMTYPE_GROUP: /* action group */ - { - bActionGroup *agrp= (bActionGroup *)ale->data; - - group= 2; - indent= 0; - special= -1; - - if (ale->id) { - /* special exception for materials */ - if (GS(ale->id->name) == ID_MA) - offset= 25; - else - offset= 14; - } - else - offset= 0; - - /* only show expand if there are any channels */ - if (agrp->channels.first) { - if (EXPANDED_AGRP(agrp)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - } - - if (agrp->flag & AGRP_MUTED) - mute = ICON_MUTE_IPO_ON; - else - mute = ICON_MUTE_IPO_OFF; - - if (EDITABLE_AGRP(agrp)) - protect = ICON_UNLOCKED; - else - protect = ICON_LOCKED; - - sel = SEL_AGRP(agrp); - strcpy(name, agrp->name); - } - break; - case ANIMTYPE_FCURVE: /* F-Curve channel */ - { - FCurve *fcu = (FCurve *)ale->data; - - indent = 0; - - group= (fcu->grp) ? 1 : 0; - grp= fcu->grp; - - if (ale->id) { - /* special exception for materials and particles */ - if (ELEM(GS(ale->id->name),ID_MA,ID_PA)) { - offset= 21; - indent= 1; - } - else - offset= 14; - } - else - offset= 0; - - if (fcu->flag & FCURVE_MUTED) - mute = ICON_MUTE_IPO_ON; - else - mute = ICON_MUTE_IPO_OFF; - - if (fcu->bezt) { - if (EDITABLE_FCU(fcu)) - protect = ICON_UNLOCKED; - else - protect = ICON_LOCKED; - } - else - protect = ICON_ZOOMOUT; // XXX editability is irrelevant here, but this icon is temp... - - sel = SEL_FCU(fcu); - - getname_anim_fcurve(name, ale->id, fcu); - } - break; - - case ANIMTYPE_SHAPEKEY: /* shapekey channel */ - { - KeyBlock *kb = (KeyBlock *)ale->data; - - indent = 0; - special = -1; - - offset= (ale->id) ? 21 : 0; - - if (kb->name[0] == '\0') - sprintf(name, "Key %d", ale->index); - else - strcpy(name, kb->name); - } - break; - - case ANIMTYPE_GPDATABLOCK: /* gpencil datablock */ - { - bGPdata *gpd = (bGPdata *)ale->data; - ScrArea *sa = (ScrArea *)ale->owner; - - indent = 0; - group= 3; - - /* only show expand if there are any channels */ - if (gpd->layers.first) { - if (gpd->flag & GP_DATA_EXPAND) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - } - - switch (sa->spacetype) { - case SPACE_VIEW3D: - { - /* this shouldn't cause any overflow... */ - //sprintf(name, "3DView:%s", view3d_get_name(sa->spacedata.first)); // XXX missing func.. - strcpy(name, "3dView"); - special= ICON_VIEW3D; - } - break; - case SPACE_NODE: - { - SpaceNode *snode= sa->spacedata.first; - char treetype[12]; - - if (snode->treetype == 1) - strcpy(treetype, "Composite"); - else - strcpy(treetype, "Material"); - sprintf(name, "Nodes:%s", treetype); - - special= ICON_NODE; - } - break; - case SPACE_SEQ: - { - SpaceSeq *sseq= sa->spacedata.first; - char imgpreview[10]; - - switch (sseq->mainb) { - case 1: sprintf(imgpreview, "Image..."); break; - case 2: sprintf(imgpreview, "Luma..."); break; - case 3: sprintf(imgpreview, "Chroma..."); break; - case 4: sprintf(imgpreview, "Histogram"); break; - - default: sprintf(imgpreview, "Sequence"); break; - } - sprintf(name, "Sequencer:%s", imgpreview); - - special= ICON_SEQUENCE; - } - break; - case SPACE_IMAGE: - { - SpaceImage *sima= sa->spacedata.first; - - if (sima->image) - sprintf(name, "Image:%s", sima->image->id.name+2); - else - strcpy(name, "Image:<None>"); - - special= ICON_IMAGE_COL; - } - break; - - default: - { - sprintf(name, "<Unknown GP-Data Source>"); - special= -1; - } - break; - } - } - break; - case ANIMTYPE_GPLAYER: /* gpencil layer */ - { - bGPDlayer *gpl = (bGPDlayer *)ale->data; - - indent = 0; - special = -1; - expand = -1; - group = 1; - - if (EDITABLE_GPL(gpl)) - protect = ICON_UNLOCKED; - else - protect = ICON_LOCKED; - - if (gpl->flag & GP_LAYER_HIDE) - mute = ICON_MUTE_IPO_ON; - else - mute = ICON_MUTE_IPO_OFF; - - sel = SEL_GPL(gpl); - BLI_snprintf(name, 32, gpl->info); - } - break; - } + for (ale= anim_data.first; ale; ale= ale->next) { + float yminc= (float)(y - ACHANNEL_HEIGHT_HALF); + float ymaxc= (float)(y + ACHANNEL_HEIGHT_HALF); - /* now, start drawing based on this information */ - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_BLEND); - - /* draw backing strip behind channel name */ - if (group == 4) { - /* only used in dopesheet... */ - if (ELEM(ale->type, ANIMTYPE_SCENE, ANIMTYPE_OBJECT)) { - /* object channel - darker */ - UI_ThemeColor(TH_DOPESHEET_CHANNELOB); - uiSetRoundBox((expand == ICON_TRIA_DOWN)? (1):(1|8)); - gl_round_box(GL_POLYGON, x+offset, yminc, (float)ACHANNEL_NAMEWIDTH, ymaxc, 8); - } - else { - /* sub-object folders - lighter */ - UI_ThemeColor(TH_DOPESHEET_CHANNELSUBOB); - - offset += 7 * indent; - glBegin(GL_QUADS); - glVertex2f(x+offset, yminc); - glVertex2f(x+offset, ymaxc); - glVertex2f((float)ACHANNEL_NAMEWIDTH, ymaxc); - glVertex2f((float)ACHANNEL_NAMEWIDTH, yminc); - glEnd(); - - /* clear group value, otherwise we cause errors... */ - group = 0; - } - } - else if (group == 3) { - /* only for gp-data channels */ - UI_ThemeColorShade(TH_GROUP, 20); - uiSetRoundBox((expand == ICON_TRIA_DOWN)? (1):(1|8)); - gl_round_box(GL_POLYGON, x+offset, yminc, (float)ACHANNEL_NAMEWIDTH, ymaxc, 8); - } - else if (group == 2) { - /* only for action group channels */ - if (ale->flag & AGRP_ACTIVE) - UI_ThemeColorShade(TH_GROUP_ACTIVE, 10); - else - UI_ThemeColorShade(TH_GROUP, 20); - uiSetRoundBox((expand == ICON_TRIA_DOWN)? (1):(1|8)); - gl_round_box(GL_POLYGON, x+offset, yminc, (float)ACHANNEL_NAMEWIDTH, ymaxc, 8); - } - else { - /* for normal channels - * - use 3 shades of color group/standard color for 3 indention level - * - only use group colors if allowed to, and if actually feasible - */ - if ( !(saction->flag & SACTION_NODRAWGCOLORS) && - (grp) && (grp->customCol) ) - { - char cp[3]; - - if (indent == 2) { - VECCOPY(cp, grp->cs.solid); - } - else if (indent == 1) { - VECCOPY(cp, grp->cs.select); - } - else { - VECCOPY(cp, grp->cs.active); - } - - glColor3ub(cp[0], cp[1], cp[2]); - } - else - UI_ThemeColorShade(TH_HEADER, ((indent==0)?20: (indent==1)?-20: -40)); - - indent += group; - offset += 7 * indent; - glBegin(GL_QUADS); - glVertex2f(x+offset, yminc); - glVertex2f(x+offset, ymaxc); - glVertex2f((float)ACHANNEL_NAMEWIDTH, ymaxc); - glVertex2f((float)ACHANNEL_NAMEWIDTH, yminc); - glEnd(); - } - - /* draw expand/collapse triangle */ - if (expand > 0) { - UI_icon_draw(x+offset, yminc, expand); - offset += 17; - } - - /* draw special icon indicating certain data-types */ - if (special > -1) { - if (ELEM(group, 3, 4)) { - /* for gpdatablock channels */ - UI_icon_draw(x+offset, yminc, special); - offset += 17; - } - else { - /* for normal channels */ - UI_icon_draw(x+offset, yminc, special); - offset += 17; - } + /* check if visible */ + if ( IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || + IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) ) + { + /* draw all channels using standard channel-drawing API */ + ANIM_channel_draw(ac, ale, yminc, ymaxc); } - glDisable(GL_BLEND); - - /* draw name */ - if (sel) - UI_ThemeColor(TH_TEXT_HI); - else - UI_ThemeColor(TH_TEXT); - offset += 3; - UI_DrawString(x+offset, y-4, name); - /* reset offset - for RHS of panel */ - offset = 0; - - /* set blending again, as text drawing may clear it */ - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_BLEND); + /* adjust y-position for next one */ + y -= ACHANNEL_STEP; + } + } + { /* second pass: widgets */ + uiBlock *block= uiBeginBlock(C, ar, "dopesheet channel buttons", UI_EMBOSS); + + y= (float)ACHANNEL_FIRST; + + for (ale= anim_data.first; ale; ale= ale->next) { + float yminc= (float)(y - ACHANNEL_HEIGHT_HALF); + float ymaxc= (float)(y + ACHANNEL_HEIGHT_HALF); - /* draw protect 'lock' */ - if (protect > -1) { - offset = 16; - UI_icon_draw((float)ACHANNEL_NAMEWIDTH-offset, yminc, protect); + /* check if visible */ + if ( IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || + IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) ) + { + /* draw all channels using standard channel-drawing API */ + ANIM_channel_draw_widgets(ac, ale, block, yminc, ymaxc); } - /* draw mute 'eye' */ - if (mute > -1) { - offset += 16; - UI_icon_draw((float)(ACHANNEL_NAMEWIDTH-offset), yminc, mute); - } - glDisable(GL_BLEND); + /* adjust y-position for next one */ + y -= ACHANNEL_STEP; } - /* adjust y-position for next one */ - y -= ACHANNEL_STEP; + uiEndBlock(C, block); + uiDrawBlock(C, block); } /* free tempolary channels */ @@ -1052,7 +218,6 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar) adt= ANIM_nla_mapping_get(ac, NULL); /* start and end of action itself */ - // TODO: this has not had scaling applied calc_action_range(ac->data, &act_start, &act_end, 0); } @@ -1084,43 +249,14 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar) if ( IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) ) { + bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale); int sel=0; /* determine if any need to draw channel */ if (ale->datatype != ALE_NONE) { /* determine if channel is selected */ - switch (ale->type) { - case ANIMTYPE_SCENE: - { - Scene *sce= (Scene *)ale->data; - sel = SEL_SCEC(sce); - } - break; - case ANIMTYPE_OBJECT: - { - Base *base= (Base *)ale->data; - sel = SEL_OBJC(base); - } - break; - case ANIMTYPE_GROUP: - { - bActionGroup *agrp = (bActionGroup *)ale->data; - sel = SEL_AGRP(agrp); - } - break; - case ANIMTYPE_FCURVE: - { - FCurve *fcu = (FCurve *)ale->data; - sel = SEL_FCU(fcu); - } - break; - case ANIMTYPE_GPLAYER: - { - bGPDlayer *gpl = (bGPDlayer *)ale->data; - sel = SEL_GPL(gpl); - } - break; - } + if (acf->has_setting(ac, ale, ACHANNEL_SETTING_SELECT)) + sel= ANIM_channel_setting_get(ac, ale, ACHANNEL_SETTING_SELECT); if (ELEM(ac->datatype, ANIMCONT_ACTION, ANIMCONT_DOPESHEET)) { switch (ale->type) { diff --git a/source/blender/editors/space_action/action_header.c b/source/blender/editors/space_action/action_header.c index d3929a22342..e2a725164c9 100644 --- a/source/blender/editors/space_action/action_header.c +++ b/source/blender/editors/space_action/action_header.c @@ -43,6 +43,7 @@ #include "BLI_blenlib.h" #include "BKE_animsys.h" +#include "BKE_action.h" #include "BKE_context.h" #include "BKE_screen.h" @@ -88,9 +89,9 @@ static void act_viewmenu(bContext *C, uiLayout *layout, void *arg_unused) //uiItemS(layout); - uiItemR(layout, NULL, 0, &spaceptr, "show_cframe_indicator", 0, 0, 0); - uiItemR(layout, NULL, 0, &spaceptr, "show_sliders", 0, 0, 0); - uiItemR(layout, NULL, 0, &spaceptr, "automerge_keyframes", 0, 0, 0); + uiItemR(layout, NULL, 0, &spaceptr, "show_cframe_indicator", 0); + uiItemR(layout, NULL, 0, &spaceptr, "show_sliders", 0); + uiItemR(layout, NULL, 0, &spaceptr, "automerge_keyframes", 0); if (sact->flag & SACTION_DRAWTIME) uiItemO(layout, "Show Frames", 0, "ANIM_OT_time_toggle"); @@ -153,7 +154,7 @@ static void act_channelmenu(bContext *C, uiLayout *layout, void *arg_unused) static void act_gplayermenu(bContext *C, uiLayout *layout, void *arg_unused) { - //uiItemMenuF(layout, "Transform", 0, nla_edit_transformmenu); + //uiItemMenuF(layout, "Transform", 0, nla_edit_transformmenu, NULL, NULL); //uiItemS(layout); //uiItemO(layout, NULL, 0, "NLAEDIT_OT_duplicate"); } @@ -210,9 +211,9 @@ static void act_edit_expomenu(bContext *C, uiLayout *layout, void *arg_unused) static void act_editmenu(bContext *C, uiLayout *layout, void *arg_unused) { - uiItemMenuF(layout, "Transform", 0, act_edit_transformmenu); - uiItemMenuF(layout, "Snap", 0, act_edit_snapmenu); - uiItemMenuF(layout, "Mirror", 0, act_edit_mirrormenu); + uiItemMenuF(layout, "Transform", 0, act_edit_transformmenu, NULL); + uiItemMenuF(layout, "Snap", 0, act_edit_snapmenu, NULL); + uiItemMenuF(layout, "Mirror", 0, act_edit_mirrormenu, NULL); uiItemS(layout); @@ -225,9 +226,9 @@ static void act_editmenu(bContext *C, uiLayout *layout, void *arg_unused) uiItemS(layout); - uiItemMenuF(layout, "Handle Type", 0, act_edit_handlesmenu); - uiItemMenuF(layout, "Interpolation Mode", 0, act_edit_ipomenu); - uiItemMenuF(layout, "Extrapolation Mode", 0, act_edit_expomenu); + uiItemMenuF(layout, "Handle Type", 0, act_edit_handlesmenu, NULL); + uiItemMenuF(layout, "Interpolation Mode", 0, act_edit_ipomenu, NULL); + uiItemMenuF(layout, "Extrapolation Mode", 0, act_edit_expomenu, NULL); uiItemS(layout); @@ -272,6 +273,7 @@ static void saction_idpoin_handle(bContext *C, ID *id, int event) /* set action */ printf("\tset action \n"); adt->action= saction->action; + adt->action->id.us++; } ED_area_tag_redraw(CTX_wm_area(C)); @@ -282,7 +284,14 @@ static void saction_idpoin_handle(bContext *C, ID *id, int event) break; case UI_ID_ADD_NEW: printf("actedit addnew \n"); - /* XXX not implemented */ + if (saction->pin == 0) { + AnimData *adt= BKE_id_add_animdata(&obact->id); /* this only adds if non-existant */ + + /* set new action */ + // XXX need to restore behaviour to copy old actions... + printf("\tset new action \n"); + adt->action= saction->action= add_empty_action("Action"); + } break; case UI_ID_OPEN: printf("actedit open \n"); @@ -404,13 +413,13 @@ void action_header_buttons(const bContext *C, ARegion *ar) if (saction->flag & SACTION_DRAWTIME) { uiDefButC(block, MENU, B_REDR, "Auto-Snap Keyframes %t|No Snap %x0|Second Step %x1|Nearest Second %x2|Nearest Marker %x3", - xco,yco,70,YIC, &(saction->autosnap), 0, 1, 0, 0, + xco,yco,90,YIC, &(saction->autosnap), 0, 1, 0, 0, "Auto-snapping mode for keyframes when transforming"); } else { uiDefButC(block, MENU, B_REDR, "Auto-Snap Keyframes %t|No Snap %x0|Frame Step %x1|Nearest Frame %x2|Nearest Marker %x3", - xco,yco,70,YIC, &(saction->autosnap), 0, 1, 0, 0, + xco,yco,90,YIC, &(saction->autosnap), 0, 1, 0, 0, "Auto-snapping mode for keyframes when transforming"); } diff --git a/source/blender/editors/space_action/action_intern.h b/source/blender/editors/space_action/action_intern.h index 26655892176..1aeeeff0c80 100644 --- a/source/blender/editors/space_action/action_intern.h +++ b/source/blender/editors/space_action/action_intern.h @@ -41,7 +41,7 @@ struct bAnimListElem; /* ***************************************** */ /* action_draw.c */ -void draw_channel_names(struct bAnimContext *ac, struct SpaceAction *saction, struct ARegion *ar); +void draw_channel_names(struct bContext *C, struct bAnimContext *ac, struct SpaceAction *saction, struct ARegion *ar); void draw_channel_strips(struct bAnimContext *ac, struct SpaceAction *saction, struct ARegion *ar); struct ActKeysInc *init_aki_data(struct bAnimContext *ac, struct bAnimListElem *ale); diff --git a/source/blender/editors/space_action/space_action.c b/source/blender/editors/space_action/space_action.c index 55e035cfced..2977d07d845 100644 --- a/source/blender/editors/space_action/space_action.c +++ b/source/blender/editors/space_action/space_action.c @@ -243,7 +243,7 @@ static void action_channel_area_draw(const bContext *C, ARegion *ar) /* data */ if (ANIM_animdata_get_context(C, &ac)) { - draw_channel_names(&ac, saction, ar); + draw_channel_names((bContext *)C, &ac, saction, ar); } /* reset view matrix */ @@ -294,6 +294,7 @@ static void action_channel_area_listener(ARegion *ar, wmNotifier *wmn) case NC_SCENE: switch(wmn->data) { case ND_OB_ACTIVE: + case ND_FRAME: ED_region_tag_redraw(ar); break; } diff --git a/source/blender/editors/space_api/spacetypes.c b/source/blender/editors/space_api/spacetypes.c index 5c33b648947..041e6a09323 100644 --- a/source/blender/editors/space_api/spacetypes.c +++ b/source/blender/editors/space_api/spacetypes.c @@ -77,6 +77,7 @@ void ED_spacetypes_init(void) ED_spacetype_sequencer(); ED_spacetype_logic(); ED_spacetype_console(); + ED_spacetype_userpref(); // ... /* register operator types for screen and all spaces */ diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c index 614017cc4c6..8306487013a 100644 --- a/source/blender/editors/space_buttons/buttons_context.c +++ b/source/blender/editors/space_buttons/buttons_context.c @@ -49,6 +49,7 @@ #include "BKE_global.h" #include "BKE_material.h" #include "BKE_modifier.h" +#include "BKE_paint.h" #include "BKE_particle.h" #include "BKE_screen.h" #include "BKE_utildefines.h" @@ -304,7 +305,7 @@ static int buttons_context_path_particle(ButsContextPath *path) return 0; } -static int buttons_context_path_brush(ButsContextPath *path) +static int buttons_context_path_brush(const bContext *C, ButsContextPath *path) { Scene *scene; ToolSettings *ts; @@ -320,14 +321,8 @@ static int buttons_context_path_brush(ButsContextPath *path) scene= path->ptr[path->len-1].data; ts= scene->toolsettings; - if(G.f & G_SCULPTMODE) - br= ts->sculpt->brush; - else if(G.f & G_VERTEXPAINT) - br= ts->vpaint->brush; - else if(G.f & G_WEIGHTPAINT) - br= ts->wpaint->brush; - else if(G.f & G_TEXTUREPAINT) - br= ts->imapaint.brush; + if(scene) + br= paint_brush(paint_get_active(scene)); if(br) { RNA_id_pointer_create(&br->id, &path->ptr[path->len]); @@ -337,11 +332,11 @@ static int buttons_context_path_brush(ButsContextPath *path) } } - /* no path to a world possible */ + /* no path to a brush possible */ return 0; } -static int buttons_context_path_texture(ButsContextPath *path) +static int buttons_context_path_texture(const bContext *C, ButsContextPath *path) { Material *ma; Lamp *la; @@ -356,7 +351,7 @@ static int buttons_context_path_texture(ButsContextPath *path) return 1; } /* try brush */ - else if((path->flag & SB_BRUSH_TEX) && buttons_context_path_brush(path)) { + else if((path->flag & SB_BRUSH_TEX) && buttons_context_path_brush(C, path)) { br= path->ptr[path->len-1].data; if(br) { @@ -465,7 +460,7 @@ static int buttons_context_path(const bContext *C, ButsContextPath *path, int ma found= buttons_context_path_material(path); break; case BCONTEXT_TEXTURE: - found= buttons_context_path_texture(path); + found= buttons_context_path_texture(C, path); break; case BCONTEXT_BONE: found= buttons_context_path_bone(path); @@ -558,7 +553,7 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r "world", "object", "mesh", "armature", "lattice", "curve", "meta_ball", "lamp", "camera", "material", "material_slot", "texture", "texture_slot", "bone", "edit_bone", "particle_system", - "cloth", "soft_body", "fluid", "collision", "brush", NULL}; + "cloth", "soft_body", "fluid", "smoke", "smoke_hr", "collision", "brush", NULL}; CTX_data_dir_set(result, dir); return 1; @@ -691,6 +686,17 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r return 1; } } + + else if(CTX_data_equals(member, "smoke")) { + PointerRNA *ptr= get_pointer_type(path, &RNA_Object); + + if(ptr && ptr->data) { + Object *ob= ptr->data; + ModifierData *md= modifiers_findByType(ob, eModifierType_Smoke); + CTX_data_pointer_set(result, &ob->id, &RNA_SmokeModifier, md); + return 1; + } + } else if(CTX_data_equals(member, "collision")) { PointerRNA *ptr= get_pointer_type(path, &RNA_Object); diff --git a/source/blender/editors/space_buttons/buttons_ops.c b/source/blender/editors/space_buttons/buttons_ops.c index 4e9715538a0..d4b5997ed95 100644 --- a/source/blender/editors/space_buttons/buttons_ops.c +++ b/source/blender/editors/space_buttons/buttons_ops.c @@ -920,7 +920,7 @@ static int toolbox_invoke(bContext *C, wmOperator *op, wmEvent *event) uiPopupMenu *pup; uiLayout *layout; - RNA_pointer_create(&sc->id, &RNA_SpaceButtonsWindow, sbuts, &ptr); + RNA_pointer_create(&sc->id, &RNA_SpaceProperties, sbuts, &ptr); pup= uiPupMenuBegin(C, "Align", 0); layout= uiPupMenuLayout(pup); diff --git a/source/blender/editors/space_console/console_ops.c b/source/blender/editors/space_console/console_ops.c index fa9055f2d8d..f8dbe0c3dd4 100644 --- a/source/blender/editors/space_console/console_ops.c +++ b/source/blender/editors/space_console/console_ops.c @@ -280,6 +280,7 @@ void CONSOLE_OT_move(wmOperatorType *ot) { /* identifiers */ ot->name= "Move Cursor"; + ot->description= "Move cursor position."; ot->idname= "CONSOLE_OT_move"; /* api callbacks */ @@ -324,6 +325,7 @@ void CONSOLE_OT_insert(wmOperatorType *ot) { /* identifiers */ ot->name= "Insert"; + ot->description= "Insert text at cursor position."; ot->idname= "CONSOLE_OT_insert"; /* api callbacks */ @@ -391,6 +393,7 @@ void CONSOLE_OT_delete(wmOperatorType *ot) { /* identifiers */ ot->name= "Delete"; + ot->description= "Delete text by cursor position."; ot->idname= "CONSOLE_OT_delete"; /* api callbacks */ @@ -434,6 +437,7 @@ void CONSOLE_OT_clear(wmOperatorType *ot) { /* identifiers */ ot->name= "Clear"; + ot->description= "Clear text by type."; ot->idname= "CONSOLE_OT_clear"; /* api callbacks */ @@ -478,6 +482,7 @@ void CONSOLE_OT_history_cycle(wmOperatorType *ot) { /* identifiers */ ot->name= "History Cycle"; + ot->description= "Cycle through history."; ot->idname= "CONSOLE_OT_history_cycle"; /* api callbacks */ @@ -525,6 +530,7 @@ void CONSOLE_OT_history_append(wmOperatorType *ot) { /* identifiers */ ot->name= "History Append"; + ot->description= "Append history at cursor position."; ot->idname= "CONSOLE_OT_history_append"; /* api callbacks */ @@ -572,6 +578,7 @@ void CONSOLE_OT_scrollback_append(wmOperatorType *ot) /* identifiers */ ot->name= "Scrollback Append"; + ot->description= "Append scrollback text by type."; ot->idname= "CONSOLE_OT_scrollback_append"; /* api callbacks */ @@ -614,6 +621,7 @@ void CONSOLE_OT_copy(wmOperatorType *ot) { /* identifiers */ ot->name= "Copy to Clipboard"; + ot->description= "Copy selected text to clipboard."; ot->idname= "CONSOLE_OT_copy"; /* api callbacks */ @@ -648,6 +656,7 @@ void CONSOLE_OT_paste(wmOperatorType *ot) { /* identifiers */ ot->name= "Paste from Clipboard"; + ot->description= "Paste text from clipboard."; ot->idname= "CONSOLE_OT_paste"; /* api callbacks */ @@ -679,6 +688,9 @@ void CONSOLE_OT_zoom(wmOperatorType *ot) { /* identifiers */ ot->name= "Console Zoom"; + /*optionals - + "Zoom view font." */ + ot->description= "Zoom screen area."; ot->idname= "CONSOLE_OT_zoom"; /* api callbacks */ diff --git a/source/blender/editors/space_console/console_report.c b/source/blender/editors/space_console/console_report.c index 2e23c4039f1..08d003f0706 100644 --- a/source/blender/editors/space_console/console_report.c +++ b/source/blender/editors/space_console/console_report.c @@ -114,6 +114,7 @@ void CONSOLE_OT_report_replay(wmOperatorType *ot) { /* identifiers */ ot->name= "Replay Operators"; + ot->description= "Replay selected reports."; ot->idname= "CONSOLE_OT_report_replay"; /* api callbacks */ @@ -160,6 +161,7 @@ void CONSOLE_OT_select_pick(wmOperatorType *ot) { /* identifiers */ ot->name= "Select report"; + ot->description= "Select reports by index."; ot->idname= "CONSOLE_OT_select_pick"; /* api callbacks */ @@ -213,6 +215,7 @@ void CONSOLE_OT_select_all_toggle(wmOperatorType *ot) { /* identifiers */ ot->name= "(De)Select All"; + ot->description= "(de)select all reports."; ot->idname= "CONSOLE_OT_select_all_toggle"; /* api callbacks */ @@ -304,6 +307,7 @@ void CONSOLE_OT_select_border(wmOperatorType *ot) { /* identifiers */ ot->name= "Border Select"; + ot->description= "Toggle border selection."; ot->idname= "CONSOLE_OT_select_border"; /* api callbacks */ @@ -357,6 +361,7 @@ void CONSOLE_OT_report_delete(wmOperatorType *ot) { /* identifiers */ ot->name= "Delete Reports"; + ot->description= "Delete selected reports."; ot->idname= "CONSOLE_OT_report_delete"; /* api callbacks */ @@ -401,6 +406,7 @@ void CONSOLE_OT_report_copy(wmOperatorType *ot) { /* identifiers */ ot->name= "Copy Reports to Clipboard"; + ot->description= "Copy selected reports to Clipboard."; ot->idname= "CONSOLE_OT_report_copy"; /* api callbacks */ diff --git a/source/blender/editors/space_file/Makefile b/source/blender/editors/space_file/Makefile index 2f4180448e5..43b2f09ed2d 100644 --- a/source/blender/editors/space_file/Makefile +++ b/source/blender/editors/space_file/Makefile @@ -59,3 +59,7 @@ ifeq ($(WITH_OPENJPEG),true) CPPFLAGS += -DWITH_OPENJPEG endif +ifeq ($(WITH_OPENEXR), true) + CPPFLAGS += -DWITH_OPENEXR +endif + diff --git a/source/blender/editors/space_file/SConscript b/source/blender/editors/space_file/SConscript index 36e042bdaa6..e6fba38fb8f 100644 --- a/source/blender/editors/space_file/SConscript +++ b/source/blender/editors/space_file/SConscript @@ -12,5 +12,7 @@ defs = [] if env['WITH_BF_OPENJPEG']: defs.append('WITH_OPENJPEG') +if env['WITH_BF_OPENEXR']: + defs.append('WITH_OPENEXR') env.BlenderLib ( 'bf_editors_space_file', sources, Split(incs), defs, libtype=['core'], priority=[115] ) diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c index 5a07c6a7550..00024ffa961 100644 --- a/source/blender/editors/space_file/file_draw.c +++ b/source/blender/editors/space_file/file_draw.c @@ -353,59 +353,9 @@ void file_calc_previews(const bContext *C, ARegion *ar) UI_view2d_totRect_set(v2d, sfile->layout->width, sfile->layout->height); } -void file_draw_previews(const bContext *C, ARegion *ar) +static void file_draw_preview(short sx, short sy, ImBuf *imb, FileLayout *layout, short dropshadow) { - SpaceFile *sfile= CTX_wm_space_file(C); - FileSelectParams* params= ED_fileselect_get_params(sfile); - FileLayout* layout= ED_fileselect_get_layout(sfile, ar); - View2D *v2d= &ar->v2d; - struct FileList* files = sfile->files; - int numfiles; - struct direntry *file; - short sx, sy; - ImBuf* imb=0; - int i; - int colorid = 0; - int offset; - int is_icon; - - if (!files) return; - - filelist_imgsize(files,sfile->layout->prv_w,sfile->layout->prv_h); - numfiles = filelist_numfiles(files); - - sx = v2d->cur.xmin + layout->tile_border_x; - sy = v2d->cur.ymax - layout->tile_border_y; - - offset = ED_fileselect_layout_offset(layout, 0, 0); - if (offset<0) offset=0; - for (i=offset; (i < numfiles) && (i < (offset+(layout->rows+2)*layout->columns)); ++i) - { - ED_fileselect_layout_tilepos(layout, i, &sx, &sy); - sx += v2d->tot.xmin+2; - sy = v2d->tot.ymax - sy; - file = filelist_file(files, i); - - if (file->flags & ACTIVE) { - colorid = TH_HILITE; - draw_tile(sx - 1, sy, sfile->layout->tile_w + 1, sfile->layout->tile_h, colorid,0); - } else if (params->active_file == i) { - colorid = TH_ACTIVE; - draw_tile(sx - 1, sy, sfile->layout->tile_w + 1, sfile->layout->tile_h, colorid,0); - } - - if ( (file->flags & IMAGEFILE) /* || (file->flags & MOVIEFILE) */) - { - filelist_loadimage(files, i); - } - is_icon = 0; - imb = filelist_getimage(files, i); - if (!imb) { - imb = filelist_geticon(files,i); - is_icon = 1; - } - - if (imb) { + if (imb) { float fx, fy; float dx, dy; short xco, yco; @@ -433,15 +383,15 @@ void file_draw_previews(const bContext *C, ARegion *ar) ey = (short)scaledy; fx = ((float)layout->prv_w - (float)ex)/2.0f; fy = ((float)layout->prv_h - (float)ey)/2.0f; - dx = (fx + 0.5f + sfile->layout->prv_border_x); - dy = (fy + 0.5f - sfile->layout->prv_border_y); + dx = (fx + 0.5f + layout->prv_border_x); + dy = (fy + 0.5f - layout->prv_border_y); xco = (float)sx + dx; - yco = (float)sy - sfile->layout->prv_h + dy; + yco = (float)sy - layout->prv_h + dy; glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); /* shadow */ - if (!is_icon && (file->flags & IMAGEFILE)) + if (dropshadow) uiDrawBoxShadow(220, xco, yco, xco + ex, yco + ey); glEnable(GL_BLEND); @@ -451,7 +401,7 @@ void file_draw_previews(const bContext *C, ARegion *ar) glaDrawPixelsTexScaled(xco, yco, imb->x, imb->y, GL_UNSIGNED_BYTE, imb->rect, scale, scale); /* border */ - if (!is_icon && (file->flags & IMAGEFILE)) { + if (dropshadow) { glColor4f(0.0f, 0.0f, 0.0f, 0.4f); fdrawbox(xco, yco, xco + ex, yco + ey); } @@ -459,41 +409,6 @@ void file_draw_previews(const bContext *C, ARegion *ar) glDisable(GL_BLEND); imb = 0; } - - /* shadow */ - UI_ThemeColorShade(TH_BACK, -20); - - - if (S_ISDIR(file->type)) { - glColor4f(1.0f, 1.0f, 0.9f, 1.0f); - } - else if (file->flags & IMAGEFILE) { - UI_ThemeColor(TH_SEQ_IMAGE); - } - else if (file->flags & MOVIEFILE) { - UI_ThemeColor(TH_SEQ_MOVIE); - } - else if (file->flags & BLENDERFILE) { - UI_ThemeColor(TH_SEQ_SCENE); - } - else { - if (params->active_file == i) { - UI_ThemeColor(TH_GRID); /* grid used for active text */ - } else if (file->flags & ACTIVE) { - UI_ThemeColor(TH_TEXT_HI); - } else { - UI_ThemeColor(TH_TEXT); - } - } - - file_draw_string(sx + layout->prv_border_x, sy+4, file->relname, layout->tile_w, layout->tile_h, FILE_SHORTEN_END); - - if (!sfile->loadimage_timer) - sfile->loadimage_timer= WM_event_add_window_timer(CTX_wm_window(C), TIMER1, 1.0/30.0); /* max 30 frames/sec. */ - - } - - uiSetRoundBox(0); } static void renamebutton_cb(bContext *C, void *arg1, char *oldname) @@ -523,6 +438,39 @@ static void renamebutton_cb(bContext *C, void *arg1, char *oldname) } } + +static void draw_background(FileLayout *layout, View2D *v2d) +{ + int i; + short sy; + + /* alternating flat shade background */ + for (i=0; (i <= layout->rows); i+=2) + { + sy = v2d->cur.ymax - i*(layout->tile_h+2*layout->tile_border_y) - layout->tile_border_y; + + UI_ThemeColorShade(TH_BACK, -7); + glRectf(v2d->cur.xmin, sy, v2d->cur.xmax, sy+layout->tile_h+2*layout->tile_border_y); + + } +} + +static void draw_dividers(FileLayout *layout, View2D *v2d) +{ + short sx; + + /* vertical column dividers */ + sx = v2d->tot.xmin; + while (sx < v2d->cur.xmax) { + sx += (layout->tile_w+2*layout->tile_border_x); + + UI_ThemeColorShade(TH_BACK, 30); + sdrawline(sx+1, v2d->cur.ymax - layout->tile_border_y , sx+1, v2d->cur.ymin); + UI_ThemeColorShade(TH_BACK, -30); + sdrawline(sx, v2d->cur.ymax - layout->tile_border_y , sx, v2d->cur.ymin); + } +} + void file_draw_list(const bContext *C, ARegion *ar) { SpaceFile *sfile= CTX_wm_space_file(C); @@ -531,6 +479,7 @@ void file_draw_list(const bContext *C, ARegion *ar) View2D *v2d= &ar->v2d; struct FileList* files = sfile->files; struct direntry *file; + ImBuf *imb; int numfiles; int numfiles_layout; int colorid = 0; @@ -538,6 +487,7 @@ void file_draw_list(const bContext *C, ARegion *ar) int offset; int i; float sw, spos; + short is_icon; numfiles = filelist_numfiles(files); @@ -547,26 +497,11 @@ void file_draw_list(const bContext *C, ARegion *ar) offset = ED_fileselect_layout_offset(layout, 0, 0); if (offset<0) offset=0; - /* alternating flat shade background */ - for (i=0; (i <= layout->rows); i+=2) - { - sx = v2d->cur.xmin; - sy = v2d->cur.ymax - i*(layout->tile_h+2*layout->tile_border_y) - layout->tile_border_y; + if (params->display != FILE_IMGDISPLAY) { - UI_ThemeColorShade(TH_BACK, -7); - glRectf(v2d->cur.xmin, sy, v2d->cur.xmax, sy+layout->tile_h+2*layout->tile_border_y); - - } + draw_background(layout, v2d); - /* vertical column dividers */ - sx = v2d->tot.xmin; - while (sx < ar->v2d.cur.xmax) { - sx += (sfile->layout->tile_w+2*sfile->layout->tile_border_x); - - UI_ThemeColorShade(TH_BACK, 30); - sdrawline(sx+1, ar->v2d.cur.ymax - layout->tile_border_y , sx+1, ar->v2d.cur.ymin); - UI_ThemeColorShade(TH_BACK, -30); - sdrawline(sx, ar->v2d.cur.ymax - layout->tile_border_y , sx, ar->v2d.cur.ymin); + draw_dividers(layout, v2d); } sx = ar->v2d.cur.xmin + layout->tile_border_x; @@ -594,16 +529,33 @@ void file_draw_list(const bContext *C, ARegion *ar) } spos = sx; - file_draw_icon(spos, sy-3, get_file_icon(file), ICON_DEFAULT_WIDTH, ICON_DEFAULT_WIDTH); - spos += ICON_DEFAULT_WIDTH + 4; - + + if ( FILE_IMGDISPLAY == params->display ) { + if ( (file->flags & IMAGEFILE) /* || (file->flags & MOVIEFILE) */) { + filelist_loadimage(files, i); + } + is_icon = 0; + imb = filelist_getimage(files, i); + if (!imb) { + imb = filelist_geticon(files,i); + is_icon = 1; + } + + file_draw_preview(sx, sy, imb, layout, !is_icon && (file->flags & IMAGEFILE)); + + } else { + file_draw_icon(spos, sy-3, get_file_icon(file), ICON_DEFAULT_WIDTH, ICON_DEFAULT_WIDTH); + spos += ICON_DEFAULT_WIDTH + 4; + } + UI_ThemeColor4(TH_TEXT); - + sw = file_string_width(file->relname); if (file->flags & EDITING) { + short but_width = (FILE_IMGDISPLAY == params->display) ? layout->tile_w : layout->column_widths[COLUMN_NAME]; uiBlock *block = uiBeginBlock(C, ar, "FileName", UI_EMBOSS); uiBut *but = uiDefBut(block, TEX, 1, "", spos, sy-layout->tile_h-3, - layout->column_widths[COLUMN_NAME], layout->tile_h, file->relname, 1.0f, (float)FILE_MAX,0,0,""); + but_width, layout->textheight*2, file->relname, 1.0f, (float)FILE_MAX,0,0,""); uiButSetRenameFunc(but, renamebutton_cb, file); if ( 0 == uiButActiveOnly(C, block, but)) { file->flags &= ~EDITING; @@ -611,36 +563,42 @@ void file_draw_list(const bContext *C, ARegion *ar) uiEndBlock(C, block); uiDrawBlock(C, block); } else { - file_draw_string(spos, sy, file->relname, sw, layout->tile_h, FILE_SHORTEN_END); + float name_width = (FILE_IMGDISPLAY == params->display) ? layout->tile_w : sw; + file_draw_string(spos, sy, file->relname, name_width, layout->tile_h, FILE_SHORTEN_END); } - spos += layout->column_widths[COLUMN_NAME] + 12; - if (params->display == FILE_SHOWSHORT) { + + uiSetRoundBox(0); + + if (params->display == FILE_SHORTDISPLAY) { + spos += layout->column_widths[COLUMN_NAME] + 12; if (!(file->type & S_IFDIR)) { sw = file_string_width(file->size); spos += layout->column_widths[COLUMN_SIZE] + 12 - sw; file_draw_string(spos, sy, file->size, sw+1, layout->tile_h, FILE_SHORTEN_END); } - } else { -#if 0 // XXX TODO: add this for non-windows systems + } else if (params->display == FILE_LONGDISPLAY) { + spos += layout->column_widths[COLUMN_NAME] + 12; + +#ifndef WIN32 /* rwx rwx rwx */ spos += 20; - sw = UI_GetStringWidth(file->mode1); - file_draw_string(spos, sy, file->mode1, sw, layout->tile_h); - - spos += 30; - sw = UI_GetStringWidth(file->mode2); - file_draw_string(spos, sy, file->mode2, sw, layout->tile_h); + sw = file_string_width(file->mode1); + file_draw_string(spos, sy, file->mode1, sw, layout->tile_h, FILE_SHORTEN_END); + spos += layout->column_widths[COLUMN_MODE1] + 12; - spos += 30; - sw = UI_GetStringWidth(file->mode3); - file_draw_string(spos, sy, file->mode3, sw, layout->tile_h); - - spos += 30; - sw = UI_GetStringWidth(file->owner); - file_draw_string(spos, sy, file->owner, sw, layout->tile_h); + sw = file_string_width(file->mode2); + file_draw_string(spos, sy, file->mode2, sw, layout->tile_h, FILE_SHORTEN_END); + spos += layout->column_widths[COLUMN_MODE2] + 12; + + sw = file_string_width(file->mode3); + file_draw_string(spos, sy, file->mode3, sw, layout->tile_h, FILE_SHORTEN_END); + spos += layout->column_widths[COLUMN_MODE3] + 12; + + sw = file_string_width(file->owner); + file_draw_string(spos, sy, file->owner, sw, layout->tile_h, FILE_SHORTEN_END); + spos += layout->column_widths[COLUMN_OWNER] + 12; #endif - sw = file_string_width(file->date); file_draw_string(spos, sy, file->date, sw, layout->tile_h, FILE_SHORTEN_END); spos += layout->column_widths[COLUMN_DATE] + 12; @@ -656,6 +614,9 @@ void file_draw_list(const bContext *C, ARegion *ar) } } } + + if (!sfile->loadimage_timer) + sfile->loadimage_timer= WM_event_add_window_timer(CTX_wm_window(C), TIMER1, 1.0/30.0); /* max 30 frames/sec. */ } diff --git a/source/blender/editors/space_file/file_panels.c b/source/blender/editors/space_file/file_panels.c index f3c18859fb0..c48b3529389 100644 --- a/source/blender/editors/space_file/file_panels.c +++ b/source/blender/editors/space_file/file_panels.c @@ -170,23 +170,28 @@ static void file_panel_operator(const bContext *C, Panel *pa) wmOperator *op= sfile->op; int empty= 1; - RNA_STRUCT_BEGIN(op->ptr, prop) { - if(strcmp(RNA_property_identifier(prop), "rna_type") == 0) - continue; - if(strcmp(RNA_property_identifier(prop), "filename") == 0) - continue; - if(strcmp(RNA_property_identifier(prop), "display") == 0) - continue; - if(strncmp(RNA_property_identifier(prop), "filter", 6) == 0) - continue; - - uiItemFullR(pa->layout, NULL, 0, op->ptr, prop, -1, 0, 0, 0, 0); - empty= 0; + if(op->type->ui) { + op->type->ui((bContext*)C, op->ptr, pa->layout); } - RNA_STRUCT_END; + else { + RNA_STRUCT_BEGIN(op->ptr, prop) { + if(strcmp(RNA_property_identifier(prop), "rna_type") == 0) + continue; + if(strcmp(RNA_property_identifier(prop), "filename") == 0) + continue; + if(strcmp(RNA_property_identifier(prop), "display") == 0) + continue; + if(strncmp(RNA_property_identifier(prop), "filter", 6) == 0) + continue; + + uiItemFullR(pa->layout, NULL, 0, op->ptr, prop, -1, 0, 0); + empty= 0; + } + RNA_STRUCT_END; - if(empty) - uiItemL(pa->layout, "No properties.", 0); + if(empty) + uiItemL(pa->layout, "No properties.", 0); + } } void file_panels_register(ARegionType *art) diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c index 7ebc8c4338f..538c1e4fce7 100644 --- a/source/blender/editors/space_file/filelist.c +++ b/source/blender/editors/space_file/filelist.c @@ -840,7 +840,16 @@ void filelist_setfiletypes(struct FileList* filelist, short has_quicktime) || BLI_testextensie(file->relname, ".mv")) { file->flags |= MOVIEFILE; } - else if(BLI_testextensie(file->relname, ".wav")) { + else if(BLI_testextensie(file->relname, ".wav") + || BLI_testextensie(file->relname, ".ogg") + || BLI_testextensie(file->relname, ".oga") + || BLI_testextensie(file->relname, ".mp3") + || BLI_testextensie(file->relname, ".mp2") + || BLI_testextensie(file->relname, ".ac3") + || BLI_testextensie(file->relname, ".aac") + || BLI_testextensie(file->relname, ".flac") + || BLI_testextensie(file->relname, ".wma") + || BLI_testextensie(file->relname, ".eac3")) { file->flags |= SOUNDFILE; } } else { // no quicktime @@ -875,7 +884,16 @@ void filelist_setfiletypes(struct FileList* filelist, short has_quicktime) || BLI_testextensie(file->relname, ".mv")) { file->flags |= MOVIEFILE; } - else if(BLI_testextensie(file->relname, ".wav")) { + else if(BLI_testextensie(file->relname, ".wav") + || BLI_testextensie(file->relname, ".ogg") + || BLI_testextensie(file->relname, ".oga") + || BLI_testextensie(file->relname, ".mp3") + || BLI_testextensie(file->relname, ".mp2") + || BLI_testextensie(file->relname, ".ac3") + || BLI_testextensie(file->relname, ".aac") + || BLI_testextensie(file->relname, ".flac") + || BLI_testextensie(file->relname, ".wma") + || BLI_testextensie(file->relname, ".eac3")) { file->flags |= SOUNDFILE; } } diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c index 8ee7d3515b5..f300505933f 100644 --- a/source/blender/editors/space_file/filesel.c +++ b/source/blender/editors/space_file/filesel.c @@ -287,6 +287,7 @@ void ED_fileselect_init_layout(struct SpaceFile *sfile, struct ARegion *ar) numfiles = filelist_numfiles(sfile->files); textheight = file_font_pointsize(); layout = sfile->layout; + layout->textheight = textheight; if (params->display == FILE_IMGDISPLAY) { layout->prv_w = 96; diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c index ea640eab090..22ad03f3523 100644 --- a/source/blender/editors/space_file/space_file.c +++ b/source/blender/editors/space_file/space_file.c @@ -310,12 +310,7 @@ static void file_main_area_draw(const bContext *C, ARegion *ar) file_hilight_set(sfile, ar, event->x, event->y); } - if (params->display == FILE_IMGDISPLAY) { - file_draw_previews(C, ar); - } else { - file_draw_list(C, ar); - } - + file_draw_list(C, ar); /* reset view matrix */ UI_view2d_view_restore(C); diff --git a/source/blender/editors/space_graph/graph_buttons.c b/source/blender/editors/space_graph/graph_buttons.c index 82babb70c53..fb995285ab7 100644 --- a/source/blender/editors/space_graph/graph_buttons.c +++ b/source/blender/editors/space_graph/graph_buttons.c @@ -160,7 +160,7 @@ static void graph_panel_properties(const bContext *C, Panel *pa) } getname_anim_fcurve(name, ale->id, fcu); - uiDefBut(block, LABEL, 1, name, 30, 180, 300, 19, NULL, 0.0, 0.0, 0, 0, "Name of Active F-Curve"); + uiDefBut(block, LABEL, 1, name, 40, 180, 300, 19, NULL, 0.0, 0.0, 0, 0, "Name of Active F-Curve"); /* TODO: the following settings could be added here * - F-Curve coloring mode - mode selector + color selector diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c index f6915c4db01..f3aa0fac42b 100644 --- a/source/blender/editors/space_graph/graph_draw.c +++ b/source/blender/editors/space_graph/graph_draw.c @@ -877,19 +877,15 @@ void graph_draw_curves (bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGri /* ************************************************************************* */ /* Channel List */ -// XXX quite a few of these need to be kept in sync with their counterparts in Action Editor -// as they're the same. We have 2 separate copies of this for now to make it easier to develop -// the diffences between the two editors, but one day these should be merged! - /* left hand part */ -void graph_draw_channel_names(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar) +void graph_draw_channel_names(bContext *C, bAnimContext *ac, SpaceIpo *sipo, ARegion *ar) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; View2D *v2d= &ar->v2d; - float x= 0.0f, y= 0.0f, height; + float y= 0.0f, height; int items, i=0; /* build list of channels to draw */ @@ -903,537 +899,57 @@ void graph_draw_channel_names(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar) * start of list offset, and the second is as a correction for the scrollers. */ height= (float)((items*ACHANNEL_STEP) + (ACHANNEL_HEIGHT*2)); - -#if 0 - if (height > (v2d->mask.ymax - v2d->mask.ymin)) { - /* don't use totrect set, as the width stays the same - * (NOTE: this is ok here, the configuration is pretty straightforward) - */ - v2d->tot.ymin= (float)(-height); - } - - /* XXX I would call the below line! (ton) */ -#endif UI_view2d_totRect_set(v2d, ar->winx, height); /* loop through channels, and set up drawing depending on their type */ - y= (float)ACHANNEL_FIRST; - - for (ale= anim_data.first, i=0; ale; ale= ale->next, i++) { - const float yminc= (float)(y - ACHANNEL_HEIGHT_HALF); - const float ymaxc= (float)(y + ACHANNEL_HEIGHT_HALF); + { /* first pass: just the standard GL-drawing for backdrop + text */ + y= (float)ACHANNEL_FIRST; - /* check if visible */ - if ( IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || - IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) ) - { - bActionGroup *grp = NULL; - short indent= 0, offset= 0, sel= 0, group= 0; - int expand= -1, protect = -1, special= -1, mute = -1; - char name[128]; + for (ale= anim_data.first, i=0; ale; ale= ale->next, i++) { + const float yminc= (float)(y - ACHANNEL_HEIGHT_HALF); + const float ymaxc= (float)(y + ACHANNEL_HEIGHT_HALF); - /* determine what needs to be drawn */ - switch (ale->type) { - case ANIMTYPE_SCENE: /* scene */ - { - Scene *sce= (Scene *)ale->data; - - group= 4; - indent= 0; - - special= ICON_SCENE_DATA; - - /* only show expand if there are any channels */ - if (EXPANDED_SCEC(sce)) - expand= ICON_TRIA_DOWN; - else - expand= ICON_TRIA_RIGHT; - - sel = SEL_SCEC(sce); - strcpy(name, sce->id.name+2); - } - break; - case ANIMTYPE_OBJECT: /* object */ - { - Base *base= (Base *)ale->data; - Object *ob= base->object; - - group= 4; - indent= 0; - - /* icon depends on object-type */ - if (ob->type == OB_ARMATURE) - special= ICON_ARMATURE_DATA; - else - special= ICON_OBJECT_DATA; - - /* only show expand if there are any channels */ - if (EXPANDED_OBJC(ob)) - expand= ICON_TRIA_DOWN; - else - expand= ICON_TRIA_RIGHT; - - sel = SEL_OBJC(base); - strcpy(name, ob->id.name+2); - } - break; - case ANIMTYPE_FILLACTD: /* action widget */ - { - bAction *act= (bAction *)ale->data; - - group = 4; - indent= 1; - special= ICON_ACTION; - - if (EXPANDED_ACTC(act)) - expand= ICON_TRIA_DOWN; - else - expand= ICON_TRIA_RIGHT; - - sel = SEL_ACTC(act); - strcpy(name, act->id.name+2); - } - break; - case ANIMTYPE_FILLDRIVERS: /* drivers widget */ - { - AnimData *adt= (AnimData *)ale->data; - - group = 4; - indent= 1; - special= ICON_ANIM_DATA; - - if (EXPANDED_DRVD(adt)) - expand= ICON_TRIA_DOWN; - else - expand= ICON_TRIA_RIGHT; - - strcpy(name, "Drivers"); - } - break; - case ANIMTYPE_FILLMATD: /* object materials (dopesheet) expand widget */ - { - Object *ob = (Object *)ale->data; - - group = 4; - indent = 1; - special = ICON_MATERIAL_DATA; - - if (FILTER_MAT_OBJC(ob)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - strcpy(name, "Materials"); - } - break; - case ANIMTYPE_FILLPARTD: /* object particles (dopesheet) expand widget */ - { - Object *ob = (Object *)ale->data; - - group = 4; - indent = 1; - special = ICON_PARTICLE_DATA; - - if (FILTER_PART_OBJC(ob)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - strcpy(name, "Particles"); - } - break; - - - case ANIMTYPE_DSMAT: /* single material (dopesheet) expand widget */ - { - Material *ma = (Material *)ale->data; - - group = 0; - indent = 0; - special = ICON_MATERIAL_DATA; - offset = 21; - - if (FILTER_MAT_OBJD(ma)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - strcpy(name, ma->id.name+2); - } - break; - case ANIMTYPE_DSLAM: /* lamp (dopesheet) expand widget */ - { - Lamp *la = (Lamp *)ale->data; - - group = 4; - indent = 1; - special = ICON_LAMP_DATA; - - if (FILTER_LAM_OBJD(la)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - strcpy(name, la->id.name+2); - } - break; - case ANIMTYPE_DSCAM: /* camera (dopesheet) expand widget */ - { - Camera *ca = (Camera *)ale->data; - - group = 4; - indent = 1; - special = ICON_CAMERA_DATA; - - if (FILTER_CAM_OBJD(ca)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - strcpy(name, ca->id.name+2); - } - break; - case ANIMTYPE_DSCUR: /* curve (dopesheet) expand widget */ - { - Curve *cu = (Curve *)ale->data; - - group = 4; - indent = 1; - special = ICON_CURVE_DATA; - - if (FILTER_CUR_OBJD(cu)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - strcpy(name, cu->id.name+2); - } - break; - case ANIMTYPE_DSSKEY: /* shapekeys (dopesheet) expand widget */ - { - Key *key= (Key *)ale->data; - - group = 4; - indent = 1; - special = ICON_SHAPEKEY_DATA; - - if (FILTER_SKE_OBJD(key)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - //sel = SEL_OBJC(base); - strcpy(name, "Shape Keys"); - } - break; - case ANIMTYPE_DSWOR: /* world (dopesheet) expand widget */ - { - World *wo= (World *)ale->data; - - group = 4; - indent = 1; - special = ICON_WORLD_DATA; - - if (FILTER_WOR_SCED(wo)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - strcpy(name, wo->id.name+2); - } - break; - case ANIMTYPE_DSPART: /* particle (dopesheet) expand widget */ - { - ParticleSettings *part= (ParticleSettings*)ale->data; - - group = 0; - indent = 0; - special = ICON_PARTICLE_DATA; - offset = 21; - - if (FILTER_PART_OBJD(part)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - strcpy(name, part->id.name+2); - } - break; - case ANIMTYPE_DSMBALL: /* metaball (dopesheet) expand widget */ - { - MetaBall *mb = (MetaBall *)ale->data; - - group = 4; - indent = 1; - special = ICON_META_DATA; - - if (FILTER_MBALL_OBJD(mb)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - strcpy(name, mb->id.name+2); - } - break; - - - case ANIMTYPE_GROUP: /* action group */ - { - bActionGroup *agrp= (bActionGroup *)ale->data; - - group= 2; - indent= 0; - special= -1; - - if (ale->id) { - /* special exception for materials */ - if (GS(ale->id->name) == ID_MA) - offset= 25; - else - offset= 14; - } - else - offset= 0; - - /* only show expand if there are any channels */ - if (agrp->channels.first) { - if (EXPANDED_AGRP(agrp)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - } - - /* for now, 'special' (i.e. in front of name) is used to show visibility status */ - if (agrp->flag & AGRP_NOTVISIBLE) - special= ICON_CHECKBOX_DEHLT; - else - special= ICON_CHECKBOX_HLT; - - if (agrp->flag & AGRP_MUTED) - mute = ICON_MUTE_IPO_ON; - else - mute = ICON_MUTE_IPO_OFF; - - if (EDITABLE_AGRP(agrp)) - protect = ICON_UNLOCKED; - else - protect = ICON_LOCKED; - - sel = SEL_AGRP(agrp); - strcpy(name, agrp->name); - } - break; - case ANIMTYPE_FCURVE: /* F-Curve channel */ - { - FCurve *fcu = (FCurve *)ale->data; - - indent = 0; - - group= (fcu->grp) ? 1 : 0; - grp= fcu->grp; - - if (ale->id) { - /* special exception for materials and particles */ - if (ELEM(GS(ale->id->name),ID_MA,ID_PA)) { - offset= 21; - indent= 1; - } - else - offset= 14; - } - else - offset= 0; - - /* for now, 'special' (i.e. in front of name) is used to show visibility status */ - if (fcu->flag & FCURVE_VISIBLE) - special= ICON_CHECKBOX_HLT; - else - special= ICON_CHECKBOX_DEHLT; - - if (fcu->flag & FCURVE_MUTED) - mute = ICON_MUTE_IPO_ON; - else - mute = ICON_MUTE_IPO_OFF; - - if (fcu->bezt) { - if (EDITABLE_FCU(fcu)) - protect = ICON_UNLOCKED; - else - protect = ICON_LOCKED; - } - else - protect = ICON_ZOOMOUT; // XXX editability is irrelevant here, but this icon is temp... - - sel = SEL_FCU(fcu); - - getname_anim_fcurve(name, ale->id, fcu); - } - break; - - case ANIMTYPE_SHAPEKEY: /* shapekey channel */ - { - KeyBlock *kb = (KeyBlock *)ale->data; - - indent = 0; - special = -1; - - offset= (ale->id) ? 21 : 0; - - if (kb->name[0] == '\0') - sprintf(name, "Key %d", ale->index); - else - strcpy(name, kb->name); - } - break; - } - - /* now, start drawing based on this information */ - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_BLEND); - - /* draw backing strip behind channel name */ - if (group == 4) { - /* only used in dopesheet... */ - if (ELEM(ale->type, ANIMTYPE_SCENE, ANIMTYPE_OBJECT)) { - /* object channel - darker */ - UI_ThemeColor(TH_DOPESHEET_CHANNELOB); - uiSetRoundBox((expand == ICON_TRIA_DOWN)? (1):(1|8)); - gl_round_box(GL_POLYGON, x+offset, yminc, (float)ACHANNEL_NAMEWIDTH, ymaxc, 8); - } - else { - /* sub-object folders - lighter */ - UI_ThemeColor(TH_DOPESHEET_CHANNELSUBOB); - - offset += 7 * indent; - glBegin(GL_QUADS); - glVertex2f(x+offset, yminc); - glVertex2f(x+offset, ymaxc); - glVertex2f((float)ACHANNEL_NAMEWIDTH, ymaxc); - glVertex2f((float)ACHANNEL_NAMEWIDTH, yminc); - glEnd(); - - /* clear group value, otherwise we cause errors... */ - group = 0; - } - } - else if (group == 3) { - /* only for gp-data channels */ - UI_ThemeColorShade(TH_GROUP, 20); - uiSetRoundBox((expand == ICON_TRIA_DOWN)? (1):(1|8)); - gl_round_box(GL_POLYGON, x+offset, yminc, (float)ACHANNEL_NAMEWIDTH, ymaxc, 8); - } - else if (group == 2) { - /* only for action group channels */ - if (ale->flag & AGRP_ACTIVE) - UI_ThemeColorShade(TH_GROUP_ACTIVE, 10); - else - UI_ThemeColorShade(TH_GROUP, 20); - uiSetRoundBox((expand == ICON_TRIA_DOWN)? (1):(1|8)); - gl_round_box(GL_POLYGON, x+offset, yminc, (float)ACHANNEL_NAMEWIDTH, ymaxc, 8); - } - else { - short shadefac= ((indent==0)?20: (indent==1)?-20: -40); - - indent += group; - offset += 7 * indent; - - /* draw channel backdrop */ - UI_ThemeColorShade(TH_HEADER, shadefac); - - glBegin(GL_QUADS); - glVertex2f(x+offset, yminc); - glVertex2f(x+offset, ymaxc); - glVertex2f((float)ACHANNEL_NAMEWIDTH, ymaxc); - glVertex2f((float)ACHANNEL_NAMEWIDTH, yminc); - glEnd(); - - /* most of the time, only F-Curves are going to be drawn here */ - if (ale->type == ANIMTYPE_FCURVE) { - /* F-Curve channels need to have a special 'color code' box drawn, which is colored with whatever - * color the curve has stored - */ - FCurve *fcu= (FCurve *)ale->data; - glColor3fv(fcu->color); - - // NOTE: only enable the following line for the fading-out gradient - //glShadeModel(GL_SMOOTH); - - glBegin(GL_QUADS); - /* solid color for the area around the checkbox */ - glVertex2f(x+offset, yminc); - glVertex2f(x+offset, ymaxc); - glVertex2f(x+offset+18, ymaxc); - glVertex2f(x+offset+18, yminc); - -#if 0 // fading out gradient - /* fading out gradient for the rest of the box */ - glVertex2f(x+offset+18, yminc); - glVertex2f(x+offset+18, ymaxc); - - UI_ThemeColorShade(TH_HEADER, shadefac); // XXX does this cause any problems on some cards? - - glVertex2f(x+offset+20, ymaxc); - glVertex2f(x+offset+20, yminc); -#endif // fading out gradient - glEnd(); - - // NOTE: only enable the following line for the fading-out gradient - //glShadeModel(GL_FLAT); - } + /* check if visible */ + if ( IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || + IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) ) + { + /* draw all channels using standard channel-drawing API */ + ANIM_channel_draw(ac, ale, yminc, ymaxc); } - /* draw expand/collapse triangle */ - if (expand > 0) { - UI_icon_draw(x+offset, yminc, expand); - offset += 17; - } - - /* draw special icon indicating certain data-types */ - if (special > -1) { - if (ELEM(group, 3, 4)) { - /* for gpdatablock channels */ - UI_icon_draw(x+offset, yminc, special); - offset += 17; - } - else { - /* for normal channels */ - UI_icon_draw(x+offset, yminc, special); - offset += 17; - } - } - glDisable(GL_BLEND); - - /* draw name */ - if (sel) - UI_ThemeColor(TH_TEXT_HI); - else - UI_ThemeColor(TH_TEXT); - offset += 3; - UI_DrawString(x+offset, y-4, name); - - /* reset offset - for RHS of panel */ - offset = 0; - - /* set blending again, as text drawing may clear it */ - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_BLEND); + /* adjust y-position for next one */ + y -= ACHANNEL_STEP; + } + } + { /* second pass: widgets */ + uiBlock *block= uiBeginBlock(C, ar, "graph channel buttons", UI_EMBOSS); + + y= (float)ACHANNEL_FIRST; + + /* set blending again, as may not be set in previous step */ + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_BLEND); + + for (ale= anim_data.first, i=0; ale; ale= ale->next, i++) { + const float yminc= (float)(y - ACHANNEL_HEIGHT_HALF); + const float ymaxc= (float)(y + ACHANNEL_HEIGHT_HALF); - /* draw protect 'lock' */ - if (protect > -1) { - offset = 16; - UI_icon_draw((float)ACHANNEL_NAMEWIDTH-offset, yminc, protect); + /* check if visible */ + if ( IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || + IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) ) + { + /* draw all channels using standard channel-drawing API */ + ANIM_channel_draw_widgets(ac, ale, block, yminc, ymaxc); } - /* draw mute 'eye' */ - if (mute > -1) { - offset += 16; - UI_icon_draw((float)(ACHANNEL_NAMEWIDTH-offset), yminc, mute); - } - glDisable(GL_BLEND); + /* adjust y-position for next one */ + y -= ACHANNEL_STEP; } - /* adjust y-position for next one */ - y -= ACHANNEL_STEP; + uiEndBlock(C, block); + uiDrawBlock(C, block); + + glDisable(GL_BLEND); } /* free tempolary channels */ diff --git a/source/blender/editors/space_graph/graph_header.c b/source/blender/editors/space_graph/graph_header.c index 2c9017db649..06d48fe20f3 100644 --- a/source/blender/editors/space_graph/graph_header.c +++ b/source/blender/editors/space_graph/graph_header.c @@ -80,15 +80,17 @@ static void graph_viewmenu(bContext *C, uiLayout *layout, void *arg_unused) uiItemS(layout); - uiItemR(layout, NULL, 0, &spaceptr, "show_cframe_indicator", 0, 0, 0); + uiItemR(layout, NULL, 0, &spaceptr, "show_cframe_indicator", 0); + uiItemR(layout, NULL, 0, &spaceptr, "show_sliders", 0); + uiItemR(layout, NULL, 0, &spaceptr, "automerge_keyframes", 0); if (sipo->flag & SIPO_NOHANDLES) uiItemO(layout, "Show Handles", ICON_CHECKBOX_DEHLT, "GRAPH_OT_handles_view_toggle"); else uiItemO(layout, "Show Handles", ICON_CHECKBOX_HLT, "GRAPH_OT_handles_view_toggle"); - uiItemR(layout, NULL, 0, &spaceptr, "only_selected_curves_handles", 0, 0, 0); - uiItemR(layout, NULL, 0, &spaceptr, "automerge_keyframes", 0, 0, 0); + uiItemR(layout, NULL, 0, &spaceptr, "only_selected_curves_handles", 0); + if (sipo->flag & SIPO_DRAWTIME) uiItemO(layout, "Show Frames", 0, "ANIM_OT_time_toggle"); @@ -201,9 +203,9 @@ static void graph_edit_expomenu(bContext *C, uiLayout *layout, void *arg_unused) static void graph_editmenu(bContext *C, uiLayout *layout, void *arg_unused) { - uiItemMenuF(layout, "Transform", 0, graph_edit_transformmenu); - uiItemMenuF(layout, "Snap", 0, graph_edit_snapmenu); - uiItemMenuF(layout, "Mirror", 0, graph_edit_mirrormenu); + uiItemMenuF(layout, "Transform", 0, graph_edit_transformmenu, NULL); + uiItemMenuF(layout, "Snap", 0, graph_edit_snapmenu, NULL); + uiItemMenuF(layout, "Mirror", 0, graph_edit_mirrormenu, NULL); uiItemS(layout); @@ -217,9 +219,9 @@ static void graph_editmenu(bContext *C, uiLayout *layout, void *arg_unused) uiItemS(layout); - uiItemMenuF(layout, "Handle Type", 0, graph_edit_handlesmenu); - uiItemMenuF(layout, "Interpolation Mode", 0, graph_edit_ipomenu); - uiItemMenuF(layout, "Extrapolation Mode", 0, graph_edit_expomenu); + uiItemMenuF(layout, "Handle Type", 0, graph_edit_handlesmenu, NULL); + uiItemMenuF(layout, "Interpolation Mode", 0, graph_edit_ipomenu, NULL); + uiItemMenuF(layout, "Extrapolation Mode", 0, graph_edit_expomenu, NULL); uiItemS(layout); diff --git a/source/blender/editors/space_graph/graph_intern.h b/source/blender/editors/space_graph/graph_intern.h index 31f1c6d4301..2e8d0655d2d 100644 --- a/source/blender/editors/space_graph/graph_intern.h +++ b/source/blender/editors/space_graph/graph_intern.h @@ -48,7 +48,7 @@ struct ARegion *graph_has_buttons_region(struct ScrArea *sa); /* ***************************************** */ /* graph_draw.c */ -void graph_draw_channel_names(struct bAnimContext *ac, struct SpaceIpo *sipo, struct ARegion *ar); +void graph_draw_channel_names(struct bContext *C, struct bAnimContext *ac, struct SpaceIpo *sipo, struct ARegion *ar); void graph_draw_curves(struct bAnimContext *ac, struct SpaceIpo *sipo, struct ARegion *ar, struct View2DGrid *grid, short sel); void graph_draw_ghost_curves(struct bAnimContext *ac, struct SpaceIpo *sipo, struct ARegion *ar, struct View2DGrid *grid); diff --git a/source/blender/editors/space_graph/space_graph.c b/source/blender/editors/space_graph/space_graph.c index 0390586951b..3717ccc8244 100644 --- a/source/blender/editors/space_graph/space_graph.c +++ b/source/blender/editors/space_graph/space_graph.c @@ -309,7 +309,7 @@ static void graph_channel_area_draw(const bContext *C, ARegion *ar) /* draw channels */ if (ANIM_animdata_get_context(C, &ac)) { - graph_draw_channel_names(&ac, sipo, ar); + graph_draw_channel_names((bContext*)C, &ac, sipo, ar); } /* reset view matrix */ diff --git a/source/blender/editors/space_image/Makefile b/source/blender/editors/space_image/Makefile index 5a69cb7fc65..a55b4e58dfa 100644 --- a/source/blender/editors/space_image/Makefile +++ b/source/blender/editors/space_image/Makefile @@ -54,3 +54,7 @@ CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include CPPFLAGS += -I../include +ifeq ($(WITH_OPENEXR), true) + CPPFLAGS += -DWITH_OPENEXR +endif + diff --git a/source/blender/editors/space_image/SConscript b/source/blender/editors/space_image/SConscript index 5fa2509bf5f..2b1d5589cb3 100644 --- a/source/blender/editors/space_image/SConscript +++ b/source/blender/editors/space_image/SConscript @@ -11,5 +11,7 @@ defs = [] if env['WITH_BF_LCMS']: defs.append('WITH_LCMS') +if env['WITH_BF_OPENEXR']: + defs.append('WITH_OPENEXR') env.BlenderLib ( 'bf_editors_space_image', sources, Split(incs), defs, libtype=['core'], priority=[40] ) diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c index 4dcaa96caf7..ac0a5c7f53a 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -58,6 +58,7 @@ #include "BKE_mesh.h" #include "BKE_node.h" #include "BKE_packedFile.h" +#include "BKE_paint.h" #include "BKE_screen.h" #include "BKE_utildefines.h" @@ -450,7 +451,7 @@ void brush_buttons(const bContext *C, uiBlock *block, short fromsima, { // SpaceImage *sima= CTX_wm_space_image(C); ToolSettings *settings= CTX_data_tool_settings(C); - Brush *brush= settings->imapaint.brush; + Brush *brush= paint_brush(&settings->imapaint.paint); ID *id; int yco, xco, butw, but_idx; // short *menupoin = &(sima->menunr); // XXX : &(G.buts->menunr); @@ -472,7 +473,7 @@ void brush_buttons(const bContext *C, uiBlock *block, short fromsima, uiBlockEndAlign(block); yco -= 30; - id= (ID*)settings->imapaint.brush; + id= (ID*)brush; xco= 200; // std_libbuttons(block, 0, yco, 0, NULL, evt_browse, ID_BR, 0, id, NULL, menupoin, 0, evt_local, evt_del, 0, evt_keepdata); if(brush && !brush->id.lib) { @@ -574,7 +575,7 @@ static void image_panel_paintcolor(const bContext *C, Panel *pa) { SpaceImage *sima= CTX_wm_space_image(C); ToolSettings *settings= CTX_data_tool_settings(C); - Brush *brush= settings->imapaint.brush; + Brush *brush= paint_brush(&settings->imapaint.paint); uiBlock *block; static float hsv[3], old[3]; // used as temp mem for picker static char hexcol[128]; @@ -1318,7 +1319,7 @@ void ED_image_uiblock_panel(const bContext *C, uiBlock *block, Image **ima_pp, I } /* exception, let's do because we only use this panel 3 times in blender... but not real good code! */ - if( (FACESEL_PAINT_TEST) && sima && &sima->iuser==iuser) + if( (paint_facesel_test(CTX_data_active_object(C))) && sima && &sima->iuser==iuser) return; /* left side default per-image options, right half the additional options */ diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c index ff25a2635d2..2f5fc805367 100644 --- a/source/blender/editors/space_image/image_draw.c +++ b/source/blender/editors/space_image/image_draw.c @@ -47,6 +47,7 @@ #include "BKE_colortools.h" #include "BKE_global.h" #include "BKE_image.h" +#include "BKE_paint.h" #include "BKE_utildefines.h" #include "BIF_gl.h" @@ -577,7 +578,7 @@ static void draw_image_view_tool(Scene *scene) static unsigned char *get_alpha_clone_image(Scene *scene, int *width, int *height) { - Brush *brush = scene->toolsettings->imapaint.brush; + Brush *brush = paint_brush(&scene->toolsettings->imapaint.paint); ImBuf *ibuf; unsigned int size, alpha; unsigned char *rect, *cp; @@ -615,7 +616,7 @@ static void draw_image_paint_helpers(SpaceImage *sima, ARegion *ar, Scene *scene int x, y, w, h; unsigned char *clonerect; - brush= scene->toolsettings->imapaint.brush; + brush= paint_brush(&scene->toolsettings->imapaint.paint); if(brush && (scene->toolsettings->imapaint.tool == PAINT_TOOL_CLONE)) { /* this is not very efficient, but glDrawPixels doesn't allow diff --git a/source/blender/editors/space_info/info_intern.h b/source/blender/editors/space_info/info_intern.h index 519364b58d9..070b627af07 100644 --- a/source/blender/editors/space_info/info_intern.h +++ b/source/blender/editors/space_info/info_intern.h @@ -32,9 +32,6 @@ struct wmOperatorType; -/* info_header.c */ -void info_header_buttons(const bContext *C, ARegion *ar); - void FILE_OT_pack_all(struct wmOperatorType *ot); void FILE_OT_unpack_all(struct wmOperatorType *ot); void FILE_OT_make_paths_relative(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_info/info_stats.c b/source/blender/editors/space_info/info_stats.c new file mode 100644 index 00000000000..2d14fbc515e --- /dev/null +++ b/source/blender/editors/space_info/info_stats.c @@ -0,0 +1,434 @@ +/** + * $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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include <stdio.h> +#include <string.h> + +#include "MEM_guardedalloc.h" + +#include "DNA_action_types.h" +#include "DNA_armature_types.h" +#include "DNA_curve_types.h" +#include "DNA_group_types.h" +#include "DNA_lattice_types.h" +#include "DNA_mesh_types.h" +#include "DNA_meta_types.h" +#include "DNA_object_types.h" +#include "DNA_particle_types.h" +#include "DNA_scene_types.h" + +#include "BKE_anim.h" +#include "BKE_context.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" + +#include "BLI_editVert.h" + +typedef struct SceneStats { + int totvert, totvertsel; + int totedge, totedgesel; + int totface, totfacesel; + int totbone, totbonesel; + int totobj, totobjsel; + int totmesh, totlamp, totcurve; + + char infostr[512]; +} SceneStats; + +static void stats_object(Object *ob, int sel, int totob, SceneStats *stats) +{ + switch(ob->type) { + case OB_MESH: { + /* we assume derivedmesh is already built, this strictly does stats now. */ + DerivedMesh *dm= ob->derivedFinal; + int totvert, totedge, totface; + + stats->totmesh +=totob; + + if(dm) { + totvert = dm->getNumVerts(dm); + totedge = dm->getNumEdges(dm); + totface = dm->getNumFaces(dm); + + stats->totvert += totvert*totob; + stats->totedge += totedge*totob; + stats->totface += totface*totob; + + if(sel) { + stats->totvertsel += totvert; + stats->totfacesel += totface; + } + } + break; + } + case OB_LAMP: + stats->totlamp += totob; + break; + 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); + + tot *= totob; + totf *= totob; + + stats->totvert+= tot; + stats->totface+= totf; + + if(sel) { + stats->totvertsel += tot; + stats->totfacesel += totf; + } + break; + } + case OB_MBALL: { + int tot= 0, totf= 0; + + count_displist(&ob->disp, &tot, &totf); + + tot *= totob; + totf *= totob; + + stats->totvert += tot; + stats->totface += totf; + + if(sel) { + stats->totvertsel += tot; + stats->totfacesel += totf; + } + break; + } + } +} + +static void stats_object_edit(Object *obedit, SceneStats *stats) +{ + if(obedit->type==OB_MESH) { + /* Mesh Edit */ + EditMesh *em= BKE_mesh_get_editmesh(obedit->data); + EditVert *eve; + EditEdge *eed; + EditFace *efa; + + for(eve= em->verts.first; eve; eve=eve->next) { + stats->totvert++; + if(eve->f & SELECT) stats->totvertsel++; + } + for(eed= em->edges.first; eed; eed=eed->next) { + stats->totedge++; + if(eed->f & SELECT) stats->totedgesel++; + } + for(efa= em->faces.first; efa; efa=efa->next) { + stats->totface++; + if(efa->f & SELECT) stats->totfacesel++; + } + + EM_validate_selections(em); + } + else if(obedit->type==OB_ARMATURE){ + /* Armature Edit */ + bArmature *arm= obedit->data; + EditBone *ebo; + + for(ebo=arm->edbo->first; ebo; ebo=ebo->next){ + stats->totbone++; + + if((ebo->flag & BONE_CONNECTED) && ebo->parent) + stats->totvert--; + + if(ebo->flag & BONE_TIPSEL) + stats->totvertsel++; + if(ebo->flag & BONE_ROOTSEL) + stats->totvertsel++; + + if(ebo->flag & BONE_SELECTED) stats->totbonesel++; + + /* if this is a connected child and it's parent is being moved, remove our root */ + if((ebo->flag & BONE_CONNECTED)&& (ebo->flag & BONE_ROOTSEL) && ebo->parent && (ebo->parent->flag & BONE_TIPSEL)) + stats->totvertsel--; + + stats->totvert+=2; + } + } + else if ELEM3(obedit->type, OB_CURVE, OB_SURF, OB_FONT) { + /* Curve Edit */ + Curve *cu= obedit->data; + Nurb *nu; + BezTriple *bezt; + BPoint *bp; + int a; + + for(nu=cu->editnurb->first; nu; nu=nu->next) { + if((nu->type & 7)==CU_BEZIER) { + bezt= nu->bezt; + a= nu->pntsu; + while(a--) { + stats->totvert+=3; + if(bezt->f1) stats->totvertsel++; + if(bezt->f2) stats->totvertsel++; + if(bezt->f3) stats->totvertsel++; + bezt++; + } + } + else { + bp= nu->bp; + a= nu->pntsu*nu->pntsv; + while(a--) { + stats->totvert++; + if(bp->f1 & SELECT) stats->totvertsel++; + bp++; + } + } + } + } + else if(obedit->type==OB_MBALL) { + /* MetaBall Edit */ + MetaBall *mball= obedit->data; + MetaElem *ml; + + for(ml= mball->editelems->first; ml; ml=ml->next) { + stats->totvert++; + if(ml->flag & SELECT) stats->totvertsel++; + } + } + else if(obedit->type==OB_LATTICE) { + /* Lattice Edit */ + Lattice *lt= obedit->data; + Lattice *editlatt= lt->editlatt; + BPoint *bp; + int a; + + bp= editlatt->def; + + a= editlatt->pntsu*editlatt->pntsv*editlatt->pntsw; + while(a--) { + stats->totvert++; + if(bp->f1 & SELECT) stats->totvertsel++; + bp++; + } + } +} + +static void stats_object_pose(Object *ob, SceneStats *stats) +{ + if(ob->pose) { + bArmature *arm= ob->data; + bPoseChannel *pchan; + + for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { + stats->totbone++; + if(pchan->bone && (pchan->bone->flag & BONE_SELECTED)) + if(pchan->bone->layer & arm->layer) + stats->totbonesel++; + } + } +} + +static void stats_object_paint(Object *ob, SceneStats *stats) +{ + if(ob->type == OB_MESH) { + Mesh *me= ob->data; + + stats->totface= me->totface; + stats->totvert= me->totvert; + } +} + +static void stats_dupli_object(Base *base, Object *ob, SceneStats *stats) +{ + if(base->flag & SELECT) stats->totobjsel++; + + if(ob->transflag & OB_DUPLIPARTS) { + /* Dupli Particles */ + ParticleSystem *psys; + ParticleSettings *part; + + for(psys=ob->particlesystem.first; psys; psys=psys->next){ + part=psys->part; + + if(part->draw_as==PART_DRAW_OB && part->dup_ob){ + int tot=count_particles(psys); + stats_object(part->dup_ob, 0, tot, stats); + } + else if(part->draw_as==PART_DRAW_GR && part->dup_group){ + GroupObject *go; + int tot, totgroup=0, cur=0; + + for(go= part->dup_group->gobject.first; go; go=go->next) + totgroup++; + + for(go= part->dup_group->gobject.first; go; go=go->next) { + tot=count_particles_mod(psys,totgroup,cur); + stats_object(go->ob, 0, tot, stats); + cur++; + } + } + } + + stats_object(ob, base->flag & SELECT, 1, stats); + stats->totobj++; + } + else if(ob->parent && (ob->parent->transflag & (OB_DUPLIVERTS|OB_DUPLIFACES))) { + /* Dupli Verts/Faces */ + int tot= count_duplilist(ob->parent); + stats->totobj+=tot; + stats_object(ob, base->flag & SELECT, tot, stats); + } + else if(ob->transflag & OB_DUPLIFRAMES) { + /* Dupli Frames */ + int tot= count_duplilist(ob); + stats->totobj+=tot; + stats_object(ob, base->flag & SELECT, tot, stats); + } + else if((ob->transflag & OB_DUPLIGROUP) && ob->dup_group) { + /* Dupli Group */ + int tot= count_duplilist(ob); + stats->totobj+=tot; + stats_object(ob, base->flag & SELECT, tot, stats); + } + else { + /* No Dupli */ + stats_object(ob, base->flag & SELECT, 1, stats); + stats->totobj++; + } +} + +/* Statistics displayed in info header. Called regularly on scene changes. */ +static void stats_update(Scene *scene) +{ + SceneStats stats; + Object *ob= (scene->basact)? scene->basact->object: NULL; + Base *base; + + memset(&stats, 0, sizeof(stats)); + + if(scene->obedit) { + /* Edit Mode */ + stats_object_edit(scene->obedit, &stats); + } + else if(ob && (ob->mode & OB_MODE_POSE)) { + /* Pose Mode */ + stats_object_pose(ob, &stats); + } + else if(ob && (ob->flag & (OB_MODE_SCULPT|OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT|OB_MODE_TEXTURE_PAINT))) { + /* Sculpt and Paint Mode */ + stats_object_paint(ob, &stats); + } + else { + /* Objects */ + for(base= scene->base.first; base; base=base->next) + if(scene->lay & base->lay) + stats_dupli_object(base, base->object, &stats); + } + + if(!scene->stats) + scene->stats= MEM_mallocN(sizeof(SceneStats), "SceneStats"); + + *(scene->stats)= stats; +} + +static void stats_string(Scene *scene) +{ + SceneStats *stats= scene->stats; + Object *ob= (scene->basact)? scene->basact->object: NULL; + uintptr_t mem_in_use, mmap_in_use; + char memstr[64]; + char *s; + + mem_in_use= MEM_get_memory_in_use(); + mmap_in_use= MEM_get_mapped_memory_in_use(); + + /* get memory statistics */ + s= memstr + sprintf(memstr, " | Mem:%.2fM", ((mem_in_use-mmap_in_use)>>10)/1024.0); + if(mmap_in_use) + sprintf(s, " (%.2fM)", ((mmap_in_use)>>10)/1024.0); + + s= stats->infostr; + + if(scene->obedit) { + if(ob_get_keyblock(scene->obedit)) + s+= sprintf(s, "(Key) "); + + if(scene->obedit->type==OB_MESH) { + if(scene->toolsettings->selectmode & SCE_SELECT_VERTEX) + s+= sprintf(s, "Ve:%d-%d | Ed:%d-%d | Fa:%d-%d", + stats->totvertsel, stats->totvert, stats->totedgesel, stats->totedge, stats->totfacesel, stats->totface); + else if(scene->toolsettings->selectmode & SCE_SELECT_EDGE) + s+= sprintf(s, "Ed:%d-%d | Fa:%d-%d", + stats->totedgesel, stats->totedge, stats->totfacesel, stats->totface); + else + s+= sprintf(s, "Fa:%d-%d", stats->totfacesel, stats->totface); + } + else if(scene->obedit->type==OB_ARMATURE) { + s+= sprintf(s, "Ve:%d-%d | Bo:%d-%d", stats->totvertsel, stats->totvert, stats->totbonesel, stats->totbone); + } + else { + s+= sprintf(s, "Ve:%d-%d", stats->totvertsel, stats->totvert); + } + + strcat(s, memstr); + } + else if(ob && (ob->mode & OB_MODE_POSE)) { + s += sprintf(s, "Bo:%d-%d %s", + stats->totbonesel, stats->totbone, memstr); + } + else { + s += sprintf(s, "Ve:%d | Fa:%d | Ob:%d-%d | La:%d%s", + stats->totvert, stats->totface, stats->totobj, stats->totobjsel, stats->totlamp, memstr); + } + + if(ob) + sprintf(s, " | %s", ob->id.name+2); +} + +void ED_info_stats_clear(Scene *scene) +{ + if(scene->stats) { + MEM_freeN(scene->stats); + scene->stats= NULL; + } +} + +char *ED_info_stats_string(Scene *scene) +{ + if(!scene->stats) + stats_update(scene); + stats_string(scene); + + return scene->stats->infostr; +} + diff --git a/source/blender/editors/space_info/space_info.c b/source/blender/editors/space_info/space_info.c index fe5bbf04af1..b6f9cbeabb5 100644 --- a/source/blender/editors/space_info/space_info.c +++ b/source/blender/editors/space_info/space_info.c @@ -1,5 +1,5 @@ /** - * $Id: + * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** * @@ -58,6 +58,7 @@ #include "UI_view2d.h" #include "ED_markers.h" +#include "ED_object.h" #include "info_intern.h" // own include @@ -166,6 +167,9 @@ static void info_header_listener(ARegion *ar, wmNotifier *wmn) if(wmn->data==ND_RENDER_RESULT) ED_region_tag_redraw(ar); break; + case NC_INFO: + ED_region_tag_redraw(ar); + break; } } diff --git a/source/blender/editors/space_logic/logic_window.c b/source/blender/editors/space_logic/logic_window.c index 274f5f47e43..06bd95f060f 100644 --- a/source/blender/editors/space_logic/logic_window.c +++ b/source/blender/editors/space_logic/logic_window.c @@ -708,8 +708,6 @@ static char *actuator_name(int type) return "Material"; case ACT_SOUND: return "Sound"; - case ACT_CD: - return "CD"; case ACT_PROPERTY: return "Property"; case ACT_EDIT_OBJECT: @@ -748,21 +746,21 @@ static char *actuator_pup(Object *owner) case OB_ARMATURE: return "Actuators %t|Action %x15|Motion %x0|Constraint %x9|Ipo %x1" "|Camera %x3|Sound %x5|Property %x6|Edit Object %x10" - "|Scene %x11|Random %x13|Message %x14|CD %x16|Game %x17" + "|Scene %x11|Random %x13|Message %x14|Game %x17" "|Visibility %x18|2D Filter %x19|Parent %x20|State %x22"; break; case OB_MESH: return "Actuators %t|Shape Action %x21|Motion %x0|Constraint %x9|Ipo %x1" "|Camera %x3|Sound %x5|Property %x6|Edit Object %x10" - "|Scene %x11|Random %x13|Message %x14|CD %x16|Game %x17" + "|Scene %x11|Random %x13|Message %x14|Game %x17" "|Visibility %x18|2D Filter %x19|Parent %x20|State %x22"; break; default: return "Actuators %t|Motion %x0|Constraint %x9|Ipo %x1" "|Camera %x3|Sound %x5|Property %x6|Edit Object %x10" - "|Scene %x11|Random %x13|Message %x14|CD %x16|Game %x17" + "|Scene %x11|Random %x13|Message %x14|Game %x17" "|Visibility %x18|2D Filter %x19|Parent %x20|State %x22"; } } @@ -1316,10 +1314,16 @@ static short draw_sensorbuttons(bSensor *sens, uiBlock *block, short xco, short * proper compatibility with older .blend files. */ str= "Type %t|Left button %x1|Middle button %x2|" "Right button %x4|Wheel Up %x5|Wheel Down %x6|Movement %x8|Mouse over %x16|Mouse over any%x32"; - uiDefButS(block, MENU, B_REDR, str, xco+10, yco-44, width-20, 19, + uiDefButS(block, MENU, B_REDR, str, xco+10, yco-44, (width*0.8f)-20, 19, &ms->type, 0, 31, 0, 0, "Specify the type of event this mouse sensor should trigger on"); + if(ms->type==32) { + uiDefButBitS(block, TOG, SENS_MOUSE_FOCUS_PULSE, B_REDR, "Pulse",(short)(xco + 10) + (width*0.8f)-20,(short)(yco - 44), + (short)(0.20 * (width-20)), 19, &ms->flag, 0.0, 0.0, 0, 0, + "Moving the mouse over a different object generates a pulse"); + } + yco-= ysize; break; } @@ -1581,7 +1585,6 @@ static int get_col_actuator(int type) case ACT_IPO: return TH_PANEL; case ACT_PROPERTY: return TH_PANEL; case ACT_SOUND: return TH_PANEL; - case ACT_CD: return TH_PANEL; case ACT_CAMERA: return TH_PANEL; case ACT_EDIT_OBJECT: return TH_PANEL; case ACT_GROUP: return TH_PANEL; @@ -1674,7 +1677,6 @@ static void check_state_mask(bContext *C, void *arg1_but, void *arg2_mask) static short draw_actuatorbuttons(Object *ob, bActuator *act, uiBlock *block, short xco, short yco, short width) { bSoundActuator *sa = NULL; - bCDActuator *cda = NULL; bObjectActuator *oa = NULL; bIpoActuator *ia = NULL; bPropertyActuator *pa = NULL; @@ -1984,11 +1986,14 @@ static short draw_actuatorbuttons(Object *ob, bActuator *act, uiBlock *block, sh } case ACT_SOUND: { - ysize = 70; - sa = act->data; sa->sndnr = 0; + if(sa->flag & ACT_SND_3D_SOUND) + ysize = 114; + else + ysize = 92; + wval = (width-20)/2; glRects(xco, yco-ysize, xco+width, yco); uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); @@ -2003,8 +2008,14 @@ static short draw_actuatorbuttons(Object *ob, bActuator *act, uiBlock *block, sh char dummy_str[] = "Sound mode %t|Play Stop %x0|Play End %x1|Loop Stop %x2|Loop End %x3|Loop Ping Pong Stop %x5|Loop Ping Pong %x4"; uiDefBut(block, TEX, B_IDNAME, "SO:",xco+30,yco-22,width-40,19, sa->sound->id.name+2, 0.0, 21.0, 0, 0, ""); uiDefButS(block, MENU, 1, dummy_str,xco+10,yco-44,width-20, 19, &sa->type, 0.0, 0.0, 0, 0, ""); - uiDefButF(block, NUM, 0, "Volume:", xco+10,yco-66,wval, 19, &sa->sound->volume, 0.0, 1.0, 0, 0, "Sets the volume of this sound"); - uiDefButF(block, NUM, 0, "Pitch:",xco+wval+10,yco-66,wval, 19, &sa->sound->pitch,-12.0, 12.0, 0, 0, "Sets the pitch of this sound"); + uiDefButF(block, NUM, 0, "Volume:", xco+10,yco-66,wval, 19, &sa->volume, 0.0, 1.0, 0, 0, "Sets the volume of this sound"); + uiDefButF(block, NUM, 0, "Pitch:",xco+wval+10,yco-66,wval, 19, &sa->pitch,-12.0, 12.0, 0, 0, "Sets the pitch of this sound"); + uiDefButS(block, TOG | BIT, 0, "3D Sound", xco+10, yco-88, width-20, 19, &sa->flag, 0.0, 1.0, 0.0, 0.0, "Plays the sound positioned in 3D space."); + if(sa->flag & ACT_SND_3D_SOUND) + { + uiDefButF(block, NUM, 0, "Rolloff: ", xco+10, yco-110, wval, 19, &sa->sound3D.rolloff_factor, 0.0, 5.0, 0.0, 0.0, "The rolloff factor defines the influence factor on volume depending on distance."); + uiDefButF(block, NUM, 0, "Reference distance: ", xco+wval+10, yco-110, wval, 19, &sa->sound3D.reference_distance, 0.0, 1000.0, 0.0, 0.0, "The reference distance is the distance where the sound has a gain of 1.0."); + } } MEM_freeN(str); } @@ -2016,41 +2027,6 @@ static short draw_actuatorbuttons(Object *ob, bActuator *act, uiBlock *block, sh break; } - case ACT_CD: - { - char cd_type_str[] = "Sound mode %t|Play all tracks %x0|Play one track %x1|" - "Volume %x3|Stop %x4|Pause %x5|Resume %x6"; - cda = act->data; - - if (cda) { - if (cda->track == 0) { - cda->track = 1; - cda->volume = 1; - cda->type = ACT_CD_PLAY_ALL; - } - - if (cda->type == ACT_CD_PLAY_TRACK || cda->type == ACT_CD_LOOP_TRACK) { - ysize = 48; - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - uiDefButS(block, NUM, 0, "Track:", xco+10,yco-44,width-20, 19, &cda->track, 1, 99, 0, 0, "Select the track to be played"); - } - else if (cda->type == ACT_CD_VOLUME) { - ysize = 48; - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - uiDefButF(block, NUM, 0, "Volume:", xco+10,yco-44,width-20, 19, &cda->volume, 0, 1, 0, 0, "Set the volume for CD playback"); - } - else { - ysize = 28; - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - } - uiDefButS(block, MENU, B_REDR, cd_type_str,xco+10,yco-22,width-20, 19, &cda->type, 0.0, 0.0, 0, 0, ""); - } - yco-= ysize; - break; - } case ACT_CAMERA: ysize= 48; diff --git a/source/blender/editors/space_nla/nla_buttons.c b/source/blender/editors/space_nla/nla_buttons.c index 7184737e0ba..2ffca5185f2 100644 --- a/source/blender/editors/space_nla/nla_buttons.c +++ b/source/blender/editors/space_nla/nla_buttons.c @@ -210,19 +210,19 @@ static void nla_panel_animdata (const bContext *C, Panel *pa) /* Active Action Properties ------------------------------------- */ /* action */ row= uiLayoutRow(layout, 1); - uiItemR(row, NULL, 0, &adt_ptr, "action", 0, 0, 0); + uiItemR(row, NULL, 0, &adt_ptr, "action", 0); /* extrapolation */ row= uiLayoutRow(layout, 1); - uiItemR(row, NULL, 0, &adt_ptr, "action_extrapolation", 0, 0, 0); + uiItemR(row, NULL, 0, &adt_ptr, "action_extrapolation", 0); /* blending */ row= uiLayoutRow(layout, 1); - uiItemR(row, NULL, 0, &adt_ptr, "action_blending", 0, 0, 0); + uiItemR(row, NULL, 0, &adt_ptr, "action_blending", 0); /* influence */ row= uiLayoutRow(layout, 1); - uiItemR(row, NULL, 0, &adt_ptr, "action_influence", 0, 0, 0); + uiItemR(row, NULL, 0, &adt_ptr, "action_influence", 0); } /* active NLA-Track */ @@ -242,7 +242,7 @@ static void nla_panel_track (const bContext *C, Panel *pa) /* Info - Active NLA-Context:Track ---------------------- */ row= uiLayoutRow(layout, 1); - uiItemR(row, NULL, ICON_NLA, &nlt_ptr, "name", 0, 0, 0); + uiItemR(row, NULL, ICON_NLA, &nlt_ptr, "name", 0); } /* generic settings for active NLA-Strip */ @@ -262,41 +262,41 @@ static void nla_panel_properties(const bContext *C, Panel *pa) /* Strip Properties ------------------------------------- */ /* strip type */ row= uiLayoutColumn(layout, 1); - uiItemR(row, NULL, ICON_NLA, &strip_ptr, "name", 0, 0, 0); // XXX icon? - uiItemR(row, NULL, 0, &strip_ptr, "type", 0, 0, 0); + uiItemR(row, NULL, ICON_NLA, &strip_ptr, "name", 0); // XXX icon? + uiItemR(row, NULL, 0, &strip_ptr, "type", 0); /* strip extents */ column= uiLayoutColumn(layout, 1); uiItemL(column, "Strip Extents:", 0); - uiItemR(column, NULL, 0, &strip_ptr, "start_frame", 0, 0, 0); - uiItemR(column, NULL, 0, &strip_ptr, "end_frame", 0, 0, 0); + uiItemR(column, NULL, 0, &strip_ptr, "start_frame", 0); + uiItemR(column, NULL, 0, &strip_ptr, "end_frame", 0); /* extrapolation */ row= uiLayoutRow(layout, 1); - uiItemR(row, NULL, 0, &strip_ptr, "extrapolation", 0, 0, 0); + uiItemR(row, NULL, 0, &strip_ptr, "extrapolation", 0); /* blending */ row= uiLayoutRow(layout, 1); - uiItemR(row, NULL, 0, &strip_ptr, "blending", 0, 0, 0); + uiItemR(row, NULL, 0, &strip_ptr, "blending", 0); /* blend in/out + autoblending * - blend in/out can only be set when autoblending is off */ column= uiLayoutColumn(layout, 1); uiLayoutSetActive(column, RNA_boolean_get(&strip_ptr, "animated_influence")==0); - uiItemR(column, NULL, 0, &strip_ptr, "auto_blending", 0, 0, 0); // XXX as toggle? + uiItemR(column, NULL, 0, &strip_ptr, "auto_blending", 0); // XXX as toggle? subcol= uiLayoutColumn(column, 1); uiLayoutSetActive(subcol, RNA_boolean_get(&strip_ptr, "auto_blending")==0); - uiItemR(subcol, NULL, 0, &strip_ptr, "blend_in", 0, 0, 0); - uiItemR(subcol, NULL, 0, &strip_ptr, "blend_out", 0, 0, 0); + uiItemR(subcol, NULL, 0, &strip_ptr, "blend_in", 0); + uiItemR(subcol, NULL, 0, &strip_ptr, "blend_out", 0); /* settings */ column= uiLayoutColumn(layout, 1); uiLayoutSetActive(column, !(RNA_boolean_get(&strip_ptr, "animated_influence") || RNA_boolean_get(&strip_ptr, "animated_time"))); uiItemL(column, "Playback Settings:", 0); - uiItemR(column, NULL, 0, &strip_ptr, "muted", 0, 0, 0); - uiItemR(column, NULL, 0, &strip_ptr, "reversed", 0, 0, 0); + uiItemR(column, NULL, 0, &strip_ptr, "muted", 0); + uiItemR(column, NULL, 0, &strip_ptr, "reversed", 0); } @@ -318,21 +318,21 @@ static void nla_panel_actclip(const bContext *C, Panel *pa) /* Strip Properties ------------------------------------- */ /* action pointer */ row= uiLayoutRow(layout, 1); - uiItemR(row, NULL, ICON_ACTION, &strip_ptr, "action", 0, 0, 0); + uiItemR(row, NULL, ICON_ACTION, &strip_ptr, "action", 0); /* action extents */ // XXX custom names were used here (to avoid the prefixes)... probably not necessary in future? column= uiLayoutColumn(layout, 1); uiItemL(column, "Action Extents:", 0); - uiItemR(column, "Start Frame", 0, &strip_ptr, "action_start_frame", 0, 0, 0); - uiItemR(column, "End Frame", 0, &strip_ptr, "action_end_frame", 0, 0, 0); + uiItemR(column, "Start Frame", 0, &strip_ptr, "action_start_frame", 0); + uiItemR(column, "End Frame", 0, &strip_ptr, "action_end_frame", 0); /* action usage */ column= uiLayoutColumn(layout, 1); uiLayoutSetActive(column, RNA_boolean_get(&strip_ptr, "animated_time")==0); uiItemL(column, "Playback Settings:", 0); - uiItemR(column, NULL, 0, &strip_ptr, "scale", 0, 0, 0); - uiItemR(column, NULL, 0, &strip_ptr, "repeat", 0, 0, 0); + uiItemR(column, NULL, 0, &strip_ptr, "scale", 0); + uiItemR(column, NULL, 0, &strip_ptr, "repeat", 0); } /* evaluation settings for active NLA-Strip */ @@ -351,19 +351,19 @@ static void nla_panel_evaluation(const bContext *C, Panel *pa) uiBlockSetHandleFunc(block, do_nla_region_buttons, NULL); column= uiLayoutColumn(layout, 1); - uiItemR(column, NULL, 0, &strip_ptr, "animated_influence", 0, 0, 0); + uiItemR(column, NULL, 0, &strip_ptr, "animated_influence", 0); subcolumn= uiLayoutColumn(column, 1); uiLayoutSetEnabled(subcolumn, RNA_boolean_get(&strip_ptr, "animated_influence")); - uiItemR(subcolumn, NULL, 0, &strip_ptr, "influence", 0, 0, 0); + uiItemR(subcolumn, NULL, 0, &strip_ptr, "influence", 0); column= uiLayoutColumn(layout, 1); - uiItemR(column, NULL, 0, &strip_ptr, "animated_time", 0, 0, 0); + uiItemR(column, NULL, 0, &strip_ptr, "animated_time", 0); subcolumn= uiLayoutColumn(column, 1); uiLayoutSetEnabled(subcolumn, RNA_boolean_get(&strip_ptr, "animated_time")); - uiItemR(subcolumn, NULL, 0, &strip_ptr, "strip_time", 0, 0, 0); + uiItemR(subcolumn, NULL, 0, &strip_ptr, "strip_time", 0); } /* F-Modifiers for active NLA-Strip */ diff --git a/source/blender/editors/space_nla/nla_channels.c b/source/blender/editors/space_nla/nla_channels.c index ab918519ec0..ccf23266427 100644 --- a/source/blender/editors/space_nla/nla_channels.c +++ b/source/blender/editors/space_nla/nla_channels.c @@ -89,6 +89,7 @@ * part of the channel is relevant. * * NOTE: eventually, this should probably be phased out when many of these things are replaced with buttons + * --> Most channels are now selection only... */ static int mouse_nla_channels (bAnimContext *ac, float x, int channel_index, short selectmode) @@ -96,6 +97,7 @@ static int mouse_nla_channels (bAnimContext *ac, float x, int channel_index, sho ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; + View2D *v2d= &ac->ar->v2d; int notifierFlags = 0; /* get the channel that was clicked on */ @@ -118,32 +120,17 @@ static int mouse_nla_channels (bAnimContext *ac, float x, int channel_index, sho case ANIMTYPE_SCENE: { Scene *sce= (Scene *)ale->data; - AnimData *adt= ale->data; - if (x < 16) { - /* toggle expand */ - sce->flag ^= SCE_DS_COLLAPSED; - - notifierFlags |= ND_ANIMCHAN_EDIT; - } - else if ( (adt) && (x >= (NLACHANNEL_NAMEWIDTH-NLACHANNEL_BUTTON_WIDTH)) ) { - /* toggle mute */ - adt->flag ^= ADT_NLA_EVAL_OFF; - - notifierFlags |= ND_ANIMCHAN_EDIT; + /* set selection status */ + if (selectmode == SELECT_INVERT) { + /* swap select */ + sce->flag ^= SCE_DS_SELECTED; } else { - /* set selection status */ - if (selectmode == SELECT_INVERT) { - /* swap select */ - sce->flag ^= SCE_DS_SELECTED; - } - else { - sce->flag |= SCE_DS_SELECTED; - } - - notifierFlags |= ND_ANIMCHAN_SELECT; + sce->flag |= SCE_DS_SELECTED; } + + notifierFlags |= ND_ANIMCHAN_SELECT; } break; case ANIMTYPE_OBJECT: @@ -152,20 +139,8 @@ static int mouse_nla_channels (bAnimContext *ac, float x, int channel_index, sho Scene *sce= (Scene *)ads->source; Base *base= (Base *)ale->data; Object *ob= base->object; - AnimData *adt= ale->adt; - if (x < 16) { - /* toggle expand */ - ob->nlaflag ^= OB_ADS_COLLAPSED; // XXX - notifierFlags |= ND_ANIMCHAN_EDIT; - } - else if ( (adt) && (x >= (NLACHANNEL_NAMEWIDTH-NLACHANNEL_BUTTON_WIDTH)) ) { - /* toggle mute */ - adt->flag ^= ADT_NLA_EVAL_OFF; - - notifierFlags |= ND_ANIMCHAN_EDIT; - } - else if (nlaedit_is_tweakmode_on(ac) == 0) { + if (nlaedit_is_tweakmode_on(ac) == 0) { /* set selection status */ if (selectmode == SELECT_INVERT) { /* swap select */ @@ -194,149 +169,6 @@ static int mouse_nla_channels (bAnimContext *ac, float x, int channel_index, sho } } break; - case ANIMTYPE_FILLMATD: - { - Object *ob= (Object *)ale->data; - ob->nlaflag ^= OB_ADS_SHOWMATS; // XXX - notifierFlags |= ND_ANIMCHAN_EDIT; - } - break; - case ANIMTYPE_FILLPARTD: - { - Object *ob= (Object *)ale->data; - ob->nlaflag ^= OB_ADS_SHOWPARTS; // XXX - notifierFlags |= ND_ANIMCHAN_EDIT; - } - break; - - case ANIMTYPE_DSMAT: - { - Material *ma= (Material *)ale->data; - AnimData *adt= ale->adt; - - if ( (adt) && (x >= (NLACHANNEL_NAMEWIDTH-NLACHANNEL_BUTTON_WIDTH)) ) { - /* toggle mute */ - adt->flag ^= ADT_NLA_EVAL_OFF; - } - else { - /* toggle expand */ - ma->flag ^= MA_DS_EXPAND; - } - notifierFlags |= ND_ANIMCHAN_EDIT; - } - break; - case ANIMTYPE_DSLAM: - { - Lamp *la= (Lamp *)ale->data; - AnimData *adt= ale->adt; - - if ( (adt) && (x >= (NLACHANNEL_NAMEWIDTH-NLACHANNEL_BUTTON_WIDTH)) ) { - /* toggle mute */ - adt->flag ^= ADT_NLA_EVAL_OFF; - } - else { - /* toggle expand */ - la->flag ^= LA_DS_EXPAND; - } - notifierFlags |= ND_ANIMCHAN_EDIT; - } - break; - case ANIMTYPE_DSCAM: - { - Camera *ca= (Camera *)ale->data; - AnimData *adt= ale->adt; - - if ( (adt) && (x >= (NLACHANNEL_NAMEWIDTH-NLACHANNEL_BUTTON_WIDTH)) ) { - /* toggle mute */ - adt->flag ^= ADT_NLA_EVAL_OFF; - } - else { - /* toggle expand */ - ca->flag ^= CAM_DS_EXPAND; - } - notifierFlags |= ND_ANIMCHAN_EDIT; - } - break; - case ANIMTYPE_DSCUR: - { - Curve *cu= (Curve *)ale->data; - AnimData *adt= ale->adt; - - if ( (adt) && (x >= (NLACHANNEL_NAMEWIDTH-NLACHANNEL_BUTTON_WIDTH)) ) { - /* toggle mute */ - adt->flag ^= ADT_NLA_EVAL_OFF; - } - else { - /* toggle expand */ - cu->flag ^= CU_DS_EXPAND; - } - notifierFlags |= ND_ANIMCHAN_EDIT; - } - break; - case ANIMTYPE_DSSKEY: - { - Key *key= (Key *)ale->data; - AnimData *adt= ale->adt; - - if ( (adt) && (x >= (NLACHANNEL_NAMEWIDTH-NLACHANNEL_BUTTON_WIDTH)) ) { - /* toggle mute */ - adt->flag ^= ADT_NLA_EVAL_OFF; - } - else { - /* toggle expand */ - key->flag ^= KEYBLOCK_DS_EXPAND; - } - notifierFlags |= ND_ANIMCHAN_EDIT; - } - break; - case ANIMTYPE_DSWOR: - { - World *wo= (World *)ale->data; - AnimData *adt= ale->adt; - - if ( (adt) && (x >= (NLACHANNEL_NAMEWIDTH-NLACHANNEL_BUTTON_WIDTH)) ) { - /* toggle mute */ - adt->flag ^= ADT_NLA_EVAL_OFF; - } - else { - /* toggle expand */ - wo->flag ^= WO_DS_EXPAND; - } - notifierFlags |= ND_ANIMCHAN_EDIT; - } - break; - case ANIMTYPE_DSPART: - { - ParticleSettings *part= (ParticleSettings *)ale->data; - AnimData *adt= ale->adt; - - if ( (adt) && (x >= (NLACHANNEL_NAMEWIDTH-NLACHANNEL_BUTTON_WIDTH)) ) { - /* toggle mute */ - adt->flag ^= ADT_NLA_EVAL_OFF; - } - else { - /* toggle expand */ - part->flag ^= PART_DS_EXPAND; - } - notifierFlags |= ND_ANIMCHAN_EDIT; - } - break; - case ANIMTYPE_DSMBALL: - { - MetaBall *mb= (MetaBall *)ale->data; - AnimData *adt= ale->adt; - - if ( (adt) && (x >= (NLACHANNEL_NAMEWIDTH-NLACHANNEL_BUTTON_WIDTH)) ) { - /* toggle mute */ - adt->flag ^= ADT_NLA_EVAL_OFF; - } - else { - /* toggle expand */ - mb->flag2 ^= MB_DS_EXPAND; - } - notifierFlags |= ND_ANIMCHAN_EDIT; - } - break; case ANIMTYPE_NLATRACK: { @@ -355,14 +187,14 @@ static int mouse_nla_channels (bAnimContext *ac, float x, int channel_index, sho else offset= 0; - if (x >= (NLACHANNEL_NAMEWIDTH-NLACHANNEL_BUTTON_WIDTH)) { + if (x >= (v2d->cur.xmax-NLACHANNEL_BUTTON_WIDTH)) { /* toggle protection (only if there's a toggle there) */ nlt->flag ^= NLATRACK_PROTECTED; /* notifier flags - channel was edited */ notifierFlags |= ND_ANIMCHAN_EDIT; } - else if (x >= (NLACHANNEL_NAMEWIDTH-2*NLACHANNEL_BUTTON_WIDTH)) { + else if (x >= (v2d->cur.xmax-2*NLACHANNEL_BUTTON_WIDTH)) { /* toggle mute */ nlt->flag ^= NLATRACK_MUTED; @@ -401,7 +233,7 @@ static int mouse_nla_channels (bAnimContext *ac, float x, int channel_index, sho { AnimData *adt= BKE_animdata_from_id(ale->owner); /* this won't crash, right? */ - if (x >= (NLACHANNEL_NAMEWIDTH-NLACHANNEL_BUTTON_WIDTH)) { + if (x >= (v2d->cur.xmax-NLACHANNEL_BUTTON_WIDTH)) { if (nlaedit_is_tweakmode_on(ac) == 0) { /* 'push-down' action - only usable when not in TweakMode */ // TODO: make this use the operator instead of calling the function directly diff --git a/source/blender/editors/space_nla/nla_draw.c b/source/blender/editors/space_nla/nla_draw.c index a7a854a7277..f30954292b4 100644 --- a/source/blender/editors/space_nla/nla_draw.c +++ b/source/blender/editors/space_nla/nla_draw.c @@ -411,7 +411,7 @@ static void nla_draw_strip (SpaceNla *snla, AnimData *adt, NlaTrack *nlt, NlaStr /* don't draw if line would end up on or after the end of the strip */ if (repeatPos < strip->end) - fdrawline(repeatPos, yminc, repeatPos, ymaxc); + fdrawline(repeatPos, yminc+4, repeatPos, ymaxc-4); } } /* or if meta-strip, draw lines delimiting extents of sub-strips (in same color as outline, if more than 1 exists) */ @@ -592,36 +592,15 @@ void draw_nla_main_data (bAnimContext *ac, SpaceNla *snla, ARegion *ar) /* *********************************************** */ /* Channel List */ -void draw_nla_channel_list (bAnimContext *ac, SpaceNla *snla, ARegion *ar) +/* old code for drawing NLA channels using GL only */ +// TODO: depreceate this code... +static void draw_nla_channel_list_gl (bAnimContext *ac, ListBase *anim_data, View2D *v2d, float y) { - ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; - int filter; - - View2D *v2d= &ar->v2d; - float x= 0.0f, y= 0.0f; - int items, height; - - /* build list of channels to draw */ - filter= (ANIMFILTER_VISIBLE|ANIMFILTER_CHANNELS); - items= ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - - /* Update max-extent of channels here (taking into account scrollers): - * - this is done to allow the channel list to be scrollable, but must be done here - * to avoid regenerating the list again and/or also because channels list is drawn first - * - offset of NLACHANNEL_HEIGHT*2 is added to the height of the channels, as first is for - * start of list offset, and the second is as a correction for the scrollers. - */ - height= ((items*NLACHANNEL_STEP) + (NLACHANNEL_HEIGHT*2)); - /* don't use totrect set, as the width stays the same - * (NOTE: this is ok here, the configuration is pretty straightforward) - */ - v2d->tot.ymin= (float)(-height); + float x = 0.0f; /* loop through channels, and set up drawing depending on their type */ - y= (float)(-NLACHANNEL_HEIGHT); - - for (ale= anim_data.first; ale; ale= ale->next) { + for (ale= anim_data->first; ale; ale= ale->next) { const float yminc= (float)(y - NLACHANNEL_HEIGHT_HALF); const float ymaxc= (float)(y + NLACHANNEL_HEIGHT_HALF); const float ydatac= (float)(y - 7); @@ -633,308 +612,10 @@ void draw_nla_channel_list (bAnimContext *ac, SpaceNla *snla, ARegion *ar) short indent= 0, offset= 0, sel= 0, group= 0; int expand= -1, protect = -1, special= -1, mute = -1; char name[128]; + short doDraw=0; /* determine what needs to be drawn */ switch (ale->type) { - case ANIMTYPE_SCENE: /* scene */ - { - Scene *sce= (Scene *)ale->data; - AnimData *adt= ale->adt; - - group= 4; - indent= 0; - - special= ICON_SCENE_DATA; - - /* only show expand if there are any channels */ - if (EXPANDED_SCEC(sce)) - expand= ICON_TRIA_DOWN; - else - expand= ICON_TRIA_RIGHT; - - /* NLA evaluation on/off button */ - if (adt) { - if (adt->flag & ADT_NLA_EVAL_OFF) - mute = ICON_MUTE_IPO_ON; - else - mute = ICON_MUTE_IPO_OFF; - } - - sel = SEL_SCEC(sce); - strcpy(name, sce->id.name+2); - } - break; - case ANIMTYPE_OBJECT: /* object */ - { - Base *base= (Base *)ale->data; - Object *ob= base->object; - AnimData *adt= ale->adt; - - group= 4; - indent= 0; - - /* icon depends on object-type */ - if (ob->type == OB_ARMATURE) - special= ICON_ARMATURE_DATA; - else - special= ICON_OBJECT_DATA; - - /* only show expand if there are any channels */ - if (EXPANDED_OBJC(ob)) - expand= ICON_TRIA_DOWN; - else - expand= ICON_TRIA_RIGHT; - - /* NLA evaluation on/off button */ - if (adt) { - if (adt->flag & ADT_NLA_EVAL_OFF) - mute = ICON_MUTE_IPO_ON; - else - mute = ICON_MUTE_IPO_OFF; - } - - sel = SEL_OBJC(base); - strcpy(name, ob->id.name+2); - } - break; - case ANIMTYPE_FILLMATD: /* object materials (dopesheet) expand widget */ - { - Object *ob = (Object *)ale->data; - - group = 4; - indent = 1; - special = ICON_MATERIAL_DATA; - - if (FILTER_MAT_OBJC(ob)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - strcpy(name, "Materials"); - } - break; - case ANIMTYPE_FILLPARTD: /* object particles (dopesheet) expand widget */ - { - Object *ob = (Object *)ale->data; - - group = 4; - indent = 1; - special = ICON_PARTICLE_DATA; - - if (FILTER_PART_OBJC(ob)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - strcpy(name, "Particles"); - } - break; - - - case ANIMTYPE_DSMAT: /* single material (dopesheet) expand widget */ - { - Material *ma = (Material *)ale->data; - AnimData *adt= ale->adt; - - group = 0; - indent = 0; - special = ICON_MATERIAL_DATA; - offset = 21; - - if (FILTER_MAT_OBJD(ma)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - /* NLA evaluation on/off button */ - if (adt) { - if (adt->flag & ADT_NLA_EVAL_OFF) - mute = ICON_MUTE_IPO_ON; - else - mute = ICON_MUTE_IPO_OFF; - } - - strcpy(name, ma->id.name+2); - } - break; - case ANIMTYPE_DSLAM: /* lamp (dopesheet) expand widget */ - { - Lamp *la = (Lamp *)ale->data; - AnimData *adt= ale->adt; - - group = 4; - indent = 1; - special = ICON_LAMP_DATA; - - if (FILTER_LAM_OBJD(la)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - /* NLA evaluation on/off button */ - if (adt) { - if (adt->flag & ADT_NLA_EVAL_OFF) - mute = ICON_MUTE_IPO_ON; - else - mute = ICON_MUTE_IPO_OFF; - } - - strcpy(name, la->id.name+2); - } - break; - case ANIMTYPE_DSCAM: /* camera (dopesheet) expand widget */ - { - Camera *ca = (Camera *)ale->data; - AnimData *adt= ale->adt; - - group = 4; - indent = 1; - special = ICON_CAMERA_DATA; - - if (FILTER_CAM_OBJD(ca)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - /* NLA evaluation on/off button */ - if (adt) { - if (adt->flag & ADT_NLA_EVAL_OFF) - mute = ICON_MUTE_IPO_ON; - else - mute = ICON_MUTE_IPO_OFF; - } - - strcpy(name, ca->id.name+2); - } - break; - case ANIMTYPE_DSCUR: /* curve (dopesheet) expand widget */ - { - Curve *cu = (Curve *)ale->data; - AnimData *adt= ale->adt; - - group = 4; - indent = 1; - special = ICON_CURVE_DATA; - - if (FILTER_CUR_OBJD(cu)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - /* NLA evaluation on/off button */ - if (adt) { - if (adt->flag & ADT_NLA_EVAL_OFF) - mute = ICON_MUTE_IPO_ON; - else - mute = ICON_MUTE_IPO_OFF; - } - - strcpy(name, cu->id.name+2); - } - break; - case ANIMTYPE_DSSKEY: /* shapekeys (dopesheet) expand widget */ - { - Key *key= (Key *)ale->data; - AnimData *adt= ale->adt; - - group = 4; - indent = 1; - special = ICON_SHAPEKEY_DATA; - - if (FILTER_SKE_OBJD(key)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - /* NLA evaluation on/off button */ - if (adt) { - if (adt->flag & ADT_NLA_EVAL_OFF) - mute = ICON_MUTE_IPO_ON; - else - mute = ICON_MUTE_IPO_OFF; - } - - //sel = SEL_OBJC(base); - strcpy(name, "Shape Keys"); - } - break; - case ANIMTYPE_DSWOR: /* world (dopesheet) expand widget */ - { - World *wo= (World *)ale->data; - AnimData *adt= ale->adt; - - group = 4; - indent = 1; - special = ICON_WORLD_DATA; - - if (FILTER_WOR_SCED(wo)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - /* NLA evaluation on/off button */ - if (adt) { - if (adt->flag & ADT_NLA_EVAL_OFF) - mute = ICON_MUTE_IPO_ON; - else - mute = ICON_MUTE_IPO_OFF; - } - - strcpy(name, wo->id.name+2); - } - break; - case ANIMTYPE_DSPART: /* particle (dopesheet) expand widget */ - { - ParticleSettings *part= (ParticleSettings*)ale->data; - AnimData *adt= ale->adt; - - group = 0; - indent = 0; - special = ICON_PARTICLE_DATA; - offset = 21; - - if (FILTER_PART_OBJD(part)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - /* NLA evaluation on/off button */ - if (adt) { - if (adt->flag & ADT_NLA_EVAL_OFF) - mute = ICON_MUTE_IPO_ON; - else - mute = ICON_MUTE_IPO_OFF; - } - - strcpy(name, part->id.name+2); - } - break; - case ANIMTYPE_DSMBALL: /* metaball (dopesheet) expand widget */ - { - MetaBall *mb = (MetaBall *)ale->data; - AnimData *adt= ale->adt; - - group = 4; - indent = 1; - special = ICON_META_DATA; - - if (FILTER_MBALL_OBJD(mb)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - /* NLA evaluation on/off button */ - if (adt) { - if (adt->flag & ADT_NLA_EVAL_OFF) - mute = ICON_MUTE_IPO_ON; - else - mute = ICON_MUTE_IPO_OFF; - } - - strcpy(name, mb->id.name+2); - } - break; - case ANIMTYPE_NLATRACK: /* NLA Track */ { NlaTrack *nlt= (NlaTrack *)ale->data; @@ -978,6 +659,9 @@ void draw_nla_channel_list (bAnimContext *ac, SpaceNla *snla, ARegion *ar) sel = SEL_NLT(nlt); strcpy(name, nlt->name); + + // draw manually still + doDraw= 1; } break; case ANIMTYPE_NLAACTION: /* NLA Action-Line */ @@ -1004,167 +688,219 @@ void draw_nla_channel_list (bAnimContext *ac, SpaceNla *snla, ARegion *ar) sprintf(name, "ActAction: <%s>", act->id.name+2); else sprintf(name, "<No Action>"); + + // draw manually still + doDraw= 1; } break; + + default: /* handled by standard channel-drawing API */ + // draw backdrops only... + ANIM_channel_draw(ac, ale, yminc, ymaxc); + break; } - /* now, start drawing based on this information */ - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_BLEND); - - /* draw backing strip behind channel name */ - if (group == 4) { - /* only used in dopesheet... */ - if (ELEM(ale->type, ANIMTYPE_SCENE, ANIMTYPE_OBJECT)) { - /* object channel - darker */ - UI_ThemeColor(TH_DOPESHEET_CHANNELOB); - uiSetRoundBox((expand == ICON_TRIA_DOWN)? (8):(1|8)); - gl_round_box(GL_POLYGON, x+offset, yminc, (float)NLACHANNEL_NAMEWIDTH, ymaxc, 10); + /* if special types, draw manually for now... */ + if (doDraw) { + /* now, start drawing based on this information */ + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_BLEND); + + /* draw backing strip behind channel name */ + if (group == 5) { + /* Action Line */ + AnimData *adt= ale->adt; + + // TODO: if tweaking some action, use the same color as for the tweaked track (quick hack done for now) + if (adt && (adt->flag & ADT_NLA_EDIT_ON)) { + // greenish color (same as tweaking strip) - hardcoded for now + glColor3f(0.3f, 0.95f, 0.1f); + } + else { + if (ale->data) + glColor3f(0.8f, 0.2f, 0.0f); // reddish color - hardcoded for now + else + glColor3f(0.6f, 0.5f, 0.5f); // greyish-red color - hardcoded for now + } + + offset += 7 * indent; + + /* only on top two corners, to show that this channel sits on top of the preceeding ones */ + uiSetRoundBox((1|2)); + + /* draw slightly shifted up vertically to look like it has more separtion from other channels, + * but we then need to slightly shorten it so that it doesn't look like it overlaps + */ + gl_round_box(GL_POLYGON, x+offset, yminc+NLACHANNEL_SKIP, (float)v2d->cur.xmax, ymaxc+NLACHANNEL_SKIP-1, 8); + + /* clear group value, otherwise we cause errors... */ + group = 0; } else { - /* sub-object folders - lighter */ - UI_ThemeColor(TH_DOPESHEET_CHANNELSUBOB); + /* for normal channels + * - use 3 shades of color group/standard color for 3 indention level + */ + UI_ThemeColorShade(TH_HEADER, ((indent==0)?20: (indent==1)?-20: -40)); + indent += group; offset += 7 * indent; glBegin(GL_QUADS); glVertex2f(x+offset, yminc); glVertex2f(x+offset, ymaxc); - glVertex2f((float)ACHANNEL_NAMEWIDTH, ymaxc); - glVertex2f((float)ACHANNEL_NAMEWIDTH, yminc); + glVertex2f((float)v2d->cur.xmax, ymaxc); + glVertex2f((float)v2d->cur.xmax, yminc); glEnd(); - - /* clear group value, otherwise we cause errors... */ - group = 0; } - } - else if (group == 5) { - /* Action Line */ - AnimData *adt= ale->adt; - // TODO: if tweaking some action, use the same color as for the tweaked track (quick hack done for now) - if (adt && (adt->flag & ADT_NLA_EDIT_ON)) { - // greenish color (same as tweaking strip) - hardcoded for now - glColor3f(0.3f, 0.95f, 0.1f); - } - else { - if (ale->data) - glColor3f(0.8f, 0.2f, 0.0f); // reddish color - hardcoded for now - else - glColor3f(0.6f, 0.5f, 0.5f); // greyish-red color - hardcoded for now + /* draw expand/collapse triangle */ + if (expand > 0) { + UI_icon_draw(x+offset, ydatac, expand); + offset += 17; } - offset += 7 * indent; + /* draw special icon indicating certain data-types */ + if (special > -1) { + /* for normal channels */ + UI_icon_draw(x+offset, ydatac, special); + offset += 17; + } + glDisable(GL_BLEND); - /* only on top two corners, to show that this channel sits on top of the preceeding ones */ - uiSetRoundBox((1|2)); + /* draw name */ + if (sel) + UI_ThemeColor(TH_TEXT_HI); + else + UI_ThemeColor(TH_TEXT); + offset += 3; + UI_DrawString(x+offset, y-4, name); - /* draw slightly shifted up vertically to look like it has more separtion from other channels, - * but we then need to slightly shorten it so that it doesn't look like it overlaps - */ - gl_round_box(GL_POLYGON, x+offset, yminc+NLACHANNEL_SKIP, (float)NLACHANNEL_NAMEWIDTH, ymaxc+NLACHANNEL_SKIP-1, 8); + /* reset offset - for RHS of panel */ + offset = 0; - /* clear group value, otherwise we cause errors... */ - group = 0; - } - else { - /* for normal channels - * - use 3 shades of color group/standard color for 3 indention level - */ - UI_ThemeColorShade(TH_HEADER, ((indent==0)?20: (indent==1)?-20: -40)); + /* set blending again, as text drawing may clear it */ + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_BLEND); - indent += group; - offset += 7 * indent; - glBegin(GL_QUADS); - glVertex2f(x+offset, yminc); - glVertex2f(x+offset, ymaxc); - glVertex2f((float)NLACHANNEL_NAMEWIDTH, ymaxc); - glVertex2f((float)NLACHANNEL_NAMEWIDTH, yminc); - glEnd(); - } - - /* draw expand/collapse triangle */ - if (expand > 0) { - UI_icon_draw(x+offset, ydatac, expand); - offset += 17; - } - - /* draw special icon indicating certain data-types */ - if (special > -1) { - /* for normal channels */ - UI_icon_draw(x+offset, ydatac, special); - offset += 17; - } - glDisable(GL_BLEND); - - /* draw name */ - if (sel) - UI_ThemeColor(TH_TEXT_HI); - else - UI_ThemeColor(TH_TEXT); - offset += 3; - UI_DrawString(x+offset, y-4, name); - - /* reset offset - for RHS of panel */ - offset = 0; - - /* set blending again, as text drawing may clear it */ - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_BLEND); - - /* draw protect 'lock' */ - if (protect > -1) { - offset = 16; - UI_icon_draw((float)NLACHANNEL_NAMEWIDTH-offset, ydatac, protect); - } - - /* draw mute 'eye' */ - if (mute > -1) { - offset += 16; - UI_icon_draw((float)(NLACHANNEL_NAMEWIDTH-offset), ydatac, mute); - } - - /* draw NLA-action line 'status-icons' - only when there's an action */ - if ((ale->type == ANIMTYPE_NLAACTION) && (ale->data)) { - AnimData *adt= ale->adt; + /* draw protect 'lock' */ + if (protect > -1) { + offset = 16; + UI_icon_draw((float)(v2d->cur.xmax-offset), ydatac, protect); + } - offset += 16; + /* draw mute 'eye' */ + if (mute > -1) { + offset += 16; + UI_icon_draw((float)(v2d->cur.xmax-offset), ydatac, mute); + } - /* now draw some indicator icons */ - if ((adt) && (adt->flag & ADT_NLA_EDIT_ON)) { - /* toggle for tweaking with mapping/no-mapping (i.e. 'in place editing' toggle) */ - // for now, use pin icon to symbolise this - if (adt->flag & ADT_NLA_EDIT_NOMAP) - UI_icon_draw((float)(NLACHANNEL_NAMEWIDTH-offset), ydatac, ICON_PINNED); - else - UI_icon_draw((float)(NLACHANNEL_NAMEWIDTH-offset), ydatac, ICON_UNPINNED); + /* draw NLA-action line 'status-icons' - only when there's an action */ + if ((ale->type == ANIMTYPE_NLAACTION) && (ale->data)) { + AnimData *adt= ale->adt; - fdrawline((float)(NLACHANNEL_NAMEWIDTH-offset), yminc, - (float)(NLACHANNEL_NAMEWIDTH-offset), ymaxc); - offset += 16;; + offset += 16; - /* 'tweaking action' indicator - not a button */ - UI_icon_draw((float)NLACHANNEL_NAMEWIDTH-offset, ydatac, ICON_EDIT); - } - else { - /* XXX firstly draw a little rect to help identify that it's different from the toggles */ - glBegin(GL_LINE_LOOP); - glVertex2f((float)NLACHANNEL_NAMEWIDTH-offset-1, y-7); - glVertex2f((float)NLACHANNEL_NAMEWIDTH-offset-1, y+9); - glVertex2f((float)NLACHANNEL_NAMEWIDTH-1, y+9); - glVertex2f((float)NLACHANNEL_NAMEWIDTH-1, y-7); - glEnd(); // GL_LINES - - /* 'push down' icon for normal active-actions */ - UI_icon_draw((float)NLACHANNEL_NAMEWIDTH-offset, ydatac, ICON_FREEZE); + /* now draw some indicator icons */ + if ((adt) && (adt->flag & ADT_NLA_EDIT_ON)) { + /* toggle for tweaking with mapping/no-mapping (i.e. 'in place editing' toggle) */ + // for now, use pin icon to symbolise this + if (adt->flag & ADT_NLA_EDIT_NOMAP) + UI_icon_draw((float)(v2d->cur.xmax-offset), ydatac, ICON_PINNED); + else + UI_icon_draw((float)(v2d->cur.xmax-offset), ydatac, ICON_UNPINNED); + + fdrawline((float)(v2d->cur.xmax-offset), yminc, + (float)(v2d->cur.xmax-offset), ymaxc); + offset += 16;; + + /* 'tweaking action' indicator - not a button */ + UI_icon_draw((float)(v2d->cur.xmax-offset), ydatac, ICON_EDIT); + } + else { + /* XXX firstly draw a little rect to help identify that it's different from the toggles */ + glBegin(GL_LINE_LOOP); + glVertex2f((float)v2d->cur.xmax-offset-1, y-7); + glVertex2f((float)v2d->cur.xmax-offset-1, y+9); + glVertex2f((float)v2d->cur.xmax-1, y+9); + glVertex2f((float)v2d->cur.xmax-1, y-7); + glEnd(); // GL_LINES + + /* 'push down' icon for normal active-actions */ + UI_icon_draw((float)NLACHANNEL_NAMEWIDTH-offset, ydatac, ICON_FREEZE); + } } + + glDisable(GL_BLEND); } - - glDisable(GL_BLEND); } /* adjust y-position for next one */ y -= NLACHANNEL_STEP; } +} + +void draw_nla_channel_list (bContext *C, bAnimContext *ac, SpaceNla *snla, ARegion *ar) +{ + ListBase anim_data = {NULL, NULL}; + bAnimListElem *ale; + int filter; + + View2D *v2d= &ar->v2d; + float y= 0.0f; + int items, height; + + /* build list of channels to draw */ + filter= (ANIMFILTER_VISIBLE|ANIMFILTER_CHANNELS); + items= ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); + + /* Update max-extent of channels here (taking into account scrollers): + * - this is done to allow the channel list to be scrollable, but must be done here + * to avoid regenerating the list again and/or also because channels list is drawn first + * - offset of NLACHANNEL_HEIGHT*2 is added to the height of the channels, as first is for + * start of list offset, and the second is as a correction for the scrollers. + */ + height= ((items*NLACHANNEL_STEP) + (NLACHANNEL_HEIGHT*2)); + /* don't use totrect set, as the width stays the same + * (NOTE: this is ok here, the configuration is pretty straightforward) + */ + v2d->tot.ymin= (float)(-height); + + /* draw channels */ + { /* first pass: backdrops + oldstyle drawing */ + y= (float)(-NLACHANNEL_HEIGHT); + + draw_nla_channel_list_gl(ac, &anim_data, v2d, y); + } + { /* second pass: UI widgets */ + uiBlock *block= uiBeginBlock(C, ar, "NLA channel buttons", UI_EMBOSS); + + y= (float)(-NLACHANNEL_HEIGHT); + + /* set blending again, as may not be set in previous step */ + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_BLEND); + + /* loop through channels, and set up drawing depending on their type */ + for (ale= anim_data.first; ale; ale= ale->next) { + const float yminc= (float)(y - NLACHANNEL_HEIGHT_HALF); + const float ymaxc= (float)(y + NLACHANNEL_HEIGHT_HALF); + + /* check if visible */ + if ( IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || + IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) ) + { + /* draw all channels using standard channel-drawing API */ + ANIM_channel_draw_widgets(ac, ale, block, yminc, ymaxc); + } + + /* adjust y-position for next one */ + y -= NLACHANNEL_STEP; + } + + uiEndBlock(C, block); + uiDrawBlock(C, block); + + glDisable(GL_BLEND); + } /* free tempolary channels */ BLI_freelistN(&anim_data); diff --git a/source/blender/editors/space_nla/nla_edit.c b/source/blender/editors/space_nla/nla_edit.c index d476852ef2d..e53ccd004db 100644 --- a/source/blender/editors/space_nla/nla_edit.c +++ b/source/blender/editors/space_nla/nla_edit.c @@ -919,6 +919,58 @@ void NLA_OT_split (wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } +/* ******************** Bake Strips Operator ***************************** */ +/* Bakes the NLA Strips for the active AnimData blocks */ + +static int nlaedit_bake_exec (bContext *C, wmOperator *op) +{ + bAnimContext ac; + + ListBase anim_data = {NULL, NULL}; + bAnimListElem *ale; + int filter; + + /* get editor data */ + if (ANIM_animdata_get_context(C, &ac) == 0) + return OPERATOR_CANCELLED; + + /* get a list of the editable tracks being shown in the NLA */ + filter= (ANIMFILTER_VISIBLE | ANIMFILTER_ANIMDATA | ANIMFILTER_FOREDIT); + ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); + + /* for each AnimData block, bake strips to animdata... */ + for (ale= anim_data.first; ale; ale= ale->next) { + // FIXME + } + + /* free temp data */ + BLI_freelistN(&anim_data); + + /* refresh auto strip properties */ + ED_nla_postop_refresh(&ac); + + /* set notifier that things have changed */ + WM_event_add_notifier(C, NC_ANIMATION|ND_NLA_EDIT, NULL); + + /* done */ + return OPERATOR_FINISHED; +} + +void NLA_OT_bake (wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Bake Strips"; + ot->idname= "NLA_OT_bake"; + ot->description= "Bake all strips of selected AnimData blocks."; + + /* api callbacks */ + ot->exec= nlaedit_bake_exec; + ot->poll= nlaop_poll_tweakmode_off; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} + /* *********************************************** */ /* NLA Editing Operations (Modifying) */ @@ -1197,7 +1249,7 @@ static int nlaedit_apply_scale_exec (bContext *C, wmOperator *op) * but leave everything else alone */ strip->scale= 1.0f; - calc_action_range(strip->act, &strip->actstart, &strip->actend, 1); + calc_action_range(strip->act, &strip->actstart, &strip->actend, 0); } } } diff --git a/source/blender/editors/space_nla/nla_header.c b/source/blender/editors/space_nla/nla_header.c index 04c2db08bda..0d3bf2cb6b1 100644 --- a/source/blender/editors/space_nla/nla_header.c +++ b/source/blender/editors/space_nla/nla_header.c @@ -94,14 +94,14 @@ static void nla_viewmenu(bContext *C, uiLayout *layout, void *arg_unused) uiItemS(layout); - uiItemR(layout, NULL, 0, &spaceptr, "show_cframe_indicator", 0, 0, 0); + uiItemR(layout, NULL, 0, &spaceptr, "show_cframe_indicator", 0); if (snla->flag & SNLA_DRAWTIME) uiItemO(layout, "Show Frames", 0, "ANIM_OT_time_toggle"); else uiItemO(layout, "Show Seconds", 0, "ANIM_OT_time_toggle"); - uiItemR(layout, NULL, 0, &spaceptr, "show_strip_curves", 0, 0, 0); + uiItemR(layout, NULL, 0, &spaceptr, "show_strip_curves", 0); uiItemS(layout); @@ -151,8 +151,8 @@ static void nla_editmenu(bContext *C, uiLayout *layout, void *arg_unused) { Scene *scene= CTX_data_scene(C); - uiItemMenuF(layout, "Transform", 0, nla_edit_transformmenu); - uiItemMenuF(layout, "Snap", 0, nla_edit_snapmenu); + uiItemMenuF(layout, "Transform", 0, nla_edit_transformmenu, NULL); + uiItemMenuF(layout, "Snap", 0, nla_edit_snapmenu, NULL); uiItemS(layout); diff --git a/source/blender/editors/space_nla/nla_intern.h b/source/blender/editors/space_nla/nla_intern.h index 7cc09707ba7..e4557ec878f 100644 --- a/source/blender/editors/space_nla/nla_intern.h +++ b/source/blender/editors/space_nla/nla_intern.h @@ -45,7 +45,7 @@ void NLA_OT_properties(wmOperatorType *ot); /* nla_draw.c */ void draw_nla_main_data(bAnimContext *ac, SpaceNla *snla, ARegion *ar); -void draw_nla_channel_list(bAnimContext *ac, SpaceNla *snla, ARegion *ar); +void draw_nla_channel_list(bContext *C, bAnimContext *ac, SpaceNla *snla, ARegion *ar); /* **************************************** */ /* nla_header.c */ diff --git a/source/blender/editors/space_nla/space_nla.c b/source/blender/editors/space_nla/space_nla.c index 6f377aabd4e..c4f929274c7 100644 --- a/source/blender/editors/space_nla/space_nla.c +++ b/source/blender/editors/space_nla/space_nla.c @@ -238,7 +238,7 @@ static void nla_channel_area_draw(const bContext *C, ARegion *ar) /* data */ if (ANIM_animdata_get_context(C, &ac)) { - draw_nla_channel_list(&ac, snla, ar); + draw_nla_channel_list((bContext *)C, &ac, snla, ar); } /* reset view matrix */ diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index 50cf193f37b..1fb8cb3452b 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -253,7 +253,7 @@ static int node_buts_mix_rgb(uiBlock *block, bNodeTree *ntree, bNode *node, rctf uiButSetFunc(bt, node_but_title_cb, node, bt); /* Alpha option, composite */ if(a_but) - uiDefButS(block, TOG, B_NODE_EXEC, "A", + uiDefIconButS(block, TOG, B_NODE_EXEC, ICON_IMAGE_RGB_ALPHA, (short)butr->xmax-20, (short)butr->ymin, 20, 20, &node->custom2, 0, 0, 0, 0, "Include Alpha of 2nd input in this operation"); } @@ -1077,7 +1077,7 @@ static int node_composit_buts_renderlayers(uiBlock *block, bNodeTree *ntree, bNo /* browse button layer */ strp= scene_layer_menu(node->id?(Scene *)node->id:scene); if(node->id) - bt= uiDefIconTextButS(block, MENU, B_NODE_EXEC, ICON_SCENE_DATA, strp, + bt= uiDefIconTextButS(block, MENU, B_NODE_EXEC, ICON_RENDERLAYERS, strp, butr->xmin+20, butr->ymin, (butr->xmax-butr->xmin)-40, 19, &node->custom1, 0, 0, 0, 0, "Choose Render Layer"); else @@ -1473,7 +1473,7 @@ static int node_composit_buts_vecblur(uiBlock *block, bNodeTree *ntree, bNode *n uiDefButS(block, NUM, B_NODE_EXEC, "MaxSpeed:", butr->xmin, dy+38, dx, 19, &nbd->maxspeed, 0, 1024, 0, 0, "If not zero, maximum speed in pixels"); - uiDefButF(block, NUM, B_NODE_EXEC, "BlurFac:", + uiDefButF(block, NUM, B_NODE_EXEC, "Blur:", butr->xmin, dy+19, dx, 19, &nbd->fac, 0.0f, 2.0f, 10, 2, "Scaling factor for motion vectors, actually 'shutter speed' in frames"); uiDefButS(block, TOG, B_NODE_EXEC, "Curved", diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c index 70e2167c1e4..f3df7a29c2e 100644 --- a/source/blender/editors/space_node/node_draw.c +++ b/source/blender/editors/space_node/node_draw.c @@ -607,9 +607,9 @@ static void do_node_internal_buttons(bContext *C, void *node_v, int event) } WM_event_add_notifier(C, NC_SCENE|ND_NODES, CTX_data_scene(C)); } - - // else if(snode->treetype==NTREE_TEXTURE) - // texture_node_event(snode, val); + else if(snode->treetype==NTREE_TEXTURE) { + WM_event_add_notifier(C, NC_TEXTURE|ND_NODES, snode->id); + } } } diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index fe68a56dea5..bc81c25d106 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -56,6 +56,7 @@ #include "BKE_main.h" #include "BKE_node.h" #include "BKE_material.h" +#include "BKE_paint.h" #include "BKE_texture.h" #include "BKE_scene.h" #include "BKE_utildefines.h" @@ -212,10 +213,8 @@ void snode_handle_recalc(bContext *C, SpaceNode *snode) WM_event_add_notifier(C, NC_MATERIAL|ND_NODES, snode->id); else if(snode->treetype==NTREE_COMPOSIT) WM_event_add_notifier(C, NC_SCENE|ND_NODES, snode->id); - else if(snode->treetype==NTREE_TEXTURE) { - // ntreeTexUpdatePreviews(snode->nodetree); /* XXX texture nodes should follow shader node methods (ton) */ - // XXX BIF_preview_changed(ID_TE); - } + else if(snode->treetype==NTREE_TEXTURE) + WM_event_add_notifier(C, NC_TEXTURE|ND_NODES, snode->id); } #if 0 @@ -486,7 +485,7 @@ static void texture_node_event(SpaceNode *snode, short event) #endif /* 0 */ /* assumes nothing being done in ntree yet, sets the default in/out node */ /* called from shading buttons or header */ -void node_shader_default(Material *ma) +void ED_node_shader_default(Material *ma) { bNode *in, *out; bNodeSocket *fromsock, *tosock; @@ -516,7 +515,7 @@ void node_shader_default(Material *ma) /* assumes nothing being done in ntree yet, sets the default in/out node */ /* called from shading buttons or header */ -void node_composit_default(Scene *sce) +void ED_node_composit_default(Scene *sce) { bNode *in, *out; bNodeSocket *fromsock, *tosock; @@ -550,7 +549,7 @@ void node_composit_default(Scene *sce) /* assumes nothing being done in ntree yet, sets the default in/out node */ /* called from shading buttons or header */ -void node_texture_default(Tex *tx) +void ED_node_texture_default(Tex *tx) { bNode *in, *out; bNodeSocket *fromsock, *tosock; @@ -575,7 +574,6 @@ void node_texture_default(Tex *tx) nodeAddLink(tx->nodetree, in, fromsock, out, tosock); ntreeSolveOrder(tx->nodetree); /* needed for pointers */ - ntreeTexUpdatePreviews(tx->nodetree); /* XXX texture nodes should follow shader node methods (ton) */ } /* Here we set the active tree(s), even called for each redraw now, so keep it fast :) */ @@ -592,7 +590,7 @@ void snode_set_context(SpaceNode *snode, Scene *scene) if(ob) { Material *ma= give_current_material(ob, ob->actcol); if(ma) { - snode->from= material_from(ob, ob->actcol); + snode->from= &ob->id; snode->id= &ma->id; snode->nodetree= ma->nodetree; } @@ -614,7 +612,13 @@ void snode_set_context(SpaceNode *snode, Scene *scene) if(snode->texfrom==SNODE_TEX_OBJECT) { if(ob) { tx= give_current_texture(ob, ob->actcol); - snode->from= (ID *)ob; + + if(ob->type == OB_LAMP) + snode->from= (ID*)ob->data; + else + snode->from= (ID*)give_current_material(ob, ob->actcol); + + /* from is not set fully for material nodes, should be ID + Node then */ } } else if(snode->texfrom==SNODE_TEX_WORLD) { @@ -623,23 +627,20 @@ void snode_set_context(SpaceNode *snode, Scene *scene) } else { MTex *mtex= NULL; + Brush *brush= NULL; - if(G.f & G_SCULPTMODE) { - Sculpt *sd= scene->toolsettings->sculpt; - if(sd && sd->brush) - if(sd->brush->texact != -1) - mtex= sd->brush->mtex[sd->brush->texact]; - } - else { - Brush *br= scene->toolsettings->imapaint.brush; - if(br) - mtex= br->mtex[br->texact]; - } - - if(mtex) { - snode->from= (ID *)scene; + if(ob && (ob->mode & OB_MODE_SCULPT)) + brush= paint_brush(&scene->toolsettings->sculpt->paint); + else + brush= paint_brush(&scene->toolsettings->imapaint.paint); + + if(brush && brush->texact != -1) + mtex= brush->mtex[brush->texact]; + + snode->from= (ID *)brush; + + if(mtex) tx= mtex->tex; - } } if(tx) { @@ -1109,9 +1110,6 @@ static int node_resize_modal(bContext *C, wmOperator *op, wmEvent *event) node->width= nsw->oldwidth + mx - nsw->mxstart; CLAMP(node->width, node->typeinfo->minwidth, node->typeinfo->maxwidth); } - // XXX - if(snode->nodetree->type == NTREE_TEXTURE) - ntreeTexUpdatePreviews(snode->nodetree); /* XXX texture nodes should follow shader node methods (ton) */ ED_region_tag_redraw(ar); @@ -1657,7 +1655,6 @@ bNode *node_add_node(SpaceNode *snode, Scene *scene, int type, float locx, float if(snode->nodetree->type==NTREE_TEXTURE) { ntreeTexCheckCyclics(snode->edittree); - ntreeTexUpdatePreviews(snode->edittree); /* XXX texture nodes should follow shader node methods (ton) */ } return node; @@ -2270,34 +2267,6 @@ void node_read_fullsamplelayers(SpaceNode *snode) WM_cursor_wait(0); } -/* called from header_info, when deleting a scene - * goes over all scenes other than the input, checks if they have - * render layer nodes referencing the to-be-deleted scene, and - * resets them to NULL. */ - -/* XXX needs to get current scene then! */ -void clear_scene_in_nodes(Scene *sce) -{ - Scene *sce1; - bNode *node; - - sce1= G.main->scene.first; - while(sce1) { - if(sce1!=sce) { - if (sce1->nodetree) { - for(node= sce1->nodetree->nodes.first; node; node= node->next) { - if(node->type==CMP_NODE_R_LAYERS) { - Scene *nodesce= (Scene *)node->id; - - if (nodesce==sce) node->id = NULL; - } - } - } - } - sce1= sce1->id.next; - } -} - void imagepaint_composite_tags(bNodeTree *ntree, Image *image, ImageUser *iuser) { bNode *node; diff --git a/source/blender/editors/space_node/node_header.c b/source/blender/editors/space_node/node_header.c index 367242d1262..2abcd2f2135 100644 --- a/source/blender/editors/space_node/node_header.c +++ b/source/blender/editors/space_node/node_header.c @@ -45,6 +45,7 @@ #include "BKE_screen.h" #include "BKE_node.h" #include "BKE_main.h" +#include "BKE_utildefines.h" #include "ED_screen.h" #include "ED_types.h" @@ -62,67 +63,9 @@ #include "node_intern.h" -/* ************************ header area region *********************** */ +/* ************************ add menu *********************** */ -static void do_node_selectmenu(bContext *C, void *arg, int event) -{ - ScrArea *curarea= CTX_wm_area(C); - SpaceNode *snode= CTX_wm_space_node(C); - - /* functions in editnode.c assume there's a tree */ - if(snode->nodetree==NULL) - return; - - switch(event) { - case 1: /* border select */ - WM_operator_name_call(C, "NODE_OT_select_border", WM_OP_INVOKE_REGION_WIN, NULL); - break; - case 2: /* select/deselect all */ - // XXX node_deselectall(snode, 1); - break; - case 3: /* select linked in */ - // XXX node_select_linked(snode, 0); - break; - case 4: /* select linked out */ - // XXX node_select_linked(snode, 1); - break; - } - - ED_area_tag_redraw(curarea); -} - -static uiBlock *node_selectmenu(bContext *C, ARegion *ar, void *arg_unused) -{ - ScrArea *curarea= CTX_wm_area(C); - uiBlock *block; - short yco= 0, menuwidth=120; - - block= uiBeginBlock(C, ar, "node_selectmenu", UI_EMBOSSP); - uiBlockSetButmFunc(block, do_node_selectmenu, NULL); - - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Border Select|B", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 1, ""); - - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Select/Deselect All|A", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 2, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Select Linked From|L", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 3, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Select Linked To|Shift L", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 4, ""); - - if(curarea->headertype==HEADERTOP) { - uiBlockSetDirection(block, UI_DOWN); - } - else { - uiBlockSetDirection(block, UI_TOP); - uiBlockFlipOrder(block); - } - - uiTextBoundsBlock(block, 50); - uiEndBlock(C, block); - - return block; -} - -void do_node_addmenu(bContext *C, void *arg, int event) +static void do_node_add(bContext *C, void *arg, int event) { SpaceNode *snode= CTX_wm_space_node(C); bNode *node; @@ -141,311 +84,125 @@ void do_node_addmenu(bContext *C, void *arg, int event) snode_handle_recalc(C, snode); } -static void node_make_addmenu(bContext *C, int nodeclass, uiBlock *block) +static void node_auto_add_menu(bContext *C, uiLayout *layout, void *arg_nodeclass) { Main *bmain= CTX_data_main(C); SpaceNode *snode= CTX_wm_space_node(C); bNodeTree *ntree; + int nodeclass= GET_INT_FROM_POINTER(arg_nodeclass); int tot= 0, a; - short yco= 0, menuwidth=120; ntree = snode->nodetree; - if(ntree) { - /* mostly taken from toolbox.c, node_add_sublevel() */ - if(ntree) { - if(nodeclass==NODE_CLASS_GROUP) { - bNodeTree *ngroup= bmain->nodetree.first; - for(; ngroup; ngroup= ngroup->id.next) - if(ngroup->type==ntree->type) - tot++; - } - else { - bNodeType *type = ntree->alltypes.first; - while(type) { - if(type->nclass == nodeclass) - tot++; - type= type->next; - } - } - } - - if(tot==0) { - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - return; + + if(!ntree) { + uiItemS(layout); + return; + } + + /* mostly taken from toolbox.c, node_add_sublevel() */ + if(nodeclass==NODE_CLASS_GROUP) { + bNodeTree *ngroup= bmain->nodetree.first; + for(; ngroup; ngroup= ngroup->id.next) + if(ngroup->type==ntree->type) + tot++; + } + else { + bNodeType *type = ntree->alltypes.first; + while(type) { + if(type->nclass == nodeclass) + tot++; + type= type->next; } - - if(nodeclass==NODE_CLASS_GROUP) { - bNodeTree *ngroup= bmain->nodetree.first; - for(tot=0, a=0; ngroup; ngroup= ngroup->id.next, tot++) { - if(ngroup->type==ntree->type) { - - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, (ngroup->id.name+2), 0, - yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1.0f, (float)(NODE_GROUP_MENU+tot), ""); - a++; - } + } + + if(tot==0) { + uiItemS(layout); + return; + } + + uiLayoutSetFunc(layout, do_node_add, NULL); + + if(nodeclass==NODE_CLASS_GROUP) { + bNodeTree *ngroup= bmain->nodetree.first; + + for(tot=0, a=0; ngroup; ngroup= ngroup->id.next, tot++) { + if(ngroup->type==ntree->type) { + uiItemV(layout, ngroup->id.name+2, 0, NODE_GROUP_MENU+tot); + a++; } } - else { - bNodeType *type; - int script=0; - for(a=0, type= ntree->alltypes.first; type; type=type->next) { - if( type->nclass == nodeclass && type->name) { - if(type->type == NODE_DYNAMIC) { - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, type->name, 0, - yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1.0f, (float)(NODE_DYNAMIC_MENU+script), ""); - script++; - } else { - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, type->name, 0, - yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1.0f, (float)(type->type), ""); - } - a++; + } + else { + bNodeType *type; + int script=0; + + for(a=0, type= ntree->alltypes.first; type; type=type->next) { + if(type->nclass == nodeclass && type->name) { + if(type->type == NODE_DYNAMIC) { + uiItemV(layout, type->name, 0, NODE_DYNAMIC_MENU+script); + script++; } + else + uiItemV(layout, type->name, 0, type->type); + + a++; } } - } else { - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - return; } } -static uiBlock *node_add_inputmenu(bContext *C, ARegion *ar, void *arg_unused) -{ - uiBlock *block; - - block= uiBeginBlock(C, ar, "node_add_inputmenu", UI_EMBOSSP); - uiBlockSetButmFunc(block, do_node_addmenu, NULL); - - node_make_addmenu(C, NODE_CLASS_INPUT, block); - - uiBlockSetDirection(block, UI_RIGHT); - uiTextBoundsBlock(block, 60); - uiEndBlock(C, block); - - return block; -} -static uiBlock *node_add_outputmenu(bContext *C, ARegion *ar, void *arg_unused) -{ - uiBlock *block; - - block= uiBeginBlock(C, ar, "node_add_outputmenu", UI_EMBOSSP); - uiBlockSetButmFunc(block, do_node_addmenu, NULL); - - node_make_addmenu(C, NODE_CLASS_OUTPUT, block); - - uiBlockSetDirection(block, UI_RIGHT); - uiTextBoundsBlock(block, 60); - uiEndBlock(C, block); - - return block; -} -static uiBlock *node_add_colormenu(bContext *C, ARegion *ar, void *arg_unused) -{ - uiBlock *block; - - block= uiBeginBlock(C, ar, "node_add_colormenu", UI_EMBOSSP); - uiBlockSetButmFunc(block, do_node_addmenu, NULL); - - node_make_addmenu(C, NODE_CLASS_OP_COLOR, block); - - uiBlockSetDirection(block, UI_RIGHT); - uiTextBoundsBlock(block, 60); - uiEndBlock(C, block); - - return block; -} -static uiBlock *node_add_vectormenu(bContext *C, ARegion *ar, void *arg_unused) -{ - uiBlock *block; - - block= uiBeginBlock(C, ar, "node_add_vectormenu", UI_EMBOSSP); - uiBlockSetButmFunc(block, do_node_addmenu, NULL); - - node_make_addmenu(C, NODE_CLASS_OP_VECTOR, block); - - uiBlockSetDirection(block, UI_RIGHT); - uiTextBoundsBlock(block, 60); - uiEndBlock(C, block); - - return block; -} -static uiBlock *node_add_filtermenu(bContext *C, ARegion *ar, void *arg_unused) -{ - uiBlock *block; - - block= uiBeginBlock(C, ar, "node_add_filtermenu", UI_EMBOSSP); - uiBlockSetButmFunc(block, do_node_addmenu, NULL); - - node_make_addmenu(C, NODE_CLASS_OP_FILTER, block); - - uiBlockSetDirection(block, UI_RIGHT); - uiTextBoundsBlock(block, 60); - uiEndBlock(C, block); - - return block; -} -static uiBlock *node_add_convertermenu(bContext *C, ARegion *ar, void *arg_unused) -{ - uiBlock *block; - - block= uiBeginBlock(C, ar, "node_add_convertermenu", UI_EMBOSSP); - uiBlockSetButmFunc(block, do_node_addmenu, NULL); - - node_make_addmenu(C, NODE_CLASS_CONVERTOR, block); - - uiBlockSetDirection(block, UI_RIGHT); - uiTextBoundsBlock(block, 60); - uiEndBlock(C, block); - - return block; -} -static uiBlock *node_add_mattemenu(bContext *C, ARegion *ar, void *arg_unused) -{ - uiBlock *block; - - block= uiBeginBlock(C, ar, "node_add_mattemenu", UI_EMBOSSP); - uiBlockSetButmFunc(block, do_node_addmenu, NULL); - - node_make_addmenu(C, NODE_CLASS_MATTE, block); - - uiBlockSetDirection(block, UI_RIGHT); - uiTextBoundsBlock(block, 60); - uiEndBlock(C, block); - - return block; -} -static uiBlock *node_add_distortmenu(bContext *C, ARegion *ar, void *arg_unused) -{ - uiBlock *block; - - block= uiBeginBlock(C, ar, "node_add_distortmenu", UI_EMBOSSP); - uiBlockSetButmFunc(block, do_node_addmenu, NULL); - - node_make_addmenu(C, NODE_CLASS_DISTORT, block); - - uiBlockSetDirection(block, UI_RIGHT); - uiTextBoundsBlock(block, 60); - uiEndBlock(C, block); - - return block; -} -static uiBlock *node_add_patternmenu(bContext *C, ARegion *ar, void *arg_unused) -{ - uiBlock *block; - - block= uiBeginBlock(C, ar, "node_add_patternmenu", UI_EMBOSSP); - uiBlockSetButmFunc(block, do_node_addmenu, NULL); - - node_make_addmenu(C, NODE_CLASS_PATTERN, block); - - uiBlockSetDirection(block, UI_RIGHT); - uiTextBoundsBlock(block, 60); - uiEndBlock(C, block); - - return block; -} -static uiBlock *node_add_texturemenu(bContext *C, ARegion *ar, void *arg_unused) +static void node_menu_add(const bContext *C, Menu *menu) { - uiBlock *block; - - block= uiBeginBlock(C, ar, "node_add_texturemenu", UI_EMBOSSP); - uiBlockSetButmFunc(block, do_node_addmenu, NULL); - - node_make_addmenu(C, NODE_CLASS_TEXTURE, block); - - uiBlockSetDirection(block, UI_RIGHT); - uiTextBoundsBlock(block, 60); - uiEndBlock(C, block); - - return block; -} -static uiBlock *node_add_groupmenu(bContext *C, ARegion *ar, void *arg_unused) -{ - uiBlock *block; - - block= uiBeginBlock(C, ar, "node_add_groupmenu", UI_EMBOSSP); - uiBlockSetButmFunc(block, do_node_addmenu, NULL); - - node_make_addmenu(C, NODE_CLASS_GROUP, block); - - uiBlockSetDirection(block, UI_RIGHT); - uiTextBoundsBlock(block, 60); - uiEndBlock(C, block); - - return block; -} + uiLayout *layout= menu->layout; + SpaceNode *snode= CTX_wm_space_node(C); -static uiBlock *node_add_dynamicmenu(bContext *C, ARegion *ar, void *arg_unused) -{ - uiBlock *block; - - block= uiBeginBlock(C, ar, "node_add_dynamicmenu", UI_EMBOSSP); - uiBlockSetButmFunc(block, do_node_addmenu, NULL); - - node_make_addmenu(C, NODE_CLASS_OP_DYNAMIC, block); - - uiBlockSetDirection(block, UI_RIGHT); - uiTextBoundsBlock(block, 60); - uiEndBlock(C, block); - - return block; -} + if(!snode->nodetree) + uiLayoutSetActive(layout, 0); -static uiBlock *node_addmenu(bContext *C, ARegion *ar, void *arg_unused) -{ - ScrArea *curarea= CTX_wm_area(C); - SpaceNode *snode= CTX_wm_space_node(C); - uiBlock *block; - short yco= 0, menuwidth=120; - - block= uiBeginBlock(C, ar, "node_addmenu", UI_EMBOSSP); - uiBlockSetButmFunc(block, do_node_addmenu, NULL); - if(snode->treetype==NTREE_SHADER) { - uiDefIconTextBlockBut(block, node_add_inputmenu, NULL, ICON_RIGHTARROW_THIN, "Input", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, node_add_outputmenu, NULL, ICON_RIGHTARROW_THIN, "Output", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, node_add_colormenu, NULL, ICON_RIGHTARROW_THIN, "Color", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, node_add_vectormenu, NULL, ICON_RIGHTARROW_THIN, "Vector", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, node_add_convertermenu, NULL, ICON_RIGHTARROW_THIN, "Convertor", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, node_add_groupmenu, NULL, ICON_RIGHTARROW_THIN, "Group", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, node_add_dynamicmenu, NULL, ICON_RIGHTARROW_THIN, "Dynamic", 0, yco-=20, 120, 19, ""); + uiItemMenuF(layout, "Input", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_INPUT)); + uiItemMenuF(layout, "Output", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_OUTPUT)); + uiItemMenuF(layout, "Color", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_OP_COLOR)); + uiItemMenuF(layout, "Vector", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_OP_VECTOR)); + uiItemMenuF(layout, "Convertor", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_CONVERTOR)); + uiItemMenuF(layout, "Group", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_GROUP)); + uiItemMenuF(layout, "Dynamic", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_OP_DYNAMIC)); } else if(snode->treetype==NTREE_COMPOSIT) { - uiDefIconTextBlockBut(block, node_add_inputmenu, NULL, ICON_RIGHTARROW_THIN, "Input", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, node_add_outputmenu, NULL, ICON_RIGHTARROW_THIN, "Output", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, node_add_colormenu, NULL, ICON_RIGHTARROW_THIN, "Color", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, node_add_vectormenu, NULL, ICON_RIGHTARROW_THIN, "Vector", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, node_add_filtermenu, NULL, ICON_RIGHTARROW_THIN, "Filter", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, node_add_convertermenu, NULL, ICON_RIGHTARROW_THIN, "Convertor", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, node_add_mattemenu, NULL, ICON_RIGHTARROW_THIN, "Matte", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, node_add_distortmenu, NULL, ICON_RIGHTARROW_THIN, "Distort", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, node_add_groupmenu, NULL, ICON_RIGHTARROW_THIN, "Group", 0, yco-=20, 120, 19, ""); - - } else if(snode->treetype==NTREE_TEXTURE) { - uiDefIconTextBlockBut(block, node_add_inputmenu, NULL, ICON_RIGHTARROW_THIN, "Input", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, node_add_outputmenu, NULL, ICON_RIGHTARROW_THIN, "Output", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, node_add_colormenu, NULL, ICON_RIGHTARROW_THIN, "Color", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, node_add_patternmenu, NULL, ICON_RIGHTARROW_THIN, "Patterns", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, node_add_texturemenu, NULL, ICON_RIGHTARROW_THIN, "Textures", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, node_add_convertermenu, NULL, ICON_RIGHTARROW_THIN, "Convertor", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, node_add_distortmenu, NULL, ICON_RIGHTARROW_THIN, "Distort", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, node_add_groupmenu, NULL, ICON_RIGHTARROW_THIN, "Group", 0, yco-=20, 120, 19, ""); + uiItemMenuF(layout, "Input", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_INPUT)); + uiItemMenuF(layout, "Output", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_OUTPUT)); + uiItemMenuF(layout, "Color", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_OP_COLOR)); + uiItemMenuF(layout, "Vector", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_OP_VECTOR)); + uiItemMenuF(layout, "Filter", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_OP_FILTER)); + uiItemMenuF(layout, "Convertor", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_CONVERTOR)); + uiItemMenuF(layout, "Matte", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_MATTE)); + uiItemMenuF(layout, "Distort", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_DISTORT)); + uiItemMenuF(layout, "Group", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_GROUP)); } - else - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - - if(curarea->headertype==HEADERTOP) { - uiBlockSetDirection(block, UI_DOWN); - } - else { - uiBlockSetDirection(block, UI_TOP); - uiBlockFlipOrder(block); + else if(snode->treetype==NTREE_TEXTURE) { + uiItemMenuF(layout, "Input", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_INPUT)); + uiItemMenuF(layout, "Output", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_OUTPUT)); + uiItemMenuF(layout, "Color", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_OP_COLOR)); + uiItemMenuF(layout, "Patterns", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_PATTERN)); + uiItemMenuF(layout, "Textures", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_TEXTURE)); + uiItemMenuF(layout, "Convertor", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_CONVERTOR)); + uiItemMenuF(layout, "Distort", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_DISTORT)); + uiItemMenuF(layout, "Group", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_GROUP)); } - - uiTextBoundsBlock(block, 50); - - return block; } +void node_menus_register(ARegionType *art) +{ + MenuType *mt; + + mt= MEM_callocN(sizeof(MenuType), "spacetype node menu add"); + strcpy(mt->idname, "NODE_MT_add"); + strcpy(mt->label, "Add"); + mt->draw= node_menu_add; + BLI_addtail(&art->menutypes, mt); +} + +#if 0 static void do_node_nodemenu(bContext *C, void *arg, int event) { ScrArea *curarea= CTX_wm_area(C); @@ -571,218 +328,5 @@ static uiBlock *node_nodemenu(bContext *C, ARegion *ar, void *arg_unused) return block; } - -static void do_node_viewmenu(bContext *C, void *arg, int event) -{ -// SpaceNode *snode= CTX_wm_space_node(C); -// ARegion *ar= CTX_wm_region(C); - ScrArea *sa= CTX_wm_area(C); - - switch(event) { - case 1: /* Zoom in */ - WM_operator_name_call(C, "VIEW2D_OT_zoom_in", WM_OP_EXEC_REGION_WIN, NULL); - break; - case 2: /* View all */ - WM_operator_name_call(C, "VIEW2D_OT_zoom_out", WM_OP_EXEC_REGION_WIN, NULL); - break; - case 3: /* View all */ - WM_operator_name_call(C, "NODE_OT_view_all", WM_OP_EXEC_REGION_WIN, NULL); - break; - case 4: /* Grease Pencil */ - // XXX add_blockhandler(sa, NODES_HANDLER_GREASEPENCIL, UI_PNL_UNSTOW); - break; - } - ED_area_tag_redraw(sa); -} - -static uiBlock *node_viewmenu(bContext *C, ARegion *ar, void *arg_unused) -{ - ScrArea *curarea= CTX_wm_area(C); - SpaceNode *snode= CTX_wm_space_node(C); - uiBlock *block; - short yco= 0, menuwidth=120; - - block= uiBeginBlock(C, ar, "node_viewmenu", UI_EMBOSSP); - uiBlockSetButmFunc(block, do_node_viewmenu, NULL); - - if (snode->nodetree) { - uiDefIconTextBut(block, BUTM, 1, ICON_MENU_PANEL, "Grease Pencil...", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 4, ""); - - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - } - - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Zoom In|NumPad +", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 1, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Zoom Out|NumPad -", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 2, ""); - - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "View All|Home", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 3, ""); - - /* XXX if (!curarea->full) - uiDefIconTextBut(block, BUTM, B_FULL, ICON_BLANK1, "Maximize Window|Ctrl UpArrow", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 4, ""); - else - uiDefIconTextBut(block, BUTM, B_FULL, ICON_BLANK1, "Tile Window|Ctrl DownArrow", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 4, ""); - */ - if(curarea->headertype==HEADERTOP) { - uiBlockSetDirection(block, UI_DOWN); - } - else { - uiBlockSetDirection(block, UI_TOP); - uiBlockFlipOrder(block); - } - - uiTextBoundsBlock(block, 50); - uiEndBlock(C, block); - - return block; -} - -static void do_node_buttons(bContext *C, void *arg, int event) -{ - // NODE_FIX_ME : instead of using "current material/texture/scene", node editor can also pin context? - // note: scene context better not gets overridden, that'll clash too much (ton) - SpaceNode *snode= CTX_wm_space_node(C); - Scene *scene= CTX_data_scene(C); - Material *ma; - Tex *tx; - - switch(event) { - case B_REDR: - ED_area_tag_redraw(CTX_wm_area(C)); - break; - case B_NODE_USEMAT: - ma= (Material *)snode->id; - if(ma) { - if(ma->use_nodes && ma->nodetree==NULL) { - node_shader_default(ma); - snode_set_context(snode, scene); - } - } - ED_area_tag_redraw(CTX_wm_area(C)); - break; - - case B_NODE_USESCENE: - if(scene->use_nodes) { - if(scene->nodetree==NULL) - node_composit_default(scene); - } - snode_set_context(snode, scene); - ED_area_tag_redraw(CTX_wm_area(C)); - break; - - case B_NODE_USETEX: - tx = (Tex *)snode->id; - if(tx) { - tx->type = 0; - if(tx->use_nodes && tx->nodetree==NULL) { - node_texture_default(tx); - snode_set_context(snode, scene); - } - } - ED_area_tag_redraw(CTX_wm_area(C)); - break; - } -} - -void node_header_buttons(const bContext *C, ARegion *ar) -{ - ScrArea *sa= CTX_wm_area(C); - SpaceNode *snode= CTX_wm_space_node(C); - Scene *scene= CTX_data_scene(C); - uiBlock *block; - short xco, yco= 3; - - block= uiBeginBlock(C, ar, "header node", UI_EMBOSS); - uiBlockSetHandleFunc(block, do_node_buttons, NULL); - - xco= ED_area_header_standardbuttons(C, block, yco); - - if((sa->flag & HEADER_NO_PULLDOWN)==0) { - int xmax; - - xmax= GetButStringLength("View"); - uiDefPulldownBut(block, node_viewmenu, NULL, - "View", xco, yco, xmax-3, 20, ""); - xco+= xmax; - - xmax= GetButStringLength("Select"); - uiDefPulldownBut(block, node_selectmenu, NULL, - "Select", xco, yco, xmax-3, 20, ""); - xco+= xmax; - - xmax= GetButStringLength("Add"); - uiDefPulldownBut(block, node_addmenu, NULL, - "Add", xco, yco, xmax-3, 20, ""); - xco+= xmax; - - xmax= GetButStringLength("Node"); - uiDefPulldownBut(block, node_nodemenu, NULL, - "Node", xco, yco, xmax-3, 20, ""); - xco+= xmax; - } - - uiBlockSetEmboss(block, UI_EMBOSS); - - uiBlockSetEmboss(block, UI_EMBOSS); - - /* main type choosing */ - uiBlockBeginAlign(block); - uiDefIconButI(block, ROW, B_REDR, ICON_MATERIAL_DATA, xco,yco,XIC,YIC-2, - &(snode->treetype), 2.0f, 0.0f, 0.0f, 0.0f, "Material Nodes"); - xco+= XIC; - uiDefIconButI(block, ROW, B_REDR, ICON_IMAGE_DATA, xco,yco,XIC,YIC-2, - &(snode->treetype), 2.0f, 1.0f, 0.0f, 0.0f, "Composite Nodes"); - xco+= XIC; - uiDefIconButI(block, ROW, B_REDR, ICON_TEXTURE_DATA, xco,yco,XIC,YIC-2, - &(snode->treetype), 2.0f, 2.0f, 0.0f, 0.0f, "Texture Nodes"); - xco+= 2*XIC; - uiBlockEndAlign(block); - - /* find and set the context */ - snode_set_context(snode, scene); - - if(snode->treetype==NTREE_SHADER) { - if(snode->from) { - /* 0, NULL -> pin */ - // XXX xco= std_libbuttons(block, xco, 0, 0, NULL, B_MATBROWSE, ID_MA, 1, snode->id, snode->from, &(snode->menunr), - // B_MATALONE, B_MATLOCAL, B_MATDELETE, B_AUTOMATNAME, B_KEEPDATA); - - if(snode->id) { - Material *ma= (Material *)snode->id; - uiDefButC(block, TOG, B_NODE_USEMAT, "Use Nodes", xco+5,yco,90,19, &ma->use_nodes, 0.0f, 0.0f, 0, 0, ""); - xco+=80; - } - } - } - else if(snode->treetype==NTREE_COMPOSIT) { - int icon; - - if(WM_jobs_test(CTX_wm_manager(C), sa)) icon= ICON_REC; else icon= ICON_BLANK1; - uiDefIconTextButS(block, TOG, B_NODE_USESCENE, icon, "Use Nodes", xco+5,yco,100,19, &scene->use_nodes, 0.0f, 0.0f, 0, 0, "Indicate this Scene will use Nodes and execute them while editing"); - xco+= 100; - uiDefButBitI(block, TOG, R_COMP_FREE, B_NOP, "Free Unused", xco+5,yco,100,19, &scene->r.scemode, 0.0f, 0.0f, 0, 0, "Free Nodes that are not used while composite"); - xco+= 100; - uiDefButBitS(block, TOG, SNODE_BACKDRAW, B_REDR, "Backdrop", xco+5,yco,90,19, &snode->flag, 0.0f, 0.0f, 0, 0, "Use active Viewer Node output as backdrop"); - xco+= 90; - } - else if(snode->treetype==NTREE_TEXTURE) { - if(snode->from) { - - // XXX xco= std_libbuttons(block, xco, 0, 0, NULL, B_TEXBROWSE, ID_TE, 1, snode->id, snode->from, &(snode->menunr), - // B_TEXALONE, B_TEXLOCAL, B_TEXDELETE, B_AUTOTEXNAME, B_KEEPDATA); - - if(snode->id) { - Tex *tx= (Tex *)snode->id; - uiDefButC(block, TOG, B_NODE_USETEX, "Use Nodes", xco+5,yco,90,19, &tx->use_nodes, 0.0f, 0.0f, 0, 0, ""); - xco+=80; - } - } - } - - UI_view2d_totRect_set(&ar->v2d, xco+XIC+100, (int)(ar->v2d.tot.ymax-ar->v2d.tot.ymin)); - - uiEndBlock(C, block); - uiDrawBlock(C, block); -} - +#endif diff --git a/source/blender/editors/space_node/node_intern.h b/source/blender/editors/space_node/node_intern.h index d6680457376..5c66c902797 100644 --- a/source/blender/editors/space_node/node_intern.h +++ b/source/blender/editors/space_node/node_intern.h @@ -31,6 +31,7 @@ /* internal exports only */ struct ARegion; +struct ARegionType; struct View2D; struct bContext; struct wmWindowManager; @@ -45,6 +46,7 @@ struct wmWindowManager; /* node_header.c */ void node_header_buttons(const bContext *C, ARegion *ar); +void node_menus_register(struct ARegionType *art); /* node_draw.c */ void drawnodespace(const bContext *C, ARegion *ar, View2D *v2d); @@ -75,9 +77,6 @@ void snode_make_group_editable(SpaceNode *snode, bNode *gnode); void snode_home(ScrArea *sa, ARegion *ar, SpaceNode *snode); void node_set_active(SpaceNode *snode, bNode *node); void node_deselectall(SpaceNode *snode, int swap); -void node_shader_default(Material *ma); -void node_composit_default(Scene *sce); -void node_texture_default(Tex *tx); void snode_composite_job(const struct bContext *C, ScrArea *sa); bNode *snode_get_editgroup(SpaceNode *snode); void snode_autoconnect(SpaceNode *snode, bNode *node_to, int flag); diff --git a/source/blender/editors/space_node/node_state.c b/source/blender/editors/space_node/node_state.c index 8d805490942..dcab3dc0895 100644 --- a/source/blender/editors/space_node/node_state.c +++ b/source/blender/editors/space_node/node_state.c @@ -183,7 +183,7 @@ void NODE_OT_visibility_toggle(wmOperatorType *ot) RNA_def_int(ot->srna, "mouse_y", 0, INT_MIN, INT_MAX, "Mouse Y", "", INT_MIN, INT_MAX); } -static int node_fit_all_exec(bContext *C, wmOperator *op) +static int node_view_all_exec(bContext *C, wmOperator *op) { ScrArea *sa= CTX_wm_area(C); ARegion *ar= CTX_wm_region(C); @@ -196,11 +196,11 @@ static int node_fit_all_exec(bContext *C, wmOperator *op) void NODE_OT_view_all(wmOperatorType *ot) { /* identifiers */ - ot->name= "Fit All"; + ot->name= "View All"; ot->idname= "NODE_OT_view_all"; /* api callbacks */ - ot->exec= node_fit_all_exec; + ot->exec= node_view_all_exec; ot->poll= ED_operator_node_active; /* flags */ diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c index 25e1b368ccb..2233a4db3a0 100644 --- a/source/blender/editors/space_node/space_node.c +++ b/source/blender/editors/space_node/space_node.c @@ -46,6 +46,7 @@ #include "BKE_colortools.h" #include "BKE_context.h" #include "BKE_screen.h" +#include "BKE_node.h" #include "ED_previewrender.h" #include "ED_space_api.h" @@ -152,12 +153,16 @@ static void node_area_listener(ScrArea *sa, wmNotifier *wmn) if(wmn->data==ND_FILEREAD) ED_area_tag_refresh(sa); break; - + + /* future: add ID checks? */ case NC_MATERIAL: - /* future: add ID check? */ if(wmn->data==ND_SHADING) ED_area_tag_refresh(sa); break; + case NC_TEXTURE: + if(wmn->data==ND_NODES) + ED_area_tag_refresh(sa); + break; } } @@ -170,13 +175,19 @@ static void node_area_refresh(const struct bContext *C, struct ScrArea *sa) if(snode->treetype==NTREE_SHADER) { Material *ma= (Material *)snode->id; if(ma->use_nodes) - ED_preview_shader_job(C, sa, snode->id, NULL, 100, 100); + ED_preview_shader_job(C, sa, snode->id, NULL, NULL, 100, 100); } else if(snode->treetype==NTREE_COMPOSIT) { Scene *scene= (Scene *)snode->id; if(scene->use_nodes) snode_composite_job(C, sa); } + else if(snode->treetype==NTREE_TEXTURE) { + Tex *tex= (Tex *)snode->id; + if(tex->use_nodes) { + ED_preview_shader_job(C, sa, snode->id, NULL, NULL, 100, 100); + } + } } } @@ -244,29 +255,18 @@ static void node_main_area_draw(const bContext *C, ARegion *ar) /* add handlers, stuff you only do once or on area/region changes */ static void node_header_area_init(wmWindowManager *wm, ARegion *ar) { - UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_HEADER, ar->winx, ar->winy); + ED_region_header_init(ar); } static void node_header_area_draw(const bContext *C, ARegion *ar) { - float col[3]; - - /* clear */ - if(ED_screen_area_active(C)) - UI_GetThemeColor3fv(TH_HEADER, col); - else - UI_GetThemeColor3fv(TH_HEADERDESEL, col); - - glClearColor(col[0], col[1], col[2], 0.0); - glClear(GL_COLOR_BUFFER_BIT); - - /* set view2d view matrix for scrolling (without scrollers) */ - UI_view2d_view_ortho(C, &ar->v2d); - - node_header_buttons(C, ar); - - /* restore view matrix? */ - UI_view2d_view_restore(C); + SpaceNode *snode= CTX_wm_space_node(C); + Scene *scene= CTX_data_scene(C); + + /* find and set the context */ + snode_set_context(snode, scene); + + ED_region_header(C, ar); } /* used for header + main area */ @@ -275,9 +275,9 @@ static void node_region_listener(ARegion *ar, wmNotifier *wmn) /* context changes */ switch(wmn->category) { case NC_SCENE: - ED_region_tag_redraw(ar); - break; case NC_MATERIAL: + case NC_TEXTURE: + case NC_NODE: ED_region_tag_redraw(ar); break; } @@ -344,6 +344,8 @@ void ED_spacetype_node(void) art->draw= node_header_area_draw; BLI_addhead(&st->regiontypes, art); + + node_menus_register(art); #if 0 /* regions: channels */ diff --git a/source/blender/editors/space_outliner/outliner.c b/source/blender/editors/space_outliner/outliner.c index 84dea679767..fca5b0cc59a 100644 --- a/source/blender/editors/space_outliner/outliner.c +++ b/source/blender/editors/space_outliner/outliner.c @@ -620,7 +620,7 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i tenla->name= "Pose"; - if(arm->edbo==NULL && (ob->flag & OB_POSEMODE)) { // channels undefined in editmode, but we want the 'tenla' pose icon itself + if(arm->edbo==NULL && (ob->mode & OB_MODE_POSE)) { // channels undefined in editmode, but we want the 'tenla' pose icon itself int a= 0, const_index= 1000; /* ensure unique id for bone constraints */ for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next, a++) { @@ -887,7 +887,7 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i else { /* do not extend Armature when we have posemode */ tselem= TREESTORE(te->parent); - if( GS(tselem->id->name)==ID_OB && ((Object *)tselem->id)->flag & OB_POSEMODE); + if( GS(tselem->id->name)==ID_OB && ((Object *)tselem->id)->mode & OB_MODE_POSE); else { Bone *curBone; for (curBone=arm->bonebase.first; curBone; curBone=curBone->next){ @@ -1016,7 +1016,6 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i PointerRNA pptr, propptr, *ptr= (PointerRNA*)idv; PropertyRNA *prop, *iterprop; PropertyType proptype; - PropertySubType propsubtype; int a, tot; /* we do lazy build, for speed and to avoid infinite recusion */ @@ -1085,7 +1084,7 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i te->flag |= TE_LAZY_CLOSED; } else if(ELEM3(proptype, PROP_BOOLEAN, PROP_INT, PROP_FLOAT)) { - tot= RNA_property_array_length(prop); + tot= RNA_property_array_length(ptr, prop); if(!(tselem->flag & TSE_CLOSED)) { for(a=0; a<tot; a++) @@ -1096,31 +1095,20 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i } } else if(type == TSE_RNA_ARRAY_ELEM) { - /* array property element */ - static char *vectoritem[4]= {" x", " y", " z", " w"}; - static char *quatitem[4]= {" w", " x", " y", " z"}; - static char *coloritem[4]= {" r", " g", " b", " a"}; + char c; prop= parent->directdata; - proptype= RNA_property_type(prop); - propsubtype= RNA_property_subtype(prop); - tot= RNA_property_array_length(prop); te->directdata= prop; te->rnaptr= *ptr; te->index= index; - if(tot == 4 && propsubtype == PROP_ROTATION) - te->name= quatitem[index]; - else if(tot <= 4 && (propsubtype == PROP_VECTOR || propsubtype == PROP_ROTATION)) - te->name= vectoritem[index]; - else if(tot <= 4 && propsubtype == PROP_COLOR) - te->name= coloritem[index]; - else { - te->name= MEM_callocN(sizeof(char)*20, "OutlinerRNAArrayName"); - sprintf(te->name, " %d", index+1); - te->flag |= TE_FREE_NAME; - } + c= RNA_property_array_item_char(prop, index); + + te->name= MEM_callocN(sizeof(char)*20, "OutlinerRNAArrayName"); + if(c) sprintf(te->name, " %c", c); + else sprintf(te->name, " %d", index+1); + te->flag |= TE_FREE_NAME; } } else if(type == TSE_KEYMAP) { @@ -2189,13 +2177,13 @@ static int tree_element_active_pose(bContext *C, Scene *scene, TreeElement *te, if(scene->obedit) ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR); - if(ob->flag & OB_POSEMODE) + if(ob->mode & OB_MODE_POSE) ED_armature_exit_posemode(C, base); else ED_armature_enter_posemode(C, base); } else { - if(ob->flag & OB_POSEMODE) return 1; + if(ob->mode & OB_MODE_POSE) return 1; } return 0; } @@ -3073,10 +3061,6 @@ static void object_delete_cb(bContext *C, Scene *scene, TreeElement *te, TreeSto if(scene->obedit==base->object) ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR); - if(base==BASACT) { - ED_view3d_exit_paint_modes(C); - } - ED_base_object_free_and_unlink(scene, base); te->directdata= NULL; tselem->id= NULL; @@ -3250,7 +3234,7 @@ static int outliner_object_operation_exec(bContext *C, wmOperator *op) Scene *scene= CTX_data_scene(C); SpaceOops *soops= CTX_wm_space_outliner(C); int event; - char *str; + char *str= NULL; /* check for invalid states */ if (soops == NULL) @@ -3674,7 +3658,7 @@ static void tree_element_to_path(SpaceOops *soops, TreeElement *te, TreeStoreEle } else if(RNA_property_type(prop) == PROP_COLLECTION) { char buf[128], *name; - + temnext= (TreeElement*)(ld->next->data); tsenext= TREESTORE(temnext); @@ -3737,7 +3721,7 @@ static void tree_element_to_path(SpaceOops *soops, TreeElement *te, TreeStoreEle /* item is part of an array, so must set the array_index */ *array_index= te->index; } - else if (RNA_property_array_length(prop)) { + else if (RNA_property_array_length(ptr, prop)) { /* entire array was selected, so keyframe all */ *flag |= KSP_FLAG_WHOLE_ARRAY; } @@ -3917,7 +3901,7 @@ static KeyingSet *verify_active_keyingset(Scene *scene, short add) /* add if none found */ // XXX the default settings have yet to evolve if ((add) && (ks==NULL)) { - ks= BKE_keyingset_add(&scene->keyingsets, "Keying Set", KEYINGSET_ABSOLUTE, 0); + ks= BKE_keyingset_add(&scene->keyingsets, NULL, KEYINGSET_ABSOLUTE, 0); scene->active_keyingset= BLI_countlist(&scene->keyingsets); } @@ -3942,7 +3926,7 @@ static void do_outliner_keyingset_editop(SpaceOops *soops, KeyingSet *ks, ListBa short groupmode= KSP_GROUP_KSNAME; /* check if RNA-property described by this selected element is an animateable prop */ - if ((tselem->type == TSE_RNA_PROPERTY) && RNA_property_animateable(&te->rnaptr, te->directdata)) { + if (ELEM(tselem->type, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM) && RNA_property_animateable(&te->rnaptr, te->directdata)) { /* get id + path + index info from the selected element */ tree_element_to_path(soops, te, tselem, &id, &path, &array_index, &flag, &groupmode); @@ -3979,8 +3963,6 @@ static void do_outliner_keyingset_editop(SpaceOops *soops, KeyingSet *ks, ListBa /* free path, since it had to be generated */ MEM_freeN(path); } - - } /* go over sub-tree */ @@ -4178,13 +4160,13 @@ static void tselem_draw_icon(float x, float y, TreeStoreElem *tselem, TreeElemen case TSE_POSEGRP_BASE: UI_icon_draw(x, y, ICON_VERTEXSEL); break; case TSE_SEQUENCE: - if((te->idcode==SEQ_MOVIE) || (te->idcode==SEQ_MOVIE_AND_HD_SOUND)) + if(te->idcode==SEQ_MOVIE) UI_icon_draw(x, y, ICON_SEQUENCE); else if(te->idcode==SEQ_META) UI_icon_draw(x, y, ICON_DOT); else if(te->idcode==SEQ_SCENE) UI_icon_draw(x, y, ICON_SCENE); - else if((te->idcode==SEQ_RAM_SOUND) || (te->idcode==SEQ_HD_SOUND)) + else if(te->idcode==SEQ_SOUND) UI_icon_draw(x, y, ICON_SOUND); else if(te->idcode==SEQ_IMAGE) UI_icon_draw(x, y, ICON_IMAGE_COL); @@ -5097,6 +5079,28 @@ static char *keymap_tweak_menu(void) return string; } +static char *keymap_tweak_dir_menu(void) +{ + static char string[500]; + static char formatstr[] = "|%s %%x%d"; + char *str= string; + + str += sprintf(str, "Tweak Direction %%t"); + + str += sprintf(str, formatstr, "Any", KM_ANY); + str += sprintf(str, formatstr, "North", EVT_GESTURE_N); + str += sprintf(str, formatstr, "North-East", EVT_GESTURE_NE); + str += sprintf(str, formatstr, "East", EVT_GESTURE_E); + str += sprintf(str, formatstr, "Sout-East", EVT_GESTURE_SE); + str += sprintf(str, formatstr, "South", EVT_GESTURE_S); + str += sprintf(str, formatstr, "South-West", EVT_GESTURE_SW); + str += sprintf(str, formatstr, "West", EVT_GESTURE_W); + str += sprintf(str, formatstr, "North-West", EVT_GESTURE_NW); + + return string; +} + + static void keymap_type_cb(bContext *C, void *kmi_v, void *unused_v) { wmKeymapItem *kmi= kmi_v; @@ -5174,17 +5178,20 @@ static void outliner_draw_keymapbuts(uiBlock *block, ARegion *ar, SpaceOops *soo str= keymap_tweak_menu(); uiDefButS(block, MENU, 0, str, xstart, (int)te->ys+1, butw2, OL_H-1, &kmi->type, 0, 0, 0, 0, "Tweak gesture"); xstart+= butw2+5; + str= keymap_tweak_dir_menu(); + uiDefButS(block, MENU, 0, str, xstart, (int)te->ys+1, butw2, OL_H-1, &kmi->val, 0, 0, 0, 0, "Tweak gesture direction"); + xstart+= butw2+5; break; } /* modifiers */ - uiBlockBeginAlign(block); uiDefButS(block, OPTION, 0, "Shift", xstart, (int)te->ys+1, butw3+5, OL_H-1, &kmi->shift, 0, 0, 0, 0, "Modifier"); xstart+= butw3+5; uiDefButS(block, OPTION, 0, "Ctrl", xstart, (int)te->ys+1, butw3, OL_H-1, &kmi->ctrl, 0, 0, 0, 0, "Modifier"); xstart+= butw3; uiDefButS(block, OPTION, 0, "Alt", xstart, (int)te->ys+1, butw3, OL_H-1, &kmi->alt, 0, 0, 0, 0, "Modifier"); xstart+= butw3; uiDefButS(block, OPTION, 0, "Cmd", xstart, (int)te->ys+1, butw3, OL_H-1, &kmi->oskey, 0, 0, 0, 0, "Modifier"); xstart+= butw3; xstart+= 5; - uiBlockEndAlign(block); + uiDefKeyevtButS(block, 0, "", xstart, (int)te->ys+1, butw3, OL_H-1, &kmi->keymodifier, "Key Modifier code"); + xstart+= butw3+5; /* rna property */ if(kmi->ptr && kmi->ptr->data) @@ -5267,7 +5274,10 @@ void draw_outliner(const bContext *C) sizex_rna= MAX2(OL_RNA_COLX, sizex_rna+OL_RNA_COL_SPACEX); /* get width of data (for setting 'tot' rect, this is column 1 + column 2 + a bit extra) */ - sizex= sizex_rna + OL_RNA_COL_SIZEX + 50; + if (soops->outlinevis == SO_KEYMAP) + sizex= sizex_rna + OL_RNA_COL_SIZEX*3 + 50; // XXX this is only really a quick hack to make this wide enough... + else + sizex= sizex_rna + OL_RNA_COL_SIZEX + 50; } else { /* width must take into account restriction columns (if visible) so that entries will still be visible */ diff --git a/source/blender/editors/space_outliner/outliner_header.c b/source/blender/editors/space_outliner/outliner_header.c index 0c7859ed4e2..d4eeaabd1d3 100644 --- a/source/blender/editors/space_outliner/outliner_header.c +++ b/source/blender/editors/space_outliner/outliner_header.c @@ -177,7 +177,7 @@ static void do_outliner_buttons(bContext *C, void *arg, int event) /* add a new KeyingSet if active is -1 */ if (scene->active_keyingset == -1) { // XXX the default settings have yet to evolve... need to keep this in sync with the - BKE_keyingset_add(&scene->keyingsets, "KeyingSet", KEYINGSET_ABSOLUTE, 0); + BKE_keyingset_add(&scene->keyingsets, NULL, KEYINGSET_ABSOLUTE, 0); scene->active_keyingset= BLI_countlist(&scene->keyingsets); } @@ -196,6 +196,8 @@ static void do_outliner_buttons(bContext *C, void *arg, int event) BLI_freelinkN(&scene->keyingsets, ks); scene->active_keyingset= 0; } + else + scene->active_keyingset= 0; } /* redraw regions with KeyingSet info */ diff --git a/source/blender/editors/space_sequencer/Makefile b/source/blender/editors/space_sequencer/Makefile index 7be0bc9cfef..2fb3de516b4 100644 --- a/source/blender/editors/space_sequencer/Makefile +++ b/source/blender/editors/space_sequencer/Makefile @@ -50,6 +50,7 @@ CPPFLAGS += -I../../imbuf CPPFLAGS += -I../../python CPPFLAGS += -I../../blenfont CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include +CPPFLAGS += -I$(NAN_AUDASPACE)/include # own include diff --git a/source/blender/editors/space_sequencer/SConscript b/source/blender/editors/space_sequencer/SConscript index ab51068a529..7a3fb6982ef 100644 --- a/source/blender/editors/space_sequencer/SConscript +++ b/source/blender/editors/space_sequencer/SConscript @@ -6,5 +6,6 @@ sources = env.Glob('*.c') incs = '../include ../../blenlib ../../blenkernel ../../blenfont ../../makesdna ../../imbuf' incs += ' ../../windowmanager #/intern/guardedalloc #/extern/glew/include' incs += ' ../../makesrna' +incs += ' #/intern/audaspace/intern' env.BlenderLib ( 'bf_editors_space_sequencer', sources, Split(incs), [], libtype=['core'], priority=[100] ) diff --git a/source/blender/editors/space_sequencer/sequencer_add.c b/source/blender/editors/space_sequencer/sequencer_add.c index 99a13c8d9e0..bdedef4b6c8 100644 --- a/source/blender/editors/space_sequencer/sequencer_add.c +++ b/source/blender/editors/space_sequencer/sequencer_add.c @@ -89,6 +89,9 @@ #include "UI_resources.h" #include "UI_view2d.h" +#include "BKE_sound.h" +#include "AUD_C-API.h" + /* own include */ #include "sequencer_intern.h" @@ -224,24 +227,80 @@ void SEQUENCER_OT_scene_strip_add(struct wmOperatorType *ot) RNA_def_string(ot->srna, "scene", "", MAX_ID_NAME-2, "Scene Name", "Scene name to add as a strip"); } +static Sequence* sequencer_add_sound_strip(bContext *C, wmOperator *op, int start_frame, int channel, char* filename) +{ + Scene *scene= CTX_data_scene(C); + Editing *ed= seq_give_editing(scene, TRUE); + + bSound *sound; + + Sequence *seq; /* generic strip vars */ + Strip *strip; + StripElem *se; + + AUD_SoundInfo info; + + sound = sound_new_file(CTX_data_main(C), filename); + + if (sound==NULL || sound->snd_sound == NULL) { + if(op) + BKE_report(op->reports, RPT_ERROR, "Unsupported audio format"); + return NULL; + } + + info = AUD_getInfo(sound->snd_sound); + + if (info.specs.format == AUD_FORMAT_INVALID) { + sound_delete(C, sound); + if(op) + BKE_report(op->reports, RPT_ERROR, "Unsupported audio format"); + return NULL; + } + + seq = alloc_sequence(ed->seqbasep, start_frame, channel); + + seq->type= SEQ_SOUND; + seq->sound= sound; + + /* basic defaults */ + seq->strip= strip= MEM_callocN(sizeof(Strip), "strip"); + strip->len = seq->len = (int) (info.length * FPS); + strip->us= 1; + + strip->stripdata= se= MEM_callocN(seq->len*sizeof(StripElem), "stripelem"); + + BLI_split_dirfile_basic(filename, strip->dir, se->name); + + seq->sound_handle = sound_new_handle(scene, sound, start_frame, start_frame + strip->len, 0); + + calc_sequence_disp(seq); + sort_seq(scene); + + /* last active name */ + strncpy(ed->act_sounddir, strip->dir, FILE_MAXDIR-1); + + return seq; +} + /* add movie operator */ static int sequencer_add_movie_strip_exec(bContext *C, wmOperator *op) { Scene *scene= CTX_data_scene(C); Editing *ed= seq_give_editing(scene, TRUE); - + struct anim *an; char filename[FILE_MAX]; - Sequence *seq; /* generic strip vars */ + Sequence *seq, *soundseq=NULL; /* generic strip vars */ Strip *strip; StripElem *se; - - int start_frame, channel; /* operator props */ - + + int start_frame, channel, sound; /* operator props */ + start_frame= RNA_int_get(op->ptr, "start_frame"); channel= RNA_int_get(op->ptr, "channel"); - + sound = RNA_boolean_get(op->ptr, "sound"); + RNA_string_get(op->ptr, "filename", filename); an = openanim(filename, IB_rect); @@ -271,10 +330,19 @@ static int sequencer_add_movie_strip_exec(bContext *C, wmOperator *op) calc_sequence_disp(seq); sort_seq(scene); + if(sound) + { + soundseq = sequencer_add_sound_strip(C, NULL, start_frame, channel+1, filename); + if(soundseq != NULL) + RNA_string_get(op->ptr, "name", soundseq->name); + } + if (RNA_boolean_get(op->ptr, "replace_sel")) { deselect_all_seq(scene); set_last_seq(scene, seq); seq->flag |= SELECT; + if(soundseq) + soundseq->flag |= SELECT; } ED_area_tag_redraw(CTX_wm_area(C)); @@ -310,24 +378,15 @@ void SEQUENCER_OT_movie_strip_add(struct wmOperatorType *ot) WM_operator_properties_filesel(ot, FOLDERFILE|MOVIEFILE); sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME); - RNA_def_boolean(ot->srna, "sound", TRUE, "Sound", "Load hd sound with the movie"); // XXX need to impliment this + RNA_def_boolean(ot->srna, "sound", TRUE, "Sound", "Load sound with the movie"); } - /* add sound operator */ static int sequencer_add_sound_strip_exec(bContext *C, wmOperator *op) { - Scene *scene= CTX_data_scene(C); - Editing *ed= seq_give_editing(scene, TRUE); - - bSound *sound; - char filename[FILE_MAX]; - + Scene *scene= CTX_data_scene(C); Sequence *seq; /* generic strip vars */ - Strip *strip; - StripElem *se; - int start_frame, channel; /* operator props */ start_frame= RNA_int_get(op->ptr, "start_frame"); @@ -335,47 +394,16 @@ static int sequencer_add_sound_strip_exec(bContext *C, wmOperator *op) RNA_string_get(op->ptr, "filename", filename); - /* XXX if(sfile->flag & FILE_STRINGCODE) { - BLI_makestringcode(G.sce, str); - }*/ - -// XXX sound= sound_new_sound(filename); - sound= NULL; - - if (sound==NULL || sound->sample->type == SAMPLE_INVALID) { - BKE_report(op->reports, RPT_ERROR, "Unsupported audio format"); - return OPERATOR_CANCELLED; - } + seq = sequencer_add_sound_strip(C, op, start_frame, channel, filename); - if (sound==NULL || sound->sample->bits != 16) { - BKE_report(op->reports, RPT_ERROR, "Only 16 bit audio is supported"); + if(seq == NULL) return OPERATOR_CANCELLED; - } - - sound->flags |= SOUND_FLAGS_SEQUENCE; -// XXX audio_makestream(sound); - - seq = alloc_sequence(ed->seqbasep, start_frame, channel); - - seq->type= SEQ_RAM_SOUND; - seq->sound= sound; - - /* basic defaults */ - seq->strip= strip= MEM_callocN(sizeof(Strip), "strip"); - strip->len = seq->len = (int) ( ((float)(sound->streamlen-1) / ( (float)scene->r.audio.mixrate*4.0 ))* FPS); - strip->us= 1; - - strip->stripdata= se= MEM_callocN(seq->len*sizeof(StripElem), "stripelem"); - - BLI_split_dirfile_basic(filename, strip->dir, se->name); RNA_string_get(op->ptr, "name", seq->name); - - calc_sequence_disp(seq); - sort_seq(scene); - - /* last active name */ - strncpy(ed->act_sounddir, strip->dir, FILE_MAXDIR-1); + + if (RNA_boolean_get(op->ptr, "cache")) { + sound_cache(seq->sound, 0); + } if (RNA_boolean_get(op->ptr, "replace_sel")) { deselect_all_seq(scene); @@ -416,7 +444,7 @@ void SEQUENCER_OT_sound_strip_add(struct wmOperatorType *ot) WM_operator_properties_filesel(ot, FOLDERFILE|SOUNDFILE); sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME); - RNA_def_boolean(ot->srna, "cache", FALSE, "Cache", "Load the sound as streaming audio"); // XXX need to impliment this + RNA_def_boolean(ot->srna, "cache", FALSE, "Cache", "Cache the sound in memory."); } /* add image operator */ @@ -585,7 +613,7 @@ static int sequencer_add_effect_strip_exec(bContext *C, wmOperator *op) if(seq->plugin==NULL) { BLI_remlink(ed->seqbasep, seq); - seq_free_sequence(ed, seq); + seq_free_sequence(scene, seq); BKE_reportf(op->reports, RPT_ERROR, "Sequencer plugin \"%s\" could not load.", filename); return OPERATOR_CANCELLED; } diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index 3b90039335e..367bfb68208 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -173,8 +173,7 @@ static void get_seq_color3ubv(Scene *curscene, Sequence *seq, char *col) case SEQ_PLUGIN: UI_GetThemeColor3ubv(TH_SEQ_PLUGIN, col); break; - case SEQ_HD_SOUND: - case SEQ_RAM_SOUND: + case SEQ_SOUND: UI_GetThemeColor3ubv(TH_SEQ_AUDIO, col); blendcol[0] = blendcol[1] = blendcol[2] = 128; if(seq->flag & SEQ_MUTE) UI_GetColorPtrBlendShade3ubv(col, blendcol, col, 0.5, 20); @@ -546,11 +545,8 @@ static void draw_seq_text(View2D *v2d, Sequence *seq, float x1, float x2, float else sprintf(str, "%d | %s", seq->len, give_seqname(seq)); } - else if (seq->type == SEQ_RAM_SOUND) { - sprintf(str, "%d | %s", seq->len, seq->strip->stripdata->name); - } - else if (seq->type == SEQ_HD_SOUND) { - sprintf(str, "%d | %s", seq->len, seq->strip->stripdata->name); + else if (seq->type == SEQ_SOUND) { + sprintf(str, "%d | %s", seq->len, seq->sound->name); } else if (seq->type == SEQ_MOVIE) { sprintf(str, "%d | %s%s", seq->len, seq->strip->dir, seq->strip->stripdata->name); @@ -664,7 +660,8 @@ static void draw_seq_strip(Scene *scene, ARegion *ar, SpaceSeq *sseq, Sequence * draw_shadedstrip(seq, background_col, x1, y1, x2, y2); /* draw additional info and controls */ - if (seq->type == SEQ_RAM_SOUND) + // XXX + if(0) // (seq->type == SEQ_SOUND) drawseqwave(scene, v2d, seq, x1, y1, x2, y2, ar->winx); if (!is_single_image) diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index 036c0769c1e..1555784f470 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -65,6 +65,7 @@ #include "BKE_scene.h" #include "BKE_utildefines.h" #include "BKE_report.h" +#include "BKE_sound.h" #include "WM_api.h" #include "WM_types.h" @@ -166,7 +167,7 @@ Sequence *get_foreground_frame_seq(Scene *scene, int frame) if(seq->flag & SEQ_MUTE || seq->startdisp > frame || seq->enddisp <= frame) continue; /* only use elements you can see - not */ - if (ELEM6(seq->type, SEQ_IMAGE, SEQ_META, SEQ_SCENE, SEQ_MOVIE, SEQ_MOVIE_AND_HD_SOUND, SEQ_COLOR)) { + if (ELEM5(seq->type, SEQ_IMAGE, SEQ_META, SEQ_SCENE, SEQ_MOVIE, SEQ_COLOR)) { if (seq->machine > best_machine) { best_seq = seq; best_machine = seq->machine; @@ -563,7 +564,7 @@ static void reload_sound_strip(Scene *scene, char *name) calc_sequence(seqact); seq->strip= 0; - seq_free_sequence(ed, seq); + seq_free_sequence(scene, seq); BLI_remlink(ed->seqbasep, seq); seq= ed->seqbasep->first; @@ -603,7 +604,7 @@ static void reload_image_strip(Scene *scene, char *name) calc_sequence(seqact); seq->strip= 0; - seq_free_sequence(ed, seq); + seq_free_sequence(scene, seq); BLI_remlink(ed->seqbasep, seq); update_changed_seq_and_deps(scene, seqact, 1, 1); @@ -722,7 +723,7 @@ int seq_effect_find_selected(Scene *scene, Sequence *activeseq, int type, Sequen for(seq=ed->seqbasep->first; seq; seq=seq->next) { if(seq->flag & SELECT) { - if (seq->type == SEQ_RAM_SOUND || seq->type == SEQ_HD_SOUND) { + if (seq->type == SEQ_SOUND) { *error_str= "Can't apply effects to audio sequence strips"; return 0; } @@ -849,7 +850,6 @@ static Sequence *del_seq_find_replace_recurs(Scene *scene, Sequence *seq) static void recurs_del_seq_flag(Scene *scene, ListBase *lb, short flag, short deleteall) { - Editing *ed= seq_give_editing(scene, FALSE); Sequence *seq, *seqn; Sequence *last_seq = get_last_seq(scene); @@ -857,20 +857,20 @@ static void recurs_del_seq_flag(Scene *scene, ListBase *lb, short flag, short de while(seq) { seqn= seq->next; if((seq->flag & flag) || deleteall) { - if(seq->type==SEQ_RAM_SOUND && seq->sound) + if(seq->type==SEQ_SOUND && seq->sound) seq->sound->id.us--; BLI_remlink(lb, seq); if(seq==last_seq) set_last_seq(scene, NULL); if(seq->type==SEQ_META) recurs_del_seq_flag(scene, &seq->seqbase, flag, 1); if(seq->ipo) seq->ipo->id.us--; - seq_free_sequence(ed, seq); + seq_free_sequence(scene, seq); } seq= seqn; } } -static Sequence *dupli_seq(Sequence *seq) +static Sequence *dupli_seq(struct Scene *scene, Sequence *seq) { Sequence *seqn = MEM_dupallocN(seq); // XXX animato: ID *id; @@ -936,14 +936,13 @@ static Sequence *dupli_seq(Sequence *seq) seqn->strip->stripdata = MEM_dupallocN(seq->strip->stripdata); seqn->anim= 0; - } else if(seq->type == SEQ_RAM_SOUND) { - seqn->strip->stripdata = + } else if(seq->type == SEQ_SOUND) { + seqn->strip->stripdata = MEM_dupallocN(seq->strip->stripdata); + if(seq->sound_handle) + seqn->sound_handle = sound_new_handle(scene, seqn->sound, seq->sound_handle->startframe, seq->sound_handle->endframe, seq->sound_handle->frameskip); + seqn->sound->id.us++; - } else if(seq->type == SEQ_HD_SOUND) { - seqn->strip->stripdata = - MEM_dupallocN(seq->strip->stripdata); - seqn->hdaudio = 0; } else if(seq->type == SEQ_IMAGE) { seqn->strip->stripdata = MEM_dupallocN(seq->strip->stripdata); @@ -970,13 +969,13 @@ static Sequence *dupli_seq(Sequence *seq) return seqn; } -static Sequence * deep_dupli_seq(Sequence * seq) +static Sequence * deep_dupli_seq(struct Scene *scene, Sequence * seq) { - Sequence * seqn = dupli_seq(seq); + Sequence * seqn = dupli_seq(scene, seq); if (seq->type == SEQ_META) { Sequence * s; for(s= seq->seqbase.first; s; s = s->next) { - Sequence * n = deep_dupli_seq(s); + Sequence * n = deep_dupli_seq(scene, s); if (n) { BLI_addtail(&seqn->seqbase, n); } @@ -995,7 +994,7 @@ static void recurs_dupli_seq(Scene *scene, ListBase *old, ListBase *new) for(seq= old->first; seq; seq= seq->next) { seq->tmp= NULL; if(seq->flag & SELECT) { - seqn = dupli_seq(seq); + seqn = dupli_seq(scene, seq); if (seqn) { /*should never fail */ seq->flag &= SEQ_DESEL; seqn->flag &= ~(SEQ_LEFTSEL+SEQ_RIGHTSEL+SEQ_LOCK); @@ -1061,10 +1060,10 @@ static Sequence *cut_seq_hard(Scene *scene, Sequence * seq, int cutframe) reload_sequence_new_file(scene, seq); calc_sequence(seq); - + if (!skip_dup) { /* Duplicate AFTER the first change */ - seqn = deep_dupli_seq(seq); + seqn = deep_dupli_seq(scene, seq); } if (seqn) { @@ -1150,10 +1149,10 @@ static Sequence *cut_seq_soft(Scene *scene, Sequence * seq, int cutframe) } calc_sequence(seq); - + if (!skip_dup) { /* Duplicate AFTER the first change */ - seqn = deep_dupli_seq(seq); + seqn = deep_dupli_seq(scene, seq); } if (seqn) { @@ -1493,11 +1492,13 @@ static int sequencer_mute_exec(bContext *C, wmOperator *op) if(selected){ /* mute unselected */ if (seq->flag & SELECT) { seq->flag |= SEQ_MUTE; + seq_update_sound(seq); } } else { if ((seq->flag & SELECT)==0) { seq->flag |= SEQ_MUTE; + seq_update_sound(seq); } } } @@ -1544,11 +1545,13 @@ static int sequencer_unmute_exec(bContext *C, wmOperator *op) if(selected){ /* unmute unselected */ if (seq->flag & SELECT) { seq->flag &= ~SEQ_MUTE; + seq_update_sound(seq); } } else { if ((seq->flag & SELECT)==0) { seq->flag &= ~SEQ_MUTE; + seq_update_sound(seq); } } } @@ -2007,7 +2010,7 @@ static int sequencer_separate_images_exec(bContext *C, wmOperator *op) start_ofs += step; } - seq_free_sequence(ed, seq); + seq_free_sequence(scene, seq); seq = seq->next; } else { seq = seq->next; @@ -2130,7 +2133,7 @@ static int sequencer_meta_make_exec(bContext *C, wmOperator *op) while(seq) { if(seq->flag & SELECT) { tot++; - if (seq->type == SEQ_RAM_SOUND) { + if (seq->type == SEQ_SOUND) { BKE_report(op->reports, RPT_ERROR, "Can't make Meta Strip from audio"); return OPERATOR_CANCELLED;; } @@ -2242,7 +2245,7 @@ static int sequencer_meta_separate_exec(bContext *C, wmOperator *op) last_seq->seqbase.last= 0; BLI_remlink(ed->seqbasep, last_seq); - seq_free_sequence(ed, last_seq); + seq_free_sequence(scene, last_seq); /* emtpy meta strip, delete all effects depending on it */ for(seq=ed->seqbasep->first; seq; seq=seq->next) diff --git a/source/blender/editors/space_sequencer/sequencer_select.c b/source/blender/editors/space_sequencer/sequencer_select.c index 335652235c6..dda5837e5f5 100644 --- a/source/blender/editors/space_sequencer/sequencer_select.c +++ b/source/blender/editors/space_sequencer/sequencer_select.c @@ -153,7 +153,7 @@ void select_single_seq(Scene *scene, Sequence *seq, int deselect_all) /* BRING B if(seq->strip) strncpy(ed->act_imagedir, seq->strip->dir, FILE_MAXDIR-1); } - else if((seq->type==SEQ_HD_SOUND) || (seq->type==SEQ_RAM_SOUND)) { + else if(seq->type==SEQ_SOUND) { if(seq->strip) strncpy(ed->act_sounddir, seq->strip->dir, FILE_MAXDIR-1); } @@ -336,7 +336,7 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, wmEvent *event) strncpy(ed->act_imagedir, seq->strip->dir, FILE_MAXDIR-1); } } else - if (seq->type == SEQ_HD_SOUND || seq->type == SEQ_RAM_SOUND) { + if (seq->type == SEQ_SOUND) { if(seq->strip) { strncpy(ed->act_sounddir, seq->strip->dir, FILE_MAXDIR-1); } diff --git a/source/blender/editors/space_text/space_text.c b/source/blender/editors/space_text/space_text.c index a9c0d3ff76b..4394fbfe1f5 100644 --- a/source/blender/editors/space_text/space_text.c +++ b/source/blender/editors/space_text/space_text.c @@ -210,21 +210,28 @@ static void text_keymap(struct wmWindowManager *wm) WM_keymap_add_item(keymap, "TEXT_OT_open", OKEY, KM_PRESS, KM_ALT, 0); WM_keymap_add_item(keymap, "TEXT_OT_reload", RKEY, KM_PRESS, KM_ALT, 0); WM_keymap_add_item(keymap, "TEXT_OT_save", SKEY, KM_PRESS, KM_ALT, 0); + 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_CTRL, 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_run_script", PKEY, KM_PRESS, KM_ALT, 0); WM_keymap_add_item(keymap, "TEXT_OT_cut", XKEY, KM_PRESS, KM_ALT, 0); WM_keymap_add_item(keymap, "TEXT_OT_cut", XKEY, KM_PRESS, KM_CTRL, 0); + WM_keymap_add_item(keymap, "TEXT_OT_cut", XKEY, KM_PRESS, KM_OSKEY, 0); WM_keymap_add_item(keymap, "TEXT_OT_copy", CKEY, KM_PRESS, KM_ALT, 0); WM_keymap_add_item(keymap, "TEXT_OT_copy", CKEY, KM_PRESS, KM_CTRL, 0); + WM_keymap_add_item(keymap, "TEXT_OT_copy", CKEY, KM_PRESS, KM_OSKEY, 0); WM_keymap_add_item(keymap, "TEXT_OT_paste", VKEY, KM_PRESS, KM_ALT, 0); WM_keymap_add_item(keymap, "TEXT_OT_paste", VKEY, KM_PRESS, KM_CTRL, 0); + WM_keymap_add_item(keymap, "TEXT_OT_paste", VKEY, KM_PRESS, KM_OSKEY, 0); if(U.uiflag & USER_MMB_PASTE) // XXX not dynamic RNA_boolean_set(WM_keymap_add_item(keymap, "TEXT_OT_paste", MIDDLEMOUSE, KM_PRESS, 0, 0)->ptr, "selection", 1); WM_keymap_add_item(keymap, "TEXT_OT_jump", JKEY, KM_PRESS, KM_ALT, 0); WM_keymap_add_item(keymap, "TEXT_OT_find", FKEY, KM_PRESS, KM_ALT, 0); + WM_keymap_add_item(keymap, "TEXT_OT_find", FKEY, KM_PRESS, KM_OSKEY, 0); WM_keymap_add_item(keymap, "TEXT_OT_properties", FKEY, KM_PRESS, KM_ALT, 0); WM_keymap_add_item(keymap, "TEXT_OT_properties", FKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "TEXT_OT_replace", HKEY, KM_PRESS, KM_ALT, 0); @@ -233,6 +240,7 @@ static void text_keymap(struct wmWindowManager *wm) WM_keymap_add_item(keymap, "TEXT_OT_to_3d_object", MKEY, KM_PRESS, KM_ALT, 0); WM_keymap_add_item(keymap, "TEXT_OT_select_all", AKEY, KM_PRESS, KM_CTRL, 0); + WM_keymap_add_item(keymap, "TEXT_OT_select_all", AKEY, KM_PRESS, KM_OSKEY, 0); WM_keymap_add_item(keymap, "TEXT_OT_indent", TABKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "TEXT_OT_unindent", TABKEY, KM_PRESS, KM_SHIFT, 0); diff --git a/source/blender/editors/space_text/text_header.c b/source/blender/editors/space_text/text_header.c index c761587198f..089436cfcf9 100644 --- a/source/blender/editors/space_text/text_header.c +++ b/source/blender/editors/space_text/text_header.c @@ -186,12 +186,18 @@ ARegion *text_has_properties_region(ScrArea *sa) return arnew; } -static int properties_poll(bContext *C) +void text_toggle_properties_region(bContext *C, ScrArea *sa, ARegion *ar) { - SpaceText *st= CTX_wm_space_text(C); - Text *text= CTX_data_edit_text(C); + ar->flag ^= RGN_FLAG_HIDDEN; + ar->v2d.flag &= ~V2D_IS_INITIALISED; /* XXX should become hide/unhide api? */ + + ED_area_initialize(CTX_wm_manager(C), CTX_wm_window(C), sa); + ED_area_tag_redraw(sa); +} - return (st && text); +static int properties_poll(bContext *C) +{ + return (CTX_wm_space_text(C) != NULL); } static int properties_exec(bContext *C, wmOperator *op) @@ -199,13 +205,8 @@ static int properties_exec(bContext *C, wmOperator *op) ScrArea *sa= CTX_wm_area(C); ARegion *ar= text_has_properties_region(sa); - if(ar) { - ar->flag ^= RGN_FLAG_HIDDEN; - ar->v2d.flag &= ~V2D_IS_INITIALISED; /* XXX should become hide/unhide api? */ - - ED_area_initialize(CTX_wm_manager(C), CTX_wm_window(C), sa); - ED_area_tag_redraw(sa); - } + if(ar) + text_toggle_properties_region(C, sa, ar); return OPERATOR_FINISHED; } @@ -214,6 +215,7 @@ void TEXT_OT_properties(wmOperatorType *ot) { /* identifiers */ ot->name= "Properties"; + ot->description= "Toggle text properties panel."; ot->idname= "TEXT_OT_properties"; /* api callbacks */ diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index 4c9f47ed170..7e514ea723a 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -176,6 +176,7 @@ void TEXT_OT_new(wmOperatorType *ot) { /* identifiers */ ot->name= "New"; + ot->description= "Create a new text data block."; ot->idname= "TEXT_OT_new"; /* api callbacks */ @@ -223,6 +224,7 @@ void TEXT_OT_open(wmOperatorType *ot) { /* identifiers */ ot->name= "Open"; + ot->description= "Open a new text data block."; ot->idname= "TEXT_OT_open"; /* api callbacks */ @@ -260,6 +262,7 @@ void TEXT_OT_reload(wmOperatorType *ot) { /* identifiers */ ot->name= "Reload"; + ot->description= "Reload active text data block from its file."; ot->idname= "TEXT_OT_reload"; /* api callbacks */ @@ -337,6 +340,7 @@ void TEXT_OT_unlink(wmOperatorType *ot) { /* identifiers */ ot->name= "Unlink"; + ot->description= "Unlink active text data block."; ot->idname= "TEXT_OT_unlink"; /* api callbacks */ @@ -367,6 +371,7 @@ void TEXT_OT_make_internal(wmOperatorType *ot) { /* identifiers */ ot->name= "Make Internal"; + ot->description= "Make active text file internal."; ot->idname= "TEXT_OT_make_internal"; /* api callbacks */ @@ -435,6 +440,7 @@ void TEXT_OT_save(wmOperatorType *ot) { /* identifiers */ ot->name= "Save"; + ot->description= "Save active text data block."; ot->idname= "TEXT_OT_save"; /* api callbacks */ @@ -490,6 +496,7 @@ void TEXT_OT_save_as(wmOperatorType *ot) { /* identifiers */ ot->name= "Save As"; + ot->description= "Save active text file with options."; ot->idname= "TEXT_OT_save_as"; /* api callbacks */ @@ -527,6 +534,7 @@ void TEXT_OT_run_script(wmOperatorType *ot) { /* identifiers */ ot->name= "Run Script"; + ot->description= "Run active script."; ot->idname= "TEXT_OT_run_script"; /* api callbacks */ @@ -583,6 +591,7 @@ void TEXT_OT_refresh_pyconstraints(wmOperatorType *ot) { /* identifiers */ ot->name= "Refresh PyConstraints"; + ot->description= "Refresh all pyconstraints."; ot->idname= "TEXT_OT_refresh_pyconstraints"; /* api callbacks */ @@ -704,6 +713,7 @@ void TEXT_OT_paste(wmOperatorType *ot) { /* identifiers */ ot->name= "Paste"; + ot->description= "Paste text from clipboard."; ot->idname= "TEXT_OT_paste"; /* api callbacks */ @@ -744,6 +754,7 @@ void TEXT_OT_copy(wmOperatorType *ot) { /* identifiers */ ot->name= "Copy"; + ot->description= "Copy selected text to clipboard."; ot->idname= "TEXT_OT_copy"; /* api callbacks */ @@ -774,6 +785,7 @@ void TEXT_OT_cut(wmOperatorType *ot) { /* identifiers */ ot->name= "Cut"; + ot->description= "Cut selected text to clipboard."; ot->idname= "TEXT_OT_cut"; /* api callbacks */ @@ -809,6 +821,7 @@ void TEXT_OT_indent(wmOperatorType *ot) { /* identifiers */ ot->name= "Indent"; + ot->description= "Indent selected text."; ot->idname= "TEXT_OT_indent"; /* api callbacks */ @@ -844,6 +857,7 @@ void TEXT_OT_unindent(wmOperatorType *ot) { /* identifiers */ ot->name= "Unindent"; + ot->description= "Unindent selected text."; ot->idname= "TEXT_OT_unindent"; /* api callbacks */ @@ -884,6 +898,7 @@ void TEXT_OT_line_break(wmOperatorType *ot) { /* identifiers */ ot->name= "Line Break"; + ot->description= "Insert line break at cursor position."; ot->idname= "TEXT_OT_line_break"; /* api callbacks */ @@ -916,6 +931,7 @@ void TEXT_OT_comment(wmOperatorType *ot) { /* identifiers */ ot->name= "Comment"; + ot->description= "Convert selected text to comment."; ot->idname= "TEXT_OT_comment"; /* api callbacks */ @@ -949,6 +965,7 @@ void TEXT_OT_uncomment(wmOperatorType *ot) { /* identifiers */ ot->name= "Uncomment"; + ot->description= "Convert selected comment to text."; ot->idname= "TEXT_OT_uncomment"; /* api callbacks */ @@ -1090,6 +1107,7 @@ void TEXT_OT_convert_whitespace(wmOperatorType *ot) { /* identifiers */ ot->name= "Convert Whitespace"; + ot->description= "Convert whitespaces by type."; ot->idname= "TEXT_OT_convert_whitespace"; /* api callbacks */ @@ -1120,6 +1138,7 @@ void TEXT_OT_select_all(wmOperatorType *ot) { /* identifiers */ ot->name= "Select All"; + ot->description= "Select all text."; ot->idname= "TEXT_OT_select_all"; /* api callbacks */ @@ -1147,6 +1166,7 @@ void TEXT_OT_select_line(wmOperatorType *ot) { /* identifiers */ ot->name= "Select Line"; + ot->description= "Select text by line."; ot->idname= "TEXT_OT_select_line"; /* api clinebacks */ @@ -1184,6 +1204,7 @@ void TEXT_OT_previous_marker(wmOperatorType *ot) { /* identifiers */ ot->name= "Previous Marker"; + ot->description= "Move to previous marker."; ot->idname= "TEXT_OT_previous_marker"; /* api callbacks */ @@ -1221,6 +1242,7 @@ void TEXT_OT_next_marker(wmOperatorType *ot) { /* identifiers */ ot->name= "Next Marker"; + ot->description= "Move to next marker"; ot->idname= "TEXT_OT_next_marker"; /* api callbacks */ @@ -1248,6 +1270,7 @@ void TEXT_OT_markers_clear(wmOperatorType *ot) { /* identifiers */ ot->name= "Clear All Markers"; + ot->description= "Clear all markers."; ot->idname= "TEXT_OT_markers_clear"; /* api callbacks */ @@ -1531,6 +1554,7 @@ void TEXT_OT_move(wmOperatorType *ot) { /* identifiers */ ot->name= "Move Cursor"; + ot->description= "Move cursor to position type."; ot->idname= "TEXT_OT_move"; /* api callbacks */ @@ -1557,6 +1581,7 @@ void TEXT_OT_move_select(wmOperatorType *ot) { /* identifiers */ ot->name= "Move Select"; + ot->description= "Make selection from current cursor position to new cursor position type."; ot->idname= "TEXT_OT_move_select"; /* api callbacks */ @@ -1596,6 +1621,7 @@ void TEXT_OT_jump(wmOperatorType *ot) { /* identifiers */ ot->name= "Jump"; + ot->description= "Jump cursor to line."; ot->idname= "TEXT_OT_jump"; /* api callbacks */ @@ -1648,6 +1674,7 @@ void TEXT_OT_delete(wmOperatorType *ot) { /* identifiers */ ot->name= "Delete"; + ot->description= "Delete text by cursor position."; ot->idname= "TEXT_OT_delete"; /* api callbacks */ @@ -1828,6 +1855,10 @@ void TEXT_OT_scroll(wmOperatorType *ot) { /* identifiers */ ot->name= "Scroll"; + /*don't really see the difference between this and + scroll_bar. Both do basically the same thing (aside + from keymaps).*/ + ot->description= "Scroll text screen."; ot->idname= "TEXT_OT_scroll"; /* api callbacks */ @@ -1876,6 +1907,10 @@ void TEXT_OT_scroll_bar(wmOperatorType *ot) { /* identifiers */ ot->name= "Scrollbar"; + /*don't really see the difference between this and + scroll. Both do basically the same thing (aside + from keymaps).*/ + ot->description= "Scroll text screen."; ot->idname= "TEXT_OT_scroll_bar"; /* api callbacks */ @@ -2151,6 +2186,7 @@ void TEXT_OT_cursor_set(wmOperatorType *ot) { /* identifiers */ ot->name= "Set Cursor"; + ot->description= "Set cursor selection."; ot->idname= "TEXT_OT_cursor_set"; /* api callbacks */ @@ -2274,6 +2310,7 @@ void TEXT_OT_insert(wmOperatorType *ot) { /* identifiers */ ot->name= "Insert"; + ot->description= "Insert text at cursor position."; ot->idname= "TEXT_OT_insert"; /* api callbacks */ @@ -2378,6 +2415,7 @@ void TEXT_OT_find(wmOperatorType *ot) { /* identifiers */ ot->name= "Find"; + ot->description= "Find specified text."; ot->idname= "TEXT_OT_find"; /* api callbacks */ @@ -2396,6 +2434,7 @@ void TEXT_OT_replace(wmOperatorType *ot) { /* identifiers */ ot->name= "Replace"; + ot->description= "Replace text with specified text."; ot->idname= "TEXT_OT_replace"; /* api callbacks */ @@ -2414,6 +2453,7 @@ void TEXT_OT_mark_all(wmOperatorType *ot) { /* identifiers */ ot->name= "Mark All"; + ot->description= "Mark all specified text."; ot->idname= "TEXT_OT_mark_all"; /* api callbacks */ @@ -2443,6 +2483,7 @@ void TEXT_OT_find_set_selected(wmOperatorType *ot) { /* identifiers */ ot->name= "Find Set Selected"; + ot->description= "Find specified text and set as selected."; ot->idname= "TEXT_OT_find_set_selected"; /* api callbacks */ @@ -2469,6 +2510,7 @@ void TEXT_OT_replace_set_selected(wmOperatorType *ot) { /* identifiers */ ot->name= "Replace Set Selected"; + ot->description= "Replace text with specified text and set as selected."; ot->idname= "TEXT_OT_replace_set_selected"; /* api callbacks */ @@ -2631,6 +2673,7 @@ void TEXT_OT_to_3d_object(wmOperatorType *ot) { /* identifiers */ ot->name= "To 3D Object"; + ot->description= "Create 3d text object from active text data block."; ot->idname= "TEXT_OT_to_3d_object"; /* api callbacks */ diff --git a/source/blender/editors/space_time/space_time.c b/source/blender/editors/space_time/space_time.c index 8445f1b47e7..ce6846a4489 100644 --- a/source/blender/editors/space_time/space_time.c +++ b/source/blender/editors/space_time/space_time.c @@ -260,11 +260,15 @@ static void time_main_area_listener(ARegion *ar, wmNotifier *wmn) { /* context changes */ switch(wmn->category) { + case NC_ANIMATION: + ED_region_tag_redraw(ar); + break; case NC_SCENE: /* any scene change for now */ ED_region_tag_redraw(ar); break; + } } @@ -273,29 +277,12 @@ static void time_main_area_listener(ARegion *ar, wmNotifier *wmn) /* add handlers, stuff you only do once or on area/region changes */ static void time_header_area_init(wmWindowManager *wm, ARegion *ar) { - UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_HEADER, ar->winx, ar->winy); + ED_region_header_init(ar); } static void time_header_area_draw(const bContext *C, ARegion *ar) { - float col[3]; - - /* clear */ - if(ED_screen_area_active(C)) - UI_GetThemeColor3fv(TH_HEADER, col); - else - UI_GetThemeColor3fv(TH_HEADERDESEL, col); - - glClearColor(col[0], col[1], col[2], 0.0); - glClear(GL_COLOR_BUFFER_BIT); - - /* set view2d view matrix for scrolling (without scrollers) */ - UI_view2d_view_ortho(C, &ar->v2d); - - time_header_buttons(C, ar); - - /* restore view matrix? */ - UI_view2d_view_restore(C); + ED_region_header(C, ar); } static void time_header_area_listener(ARegion *ar, wmNotifier *wmn) @@ -372,8 +359,6 @@ static SpaceLink *time_new(const bContext *C) static void time_free(SpaceLink *sl) { } - - /* spacetype; init callback in ED_area_initialize() */ /* init is called to (re)initialize an existing editor (file read, screen changes) */ /* validate spacedata, add own area level handlers */ diff --git a/source/blender/editors/space_time/time_header.c b/source/blender/editors/space_time/time_header.c deleted file mode 100644 index b4e3c087360..00000000000 --- a/source/blender/editors/space_time/time_header.c +++ /dev/null @@ -1,572 +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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * The Original Code is Copyright (C) 2008 Blender Foundation. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -#include <string.h> -#include <stdio.h> - -#include "DNA_space_types.h" -#include "DNA_scene_types.h" -#include "DNA_screen_types.h" -#include "DNA_windowmanager_types.h" -#include "DNA_userdef_types.h" - -#include "MEM_guardedalloc.h" - -#include "BLI_blenlib.h" - -#include "BKE_context.h" -#include "BKE_global.h" -#include "BKE_screen.h" - -#include "ED_keyframing.h" -#include "ED_screen.h" -#include "ED_screen_types.h" -#include "ED_types.h" -#include "ED_util.h" - -#include "WM_api.h" -#include "WM_types.h" - -#include "RNA_access.h" - -#include "BIF_gl.h" -#include "BIF_glutil.h" - -#include "UI_interface.h" -#include "UI_resources.h" -#include "UI_view2d.h" - -#include "ED_markers.h" - -#include "time_intern.h" - - -/* ************************ header time area region *********************** */ - -/* exported for use in screen_ops.c */ -ARegion *time_top_left_3dwindow(bScreen *screen) -{ - ARegion *aret= NULL; - ScrArea *sa; - int min= 10000; - - for(sa= screen->areabase.first; sa; sa= sa->next) { - if(sa->spacetype==SPACE_VIEW3D) { - ARegion *ar; - for(ar= sa->regionbase.first; ar; ar= ar->next) { - if(ar->regiontype==RGN_TYPE_WINDOW) { - if(ar->winrct.xmin - ar->winrct.ymin < min) { - aret= ar; - min= ar->winrct.xmin - ar->winrct.ymin; - } - } - } - } - } - return aret; -} - -static void do_time_redrawmenu(bContext *C, void *arg, int event) -{ - - if(event < 1001) { - bScreen *screen= CTX_wm_screen(C); - SpaceTime *stime= CTX_wm_space_time(C); - - stime->redraws ^= event; - - if(screen->animtimer) { - wmTimer *wt= screen->animtimer; - ScreenAnimData *sad= wt->customdata; - - sad->redraws= stime->redraws; - sad->ar= NULL; - if(stime->redraws & TIME_REGION) - sad->ar= time_top_left_3dwindow(screen); - } - } -} - - -static uiBlock *time_redrawmenu(bContext *C, ARegion *ar, void *arg_unused) -{ - ScrArea *curarea= CTX_wm_area(C); - SpaceTime *stime= CTX_wm_space_time(C); - uiBlock *block; - short yco= 0, menuwidth=120, icon; - - block= uiBeginBlock(C, ar, "header time_redrawmenu", UI_EMBOSSP); - uiBlockSetButmFunc(block, do_time_redrawmenu, NULL); - - if(stime->redraws & TIME_REGION) icon= ICON_CHECKBOX_HLT; - else icon= ICON_CHECKBOX_DEHLT; - uiDefIconTextBut(block, BUTM, 1, icon, "Top-Left 3D Window", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, TIME_REGION, ""); - - if(stime->redraws & TIME_ALL_3D_WIN) icon= ICON_CHECKBOX_HLT; - else icon= ICON_CHECKBOX_DEHLT; - uiDefIconTextBut(block, BUTM, 1, icon, "All 3D Windows", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, TIME_ALL_3D_WIN, ""); - - if(stime->redraws & TIME_ALL_ANIM_WIN) icon= ICON_CHECKBOX_HLT; - else icon= ICON_CHECKBOX_DEHLT; - uiDefIconTextBut(block, BUTM, 1, icon, "Animation Windows", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, TIME_ALL_ANIM_WIN, ""); - - if(stime->redraws & TIME_ALL_BUTS_WIN) icon= ICON_CHECKBOX_HLT; - else icon= ICON_CHECKBOX_DEHLT; - uiDefIconTextBut(block, BUTM, 1, icon, "Buttons Windows", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, TIME_ALL_BUTS_WIN, ""); - - if(stime->redraws & TIME_ALL_IMAGE_WIN) icon= ICON_CHECKBOX_HLT; - else icon= ICON_CHECKBOX_DEHLT; - uiDefIconTextBut(block, BUTM, 1, icon, "Image Windows", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, TIME_ALL_IMAGE_WIN, ""); - - /* Add sequencer only redraw*/ - if(stime->redraws & TIME_SEQ) icon= ICON_CHECKBOX_HLT; - else icon= ICON_CHECKBOX_DEHLT; - uiDefIconTextBut(block, BUTM, 1, icon, "Sequencer Windows", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, TIME_SEQ, ""); - - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - - if(stime->redraws & TIME_CONTINUE_PHYSICS) icon= ICON_CHECKBOX_HLT; - else icon= ICON_CHECKBOX_DEHLT; - uiDefIconTextBut(block, BUTM, 1, icon, "Continue Physics", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, TIME_CONTINUE_PHYSICS, "During playblack, continue physics simulations regardless of the frame number"); - - if(curarea->headertype==HEADERTOP) { - uiBlockSetDirection(block, UI_DOWN); - } - else { - uiBlockSetDirection(block, UI_TOP); - uiBlockFlipOrder(block); - } - - uiTextBoundsBlock(block, 50); - uiEndBlock(C, block); - - return block; -} - -static void do_time_viewmenu(bContext *C, void *arg, int event) -{ - ScrArea *curarea= CTX_wm_area(C); - SpaceTime *stime= CTX_wm_space_time(C); - View2D *v2d= UI_view2d_fromcontext_rwin(C); - Scene *scene= CTX_data_scene(C); - int first; - - switch(event) { - case 2: /* Play Back Animation */ - //if(!has_screenhandler(G.curscreen, SCREEN_HANDLER_ANIM)) - // start_animated_screen(stime); - break; - case 3: /* View All */ - if(v2d) { - first= scene->r.sfra; - if(first >= scene->r.efra) first= scene->r.efra; - v2d->cur.xmin=v2d->tot.xmin= (float)first-2; - v2d->cur.xmax=v2d->tot.xmax= (float)scene->r.efra+2; - - ED_area_tag_redraw(curarea); - } - break; - case 4: /* Maximize Window */ - /* using event B_FULL */ - break; - case 5: /* show time or frames */ - stime->flag ^= TIME_DRAWFRAMES; - ED_area_tag_redraw(curarea); - break; - case 6: - //nextprev_marker(1); - break; - case 7: - //nextprev_marker(-1); - break; - case 10: - //timeline_frame_to_center(); - break; - case 11: - if(v2d) { - v2d->flag ^= V2D_VIEWSYNC_SCREEN_TIME; - UI_view2d_sync(CTX_wm_screen(C), CTX_wm_area(C), v2d, V2D_LOCK_SET); - } - break; - case 12: /* only show keyframes from selected data */ - stime->flag ^= TIME_ONLYACTSEL; - ED_area_tag_redraw(curarea); - break; - } -} - -static uiBlock *time_viewmenu(bContext *C, ARegion *ar, void *arg_unused) -{ - ScrArea *curarea= CTX_wm_area(C); - SpaceTime *stime= CTX_wm_space_time(C); - View2D *v2d= UI_view2d_fromcontext_rwin(C); - uiBlock *block; - short yco= 0, menuwidth=120; - - block= uiBeginBlock(C, ar, "time_viewmenu", UI_EMBOSSP); - uiBlockSetButmFunc(block, do_time_viewmenu, NULL); - - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Play Back Animation", 0, yco-=20, - menuwidth, 19, NULL, 0.0, 0.0, 1, 2, ""); - - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - - if(stime->flag & TIME_DRAWFRAMES) - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Show Seconds|Ctrl T", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 5, ""); - else - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Show Frames|Ctrl T", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 5, ""); - - uiDefIconTextBut(block, BUTM, 1, (stime->flag & TIME_ONLYACTSEL)?ICON_CHECKBOX_HLT:ICON_CHECKBOX_DEHLT, - "Only Selected Data Keys|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 12, ""); - - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Jump To Next Marker|PageUp", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 6, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Jump To Prev Marker|PageDown", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 7, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Jump To Next Key|Ctrl PageUp", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 8, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Jump To Prev Key|Ctrl PageDown", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 9, ""); - - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Center View|C", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 10, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "View All|Home", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 3, ""); - uiDefIconTextBut(block, BUTM, 1, (v2d->flag & V2D_VIEWSYNC_SCREEN_TIME)?ICON_CHECKBOX_HLT:ICON_CHECKBOX_DEHLT, - "Lock Time to Other Windows|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 11, ""); - -// if (!curarea->full) -// uiDefIconTextBut(block, BUTM, B_FULL, ICON_BLANK1, "Maximize Window|Ctrl UpArrow", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 4, ""); -// else -// uiDefIconTextBut(block, BUTM, B_FULL, ICON_BLANK1, "Tile Window|Ctrl DownArrow", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 4, ""); - - if(curarea->headertype==HEADERTOP) { - uiBlockSetDirection(block, UI_DOWN); - } - else { - uiBlockSetDirection(block, UI_TOP); - uiBlockFlipOrder(block); - } - - uiTextBoundsBlock(block, 50); - uiEndBlock(C, block); - - return block; -} - -static void do_time_framemenu(bContext *C, void *arg, int event) -{ - Scene *scene= CTX_data_scene(C); - - switch(event) { - case 1: /*Set as Start */ - if (scene->r.psfra) { - if (scene->r.pefra < scene->r.cfra) - scene->r.pefra= scene->r.cfra; - scene->r.psfra= scene->r.cfra; - } - else - scene->r.sfra = scene->r.cfra; - WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, scene); - break; - case 2: /* Set as End */ - if (scene->r.psfra) { - if (scene->r.cfra < scene->r.psfra) - scene->r.psfra= scene->r.cfra; - scene->r.pefra= scene->r.cfra; - } - else - scene->r.efra = scene->r.cfra; - WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, scene); - break; - case 3: /* Rename Marker */ - //rename_marker(); - break; - } -} - -static uiBlock *time_framemenu(bContext *C, ARegion *ar, void *arg_unused) -{ - ScrArea *curarea= CTX_wm_area(C); - uiBlock *block; - short yco= 0, menuwidth=120; - - block= uiBeginBlock(C, ar, "time_framemenu", UI_EMBOSSP); - uiBlockSetButmFunc(block, do_time_framemenu, NULL); - - uiDefIconTextButO(block, BUTM, "MARKER_OT_add", WM_OP_EXEC_REGION_WIN, ICON_BLANK1, "Add Marker", - 0, yco-=2, menuwidth, 19, ""); - uiDefIconTextButO(block, BUTM, "MARKER_OT_duplicate", WM_OP_EXEC_REGION_WIN, ICON_BLANK1, "Duplicate Marker", - 0, yco-=20, menuwidth, 19, ""); - uiDefIconTextButO(block, BUTM, "MARKER_OT_delete", WM_OP_EXEC_REGION_WIN, ICON_BLANK1, "Delete Marker", - 0, yco-=20, menuwidth, 19, ""); - - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Name Marker|Ctrl M", - 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 3, ""); - uiDefIconTextButO(block, BUTM, "MARKER_OT_move", WM_OP_INVOKE_REGION_WIN, ICON_BLANK1, "Grab/Move Marker", - 0, yco-=20, menuwidth, 19, ""); - - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Set as Start|S", - 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 1, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Set as End|E", - 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 2, ""); - - if(curarea->headertype==HEADERTOP) { - uiBlockSetDirection(block, UI_DOWN); - } - else { - uiBlockSetDirection(block, UI_TOP); - uiBlockFlipOrder(block); - } - - uiTextBoundsBlock(block, 50); - uiEndBlock(C, block); - - return block; -} - - -#define B_REDRAWALL 750 -#define B_TL_PLAY 752 -#define B_TL_RPLAY 760 -#define B_TL_STOP 756 -#define B_TL_PREVIEWON 757 - -#define B_FLIPINFOMENU 0 -#define B_NEWFRAME 0 -#define B_DIFF 0 - - -void do_time_buttons(bContext *C, void *arg, int event) -{ - Scene *scene= CTX_data_scene(C); - - switch(event) { - case B_REDRAWALL: - WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, scene); - break; - case B_NEWFRAME: - WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene); - break; - case B_TL_PREVIEWON: - if (scene->r.psfra) { - /* turn on preview range */ - scene->r.psfra= scene->r.sfra; - scene->r.pefra= scene->r.efra; - } - else { - /* turn off preview range */ - scene->r.psfra= 0; - scene->r.pefra= 0; - } - //BIF_undo_push("Set anim-preview range"); - WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, scene); - break; - } -} - - -void time_header_buttons(const bContext *C, ARegion *ar) -{ - ScrArea *sa= CTX_wm_area(C); - SpaceTime *stime= CTX_wm_space_time(C); - Scene *scene= CTX_data_scene(C); - wmTimer *animtimer= CTX_wm_screen(C)->animtimer; - uiBlock *block; - uiBut *but; - int xco, yco= 3; - char *menustr= NULL; - - block= uiBeginBlock(C, ar, "header buttons", UI_EMBOSS); - uiBlockSetHandleFunc(block, do_time_buttons, NULL); - - xco= ED_area_header_standardbuttons(C, block, yco); - - if((sa->flag & HEADER_NO_PULLDOWN)==0) { - int xmax; - - xmax= GetButStringLength("View"); - uiDefPulldownBut(block, time_viewmenu, sa, - "View", xco, yco, xmax-3, 20, ""); - xco+= xmax; - xmax= GetButStringLength("Frame"); - uiDefPulldownBut(block, time_framemenu, sa, - "Frame", xco, yco, xmax-3, 20, ""); - xco+= xmax; - - xmax= GetButStringLength("Playback"); - uiDefPulldownBut(block, time_redrawmenu, sa, - "Playback", xco, yco, xmax-3, 20, ""); - xco+= xmax; - } - - uiBlockSetEmboss(block, UI_EMBOSS); - - uiBlockBeginAlign(block); - - uiDefButI(block, TOG, B_TL_PREVIEWON,"PR", - xco,yco, XIC*2, YIC, - &scene->r.psfra,0, 1, 0, 0, - "Show settings for frame range of animation preview"); - - xco += XIC*2; - - if (scene->r.psfra) { - uiDefButI(block, NUM, B_REDRAWALL,"Start:", - xco,yco, (int)4.5*XIC, YIC, - &scene->r.psfra,MINFRAMEF, MAXFRAMEF, 0, 0, - "The start frame of the animation preview (inclusive)"); - - xco += (int)(4.5*XIC); - - uiDefButI(block, NUM, B_REDRAWALL,"End:", - xco,yco, (int)4.5*XIC,YIC, - &scene->r.pefra,(float)PSFRA, MAXFRAMEF, 0, 0, - "The end frame of the animation preview (inclusive)"); - } - else { - uiDefButI(block, NUM, B_REDRAWALL,"Start:", - xco,yco, (int)4.5*XIC, YIC, - &scene->r.sfra,MINFRAMEF, MAXFRAMEF, 0, 0, - "The start frame of the animation (inclusive)"); - - xco += (short)(4.5*XIC); - - uiDefButI(block, NUM, B_REDRAWALL,"End:", - xco,yco, (int)4.5*XIC,YIC, - &scene->r.efra,(float)SFRA, MAXFRAMEF, 0, 0, - "The end frame of the animation (inclusive)"); - } - uiBlockEndAlign(block); - - xco += (short)(4.5 * XIC); - - /* MINAFRAMEF not MINFRAMEF, since MINAFRAMEF allows to set current frame negative - * to facilitate easier keyframing in some situations - */ - uiDefButI(block, NUM, B_NEWFRAME, "", - xco,yco, (int)3.5*XIC,YIC, - &(scene->r.cfra), MINAFRAMEF, MAXFRAMEF, 0, 0, - "Displays Current Frame of animation"); - - xco += (short)(3.5 * XIC); - - uiBlockBeginAlign(block); - - but= uiDefIconButO(block, BUT, "SCREEN_OT_frame_jump", WM_OP_INVOKE_REGION_WIN, ICON_REW, xco,yco,XIC,YIC, "Skip to Start frame (Shift DownArrow)"); - RNA_boolean_set(uiButGetOperatorPtrRNA(but), "end", 0); - xco+= XIC; - - but= uiDefIconButO(block, BUT, "SCREEN_OT_keyframe_jump", WM_OP_INVOKE_REGION_WIN, ICON_PREV_KEYFRAME, xco,yco,XIC,YIC, "Skip to previous keyframe (Ctrl PageDown)"); - RNA_boolean_set(uiButGetOperatorPtrRNA(but), "next", 0); - xco+= XIC; - - if (animtimer) { - /* pause button 2*size to keep buttons in place */ - but=uiDefIconButO(block, BUT, "SCREEN_OT_animation_play", WM_OP_INVOKE_REGION_WIN, ICON_PAUSE, xco,yco,XIC*2,YIC, "Stop Playing Timeline"); - - xco+= XIC; - } - else { - but=uiDefIconButO(block, BUT, "SCREEN_OT_animation_play", WM_OP_INVOKE_REGION_WIN, ICON_PLAY_REVERSE, xco,yco,XIC,YIC, "Play Timeline in Reverse"); - RNA_boolean_set(uiButGetOperatorPtrRNA(but), "reverse", 1); - xco+= XIC; - - but=uiDefIconButO(block, BUT, "SCREEN_OT_animation_play", WM_OP_INVOKE_REGION_WIN, ICON_PLAY, xco,yco,XIC,YIC, "Play Timeline"); - RNA_boolean_set(uiButGetOperatorPtrRNA(but), "reverse", 0); - } - xco+= XIC; - - but= uiDefIconButO(block, BUT, "SCREEN_OT_keyframe_jump", WM_OP_INVOKE_REGION_WIN, ICON_NEXT_KEYFRAME, xco,yco,XIC,YIC, "Skip to next keyframe (Ctrl PageUp)"); - RNA_boolean_set(uiButGetOperatorPtrRNA(but), "next", 1); - xco+= XIC; - - but= uiDefIconButO(block, BUT, "SCREEN_OT_frame_jump", WM_OP_INVOKE_REGION_WIN, ICON_FF, xco,yco,XIC,YIC, "Skip to End frame (Shift UpArrow)"); - RNA_boolean_set(uiButGetOperatorPtrRNA(but), "end", 1); - xco+= XIC; - uiBlockEndAlign(block); - - xco+= 1.5*XIC; - - uiBlockBeginAlign(block); - uiDefIconButBitS(block, TOG, AUTOKEY_ON, B_REDRAWALL, ICON_REC, - xco, yco, XIC, YIC, &(scene->toolsettings->autokey_mode), 0, 0, 0, 0, "Automatic keyframe insertion for Objects and Bones"); - xco+= XIC; - - if (IS_AUTOKEY_ON(scene)) { - uiDefButS(block, MENU, B_REDRAWALL, - "Auto-Keying Mode %t|Add/Replace Keys%x3|Replace Keys %x5", - xco, yco, (int)5.5*XIC, YIC, &(scene->toolsettings->autokey_mode), 0, 1, 0, 0, - "Mode of automatic keyframe insertion for Objects and Bones"); - xco+= (5.5*XIC); - - if (animtimer) { - uiDefButBitS(block, TOG, ANIMRECORD_FLAG_WITHNLA, B_REDRAWALL, "Layered", - xco,yco, XIC*2.5, YIC, - &(scene->toolsettings->autokey_flag),0, 1, 0, 0, - "Add a new NLA Track + Strip for every loop/pass made over the animation to allow non-destructive tweaking."); - xco+= (3*XIC); - } - } - else - xco+= 6; - - uiBlockEndAlign(block); - - menustr= ANIM_build_keyingsets_menu(&scene->keyingsets, 0); - uiDefButI(block, MENU, B_DIFF, - menustr, - xco, yco, (int)5.5*XIC, YIC, &(scene->active_keyingset), 0, 1, 0, 0, - "Active Keying Set (i.e. set of channels to Insert Keyframes for)"); - MEM_freeN(menustr); - xco+= (5.5*XIC); - - uiBlockBeginAlign(block); - uiDefIconButO(block, BUT, "ANIM_OT_delete_keyframe", WM_OP_INVOKE_REGION_WIN, ICON_KEY_DEHLT, xco,yco,XIC,YIC, "Delete Keyframes for the Active Keying Set (Alt-I)"); - xco += XIC; - uiDefIconButO(block, BUT, "ANIM_OT_insert_keyframe", WM_OP_INVOKE_REGION_WIN, ICON_KEY_HLT, xco,yco,XIC,YIC, "Insert Keyframes for the Active Keying Set (I)"); - xco += XIC; - uiBlockEndAlign(block); - - xco+= XIC; - - uiDefIconButBitI(block, TOG, TIME_WITH_SEQ_AUDIO, B_DIFF, ICON_SPEAKER, - xco, yco, XIC, YIC, &(stime->redraws), 0, 0, 0, 0, "Play back and sync with audio from Sequence Editor"); - - - /* always as last */ - UI_view2d_totRect_set(&ar->v2d, xco+XIC+80, (int)(ar->v2d.tot.ymax-ar->v2d.tot.ymin)); - - uiEndBlock(C, block); - uiDrawBlock(C, block); -} - - diff --git a/source/blender/editors/space_userpref/Makefile b/source/blender/editors/space_userpref/Makefile new file mode 100644 index 00000000000..be7206f51ce --- /dev/null +++ b/source/blender/editors/space_userpref/Makefile @@ -0,0 +1,55 @@ +# +# $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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# The Original Code is Copyright (C) 2007 Blender Foundation +# All rights reserved. +# +# The Original Code is: all of this file. +# +# Contributor(s): none yet. +# +# ***** END GPL LICENSE BLOCK ***** +# +# Makes module object directory and bounces make to subdirectories. + +LIBNAME = ed_userpref +DIR = $(OCGDIR)/blender/$(LIBNAME) + +include nan_compile.mk + +CFLAGS += $(LEVEL_1_C_WARNINGS) + +CPPFLAGS += -I$(NAN_GLEW)/include +CPPFLAGS += -I$(OPENGL_HEADERS) + +# not very neat.... +CPPFLAGS += -I../../windowmanager +CPPFLAGS += -I../../blenloader +CPPFLAGS += -I../../blenkernel +CPPFLAGS += -I../../blenlib +CPPFLAGS += -I../../makesdna +CPPFLAGS += -I../../makesrna +CPPFLAGS += -I../../imbuf +CPPFLAGS += -I../../python +CPPFLAGS += -I../../blenfont +CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include + +# own include + +CPPFLAGS += -I../include diff --git a/source/blender/editors/space_userpref/SConscript b/source/blender/editors/space_userpref/SConscript new file mode 100644 index 00000000000..1b808a5a7c0 --- /dev/null +++ b/source/blender/editors/space_userpref/SConscript @@ -0,0 +1,14 @@ +#!/usr/bin/python +Import ('env') + +sources = env.Glob('*.c') + +incs = '../include ../../blenlib ../../blenkernel ../../makesdna ../../makesrna ../../imbuf ../../blenfont' +incs += ' ../../windowmanager #/intern/guardedalloc #/extern/glew/include' + +defs = [] + +if env['WITH_BF_GAMEENGINE']: + defs.append('GAMEBLENDER=1') + +env.BlenderLib ( 'bf_editors_space_userpref', sources, Split(incs), defs, libtype=['core'], priority=[70] ) diff --git a/source/blender/editors/space_userpref/space_userpref.c b/source/blender/editors/space_userpref/space_userpref.c new file mode 100644 index 00000000000..8c9d723ce2c --- /dev/null +++ b/source/blender/editors/space_userpref/space_userpref.c @@ -0,0 +1,188 @@ +/** + * $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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2008 Blender Foundation. + * All rights reserved. + * + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include <string.h> +#include <stdio.h> + +#include "DNA_space_types.h" +#include "DNA_screen_types.h" + +#include "MEM_guardedalloc.h" + +#include "BLI_blenlib.h" + +#include "BKE_context.h" +#include "BKE_screen.h" + +#include "ED_space_api.h" +#include "ED_screen.h" + +#include "BIF_gl.h" + +#include "WM_api.h" +#include "WM_types.h" + +#include "userpref_intern.h" // own include + +/* ******************** default callbacks for userpref space ***************** */ + +static SpaceLink *userpref_new(const bContext *C) +{ + ARegion *ar; + SpaceUserPref *spref; + + spref= MEM_callocN(sizeof(SpaceUserPref), "inituserpref"); + spref->spacetype= SPACE_USERPREF; + + /* header */ + ar= MEM_callocN(sizeof(ARegion), "header for userpref"); + + BLI_addtail(&spref->regionbase, ar); + ar->regiontype= RGN_TYPE_HEADER; + ar->alignment= RGN_ALIGN_BOTTOM; + + /* main area */ + ar= MEM_callocN(sizeof(ARegion), "main area for userpref"); + + BLI_addtail(&spref->regionbase, ar); + ar->regiontype= RGN_TYPE_WINDOW; + + return (SpaceLink *)spref; +} + +/* not spacelink itself */ +static void userpref_free(SpaceLink *sl) +{ +// SpaceUserPref *spref= (SpaceUserPref*) sl; + +} + + +/* spacetype; init callback */ +static void userpref_init(struct wmWindowManager *wm, ScrArea *sa) +{ + +} + +static SpaceLink *userpref_duplicate(SpaceLink *sl) +{ + SpaceUserPref *sprefn= MEM_dupallocN(sl); + + /* clear or remove stuff from old */ + + return (SpaceLink *)sprefn; +} + + + +/* add handlers, stuff you only do once or on area/region changes */ +static void userpref_main_area_init(wmWindowManager *wm, ARegion *ar) +{ + ED_region_panels_init(wm, ar); +} + +static void userpref_main_area_draw(const bContext *C, ARegion *ar) +{ + ED_region_panels(C, ar, 1, NULL, -1); +} + +void userpref_operatortypes(void) +{ +} + +void userpref_keymap(struct wmWindowManager *wm) +{ + +} + +/* add handlers, stuff you only do once or on area/region changes */ +static void userpref_header_area_init(wmWindowManager *wm, ARegion *ar) +{ + ED_region_header_init(ar); +} + +static void userpref_header_area_draw(const bContext *C, ARegion *ar) +{ + ED_region_header(C, ar); +} + +static void userpref_main_area_listener(ARegion *ar, wmNotifier *wmn) +{ + /* context changes */ +} + +static void userpref_header_listener(ARegion *ar, wmNotifier *wmn) +{ + /* context changes */ + switch(wmn->category) { + default: + break; + } + +} + +/* only called once, from space/spacetypes.c */ +void ED_spacetype_userpref(void) +{ + SpaceType *st= MEM_callocN(sizeof(SpaceType), "spacetype userpref"); + ARegionType *art; + + st->spaceid= SPACE_USERPREF; + + st->new= userpref_new; + st->free= userpref_free; + st->init= userpref_init; + st->duplicate= userpref_duplicate; + st->operatortypes= userpref_operatortypes; + st->keymap= userpref_keymap; + + /* regions: main window */ + art= MEM_callocN(sizeof(ARegionType), "spacetype userpref region"); + art->regionid = RGN_TYPE_WINDOW; + art->init= userpref_main_area_init; + art->draw= userpref_main_area_draw; + art->listener= userpref_main_area_listener; + art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D; + + BLI_addhead(&st->regiontypes, art); + + /* regions: header */ + art= MEM_callocN(sizeof(ARegionType), "spacetype userpref region"); + art->regionid = RGN_TYPE_HEADER; + art->minsizey= HEADERY; + art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D; + art->listener= userpref_header_listener; + art->init= userpref_header_area_init; + art->draw= userpref_header_area_draw; + + BLI_addhead(&st->regiontypes, art); + + + BKE_spacetype_register(st); +} + diff --git a/source/blender/editors/space_userpref/userpref_intern.h b/source/blender/editors/space_userpref/userpref_intern.h new file mode 100644 index 00000000000..596c2675b01 --- /dev/null +++ b/source/blender/editors/space_userpref/userpref_intern.h @@ -0,0 +1,34 @@ +/** + * $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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2008 Blender Foundation. + * All rights reserved. + * + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ +#ifndef ED_USERPREF_INTERN_H +#define ED_USERPREF_INTERN_H + +/* internal exports only */ + +#endif /* ED_USERPREF_INTERN_H */ + diff --git a/source/blender/editors/space_userpref/userpref_ops.c b/source/blender/editors/space_userpref/userpref_ops.c new file mode 100644 index 00000000000..91a6651bd92 --- /dev/null +++ b/source/blender/editors/space_userpref/userpref_ops.c @@ -0,0 +1,33 @@ +/** + * $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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2008 Blender Foundation. + * All rights reserved. + * + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include <string.h> +#include <stdio.h> + +#include "userpref_intern.h" + diff --git a/source/blender/editors/space_view3d/drawarmature.c b/source/blender/editors/space_view3d/drawarmature.c index 5a9790390b7..a5718386554 100644 --- a/source/blender/editors/space_view3d/drawarmature.c +++ b/source/blender/editors/space_view3d/drawarmature.c @@ -2271,7 +2271,7 @@ static void draw_ghost_poses_range(Scene *scene, View3D *v3d, RegionView3D *rv3d range= (float)(end - start); /* store values */ - ob->flag &= ~OB_POSEMODE; + ob->mode &= ~OB_MODE_POSE; cfrao= CFRA; flago= arm->flag; arm->flag &= ~(ARM_DRAWNAMES|ARM_DRAWAXES); @@ -2308,7 +2308,7 @@ static void draw_ghost_poses_range(Scene *scene, View3D *v3d, RegionView3D *rv3d ob->pose= poseo; arm->flag= flago; armature_rebuild_pose(ob, ob->data); - ob->flag |= OB_POSEMODE; + ob->mode |= OB_MODE_POSE; ob->ipoflag= ipoflago; } @@ -2349,7 +2349,7 @@ static void draw_ghost_poses_keys(Scene *scene, View3D *v3d, RegionView3D *rv3d, if (range == 0) return; /* store values */ - ob->flag &= ~OB_POSEMODE; + ob->mode &= ~OB_MODE_POSE; cfrao= CFRA; flago= arm->flag; arm->flag &= ~(ARM_DRAWNAMES|ARM_DRAWAXES); @@ -2388,7 +2388,7 @@ static void draw_ghost_poses_keys(Scene *scene, View3D *v3d, RegionView3D *rv3d, ob->pose= poseo; arm->flag= flago; armature_rebuild_pose(ob, ob->data); - ob->flag |= OB_POSEMODE; + ob->mode |= OB_MODE_POSE; } /* draw ghosts around current frame @@ -2415,7 +2415,7 @@ static void draw_ghost_poses(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base range= (float)(arm->ghostep)*stepsize + 0.5f; /* plus half to make the for loop end correct */ /* store values */ - ob->flag &= ~OB_POSEMODE; + ob->mode &= ~OB_MODE_POSE; cfrao= CFRA; actframe= BKE_nla_tweakedit_remap(adt, (float)CFRA, 0); flago= arm->flag; @@ -2474,7 +2474,7 @@ static void draw_ghost_poses(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base ob->pose= poseo; arm->flag= flago; armature_rebuild_pose(ob, ob->data); - ob->flag |= OB_POSEMODE; + ob->mode |= OB_MODE_POSE; } /* ********************************** Armature Drawing - Main ************************* */ @@ -2513,10 +2513,10 @@ int draw_armature(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, int /* drawing posemode selection indices or colors only in these cases */ if(!(base->flag & OB_FROMDUPLI)) { if(G.f & G_PICKSEL) { - if(ob->flag & OB_POSEMODE) + if(ob->mode & OB_MODE_POSE) arm->flag |= ARM_POSEMODE; } - else if(ob->flag & OB_POSEMODE) { + else if(ob->mode & OB_MODE_POSE) { if (arm->ghosttype == ARM_GHOST_RANGE) { draw_ghost_poses_range(scene, v3d, rv3d, base); } @@ -2530,7 +2530,7 @@ int draw_armature(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, int if ((flag & DRAW_SCENESET)==0) { if(ob==OBACT) arm->flag |= ARM_POSEMODE; - else if(G.f & G_WEIGHTPAINT) { + else if(ob->mode & OB_MODE_WEIGHT_PAINT) { if(OBACT && ob==modifiers_isDeformedByArmature(OBACT)) arm->flag |= ARM_POSEMODE; } @@ -2541,7 +2541,7 @@ int draw_armature(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, int draw_pose_channels(scene, v3d, rv3d, base, dt); arm->flag &= ~ARM_POSEMODE; - if(ob->flag & OB_POSEMODE) + if(ob->mode & OB_MODE_POSE) UI_ThemeColor(TH_WIRE); /* restore, for extra draw stuff */ } else retval= 1; diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c index 846d45388d3..2e47e2d4483 100644 --- a/source/blender/editors/space_view3d/drawmesh.c +++ b/source/blender/editors/space_view3d/drawmesh.c @@ -60,6 +60,7 @@ #include "BKE_material.h" #include "BKE_mesh.h" #include "BKE_object.h" +#include "BKE_paint.h" #include "BKE_property.h" #include "BKE_utildefines.h" #include "BKE_tessmesh.h" @@ -298,9 +299,9 @@ static int set_draw_settings_cached(int clearcache, int textured, MTFace *texfac if (textured!=c_textured || texface!=c_texface) { if (textured ) { - c_badtex= !GPU_set_tpage(texface); + c_badtex= !GPU_set_tpage(texface, !(litob->mode & OB_MODE_TEXTURE_PAINT)); } else { - GPU_set_tpage(0); + GPU_set_tpage(NULL, 0); c_badtex= 0; } c_textured= textured; @@ -378,7 +379,7 @@ static void draw_textured_begin(Scene *scene, View3D *v3d, RegionView3D *rv3d, O static void draw_textured_end() { /* switch off textures */ - GPU_set_tpage(0); + GPU_set_tpage(NULL, 0); glShadeModel(GL_FLAT); glDisable(GL_CULL_FACE); @@ -506,7 +507,7 @@ void draw_mesh_text(Scene *scene, Object *ob, int glsl) if(ob == scene->obedit) return; else if(ob==OBACT) - if(FACESEL_PAINT_TEST) + if(paint_facesel_test(ob)) return; ddm = mesh_get_derived_deform(scene, ob, CD_MASK_BAREMESH); @@ -586,7 +587,7 @@ void draw_mesh_textured(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *o if(ob == scene->obedit) { dm->drawMappedFacesTex(dm, draw_em_tf_mapped__set_draw, me->edit_btmesh); } else if(faceselect) { - if(G.f & G_WEIGHTPAINT) + if(ob->mode & OB_MODE_WEIGHT_PAINT) dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions, me, 1); else dm->drawMappedFacesTex(dm, draw_tface_mapped__set_draw, me); diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 486ffb3d178..79c4cdc87fb 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -87,9 +87,11 @@ #include "BKE_mball.h" #include "BKE_modifier.h" #include "BKE_object.h" +#include "BKE_paint.h" #include "BKE_particle.h" #include "BKE_property.h" #include "BKE_smoke.h" +#include "BKE_unit.h" #include "BKE_utildefines.h" #include "BKE_tessmesh.h" @@ -213,11 +215,10 @@ int draw_glsl_material(Scene *scene, Object *ob, View3D *v3d, int dt) return 0; if(!CHECK_OB_DRAWTEXTURE(v3d, dt)) return 0; - if(ob==OBACT && (G.f & G_WEIGHTPAINT)) + if(ob==OBACT && (ob && ob->mode & OB_MODE_WEIGHT_PAINT)) return 0; - return ((G.fileflags & G_FILE_GAME_MAT) && - (G.fileflags & G_FILE_GAME_MAT_GLSL) && (dt >= OB_SHADED)); + return (scene->gm.matmode == GAME_MAT_GLSL) && (dt >= OB_SHADED); } static int check_material_alpha(Base *base, Mesh *me, int glsl) @@ -1893,7 +1894,7 @@ static void draw_em_fancy_edges(BMEditMesh *em, Scene *scene, View3D *v3d, } static void draw_em_measure_stats(View3D *v3d, RegionView3D *rv3d, - Object *ob, BMEditMesh *em) + Object *ob, BMEditMesh *em, UnitSettings *unit) { #if 0 Mesh *me= ob->data; @@ -1904,18 +1905,20 @@ static void draw_em_measure_stats(View3D *v3d, RegionView3D *rv3d, char val[32]; /* Stores the measurement display text here */ char conv_float[5]; /* Use a float conversion matching the grid size */ float area, col[3]; /* area of the face, color of the text to draw */ - + float grid= unit->system ? unit->scale_length : v3d->grid; + int do_split= unit->flag & USER_UNIT_OPT_SPLIT; if(G.f & (G_RENDER_OGL|G_RENDER_SHADOW)) return; /* make the precission of the pronted value proportionate to the gridsize */ - if ((v3d->grid) < 0.01) + + if (grid < 0.01f) strcpy(conv_float, "%.6f"); - else if ((v3d->grid) < 0.1) + else if (grid < 0.1f) strcpy(conv_float, "%.5f"); - else if ((v3d->grid) < 1.0) + else if (grid < 1.0f) strcpy(conv_float, "%.4f"); - else if ((v3d->grid) < 10.0) + else if (grid < 10.0f) strcpy(conv_float, "%.3f"); else strcpy(conv_float, "%.2f"); @@ -1924,13 +1927,13 @@ static void draw_em_measure_stats(View3D *v3d, RegionView3D *rv3d, if(v3d->zbuf && (v3d->flag & V3D_ZBUF_SELECT)==0) glDisable(GL_DEPTH_TEST); - if(v3d->zbuf) bglPolygonOffset(rv3d->dist, 5.0); + if(v3d->zbuf) bglPolygonOffset(rv3d->dist, 5.0f); if(me->drawflag & ME_DRAW_EDGELEN) { UI_GetThemeColor3fv(TH_TEXT, col); /* make color a bit more red */ - if(col[0]> 0.5) {col[1]*=0.7; col[2]*= 0.7;} - else col[0]= col[0]*0.7 + 0.3; + if(col[0]> 0.5f) {col[1]*=0.7f; col[2]*= 0.7f;} + else col[0]= col[0]*0.7f + 0.3f; glColor3fv(col); for(eed= em->edges.first; eed; eed= eed->next) { @@ -1939,16 +1942,19 @@ static void draw_em_measure_stats(View3D *v3d, RegionView3D *rv3d, VECCOPY(v1, eed->v1->co); VECCOPY(v2, eed->v2->co); - x= 0.5*(v1[0]+v2[0]); - y= 0.5*(v1[1]+v2[1]); - z= 0.5*(v1[2]+v2[2]); + x= 0.5f*(v1[0]+v2[0]); + y= 0.5f*(v1[1]+v2[1]); + z= 0.5f*(v1[2]+v2[2]); if(v3d->flag & V3D_GLOBAL_STATS) { Mat4MulVecfl(ob->obmat, v1); Mat4MulVecfl(ob->obmat, v2); } + if(unit->system) + bUnit_AsString(val, sizeof(val), VecLenf(v1, v2)*unit->scale_length, 3, unit->system, B_UNIT_LENGTH, do_split, FALSE); + else + sprintf(val, conv_float, VecLenf(v1, v2)); - sprintf(val, conv_float, VecLenf(v1, v2)); view3d_object_text_draw_add(x, y, z, val, 0); } } @@ -1959,8 +1965,8 @@ static void draw_em_measure_stats(View3D *v3d, RegionView3D *rv3d, UI_GetThemeColor3fv(TH_TEXT, col); /* make color a bit more green */ - if(col[1]> 0.5) {col[0]*=0.7; col[2]*= 0.7;} - else col[1]= col[1]*0.7 + 0.3; + if(col[1]> 0.5f) {col[0]*=0.7f; col[2]*= 0.7f;} + else col[1]= col[1]*0.7f + 0.3f; glColor3fv(col); for(efa= em->faces.first; efa; efa= efa->next) { @@ -1983,7 +1989,11 @@ static void draw_em_measure_stats(View3D *v3d, RegionView3D *rv3d, else area = AreaT3Dfl(v1, v2, v3); - sprintf(val, conv_float, area); + if(unit->system) + bUnit_AsString(val, sizeof(val), area*unit->scale_length, 3, unit->system, B_UNIT_LENGTH, do_split, FALSE); // XXX should be B_UNIT_AREA + else + sprintf(val, conv_float, area); + view3d_object_text_draw_add(efa->cent[0], efa->cent[1], efa->cent[2], val, 0); } } @@ -1994,8 +2004,8 @@ static void draw_em_measure_stats(View3D *v3d, RegionView3D *rv3d, UI_GetThemeColor3fv(TH_TEXT, col); /* make color a bit more blue */ - if(col[2]> 0.5) {col[0]*=0.7; col[1]*= 0.7;} - else col[2]= col[2]*0.7 + 0.3; + if(col[2]> 0.5f) {col[0]*=0.7f; col[1]*= 0.7f;} + else col[2]= col[2]*0.7f + 0.3f; glColor3fv(col); for(efa= em->faces.first; efa; efa= efa->next) { @@ -2025,13 +2035,13 @@ static void draw_em_measure_stats(View3D *v3d, RegionView3D *rv3d, if( (e4->f & e1->f & SELECT) || (G.moving && (efa->v1->f & SELECT)) ) { /* Vec 1 */ sprintf(val,"%.3f", VecAngle3(v4, v1, v2)); - VecLerpf(fvec, efa->cent, efa->v1->co, 0.8); + VecLerpf(fvec, efa->cent, efa->v1->co, 0.8f); view3d_object_text_draw_add(efa->cent[0], efa->cent[1], efa->cent[2], val, 0); } if( (e1->f & e2->f & SELECT) || (G.moving && (efa->v2->f & SELECT)) ) { /* Vec 2 */ sprintf(val,"%.3f", VecAngle3(v1, v2, v3)); - VecLerpf(fvec, efa->cent, efa->v2->co, 0.8); + VecLerpf(fvec, efa->cent, efa->v2->co, 0.8f); view3d_object_text_draw_add(fvec[0], fvec[1], fvec[2], val, 0); } if( (e2->f & e3->f & SELECT) || (G.moving && (efa->v3->f & SELECT)) ) { @@ -2040,14 +2050,14 @@ static void draw_em_measure_stats(View3D *v3d, RegionView3D *rv3d, sprintf(val,"%.3f", VecAngle3(v2, v3, v4)); else sprintf(val,"%.3f", VecAngle3(v2, v3, v1)); - VecLerpf(fvec, efa->cent, efa->v3->co, 0.8); + VecLerpf(fvec, efa->cent, efa->v3->co, 0.8f); view3d_object_text_draw_add(fvec[0], fvec[1], fvec[2], val, 0); } /* Vec 4 */ if(efa->v4) { if( (e3->f & e4->f & SELECT) || (G.moving && (efa->v4->f & SELECT)) ) { sprintf(val,"%.3f", VecAngle3(v3, v4, v1)); - VecLerpf(fvec, efa->cent, efa->v4->co, 0.8); + VecLerpf(fvec, efa->cent, efa->v4->co, 0.8f); view3d_object_text_draw_add(fvec[0], fvec[1], fvec[2], val, 0); } } @@ -2056,7 +2066,7 @@ static void draw_em_measure_stats(View3D *v3d, RegionView3D *rv3d, if(v3d->zbuf) { glEnable(GL_DEPTH_TEST); - bglPolygonOffset(rv3d->dist, 0.0); + bglPolygonOffset(rv3d->dist, 0.0f); } #endif } @@ -2144,7 +2154,7 @@ static void draw_em_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object } } - if((me->drawflag & (ME_DRAWFACES)) || FACESEL_PAINT_TEST) { /* transp faces */ + if((me->drawflag & (ME_DRAWFACES)) || paint_facesel_test(ob)) { /* transp faces */ unsigned char col1[4], col2[4], col3[4]; UI_GetThemeColor4ubv(TH_FACE, (char *)col1); @@ -2232,7 +2242,7 @@ static void draw_em_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object } if(me->drawflag & (ME_DRAW_EDGELEN|ME_DRAW_FACEAREA|ME_DRAW_EDGEANG)) - draw_em_measure_stats(v3d, rv3d, ob, em); + draw_em_measure_stats(v3d, rv3d, ob, em, &scene->unit); } if(dt>OB_WIRE) { @@ -2303,7 +2313,7 @@ static void draw_mesh_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base glFrontFace((ob->transflag&OB_NEG_SCALE)?GL_CW:GL_CCW); // Unwanted combination. - if (ob==OBACT && FACESEL_PAINT_TEST) draw_wire = 0; + if (ob==OBACT && paint_facesel_test(ob)) draw_wire = 0; if(dt==OB_BOUNDBOX) { draw_bounding_volume(scene, ob); @@ -2316,12 +2326,12 @@ static void draw_mesh_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base else if(dt==OB_WIRE || totface==0) { draw_wire = 1; /* draw wire only, no depth buffer stuff */ } - else if( (ob==OBACT && (G.f & G_TEXTUREPAINT || FACESEL_PAINT_TEST)) || + else if( (ob==OBACT && (ob->mode & OB_MODE_TEXTURE_PAINT || paint_facesel_test(ob))) || CHECK_OB_DRAWTEXTURE(v3d, dt)) { - int faceselect= (ob==OBACT && FACESEL_PAINT_TEST); + int faceselect= (ob==OBACT && paint_facesel_test(ob)); - if ((v3d->flag&V3D_SELECT_OUTLINE) && (base->flag&SELECT) && !(G.f&G_PICKSEL || FACESEL_PAINT_TEST) && !draw_wire) { + if ((v3d->flag&V3D_SELECT_OUTLINE) && (base->flag&SELECT) && !(G.f&G_PICKSEL || paint_facesel_test(ob)) && !draw_wire) { draw_mesh_object_outline(v3d, ob, dm); } @@ -2375,7 +2385,7 @@ static void draw_mesh_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base if(ob==OBACT) { do_draw= 0; - if( (G.f & G_WEIGHTPAINT)) { + if(ob && ob->mode & OB_MODE_WEIGHT_PAINT) { /* enforce default material settings */ GPU_enable_material(0, NULL); @@ -2395,12 +2405,13 @@ static void draw_mesh_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base GPU_disable_material(); } - else if((G.f & (G_VERTEXPAINT+G_TEXTUREPAINT)) && me->mcol) { - dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions, NULL, 1); - } - else if(G.f & (G_VERTEXPAINT+G_TEXTUREPAINT)) { - glColor3f(1.0f, 1.0f, 1.0f); - dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions, NULL, 0); + else if(ob->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_TEXTURE_PAINT)) { + if(me->mcol) + dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions, NULL, 1); + else { + glColor3f(1.0f, 1.0f, 1.0f); + dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions, NULL, 0); + } } else do_draw= 1; } @@ -3560,7 +3571,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv } if((part->draw&PART_DRAW_NUM || part->draw&PART_DRAW_HEALTH) && !(G.f & G_RENDER_SHADOW)){ - strcpy(val, ""); + val[0]= '\0'; if(part->draw&PART_DRAW_NUM) sprintf(val, " %i", a); @@ -4824,7 +4835,7 @@ static void drawSolidSelect(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base drawDispListwire(&ob->disp); } else if(ob->type==OB_ARMATURE) { - if(!(ob->flag & OB_POSEMODE)) + if(!(ob->mode & OB_MODE_POSE)) draw_armature(scene, v3d, rv3d, base, OB_WIRE, 0); } @@ -4973,7 +4984,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) /* xray delay? */ if((flag & DRAW_PICKING)==0 && (base->flag & OB_FROMDUPLI)==0) { /* don't do xray in particle mode, need the z-buffer */ - if(!(G.f & G_PARTICLEEDIT)) { + if(!(ob->mode & OB_MODE_PARTICLE_EDIT)) { /* xray and transp are set when it is drawing the 2nd/3rd pass */ if(!v3d->xray && !v3d->transp && (ob->dtx & OB_DRAWXRAY) && !(ob->dtx & OB_DRAWTRANSP)) { add_view3d_after(v3d, base, V3D_XRAY, flag); @@ -5060,6 +5071,9 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) /* patch? children objects with a timeoffs change the parents. How to solve! */ /* if( ((int)ob->ctime) != F_(scene->r.cfra)) where_is_object(scene, ob); */ + + /* draw paths... */ + // TODO... /* multiply view with object matrix */ wmMultMatrix(ob->obmat); @@ -5119,7 +5133,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) dtx= 0; /* faceselect exception: also draw solid when dt==wire, except in editmode */ - if(ob==OBACT && (G.f & (G_VERTEXPAINT+G_TEXTUREPAINT+G_WEIGHTPAINT))) { + if(ob==OBACT && (ob->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT|OB_MODE_TEXTURE_PAINT))) { if(ob->type==OB_MESH) { if(ob==scene->obedit); @@ -5332,7 +5346,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) for(psys=ob->particlesystem.first; psys; psys=psys->next) draw_new_particle_system(scene, v3d, rv3d, base, psys, dt); - if(G.f & G_PARTICLEEDIT && ob==OBACT) { + if(ob->mode & OB_MODE_PARTICLE_EDIT && ob==OBACT) { psys= PE_get_current(scene, ob); if(psys && !scene->obedit && psys_in_edit_mode(scene, psys)) draw_particle_edit(scene, v3d, rv3d, ob, psys, dt); @@ -5346,352 +5360,15 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) } /* draw code for smoke */ - if(md = modifiers_findByType(ob, eModifierType_Smoke)) { - SmokeModifierData *smd = (SmokeModifierData *)md; - - // draw collision objects - if((smd->type & MOD_SMOKE_TYPE_COLL) && smd->coll) - { - SmokeCollSettings *scs = smd->coll; - /* - if(scs->points) - { - size_t i; - - wmLoadMatrix(rv3d->viewmat); - - if(col || (ob->flag & SELECT)) cpack(0xFFFFFF); - glDepthMask(GL_FALSE); - glEnable(GL_BLEND); - - - // glPointSize(3.0); - bglBegin(GL_POINTS); - - for(i = 0; i < scs->numpoints; i++) - { - bglVertex3fv(&scs->points[3*i]); - } - - bglEnd(); - glPointSize(1.0); - - wmMultMatrix(ob->obmat); - glDisable(GL_BLEND); - glDepthMask(GL_TRUE); - if(col) cpack(col); - - } - */ - } - - // only draw domains - if(smd->domain && smd->domain->fluid) - { - int x, y, z, i; - float viewnormal[3]; - int mainaxis[3] = {0,0,0}; - float align = 0, signed_align = 0; - int max_textures = 0, counter_textures = 0; - float *buffer = NULL; - int res[3]; - float bigfactor = 1.0; - int big = smd->domain->flags & MOD_SMOKE_HIGHRES; - int new = 0; - - // GUI sent redraw event - if(smd->domain->flags & MOD_SMOKE_VIEW_REDRAWNICE) - { - new = 1; - smd->domain->flags &= ~MOD_SMOKE_VIEW_REDRAWNICE; - } - - if(!big) - { - res[0] = smd->domain->res[0]; - res[1] = smd->domain->res[1]; - res[2] = smd->domain->res[2]; - } - else - { - smoke_get_bigres(smd->domain->fluid, res); - bigfactor = 1.0 / smd->domain->amplify; - } - - wmLoadMatrix(rv3d->viewmat); - - if(col || (ob->flag & SELECT)) cpack(0xFFFFFF); /* for visibility, also while wpaint */ - glDepthMask(GL_FALSE); - glEnable(GL_BLEND); - - // get view vector - VECCOPY(viewnormal, rv3d->viewinv[2]); - Normalize(viewnormal); - for(i = 0; i < 3; i++) - { - if(ABS(viewnormal[i]) > align) - { - mainaxis[0] = i; - align = ABS(viewnormal[i]); - signed_align = viewnormal[i]; - } - } - mainaxis[1] = (mainaxis[0] + 1) % 3; - mainaxis[2] = (mainaxis[0] + 2) % 3; - - if(!smd->domain->bind) - { - smd->domain->bind = MEM_callocN(sizeof(GLuint)*256, "Smoke_bind"); - if(big) - smd->domain->viewsettings |= MOD_SMOKE_VIEW_CHANGETOBIG; - new = 3; - } - - // check if view axis / mode has been changed - if(smd->domain->viewsettings) - { - if(big) - { - if(!(smd->domain->viewsettings & MOD_SMOKE_VIEW_BIG)) - new = 2; - else if(!(smd->domain->viewsettings & MOD_SMOKE_VIEW_CHANGETOBIG)) - new = 1; - - smd->domain->viewsettings |= MOD_SMOKE_VIEW_CHANGETOBIG; - } - else - { - if(!(smd->domain->viewsettings & MOD_SMOKE_VIEW_SMALL)) - new = 2; - else if(smd->domain->viewsettings & MOD_SMOKE_VIEW_CHANGETOBIG) - new = 1; - - smd->domain->viewsettings &= ~MOD_SMOKE_VIEW_CHANGETOBIG; - } - - if(!new) - { - if((mainaxis[0] == 0) && !(smd->domain->viewsettings & MOD_SMOKE_VIEW_X)) - new = 1; - else if((mainaxis[0] == 1) && !(smd->domain->viewsettings & MOD_SMOKE_VIEW_Y)) - new = 1; - else if((mainaxis[0] == 2) && !(smd->domain->viewsettings & MOD_SMOKE_VIEW_Z)) - new = 1; - - // printf("check axis\n"); - } - } - else - new = 3; - - if(new > 1) - { - float light[3] = {0.0,0.0,2.0}; // TODO: take real LAMP coordinates - dg - Base *base_tmp = NULL; - - for(base_tmp = scene->base.first; base_tmp; base_tmp= base_tmp->next) - { - if(base_tmp->object->type == OB_LAMP) - { - Lamp *la = (Lamp *)base_tmp->object->data; - - if(la->type == LA_LOCAL) - { - VECCOPY(light, base_tmp->object->obmat[3]); - break; - } - } - } - - if(!big && !(smd->domain->viewsettings & MOD_SMOKE_VIEW_SMALL)) - { - smoke_prepare_View(smd, light); - // printf("prepared View!\n"); - } - else if(big && !(smd->domain->viewsettings & MOD_SMOKE_VIEW_BIG)) - { - smoke_prepare_bigView(smd, light); - // printf("prepared bigView!\n"); - } + md = modifiers_findByType(ob, eModifierType_Smoke); + if (md) { + SmokeModifierData *smd = (SmokeModifierData *)md; + if(smd->type & MOD_SMOKE_TYPE_DOMAIN && smd->domain && smd->domain->fluid) { + GPU_create_smoke(smd); + draw_volume(scene, ar, v3d, base, smd->domain->tex, smd->domain->res); + GPU_free_smoke(smd); } - - // printf("big: %d, new: %d\n", big, new); - - // only create buffer if we need to create new textures - if(new) - buffer = MEM_mallocN(sizeof(float)*res[mainaxis[1]]*res[mainaxis[2]]*4, "SmokeDrawBuffer"); - - if(buffer || smd->domain->viewsettings) - { - int mod_texture = 0; - - // printf("if(buffer || smd->domain->viewsettings)\n"); - - max_textures = (res[mainaxis[0]] > 256) ? 256 : res[mainaxis[0]]; - - if(!smd->domain->viewsettings) // new frame or new start - { - smd->domain->max_textures = max_textures; - glGenTextures(smd->domain->max_textures, (GLuint *)smd->domain->bind); - new = 1; - // printf("glGenTextures\n"); - } - else - { - if(new) - { - // printf("glDeleteTextures\n"); - glDeleteTextures(smd->domain->max_textures, (GLuint *)smd->domain->bind); - smd->domain->max_textures = max_textures; - glGenTextures(smd->domain->max_textures, (GLuint *)smd->domain->bind); - } - } - - mod_texture = MAX3(1, smd->domain->visibility, (int)(res[mainaxis[0]] / smd->domain->max_textures )); - - // align order of billboards to be front or backview (e.g. +x or -x axis) - if(signed_align < 0) - { - z = res[mainaxis[0]] - 1; - } - else - { - z = 0; - } - - for (; signed_align > 0 ? (z < res[mainaxis[0]]) : (z >= 0); signed_align > 0 ? z++ : z--) // 2 - { - float quad[4][3]; - - if(new) - { - for (y = 0; y < res[mainaxis[1]]; y++) // 1 - { - for (x = 0; x < res[mainaxis[2]]; x++) // 0 - { - size_t index; - size_t image_index; - float tray, tvox; - - image_index = smoke_get_index2d(y, res[mainaxis[1]], x); - - if(mainaxis[0] == 0) - { - // mainaxis[1] == 1, mainaxis[2] == 2 - index = smoke_get_index(z, res[mainaxis[0]], y, res[mainaxis[1]], x); - } - else if(mainaxis[0] == 1) - { - // mainaxis[1] == 2, mainaxis[2] == 0 - index = smoke_get_index(x, res[mainaxis[2]], z, res[mainaxis[0]], y); - } - else // mainaxis[0] == 2 - { - // mainaxis[1] == 0, mainaxis[2] == 1 - index = smoke_get_index(y, res[mainaxis[1]], x, res[mainaxis[2]], z); - } - - if(!big) - { - tvox = smoke_get_tvox(smd, index); - tray = smoke_get_tray(smd, index); - } - else - { - tvox = smoke_get_bigtvox(smd, index); - tray = smoke_get_bigtray(smd, index); - } - - // fill buffer with luminance and alpha - // 1 - T_vox - buffer[image_index*4 + 3] = 1.0 - tvox; // 0 = transparent => d.h. tvox = 1 - - // L_vox = Omega * L_light * (1 - T_vox) * T_ray - buffer[image_index*4] = buffer[image_index*4 + 1] = buffer[image_index*4 + 2] = smd->domain->omega * 1.0 * tvox * tray; - } - } - } - glBindTexture(GL_TEXTURE_2D, smd->domain->bind[counter_textures]); - glEnable(GL_TEXTURE_2D); - - if(new) - { - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, res[mainaxis[1]], res[mainaxis[2]], 0, GL_RGBA, GL_FLOAT, buffer); - glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); // Linear Filtering - glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); // Linear Filtering - } - - if((z % mod_texture) == 0 ) - { - // botttom left - quad[3][mainaxis[0]] = smd->domain->p0[mainaxis[0]] + z * smd->domain->dx * bigfactor + smd->domain->dx * bigfactor * 0.5; - quad[3][mainaxis[1]] = smd->domain->p0[mainaxis[1]] + smd->domain->dx * bigfactor * 0.5; - quad[3][mainaxis[2]] = smd->domain->p0[mainaxis[2]] + smd->domain->dx * bigfactor * 0.5; - - // top right - quad[1][mainaxis[0]] = smd->domain->p0[mainaxis[0]] + z * smd->domain->dx * bigfactor + smd->domain->dx * bigfactor * 0.5; - quad[1][mainaxis[1]] = smd->domain->p0[mainaxis[1]] + (res[mainaxis[1]] - 1) * smd->domain->dx * bigfactor + smd->domain->dx * bigfactor * 0.5; - quad[1][mainaxis[2]] = smd->domain->p0[mainaxis[2]] + (res[mainaxis[2]] - 1) * smd->domain->dx * bigfactor + smd->domain->dx * bigfactor * 0.5; - - // top left - quad[2][mainaxis[0]] = smd->domain->p0[mainaxis[0]] + z * smd->domain->dx * bigfactor + smd->domain->dx * bigfactor * 0.5; - quad[2][mainaxis[1]] = smd->domain->p0[mainaxis[1]] + smd->domain->dx * bigfactor * 0.5; - quad[2][mainaxis[2]] = smd->domain->p0[mainaxis[2]] + (res[mainaxis[2]] - 1) * smd->domain->dx * bigfactor + smd->domain->dx * bigfactor * 0.5; - - // bottom right - quad[0][mainaxis[0]] = smd->domain->p0[mainaxis[0]] + z * smd->domain->dx * bigfactor + smd->domain->dx * bigfactor * 0.5; - quad[0][mainaxis[1]] = smd->domain->p0[mainaxis[1]] + (res[mainaxis[1]] - 1) * smd->domain->dx * bigfactor + smd->domain->dx * bigfactor * 0.5; - quad[0][mainaxis[2]] = smd->domain->p0[mainaxis[2]] + smd->domain->dx * bigfactor * 0.5; - - glBegin(GL_QUADS); // Start Drawing Quads - - glTexCoord2f(1.0f, 0.0f); - glVertex3fv(quad[0]); // Left And Up 1 Unit (Top Left) - glTexCoord2f(1.0f, 1.0f); - glVertex3fv(quad[1]); // Right And Up 1 Unit (Top Right) - glTexCoord2f(0.0f, 1.0f); - glVertex3fv(quad[2]); // Right And Down One Unit (Bottom Right) - glTexCoord2f(0.0f, 0.0f); - glVertex3fv(quad[3]); // Left And Down One Unit (Bottom Left) - - glEnd(); - } - counter_textures++; - } - } - if(buffer) - { - MEM_freeN(buffer); - buffer = NULL; - } - - // set correct flag for viewsettings - if(1) - { - // do not clear BIG/SMALL flag - smd->domain->viewsettings &= ~MOD_SMOKE_VIEW_X; - smd->domain->viewsettings &= ~MOD_SMOKE_VIEW_Y; - smd->domain->viewsettings &= ~MOD_SMOKE_VIEW_Z; - - // set what caches we have - if(big) - smd->domain->viewsettings |= MOD_SMOKE_VIEW_BIG; - else - smd->domain->viewsettings |= MOD_SMOKE_VIEW_SMALL; - - if(mainaxis[0] == 0) - smd->domain->viewsettings |= MOD_SMOKE_VIEW_X; - else if(mainaxis[0] == 1) - smd->domain->viewsettings |= MOD_SMOKE_VIEW_Y; - else if(mainaxis[0] == 2) - smd->domain->viewsettings |= MOD_SMOKE_VIEW_Z; - } - - wmMultMatrix(ob->obmat); - glDisable(GL_BLEND); - glDepthMask(GL_TRUE); - if(col) cpack(col); } } @@ -5753,7 +5430,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) if(G.f & G_RENDER_SHADOW) return; /* object centers, need to be drawn in viewmat space for speed, but OK for picking select */ - if(ob!=OBACT || (G.f & (G_VERTEXPAINT|G_TEXTUREPAINT|G_WEIGHTPAINT))==0) { + if(ob!=OBACT || !(ob->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT|OB_MODE_TEXTURE_PAINT))) { int do_draw_center= -1; /* defines below are zero or positive... */ if((scene->basact)==base) diff --git a/source/blender/editors/space_view3d/drawvolume.c b/source/blender/editors/space_view3d/drawvolume.c new file mode 100644 index 00000000000..f4242c70139 --- /dev/null +++ b/source/blender/editors/space_view3d/drawvolume.c @@ -0,0 +1,304 @@ +/** + * $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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * Contributor(s): Daniel Genrich + * + * ***** END GPL LICENSE BLOCK ***** + */ + + +#include <string.h> +#include <math.h> + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include "MEM_guardedalloc.h" + +#include "IMB_imbuf.h" + + +#include "MTC_matrixops.h" + +#include "DNA_armature_types.h" +#include "DNA_boid_types.h" +#include "DNA_camera_types.h" +#include "DNA_curve_types.h" +#include "DNA_constraint_types.h" // for drawing constraint +#include "DNA_effect_types.h" +#include "DNA_lamp_types.h" +#include "DNA_lattice_types.h" +#include "DNA_material_types.h" +#include "DNA_mesh_types.h" +#include "DNA_meshdata_types.h" +#include "DNA_meta_types.h" +#include "DNA_modifier_types.h" +#include "DNA_object_types.h" +#include "DNA_object_force.h" +#include "DNA_object_fluidsim.h" +#include "DNA_particle_types.h" +#include "DNA_space_types.h" +#include "DNA_scene_types.h" +#include "DNA_screen_types.h" +#include "DNA_smoke_types.h" +#include "DNA_userdef_types.h" +#include "DNA_view3d_types.h" +#include "DNA_world_types.h" + +#include "BLI_blenlib.h" +#include "BLI_arithb.h" +#include "BLI_editVert.h" +#include "BLI_edgehash.h" +#include "BLI_rand.h" + +#include "BKE_anim.h" //for the where_on_path function +#include "BKE_curve.h" +#include "BKE_constraint.h" // for the get_constraint_target function +#include "BKE_DerivedMesh.h" +#include "BKE_deform.h" +#include "BKE_displist.h" +#include "BKE_effect.h" +#include "BKE_font.h" +#include "BKE_global.h" +#include "BKE_image.h" +#include "BKE_key.h" +#include "BKE_lattice.h" +#include "BKE_mesh.h" +#include "BKE_material.h" +#include "BKE_mball.h" +#include "BKE_modifier.h" +#include "BKE_object.h" +#include "BKE_paint.h" +#include "BKE_particle.h" +#include "BKE_property.h" +#include "BKE_smoke.h" +#include "BKE_unit.h" +#include "BKE_utildefines.h" +#include "smoke_API.h" + +#include "BIF_gl.h" +#include "BIF_glutil.h" + +#include "GPU_draw.h" +#include "GPU_material.h" +#include "GPU_extensions.h" + +#include "ED_mesh.h" +#include "ED_particle.h" +#include "ED_screen.h" +#include "ED_types.h" +#include "ED_util.h" + +#include "UI_resources.h" +#include "UI_interface_icons.h" + +#include "WM_api.h" +#include "BLF_api.h" + +#include "GPU_extensions.h" + +#include "view3d_intern.h" // own include + +struct GPUTexture; + +/* draw slices of smoke is adapted from c++ code authored by: Johannes Schmid and Ingemar Rask, 2006, johnny@grob.org */ +static float cv[][3] = { + {1.0f, 1.0f, 1.0f}, {-1.0f, 1.0f, 1.0f}, {-1.0f, -1.0f, 1.0f}, {1.0f, -1.0f, 1.0f}, + {1.0f, 1.0f, -1.0f}, {-1.0f, 1.0f, -1.0f}, {-1.0f, -1.0f, -1.0f}, {1.0f, -1.0f, -1.0f} +}; + +// edges have the form edges[n][0][xyz] + t*edges[n][1][xyz] +static float edges[12][2][3] = { + {{1.0f, 1.0f, -1.0f}, {0.0f, 0.0f, 1.0f}}, + {{-1.0f, 1.0f, -1.0f}, {0.0f, 0.0f, 1.0f}}, + {{-1.0f, -1.0f, -1.0f}, {0.0f, 0.0f, 1.0f}}, + {{1.0f, -1.0f, -1.0f}, {0.0f, 0.0f, 1.0f}}, + + {{1.0f, -1.0f, 1.0f}, {0.0f, 1.0f, 0.0f}}, + {{-1.0f, -1.0f, 1.0f}, {0.0f, 1.0f, 0.0f}}, + {{-1.0f, -1.0f, -1.0f}, {0.0f, 1.0f, 0.0f}}, + {{1.0f, -1.0f, -1.0f}, {0.0f, 1.0f, 0.0f}}, + + {{-1.0f, 1.0f, 1.0f}, {1.0f, 0.0f, 0.0f}}, + {{-1.0f, -1.0f, 1.0f}, {1.0f, 0.0f, 0.0f}}, + {{-1.0f, -1.0f, -1.0f}, {1.0f, 0.0f, 0.0f}}, + {{-1.0f, 1.0f, -1.0f}, {1.0f, 0.0f, 0.0f}} +}; + +int intersect_edges(float *points, float a, float b, float c, float d) +{ + int i; + float t; + int numpoints = 0; + + for (i=0; i<12; i++) { + t = -(a*edges[i][0][0] + b*edges[i][0][1] + c*edges[i][0][2] + d) + / (a*edges[i][1][0] + b*edges[i][1][1] + c*edges[i][1][2]); + if ((t>0)&&(t<2)) { + points[numpoints * 3 + 0] = edges[i][0][0] + edges[i][1][0]*t; + points[numpoints * 3 + 1] = edges[i][0][1] + edges[i][1][1]*t; + points[numpoints * 3 + 2] = edges[i][0][2] + edges[i][1][2]*t; + numpoints++; + } + } + return numpoints; +} + +static int convex(float *p0, float *up, float *a, float *b) +{ + // Vec3 va = a-p0, vb = b-p0; + float va[3], vb[3], tmp[3]; + VECSUB(va, a, p0); + VECSUB(vb, b, p0); + Crossf(tmp, va, vb); + return INPR(up, tmp) >= 0; +} + +// copied from gpu_extension.c +static int is_pow2(int n) +{ + return ((n)&(n-1))==0; +} + +static int larger_pow2(int n) +{ + if (is_pow2(n)) + return n; + + while(!is_pow2(n)) + n= n&(n-1); + + return n*2; +} + +void draw_volume(Scene *scene, ARegion *ar, View3D *v3d, Base *base, GPUTexture *tex, int res[3]) +{ + Object *ob = base->object; + RegionView3D *rv3d= ar->regiondata; + + float viewnormal[3]; + int i, j, n; + float d, d0, dd; + float *points = NULL; + int numpoints = 0; + float cor[3] = {1.,1.,1.}; + int gl_depth = 0, gl_blend = 0; + + glGetBooleanv(GL_BLEND, (GLboolean *)&gl_blend); + glGetBooleanv(GL_DEPTH_TEST, (GLboolean *)&gl_depth); + + wmLoadMatrix(rv3d->viewmat); + wmMultMatrix(ob->obmat); + + glDepthMask(GL_FALSE); + glDisable(GL_DEPTH_TEST); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + // get view vector + VECCOPY(viewnormal, rv3d->viewinv[2]); + Normalize(viewnormal); + + // find cube vertex that is closest to the viewer + for (i=0; i<8; i++) { + float x,y,z; + + x = cv[i][0] + viewnormal[0]; + y = cv[i][1] + viewnormal[1]; + z = cv[i][2] + viewnormal[2]; + + if ((x>=-1.0f)&&(x<=1.0f) + &&(y>=-1.0f)&&(y<=1.0f) + &&(z>=-1.0f)&&(z<=1.0f)) { + break; + } + } + + GPU_texture_bind(tex, 0); + + if (!GLEW_ARB_texture_non_power_of_two) { + cor[0] = (float)res[0]/(float)larger_pow2(res[0]); + cor[1] = (float)res[1]/(float)larger_pow2(res[1]); + cor[2] = (float)res[2]/(float)larger_pow2(res[2]); + } + + // our slices are defined by the plane equation a*x + b*y +c*z + d = 0 + // (a,b,c), the plane normal, are given by viewdir + // d is the parameter along the view direction. the first d is given by + // inserting previously found vertex into the plane equation + d0 = -(viewnormal[0]*cv[i][0] + viewnormal[1]*cv[i][1] + viewnormal[2]*cv[i][2]); + dd = 2.0*d0/64.0f; + n = 0; + + // printf("d0: %f, dd: %f\n", d0, dd); + + points = MEM_callocN(sizeof(float)*12*3, "smoke_points_preview"); + + for (d = d0; d > -d0; d -= dd) { + float p0[3]; + // intersect_edges returns the intersection points of all cube edges with + // the given plane that lie within the cube + numpoints = intersect_edges(points, viewnormal[0], viewnormal[1], viewnormal[2], d); + + if (numpoints > 2) { + VECCOPY(p0, points); + + // sort points to get a convex polygon + for(i = 1; i < numpoints - 1; i++) + { + for(j = i + 1; j < numpoints; j++) + { + if(convex(p0, viewnormal, &points[j * 3], &points[i * 3])) + { + float tmp2[3]; + VECCOPY(tmp2, &points[i * 3]); + VECCOPY(&points[i * 3], &points[j * 3]); + VECCOPY(&points[j * 3], tmp2); + } + } + } + + glBegin(GL_POLYGON); + for (i = 0; i < numpoints; i++) { + glColor3f(1.0, 1.0, 1.0); + glTexCoord3d((points[i * 3 + 0] + 1.0)*cor[0]/2.0, (points[i * 3 + 1] + 1)*cor[1]/2.0, (points[i * 3 + 2] + 1.0)*cor[2]/2.0); + glVertex3f(points[i * 3 + 0], points[i * 3 + 1], points[i * 3 + 2]); + } + glEnd(); + } + n++; + } + + GPU_texture_unbind(tex); + + MEM_freeN(points); + + if(!gl_blend) + glDisable(GL_BLEND); + if(gl_depth) + { + glEnable(GL_DEPTH_TEST); + glDepthMask(GL_TRUE); + } +} + diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index e1f0b537241..3dd65a6f796 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -280,7 +280,7 @@ static void view3d_modal_keymaps(wmWindowManager *wm, ARegion *ar, int stype) /* copy last mode, then we can re-init the region maps */ rv3d->lastmode= stype; - + keymap= WM_keymap_listbase(wm, "Object Mode", 0, 0); if(ELEM(stype, 0, NS_MODE_OBJECT)) WM_event_add_keymap_handler(&ar->handlers, keymap); @@ -304,6 +304,12 @@ static void view3d_modal_keymaps(wmWindowManager *wm, ARegion *ar, int stype) WM_event_add_keymap_handler(&ar->handlers, keymap); else WM_event_remove_keymap_handler(&ar->handlers, keymap); + + keymap= WM_keymap_listbase(wm, "Pose", 0, 0); + if(stype==NS_MODE_POSE) + WM_event_add_keymap_handler(&ar->handlers, keymap); + else + WM_event_remove_keymap_handler(&ar->handlers, keymap); keymap= WM_keymap_listbase(wm, "Metaball", 0, 0); if(stype==NS_EDITMODE_MBALL) @@ -319,7 +325,7 @@ static void view3d_modal_keymaps(wmWindowManager *wm, ARegion *ar, int stype) /* armature sketching needs to take over mouse */ keymap= WM_keymap_listbase(wm, "Armature_Sketch", 0, 0); - if(stype==NS_EDITMODE_TEXT) + if(stype==NS_EDITMODE_ARMATURE) WM_event_add_keymap_handler_priority(&ar->handlers, keymap, 10); else WM_event_remove_keymap_handler(&ar->handlers, keymap); @@ -595,7 +601,7 @@ static void view3d_tools_area_init(wmWindowManager *wm, ARegion *ar) static void view3d_tools_area_draw(const bContext *C, ARegion *ar) { - ED_region_panels(C, ar, 1, view3d_context_string(C), -1); + ED_region_panels(C, ar, 1, CTX_data_mode_string(C), -1); } static int view3d_context(const bContext *C, const char *member, bContextDataResult *result) @@ -889,7 +895,7 @@ void ED_spacetype_view3d(void) /* regions: tool(bar) */ art= MEM_callocN(sizeof(ARegionType), "spacetype view3d region"); art->regionid = RGN_TYPE_TOOLS; - art->minsizex= 120; // XXX + art->minsizex= 160; // XXX art->minsizey= 50; // XXX art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_FRAMES; art->listener= view3d_buttons_area_listener; diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c index f64954af6c3..efe23101e6c 100644 --- a/source/blender/editors/space_view3d/view3d_buttons.c +++ b/source/blender/editors/space_view3d/view3d_buttons.c @@ -1000,6 +1000,7 @@ static void view3d_panel_transform_spaces(const bContext *C, Panel *pa) } #endif // XXX not used +#if 0 static void brush_idpoin_handle(bContext *C, ID *id, int event) { Brush **br = current_brush_source(CTX_data_scene(C)); @@ -1030,6 +1031,7 @@ static void brush_idpoin_handle(bContext *C, ID *id, int event) break; } } +#endif static void view3d_panel_object(const bContext *C, Panel *pa) { @@ -1041,7 +1043,6 @@ static void view3d_panel_object(const bContext *C, Panel *pa) Object *ob= OBACT; TransformProperties *tfp; float lim; - static char hexcol[128]; if(ob==NULL) return; @@ -1055,13 +1056,13 @@ static void view3d_panel_object(const bContext *C, Panel *pa) // XXX uiSetButLock(object_is_libdata(ob), ERROR_LIBDATA_MESSAGE); - if(G.f & (G_VERTEXPAINT|G_TEXTUREPAINT|G_WEIGHTPAINT)) { + if(ob->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT|OB_MODE_TEXTURE_PAINT)) { } else { //bt= uiDefBut(block, TEX, B_IDNAME, "OB: ", 10,180,140,20, ob->id.name+2, 0.0, 21.0, 0, 0, ""); //uiButSetFunc(bt, test_idbutton_cb, ob->id.name, NULL); - if((G.f & G_PARTICLEEDIT)==0) { + if((ob->mode & OB_MODE_PARTICLE_EDIT)==0) { // uiBlockBeginAlign(block); // uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_OBJECTPANELPARENT, "Par:", 160, 180, 140, 20, &ob->parent, "Parent Object"); if((ob->parent) && (ob->partype == PARBONE)) { @@ -1082,7 +1083,7 @@ static void view3d_panel_object(const bContext *C, Panel *pa) if(ob->type==OB_MBALL) v3d_editmetaball_buts(block, ob, lim); else v3d_editvertex_buts(C, block, v3d, ob, lim); } - else if(ob->flag & OB_POSEMODE) { + else if(ob->mode & OB_MODE_POSE) { v3d_posearmature_buts(block, v3d, ob, lim); } else { diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 5e6bfe89165..905657910b8 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -59,9 +59,11 @@ #include "BKE_key.h" #include "BKE_object.h" #include "BKE_global.h" +#include "BKE_paint.h" #include "BKE_scene.h" #include "BKE_screen.h" #include "BKE_utildefines.h" +#include "BKE_unit.h" #include "RE_pipeline.h" // make_stars @@ -234,15 +236,18 @@ static void drawgrid_draw(ARegion *ar, float wx, float wy, float x, float y, flo } -static void drawgrid(ARegion *ar, View3D *v3d) +#define GRID_MIN_PX 6.0f + +static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, char **grid_unit) { /* extern short bgpicmode; */ RegionView3D *rv3d= ar->regiondata; float wx, wy, x, y, fw, fx, fy, dx; float vec4[4]; char col[3], col2[3]; - short sublines = v3d->gridsubdiv; + *grid_unit= NULL; + vec4[0]=vec4[1]=vec4[2]=0.0; vec4[3]= 1.0; Mat4MulVec4fl(rv3d->persmat, vec4); @@ -256,7 +261,8 @@ static void drawgrid(ARegion *ar, View3D *v3d) x= (wx)*fx/fw; y= (wy)*fy/fw; - vec4[0]=vec4[1]=v3d->grid; + vec4[0]=vec4[1]= (unit->system) ? 1.0 : v3d->grid; + vec4[2]= 0.0; vec4[3]= 1.0; Mat4MulVec4fl(rv3d->persmat, vec4); @@ -272,72 +278,115 @@ static void drawgrid(ARegion *ar, View3D *v3d) /* check zoom out */ UI_ThemeColor(TH_GRID); - if(dx<6.0) { - v3d->gridview*= sublines; - dx*= sublines; - - if(dx<6.0) { + if(unit->system) { + /* Use GRID_MIN_PX*2 for units because very very small grid + * items are less useful when dealing with units */ + void *usys; + int len, i; + double scalar; + float dx_scalar; + float blend_fac; + + bUnit_GetSystem(&usys, &len, unit->system, B_UNIT_LENGTH); + + if(usys) { + i= len; + while(i--) { + scalar= bUnit_GetScaler(usys, i); + + dx_scalar = dx * scalar * unit->scale_length; + if (dx_scalar < (GRID_MIN_PX*2)) + continue; + + /* Store the smallest drawn grid size units name so users know how big each grid cell is */ + if(*grid_unit==NULL) { + *grid_unit= bUnit_GetNameDisplay(usys, i); + v3d->gridview= (scalar * unit->scale_length); + } + blend_fac= 1-((GRID_MIN_PX*2)/dx_scalar); + + /* tweak to have the fade a bit nicer */ + blend_fac= (blend_fac * blend_fac) * 2.0f; + CLAMP(blend_fac, 0.3f, 1.0f); + + + UI_ThemeColorBlend(TH_BACK, TH_GRID, blend_fac); + + drawgrid_draw(ar, wx, wy, x, y, dx_scalar); + } + } + } + else { + short sublines = v3d->gridsubdiv; + + if(dx<GRID_MIN_PX) { v3d->gridview*= sublines; dx*= sublines; - if(dx<6.0) { + if(dx<GRID_MIN_PX) { v3d->gridview*= sublines; - dx*=sublines; - if(dx<6.0); - else { - UI_ThemeColor(TH_GRID); + dx*= sublines; + + if(dx<GRID_MIN_PX) { + v3d->gridview*= sublines; + dx*=sublines; + if(dx<GRID_MIN_PX); + else { + UI_ThemeColor(TH_GRID); + drawgrid_draw(ar, wx, wy, x, y, dx); + } + } + else { // start blending out + UI_ThemeColorBlend(TH_BACK, TH_GRID, dx/(GRID_MIN_PX*10)); drawgrid_draw(ar, wx, wy, x, y, dx); + + UI_ThemeColor(TH_GRID); + drawgrid_draw(ar, wx, wy, x, y, sublines*dx); } } - else { // start blending out - UI_ThemeColorBlend(TH_BACK, TH_GRID, dx/60.0); + else { // start blending out (GRID_MIN_PX < dx < (GRID_MIN_PX*10)) + UI_ThemeColorBlend(TH_BACK, TH_GRID, dx/(GRID_MIN_PX*10)); drawgrid_draw(ar, wx, wy, x, y, dx); - + UI_ThemeColor(TH_GRID); drawgrid_draw(ar, wx, wy, x, y, sublines*dx); } } - else { // start blending out (6 < dx < 60) - UI_ThemeColorBlend(TH_BACK, TH_GRID, dx/60.0); - drawgrid_draw(ar, wx, wy, x, y, dx); - - UI_ThemeColor(TH_GRID); - drawgrid_draw(ar, wx, wy, x, y, sublines*dx); - } - } - else { - if(dx>60.0) { // start blending in - v3d->gridview/= sublines; - dx/= sublines; - if(dx>60.0) { // start blending in + else { + if(dx>(GRID_MIN_PX*10)) { // start blending in v3d->gridview/= sublines; dx/= sublines; - if(dx>60.0) { - UI_ThemeColor(TH_GRID); - drawgrid_draw(ar, wx, wy, x, y, dx); + if(dx>(GRID_MIN_PX*10)) { // start blending in + v3d->gridview/= sublines; + dx/= sublines; + if(dx>(GRID_MIN_PX*10)) { + UI_ThemeColor(TH_GRID); + drawgrid_draw(ar, wx, wy, x, y, dx); + } + else { + UI_ThemeColorBlend(TH_BACK, TH_GRID, dx/(GRID_MIN_PX*10)); + drawgrid_draw(ar, wx, wy, x, y, dx); + UI_ThemeColor(TH_GRID); + drawgrid_draw(ar, wx, wy, x, y, dx*sublines); + } } else { - UI_ThemeColorBlend(TH_BACK, TH_GRID, dx/60.0); + UI_ThemeColorBlend(TH_BACK, TH_GRID, dx/(GRID_MIN_PX*10)); drawgrid_draw(ar, wx, wy, x, y, dx); UI_ThemeColor(TH_GRID); drawgrid_draw(ar, wx, wy, x, y, dx*sublines); } } else { - UI_ThemeColorBlend(TH_BACK, TH_GRID, dx/60.0); + UI_ThemeColorBlend(TH_BACK, TH_GRID, dx/(GRID_MIN_PX*10)); drawgrid_draw(ar, wx, wy, x, y, dx); - UI_ThemeColor(TH_GRID); + UI_ThemeColor(TH_GRID); drawgrid_draw(ar, wx, wy, x, y, dx*sublines); } } - else { - UI_ThemeColorBlend(TH_BACK, TH_GRID, dx/60.0); - drawgrid_draw(ar, wx, wy, x, y, dx); - UI_ThemeColor(TH_GRID); - drawgrid_draw(ar, wx, wy, x, y, dx*sublines); - } } + x+= (wx); y+= (wy); UI_GetThemeColor3ubv(TH_GRID, col); @@ -361,7 +410,7 @@ static void drawgrid(ARegion *ar, View3D *v3d) glDepthMask(1); // enable write in zbuffer } - +#undef GRID_MIN_PX static void drawfloor(Scene *scene, View3D *v3d) { @@ -749,7 +798,7 @@ static void draw_selected_name(Scene *scene, Object *ob, View3D *v3d) } } } - else if(ob->pose && (ob->flag & OB_POSEMODE)) { + else if(ob->pose && (ob->mode & OB_MODE_POSE)) { bPoseChannel *pchan; for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { if((pchan->bone->flag & BONE_ACTIVE) && (pchan->bone->layer & arm->layer)) { @@ -1042,7 +1091,8 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d) void backdrawview3d(Scene *scene, ARegion *ar, View3D *v3d) { RegionView3D *rv3d= ar->regiondata; - struct Base *base; + struct Base *base = scene->basact; + rcti winrct; /*for 2.43 release, don't use glext and just define the constant. this to avoid possibly breaking platforms before release.*/ @@ -1054,9 +1104,11 @@ void backdrawview3d(Scene *scene, ARegion *ar, View3D *v3d) int m; #endif - if(G.f & G_VERTEXPAINT || G.f & G_WEIGHTPAINT || (FACESEL_PAINT_TEST)); - else if((G.f & G_TEXTUREPAINT) && scene->toolsettings && (scene->toolsettings->imapaint.flag & IMAGEPAINT_PROJECT_DISABLE)); - else if((G.f & G_PARTICLEEDIT) && v3d->drawtype>OB_WIRE && (v3d->flag & V3D_ZBUF_SELECT)); + if(base && (base->object->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT) || + paint_facesel_test(base->object))); + else if((base && (base->object->mode & OB_MODE_TEXTURE_PAINT)) && + scene->toolsettings && (scene->toolsettings->imapaint.flag & IMAGEPAINT_PROJECT_DISABLE)); + else if((base && (base->object->mode & OB_MODE_PARTICLE_EDIT)) && v3d->drawtype>OB_WIRE && (v3d->flag & V3D_ZBUF_SELECT)); else if(scene->obedit && v3d->drawtype>OB_WIRE && (v3d->flag & V3D_ZBUF_SELECT)); else { v3d->flag &= ~V3D_NEEDBACKBUFDRAW; @@ -1086,6 +1138,9 @@ void backdrawview3d(Scene *scene, ARegion *ar, View3D *v3d) glDisable(GL_DITHER); + region_scissor_winrct(ar, &winrct); + glScissor(winrct.xmin, winrct.ymin, winrct.xmax - winrct.xmin, winrct.ymax - winrct.ymin); + glClearColor(0.0, 0.0, 0.0, 0.0); if(v3d->zbuf) { glEnable(GL_DEPTH_TEST); @@ -1101,7 +1156,6 @@ void backdrawview3d(Scene *scene, ARegion *ar, View3D *v3d) G.f |= G_BACKBUFSEL; - base= (scene->basact); if(base && (base->lay & v3d->lay)) { draw_object_backbufsel(scene, v3d, rv3d, base->object); } @@ -1805,13 +1859,13 @@ static void gpu_update_lamps_shadows(Scene *scene, View3D *v3d) /* *********************** customdata **************** */ /* goes over all modes and view3d settings */ -static CustomDataMask get_viewedit_datamask(bScreen *screen) +static CustomDataMask get_viewedit_datamask(bScreen *screen, Scene *scene, Object *ob) { CustomDataMask mask = CD_MASK_BAREMESH; ScrArea *sa; /* check if we need tfaces & mcols due to face select or texture paint */ - if(FACESEL_PAINT_TEST || G.f & G_TEXTUREPAINT) + if(paint_facesel_test(ob) || (ob && ob->mode & OB_MODE_TEXTURE_PAINT)) mask |= CD_MASK_MTFACE | CD_MASK_MCOL; /* check if we need tfaces & mcols due to view mode */ @@ -1825,23 +1879,22 @@ static CustomDataMask get_viewedit_datamask(bScreen *screen) if((view->drawtype == OB_TEXTURE) || ((view->drawtype == OB_SOLID) && (view->flag2 & V3D_SOLID_TEX))) { mask |= CD_MASK_MTFACE | CD_MASK_MCOL; - if((G.fileflags & G_FILE_GAME_MAT) && - (G.fileflags & G_FILE_GAME_MAT_GLSL)) { + if(scene->gm.matmode == GAME_MAT_GLSL) mask |= CD_MASK_ORCO; - } } } } /* check if we need mcols due to vertex paint or weightpaint */ - if(G.f & G_VERTEXPAINT) - mask |= CD_MASK_MCOL; - if(G.f & G_WEIGHTPAINT) - mask |= CD_MASK_WEIGHT_MCOL; - - if(G.f & G_SCULPTMODE) - mask |= CD_MASK_MDISPS; - + if(ob) { + if(ob->mode & OB_MODE_VERTEX_PAINT) + mask |= CD_MASK_MCOL; + if(ob->mode & OB_MODE_WEIGHT_PAINT) + mask |= CD_MASK_WEIGHT_MCOL; + if(ob->mode & OB_MODE_SCULPT) + mask |= CD_MASK_MDISPS; + } + return mask; } @@ -1855,9 +1908,10 @@ void view3d_main_area_draw(const bContext *C, ARegion *ar) Object *ob; int retopo= 0, sculptparticle= 0; Object *obact = OBACT; + char *grid_unit= NULL; /* from now on all object derived meshes check this */ - v3d->customdata_mask= get_viewedit_datamask(CTX_wm_screen(C)); + v3d->customdata_mask= get_viewedit_datamask(CTX_wm_screen(C), scene, obact); /* shadow buffers, before we setup matrices */ if(draw_glsl_material(scene, NULL, v3d, v3d->drawtype)) @@ -1929,7 +1983,7 @@ void view3d_main_area_draw(const bContext *C, ARegion *ar) } else { ED_region_pixelspace(ar); - drawgrid(ar, v3d); + drawgrid(&scene->unit, ar, v3d, &grid_unit); /* XXX make function? replaces persp(1) */ glMatrixMode(GL_PROJECTION); wmLoadMatrix(rv3d->winmat); @@ -1983,7 +2037,7 @@ void view3d_main_area_draw(const bContext *C, ARegion *ar) } // retopo= retopo_mesh_check() || retopo_curve_check(); - sculptparticle= (G.f & (G_SCULPTMODE|G_PARTICLEEDIT)) && !scene->obedit; + sculptparticle= (obact && obact->mode & (OB_MODE_SCULPT|OB_MODE_PARTICLE_EDIT)) && !scene->obedit; if(retopo) view3d_update_depths(ar, v3d); @@ -1996,7 +2050,7 @@ void view3d_main_area_draw(const bContext *C, ARegion *ar) } if(!retopo && sculptparticle && !(obact && (obact->dtx & OB_DRAWXRAY))) { - if(G.f & G_SCULPTMODE) + if(obact && obact->mode & OB_MODE_SCULPT) draw_sculpt_depths(scene, ar, v3d); view3d_update_depths(ar, v3d); } @@ -2012,7 +2066,7 @@ void view3d_main_area_draw(const bContext *C, ARegion *ar) view3d_draw_xray(scene, ar, v3d, 1); // clears zbuffer if it is used! if(!retopo && sculptparticle && (obact && (OBACT->dtx & OB_DRAWXRAY))) { - if(G.f & G_SCULPTMODE) + if(obact && obact->mode & OB_MODE_SCULPT) draw_sculpt_depths(scene, ar, v3d); view3d_update_depths(ar, v3d); } @@ -2060,19 +2114,23 @@ void view3d_main_area_draw(const bContext *C, ARegion *ar) if(U.uiflag & USER_SHOW_VIEWPORTNAME) { draw_viewport_name(ar, v3d); } - + if (grid_unit) { /* draw below the viewport name */ + UI_ThemeColor(TH_TEXT_HI); + BLF_draw_default(10, ar->winy-(USER_SHOW_VIEWPORTNAME?40:20), 0.0f, grid_unit); + } + ob= OBACT; if(U.uiflag & USER_DRAWVIEWINFO) draw_selected_name(scene, ob, v3d); /* XXX here was the blockhandlers for floating panels */ - if(G.f & G_VERTEXPAINT || G.f & G_WEIGHTPAINT || G.f & G_TEXTUREPAINT) { + if(ob && ob->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT|OB_MODE_TEXTURE_PAINT)) { v3d->flag |= V3D_NEEDBACKBUFDRAW; // XXX addafterqueue(ar->win, BACKBUFDRAW, 1); } - if((G.f & G_PARTICLEEDIT) && v3d->drawtype>OB_WIRE && (v3d->flag & V3D_ZBUF_SELECT)) { + if((ob && ob->mode & OB_MODE_PARTICLE_EDIT) && v3d->drawtype>OB_WIRE && (v3d->flag & V3D_ZBUF_SELECT)) { v3d->flag |= V3D_NEEDBACKBUFDRAW; // XXX addafterqueue(ar->win, BACKBUFDRAW, 1); } diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index acb3a2257dc..a7ea19e49f9 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -54,6 +54,7 @@ #include "BKE_depsgraph.h" #include "BKE_object.h" #include "BKE_global.h" +#include "BKE_paint.h" #include "BKE_report.h" #include "BKE_scene.h" #include "BKE_screen.h" @@ -856,6 +857,7 @@ static int viewhome_exec(bContext *C, wmOperator *op) /* was view3d_home() in 2. RegionView3D *rv3d= CTX_wm_region_view3d(C); Scene *scene= CTX_data_scene(C); Base *base; + float *curs; int center= RNA_boolean_get(op->ptr, "center"); @@ -865,6 +867,10 @@ static int viewhome_exec(bContext *C, wmOperator *op) /* was view3d_home() in 2. if(center) { min[0]= min[1]= min[2]= 0.0f; max[0]= max[1]= max[2]= 0.0f; + + /* in 2.4x this also move the cursor to (0, 0, 0) (with shift+c). */ + curs= give_cursor(scene, v3d); + curs[0]= curs[1]= curs[2]= 0.0; } else { INIT_MINMAX(min, max); @@ -904,6 +910,9 @@ static int viewhome_exec(bContext *C, wmOperator *op) /* was view3d_home() in 2. rv3d->persp= V3D_PERSP; smooth_view(C, NULL, v3d->camera, new_ofs, NULL, &new_dist, NULL); } + else { + smooth_view(C, NULL, NULL, new_ofs, NULL, &new_dist, NULL); + } } // XXX BIF_view3d_previewrender_signal(curarea, PR_DBASE|PR_DISPRECT); @@ -947,14 +956,14 @@ static int viewcenter_exec(bContext *C, wmOperator *op) /* like a localview with INIT_MINMAX(min, max); - if (G.f & G_WEIGHTPAINT) { + if (ob && ob->mode & OB_MODE_WEIGHT_PAINT) { /* hardcoded exception, we look for the one selected armature */ /* this is weak code this way, we should make a generic active/selection callback interface once... */ Base *base; for(base=scene->base.first; base; base= base->next) { if(TESTBASELIB(v3d, base)) { if(base->object->type==OB_ARMATURE) - if(base->object->flag & OB_POSEMODE) + if(base->object->mode & OB_MODE_POSE) break; } } @@ -966,7 +975,7 @@ static int viewcenter_exec(bContext *C, wmOperator *op) /* like a localview with if(obedit) { ok = minmax_verts(obedit, min, max); /* only selected */ } - else if(ob && (ob->flag & OB_POSEMODE)) { + else if(ob && (ob->mode & OB_MODE_POSE)) { if(ob->pose) { bArmature *arm= ob->data; bPoseChannel *pchan; @@ -987,10 +996,10 @@ static int viewcenter_exec(bContext *C, wmOperator *op) /* like a localview with } } } - else if (FACESEL_PAINT_TEST) { + else if (paint_facesel_test(ob)) { // XXX ok= minmax_tface(min, max); } - else if (G.f & G_PARTICLEEDIT) { + else if (ob && (ob->mode & OB_MODE_PARTICLE_EDIT)) { ok= PE_minmax(scene, min, max); } else { @@ -2196,7 +2205,7 @@ void viewmoveNDOF(Scene *scene, ARegion *ar, View3D *v3d, int mode) rv3d->view = 0; //printf("passing here \n"); // - if (scene->obedit==NULL && ob && !(ob->flag & OB_POSEMODE)) { + if (scene->obedit==NULL && ob && !(ob->mode & OB_MODE_POSE)) { use_sel = 1; } diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c index 2bc9b96281e..53dbe2dc9d9 100644 --- a/source/blender/editors/space_view3d/view3d_header.c +++ b/source/blender/editors/space_view3d/view3d_header.c @@ -61,6 +61,7 @@ #include "BKE_main.h" #include "BKE_mesh.h" #include "BKE_modifier.h" +#include "BKE_paint.h" #include "BKE_particle.h" #include "BKE_screen.h" #include "BKE_utildefines.h" /* for VECCOPY */ @@ -80,6 +81,7 @@ #include "RNA_access.h" #include "RNA_define.h" +#include "RNA_enum_types.h" #include "BIF_gl.h" #include "BIF_glutil.h" @@ -105,16 +107,6 @@ * This can be cleaned when I make some new 'mode' icons. */ -#define V3D_OBJECTMODE_SEL ICON_OBJECT_DATA -#define V3D_EDITMODE_SEL ICON_EDITMODE_HLT -#define V3D_SCULPTMODE_SEL ICON_SCULPTMODE_HLT -#define V3D_FACESELECT_SEL ICON_FACESEL_HLT /* this is not a mode anymore - just a switch */ -#define V3D_VERTEXPAINTMODE_SEL ICON_VPAINT_HLT -#define V3D_TEXTUREPAINTMODE_SEL ICON_TPAINT_HLT -#define V3D_WEIGHTPAINTMODE_SEL ICON_WPAINT_HLT -#define V3D_POSEMODE_SEL ICON_POSE_HLT -#define V3D_PARTICLEEDITMODE_SEL ICON_ANIM - #define TEST_EDITMESH if(obedit==0) return; \ if( (v3d->lay & obedit->lay)==0 ) return; @@ -135,29 +127,6 @@ static int retopo_mesh_paint_check() {return 0;} /* end XXX ************* */ - -/* well... in this file a lot of view mode manipulation happens, so let's have it defined here */ -void ED_view3d_exit_paint_modes(bContext *C) -{ - if(G.f & G_TEXTUREPAINT) - WM_operator_name_call(C, "PAINT_OT_texture_paint_toggle", WM_OP_EXEC_REGION_WIN, NULL); - if(G.f & G_VERTEXPAINT) - WM_operator_name_call(C, "PAINT_OT_vertex_paint_toggle", WM_OP_EXEC_REGION_WIN, NULL); - else if(G.f & G_WEIGHTPAINT) - WM_operator_name_call(C, "PAINT_OT_weight_paint_toggle", WM_OP_EXEC_REGION_WIN, NULL); - - if(G.f & G_SCULPTMODE) - WM_operator_name_call(C, "SCULPT_OT_sculptmode_toggle", WM_OP_EXEC_REGION_WIN, NULL); - if(G.f & G_PARTICLEEDIT) - WM_operator_name_call(C, "PARTICLE_OT_particle_edit_toggle", WM_OP_EXEC_REGION_WIN, NULL); - - G.f &= ~(G_VERTEXPAINT+G_TEXTUREPAINT+G_WEIGHTPAINT+G_SCULPTMODE+G_PARTICLEEDIT); -} - - - - - static void do_view3d_header_buttons(bContext *C, void *arg, int event); #define B_SCENELOCK 101 @@ -220,55 +189,6 @@ static void handle_view3d_lock(bContext *C) } } -/* XXX; all this context stuff... should become operator */ -void do_layer_buttons(bContext *C, short event) -{ - wmWindow *win= CTX_wm_window(C); - Scene *scene= CTX_data_scene(C); - ScrArea *sa= CTX_wm_area(C); - View3D *v3d= sa->spacedata.first; - static int oldlay= 1; - short shift, alt, ctrl; - - shift= win->eventstate->shift; - alt= win->eventstate->alt; - ctrl= win->eventstate->ctrl; - - if(v3d==0) return; - if(v3d->localview) return; - - if(event==-1 && ctrl) { - v3d->scenelock= !v3d->scenelock; - do_view3d_header_buttons(C, NULL, B_SCENELOCK); - } else if (event<0) { - if(v3d->lay== (1<<20)-1) { - if(event==-2 || shift) v3d->lay= oldlay; - } - else { - oldlay= v3d->lay; - v3d->lay= (1<<20)-1; - } - - if(v3d->scenelock) handle_view3d_lock(C); - - /* new layers might need unflushed events events */ - DAG_scene_update_flags(scene, v3d->lay); /* tags all that moves and flushes */ - } - else { - if(alt) { - if(event<11) event+= 10; - } - if(shift) { - if(v3d->lay & (1<<event)) v3d->lay -= (1<<event); - else v3d->lay += (1<<event); - } - do_view3d_header_buttons(C, NULL, event+B_LAY); - } - ED_area_tag_redraw(sa); - - if(v3d->drawtype == OB_SHADED) reshadeall_displist(scene); -} - static int layers_exec(bContext *C, wmOperator *op) { Scene *scene= CTX_data_scene(C); @@ -347,403 +267,6 @@ void VIEW3D_OT_layers(wmOperatorType *ot) RNA_def_boolean(ot->srna, "extend", 0, "Extend", ""); } - -#if 0 -static void do_view3d_view_camerasmenu(bContext *C, void *arg, int event) -{ - Scene *scene= CTX_data_scene(C); - Base *base; - int i=1; - - if (event == 1) { - /* Set Active Object as Active Camera */ - /* XXX ugly hack alert */ -// G.qual |= LR_CTRLKEY; -// persptoetsen(PAD0); -// G.qual &= ~LR_CTRLKEY; - } else { - - for( base = FIRSTBASE; base; base = base->next ) { - if (base->object->type == OB_CAMERA) { - i++; - - if (event==i) { - /* XXX use api call! */ - - break; - } - } - } - } - -} - - -static uiBlock *view3d_view_camerasmenu(bContext *C, ARegion *ar, void *arg_unused) -{ - Scene *scene= CTX_data_scene(C); - Base *base; - uiBlock *block; - short yco= 0, menuwidth=120; - int i=1; - char camname[48]; - - block= uiBeginBlock(C, ar, "view3d_view_camerasmenu", UI_EMBOSSP); - uiBlockSetButmFunc(block, do_view3d_view_camerasmenu, NULL); - - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Set Active Object as Active Camera|Ctrl NumPad 0", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 1, ""); - - uiDefBut(block, SEPR, 0, "", 0, yco-=6, 140, 6, NULL, 0.0, 0.0, 0, 0, ""); - - for( base = FIRSTBASE; base; base = base->next ) { - if (base->object->type == OB_CAMERA) { - i++; - - strcpy(camname, base->object->id.name+2); - if (base->object == scene->camera) strcat(camname, " (Active)"); - - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, camname, 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, i, ""); - } - } - - uiBlockSetDirection(block, UI_RIGHT); - uiTextBoundsBlock(block, 50); - return block; -} -#endif - -#if 0 -static void do_view3d_view_cameracontrolsmenu(bContext *C, void *arg, int event) -{ - switch(event) { - case 0: /* Orbit Left */ - persptoetsen(PAD4); - break; - case 1: /* Orbit Right */ - persptoetsen(PAD6); - break; - case 2: /* Orbit Up */ - persptoetsen(PAD8); - break; - case 3: /* Orbit Down */ - persptoetsen(PAD2); - break; - case 4: /* Pan left */ - /* XXX ugly hack alert */ -// G.qual |= LR_CTRLKEY; - persptoetsen(PAD4); -// G.qual &= ~LR_CTRLKEY; - break; - case 5: /* Pan right */ - /* XXX ugly hack alert */ -// G.qual |= LR_CTRLKEY; - persptoetsen(PAD6); -// G.qual &= ~LR_CTRLKEY; - break; - case 6: /* Pan up */ - /* ugly hack alert */ -// G.qual |= LR_CTRLKEY; - persptoetsen(PAD8); -// G.qual &= ~LR_CTRLKEY; - break; - case 7: /* Pan down */ - /* ugly hack alert */ -// G.qual |= LR_CTRLKEY; - persptoetsen(PAD2); -// G.qual &= ~LR_CTRLKEY; - break; - case 8: /* Zoom In */ - persptoetsen(PADPLUSKEY); - break; - case 9: /* Zoom Out */ - persptoetsen(PADMINUS); - break; - case 10: /* Reset Zoom */ - persptoetsen(PADENTER); - break; - case 11: /* Camera Fly mode */ - fly(); - break; - } -} - - -static uiBlock *view3d_view_cameracontrolsmenu(bContext *C, ARegion *ar, void *arg_unused) -{ -/* static short tog=0; */ - uiBlock *block; - short yco= 0, menuwidth=120; - - block= uiBeginBlock(C, ar, "view3d_view_cameracontrolsmenu", UI_EMBOSSP); - uiBlockSetButmFunc(block, do_view3d_view_cameracontrolsmenu, NULL); - - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Camera Fly Mode|Shift F", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 11, ""); - - uiDefBut(block, SEPR, 0, "", 0, yco-=6, 140, 6, NULL, 0.0, 0.0, 0, 0, ""); - - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Orbit Left|NumPad 4", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 0, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Orbit Right|NumPad 6", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 1, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Orbit Up|NumPad 8", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 2, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Orbit Down|NumPad 2", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 3, ""); - - uiDefBut(block, SEPR, 0, "", 0, yco-=6, 140, 6, NULL, 0.0, 0.0, 0, 0, ""); - - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Pan Left|Ctrl NumPad 4", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 4, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Pan Right|Ctrl NumPad 6", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 5, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Pan Up|Ctrl NumPad 8", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 6, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Pan Down|Ctrl NumPad 2", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 7, ""); - - uiDefBut(block, SEPR, 0, "", 0, yco-=6, 140, 6, NULL, 0.0, 0.0, 0, 0, ""); - - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Zoom In|NumPad +", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 8, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Zoom Out|NumPad -", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 9, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Reset Zoom|NumPad Enter", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 10, ""); - - uiBlockSetDirection(block, UI_RIGHT); - uiTextBoundsBlock(block, 50); - return block; -} - -static void do_view3d_view_alignviewmenu(bContext *C, void *arg, int event) -{ - Scene *scene= CTX_data_scene(C); - ScrArea *sa= CTX_wm_area(C); - View3D *v3d= sa->spacedata.first; - Object *obedit = CTX_data_edit_object(C); - float *curs; - - switch(event) { - - case 0: /* Align View to Selected (edit/faceselect mode) */ - case 1: - case 2: - if ((obedit) && (obedit->type == OB_MESH)) { - editmesh_align_view_to_selected(v3d, event + 1); - } - else if (FACESEL_PAINT_TEST) { - Object *obact= OBACT; - if (obact && obact->type==OB_MESH) { - Mesh *me= obact->data; - - if (me->mtface) { -// XXX faceselect_align_view_to_selected(v3d, me, event + 1); - ED_area_tag_redraw(sa); - } - } - } - break; - case 3: /* Center View to Cursor */ - curs= give_cursor(scene, v3d); - v3d->ofs[0]= -curs[0]; - v3d->ofs[1]= -curs[1]; - v3d->ofs[2]= -curs[2]; - ED_area_tag_redraw(sa); - break; - case 4: /* Align Active Camera to View */ - /* XXX This ugly hack is a symptom of the nasty persptoetsen function, - * but at least it works for now. - */ -// G.qual |= LR_CTRLKEY|LR_ALTKEY; - persptoetsen(PAD0); -// G.qual &= ~(LR_CTRLKEY|LR_ALTKEY); - break; - case 5: /* Align View to Selected (object mode) */ -// XXX mainqenter(PADASTERKEY, 1); - break; - case 6: /* Center View and Cursor to Origin */ - WM_operator_name_call(C, "VIEW3D_OT_view_center", WM_OP_EXEC_REGION_WIN, NULL); - curs= give_cursor(scene, v3d); - curs[0]=curs[1]=curs[2]= 0.0; - break; - } -} - -static uiBlock *view3d_view_alignviewmenu(bContext *C, ARegion *ar, void *arg_unused) -{ -/* static short tog=0; */ - uiBlock *block; - Object *obedit = CTX_data_edit_object(C); - short yco= 0, menuwidth=120; - - block= uiBeginBlock(C, ar, "view3d_view_alignviewmenu", UI_EMBOSSP); - uiBlockSetButmFunc(block, do_view3d_view_alignviewmenu, NULL); - - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Center View to Cursor|C", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 3, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Center Cursor and View All|Shift C", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 6, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Align Active Camera to View|Ctrl Alt NumPad 0", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 4, ""); - - if (((obedit) && (obedit->type == OB_MESH)) || (FACESEL_PAINT_TEST)) { - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Align View to Selected (Top)|Shift V", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 2, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Align View to Selected (Front)|Shift V", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 1, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Align View to Selected (Side)|Shift V", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 0, ""); - } else { - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Align View to Selected|NumPad *", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 5, ""); - } - - uiBlockSetDirection(block, UI_RIGHT); - uiTextBoundsBlock(block, 50); - return block; -} -#endif - -#if 0 -static uiBlock *view3d_view_spacehandlers(bContext *C, ARegion *ar, void *arg_unused) -{ - /* XXX */ - return NULL; -} - - -static void do_view3d_viewmenu(bContext *C, void *arg, int event) -{ - - switch(event) { - case 0: /* User */ - break; - case 1: /* Camera */ - break; - case 2: /* Top */ - break; - case 3: /* Front */ - break; - case 4: /* Side */ - break; - case 5: /* Perspective */ - break; - case 6: /* Orthographic */ - break; - case 7: /* Local View */ - break; - case 8: /* Global View */ - break; - case 9: /* View All (Home) */ - WM_operator_name_call(C, "VIEW3D_OT_view_all", WM_OP_EXEC_REGION_WIN, NULL); - break; - case 11: /* View Selected */ - WM_operator_name_call(C, "VIEW3D_OT_view_center", WM_OP_EXEC_REGION_WIN, NULL); - break; - case 13: /* Play Back Animation */ - break; - case 15: /* Background Image... */ -// add_blockhandler(sa, VIEW3D_HANDLER_BACKGROUND, UI_PNL_UNSTOW); - break; - case 16: /* View Panel */ -// add_blockhandler(sa, VIEW3D_HANDLER_PROPERTIES, UI_PNL_UNSTOW); - break; - case 17: /* Set Clipping Border */ - WM_operator_name_call(C, "VIEW3D_OT_clip_border", WM_OP_INVOKE_REGION_WIN, NULL); - break; - case 18: /* render preview */ -// toggle_blockhandler(sa, VIEW3D_HANDLER_PREVIEW, 0); - break; - case 19: /* zoom within border */ -// view3d_border_zoom(); - break; - case 20: /* Transform Space Panel */ -// add_blockhandler(sa, VIEW3D_HANDLER_TRANSFORM, UI_PNL_UNSTOW); - break; - case 21: /* Grease Pencil */ -// add_blockhandler(sa, VIEW3D_HANDLER_GREASEPENCIL, UI_PNL_UNSTOW); - break; - case 22: /* View all layers */ - do_layer_buttons(C, -2); - break; - } -} -#endif - -#if 0 -static uiBlock *view3d_viewmenu(bContext *C, ARegion *ar, void *arg_unused) -{ - ScrArea *sa= CTX_wm_area(C); - View3D *v3d= sa->spacedata.first; - RegionView3D *rv3d= wm_region_view3d(C); - uiBlock *block; - short yco= 0, menuwidth=120; - - block= uiBeginBlock(C, ar, "view3d_viewmenu", UI_EMBOSSP); - uiBlockSetButmFunc(block, do_view3d_viewmenu, NULL); - - uiDefIconTextBut(block, BUTM, 1, ICON_MENU_PANEL, "Transform Orientations...", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 20, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_MENU_PANEL, "Render Preview...|Shift P", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 18, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_MENU_PANEL, "View Properties...", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 16, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_MENU_PANEL, "Background Image...", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 15, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_MENU_PANEL, "Grease Pencil...", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 21, ""); - - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - - if ((rv3d->viewbut == 0) && !(rv3d->persp == V3D_CAMOB)) uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "User", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 0, ""); - else uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "User", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 0, ""); - if (rv3d->persp == V3D_CAMOB) uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Camera|NumPad 0", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 1, ""); - else uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Camera|NumPad 0", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 1, ""); - if (rv3d->viewbut == 1) uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Top|NumPad 7", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 2, ""); - else uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Top|NumPad 7", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 2, ""); - if (rv3d->viewbut == 2) uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Front|NumPad 1", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 3, ""); - else uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Front|NumPad 1", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 3, ""); - if (rv3d->viewbut == 3) uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Side|NumPad 3", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 4, ""); - else uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Side|NumPad 3", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 4, ""); - - uiDefIconTextBlockBut(block, view3d_view_camerasmenu, NULL, ICON_RIGHTARROW_THIN, "Cameras", 0, yco-=20, 120, 19, ""); - - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - - if(rv3d->persp==V3D_PERSP) uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Perspective|NumPad 5", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 5, ""); - else uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Perspective|NumPad 5", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 5, ""); - if(rv3d->persp==V3D_ORTHO) uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Orthographic|NumPad 5", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 6, ""); - else uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Orthographic|NumPad 5", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 6, ""); - - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - - if(v3d->lay== (1<<20)-1) uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Show Previous Layers|Shift ~", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 22, ""); - else uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Show All Layers| ~", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 22, ""); - - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - - if(v3d->localview) uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Local View|NumPad /", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 7, ""); - else uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Local View|NumPad /", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 7, ""); - if(!v3d->localview) uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Global View|NumPad /", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 8, ""); - else uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Global View|NumPad /", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 8, ""); - - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - - uiDefIconTextBlockBut(block, view3d_view_cameracontrolsmenu, NULL, ICON_RIGHTARROW_THIN, "View Navigation", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, view3d_view_alignviewmenu, NULL, ICON_RIGHTARROW_THIN, "Align View", 0, yco-=20, 120, 19, ""); - - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - - if(rv3d->rflag & RV3D_CLIPPING) - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Clear Clipping Border|Alt B", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 17, ""); - else - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Set Clipping Border|Alt B", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 17, ""); - if (rv3d->persp==V3D_ORTHO) uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Zoom Within Border...|Shift B", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 19, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "View Selected|NumPad .", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 11, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "View All|Home", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 9, ""); - if(!sa->full) uiDefIconTextBut(block, BUTM, B_FULL, ICON_BLANK1, "Maximize Window|Ctrl UpArrow", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 99, ""); - else uiDefIconTextBut(block, BUTM, B_FULL, ICON_BLANK1, "Tile Window|Ctrl DownArrow", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 99, ""); - - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Play Back Animation|Alt A", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 13, ""); - -#ifndef DISABLE_PYTHON - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - uiDefIconTextBlockBut(block, view3d_view_spacehandlers, NULL, ICON_RIGHTARROW_THIN, "Space Handler Scripts", 0, yco-=20, 120, 19, ""); -#endif - - if(ar->alignment==RGN_ALIGN_TOP) { - uiBlockSetDirection(block, UI_DOWN); - } - else { - uiBlockSetDirection(block, UI_TOP); - uiBlockFlipOrder(block); - } - - uiTextBoundsBlock(block, 50); - - return block; -} -#endif - #if 0 void do_view3d_select_object_typemenu(bContext *C, void *arg, int event) { @@ -964,188 +487,6 @@ static uiBlock *view3d_select_object_groupedmenu(bContext *C, ARegion *ar, void #endif -static void view3d_select_objectmenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - uiItemO(layout, NULL, 0, "VIEW3D_OT_select_border"); - - uiItemS(layout); - - uiItemO(layout, "Select/Deselect All", 0, "OBJECT_OT_select_all_toggle"); - uiItemO(layout, "Inverse", 0, "OBJECT_OT_select_inverse"); - uiItemO(layout, "Random", 0, "OBJECT_OT_select_random"); - uiItemO(layout, "Select All by Layer", 0, "OBJECT_OT_select_by_layer"); - uiItemMenuEnumO(layout, "Select All by Type", 0, "OBJECT_OT_select_by_type", "type"); - uiItemMenuEnumO(layout, "Select Grouped", 0, "OBJECT_OT_select_grouped", "type"); - -#if 0 - uiDefIconTextBlockBut(block, view3d_select_object_layermenu, NULL, ICON_RIGHTARROW_THIN, "Select All by Layer", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, view3d_select_object_typemenu, NULL, ICON_RIGHTARROW_THIN, "Select All by Type", 0, yco-=20, 120, 19, ""); - - uiItemS(layout); - - uiDefIconTextBlockBut(block, view3d_select_object_linkedmenu, NULL, ICON_RIGHTARROW_THIN, "Linked", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, view3d_select_object_groupedmenu, NULL, ICON_RIGHTARROW_THIN, "Grouped", 0, yco-=20, 120, 19, ""); -#endif -} - -static void view3d_select_meshmenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - uiItemO(layout, NULL, 0, "VIEW3D_OT_select_border"); - - uiItemS(layout); - - uiItemO(layout, "Select/Deselect All", 0, "MESH_OT_select_all_toggle"); - uiItemO(layout, "Inverse", 0, "MESH_OT_select_inverse"); - - uiItemS(layout); - - uiItemO(layout, "Random...", 0, "MESH_OT_select_random"); // Random... - uiItemO(layout, "Sharp Edges", 0, "MESH_OT_edges_select_sharp"); - uiItemO(layout, "Linked Flat Faces", 0, "MESH_OT_faces_select_linked_flat"); - - uiItemS(layout); - - uiItemEnumO(layout, "Triangles", 0, "MESH_OT_select_by_number_vertices", "type", 3); // Ctrl Alt Shift 3 - uiItemEnumO(layout, "Quads", 0, "MESH_OT_select_by_number_vertices", "type", 4); // Ctrl Alt Shift 4 - uiItemEnumO(layout, "Loose Verts/Edges", 0, "MESH_OT_select_by_number_vertices", "type", 5); // Ctrl Alt Shift 5 - uiItemO(layout, "Similar...", 0, "MESH_OT_select_similar"); - - uiItemS(layout); - - uiItemO(layout, "Less", 0, "MESH_OT_select_more"); - uiItemO(layout, "More", 0, "MESH_OT_select_less"); - - uiItemS(layout); - - uiItemO(layout, "Linked", 0, "MESH_OT_select_linked"); - uiItemO(layout, "Vertex Path", 0, "MESH_OT_select_vertex_path"); // W, Alt 7 - uiItemO(layout, "Edge Loop", 0, "MESH_OT_loop_multi_select"); - uiItemBooleanO(layout, "Edge Ring", 0, "MESH_OT_loop_multi_select", "ring", 1); - - uiItemS(layout); - - uiItemO(layout, NULL, 0, "MESH_OT_loop_to_region"); // Ctrl E 8 - uiItemO(layout, NULL, 0, "MESH_OT_region_to_loop"); // Ctrl E 9 -} - -static void view3d_select_curvemenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - Object *obedit= CTX_data_edit_object(C); - - uiItemO(layout, NULL, 0, "VIEW3D_OT_select_border"); - uiItemO(layout, NULL, 0, "VIEW3D_OT_select_circle"); - - uiItemS(layout); - - uiItemO(layout, NULL, 0, "CURVE_OT_select_all_toggle"); - uiItemO(layout, NULL, 0, "CURVE_OT_select_inverse"); - uiItemO(layout, NULL, 0, "CURVE_OT_select_random"); // Random... - uiItemO(layout, NULL, 0, "CURVE_OT_select_every_nth"); // Every Nth.. - - uiItemS(layout); - - if(obedit->type == OB_SURF) { - uiItemO(layout, NULL, 0, "CURVE_OT_select_row"); - } - else { - uiItemO(layout, NULL, 0, "CURVE_OT_de_select_first"); - uiItemO(layout, NULL, 0, "CURVE_OT_de_select_last"); - uiItemO(layout, NULL, 0, "CURVE_OT_select_next"); - uiItemO(layout, NULL, 0, "CURVE_OT_select_previous"); - } - - uiItemS(layout); - - uiItemO(layout, NULL, 0, "CURVE_OT_select_more"); - uiItemO(layout, NULL, 0, "CURVE_OT_select_less"); - - /* commented out because it seems to only like the LKEY method - based on mouse pointer position :( */ - /* uiItemO(layout, NULL, 0, "CURVE_OT_select_linked"); */ - -#if 0 - G.qual |= LR_CTRLKEY; - select_connected_nurb(); - G.qual &= ~LR_CTRLKEY; - break;*/ -#endif -} - -static void view3d_select_metaballmenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - uiItemO(layout, NULL, 0, "VIEW3D_OT_select_border"); - uiItemS(layout); - uiItemO(layout, NULL, 0, "MBALL_OT_select_deselect_all_metaelems"); - uiItemO(layout, NULL, 0, "MBALL_OT_select_inverse_metaelems"); - uiItemS(layout); - uiItemO(layout, NULL, 0, "MBALL_OT_select_random_metaelems"); -} - -static void view3d_select_latticemenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - uiItemO(layout, NULL, 0, "VIEW3D_OT_select_border"); - uiItemS(layout); - uiItemO(layout, NULL, 0, "LATTICE_OT_select_all_toggle"); -} - -static void view3d_select_armaturemenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - PointerRNA ptr; - - uiItemO(layout, NULL, 0, "VIEW3D_OT_select_border"); - - uiItemS(layout); - - uiItemO(layout, "Select/Deselect All", 0, "ARMATURE_OT_select_all_toggle"); - uiItemO(layout, "Inverse", 0, "ARMATURE_OT_select_inverse"); - - uiItemS(layout); - - uiItemEnumO(layout, "Parent", 0, "ARMATURE_OT_select_hierarchy", "direction", BONE_SELECT_PARENT); - uiItemEnumO(layout, "Child", 0, "ARMATURE_OT_select_hierarchy", "direction", BONE_SELECT_CHILD); - - uiItemS(layout); - - WM_operator_properties_create(&ptr, "ARMATURE_OT_select_hierarchy"); - RNA_boolean_set(&ptr, "extend", 1); - RNA_enum_set(&ptr, "direction", BONE_SELECT_PARENT); - uiItemFullO(layout, "Extend Parent", 0, "ARMATURE_OT_select_hierarchy", ptr.data, WM_OP_EXEC_REGION_WIN); - - WM_operator_properties_create(&ptr, "ARMATURE_OT_select_hierarchy"); - RNA_boolean_set(&ptr, "extend", 1); - RNA_enum_set(&ptr, "direction", BONE_SELECT_CHILD); - uiItemFullO(layout, "Extend Child", 0, "ARMATURE_OT_select_hierarchy", ptr.data, WM_OP_EXEC_REGION_WIN); -} - -static void view3d_select_posemenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - PointerRNA ptr; - - uiItemO(layout, NULL, 0, "VIEW3D_OT_select_border"); - - uiItemS(layout); - - uiItemO(layout, "Select/Deselect All", 0, "POSE_OT_select_all_toggle"); - uiItemO(layout, "Inverse", 0, "POSE_OT_select_inverse"); - uiItemO(layout, "Constraint Target", 0, "POSE_OT_select_constraint_target"); - - uiItemS(layout); - - uiItemEnumO(layout, "Parent", 0, "POSE_OT_select_hierarchy", "direction", BONE_SELECT_PARENT); - uiItemEnumO(layout, "Child", 0, "POSE_OT_select_hierarchy", "direction", BONE_SELECT_CHILD); - - uiItemS(layout); - - WM_operator_properties_create(&ptr, "POSE_OT_select_hierarchy"); - RNA_boolean_set(&ptr, "extend", 1); - RNA_enum_set(&ptr, "direction", BONE_SELECT_PARENT); - uiItemFullO(layout, "Extend Parent", 0, "POSE_OT_select_hierarchy", ptr.data, WM_OP_EXEC_REGION_WIN); - - WM_operator_properties_create(&ptr, "POSE_OT_select_hierarchy"); - RNA_boolean_set(&ptr, "extend", 1); - RNA_enum_set(&ptr, "direction", BONE_SELECT_CHILD); - uiItemFullO(layout, "Extend Child", 0, "POSE_OT_select_hierarchy", ptr.data, WM_OP_EXEC_REGION_WIN); -} - void do_view3d_select_faceselmenu(bContext *C, void *arg, int event) { #if 0 @@ -1216,19 +557,15 @@ static uiBlock *view3d_select_faceselmenu(bContext *C, ARegion *ar, void *arg_un return block; } -static void view3d_edit_snapmenu(bContext *C, uiLayout *layout, void *arg_unused) +/* wrapper for python layouts */ +void uiTemplate_view3d_select_faceselmenu(uiLayout *layout, bContext *C) { - uiItemO(layout, NULL, 0, "VIEW3D_OT_snap_selected_to_grid"); - uiItemO(layout, NULL, 0, "VIEW3D_OT_snap_selected_to_cursor"); - uiItemO(layout, NULL, 0, "VIEW3D_OT_snap_selected_to_center"); - - uiItemS(layout); - - uiItemO(layout, NULL, 0, "VIEW3D_OT_snap_cursor_to_selected"); - uiItemO(layout, NULL, 0, "VIEW3D_OT_snap_cursor_to_grid"); - uiItemO(layout, NULL, 0, "VIEW3D_OT_snap_cursor_to_active"); + void *arg_unused = NULL; + ARegion *ar= CTX_wm_region(C); + view3d_select_faceselmenu(C, ar, arg_unused); } +#if 0 void do_view3d_transform_moveaxismenu(bContext *C, void *arg, int event) { #if 0 @@ -1429,7 +766,9 @@ static uiBlock *view3d_transform_scaleaxismenu(bContext *C, ARegion *ar, void *a uiTextBoundsBlock(block, 60); return block; } +#endif +#if 0 static void do_view3d_transformmenu(bContext *C, void *arg, int event) { #if 0 @@ -1665,10 +1004,12 @@ static uiBlock *view3d_object_mirrormenu(bContext *C, ARegion *ar, void *arg_unu return block; } #endif +#endif +#if 0 static void view3d_edit_object_transformmenu(bContext *C, uiLayout *layout, void *arg_unused) { -#if 0 +#if 0 // XXX not used anymore uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Apply Scale/Rotation to ObData|Ctrl A, 1", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 6, ""); apply_objects_locrot(); uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Apply Visual Transform|Ctrl A, 2", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 7, ""); @@ -1685,6 +1026,7 @@ static void view3d_edit_object_transformmenu(bContext *C, uiLayout *layout, void uiItemO(layout, NULL, 0, "OBJECT_OT_scale_clear"); uiItemO(layout, NULL, 0, "OBJECT_OT_origin_clear"); } +#endif #if 0 static void do_view3d_edit_object_makelocalmenu(bContext *C, void *arg, int event) @@ -1925,42 +1267,6 @@ static uiBlock *view3d_edit_object_copyattrmenu(bContext *C, ARegion *ar, void * } #endif -static void view3d_edit_object_parentmenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - uiItemO(layout, "Make Parent...", 0, "OBJECT_OT_parent_set"); - uiItemO(layout, "Clear Parent...", 0, "OBJECT_OT_parent_clear"); -} - -static void view3d_edit_object_groupmenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - uiItemO(layout, NULL, 0, "GROUP_OT_group_create"); - uiItemO(layout, NULL, 0, "GROUP_OT_objects_remove"); - - uiItemS(layout); - - uiItemO(layout, NULL, 0, "GROUP_OT_objects_add_active"); - uiItemO(layout, NULL, 0, "GROUP_OT_objects_remove_active"); -} - -static void view3d_edit_object_trackmenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - uiItemO(layout, "Make Track...", 0, "OBJECT_OT_track_set"); - uiItemO(layout, "Clear Track...", 0, "OBJECT_OT_track_clear"); -} - -static void view3d_edit_object_constraintsmenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - uiItemO(layout, NULL, 0, "OBJECT_OT_constraint_add_with_targets"); - uiItemO(layout, NULL, 0, "OBJECT_OT_constraints_clear"); -} - -static void view3d_edit_object_showhidemenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - uiItemO(layout, "Show Hidden", 0, "OBJECT_OT_restrictview_clear"); - uiItemO(layout, "Hide Selected", 0, "OBJECT_OT_restrictview_set"); - uiItemBooleanO(layout, "Hide Unselected", 0, "OBJECT_OT_restrictview_set", "unselected", 1); -} - #if 0 #ifndef DISABLE_PYTHON static void do_view3d_edit_object_scriptsmenu(bContext *C, void *arg, int event) @@ -2034,919 +1340,6 @@ static void do_view3d_edit_objectmenu(bContext *C, void *arg, int event) } #endif -static void view3d_edit_objectmenu(bContext *C, uiLayout *layout, void *arg_unused) -{ -#if 0 - Object *ob= CTX_data_active_object(C); - - uiDefIconTextBlockBut(block, view3d_transformmenu, NULL, ICON_RIGHTARROW_THIN, "Transform", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, view3d_object_mirrormenu, NULL, ICON_RIGHTARROW_THIN, "Mirror", 0, yco-=20, menuwidth, 19, ""); -#endif - - uiItemMenuF(layout, "Clear/Apply", 0, view3d_edit_object_transformmenu); - uiItemMenuF(layout, "Snap", 0, view3d_edit_snapmenu); - - uiItemS(layout); - - // TODO: these operators may get renamed - uiItemO(layout, NULL, 0, "ANIM_OT_insert_keyframe_menu"); - uiItemO(layout, NULL, 0, "ANIM_OT_delete_keyframe_v3d"); - - uiItemS(layout); - - uiItemO(layout, NULL, 0, "OBJECT_OT_duplicate"); - uiItemBooleanO(layout, "Duplicate Linked", 0, "OBJECT_OT_duplicate", "linked", 1); - uiItemO(layout, NULL, 0, "OBJECT_OT_delete"); - - uiItemO(layout, NULL, 0, "OBJECT_OT_proxy_make"); -#if 0 - uiDefIconTextBlockBut(block, view3d_edit_object_makelinksmenu, NULL, ICON_RIGHTARROW_THIN, "Make Links", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, view3d_edit_object_singleusermenu, NULL, ICON_RIGHTARROW_THIN, "Make Single User", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, view3d_edit_object_makelocalmenu, NULL, ICON_RIGHTARROW_THIN, "Make Local", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, view3d_edit_object_copyattrmenu, NULL, ICON_RIGHTARROW_THIN, "Copy Attributes", 0, yco-=20, 120, 19, ""); -#endif - - uiItemS(layout); - - uiItemMenuF(layout, "Parent", 0, view3d_edit_object_parentmenu); - uiItemMenuF(layout, "Track", 0, view3d_edit_object_trackmenu); - uiItemMenuF(layout, "Group", 0, view3d_edit_object_groupmenu); - uiItemMenuF(layout, "Constraints", 0, view3d_edit_object_constraintsmenu); - -#if 0 - if(ob && ob->type == OB_MESH) { - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Boolean Operation...|W", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 7, ""); - } - - // join... (added already) - - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Convert Object Type...|Alt C", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 9, ""); -#endif - uiItemS(layout); - - uiItemO(layout, NULL, 0, "OBJECT_OT_join"); - - uiItemS(layout); - -#if 0 - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Move to Layer...|M", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 10, ""); -#endif - - uiItemMenuF(layout, "Show/Hide", 0, view3d_edit_object_showhidemenu); - -#if 0 -#ifndef DISABLE_PYTHON - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - uiDefIconTextBlockBut(block, view3d_edit_object_scriptsmenu, NULL, ICON_RIGHTARROW_THIN, "Scripts", 0, yco-=20, 120, 19, ""); -#endif -#endif -} - -static void view3d_edit_mesh_verticesmenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - uiItemO(layout, "Merge...", 0, "MESH_OT_merge"); - uiItemO(layout, "Rip", 0, "MESH_OT_rip"); - uiItemO(layout, "Split", 0, "MESH_OT_split"); - uiItemO(layout, "Separate", 0, "MESH_OT_separate"); - - uiItemS(layout); - - uiItemO(layout, "Smooth", 0, "MESH_OT_vertices_smooth"); - uiItemO(layout, "Remove Doubles", 0, "MESH_OT_remove_doubles"); - -#if 0 - uiItemS(layout); - - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Make Vertex Parent|Ctrl P", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 0, ""); // add_hook_menu(); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Add Hook|Ctrl H", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 6, ""); // make_parent(); -#endif -} - -void do_view3d_edit_mesh_edgesmenu(bContext *C, void *arg, int event) -{ -#if 0 - Scene *scene= CTX_data_scene(C); - float fac; - short randfac; - - switch(event) { - case 9: /* Crease SubSurf */ - if(!multires_level1_test()) { - initTransform(TFM_CREASE, CTX_EDGE); - Transform(); - } - break; - case 12: /* Edgeslide */ - EdgeSlide(0,0.0); - break; - case 13: /* Edge Loop Delete */ - if(EdgeLoopDelete()) { - countall(); - ED_undo_push(C, "Erase Edge Loop"); - DAG_object_flush_update(scene, obedit, OB_RECALC_DATA); - } - break; - case 14: /*Collapse Edges*/ - collapseEdges(); - ED_undo_push(C, "Collapse"); - break; - case 17: /* Adjust Bevel Weight */ - if(!multires_level1_test()) { - initTransform(TFM_BWEIGHT, CTX_EDGE); - Transform(); - } - break; - } -#endif -} - -static void view3d_edit_mesh_edgesmenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - uiItemO(layout, NULL, 0, "MESH_OT_edge_face_add"); - -#if 0 - uiItemO(layout, "Bevel", 0, "MESH_OT_bevel"); // bevelmenu(em) - uiItemO(layout, "Loop Subdivide...", 0, "MESH_OT_loop_subdivide"); // Ctr R, CutEdgeloop(1); - uiItemO(layout, "Knife Subdivide...", 0, "MESH_OT_loop_subdivide"); // Shift K, KnifeSubdivide(KNIFE_PROMPT); - - uiItemS(layout); -#endif - - uiItemO(layout, "Subdivide", 0, "MESH_OT_subdivide"); - uiItemFloatO(layout, "Subdivide Smooth", 0, "MESH_OT_subdivide", "smoothness", 1.0f); - - uiItemS(layout); - - uiItemO(layout, "Mark Seam", 0, "MESH_OT_mark_seam"); - uiItemBooleanO(layout, "Clear Seam", 0, "MESH_OT_mark_seam", "clear", 1); - - uiItemS(layout); - - uiItemO(layout, "Mark Sharp", 0, "MESH_OT_mark_sharp"); - uiItemBooleanO(layout, "Clear Sharp", 0, "MESH_OT_mark_sharp", "clear", 1); - -#if 0 - uiItemS(layout); - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Adjust Bevel Weight|Ctrl Shift E", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 17, ""); - - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Crease SubSurf|Shift E", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 9, ""); -#endif - - uiItemS(layout); - - uiItemEnumO(layout, "Rotate Edge CW", 0, "MESH_OT_edge_rotate", "direction", 1); - uiItemEnumO(layout, "Rotate Edge CCW", 0, "MESH_OT_edge_rotate", "direction", 2); - -#if 0 - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Slide Edge |Ctrl E", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 12, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Delete Edge Loop|X", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 13, ""); - - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Collapse", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 14, ""); -#endif -} - -static void view3d_edit_mesh_facesmenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - uiItemO(layout, NULL, 0, "MESH_OT_edge_face_add"); - uiItemO(layout, NULL, 0, "MESH_OT_fill"); - uiItemO(layout, NULL, 0, "MESH_OT_beauty_fill"); - - uiItemS(layout); - - uiItemO(layout, NULL, 0, "MESH_OT_quads_convert_to_tris"); - uiItemO(layout, NULL, 0, "MESH_OT_tris_convert_to_quads"); - uiItemO(layout, NULL, 0, "MESH_OT_edge_flip"); - - uiItemS(layout); - - uiItemO(layout, NULL, 0, "MESH_OT_faces_shade_smooth"); - uiItemO(layout, NULL, 0, "MESH_OT_faces_shade_flat"); -} - -static void view3d_edit_mesh_normalsmenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - uiItemO(layout, "Recalculate Outside", 0, "MESH_OT_normals_make_consistent"); - uiItemBooleanO(layout, "Recalculate Inside", 0, "MESH_OT_normals_make_consistent", "inside", 1); - - uiItemS(layout); - - uiItemO(layout, NULL, 0, "MESH_OT_flip_normals"); -} - -void do_view3d_edit_mirrormenu(bContext *C, void *arg, int event) -{ -#if 0 - float mat[3][3]; - - Mat3One(mat); - - switch(event) { - case 0: - initTransform(TFM_MIRROR, CTX_NO_PET); - Transform(); - break; - case 1: - initTransform(TFM_MIRROR, CTX_NO_PET|CTX_AUTOCONFIRM); - BIF_setSingleAxisConstraint(mat[0], " on global X axis"); - Transform(); - break; - case 2: - initTransform(TFM_MIRROR, CTX_NO_PET|CTX_AUTOCONFIRM); - BIF_setSingleAxisConstraint(mat[1], " on global Y axis"); - Transform(); - break; - case 3: - initTransform(TFM_MIRROR, CTX_NO_PET|CTX_AUTOCONFIRM); - BIF_setSingleAxisConstraint(mat[2], "on global Z axis"); - Transform(); - break; - case 4: - initTransform(TFM_MIRROR, CTX_NO_PET|CTX_AUTOCONFIRM); - BIF_setLocalAxisConstraint('X', " on local X axis"); - Transform(); - break; - case 5: - initTransform(TFM_MIRROR, CTX_NO_PET|CTX_AUTOCONFIRM); - BIF_setLocalAxisConstraint('Y', " on local Y axis"); - Transform(); - break; - case 6: - initTransform(TFM_MIRROR, CTX_NO_PET|CTX_AUTOCONFIRM); - BIF_setLocalAxisConstraint('Z', " on local Z axis"); - Transform(); - break; - } -#endif -} - -static uiBlock *view3d_edit_mirrormenu(bContext *C, ARegion *ar, void *arg_unused) -{ - uiBlock *block; - short yco = 20, menuwidth = 120; - - block= uiBeginBlock(C, ar, "view3d_edit_mirrormenu", UI_EMBOSSP); - uiBlockSetButmFunc(block, do_view3d_edit_mirrormenu, NULL); - - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Interactive Mirror|Ctrl M", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 0, ""); - - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "X Global|Ctrl M, X", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 1, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Y Global|Ctrl M, Y", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 2, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Z Global|Ctrl M, Z", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 3, ""); - - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "X Local|Ctrl M, X X", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 4, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Y Local|Ctrl M, Y Y", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 5, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Z Local|Ctrl M, Z Z", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 6, ""); - - uiBlockSetDirection(block, UI_RIGHT); - uiTextBoundsBlock(block, 60); - return block; -} - -static void view3d_edit_mesh_showhidemenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - uiItemO(layout, NULL, 0, "MESH_OT_reveal"); - uiItemO(layout, NULL, 0, "MESH_OT_hide"); - uiItemBooleanO(layout, "Hide Unselected", 0, "MESH_OT_hide", "unselected", 1); -} - -#ifndef DISABLE_PYTHON -#if 0 -static void do_view3d_edit_mesh_scriptsmenu(bContext *C, void *arg, int event) -{ - BPY_menu_do_python(PYMENU_MESH, event); -} - -static uiBlock *view3d_edit_mesh_scriptsmenu(bContext *C, ARegion *ar, void *arg_unused) -{ - uiBlock *block; -// short yco = 20, menuwidth = 120; -// XXX BPyMenu *pym; -// int i = 0; - - block= uiBeginBlock(C, ar, "v3d_emesh_pymenu", UI_EMBOSSP); - uiBlockSetButmFunc(block, do_view3d_edit_mesh_scriptsmenu, NULL); - -// for (pym = BPyMenuTable[PYMENU_MESH]; pym; pym = pym->next, i++) { -// uiDefIconTextBut(block, BUTM, 1, ICON_PYTHON, pym->name, 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, i, pym->tooltip?pym->tooltip:pym->filename); -// } - - uiBlockSetDirection(block, UI_RIGHT); - uiTextBoundsBlock(block, 60); - - return block; -} -#endif -#endif /* DISABLE_PYTHON */ - -#if 0 -static void do_view3d_edit_meshmenu(bContext *C, void *arg, int event) -{ - ScrArea *sa= CTX_wm_area(C); - - switch(event) { - - case 2: /* transform properties */ - add_blockhandler(sa, VIEW3D_HANDLER_OBJECT, 0); - break; - case 4: /* insert keyframe */ - common_insertkey(); - break; - case 16: /* delete keyframe */ - common_deletekey(); - break; - } -} -#endif - -static void view3d_edit_meshmenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - Scene *scene= CTX_data_scene(C); - ToolSettings *ts= CTX_data_tool_settings(C); - PointerRNA tsptr; - - RNA_pointer_create(&scene->id, &RNA_ToolSettings, ts, &tsptr); - - uiItemO(layout, "Undo Editing", 0, "ED_OT_undo"); - uiItemO(layout, "Redo Editing", 0, "ED_OT_redo"); - -#if 0 - uiDefIconTextBlockBut(block, editmode_undohistorymenu, NULL, ICON_RIGHTARROW_THIN, "Undo History", 0, yco-=20, 120, 19, ""); -#endif - - uiItemS(layout); - -#if 0 - uiDefIconTextBlockBut(block, view3d_transformmenu, NULL, ICON_RIGHTARROW_THIN, "Transform", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, view3d_edit_mirrormenu, NULL, ICON_RIGHTARROW_THIN, "Mirror", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, view3d_edit_snapmenu, NULL, ICON_RIGHTARROW_THIN, "Snap", 0, yco-=20, 120, 19, ""); -#endif - - uiItemMenuF(layout, "Snap", 0, view3d_edit_snapmenu); - - uiItemS(layout); - -#if 0 - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Insert Keyframe|I", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 4, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Delete Keyframe|Alt I", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 16, ""); - - uiItemS(layout); -#endif - - uiItemO(layout, NULL, 0, "UV_OT_mapping_menu"); - - uiItemS(layout); - - uiItemO(layout, NULL, 0, "MESH_OT_extrude"); - uiItemO(layout, NULL, 0, "MESH_OT_duplicate"); - uiItemO(layout, "Delete...", 0, "MESH_OT_delete"); - - uiItemS(layout); - - uiItemMenuF(layout, "Vertices", 0, view3d_edit_mesh_verticesmenu); - uiItemMenuF(layout, "Edges", 0, view3d_edit_mesh_edgesmenu); - uiItemMenuF(layout, "Faces", 0, view3d_edit_mesh_facesmenu); - uiItemMenuF(layout, "Normals", 0, view3d_edit_mesh_normalsmenu); - - uiItemS(layout); - - uiItemR(layout, NULL, 0, &tsptr, "automerge_editing", 0, 0, 0); - uiItemR(layout, NULL, 0, &tsptr, "proportional_editing", 0, 0, 0); // |O - uiItemMenuEnumR(layout, NULL, 0, &tsptr, "proportional_editing_falloff"); // |Shift O - - uiItemS(layout); - - uiItemMenuF(layout, "Show/Hide", 0, view3d_edit_mesh_showhidemenu); - -#if 0 -#ifndef DISABLE_PYTHON - uiItemS(layout); - uiDefIconTextBlockBut(block, view3d_edit_mesh_scriptsmenu, NULL, ICON_RIGHTARROW_THIN, "Scripts", 0, yco-=20, 120, 19, ""); -#endif -#endif -} - -static void view3d_edit_curve_controlpointsmenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - Object *obedit= CTX_data_edit_object(C); - - if(obedit->type == OB_CURVE) { - uiItemEnumO(layout, NULL, 0, "TFM_OT_transform", "mode", TFM_TILT); - uiItemO(layout, NULL, 0, "CURVE_OT_tilt_clear"); - uiItemO(layout, NULL, 0, "CURVE_OT_separate"); - - uiItemS(layout); - - uiItemEnumO(layout, NULL, 0, "CURVE_OT_handle_type_set", "type", 1); - uiItemEnumO(layout, NULL, 0, "CURVE_OT_handle_type_set", "type", 3); - uiItemEnumO(layout, NULL, 0, "CURVE_OT_handle_type_set", "type", 2); - - uiItemS(layout); - } - - // XXX uiItemO(layout, NULL, 0, "OBJECT_OT_make_vertex_parent"); Make VertexParent|Ctrl P - // make_parent() - // XXX uiItemO(layout, NULL, 0, "OBJECT_OT_add_hook"); Add Hook| Ctrl H - // add_hook_menu() -} - -static void view3d_edit_curve_segmentsmenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - uiItemO(layout, NULL, 0, "CURVE_OT_subdivide"); - uiItemO(layout, NULL, 0, "CURVE_OT_switch_direction"); -} - -static void view3d_edit_curve_showhidemenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - uiItemO(layout, NULL, 0, "CURVE_OT_reveal"); - uiItemO(layout, NULL, 0, "CURVE_OT_hide"); - uiItemBooleanO(layout, "Hide Unselected", 0, "CURVE_OT_hide", "unselected", 1); -} - -static void view3d_edit_curvemenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - Scene *scene= CTX_data_scene(C); - ToolSettings *ts= CTX_data_tool_settings(C); - PointerRNA tsptr; - - RNA_pointer_create(&scene->id, &RNA_ToolSettings, ts, &tsptr); - -#if 0 - uiDefIconTextBut(block, BUTM, 1, ICON_MENU_PANEL, "Transform Properties...|N", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 1, ""); - uiDefIconTextBlockBut(block, view3d_transformmenu, NULL, ICON_RIGHTARROW_THIN, "Transform", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, view3d_edit_mirrormenu, NULL, ICON_RIGHTARROW_THIN, "Mirror", 0, yco-=20, menuwidth, 19, ""); -#endif - - uiItemMenuF(layout, "Snap", 0, view3d_edit_snapmenu); - - uiItemS(layout); - - // XXX uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Insert Keyframe|I", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 2, ""); - // common_insertkey(); - // XXX uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Delete Keyframe|Alt I", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 16, ""); - // common_deletekey(); - - - uiItemO(layout, NULL, 0, "CURVE_OT_extrude"); - uiItemO(layout, NULL, 0, "CURVE_OT_duplicate"); - uiItemO(layout, NULL, 0, "CURVE_OT_separate"); - uiItemO(layout, NULL, 0, "CURVE_OT_make_segment"); - uiItemO(layout, NULL, 0, "CURVE_OT_cyclic_toggle"); - uiItemO(layout, NULL, 0, "CURVE_OT_delete"); // Delete... - - uiItemS(layout); - - uiItemMenuF(layout, "Control Points", 0, view3d_edit_curve_controlpointsmenu); - uiItemMenuF(layout, "Segments", 0, view3d_edit_curve_segmentsmenu); - - uiItemS(layout); - - uiItemR(layout, NULL, 0, &tsptr, "proportional_editing", 0, 0, 0); // |O - uiItemMenuEnumR(layout, NULL, 0, &tsptr, "proportional_editing_falloff"); // |Shift O - - uiItemS(layout); - - uiItemMenuF(layout, "Show/Hide Control Points", 0, view3d_edit_curve_showhidemenu); -} - -static void view3d_edit_metaball_showhidemenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - uiItemO(layout, NULL, 0, "MBALL_OT_hide_metaelems"); - uiItemO(layout, NULL, 0, "MBALL_OT_reveal_metaelems"); - uiItemBooleanO(layout, "Hide Unselected", 0, "MBALL_OT_hide_metaelems", "unselected", 1); -} - -static void view3d_edit_metaballmenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - Scene *scene= CTX_data_scene(C); - ToolSettings *ts= CTX_data_tool_settings(C); - PointerRNA tsptr; - - RNA_pointer_create(&scene->id, &RNA_ToolSettings, ts, &tsptr); - - uiItemO(layout, "Undo Editing", 0, "ED_OT_undo"); - uiItemO(layout, "Redo Editing", 0, "ED_OT_redo"); - - uiItemS(layout); - - uiItemMenuF(layout, "Snap", 0, view3d_edit_snapmenu); - - uiItemS(layout); - - uiItemO(layout, NULL, 0, "MBALL_OT_delete_metaelems"); - uiItemO(layout, NULL, 0, "MBALL_OT_duplicate_metaelems"); - - uiItemS(layout); - - uiItemR(layout, NULL, 0, &tsptr, "proportional_editing", 0, 0, 0); // |O - uiItemMenuEnumR(layout, NULL, 0, &tsptr, "proportional_editing_falloff"); // |Shift O - - uiItemS(layout); - - uiItemMenuF(layout, "Show/Hide Control Points", 0, view3d_edit_metaball_showhidemenu); -} - -static void view3d_edit_text_charsmenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - /* the character codes are specified in UTF-8 */ - - uiItemStringO(layout, "Copyright|Alt C", 0, "FONT_OT_text_insert", "text", "\xC2\xA9"); - uiItemStringO(layout, "Registered Trademark|Alt R", 0, "FONT_OT_text_insert", "text", "\xC2\xAE"); - - uiItemS(layout); - - uiItemStringO(layout, "Degree Sign|Alt G", 0, "FONT_OT_text_insert", "text", "\xC2\xB0"); - uiItemStringO(layout, "Multiplication Sign|Alt x", 0, "FONT_OT_text_insert", "text", "\xC3\x97"); - uiItemStringO(layout, "Circle|Alt .", 0, "FONT_OT_text_insert", "text", "\xC2\x8A"); - uiItemStringO(layout, "Superscript 1|Alt 1", 0, "FONT_OT_text_insert", "text", "\xC2\xB9"); - uiItemStringO(layout, "Superscript 2|Alt 2", 0, "FONT_OT_text_insert", "text", "\xC2\xB2"); - uiItemStringO(layout, "Superscript 3|Alt 3", 0, "FONT_OT_text_insert", "text", "\xC2\xB3"); - uiItemStringO(layout, "Double >>|Alt >", 0, "FONT_OT_text_insert", "text", "\xC2\xBB"); - uiItemStringO(layout, "Double <<|Alt <", 0, "FONT_OT_text_insert", "text", "\xC2\xAB"); - uiItemStringO(layout, "Promillage|Alt %", 0, "FONT_OT_text_insert", "text", "\xE2\x80\xB0"); - - uiItemS(layout); - - uiItemStringO(layout, "Dutch Florin|Alt F", 0, "FONT_OT_text_insert", "text", "\xC2\xA4"); - uiItemStringO(layout, "British Pound|Alt L", 0, "FONT_OT_text_insert", "text", "\xC2\xA3"); - uiItemStringO(layout, "Japanese Yen|Alt Y", 0, "FONT_OT_text_insert", "text", "\xC2\xA5"); - - uiItemS(layout); - - uiItemStringO(layout, "German S|Alt S", 0, "FONT_OT_text_insert", "text", "\xC3\x9F"); - uiItemStringO(layout, "Spanish Question Mark|Alt ?", 0, "FONT_OT_text_insert", "text", "\xC2\xBF"); - uiItemStringO(layout, "Spanish Exclamation Mark|Alt !", 0, "FONT_OT_text_insert", "text", "\xC2\xA1"); -} - -static void view3d_edit_textmenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - uiItemO(layout, NULL, 0, "FONT_OT_file_paste"); - uiItemS(layout); - uiItemMenuF(layout, "Special Characters", 0, view3d_edit_text_charsmenu); -} - -static void view3d_edit_latticemenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - Scene *scene= CTX_data_scene(C); - ToolSettings *ts= CTX_data_tool_settings(C); - PointerRNA tsptr; - - RNA_pointer_create(&scene->id, &RNA_ToolSettings, ts, &tsptr); - -#if 0 - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Undo Editing|U", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 0, ""); - - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - - uiDefIconTextBlockBut(block, view3d_transformmenu, NULL, ICON_RIGHTARROW_THIN, "Transform", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, view3d_edit_mirrormenu, NULL, ICON_RIGHTARROW_THIN, "Mirror", 0, yco-=20, menuwidth, 19, ""); -#endif - - uiItemMenuF(layout, "Snap", 0, view3d_edit_snapmenu); - - uiItemS(layout); - - // XXX uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Insert Keyframe|I", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 2, ""); - // common_insertkey(); - // XXX uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Delete Keyframe|Alt I", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 16, ""); - // common_deletekey(); - - uiItemO(layout, NULL, 0, "LATTICE_OT_make_regular"); - - uiItemS(layout); - - uiItemR(layout, NULL, 0, &tsptr, "proportional_editing", 0, 0, 0); // |O - uiItemMenuEnumR(layout, NULL, 0, &tsptr, "proportional_editing_falloff"); // |Shift O -} - - -static void view3d_edit_armature_parentmenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - uiItemO(layout, NULL, 0, "ARMATURE_OT_parent_set"); - uiItemO(layout, NULL, 0, "ARMATURE_OT_parent_clear"); -} - -static void view3d_edit_armature_rollmenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - /* 0 = 'Global', 1 = 'Cursor' */ - // TODO: keep these in sync... - uiItemEnumO(layout, "Clear Roll (Z-Axis Up)", 0, "ARMATURE_OT_calculate_roll", "type", 0); - uiItemEnumO(layout, "Roll to Cursor", 0, "ARMATURE_OT_calculate_roll", "type", 1); - - uiItemS(layout); - - uiItemEnumO(layout, "Set Roll", 0, "TFM_OT_transform", "mode", TFM_BONE_ROLL); -} - -static void view3d_edit_armature_settingsmenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - uiItemEnumO(layout, "Toggle a Setting", 0, "ARMATURE_OT_flags_set", "mode", 2); - uiItemEnumO(layout, "Enable a Setting", 0, "ARMATURE_OT_flags_set", "mode", 1); - uiItemEnumO(layout, "Disable a Setting", 0, "ARMATURE_OT_flags_set", "mode", 0); -} - -#if 0 -static void do_view3d_edit_armaturemenu(bContext *C, void *arg, int event) -{ - static short numcuts= 2; - - switch(event) { - case 0: /* Undo Editing */ - remake_editArmature(); - break; - - case 6: /* Shear */ - initTransform(TFM_SHEAR, CTX_NONE); - Transform(); - break; - case 7: /* Warp */ - initTransform(TFM_WARP, CTX_NONE); - Transform(); - case 23: /* bone sketching panel */ - add_blockhandler(curarea, VIEW3D_HANDLER_BONESKETCH, UI_PNL_UNSTOW); - break; - } -} -#endif - -static void view3d_edit_armaturemenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - Object *obedit = CTX_data_edit_object(C); - bArmature *arm= obedit->data; - -#if 0 - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Undo Editing|U", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 0, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_MENU_PANEL, "Bone Sketching|P", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 23, ""); - uiDefIconTextBlockBut(block, view3d_transformmenu, NULL, ICON_RIGHTARROW_THIN, "Transform", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, view3d_edit_mirrormenu, NULL, ICON_RIGHTARROW_THIN, "Mirror", 0, yco-=20, menuwidth, 19, ""); -#endif - uiItemMenuF(layout, "Snap", 0, view3d_edit_snapmenu); - uiItemMenuF(layout, "Bone Roll", 0, view3d_edit_armature_rollmenu); - - if (arm->drawtype == ARM_ENVELOPE) - uiItemEnumO(layout, "Scale Envelope Distance", 0, "TFM_OT_transform", "mode", TFM_BONESIZE); - else - uiItemEnumO(layout, "Scale B-Bone Width", 0, "TFM_OT_transform", "mode", TFM_BONESIZE); - - uiItemS(layout); - - uiItemO(layout, "Extrude", 0, "ARMATURE_OT_extrude"); - if (arm->flag & ARM_MIRROR_EDIT) - uiItemBooleanO(layout, "Extrude Forked", 0, "ARMATURE_OT_extrude", "forked", 1); - - uiItemO(layout, NULL, 0, "ARMATURE_OT_duplicate"); - uiItemO(layout, NULL, 0, "ARMATURE_OT_merge"); - uiItemO(layout, NULL, 0, "ARMATURE_OT_fill"); - uiItemO(layout, NULL, 0, "ARMATURE_OT_delete"); - uiItemO(layout, NULL, 0, "ARMATURE_OT_separate"); - - uiItemS(layout); - - uiItemO(layout, NULL, 0, "ARMATURE_OT_subdivide_simple"); - uiItemO(layout, NULL, 0, "ARMATURE_OT_subdivide_multi"); - - uiItemEnumO(layout, "AutoName Left/Right", 0, "ARMATURE_OT_autoside_names", "axis", 0); - uiItemEnumO(layout, "AutoName Front/Back", 0, "ARMATURE_OT_autoside_names", "axis", 1); - uiItemEnumO(layout, "AutoName Top/Bottom", 0, "ARMATURE_OT_autoside_names", "axis", 2); - - uiItemO(layout, "Flip Left/Right Names", 0, "ARMATURE_OT_flip_names"); - - uiItemS(layout); - - uiItemO(layout, NULL, 0, "ARMATURE_OT_armature_layers"); - uiItemO(layout, NULL, 0, "ARMATURE_OT_bone_layers"); - - uiItemS(layout); - - uiItemMenuF(layout, "Parent", 0, view3d_edit_armature_parentmenu); - - uiItemS(layout); - - uiItemMenuF(layout, "Bone Settings ", 0, view3d_edit_armature_settingsmenu); -} - - -static void view3d_pose_armature_transformmenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - //uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Clear User Transform|W", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 4, ""); - //used: clear_user_transform(scene, ob); - //uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - - uiItemO(layout, NULL, 0, "POSE_OT_loc_clear"); - uiItemO(layout, NULL, 0, "POSE_OT_rot_clear"); - uiItemO(layout, NULL, 0, "POSE_OT_scale_clear"); - - // ??? - //uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Clear Origin|Alt O", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 0, ""); - //used:clear_object('o'); -} - -static void view3d_pose_armature_showhidemenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - uiItemO(layout, "Show Hidden", 0, "POSE_OT_reveal"); - - uiItemO(layout, "Hide Selected", 0, "POSE_OT_hide"); - uiItemBooleanO(layout, "Hide Unselected", 0, "POSE_OT_hide", "unselected", 1); -} - -static void view3d_pose_armature_ikmenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - uiItemO(layout, NULL, 0, "POSE_OT_ik_add"); - uiItemO(layout, NULL, 0, "POSE_OT_ik_clear"); -} - -static void view3d_pose_armature_constraintsmenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - uiItemO(layout, NULL, 0, "POSE_OT_constraint_add_with_targets"); - uiItemO(layout, NULL, 0, "POSE_OT_constraints_clear"); -} - -static void view3d_pose_armature_groupmenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - uiItemO(layout, "Add Selected to Active Group", 0, "POSE_OT_group_assign"); - //uiItemO(layout, "Add Selected to Group", 0, "POSE_OT_group_assign"); - - uiItemO(layout, "Add New Group", 0, "POSE_OT_group_add"); - - uiItemO(layout, "Remove from All Groups", 0, "POSE_OT_group_unassign"); - uiItemO(layout, "Remove Active Group", 0, "POSE_OT_group_remove"); -} - -static void view3d_pose_armature_motionpathsmenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - uiItemO(layout, NULL, 0, "POSE_OT_paths_calculate"); - uiItemO(layout, NULL, 0, "POSE_OT_paths_clear"); -} - -static void view3d_pose_armature_poselibmenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - uiItemO(layout, NULL, 0, "POSELIB_OT_browse_interactive"); - - uiItemS(layout); - - uiItemO(layout, NULL, 0, "POSELIB_OT_pose_add"); - uiItemO(layout, NULL, 0, "POSELIB_OT_pose_rename"); - uiItemO(layout, NULL, 0, "POSELIB_OT_pose_remove"); -} - -static void view3d_pose_armature_settingsmenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - uiItemEnumO(layout, "Toggle a Setting", 0, "POSE_OT_flags_set", "mode", 2); - uiItemEnumO(layout, "Enable a Setting", 0, "POSE_OT_flags_set", "mode", 1); - uiItemEnumO(layout, "Disable a Setting", 0, "POSE_OT_flags_set", "mode", 0); -} - -#if 0 -static void do_view3d_pose_armaturemenu(bContext *C, void *arg, int event) -{ - Object *ob; - ob=OBACT; - - switch(event) { - case 5: - pose_copy_menu(); - break; - case 15: - pose_relax(); - break; - } -} -#endif - -static void view3d_pose_armaturemenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - Object *ob = CTX_data_active_object(C); - bArmature *arm= ob->data; - -#if 0 // XXX to be ported, using uiItemMenuF(layout, "<Name>", 0, view3d_pose_armature_<category>menu); - uiDefIconTextBlockBut(block, view3d_transformmenu, NULL, ICON_RIGHTARROW_THIN, "Transform", 0, yco-=20, 120, 19, ""); -#endif - if ( (arm) && ((arm->drawtype == ARM_B_BONE) || (arm->drawtype == ARM_ENVELOPE)) ) - uiItemEnumO(layout, "Scale Envelope Distance", 0, "TFM_OT_transform", "mode", TFM_BONESIZE); - uiItemMenuF(layout, "Clear Transform", 0, view3d_pose_armature_transformmenu); - - uiItemS(layout); - - // TODO: these operators may get renamed - uiItemO(layout, NULL, 0, "ANIM_OT_insert_keyframe_menu"); - uiItemO(layout, NULL, 0, "ANIM_OT_delete_keyframe_v3d"); - - uiItemS(layout); - -#if 0 - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Relax Pose|W", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 15, ""); -#endif - uiItemO(layout, NULL, 0, "POSE_OT_apply"); - - uiItemS(layout); - - uiItemO(layout, "Copy Current Pose", 0, "POSE_OT_copy"); - uiItemO(layout, "Paste Pose", 0, "POSE_OT_paste"); - uiItemBooleanO(layout, "Paste X-Flipped Pose", 0, "POSE_OT_paste", "flipped", 1); - - uiItemS(layout); - - uiItemMenuF(layout, "Pose Library", 0, view3d_pose_armature_poselibmenu); - uiItemMenuF(layout, "Motion Paths", 0, view3d_pose_armature_motionpathsmenu); - uiItemMenuF(layout, "Bone Groups", 0, view3d_pose_armature_groupmenu); - - uiItemS(layout); - - uiItemMenuF(layout, "Inverse Kinematics", 0, view3d_pose_armature_ikmenu); - uiItemMenuF(layout, "Constraints", 0, view3d_pose_armature_constraintsmenu); - - uiItemS(layout); - - uiItemEnumO(layout, "AutoName Left/Right", 0, "POSE_OT_autoside_names", "axis", 0); - uiItemEnumO(layout, "AutoName Front/Back", 0, "POSE_OT_autoside_names", "axis", 1); - uiItemEnumO(layout, "AutoName Top/Bottom", 0, "POSE_OT_autoside_names", "axis", 2); - - uiItemO(layout, "Flip Left/Right Names", 0, "POSE_OT_flip_names"); - - uiItemS(layout); - - uiItemO(layout, NULL, 0, "POSE_OT_armature_layers"); - uiItemO(layout, NULL, 0, "POSE_OT_bone_layers"); - - uiItemS(layout); - - uiItemMenuF(layout, "Show/Hide Bones", 0, view3d_pose_armature_showhidemenu); - uiItemMenuF(layout, "Bone Settings", 0, view3d_pose_armature_settingsmenu); - -#if 0 - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Copy Attributes...|Ctrl C", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 5, ""); -#endif -} - - -/* vertex paint menu */ -static void do_view3d_vpaintmenu(bContext *C, void *arg, int event) -{ -#if 0 - /* events >= 3 are registered bpython scripts */ -#ifndef DISABLE_PYTHON - if (event >= 3) BPY_menu_do_python(PYMENU_VERTEXPAINT, event - 3); -#endif - switch(event) { - case 0: /* undo vertex painting */ - BIF_undo(); - break; - case 1: /* set vertex colors/weight */ - if(FACESEL_PAINT_TEST) - clear_vpaint_selectedfaces(); - else /* we know were in vertex paint mode */ - clear_vpaint(); - break; - case 2: - make_vertexcol(1); - break; - } -#endif -} - -static uiBlock *view3d_vpaintmenu(bContext *C, ARegion *ar, void *arg_unused) -{ - uiBlock *block; - short yco= 0, menuwidth=120; -#ifndef DISABLE_PYTHON -// XXX BPyMenu *pym; -// int i=0; -#endif - - block= uiBeginBlock(C, ar, "view3d_paintmenu", UI_EMBOSSP); - uiBlockSetButmFunc(block, do_view3d_vpaintmenu, NULL); - - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Undo Vertex Painting|U", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 0, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Set Vertex Colors|Shift K", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 1, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Set Shaded Vertex Colors", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 2, ""); - -#ifndef DISABLE_PYTHON - /* note that we account for the 3 previous entries with i+3: - even if the last item isnt displayed, it dosent matter */ -// for (pym = BPyMenuTable[PYMENU_VERTEXPAINT]; pym; pym = pym->next, i++) { -// uiDefIconTextBut(block, BUTM, 1, ICON_PYTHON, pym->name, 0, yco-=20, -// menuwidth, 19, NULL, 0.0, 0.0, 1, i+3, -// pym->tooltip?pym->tooltip:pym->filename); -// } -#endif - - if(ar->alignment==RGN_ALIGN_TOP) { - uiBlockSetDirection(block, UI_DOWN); - } - else { - uiBlockSetDirection(block, UI_TOP); - uiBlockFlipOrder(block); - } - - uiTextBoundsBlock(block, 50); - return block; -} - /* texture paint menu (placeholder, no items yet??) */ static void do_view3d_tpaintmenu(bContext *C, void *arg, int event) @@ -3032,7 +1425,7 @@ static uiBlock *view3d_wpaintmenu(bContext *C, ARegion *ar, void *arg_unused) uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - if (FACESEL_PAINT_TEST) { + if (paint_facesel_test(CTX_data_active_object(C))) { uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Set Weight|Shift K", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 1, ""); uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); menunr++; @@ -3060,185 +1453,6 @@ static uiBlock *view3d_wpaintmenu(bContext *C, ARegion *ar, void *arg_unused) return block; } -void do_view3d_sculpt_inputmenu(bContext *C, void *arg, int event) -{ -#if 0 - Scene *scene= CTX_data_scene(C); - SculptData *sd= &scene->sculptdata; - short val; - - switch(event) { - case 0: - sd->flags ^= SCULPT_INPUT_SMOOTH; - ED_undo_push(C, "Smooth stroke"); - break; - case 1: - val= sd->tablet_size; - if(button(&val,0,10,"Tablet Size:")==0) return; - sd->tablet_size= val; - ED_undo_push(C, "Tablet size"); - break; - case 2: - val= sd->tablet_strength; - if(button(&val,0,10,"Tablet Strength:")==0) return; - sd->tablet_strength= val; - ED_undo_push(C, "Tablet strength"); - break; - } - -#endif -} - -void do_view3d_sculptmenu(bContext *C, void *arg, int event) -{ -#if 0 - Scene *scene= CTX_data_scene(C); - ScrArea *sa= CTX_wm_area(C); - View3D *v3d= sa->spacedata.first; - SculptData *sd= &scene->sculptdata; - BrushData *br= sculptmode_brush(); - - switch(event) { - case 0: - case 1: - case 2: - case 3: - case 4: - case 5: - case 6: - sd->brush_type= event+1; - ED_undo_push(C, "Brush type"); - break; - case 11: - if(v3d) - v3d->pivot_last= !v3d->pivot_last; - break; - case 12: - sd->flags ^= SCULPT_DRAW_FAST; - ED_undo_push(C, "Partial Redraw"); - break; - case 13: - sd->flags ^= SCULPT_DRAW_BRUSH; - ED_undo_push(C, "Draw Brush"); - break; - case 14: - add_blockhandler(sa, VIEW3D_HANDLER_OBJECT, UI_PNL_UNSTOW); - break; - case 15: - sculpt_radialcontrol_start(RADIALCONTROL_ROTATION); - break; - case 16: - sculpt_radialcontrol_start(RADIALCONTROL_STRENGTH); - break; - case 17: - sculpt_radialcontrol_start(RADIALCONTROL_SIZE); - break; -#endif -} - -uiBlock *view3d_sculpt_inputmenu(bContext *C, ARegion *ar, void *arg_unused) -{ - uiBlock *block; - short yco= 0, menuwidth= 120; - Sculpt *sd= CTX_data_tool_settings(C)->sculpt; - - block= uiBeginBlock(C, ar, "view3d_sculpt_inputmenu", UI_EMBOSSP); - uiBlockSetButmFunc(block, do_view3d_sculpt_inputmenu, NULL); - - uiDefIconTextBut(block, BUTM, 1, ((sd->flags & SCULPT_INPUT_SMOOTH) ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT), "Smooth Stroke|Shift S", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 0, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Tablet Size Adjust", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 1, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Tablet Strength Adjust", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 2, ""); - - uiBlockSetDirection(block, UI_RIGHT); - uiTextBoundsBlock(block, 50); - return block; -} - -static void view3d_sculpt_menu(bContext *C, uiLayout *layout, void *arg_unused) -{ - bScreen *sc= CTX_wm_screen(C); - Sculpt *s = CTX_data_tool_settings(C)->sculpt; - PointerRNA rna; - - RNA_pointer_create(&sc->id, &RNA_Sculpt, s, &rna); - - uiItemR(layout, NULL, 0, &rna, "symmetry_x", 0, 0, 0); - uiItemR(layout, NULL, 0, &rna, "symmetry_y", 0, 0, 0); - uiItemR(layout, NULL, 0, &rna, "symmetry_z", 0, 0, 0); - uiItemR(layout, NULL, 0, &rna, "lock_x", 0, 0, 0); - uiItemR(layout, NULL, 0, &rna, "lock_y", 0, 0, 0); - uiItemR(layout, NULL, 0, &rna, "lock_z", 0, 0, 0); - - /* Brush settings */ - RNA_pointer_create(&sc->id, &RNA_Brush, s->brush, &rna); - - /* Curve */ - uiItemS(layout); - uiItemEnumO(layout, NULL, 0, "SCULPT_OT_brush_curve_preset", "mode", BRUSH_PRESET_SHARP); - uiItemEnumO(layout, NULL, 0, "SCULPT_OT_brush_curve_preset", "mode", BRUSH_PRESET_SMOOTH); - uiItemEnumO(layout, NULL, 0, "SCULPT_OT_brush_curve_preset", "mode", BRUSH_PRESET_MAX); - - uiItemS(layout); - - uiItemR(layout, NULL, 0, &rna, "airbrush", 0, 0, 0); - uiItemR(layout, NULL, 0, &rna, "rake", 0, 0, 0); - uiItemR(layout, NULL, 0, &rna, "anchored", 0, 0, 0); - uiItemR(layout, NULL, 0, &rna, "space", 0, 0, 0); - uiItemR(layout, NULL, 0, &rna, "smooth_stroke", 0, 0, 0); - - uiItemR(layout, NULL, 0, &rna, "flip_direction", 0, 0, 0); -} - -uiBlock *view3d_sculptmenu(bContext *C, ARegion *ar, void *arg_unused) -{ - ScrArea *sa= CTX_wm_area(C); - View3D *v3d= sa->spacedata.first; - uiBlock *block; - Sculpt *sd= CTX_data_tool_settings(C)->sculpt; -// XXX const BrushData *br= sculptmode_brush(); - short yco= 0, menuwidth= 120; - - block= uiBeginBlock(C, ar, "view3d_sculptmenu", UI_EMBOSSP); - uiBlockSetButmFunc(block, do_view3d_sculptmenu, NULL); - - uiDefIconTextBut(block, BUTM, 1, ICON_MENU_PANEL, "Sculpt Properties|N", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 14, ""); - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - uiDefIconTextBlockBut(block, view3d_sculpt_inputmenu, NULL, ICON_RIGHTARROW_THIN, "Input Settings", 0, yco-=20, 120, 19, ""); - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - uiDefIconTextBut(block, BUTM, 1, ((sd->flags & SCULPT_DRAW_BRUSH) ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT), "Display Brush", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 13, ""); - uiDefIconTextBut(block, BUTM, 1, ((sd->flags & SCULPT_DRAW_FAST) ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT), "Partial Redraw", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 12, ""); - if(v3d) - uiDefIconTextBut(block, BUTM, 1, (v3d->pivot_last ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT), "Pivot Last", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 11, ""); - - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Scale Brush|F", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 17, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Strengthen Brush|Shift F", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 16, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Rotate Brush|Ctrl F", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 15, ""); - - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - /* XXX uiDefIconTextBut(block, BUTM, 1, (sd->brush_type==FLATTEN_BRUSH ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT), "Flatten|T", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 6, ""); - uiDefIconTextBut(block, BUTM, 1, (sd->brush_type==LAYER_BRUSH ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT), "Layer|L", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 5, ""); - uiDefIconTextBut(block, BUTM, 1, (sd->brush_type==GRAB_BRUSH ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT), "Grab|G", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 4, ""); - uiDefIconTextBut(block, BUTM, 1, (sd->brush_type==INFLATE_BRUSH ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT), "Inflate|I", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 3, ""); - uiDefIconTextBut(block, BUTM, 1, (sd->brush_type==PINCH_BRUSH ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT), "Pinch|P", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 2, ""); - uiDefIconTextBut(block, BUTM, 1, (sd->brush_type==SMOOTH_BRUSH ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT), "Smooth|S", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 1, ""); - uiDefIconTextBut(block, BUTM, 1, (sd->brush_type==DRAW_BRUSH ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT), "Draw|D", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 0, "");*/ - - - if(ar->alignment==RGN_ALIGN_TOP) { - uiBlockSetDirection(block, UI_DOWN); - } - else { - uiBlockSetDirection(block, UI_TOP); - uiBlockFlipOrder(block); - } - - uiTextBoundsBlock(block, 50); - - return block; -} - static void do_view3d_facesel_showhidemenu(bContext *C, void *arg, int event) { #if 0 @@ -3323,61 +1537,6 @@ static uiBlock *view3d_faceselmenu(bContext *C, ARegion *ar, void *arg_unused) return block; } -static void view3d_select_particlemenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - ToolSettings *ts= CTX_data_tool_settings(C); - - uiItemO(layout, NULL, 0, "VIEW3D_OT_select_border"); - - uiItemS(layout); - - uiItemO(layout, NULL, 0, "PARTICLE_OT_select_all_toggle"); - uiItemO(layout, NULL, 0, "PARTICLE_OT_select_linked"); - - if(ts->particle.selectmode & SCE_SELECT_POINT) { - uiItemO(layout, NULL, 0, "PARTICLE_OT_select_last"); // |W, 4 - uiItemO(layout, NULL, 0, "PARTICLE_OT_select_first"); // |W, 3 - } - - uiItemS(layout); - - uiItemO(layout, NULL, 0, "PARTICLE_OT_select_more"); - uiItemO(layout, NULL, 0, "PARTICLE_OT_select_less"); -} - -static void view3d_particle_showhidemenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - uiItemO(layout, NULL, 0, "PARTICLE_OT_reveal"); - uiItemO(layout, NULL, 0, "PARTICLE_OT_hide"); - uiItemBooleanO(layout, "Hide Unselected", 0, "PARTICLE_OT_hide", "unselected", 1); -} - -static void view3d_particlemenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - ToolSettings *ts= CTX_data_tool_settings(C); - - // XXX uiDefIconTextBut(block, BUTM, 1, ICON_MENU_PANEL, "Particle Edit Properties|N", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 1, ""); - // add_blockhandler(sa, VIEW3D_HANDLER_OBJECT, UI_PNL_UNSTOW); - // XXX uiItemS(layout); - // - // XXX uiDefIconTextBut(block, BUTM, 1, (pset->flag & PE_X_MIRROR)? ICON_CHECKBOX_HLT: ICON_CHECKBOX_DEHLT, "X-Axis Mirror Editing", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 6, ""); - // pset->flag ^= PE_X_MIRROR; - - uiItemO(layout, NULL, 0, "PARTICLE_OT_mirror"); // |Ctrl M - - uiItemS(layout); - - uiItemO(layout, NULL, 0, "PARTICLE_OT_remove_doubles"); // |W, 5 - uiItemO(layout, NULL, 0, "PARTICLE_OT_delete"); - if(ts->particle.selectmode & SCE_SELECT_POINT) - uiItemO(layout, NULL, 0, "PARTICLE_OT_subdivide"); // |W, 2 - uiItemO(layout, NULL, 0, "PARTICLE_OT_rekey"); // |W, 1 - - uiItemS(layout); - - uiItemMenuF(layout, "Show/Hide Particles", 0, view3d_particle_showhidemenu); -} - static char *view3d_modeselect_pup(Scene *scene) { Object *ob= OBACT; @@ -3387,10 +1546,7 @@ static char *view3d_modeselect_pup(Scene *scene) str += sprintf(str, "Mode: %%t"); - if(ob) - str += sprintf(str, formatstr, "Object Mode", V3D_OBJECTMODE_SEL, ICON_OBJECT_DATA); - else - str += sprintf(str, formatstr, "Object Mode", V3D_OBJECTMODE_SEL, ICON_OBJECT_DATA); + str += sprintf(str, formatstr, "Object Mode", OB_MODE_OBJECT, ICON_OBJECT_DATA); if(ob==NULL) return string; @@ -3399,26 +1555,25 @@ static char *view3d_modeselect_pup(Scene *scene) || (ob->type == OB_CURVE) || (ob->type == OB_SURF) || (ob->type == OB_FONT) || (ob->type == OB_MBALL) || (ob->type == OB_LATTICE))) { - str += sprintf(str, formatstr, "Edit Mode", V3D_EDITMODE_SEL, ICON_EDITMODE_HLT); + str += sprintf(str, formatstr, "Edit Mode", OB_MODE_EDIT, ICON_EDITMODE_HLT); } if (ob->type == OB_MESH) { - str += sprintf(str, formatstr, "Sculpt Mode", V3D_SCULPTMODE_SEL, ICON_SCULPTMODE_HLT); - /*str += sprintf(str, formatstr, "Face Select", V3D_FACESELECTMODE_SEL, ICON_FACESEL_HLT);*/ - str += sprintf(str, formatstr, "Vertex Paint", V3D_VERTEXPAINTMODE_SEL, ICON_VPAINT_HLT); - str += sprintf(str, formatstr, "Texture Paint", V3D_TEXTUREPAINTMODE_SEL, ICON_TPAINT_HLT); - str += sprintf(str, formatstr, "Weight Paint", V3D_WEIGHTPAINTMODE_SEL, ICON_WPAINT_HLT); + str += sprintf(str, formatstr, "Sculpt Mode", OB_MODE_SCULPT, ICON_SCULPTMODE_HLT); + str += sprintf(str, formatstr, "Vertex Paint", OB_MODE_VERTEX_PAINT, ICON_VPAINT_HLT); + str += sprintf(str, formatstr, "Texture Paint", OB_MODE_TEXTURE_PAINT, ICON_TPAINT_HLT); + str += sprintf(str, formatstr, "Weight Paint", OB_MODE_WEIGHT_PAINT, ICON_WPAINT_HLT); } /* if active object is an armature */ if (ob->type==OB_ARMATURE) { - str += sprintf(str, formatstr, "Pose Mode", V3D_POSEMODE_SEL, ICON_POSE_HLT); + str += sprintf(str, formatstr, "Pose Mode", OB_MODE_POSE, ICON_POSE_HLT); } if (ob->particlesystem.first) { - str += sprintf(str, formatstr, "Particle Mode", V3D_PARTICLEEDITMODE_SEL, ICON_PARTICLEMODE); + str += sprintf(str, formatstr, "Particle Mode", OB_MODE_PARTICLE_EDIT, ICON_PARTICLEMODE); } return (string); @@ -3506,11 +1661,10 @@ static void do_view3d_header_buttons(bContext *C, void *arg, int event) ToolSettings *ts= CTX_data_tool_settings(C); ScrArea *sa= CTX_wm_area(C); View3D *v3d= sa->spacedata.first; - Base *basact= CTX_data_active_base(C); - Object *ob= CTX_data_active_object(C); Object *obedit = CTX_data_edit_object(C); BMEditMesh *em= NULL; int bit, ctrl= win->eventstate->ctrl, shift= win->eventstate->shift; + PointerRNA props_ptr; if(obedit && obedit->type==OB_MESH) { em= ((Mesh *)obedit->data)->edit_btmesh; @@ -3557,79 +1711,10 @@ static void do_view3d_header_buttons(bContext *C, void *arg, int event) // XXX start_game(); break; case B_MODESELECT: - if (v3d->modeselect == V3D_OBJECTMODE_SEL) { - - v3d->flag &= ~V3D_MODE; - ED_view3d_exit_paint_modes(C); - ED_armature_exit_posemode(C, basact); - if(obedit) - ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR); /* exit editmode and undo */ - } - else if (v3d->modeselect == V3D_EDITMODE_SEL) { - if(!obedit) { - v3d->flag &= ~V3D_MODE; - ED_object_enter_editmode(C, EM_WAITCURSOR); - ED_undo_push(C, "Original"); /* here, because all over code enter_editmode is abused */ - } - } - else if (v3d->modeselect == V3D_SCULPTMODE_SEL) { - if (!(G.f & G_SCULPTMODE)) { - v3d->flag &= ~V3D_MODE; - ED_view3d_exit_paint_modes(C); - if(obedit) ED_object_exit_editmode(C, EM_FREEUNDO|EM_FREEUNDO|EM_WAITCURSOR); /* exit editmode and undo */ - - WM_operator_name_call(C, "SCULPT_OT_sculptmode_toggle", WM_OP_EXEC_REGION_WIN, NULL); - } - } - else if (v3d->modeselect == V3D_VERTEXPAINTMODE_SEL) { - if (!(G.f & G_VERTEXPAINT)) { - v3d->flag &= ~V3D_MODE; - ED_view3d_exit_paint_modes(C); - if(obedit) ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR); /* exit editmode and undo */ - - WM_operator_name_call(C, "PAINT_OT_vertex_paint_toggle", WM_OP_EXEC_REGION_WIN, NULL); - } - } - else if (v3d->modeselect == V3D_TEXTUREPAINTMODE_SEL) { - if (!(G.f & G_TEXTUREPAINT)) { - v3d->flag &= ~V3D_MODE; - ED_view3d_exit_paint_modes(C); - if(obedit) ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR); /* exit editmode and undo */ - - WM_operator_name_call(C, "PAINT_OT_texture_paint_toggle", WM_OP_EXEC_REGION_WIN, NULL); - } - } - else if (v3d->modeselect == V3D_WEIGHTPAINTMODE_SEL) { - if (!(G.f & G_WEIGHTPAINT) && (ob && ob->type == OB_MESH) ) { - v3d->flag &= ~V3D_MODE; - ED_view3d_exit_paint_modes(C); - if(obedit) - ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR); /* exit editmode and undo */ - - WM_operator_name_call(C, "PAINT_OT_weight_paint_toggle", WM_OP_EXEC_REGION_WIN, NULL); - } - } - else if (v3d->modeselect == V3D_POSEMODE_SEL) { - - if (ob) { - v3d->flag &= ~V3D_MODE; - if(obedit) - ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR); /* exit editmode and undo */ - - ED_armature_enter_posemode(C, basact); - } - } - else if(v3d->modeselect == V3D_PARTICLEEDITMODE_SEL){ - if (!(G.f & G_PARTICLEEDIT)) { - v3d->flag &= ~V3D_MODE; - ED_view3d_exit_paint_modes(C); - if(obedit) ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR); /* exit editmode and undo */ - - WM_operator_name_call(C, "PARTICLE_OT_particle_edit_toggle", WM_OP_EXEC_REGION_WIN, NULL); - } - } - break; - + WM_operator_properties_create(&props_ptr, "OBJECT_OT_mode_set"); + RNA_enum_set(&props_ptr, "mode", v3d->modeselect); + WM_operator_name_call(C, "OBJECT_OT_mode_set", WM_OP_EXEC_REGION_WIN, &props_ptr); + break; case B_AROUND: // XXX handle_view3d_around(); /* copies to other 3d windows */ break; @@ -3689,20 +1774,20 @@ static void do_view3d_header_buttons(bContext *C, void *arg, int event) case B_MAN_TRANS: if( shift==0 || v3d->twtype==0) { v3d->twtype= V3D_MANIP_TRANSLATE; - ED_area_tag_redraw(sa); } - break; + ED_area_tag_redraw(sa); + break; case B_MAN_ROT: if( shift==0 || v3d->twtype==0) { - v3d->twtype= V3D_MANIP_ROTATE; - ED_area_tag_redraw(sa); + v3d->twtype= V3D_MANIP_ROTATE; } + ED_area_tag_redraw(sa); break; case B_MAN_SCALE: if( shift==0 || v3d->twtype==0) { - v3d->twtype= V3D_MANIP_SCALE; - ED_area_tag_redraw(sa); + v3d->twtype= V3D_MANIP_SCALE; } + ED_area_tag_redraw(sa); break; case B_NDOF: break; @@ -3769,111 +1854,34 @@ static void view3d_header_pulldowns(const bContext *C, uiBlock *block, Object *o * height of the header */ xmax= GetButStringLength("Select"); - if (obedit) { - if (ob && ob->type == OB_MESH) { - uiDefMenuBut(block, view3d_select_meshmenu, NULL, "Select", xco,yco, xmax-3, 20, ""); - } else if (ob && (ob->type == OB_CURVE || ob->type == OB_SURF)) { - uiDefMenuBut(block, view3d_select_curvemenu, NULL, "Select", xco, yco, xmax-3, 20, ""); - } else if (ob && ob->type == OB_FONT) { - xmax= 0; - } else if (ob && ob->type == OB_MBALL) { - uiDefMenuBut(block, view3d_select_metaballmenu, NULL, "Select", xco,yco, xmax-3, 20, ""); - } else if (ob && ob->type == OB_LATTICE) { - uiDefMenuBut(block, view3d_select_latticemenu, NULL, "Select", xco, yco, xmax-3, 20, ""); - } else if (ob && ob->type == OB_ARMATURE) { - uiDefMenuBut(block, view3d_select_armaturemenu, NULL, "Select", xco,yco, xmax-3, 20, ""); - } - } else if (FACESEL_PAINT_TEST) { - if (ob && ob->type == OB_MESH) { - uiDefPulldownBut(block, view3d_select_faceselmenu, NULL, "Select", xco,yco, xmax-3, 20, ""); - } - } else if ((G.f & G_VERTEXPAINT) || (G.f & G_TEXTUREPAINT) || (G.f & G_WEIGHTPAINT)) { - uiDefBut(block, LABEL,0,"", xco, 0, xmax, 20, 0, 0, 0, 0, 0, ""); - } else if (G.f & G_PARTICLEEDIT) { - uiDefMenuBut(block, view3d_select_particlemenu, NULL, "Select", xco,yco, xmax-3, 20, ""); - } else { - - if (ob && (ob->flag & OB_POSEMODE)) - uiDefMenuBut(block, view3d_select_posemenu, NULL, "Select", xco,yco, xmax-3, 20, ""); - else - uiDefMenuBut(block, view3d_select_objectmenu, NULL, "Select", xco,yco, xmax-3, 20, ""); - } + xco+= xmax; if (obedit) { - if (ob && ob->type == OB_MESH) { - xmax= GetButStringLength("Mesh"); - uiDefMenuBut(block, view3d_edit_meshmenu, NULL, "Mesh", xco,yco, xmax-3, 20, ""); - xco+= xmax; - } else if (ob && ob->type == OB_CURVE) { - xmax= GetButStringLength("Curve"); - uiDefMenuBut(block, view3d_edit_curvemenu, NULL, "Curve", xco, yco, xmax-3, 20, ""); - xco+= xmax; - } else if (ob && ob->type == OB_SURF) { - xmax= GetButStringLength("Surface"); - uiDefMenuBut(block, view3d_edit_curvemenu, NULL, "Surface", xco, yco, xmax-3, 20, ""); - xco+= xmax; - } else if (ob && ob->type == OB_FONT) { - xmax= GetButStringLength("Text"); - uiDefMenuBut(block, view3d_edit_textmenu, NULL, "Text", xco, yco, xmax-3, 20, ""); - xco+= xmax; - } else if (ob && ob->type == OB_MBALL) { - xmax= GetButStringLength("Metaball"); - uiDefMenuBut(block, view3d_edit_metaballmenu, NULL, "Metaball", xco,yco, xmax-3, 20, ""); - xco+= xmax; - } else if (ob && ob->type == OB_LATTICE) { - xmax= GetButStringLength("Lattice"); - uiDefMenuBut(block, view3d_edit_latticemenu, NULL, "Lattice", xco, yco, xmax-3, 20, ""); - xco+= xmax; - } else if (ob && ob->type == OB_ARMATURE) { - xmax= GetButStringLength("Armature"); - uiDefMenuBut(block, view3d_edit_armaturemenu, NULL, "Armature", xco,yco, xmax-3, 20, ""); - xco+= xmax; - } - } - else if (G.f & G_WEIGHTPAINT) { + else if (ob && ob->mode & OB_MODE_WEIGHT_PAINT) { xmax= GetButStringLength("Paint"); uiDefPulldownBut(block, view3d_wpaintmenu, NULL, "Paint", xco,yco, xmax-3, 20, ""); xco+= xmax; } - else if (G.f & G_VERTEXPAINT) { - xmax= GetButStringLength("Paint"); - uiDefPulldownBut(block, view3d_vpaintmenu, NULL, "Paint", xco,yco, xmax-3, 20, ""); - xco+= xmax; - } - else if (G.f & G_TEXTUREPAINT) { + else if (ob && ob->mode & OB_MODE_TEXTURE_PAINT) { xmax= GetButStringLength("Paint"); uiDefPulldownBut(block, view3d_tpaintmenu, NULL, "Paint", xco,yco, xmax-3, 20, ""); xco+= xmax; } - else if( G.f & G_SCULPTMODE) { - xmax= GetButStringLength("Sculpt"); - uiDefMenuBut(block, view3d_sculpt_menu, NULL, "Sculpt", xco, yco, xmax-3, 20, ""); - xco+= xmax; - } - else if (FACESEL_PAINT_TEST) { + else if (paint_facesel_test(ob)) { if (ob && ob->type == OB_MESH) { xmax= GetButStringLength("Face"); uiDefPulldownBut(block, view3d_faceselmenu, NULL, "Face", xco,yco, xmax-3, 20, ""); xco+= xmax; } } - else if(G.f & G_PARTICLEEDIT) { - xmax= GetButStringLength("Particle"); - uiDefMenuBut(block, view3d_particlemenu, NULL, "Particle", xco,yco, xmax-3, 20, ""); - xco+= xmax; + else if(ob && ob->mode & OB_MODE_PARTICLE_EDIT) { + /* ported to python */ } else { - if (ob && (ob->flag & OB_POSEMODE)) { - xmax= GetButStringLength("Pose"); - uiDefMenuBut(block, view3d_pose_armaturemenu, NULL, "Pose", xco,yco, xmax-3, 20, ""); - xco+= xmax; - } - else { - xmax= GetButStringLength("Object"); - uiDefMenuBut(block, view3d_edit_objectmenu, NULL, "Object", xco,yco, xmax-3, 20, ""); - xco+= xmax; + if (ob && (ob->mode & OB_MODE_POSE)) { + /* ported to python */ } } @@ -3903,6 +1911,20 @@ static void header_xco_step(ARegion *ar, int *xco, int *yco, int *maxco, int ste } } +/* Returns the icon associated with an object mode */ +static int object_mode_icon(int mode) +{ + EnumPropertyItem *item = object_mode_items; + + while(item->name != NULL) { + if(item->value == mode) + return item->icon; + ++item; + } + + return ICON_OBJECT_DATAMODE; +} + void uiTemplateHeader3D(uiLayout *layout, struct bContext *C) { ARegion *ar= CTX_wm_region(C); @@ -3925,29 +1947,23 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C) uiBlockSetEmboss(block, UI_EMBOSS); /* mode */ - v3d->modeselect = V3D_OBJECTMODE_SEL; - - if (obedit) v3d->modeselect = V3D_EDITMODE_SEL; - else if(ob && (ob->flag & OB_POSEMODE)) v3d->modeselect = V3D_POSEMODE_SEL; - else if (G.f & G_SCULPTMODE) v3d->modeselect = V3D_SCULPTMODE_SEL; - else if (G.f & G_WEIGHTPAINT) v3d->modeselect = V3D_WEIGHTPAINTMODE_SEL; - else if (G.f & G_VERTEXPAINT) v3d->modeselect = V3D_VERTEXPAINTMODE_SEL; - else if (G.f & G_TEXTUREPAINT) v3d->modeselect = V3D_TEXTUREPAINTMODE_SEL; - /*else if(G.f & G_FACESELECT) v3d->modeselect = V3D_FACESELECTMODE_SEL;*/ - else if(G.f & G_PARTICLEEDIT) v3d->modeselect = V3D_PARTICLEEDITMODE_SEL; + if(ob) + v3d->modeselect = ob->mode; + else + v3d->modeselect = OB_MODE_OBJECT; v3d->flag &= ~V3D_MODE; /* not sure what the v3d->flag is useful for now... modeselect is confusing */ if(obedit) v3d->flag |= V3D_EDITMODE; - if(ob && (ob->flag & OB_POSEMODE)) v3d->flag |= V3D_POSEMODE; - if(G.f & G_VERTEXPAINT) v3d->flag |= V3D_VERTEXPAINT; - if(G.f & G_WEIGHTPAINT) v3d->flag |= V3D_WEIGHTPAINT; - if (G.f & G_TEXTUREPAINT) v3d->flag |= V3D_TEXTUREPAINT; - if(FACESEL_PAINT_TEST) v3d->flag |= V3D_FACESELECT; - - uiDefIconTextButS(block, MENU, B_MODESELECT, (v3d->modeselect),view3d_modeselect_pup(scene) , - xco,yco,126,20, &(v3d->modeselect), 0, 0, 0, 0, "Mode (Hotkeys: Tab, V, Ctrl Tab)"); + if(ob && (ob->mode & OB_MODE_POSE)) v3d->flag |= V3D_POSEMODE; + if(ob && (ob->mode & OB_MODE_VERTEX_PAINT)) v3d->flag |= V3D_VERTEXPAINT; + if(ob && (ob->mode & OB_MODE_WEIGHT_PAINT)) v3d->flag |= V3D_WEIGHTPAINT; + if(ob && (ob->mode & OB_MODE_TEXTURE_PAINT)) v3d->flag |= V3D_TEXTUREPAINT; + if(paint_facesel_test(ob)) v3d->flag |= V3D_FACESELECT; + + uiDefIconTextButS(block, MENU, B_MODESELECT, object_mode_icon(v3d->modeselect), view3d_modeselect_pup(scene) , + xco,yco,126,20, &(v3d->modeselect), 0, 0, 0, 0, "Mode (Hotkeys: Tab, V, Ctrl Tab)"); header_xco_step(ar, &xco, &yco, &maxco, 126+8); /* DRAWTYPE */ @@ -3987,7 +2003,7 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C) uiBlockEndAlign(block); } } else { - if (obedit==NULL && (G.f & (G_VERTEXPAINT|G_WEIGHTPAINT|G_TEXTUREPAINT))) { + if (obedit==NULL && ((ob && ob->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT|OB_MODE_TEXTURE_PAINT)))) { uiDefIconButBitI(block, TOG, G_FACESELECT, B_VIEW_BUTSEDIT, ICON_FACESEL_HLT,xco,yco,XIC,YIC, &G.f, 0, 0, 0, 0, "Painting Mask (FKey)"); header_xco_step(ar, &xco, &yco, &maxco, XIC+10); } else { @@ -4074,7 +2090,7 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C) } /* proportional falloff */ - if((obedit && (obedit->type == OB_MESH || obedit->type == OB_CURVE || obedit->type == OB_SURF || obedit->type == OB_LATTICE)) || G.f & G_PARTICLEEDIT) { + if((obedit && (obedit->type == OB_MESH || obedit->type == OB_CURVE || obedit->type == OB_SURF || obedit->type == OB_LATTICE)) || (ob && ob->mode & OB_MODE_PARTICLE_EDIT)) { uiBlockBeginAlign(block); uiDefIconTextButS(block, ICONTEXTROW,B_REDR, ICON_PROP_OFF, "Proportional %t|Off %x0|On %x1|Connected %x2", xco,yco,XIC+10,YIC, &(ts->proportional), 0, 1.0, 0, 0, "Proportional Edit Falloff (Hotkeys: O, Alt O) "); @@ -4133,7 +2149,7 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C) uiBlockEndAlign(block); header_xco_step(ar, &xco, &yco, &maxco, XIC); } - else if(G.f & G_PARTICLEEDIT) { + else if(ob && ob->mode & OB_MODE_PARTICLE_EDIT) { uiBlockBeginAlign(block); uiDefIconButBitI(block, TOG, SCE_SELECT_PATH, B_SEL_PATH, ICON_EDGESEL, xco,yco,XIC,YIC, &ts->particle.selectmode, 1.0, 0.0, 0, 0, "Path edit mode"); xco+= XIC; @@ -4153,7 +2169,7 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C) uiDefIconBut(block, BUT, B_VIEWRENDER, ICON_SCENE, xco,yco,XIC,YIC, NULL, 0, 1.0, 0, 0, "Render this window (Ctrl Click for anim)"); - if (ob && (ob->flag & OB_POSEMODE)) { + if (ob && (ob->mode & OB_MODE_POSE)) { xco+= XIC; uiBlockBeginAlign(block); @@ -4170,11 +2186,5 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C) } } - - /* always as last */ - UI_view2d_totRect_set(&ar->v2d, maxco+XIC+80, ar->v2d.tot.ymax-ar->v2d.tot.ymin); - - uiEndBlock(C, block); - uiDrawBlock(C, block); } diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h index 3e9382509f4..e5e85cf9d16 100644 --- a/source/blender/editors/space_view3d/view3d_intern.h +++ b/source/blender/editors/space_view3d/view3d_intern.h @@ -140,7 +140,6 @@ void view3d_buttons_register(struct ARegionType *art); void VIEW3D_OT_toolbar(struct wmOperatorType *ot); void view3d_toolbar_register(struct ARegionType *art); void view3d_tool_props_register(struct ARegionType *art); -char *view3d_context_string(const struct bContext *C); /* view3d_snap.c */ int minmax_verts(Object *obedit, float *min, float *max); @@ -157,6 +156,9 @@ void VIEW3D_OT_snap_menu(struct wmOperatorType *ot); ARegion *view3d_has_buttons_region(ScrArea *sa); ARegion *view3d_has_tools_region(ScrArea *sa); +/* draw_volume.c */ +void draw_volume(struct Scene *scene, struct ARegion *ar, struct View3D *v3d, struct Base *base, struct GPUTexture *tex, int res[3]); + #endif /* ED_VIEW3D_INTERN_H */ diff --git a/source/blender/editors/space_view3d/view3d_ops.c b/source/blender/editors/space_view3d/view3d_ops.c index 32305b5c76b..57922d78880 100644 --- a/source/blender/editors/space_view3d/view3d_ops.c +++ b/source/blender/editors/space_view3d/view3d_ops.c @@ -106,9 +106,6 @@ void view3d_keymap(wmWindowManager *wm) ListBase *keymap= WM_keymap_listbase(wm, "View3D Generic", SPACE_VIEW3D, 0); wmKeymapItem *km; - WM_keymap_add_item(keymap, "PAINT_OT_vertex_paint_toggle", VKEY, KM_PRESS, 0, 0); - WM_keymap_add_item(keymap, "PAINT_OT_weight_paint_toggle", TABKEY, KM_PRESS, KM_CTRL, 0); - WM_keymap_add_item(keymap, "VIEW3D_OT_properties", NKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "VIEW3D_OT_toolbar", TKEY, KM_PRESS, 0, 0); @@ -135,7 +132,8 @@ void view3d_keymap(wmWindowManager *wm) km = WM_keymap_add_item(keymap, "SKETCH_OT_draw_preview", MOUSEMOVE, KM_ANY, KM_CTRL, 0); RNA_boolean_set(km->ptr, "snap", 1); - WM_keymap_verify_item(keymap, "VIEW3D_OT_manipulator", ACTIONMOUSE, KM_PRESS, 0, 0); + WM_keymap_verify_item(keymap, "VIEW3D_OT_manipulator", LEFTMOUSE, KM_PRESS, 0, 0); /* manipulator always on left mouse, not on action mouse*/ + WM_keymap_verify_item(keymap, "VIEW3D_OT_cursor3d", ACTIONMOUSE, KM_PRESS, 0, 0); WM_keymap_verify_item(keymap, "VIEW3D_OT_viewrotate", MIDDLEMOUSE, KM_PRESS, 0, 0); diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index d0c0a63eb1a..8cb64a14291 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -59,6 +59,7 @@ #include "BKE_depsgraph.h" #include "BKE_object.h" #include "BKE_global.h" +#include "BKE_paint.h" #include "BKE_scene.h" #include "BKE_screen.h" #include "BKE_utildefines.h" @@ -385,7 +386,7 @@ static void do_lasso_select_objects(ViewContext *vc, short mcords[][2], short mo else ED_base_object_select(base, BA_DESELECT); base->object->flag= base->flag; } - if(base->object->flag & OB_POSEMODE) { + if(base->object->mode & OB_MODE_POSE) { do_lasso_select_pose(vc, mcords, moves, select); } } @@ -699,12 +700,14 @@ static void do_lasso_select_node(short mcords[][2], short moves, short select) void view3d_lasso_select(bContext *C, ViewContext *vc, short mcords[][2], short moves, short select) { + Object *ob = CTX_data_active_object(C); + if(vc->obedit==NULL) { - if(FACESEL_PAINT_TEST) + if(paint_facesel_test(ob)) do_lasso_select_facemode(vc, mcords, moves, select); - else if(G.f & (G_VERTEXPAINT|G_TEXTUREPAINT|G_WEIGHTPAINT)) + else if(ob && ob->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT|OB_MODE_TEXTURE_PAINT)) ; - else if(G.f & G_PARTICLEEDIT) + else if(ob && ob->mode & OB_MODE_PARTICLE_EDIT) PE_lasso_select(C, mcords, moves, select); else do_lasso_select_objects(vc, mcords, moves, select); @@ -1121,7 +1124,7 @@ static void mouse_select(bContext *C, short *mval, short extend, short obcenter) WM_event_add_notifier(C, NC_OBJECT|ND_BONE_ACTIVE, basact->object); /* in weightpaint, we use selected bone to select vertexgroup, so no switch to new active object */ - if(G.f & G_WEIGHTPAINT) { + if(basact->object->mode & OB_MODE_WEIGHT_PAINT) { /* prevent activating */ basact= NULL; } @@ -1339,6 +1342,7 @@ static int view3d_borderselect_exec(bContext *C, wmOperator *op) ScrArea *sa= CTX_wm_area(C); View3D *v3d= sa->spacedata.first; Object *obedit= CTX_data_edit_object(C); + Object *obact= CTX_data_active_object(C); rcti rect; Base *base; MetaElem *ml; @@ -1357,11 +1361,11 @@ static int view3d_borderselect_exec(bContext *C, wmOperator *op) rect.xmax= RNA_int_get(op->ptr, "xmax"); rect.ymax= RNA_int_get(op->ptr, "ymax"); - if(obedit==NULL && (FACESEL_PAINT_TEST)) { + if(obedit==NULL && (paint_facesel_test(OBACT))) { // XXX face_borderselect(); return OPERATOR_FINISHED; } - else if(obedit==NULL && (G.f & G_PARTICLEEDIT)) { + else if(obedit==NULL && (obact && obact->mode & OB_MODE_PARTICLE_EDIT)) { return PE_border_select(C, &rect, (val==LEFTMOUSE)); } @@ -1468,7 +1472,7 @@ static int view3d_borderselect_exec(bContext *C, wmOperator *op) int bone_only; int totobj= MAXPICKBUF; // XXX solve later - if((ob) && (ob->flag & OB_POSEMODE)) + if((ob) && (ob->mode & OB_MODE_POSE)) bone_only= 1; else bone_only= 0; @@ -1579,6 +1583,7 @@ static int view3d_select_invoke(bContext *C, wmOperator *op, wmEvent *event) { Object *obedit= CTX_data_edit_object(C); short extend= RNA_enum_is_equal(C, op->ptr, "type", "EXTEND"); + Object *obact= CTX_data_active_object(C); view3d_operator_needs_opengl(C); @@ -1595,7 +1600,7 @@ static int view3d_select_invoke(bContext *C, wmOperator *op, wmEvent *event) mouse_mball(C, event->mval, extend); } - else if(G.f & G_PARTICLEEDIT) + else if(obact && obact->mode & OB_MODE_PARTICLE_EDIT) PE_mouse_particles(C, event->mval, extend); else mouse_select(C, event->mval, extend, 0); @@ -1656,9 +1661,9 @@ static void mesh_circle_doSelectFace(void *userData, BMFace *efa, int x, int y, static void mesh_circle_select(ViewContext *vc, int selecting, short *mval, float rad) { int bbsel; + Object *ob= vc->obact; - if(vc->obedit==NULL && (FACESEL_PAINT_TEST)) { - Object *ob= vc->obact; + if(vc->obedit==NULL && paint_facesel_test(ob)) { Mesh *me = ob?ob->data:NULL; if (me) { @@ -1798,12 +1803,13 @@ static int view3d_circle_select_exec(bContext *C, wmOperator *op) ScrArea *sa= CTX_wm_area(C); ARegion *ar= CTX_wm_region(C); Scene *scene= CTX_data_scene(C); + Object *obact= CTX_data_active_object(C); View3D *v3d= sa->spacedata.first; int x= RNA_int_get(op->ptr, "x"); int y= RNA_int_get(op->ptr, "y"); int radius= RNA_int_get(op->ptr, "radius"); - if(CTX_data_edit_object(C) || (G.f & G_PARTICLEEDIT)) { + if(CTX_data_edit_object(C) || (obact && obact->mode & OB_MODE_PARTICLE_EDIT)) { ViewContext vc; short mval[2], selecting; @@ -1814,8 +1820,10 @@ static int view3d_circle_select_exec(bContext *C, wmOperator *op) mval[1]= y; selecting= LEFTMOUSE==RNA_int_get(op->ptr, "event_type"); // XXX solve - if(CTX_data_edit_object(C)) + if(CTX_data_edit_object(C)) { obedit_circle_select(&vc, selecting, mval, (float)radius); + WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obact); + } else return PE_circle_select(C, selecting, mval, (float)radius); } diff --git a/source/blender/editors/space_view3d/view3d_snap.c b/source/blender/editors/space_view3d/view3d_snap.c index 5ec34d35d45..969591b1946 100644 --- a/source/blender/editors/space_view3d/view3d_snap.c +++ b/source/blender/editors/space_view3d/view3d_snap.c @@ -510,7 +510,7 @@ static int snap_sel_to_grid(bContext *C, wmOperator *op) CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) { ob= base->object; - if(ob->flag & OB_POSEMODE) { + if(ob->mode & OB_MODE_POSE) { bPoseChannel *pchan; bArmature *arm= ob->data; @@ -637,7 +637,7 @@ static int snap_sel_to_curs(bContext *C, wmOperator *op) else { CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) { ob= base->object; - if(ob->flag & OB_POSEMODE) { + if(ob->mode & OB_MODE_POSE) { bPoseChannel *pchan; bArmature *arm= ob->data; float cursp[3]; @@ -803,7 +803,7 @@ static int snap_curs_to_sel(bContext *C, wmOperator *op) else { Object *ob= OBACT; - if(ob && (ob->flag & OB_POSEMODE)) { + if(ob && (ob->mode & OB_MODE_POSE)) { bArmature *arm= ob->data; bPoseChannel *pchan; for (pchan = ob->pose->chanbase.first; pchan; pchan=pchan->next) { @@ -963,7 +963,7 @@ static int snap_selected_to_center(bContext *C, wmOperator *op) CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) { ob= base->object; - if(ob->flag & OB_POSEMODE) { + if(ob->mode & OB_MODE_POSE) { bPoseChannel *pchan; bArmature *arm= ob->data; @@ -1032,7 +1032,7 @@ static int snap_selected_to_center(bContext *C, wmOperator *op) CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) { ob= base->object; - if(ob->flag & OB_POSEMODE) { + if(ob->mode & OB_MODE_POSE) { bPoseChannel *pchan; bArmature *arm= ob->data; diff --git a/source/blender/editors/space_view3d/view3d_toolbar.c b/source/blender/editors/space_view3d/view3d_toolbar.c index 67d8bc3e5ee..c87dd0b7948 100644 --- a/source/blender/editors/space_view3d/view3d_toolbar.c +++ b/source/blender/editors/space_view3d/view3d_toolbar.c @@ -118,6 +118,19 @@ static void redo_cb(bContext *C, void *arg_op, void *arg2) } } +static wmOperator *view3d_last_operator(const bContext *C) +{ + wmWindowManager *wm= CTX_wm_manager(C); + wmOperator *op; + + /* only for operators that are registered and did an undo push */ + for(op= wm->operators.last; op; op= op->prev) + if((op->type->flag & OPTYPE_REGISTER) && (op->type->flag & OPTYPE_UNDO)) + break; + + return op; +} + static void view3d_panel_operator_redo_buts(const bContext *C, Panel *pa, wmOperator *op) { wmWindowManager *wm= CTX_wm_manager(C); @@ -129,28 +142,32 @@ static void view3d_panel_operator_redo_buts(const bContext *C, Panel *pa, wmOper } RNA_pointer_create(&wm->id, op->type->srna, op->properties, &ptr); - uiDefAutoButsRNA(C, pa->layout, &ptr, 1); - + if(op->type->ui) + op->type->ui((bContext*)C, &ptr, pa->layout); + else + uiDefAutoButsRNA(C, pa->layout, &ptr, 1); +} + +static void view3d_panel_operator_redo_header(const bContext *C, Panel *pa) +{ + wmOperator *op= view3d_last_operator(C); + + if(op) BLI_strncpy(pa->drawname, op->type->name, sizeof(pa->drawname)); + else BLI_strncpy(pa->drawname, "Operator", sizeof(pa->drawname)); } static void view3d_panel_operator_redo(const bContext *C, Panel *pa) { - wmWindowManager *wm= CTX_wm_manager(C); - wmOperator *op; + wmOperator *op= view3d_last_operator(C); uiBlock *block; - block= uiLayoutGetBlock(pa->layout); - - /* only for operators that are registered and did an undo push */ - for(op= wm->operators.last; op; op= op->prev) - if((op->type->flag & OPTYPE_REGISTER) && (op->type->flag & OPTYPE_UNDO)) - break; - if(op==NULL) return; if(op->type->poll && op->type->poll((bContext *)C)==0) return; + block= uiLayoutGetBlock(pa->layout); + uiBlockSetFunc(block, redo_cb, op, NULL); if(op->macro.first) { @@ -164,42 +181,6 @@ static void view3d_panel_operator_redo(const bContext *C, Panel *pa) /* ******************* */ -char *view3d_context_string(const bContext *C) -{ - Object *obedit= CTX_data_edit_object(C); - - if(obedit) { - switch(obedit->type) { - case OB_MESH: - return "editmode_mesh"; - case OB_CURVE: - return "editmode_curve"; - case OB_SURF: - return "editmode_surface"; - case OB_FONT: - return "editmode_text"; - case OB_ARMATURE: - return "editmode_armature"; - case OB_MBALL: - return "editmode_mball"; - case OB_LATTICE: - return "editmode_lattice"; - } - } - else { - Object *ob = CTX_data_active_object(C); - - if(ob && (ob->flag & OB_POSEMODE)) return "pose_mode"; - else if (G.f & G_SCULPTMODE) return "sculpt_mode"; - else if (G.f & G_WEIGHTPAINT) return "weight_paint"; - else if (G.f & G_VERTEXPAINT) return "vertex_paint"; - else if (G.f & G_TEXTUREPAINT) return "texture_paint"; - else if(G.f & G_PARTICLEEDIT) return "particle_mode"; - } - - return "objectmode"; -} - typedef struct CustomTool { struct CustomTool *next, *prev; char opname[OP_MAX_TYPENAME]; @@ -215,7 +196,7 @@ static void operator_call_cb(struct bContext *C, void *arg_listbase, void *arg2) BLI_addtail(arg_listbase, ct); BLI_strncpy(ct->opname, ot->idname, OP_MAX_TYPENAME); - BLI_strncpy(ct->context, view3d_context_string(C), OP_MAX_TYPENAME); + BLI_strncpy(ct->context, CTX_data_mode_string(C), OP_MAX_TYPENAME); } } @@ -278,7 +259,7 @@ static void view3d_panel_tool_shelf(const bContext *C, Panel *pa) SpaceLink *sl= CTX_wm_space_data(C); SpaceType *st= NULL; uiLayout *col; - const char *context= view3d_context_string(C); + const char *context= CTX_data_mode_string(C); if(sl) st= BKE_spacetype_from_id(sl->spacetype); @@ -289,7 +270,7 @@ static void view3d_panel_tool_shelf(const bContext *C, Panel *pa) for(ct= st->toolshelf.first; ct; ct= ct->next) { if(0==strncmp(context, ct->context, OP_MAX_TYPENAME)) { col= uiLayoutColumn(pa->layout, 1); - uiItemFullO(col, NULL, 0, ct->opname, NULL, WM_OP_INVOKE_REGION_WIN); + uiItemFullO(col, NULL, 0, ct->opname, NULL, WM_OP_INVOKE_REGION_WIN, 0); } } } @@ -315,7 +296,8 @@ void view3d_tool_props_register(ARegionType *art) pt= MEM_callocN(sizeof(PanelType), "spacetype view3d panel last operator"); strcpy(pt->idname, "VIEW3D_PT_last_operator"); - strcpy(pt->label, "Last Operator"); + strcpy(pt->label, "Operator"); + pt->draw_header= view3d_panel_operator_redo_header; pt->draw= view3d_panel_operator_redo; BLI_addtail(&art->paneltypes, pt); } diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index 20e0a79f0c7..ce7b6ba454d 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -63,6 +63,7 @@ #include "RE_pipeline.h" // make_stars #include "BIF_gl.h" +#include "BIF_glutil.h" #include "WM_api.h" #include "WM_types.h" @@ -543,6 +544,18 @@ void view3d_get_object_project_mat(RegionView3D *rv3d, Object *ob, float pmat[4] Mat4MulMat4(pmat, vmat, rv3d->winmat); } +/* Uses window coordinates (x,y) and depth component z to find a point in + modelspace */ +void view3d_unproject(bglMats *mats, float out[3], const short x, const short y, const float z) +{ + double ux, uy, uz; + + gluUnProject(x,y,z, mats->modelview, mats->projection, + (GLint *)mats->viewport, &ux, &uy, &uz ); + out[0] = ux; + out[1] = uy; + out[2] = uz; +} /* use above call to get projecting mat */ void view3d_project_float(ARegion *ar, float *vec, float *adr, float mat[4][4]) @@ -1389,12 +1402,13 @@ static ListBase queue_back; static void SaveState(bContext *C) { wmWindow *win= CTX_wm_window(C); + Object *obact = CTX_data_active_object(C); glPushAttrib(GL_ALL_ATTRIB_BITS); GPU_state_init(); - if(G.f & G_TEXTUREPAINT) + if(obact && obact->mode & OB_MODE_TEXTURE_PAINT) GPU_paint_set_mipmap(1); queue_back= win->queue; @@ -1407,8 +1421,9 @@ static void SaveState(bContext *C) static void RestoreState(bContext *C) { wmWindow *win= CTX_wm_window(C); + Object *obact = CTX_data_active_object(C); - if(G.f & G_TEXTUREPAINT) + if(obact && obact->mode & OB_MODE_TEXTURE_PAINT) GPU_paint_set_mipmap(0); //XXX curarea->win_swap = 0; diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 510193fdade..dd7cebdfe3f 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -89,6 +89,7 @@ #include "BKE_pointcache.h" #include "BKE_utildefines.h" #include "BKE_context.h" +#include "BKE_unit.h" //#include "BSE_view.h" @@ -3039,12 +3040,22 @@ static void headerTranslation(TransInfo *t, float vec[3], char *str) { applyAspectRatio(t, dvec); dist = VecLength(vec); - sprintf(&tvec[0], "%.4f", dvec[0]); - sprintf(&tvec[20], "%.4f", dvec[1]); - sprintf(&tvec[40], "%.4f", dvec[2]); + if(t->scene->unit.system) { + int i, do_split= t->scene->unit.flag & USER_UNIT_OPT_SPLIT ? 1:0; + + for(i=0; i<3; i++) + bUnit_AsString(&tvec[i*20], 20, dvec[i]*t->scene->unit.scale_length, 4, t->scene->unit.system, B_UNIT_LENGTH, do_split, 1); + } + else { + sprintf(&tvec[0], "%.4f", dvec[0]); + sprintf(&tvec[20], "%.4f", dvec[1]); + sprintf(&tvec[40], "%.4f", dvec[2]); + } } - if( dist > 1e10 || dist < -1e10 ) /* prevent string buffer overflow */ + if(t->scene->unit.system) + bUnit_AsString(distvec, sizeof(distvec), dist*t->scene->unit.scale_length, 4, t->scene->unit.system, B_UNIT_LENGTH, t->scene->unit.flag & USER_UNIT_OPT_SPLIT, 0); + else if( dist > 1e10 || dist < -1e10 ) /* prevent string buffer overflow */ sprintf(distvec, "%.4e", dist); else sprintf(distvec, "%.4f", dist); diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 783d98e4c6f..b556ff907da 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -700,6 +700,8 @@ int count_set_pose_transflags(int *out_mode, short around, Object *ob) bone->flag &= ~BONE_HINGE_CHILD_TRANSFORM; bone->flag &= ~BONE_TRANSFORM_CHILD; } + else + bone->flag &= ~BONE_TRANSFORM; } /* make sure no bone can be transformed when a parent is transformed */ @@ -919,7 +921,7 @@ static short pose_grab_with_ik(Object *ob) Bone *bonec; short tot_ik= 0; - if ((ob==NULL) || (ob->pose==NULL) || (ob->flag & OB_POSEMODE)==0) + if ((ob==NULL) || (ob->pose==NULL) || (ob->mode & OB_MODE_POSE)==0) return 0; arm = ob->data; @@ -4933,7 +4935,7 @@ void special_aftertrans_update(TransInfo *t) // allqueue(REDRAWBUTSEDIT, 0); } - else if(G.f & G_PARTICLEEDIT) { + else if(t->scene->basact && (ob = t->scene->basact->object) && ob->mode & OB_MODE_PARTICLE_EDIT) { ; } else { @@ -4992,9 +4994,9 @@ static void createTransObject(bContext *C, TransInfo *t) set_trans_object_base_flags(C, t); /* count */ +#if 0 // TRANSFORM_FIX_ME CTX_DATA_BEGIN(C, Object*, ob, selected_objects) { -#if 0 // TRANSFORM_FIX_ME /* store ipo keys? */ if ((ob->id.lib == 0) && (ob->ipo) && (ob->ipo->showkey) && (ob->ipoflag & OB_DRAWKEY)) { elems.first= elems.last= NULL; @@ -5008,12 +5010,14 @@ static void createTransObject(bContext *C, TransInfo *t) if(elems.first==NULL) t->total++; } -#endif // else { t->total++; // } } CTX_DATA_END; +#else + t->total= CTX_DATA_COUNT(C, selected_objects); +#endif if(!t->total) { /* clear here, main transform function escapes too */ @@ -5267,18 +5271,18 @@ void createTransData(bContext *C, TransInfo *t) t->poseobj = ob; /* <- tsk tsk, this is going to give issues one day */ } } - else if (ob && (ob->flag & OB_POSEMODE)) { + else if (ob && (ob->mode & OB_MODE_POSE)) { // XXX this is currently limited to active armature only... // XXX active-layer checking isn't done as that should probably be checked through context instead createTransPose(C, t, ob); } - else if (G.f & G_WEIGHTPAINT) { + else if (ob && (ob->mode & OB_MODE_WEIGHT_PAINT)) { /* exception, we look for the one selected armature */ CTX_DATA_BEGIN(C, Object*, ob_armature, selected_objects) { if(ob_armature->type==OB_ARMATURE) { - if(ob_armature->flag & OB_POSEMODE) + if(ob_armature->mode & OB_MODE_POSE) { createTransPose(C, t, ob_armature); break; @@ -5287,7 +5291,7 @@ void createTransData(bContext *C, TransInfo *t) } CTX_DATA_END; } - else if (G.f & G_PARTICLEEDIT && PE_can_edit(PE_get_current(scene, ob))) { + else if (ob && (ob->mode & OB_MODE_PARTICLE_EDIT) && PE_can_edit(PE_get_current(scene, ob))) { createTransParticleVerts(C, t); if(t->data && t->flag & T_PROP_EDIT) { diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index fe3e7b08685..b96cb2601ec 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -271,7 +271,7 @@ static void editbmesh_apply_to_mirror(TransInfo *t) /* tags the given ID block for refreshes (if applicable) due to * Animation Editor editing */ -static void animedit_refresh_id_tags (ID *id) +static void animedit_refresh_id_tags (Scene *scene, ID *id) { if (id) { AnimData *adt= BKE_animdata_from_id(id); @@ -281,12 +281,11 @@ static void animedit_refresh_id_tags (ID *id) adt->recalc |= ADT_RECALC_ANIM; /* if ID-block is Object, set recalc flags */ - // TODO: this should probably go through the depsgraph instead... but for now, let's be lazy switch (GS(id->name)) { case ID_OB: { Object *ob= (Object *)id; - ob->recalc |= OB_RECALC; + DAG_object_flush_update(scene, ob, OB_RECALC_DATA); /* sets recalc flags */ } break; } @@ -345,11 +344,11 @@ static void animrecord_check_state (Scene *scene, ID *id, wmTimer *animtimer) void recalcData(TransInfo *t) { Scene *scene = t->scene; - Base *base; + Base *base = scene->basact; if (t->obedit) { } - else if(G.f & G_PARTICLEEDIT) { + else if(base && base->object->mode & OB_MODE_PARTICLE_EDIT) { flushTransParticles(t); } if (t->spacetype==SPACE_NODE) { @@ -386,7 +385,7 @@ void recalcData(TransInfo *t) /* just tag these animdata-blocks to recalc, assuming that some data there changed */ for (ale= anim_data.first; ale; ale= ale->next) { /* set refresh tags for objects using this animation */ - animedit_refresh_id_tags(ale->id); + animedit_refresh_id_tags(t->scene, ale->id); } /* now free temp channels */ @@ -434,7 +433,7 @@ void recalcData(TransInfo *t) calchandles_fcurve(fcu); /* set refresh tags for objects using this animation */ - animedit_refresh_id_tags(ale->id); + animedit_refresh_id_tags(t->scene, ale->id); } /* do resort and other updates? */ @@ -465,7 +464,7 @@ void recalcData(TransInfo *t) continue; /* set refresh tags for objects using this animation */ - animedit_refresh_id_tags(tdn->id); + animedit_refresh_id_tags(t->scene, tdn->id); /* if cancelling transform, just write the values without validating, then move on */ if (t->state == TRANS_CANCEL) { @@ -768,7 +767,7 @@ void recalcData(TransInfo *t) */ // TODO: autokeyframe calls need some setting to specify to add samples (FPoints) instead of keyframes? if ((t->animtimer) && IS_AUTOKEY_ON(t->scene)) { - short targetless_ik= (t->flag & T_AUTOIK); // XXX this currently doesn't work, since flags aren't set yet! + int targetless_ik= (t->flag & T_AUTOIK); // XXX this currently doesn't work, since flags aren't set yet! animrecord_check_state(t->scene, &ob->id, t->animtimer); autokeyframe_pose_cb_func(t->scene, (View3D *)t->view, ob, t->mode, targetless_ik); diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c index b999053bc1f..e0ab6bcf5f3 100644 --- a/source/blender/editors/transform/transform_manipulator.c +++ b/source/blender/editors/transform/transform_manipulator.c @@ -341,7 +341,7 @@ int calc_manipulator_stats(const bContext *C) Mat4MulVecfl(obedit->obmat, scene->twmax); } } - else if(ob && (ob->flag & OB_POSEMODE)) { + else if(ob && (ob->mode & OB_MODE_POSE)) { bPoseChannel *pchan; int mode = TFM_ROTATION; // mislead counting bones... bah. We don't know the manipulator mode, could be mixed @@ -361,10 +361,10 @@ int calc_manipulator_stats(const bContext *C) Mat4MulVecfl(ob->obmat, scene->twmax); } } - else if(G.f & (G_VERTEXPAINT + G_TEXTUREPAINT + G_WEIGHTPAINT + G_SCULPTMODE)) { + else if(ob && (ob->mode & (OB_MODE_SCULPT|OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT|OB_MODE_TEXTURE_PAINT))) { ; } - else if(G.f & G_PARTICLEEDIT) { + else if(ob && ob->mode & OB_MODE_PARTICLE_EDIT) { ParticleSystem *psys= PE_get_current(scene, ob); ParticleData *pa = psys->particles; ParticleEditKey *ek; @@ -415,7 +415,7 @@ int calc_manipulator_stats(const bContext *C) switch(v3d->twmode) { case V3D_MANIP_NORMAL: - if(obedit || ob->flag & OB_POSEMODE) { + if(obedit || ob->mode & OB_MODE_POSE) { float mat[3][3]; int type; @@ -1418,7 +1418,7 @@ void BIF_draw_manipulator(const bContext *C) rv3d->twmat[3][2]= (scene->twmin[2] + scene->twmax[2])/2.0f; if(v3d->around==V3D_ACTIVE && scene->obedit==NULL) { Object *ob= OBACT; - if(ob && !(ob->flag & OB_POSEMODE)) + if(ob && !(ob->mode & OB_MODE_POSE)) VECCOPY(rv3d->twmat[3], ob->obmat[3]); } break; diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c index 89aae3aebfd..9aef9c217ab 100644 --- a/source/blender/editors/transform/transform_ops.c +++ b/source/blender/editors/transform/transform_ops.c @@ -148,6 +148,7 @@ void TFM_OT_select_orientation(struct wmOperatorType *ot) /* identifiers */ ot->name = "Select Orientation"; + ot->description= "Select orientation type."; ot->idname = "TFM_OT_select_orientation"; /* api callbacks */ @@ -308,6 +309,7 @@ void TFM_OT_translate(struct wmOperatorType *ot) { /* identifiers */ ot->name = "Translate"; + ot->description= "Translate selected items."; ot->idname = OP_TRANSLATION; ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING; @@ -333,6 +335,7 @@ void TFM_OT_resize(struct wmOperatorType *ot) { /* identifiers */ ot->name = "Resize"; + ot->description= "Resize selected items."; ot->idname = OP_RESIZE; ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING; @@ -359,6 +362,7 @@ void TFM_OT_trackball(struct wmOperatorType *ot) { /* identifiers */ ot->name = "Trackball"; + ot->description= "Trackball style rotation of selected items."; ot->idname = OP_TRACKBALL; ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING; @@ -380,6 +384,7 @@ void TFM_OT_rotate(struct wmOperatorType *ot) { /* identifiers */ ot->name = "Rotate"; + ot->description= "Rotate selected items."; ot->idname = OP_ROTATION; ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING; @@ -405,6 +410,10 @@ void TFM_OT_tilt(struct wmOperatorType *ot) { /* identifiers */ ot->name = "Tilt"; + /*optionals - + "Tilt selected vertices." + "Specify an extra axis rotation for selected vertices of 3d curve." */ + ot->description= "Tilt selected control vertices of 3d curve."; ot->idname = OP_TILT; ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING; @@ -428,6 +437,7 @@ void TFM_OT_warp(struct wmOperatorType *ot) { /* identifiers */ ot->name = "Warp"; + ot->description= "Warp selected items around the cursor."; ot->idname = OP_WARP; ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING; @@ -452,6 +462,7 @@ void TFM_OT_shear(struct wmOperatorType *ot) { /* identifiers */ ot->name = "Shear"; + ot->description= "Shear selected items along the horizontal screen axis."; ot->idname = OP_SHEAR; ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING; @@ -476,6 +487,7 @@ void TFM_OT_shrink_fatten(struct wmOperatorType *ot) { /* identifiers */ ot->name = "Shrink/Fatten"; + ot->description= "Shrink/fatten selected vertices along normals."; ot->idname = OP_SHRINK_FATTEN; ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING; @@ -497,6 +509,8 @@ void TFM_OT_tosphere(struct wmOperatorType *ot) { /* identifiers */ ot->name = "To Sphere"; + //added "around mesh center" to differentiate between "MESH_OT_vertices_to_sphere()" + ot->description= "Move selected vertices outward in a spherical shape around mesh center."; ot->idname = OP_TOSPHERE; ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING; @@ -548,6 +562,7 @@ void TFM_OT_transform(struct wmOperatorType *ot) /* identifiers */ ot->name = "Transform"; + ot->description= "Transform selected items by mode type."; ot->idname = "TFM_OT_transform"; ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING; diff --git a/source/blender/editors/transform/transform_orientations.c b/source/blender/editors/transform/transform_orientations.c index 2caa28600cf..6d5138ff11a 100644 --- a/source/blender/editors/transform/transform_orientations.c +++ b/source/blender/editors/transform/transform_orientations.c @@ -88,7 +88,7 @@ void BIF_manageTransformOrientation(bContext *C, int confirm, int set) { else if (obedit->type == OB_ARMATURE) index = manageBoneSpace(C, confirm, set); } - else if (ob && (ob->flag & OB_POSEMODE)) { + else if (ob && (ob->mode & OB_MODE_POSE)) { index = manageBoneSpace(C, confirm, set); } else { @@ -488,7 +488,7 @@ void initTransformOrientation(bContext *C, TransInfo *t) break; case V3D_MANIP_NORMAL: - if(obedit || ob->flag & OB_POSEMODE) { + if(obedit || ob->mode & OB_MODE_POSE) { float mat[3][3]; int type; @@ -868,7 +868,7 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3], Mat3MulVecfl(mat, plane); } } - else if(ob && (ob->flag & OB_POSEMODE)) + else if(ob && (ob->mode & OB_MODE_POSE)) { bArmature *arm= ob->data; bPoseChannel *pchan; @@ -898,10 +898,7 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3], result = ORIENTATION_EDGE; } } - else if(G.f & (G_VERTEXPAINT + G_TEXTUREPAINT + G_WEIGHTPAINT + G_SCULPTMODE)) - { - } - else if(G.f & G_PARTICLEEDIT) + else if(ob && (ob->mode & (OB_MODE_SCULPT|OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT|OB_MODE_TEXTURE_PAINT|OB_MODE_PARTICLE_EDIT))) { } else { diff --git a/source/blender/editors/util/undo.c b/source/blender/editors/util/undo.c index 435f2c7ecf4..41159397634 100644 --- a/source/blender/editors/util/undo.c +++ b/source/blender/editors/util/undo.c @@ -75,14 +75,11 @@ /* ***************** generic undo system ********************* */ -/* ********* XXX **************** */ -static void sound_initialize_sounds() {} -/* ********* XXX **************** */ - void ED_undo_push(bContext *C, char *str) { wmWindowManager *wm= CTX_wm_manager(C); Object *obedit= CTX_data_edit_object(C); + Object *obact= CTX_data_active_object(C); if(obedit) { if (U.undosteps == 0) return; @@ -100,7 +97,7 @@ void ED_undo_push(bContext *C, char *str) else if (obedit->type==OB_ARMATURE) undo_push_armature(C, str); } - else if(G.f & G_PARTICLEEDIT) { + else if(obact && obact->mode & OB_MODE_PARTICLE_EDIT) { if (U.undosteps == 0) return; PE_undo_push(CTX_data_scene(C), str); @@ -119,12 +116,13 @@ void ED_undo_push(bContext *C, char *str) static int ed_undo_step(bContext *C, int step, const char *undoname) { Object *obedit= CTX_data_edit_object(C); + Object *obact= CTX_data_active_object(C); ScrArea *sa= CTX_wm_area(C); if(sa && sa->spacetype==SPACE_IMAGE) { SpaceImage *sima= (SpaceImage *)sa->spacedata.first; - if(G.f & G_TEXTUREPAINT || sima->flag & SI_DRAWTOOL) { + if((obact && obact->mode & OB_MODE_TEXTURE_PAINT) || sima->flag & SI_DRAWTOOL) { undo_imagepaint_step(step); WM_event_add_notifier(C, NC_WINDOW, NULL); @@ -146,9 +144,9 @@ static int ed_undo_step(bContext *C, int step, const char *undoname) else { int do_glob_undo= 0; - if(G.f & G_TEXTUREPAINT) + if(obact && obact->mode & OB_MODE_TEXTURE_PAINT) undo_imagepaint_step(step); - else if(G.f & G_PARTICLEEDIT) { + else if(obact && obact->mode & OB_MODE_PARTICLE_EDIT) { if(step==1) PE_undo(CTX_data_scene(C)); else @@ -167,7 +165,6 @@ static int ed_undo_step(bContext *C, int step, const char *undoname) BKE_undo_name(C, undoname); else BKE_undo_step(C, step); - sound_initialize_sounds(); } } @@ -214,13 +211,14 @@ static int ed_redo_exec(bContext *C, wmOperator *op) void ED_undo_menu(bContext *C) { Object *obedit= CTX_data_edit_object(C); + Object *obact= CTX_data_active_object(C); if(obedit) { //if ELEM7(obedit->type, OB_MESH, OB_FONT, OB_CURVE, OB_SURF, OB_MBALL, OB_LATTICE, OB_ARMATURE) // undo_editmode_menu(); } else { - if(G.f & G_PARTICLEEDIT) + if(obact && obact->mode & OB_MODE_PARTICLE_EDIT) PE_undo_menu(CTX_data_scene(C), CTX_data_active_object(C)); else if(U.uiflag & USER_GLOBALUNDO) { char *menu= BKE_undo_menu_string(); @@ -229,7 +227,6 @@ void ED_undo_menu(bContext *C) MEM_freeN(menu); if(event>0) { BKE_undo_number(C, event); - sound_initialize_sounds(); } } } @@ -242,6 +239,7 @@ void ED_OT_undo(wmOperatorType *ot) { /* identifiers */ ot->name= "Undo"; + ot->description= "Undo previous action."; ot->idname= "ED_OT_undo"; /* api callbacks */ @@ -253,6 +251,7 @@ void ED_OT_redo(wmOperatorType *ot) { /* identifiers */ ot->name= "Redo"; + ot->description= "Redo previous action."; ot->idname= "ED_OT_redo"; /* api callbacks */ diff --git a/source/blender/gpu/GPU_draw.h b/source/blender/gpu/GPU_draw.h index 802f30506f8..00d0e3131e5 100644 --- a/source/blender/gpu/GPU_draw.h +++ b/source/blender/gpu/GPU_draw.h @@ -43,6 +43,7 @@ struct Object; struct Scene; struct View3D; struct RegionView3D; +struct SmokeModifierData; /* OpenGL drawing functions related to shading. These are also * shared with the game engine, where there were previously @@ -78,7 +79,7 @@ int GPU_get_material_blend_mode(void); * be drawn using one or the other * - passing NULL clears the state again */ -int GPU_set_tpage(struct MTFace *tface); +int GPU_set_tpage(struct MTFace *tface, int mipmap); /* Lights * - returns how many lights were enabled @@ -105,13 +106,17 @@ void GPU_paint_set_mipmap(int mipmap); /* Image updates and free * - these deal with images bound as opengl textures */ -void GPU_paint_update_image(struct Image *ima, int x, int y, int w, int h); +void GPU_paint_update_image(struct Image *ima, int x, int y, int w, int h, int mipmap); void GPU_update_images_framechange(void); int GPU_update_image_time(struct Image *ima, double time); -int GPU_verify_image(struct Image *ima, int tftile, int tfmode, int compare); +int GPU_verify_image(struct Image *ima, int tftile, int tfmode, int compare, int mipmap); void GPU_free_image(struct Image *ima); void GPU_free_images(void); +/* smoke drawing functions */ +void GPU_free_smoke(struct SmokeModifierData *smd); +void GPU_create_smoke(struct SmokeModifierData *smd); + #ifdef __cplusplus } #endif diff --git a/source/blender/gpu/GPU_extensions.h b/source/blender/gpu/GPU_extensions.h index 7218b6b1328..e00cab79ce0 100644 --- a/source/blender/gpu/GPU_extensions.h +++ b/source/blender/gpu/GPU_extensions.h @@ -73,9 +73,10 @@ int GPU_print_error(char *str); GPUTexture *GPU_texture_create_1D(int w, float *pixels); GPUTexture *GPU_texture_create_2D(int w, int h, float *pixels); +GPUTexture *GPU_texture_create_3D(int w, int h, int depth, float *fpixels); GPUTexture *GPU_texture_create_depth(int w, int h); GPUTexture *GPU_texture_from_blender(struct Image *ima, - struct ImageUser *iuser, double time); + struct ImageUser *iuser, double time, int mipmap); void GPU_texture_free(GPUTexture *tex); void GPU_texture_ref(GPUTexture *tex); diff --git a/source/blender/gpu/GPU_material.h b/source/blender/gpu/GPU_material.h index 49c0dc166c1..f7318869fb3 100644 --- a/source/blender/gpu/GPU_material.h +++ b/source/blender/gpu/GPU_material.h @@ -124,7 +124,7 @@ void GPU_material_free(struct Material *ma); void GPU_materials_free(); -void GPU_material_bind(GPUMaterial *material, int oblay, int viewlay, double time); +void GPU_material_bind(GPUMaterial *material, int oblay, int viewlay, double time, int mipmap); void GPU_material_bind_uniforms(GPUMaterial *material, float obmat[][4], float viewmat[][4], float viewinv[][4], float obcol[4]); void GPU_material_unbind(GPUMaterial *material); int GPU_material_bound(GPUMaterial *material); diff --git a/source/blender/gpu/intern/gpu_codegen.c b/source/blender/gpu/intern/gpu_codegen.c index 94c1910e3bc..c8a2d553685 100644 --- a/source/blender/gpu/intern/gpu_codegen.c +++ b/source/blender/gpu/intern/gpu_codegen.c @@ -824,7 +824,7 @@ void GPU_nodes_extract_dynamic_inputs(GPUPass *pass, ListBase *nodes) GPU_shader_unbind(shader); } -void GPU_pass_bind(GPUPass *pass, double time) +void GPU_pass_bind(GPUPass *pass, double time, int mipmap) { GPUInput *input; GPUShader *shader = pass->shader; @@ -838,7 +838,7 @@ void GPU_pass_bind(GPUPass *pass, double time) /* now bind the textures */ for (input=inputs->first; input; input=input->next) { if (input->ima) - input->tex = GPU_texture_from_blender(input->ima, input->iuser, time); + input->tex = GPU_texture_from_blender(input->ima, input->iuser, time, mipmap); if(input->tex && input->bindtex) { GPU_texture_bind(input->tex, input->texid); diff --git a/source/blender/gpu/intern/gpu_codegen.h b/source/blender/gpu/intern/gpu_codegen.h index 53b52f24f16..f5dd956d176 100644 --- a/source/blender/gpu/intern/gpu_codegen.h +++ b/source/blender/gpu/intern/gpu_codegen.h @@ -71,7 +71,7 @@ GPUPass *GPU_generate_pass(ListBase *nodes, struct GPUNodeLink *outlink, struct GPUShader *GPU_pass_shader(GPUPass *pass); -void GPU_pass_bind(GPUPass *pass, double time); +void GPU_pass_bind(GPUPass *pass, double time, int mipmap); void GPU_pass_update_uniforms(GPUPass *pass); void GPU_pass_unbind(GPUPass *pass); diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index eb834abc670..a81c7e03455 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -38,9 +38,11 @@ #include "DNA_lamp_types.h" #include "DNA_material_types.h" #include "DNA_meshdata_types.h" +#include "DNA_modifier_types.h" #include "DNA_node_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" +#include "DNA_smoke_types.h" #include "DNA_userdef_types.h" #include "DNA_view3d_types.h" @@ -194,8 +196,11 @@ static int smaller_pow2(int num) static int is_pow2_limit(int num) { /* take texture clamping into account */ - if (G.f & G_TEXTUREPAINT) - return 1; + + /* XXX: texturepaint not global! + if (G.f & G_TEXTUREPAINT) + return 1;*/ + if (U.glreslimit != 0 && num > U.glreslimit) return 0; @@ -204,8 +209,9 @@ static int is_pow2_limit(int num) static int smaller_pow2_limit(int num) { - if (G.f & G_TEXTUREPAINT) - return 1; + /* XXX: texturepaint not global! + if (G.f & G_TEXTUREPAINT) + return 1;*/ /* take texture clamping into account */ if (U.glreslimit != 0 && num > U.glreslimit) @@ -249,7 +255,7 @@ void GPU_set_linear_mipmap(int linear) static int gpu_get_mipmap(void) { - return GTS.domipmap && (!(G.f & G_TEXTUREPAINT)); + return GTS.domipmap; } static GLenum gpu_get_mipmap_filter(int mag) @@ -382,7 +388,7 @@ static void gpu_verify_reflection(Image *ima) } } -int GPU_verify_image(Image *ima, int tftile, int tfmode, int compare) +int GPU_verify_image(Image *ima, int tftile, int tfmode, int compare, int mipmap) { ImBuf *ibuf = NULL; unsigned int *bind = NULL; @@ -507,7 +513,7 @@ int GPU_verify_image(Image *ima, int tftile, int tfmode, int compare) } /* scale if not a power of two */ - if (!is_pow2_limit(rectw) || !is_pow2_limit(recth)) { + if (!mipmap && (!is_pow2_limit(rectw) || !is_pow2_limit(recth))) { rectw= smaller_pow2_limit(rectw); recth= smaller_pow2_limit(recth); @@ -520,7 +526,7 @@ int GPU_verify_image(Image *ima, int tftile, int tfmode, int compare) glGenTextures(1, (GLuint *)bind); glBindTexture( GL_TEXTURE_2D, *bind); - if (!gpu_get_mipmap()) { + if (!(gpu_get_mipmap() && mipmap)) { glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, rectw, recth, 0, GL_RGBA, GL_UNSIGNED_BYTE, rect); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gpu_get_mipmap_filter(1)); @@ -559,7 +565,7 @@ static void gpu_verify_repeat(Image *ima) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); } -int GPU_set_tpage(MTFace *tface) +int GPU_set_tpage(MTFace *tface, int mipmap) { Image *ima; @@ -575,7 +581,7 @@ int GPU_set_tpage(MTFace *tface) gpu_verify_alpha_mode(tface); gpu_verify_reflection(ima); - if(GPU_verify_image(ima, tface->tile, tface->mode, 1)) { + if(GPU_verify_image(ima, tface->tile, tface->mode, 1, mipmap)) { GTS.curtile= GTS.tile; GTS.curima= GTS.ima; GTS.curtilemode= GTS.tilemode; @@ -640,13 +646,13 @@ void GPU_paint_set_mipmap(int mipmap) } } -void GPU_paint_update_image(Image *ima, int x, int y, int w, int h) +void GPU_paint_update_image(Image *ima, int x, int y, int w, int h, int mipmap) { ImBuf *ibuf; ibuf = BKE_image_get_ibuf(ima, NULL); - if (ima->repbind || gpu_get_mipmap() || !ima->bindcode || !ibuf || + if (ima->repbind || (gpu_get_mipmap() && mipmap) || !ima->bindcode || !ibuf || (!is_pow2(ibuf->x) || !is_pow2(ibuf->y)) || (w == 0) || (h == 0)) { /* these cases require full reload still */ @@ -740,6 +746,23 @@ int GPU_update_image_time(Image *ima, double time) return inc; } + +void GPU_free_smoke(SmokeModifierData *smd) +{ + if(smd->type & MOD_SMOKE_TYPE_DOMAIN && smd->domain) + { + if(smd->domain->tex) + GPU_texture_free(smd->domain->tex); + smd->domain->tex = NULL; + } +} + +void GPU_create_smoke(SmokeModifierData *smd) +{ + if(smd->type & MOD_SMOKE_TYPE_DOMAIN && smd->domain && !smd->domain->tex) + smd->domain->tex = GPU_texture_create_3D(smd->domain->res[0], smd->domain->res[1], smd->domain->res[2], smd->domain->view3d); +} + void GPU_free_image(Image *ima) { /* free regular image binding */ @@ -988,7 +1011,7 @@ int GPU_enable_material(int nr, void *attribs) gpumat = GPU_material_from_blender(GMS.gscene, mat); GPU_material_vertex_attributes(gpumat, gattribs); - GPU_material_bind(gpumat, GMS.gob->lay, GMS.glay, 1.0); + GPU_material_bind(gpumat, GMS.gob->lay, GMS.glay, 1.0, !(GMS.gob->mode & OB_MODE_TEXTURE_PAINT)); GPU_material_bind_uniforms(gpumat, GMS.gob->obmat, GMS.gviewmat, GMS.gviewinv, GMS.gob->col); GMS.gboundmat= mat; diff --git a/source/blender/gpu/intern/gpu_extensions.c b/source/blender/gpu/intern/gpu_extensions.c index 4984e043031..850b46dc28c 100644 --- a/source/blender/gpu/intern/gpu_extensions.c +++ b/source/blender/gpu/intern/gpu_extensions.c @@ -312,7 +312,70 @@ static GPUTexture *GPU_texture_create_nD(int w, int h, int n, float *fpixels, in return tex; } -GPUTexture *GPU_texture_from_blender(Image *ima, ImageUser *iuser, double time) + +GPUTexture *GPU_texture_create_3D(int w, int h, int depth, float *fpixels) +{ + GPUTexture *tex; + GLenum type, format, internalformat; + void *pixels = NULL; + float vfBorderColor[4] = {0.0f, 0.0f, 0.0f, 0.0f}; + + tex = MEM_callocN(sizeof(GPUTexture), "GPUTexture"); + tex->w = w; + tex->h = h; + tex->depth = depth; + tex->number = -1; + tex->refcount = 1; + tex->target = GL_TEXTURE_3D; + + glGenTextures(1, &tex->bindcode); + + if (!tex->bindcode) { + fprintf(stderr, "GPUTexture: texture create failed: %d\n", + (int)glGetError()); + GPU_texture_free(tex); + return NULL; + } + + if (!GLEW_ARB_texture_non_power_of_two) { + tex->w = larger_pow2(tex->w); + tex->h = larger_pow2(tex->h); + tex->depth = larger_pow2(tex->depth); + } + + tex->number = 0; + glBindTexture(tex->target, tex->bindcode); + + type = GL_UNSIGNED_BYTE; + format = GL_RGBA; + internalformat = GL_RGBA8; + + if (fpixels) + pixels = GPU_texture_convert_pixels(w*h*depth, fpixels); + + glTexImage3D(tex->target, 0, internalformat, tex->w, tex->h, tex->depth, 0, format, type, 0); + + if (fpixels) { + glTexSubImage3D(tex->target, 0, 0, 0, 0, w, h, depth, format, type, pixels); + } + + glTexParameterfv(GL_TEXTURE_3D, GL_TEXTURE_BORDER_COLOR, vfBorderColor); + glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER); + glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER); + glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_BORDER); + + if (pixels) + MEM_freeN(pixels); + + if (tex) + GPU_texture_unbind(tex); + + return tex; +} + +GPUTexture *GPU_texture_from_blender(Image *ima, ImageUser *iuser, double time, int mipmap) { GPUTexture *tex; GLint w, h, border, lastbindcode, bindcode; @@ -320,7 +383,7 @@ GPUTexture *GPU_texture_from_blender(Image *ima, ImageUser *iuser, double time) glGetIntegerv(GL_TEXTURE_BINDING_2D, &lastbindcode); GPU_update_image_time(ima, time); - bindcode = GPU_verify_image(ima, 0, 0, 0); + bindcode = GPU_verify_image(ima, 0, 0, 0, mipmap); if(ima->gputexture) { ima->gputexture->bindcode = bindcode; diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c index 7e8b5c18d71..c0fb069fc41 100644 --- a/source/blender/gpu/intern/gpu_material.c +++ b/source/blender/gpu/intern/gpu_material.c @@ -246,7 +246,7 @@ void GPU_material_free(Material *ma) BLI_freelistN(&ma->gpumaterial); } -void GPU_material_bind(GPUMaterial *material, int oblay, int viewlay, double time) +void GPU_material_bind(GPUMaterial *material, int oblay, int viewlay, double time, int mipmap) { if(material->pass) { LinkData *nlink; @@ -266,7 +266,7 @@ void GPU_material_bind(GPUMaterial *material, int oblay, int viewlay, double tim } } - GPU_pass_bind(material->pass, time); + GPU_pass_bind(material->pass, time, mipmap); material->bound = 1; } } @@ -500,7 +500,7 @@ static void ramp_diffuse_result(GPUShadeInput *shi, GPUNodeLink **diff) GPUMaterial *mat= shi->gpumat; GPUNodeLink *fac; - if(!(G.fileflags & G_FILE_GLSL_NO_RAMPS)) { + if(!(mat->scene->gm.flag & GAME_GLSL_NO_RAMPS)) { if(ma->ramp_col) { if(ma->rampin_col==MA_RAMP_IN_RESULT) { GPU_link(mat, "ramp_rgbtobw", *diff, &fac); @@ -516,7 +516,7 @@ static void add_to_diffuse(GPUMaterial *mat, Material *ma, GPUShadeInput *shi, G { GPUNodeLink *fac, *tmp, *addcol; - if(!(G.fileflags & G_FILE_GLSL_NO_RAMPS) && + if(!(mat->scene->gm.flag & GAME_GLSL_NO_RAMPS) && ma->ramp_col && (ma->mode & MA_RAMP_COL)) { /* MA_RAMP_IN_RESULT is exceptional */ if(ma->rampin_col==MA_RAMP_IN_RESULT) { @@ -556,7 +556,7 @@ static void ramp_spec_result(GPUShadeInput *shi, GPUNodeLink **spec) GPUMaterial *mat= shi->gpumat; GPUNodeLink *fac; - if(!(G.fileflags & G_FILE_GLSL_NO_RAMPS) && + if(!(mat->scene->gm.flag & GAME_GLSL_NO_RAMPS) && ma->ramp_spec && ma->rampin_spec==MA_RAMP_IN_RESULT) { GPU_link(mat, "ramp_rgbtobw", *spec, &fac); @@ -644,7 +644,7 @@ static void shade_one_light(GPUShadeInput *shi, GPUShadeResult *shr, GPULamp *la is= inp; /* Lambert */ - if(!(G.fileflags & G_FILE_GLSL_NO_SHADERS)) { + if(!(mat->scene->gm.flag & GAME_GLSL_NO_SHADERS)) { if(ma->diff_shader==MA_DIFF_ORENNAYAR) GPU_link(mat, "shade_diffuse_oren_nayer", inp, vn, lv, view, GPU_uniform(&ma->roughness), &is); else if(ma->diff_shader==MA_DIFF_TOON) @@ -656,7 +656,7 @@ static void shade_one_light(GPUShadeInput *shi, GPUShadeResult *shr, GPULamp *la } } - if(!(G.fileflags & G_FILE_GLSL_NO_SHADERS)) + if(!(mat->scene->gm.flag & GAME_GLSL_NO_SHADERS)) if(ma->shade_flag & MA_CUBIC) GPU_link(mat, "shade_cubic", is, &is); @@ -671,7 +671,7 @@ static void shade_one_light(GPUShadeInput *shi, GPUShadeResult *shr, GPULamp *la // done in shade_visifac now, GPU_link(mat, "mtex_value_clamp_positive", i, &i); if((ma->mode & MA_SHADOW) && GPU_lamp_has_shadow_buffer(lamp)) { - if(!(G.fileflags & G_FILE_GLSL_NO_SHADOWS)) { + if(!(mat->scene->gm.flag & GAME_GLSL_NO_SHADOWS)) { mat->dynproperty |= DYN_LAMP_PERSMAT; GPU_link(mat, "test_shadowbuf", @@ -700,7 +700,7 @@ static void shade_one_light(GPUShadeInput *shi, GPUShadeResult *shr, GPULamp *la GPU_link(mat, "math_multiply", i, shadfac, &i); } } - else if((G.fileflags & G_FILE_GLSL_NO_SHADOWS) && (lamp->mode & LA_ONLYSHADOW)) { + else if((mat->scene->gm.flag & GAME_GLSL_NO_SHADOWS) && (lamp->mode & LA_ONLYSHADOW)) { add_user_list(&mat->lamps, lamp); add_user_list(&lamp->materials, shi->gpumat->ma); return; @@ -716,7 +716,7 @@ static void shade_one_light(GPUShadeInput *shi, GPUShadeResult *shr, GPULamp *la } } - if(G.fileflags & G_FILE_GLSL_NO_SHADERS); + if(mat->scene->gm.flag & GAME_GLSL_NO_SHADERS); else if(!(lamp->mode & LA_NO_SPEC) && !(lamp->mode & LA_ONLYSHADOW) && (GPU_link_changed(shi->spec) || ma->spec != 0.0f)) { if(lamp->type == LA_HEMI) { @@ -1015,11 +1015,11 @@ static void do_material_tex(GPUShadeInput *shi) if(mtex->mapto & MAP_COL) texture_rgb_blend(mat, tcol, shi->rgb, tin, colfac, mtex->blendtype, &shi->rgb); - if(!(G.fileflags & G_FILE_GLSL_NO_EXTRA_TEX) && (mtex->mapto & MAP_COLSPEC)) + if(!(mat->scene->gm.flag & GAME_GLSL_NO_EXTRA_TEX) && (mtex->mapto & MAP_COLSPEC)) texture_rgb_blend(mat, tcol, shi->specrgb, tin, colfac, mtex->blendtype, &shi->specrgb); } - if(!(G.fileflags & G_FILE_GLSL_NO_EXTRA_TEX) && (mtex->mapto & MAP_NORM)) { + if(!(mat->scene->gm.flag & GAME_GLSL_NO_EXTRA_TEX) && (mtex->mapto & MAP_NORM)) { if(mtex->maptoneg & MAP_NORM) tex->norfac= -mtex->norfac; else tex->norfac= mtex->norfac; @@ -1065,22 +1065,22 @@ static void do_material_tex(GPUShadeInput *shi) GPU_link(mat, "mtex_rgbtoint", trgb, &tin); } - if(!(G.fileflags & G_FILE_GLSL_NO_EXTRA_TEX) && mtex->mapto & MAP_REF) { + if(!(mat->scene->gm.flag & GAME_GLSL_NO_EXTRA_TEX) && mtex->mapto & MAP_REF) { int flip= mtex->maptoneg & MAP_REF; texture_value_blend(mat, GPU_uniform(&mtex->def_var), shi->refl, tin, varfac, mtex->blendtype, flip, &shi->refl); GPU_link(mat, "mtex_value_clamp_positive", shi->refl, &shi->refl); } - if(!(G.fileflags & G_FILE_GLSL_NO_EXTRA_TEX) && mtex->mapto & MAP_SPEC) { + if(!(mat->scene->gm.flag & GAME_GLSL_NO_EXTRA_TEX) && mtex->mapto & MAP_SPEC) { int flip= mtex->maptoneg & MAP_SPEC; texture_value_blend(mat, GPU_uniform(&mtex->def_var), shi->spec, tin, varfac, mtex->blendtype, flip, &shi->spec); GPU_link(mat, "mtex_value_clamp_positive", shi->spec, &shi->spec); } - if(!(G.fileflags & G_FILE_GLSL_NO_EXTRA_TEX) && mtex->mapto & MAP_EMIT) { + if(!(mat->scene->gm.flag & GAME_GLSL_NO_EXTRA_TEX) && mtex->mapto & MAP_EMIT) { int flip= mtex->maptoneg & MAP_EMIT; texture_value_blend(mat, GPU_uniform(&mtex->def_var), shi->emit, tin, varfac, mtex->blendtype, flip, &shi->emit); GPU_link(mat, "mtex_value_clamp_positive", shi->emit, &shi->emit); } - if(!(G.fileflags & G_FILE_GLSL_NO_EXTRA_TEX) && mtex->mapto & MAP_HAR) { + if(!(mat->scene->gm.flag & GAME_GLSL_NO_EXTRA_TEX) && mtex->mapto & MAP_HAR) { int flip= mtex->maptoneg & MAP_HAR; GPU_link(mat, "mtex_har_divide", shi->har, &shi->har); texture_value_blend(mat, GPU_uniform(&mtex->def_var), shi->har, tin, varfac, mtex->blendtype, flip, &shi->har); @@ -1091,7 +1091,7 @@ static void do_material_tex(GPUShadeInput *shi) texture_value_blend(mat, GPU_uniform(&mtex->def_var), shi->alpha, tin, varfac, mtex->blendtype, flip, &shi->alpha); GPU_link(mat, "mtex_value_clamp", shi->alpha, &shi->alpha); } - if(!(G.fileflags & G_FILE_GLSL_NO_EXTRA_TEX) && mtex->mapto & MAP_AMB) { + if(!(mat->scene->gm.flag & GAME_GLSL_NO_EXTRA_TEX) && mtex->mapto & MAP_AMB) { int flip= mtex->maptoneg & MAP_AMB; texture_value_blend(mat, GPU_uniform(&mtex->def_var), shi->amb, tin, varfac, mtex->blendtype, flip, &shi->amb); GPU_link(mat, "mtex_value_clamp", shi->amb, &shi->amb); @@ -1139,10 +1139,10 @@ void GPU_shaderesult_set(GPUShadeInput *shi, GPUShadeResult *shr) do_material_tex(shi); - if(ma->mode & MA_ZTRA) + if((ma->mode & MA_TRANSP) && (ma->mode & MA_ZTRANSP)) GPU_material_enable_alpha(mat); - if((G.fileflags & G_FILE_GLSL_NO_LIGHTS) || (ma->mode & MA_SHLESS)) { + if((mat->scene->gm.flag & GAME_GLSL_NO_LIGHTS) || (ma->mode & MA_SHLESS)) { shr->combined = shi->rgb; shr->alpha = shi->alpha; GPU_link(mat, "set_rgb", shi->rgb, &shr->diff); @@ -1213,7 +1213,7 @@ void GPU_shaderesult_set(GPUShadeInput *shi, GPUShadeResult *shr) GPU_uniform(&world->horr), &shr->combined); } - if(!(ma->mode & MA_ZTRA)) { + if(!((ma->mode & MA_TRANSP) && (ma->mode & MA_ZTRANSP))) { if(world && (GPU_link_changed(shr->alpha) || ma->alpha != 1.0f)) GPU_link(mat, "shade_world_mix", GPU_uniform(&world->horr), shr->combined, &shr->combined); @@ -1251,7 +1251,7 @@ GPUMaterial *GPU_material_from_blender(Scene *scene, Material *ma) mat = GPU_material_construct_begin(ma); mat->scene = scene; - if(!(G.fileflags & G_FILE_GLSL_NO_NODES) && ma->nodetree && ma->use_nodes) { + if(!(scene->gm.flag & GAME_GLSL_NO_NODES) && ma->nodetree && ma->use_nodes) { ntreeGPUMaterialNodes(ma->nodetree, mat); } else { @@ -1458,8 +1458,8 @@ void GPU_lamp_free(Object *ob) int GPU_lamp_has_shadow_buffer(GPULamp *lamp) { - return (!(G.fileflags & G_FILE_GLSL_NO_SHADOWS) && - !(G.fileflags & G_FILE_GLSL_NO_LIGHTS) && + return (!(lamp->scene->gm.flag & GAME_GLSL_NO_SHADOWS) && + !(lamp->scene->gm.flag & GAME_GLSL_NO_LIGHTS) && lamp->tex && lamp->fb); } diff --git a/source/blender/imbuf/CMakeLists.txt b/source/blender/imbuf/CMakeLists.txt index 391f6e9e1a2..76dd2afebdc 100644 --- a/source/blender/imbuf/CMakeLists.txt +++ b/source/blender/imbuf/CMakeLists.txt @@ -28,7 +28,7 @@ FILE(GLOB SRC intern/*.c) SET(INC . ../makesdna ../../../intern/guardedalloc ../../../intern/memutil ../blenlib - ../avi ../quicktime ../blenkernel + ../avi ../blenkernel ${JPEG_INC} ${PNG_INC} ${TIFF_INC} @@ -45,7 +45,7 @@ IF(WITH_OPENJPEG) ENDIF(WITH_OPENJPEG) IF(WITH_QUICKTIME) - SET(INC ${INC} ${QUICKTIME_INC}) + SET(INC ${INC} ../quicktime ${QUICKTIME_INC}) ADD_DEFINITIONS(-DWITH_QUICKTIME) ENDIF(WITH_QUICKTIME) diff --git a/source/blender/imbuf/intern/openexr/Makefile b/source/blender/imbuf/intern/openexr/Makefile index f77e3723e8a..083089b11d5 100644 --- a/source/blender/imbuf/intern/openexr/Makefile +++ b/source/blender/imbuf/intern/openexr/Makefile @@ -35,6 +35,9 @@ include nan_compile.mk CFLAGS += $(LEVEL_1_C_WARNINGS) +# If compiling the API, WITH_OPENEXR must be set. +CPPFLAGS += -DWITH_OPENEXR + CPPFLAGS += -I../../../makesdna CPPFLAGS += -I../../../blenkernel CPPFLAGS += -I../../../blenlib diff --git a/source/blender/imbuf/intern/openexr/SConscript b/source/blender/imbuf/intern/openexr/SConscript index aa166a1983c..30757db1cef 100644 --- a/source/blender/imbuf/intern/openexr/SConscript +++ b/source/blender/imbuf/intern/openexr/SConscript @@ -13,6 +13,6 @@ incs = ['.', '../../../makesdna'] incs += Split(env['BF_OPENEXR_INC']) -defs = [] +defs = ['WITH_OPENEXR'] env.BlenderLib ('bf_openexr', source_files, incs, defs, libtype=['core','player'], priority = [225, 85]) diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp index 32d97d79bd7..a780727b1a2 100644 --- a/source/blender/imbuf/intern/openexr/openexr_api.cpp +++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp @@ -51,7 +51,6 @@ _CRTIMP void __cdecl _invalid_parameter_noinfo(void) #include "IMB_imbuf.h" #include "IMB_allocimbuf.h" -#define WITH_OPENEXR #include "openexr_multi.h" } diff --git a/source/blender/makesdna/DNA_actuator_types.h b/source/blender/makesdna/DNA_actuator_types.h index c3f668ff622..278da27faf9 100644 --- a/source/blender/makesdna/DNA_actuator_types.h +++ b/source/blender/makesdna/DNA_actuator_types.h @@ -37,6 +37,9 @@ struct Scene; struct Group; struct Text; +// for Sound3D +#include "DNA_sound_types.h" + /* ****************** ACTUATORS ********************* */ /* unused now, moved to editobjectactuator in 2.02. Still needed for dna */ @@ -62,18 +65,13 @@ typedef struct bSoundActuator { short flag, sndnr; int sta, end; short pad1[2]; + float volume, pitch; struct bSound *sound; + struct Sound3D sound3D; short type, makecopy; short copymade, pad2[1]; } bSoundActuator; -typedef struct bCDActuator { - short flag, sndnr; - int sta, end; - short type, track; - float volume; -} bCDActuator; - typedef struct bEditObjectActuator { int time; short type, flag; @@ -291,7 +289,6 @@ typedef struct FreeCamera { #define ACT_RANDOM 13 #define ACT_MESSAGE 14 #define ACT_ACTION 15 /* __ NLA */ -#define ACT_CD 16 #define ACT_GAME 17 #define ACT_VISIBILITY 18 #define ACT_2DFILTER 19 @@ -432,6 +429,9 @@ typedef struct FreeCamera { #define ACT_RANDOM_FLOAT_NORMAL 8 #define ACT_RANDOM_FLOAT_NEGATIVE_EXPONENTIAL 9 +/* SoundActuator->flag */ +#define ACT_SND_3D_SOUND 1 + /* SoundActuator->type */ #define ACT_SND_PLAY_STOP_SOUND 0 #define ACT_SND_PLAY_END_SOUND 1 @@ -444,15 +444,6 @@ typedef struct FreeCamera { #define ACT_MESG_MESG 0 #define ACT_MESG_PROP 1 -/* cdactuator->type */ -#define ACT_CD_PLAY_ALL 0 -#define ACT_CD_PLAY_TRACK 1 -#define ACT_CD_LOOP_TRACK 2 -#define ACT_CD_VOLUME 3 -#define ACT_CD_STOP 4 -#define ACT_CD_PAUSE 5 -#define ACT_CD_RESUME 6 - /* gameactuator->type */ #define ACT_GAME_LOAD 0 #define ACT_GAME_START 1 diff --git a/source/blender/makesdna/DNA_brush_types.h b/source/blender/makesdna/DNA_brush_types.h index f88d3b68ebf..a3a1a342584 100644 --- a/source/blender/makesdna/DNA_brush_types.h +++ b/source/blender/makesdna/DNA_brush_types.h @@ -58,18 +58,17 @@ typedef struct Brush { int size; /* brush diameter */ float innerradius; /* inner radius after which the falloff starts */ float spacing; /* spacing of paint operations */ + int smooth_stroke_radius; /* turning radius (in pixels) for smooth stroke */ + float smooth_stroke_factor; /* higher values limit fast changes in the stroke direction */ float rate; /* paint operations / second (airbrush) */ float rgb[3]; /* color */ float alpha; /* opacity */ - float rot; /* rotation in radians */ - short texact; /* active texture */ char sculpt_tool; /* active tool */ - char tex_mode; - char pad[4]; + char pad[1]; } Brush; /* Brush.flag */ @@ -85,21 +84,7 @@ typedef struct Brush { #define BRUSH_DIR_IN 512 #define BRUSH_SPACE 1024 #define BRUSH_SMOOTH_STROKE 2048 - -/* Brush.blend */ -#define BRUSH_BLEND_MIX 0 -#define BRUSH_BLEND_ADD 1 -#define BRUSH_BLEND_SUB 2 -#define BRUSH_BLEND_MUL 3 -#define BRUSH_BLEND_LIGHTEN 4 -#define BRUSH_BLEND_DARKEN 5 -#define BRUSH_BLEND_ERASE_ALPHA 6 -#define BRUSH_BLEND_ADD_ALPHA 7 - -/* Brush.tex_mode */ -#define BRUSH_TEX_DRAG 0 -#define BRUSH_TEX_TILE 1 -#define BRUSH_TEX_3D 2 +#define BRUSH_PERSISTENT 4096 /* Brush.sculpt_tool */ #define SCULPT_TOOL_DRAW 1 diff --git a/source/blender/makesdna/DNA_material_types.h b/source/blender/makesdna/DNA_material_types.h index 5b566a244b4..f268c117065 100644 --- a/source/blender/makesdna/DNA_material_types.h +++ b/source/blender/makesdna/DNA_material_types.h @@ -47,6 +47,34 @@ struct Ipo; /* WATCH IT: change type? also make changes in ipo.h */ +typedef struct VolumeSettings { + float density; + float emission; + float absorption; + float scattering; + + float emission_col[3]; + float absorption_col[3]; + float density_scale; + float depth_cutoff; + + short phasefunc_type; + short vpad[3]; + float phasefunc_g; + + float stepsize; + float shade_stepsize; + + short stepsize_type; + short shadeflag; + short shade_type; + short precache_resolution; + + float ms_diff; + float ms_intensity; + int ms_steps; +} VolumeSettings; + typedef struct Material { ID id; struct AnimData *adt; /* animation data (must be immediately after id for utilities to use it) */ @@ -62,6 +90,8 @@ typedef struct Material { float translucency; /* end synced with render_types.h */ + struct VolumeSettings vol; + float fresnel_mir, fresnel_mir_i; float fresnel_tra, fresnel_tra_i; float filter; /* filter added, for raytrace transparency and transmissivity */ @@ -164,7 +194,7 @@ typedef struct Material { #define MA_VERTEXCOL 16 #define MA_HALO_SOFT 16 #define MA_HALO 32 /* deprecated */ -#define MA_ZTRA 64 +#define MA_ZTRANSP 64 #define MA_VERTEXCOLP 128 #define MA_ZINV 256 #define MA_HALO_RINGS 256 @@ -180,7 +210,7 @@ typedef struct Material { #define MA_NOMIST 0x4000 #define MA_HALO_SHADE 0x4000 #define MA_HALO_FLARE 0x8000 -#define MA_RADIO 0x10000 +#define MA_TRANSP 0x10000 #define MA_RAYTRANSP 0x20000 #define MA_RAYMIRROR 0x40000 #define MA_SHADOW_TRA 0x80000 @@ -224,7 +254,7 @@ typedef struct Material { #define MA_SPEC_WARDISO 4 /* dynamode */ -#define MA_DRAW_DYNABUTS 1 +#define MA_DRAW_DYNABUTS 1 /* deprecated */ #define MA_FH_NOR 2 /* ramps */ @@ -287,6 +317,14 @@ typedef struct Material { #define MAP_WARP 8192 #define MAP_LAYER 16384 +/* volume mapto - reuse definitions for now - a bit naughty! */ +#define MAP_DENSITY 128 +#define MAP_EMISSION 64 +#define MAP_EMISSION_COL 1 +#define MAP_ABSORPTION 512 +#define MAP_ABSORPTION_COL 8 +#define MAP_SCATTERING 16 + /* mapto for halo */ //#define MAP_HA_COL 1 //#define MAP_HA_ALPHA 128 @@ -330,5 +368,29 @@ typedef struct Material { /* sss_flag */ #define MA_DIFF_SSS 1 +/* vol_stepsize_type */ +#define MA_VOL_STEP_RANDOMIZED 0 +#define MA_VOL_STEP_CONSTANT 1 +#define MA_VOL_STEP_ADAPTIVE 2 + +/* vol_shadeflag */ +#define MA_VOL_SHADED 1 +#define MA_VOL_RECVSHADOW 4 +#define MA_VOL_PRECACHESHADING 8 + +/* vol_shading_type */ +#define MA_VOL_SHADE_NONE 0 +#define MA_VOL_SHADE_SINGLE 1 +#define MA_VOL_SHADE_MULTIPLE 2 +#define MA_VOL_SHADE_SINGLEPLUSMULTIPLE 3 + +/* vol_phasefunc_type */ +#define MA_VOL_PH_ISOTROPIC 0 +#define MA_VOL_PH_MIEHAZY 1 +#define MA_VOL_PH_MIEMURKY 2 +#define MA_VOL_PH_RAYLEIGH 3 +#define MA_VOL_PH_HG 4 +#define MA_VOL_PH_SCHLICK 5 + #endif diff --git a/source/blender/makesdna/DNA_mesh_types.h b/source/blender/makesdna/DNA_mesh_types.h index 01c009a7971..52323913ee4 100644 --- a/source/blender/makesdna/DNA_mesh_types.h +++ b/source/blender/makesdna/DNA_mesh_types.h @@ -156,7 +156,7 @@ typedef struct TFace { #define ME_DRAWCREASES (1 << 6) #define ME_DRAWSEAMS (1 << 7) #define ME_DRAWSHARP (1 << 8) -#define ME_DRAWBWEIGHTS (1 << 8) +#define ME_DRAWBWEIGHTS (1 << 9) #define ME_DRAW_EDGELEN (1 << 10) #define ME_DRAW_FACEAREA (1 << 11) diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h index 3f504848d77..be7452c4ae1 100644 --- a/source/blender/makesdna/DNA_modifier_types.h +++ b/source/blender/makesdna/DNA_modifier_types.h @@ -252,7 +252,6 @@ typedef struct SmokeModifierData { struct SmokeCollSettings *coll; /* collision objects */ float time; int type; /* domain, inflow, outflow, ... */ - struct PointCache *point_cache; /* definition is in DNA_object_force.h */ } SmokeModifierData; typedef struct DisplaceModifierData { @@ -290,7 +289,7 @@ typedef struct UVProjectModifierData { ModifierData modifier; /* the objects which do the projecting */ - struct Object *projectors[10]; + struct Object *projectors[10]; /* MOD_UVPROJECT_MAX */ struct Image *image; /* the image to project */ int flags; int num_projectors; @@ -398,6 +397,8 @@ typedef struct HookModifierData { ModifierData modifier; struct Object *object; + char subtarget[32]; /* optional name of bone target */ + float parentinv[4][4]; /* matrix making current transform unmodified */ float cent[3]; /* visualization of hook */ float falloff; /* if not zero, falloff is distance where influence zero */ @@ -420,6 +421,7 @@ typedef struct ClothModifierData { struct ClothSimSettings *sim_parms; /* definition is in DNA_cloth_types.h */ struct ClothCollSettings *coll_parms; /* definition is in DNA_cloth_types.h */ struct PointCache *point_cache; /* definition is in DNA_object_force.h */ + struct ListBase ptcaches; } ClothModifierData; typedef struct CollisionModifierData { @@ -640,4 +642,6 @@ typedef struct SimpleDeformModifierData { coordinates or global coordinates of origin */ #define MOD_SIMPLEDEFORM_ORIGIN_LOCAL (1<<0) +#define MOD_UVPROJECT_MAX 10 + #endif diff --git a/source/blender/makesdna/DNA_object_force.h b/source/blender/makesdna/DNA_object_force.h index b5b33610bfe..625864c4888 100644 --- a/source/blender/makesdna/DNA_object_force.h +++ b/source/blender/makesdna/DNA_object_force.h @@ -74,14 +74,36 @@ typedef struct PartDeflect { int seed; /* wind noise random seed */ } PartDeflect; +/* Point cache file data types: + * - used as (1<<flag) so poke jahka if you reach the limit of 15 + * - to add new data types update: + * * BKE_ptcache_data_size() + * * ptcache_file_init_pointers() +*/ +#define BPHYS_DATA_INDEX 0 +#define BPHYS_DATA_LOCATION 1 +#define BPHYS_DATA_VELOCITY 2 +#define BPHYS_DATA_ROTATION 3 +#define BPHYS_DATA_AVELOCITY 4 /* used for particles */ +#define BPHYS_DATA_XCONST 4 /* used for cloth */ +#define BPHYS_DATA_SIZE 5 +#define BPHYS_DATA_TIMES 6 +#define BPHYS_DATA_BOIDS 7 + +#define BPHYS_TOT_DATA 8 + typedef struct PTCacheMem { struct PTCacheMem *next, *prev; int frame, totpoint; - float *data; /* data points */ - void *xdata; /* extra data */ + unsigned int data_types, rt; + int *index_array; /* quick access to stored points with index */ + + void *data[8]; /* BPHYS_TOT_DATA */ + void *cur[8]; /* BPHYS_TOT_DATA */ } PTCacheMem; typedef struct PointCache { + struct PointCache *next, *prev; int flag; /* generic flag */ int step; /* frames between cached frames */ int simframe; /* current frame of simulation (only if SIMULATION_VALID) */ @@ -229,6 +251,7 @@ typedef struct SoftBody { float inpush; struct PointCache *pointcache; + struct ListBase ptcaches; } SoftBody; @@ -283,6 +306,7 @@ typedef struct SoftBody { #define PTCACHE_QUICK_CACHE 128 #define PTCACHE_FRAMES_SKIPPED 256 #define PTCACHE_EXTERNAL 512 +#define PTCACHE_READ_INFO 1024 /* PTCACHE_OUTDATED + PTCACHE_FRAMES_SKIPPED */ #define PTCACHE_REDO_NEEDED 258 diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h index fa594417a17..5b10141f6cc 100644 --- a/source/blender/makesdna/DNA_object_types.h +++ b/source/blender/makesdna/DNA_object_types.h @@ -53,6 +53,7 @@ struct SoftBody; struct FluidsimSettings; struct ParticleSystem; struct DerivedMesh; +struct SculptSession; typedef struct bDeformGroup { struct bDeformGroup *next, *prev; @@ -91,6 +92,8 @@ typedef struct BoundBox { typedef struct Object { ID id; struct AnimData *adt; /* animation data (must be immediately after id for utilities to use it) */ + + struct SculptSession *sculpt; short type, partype; int par1, par2, par3; /* can be vertexnrs */ @@ -113,6 +116,9 @@ typedef struct Object { ListBase defbase; ListBase modifiers; /* list of ModifierData structures */ + int mode; /* Local object mode */ + int restore_mode; /* Keep track of what mode to return to after toggling a mode */ + /* materials */ struct Material **mat; /* material slots */ char *matbits; /* a bitfield, with each bit 1 if corrusponding material linked to object */ @@ -227,9 +233,11 @@ typedef struct Object { int lastDataMask; /* the custom data layer mask that was last used to calculate derivedDeform and derivedFinal */ unsigned int state; /* bit masks of game controllers that are active */ unsigned int init_state; /* bit masks of initial state as recorded by the users */ + int pad2; ListBase gpulamp; /* runtime, for lamps only */ + ListBase pc_ids; } Object; /* Warning, this is not used anymore because hooks are now modifiers */ @@ -395,7 +403,6 @@ extern Object workob; #define OB_DONE 1024 #define OB_RADIO 2048 #define OB_FROMGROUP 4096 -#define OB_POSEMODE 8192 /* ob->recalc (flag bits!) */ #define OB_RECALC_OB 1 @@ -504,7 +511,17 @@ extern Object workob; #define OB_LOCK_SCALEZ 256 #define OB_LOCK_SCALE 448 -/* ob->softflag in DNA_object_force.h */ +/* ob->mode */ +typedef enum ObjectMode { + OB_MODE_OBJECT = 0, + OB_MODE_EDIT = 1, + OB_MODE_SCULPT = 2, + OB_MODE_VERTEX_PAINT = 4, + OB_MODE_WEIGHT_PAINT = 8, + OB_MODE_TEXTURE_PAINT = 16, + OB_MODE_PARTICLE_EDIT = 32, + OB_MODE_POSE = 64 +} ObjectMode; #ifdef __cplusplus } diff --git a/source/blender/makesdna/DNA_particle_types.h b/source/blender/makesdna/DNA_particle_types.h index b71d390db5a..925fd31328d 100644 --- a/source/blender/makesdna/DNA_particle_types.h +++ b/source/blender/makesdna/DNA_particle_types.h @@ -229,6 +229,7 @@ typedef struct ParticleSystem{ /* note, make sure all (runtime) are NULL's in /* point cache */ struct PointCache *pointcache; + struct ListBase ptcaches; struct KDTree *tree; /* used for interactions with self and other systems */ }ParticleSystem; diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index 752f756401c..9161157f597 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -47,6 +47,7 @@ struct Text; struct bNodeTree; struct AnimData; struct Editing; +struct SceneStats; typedef struct Base { struct Base *next, *prev; @@ -387,7 +388,7 @@ typedef struct GameData { * bit 3: (gameengine): Activity culling is enabled. * bit 5: (gameengine) : enable Bullet DBVT tree for view frustrum culling */ - short mode, pad11; + short mode, flag, matmode, pad[3]; short occlusionRes; /* resolution of occlusion Z buffer in pixel */ short physicsEngine; short ticrate, maxlogicstep, physubstep, maxphystep; @@ -401,6 +402,7 @@ typedef struct GameData { struct GameDome dome; short stereoflag, stereomode, xsch, ysch; //xsch and ysch can be deleted !!! } GameData; + #define STEREO_NOSTEREO 1 #define STEREO_ENABLED 2 #define STEREO_DOME 3 @@ -422,6 +424,25 @@ typedef struct GameData { #define WOPHY_ODE 4 #define WOPHY_BULLET 5 +/* GameData.flag */ +#define GAME_ENABLE_ALL_FRAMES (1 << 1) +#define GAME_SHOW_DEBUG_PROPS (1 << 2) +#define GAME_SHOW_FRAMERATE (1 << 3) +#define GAME_SHOW_PHYSICS (1 << 4) +#define GAME_DISPLAY_LISTS (1 << 5) +#define GAME_GLSL_NO_LIGHTS (1 << 6) +#define GAME_GLSL_NO_SHADERS (1 << 7) +#define GAME_GLSL_NO_SHADOWS (1 << 8) +#define GAME_GLSL_NO_RAMPS (1 << 9) +#define GAME_GLSL_NO_NODES (1 << 10) +#define GAME_GLSL_NO_EXTRA_TEX (1 << 11) +#define GAME_IGNORE_DEPRECATION_WARNINGS (1 << 12) + +/* GameData.matmode */ +#define GAME_MAT_TEXFACE 0 +#define GAME_MAT_MULTITEX 1 +#define GAME_MAT_GLSL 2 + typedef struct TimeMarker { struct TimeMarker *next, *prev; int frame; @@ -429,8 +450,21 @@ typedef struct TimeMarker { unsigned int flag; } TimeMarker; +typedef struct Paint { + /* Array of brushes selected for use in this paint mode */ + Brush **brushes; + int active_brush_index, brush_count; + + /* WM Paint cursor */ + void *paint_cursor; + unsigned char paint_cursor_col[4]; + + int pad; +} Paint; + typedef struct ImagePaintSettings { - struct Brush *brush; + Paint paint; + short flag, tool; /* for projection painting only */ @@ -465,26 +499,20 @@ typedef struct TransformOrientation { float mat[3][3]; } TransformOrientation; -struct SculptSession; -typedef struct Sculpt -{ - /* Note! a deep copy of this struct must be done header_info.c's copy_scene function */ - /* Data stored only from entering sculptmode until exiting sculptmode */ - struct SculptSession *session; - struct Brush *brush; +typedef struct Sculpt { + Paint paint; /* For rotating around a pivot point */ float pivot[3]; int flags; - /* For the Brush Shape */ - char texsep; + /* Control tablet input */ char tablet_size, tablet_strength; - char pad[5]; + char pad[6]; } Sculpt; typedef struct VPaint { - struct Brush *brush; + Paint paint; float gamma, mul; /* should become part of struct Brush? */ short mode, flag; @@ -622,6 +650,12 @@ typedef struct bStats { int totvert, totface; } bStats; +typedef struct UnitSettings { + /* Display/Editing unit options for each scene */ + float scale_length; /* maybe have other unit conversions? */ + short system; + short flag; /* imperial, metric etc */ +} UnitSettings; typedef struct Scene { ID id; @@ -642,7 +676,7 @@ typedef struct Scene { float twmin[3], twmax[3]; /* boundbox of selection for transform widget */ unsigned int lay; - + short flag; /* various settings */ short use_nodes; @@ -662,6 +696,7 @@ typedef struct Scene { ListBase markers; ListBase transform_spaces; + ListBase sound_handles; /* none of the dependancy graph vars is mean to be saved */ struct DagForest *theDag; @@ -680,6 +715,9 @@ typedef struct Scene { /* Game Settings */ struct GameFraming framing; // XXX deprecated since 2.5 struct GameData gm; + + /* Units */ + struct UnitSettings unit; } Scene; @@ -1071,6 +1109,15 @@ typedef enum SculptFlags { #define SK_RETARGET_ROLL_VIEW 1 #define SK_RETARGET_ROLL_JOINT 2 +/* UnitSettings */ + +/* UnitSettings->system */ +#define USER_UNIT_NONE 0 +#define USER_UNIT_METRIC 1 +#define USER_UNIT_IMPERIAL 2 +/* UnitSettings->flag */ +#define USER_UNIT_OPT_SPLIT 1 + #ifdef __cplusplus } diff --git a/source/blender/makesdna/DNA_sensor_types.h b/source/blender/makesdna/DNA_sensor_types.h index 8b29ce1338d..cc998de7eec 100644 --- a/source/blender/makesdna/DNA_sensor_types.h +++ b/source/blender/makesdna/DNA_sensor_types.h @@ -178,6 +178,9 @@ typedef struct bJoystickSensor { /* bMouseSensor->type: uses blender event defines */ +/* bMouseSensor->flag: only pulse for now */ +#define SENS_MOUSE_FOCUS_PULSE 1 + /* propertysensor->type */ #define SENS_PROP_EQUAL 0 #define SENS_PROP_NEQUAL 1 diff --git a/source/blender/makesdna/DNA_sequence_types.h b/source/blender/makesdna/DNA_sequence_types.h index 422e1b07ed7..6d455d20f59 100644 --- a/source/blender/makesdna/DNA_sequence_types.h +++ b/source/blender/makesdna/DNA_sequence_types.h @@ -160,7 +160,7 @@ typedef struct Sequence { ListBase seqbase; /* list of strips for metastrips */ struct bSound *sound; /* the linked "bSound" object */ - struct hdaudio *hdaudio; /* external hdaudio object */ + struct SoundHandle *sound_handle; float level, pan; /* level in dB (0=full), pan -1..1 */ int scenenr; /* for scene selection */ float strobe; @@ -281,7 +281,7 @@ typedef struct SpeedControlVars { #define SEQ_MOVIE 3 #define SEQ_RAM_SOUND 4 #define SEQ_HD_SOUND 5 -#define SEQ_MOVIE_AND_HD_SOUND 6 /* helper for add_sequence */ +#define SEQ_SOUND 4 #define SEQ_EFFECT 8 #define SEQ_CROSS 8 diff --git a/source/blender/makesdna/DNA_smoke_types.h b/source/blender/makesdna/DNA_smoke_types.h index c3efc5e04dd..7c6c7fab9e4 100644 --- a/source/blender/makesdna/DNA_smoke_types.h +++ b/source/blender/makesdna/DNA_smoke_types.h @@ -30,20 +30,17 @@ #define DNA_SMOKE_TYPES_H /* flags */ -#define MOD_SMOKE_HIGHRES (1<<1) +#define MOD_SMOKE_HIGHRES (1<<1) /* enable high resolution */ +#define MOD_SMOKE_DISSOLVE (1<<2) /* let smoke dissolve */ +#define MOD_SMOKE_DISSOLVE_LOG (1<<3) /* using 1/x for dissolve */ + /* noise */ #define MOD_SMOKE_NOISEWAVE (1<<0) #define MOD_SMOKE_NOISEFFT (1<<1) #define MOD_SMOKE_NOISECURL (1<<2) + /* viewsettings */ -#define MOD_SMOKE_VIEW_X (1<<0) -#define MOD_SMOKE_VIEW_Y (1<<1) -#define MOD_SMOKE_VIEW_Z (1<<2) -#define MOD_SMOKE_VIEW_SMALL (1<<3) -#define MOD_SMOKE_VIEW_BIG (1<<4) -#define MOD_SMOKE_VIEW_CHANGETOBIG (1<<5) -#define MOD_SMOKE_VIEW_REDRAWNICE (1<<6) -#define MOD_SMOKE_VIEW_REDRAWALL (1<<7) +#define MOD_SMOKE_SHOWHIGHRES (1<<0) /* show high resolution */ typedef struct SmokeDomainSettings { struct SmokeModifierData *smd; /* for fast RNA access */ @@ -51,32 +48,35 @@ typedef struct SmokeDomainSettings { struct Group *fluid_group; struct Group *eff_group; // effector group for e.g. wind force struct Group *coll_group; // collision objects group - unsigned int *bind; - float *tvox; - float *tray; - float *tvoxbig; - float *traybig; + struct GPUTexture *tex; + float *view3d; /* voxel data for display */ + unsigned int v3dnum; /* number of frame in view3d buffer */ float p0[3]; /* start point of BB */ float p1[3]; /* end point of BB */ float dx; /* edge length of one cell */ float firstframe; float lastframe; - float omega; /* smoke color - from 0 to 1 */ float temp; /* fluid temperature */ float tempAmb; /* ambient temperature */ float alpha; float beta; int res[3]; /* domain resolution */ - int amplify; /* wavelet amplification */ int maxres; /* longest axis on the BB gets this resolution assigned */ int flags; /* show up-res or low res, etc */ - int visibility; /* how many billboards to show (every 2nd, 3rd, 4th,..) */ int viewsettings; - int max_textures; + short diss_percent; + short pad; + int diss_speed;/* in frames */ + struct PointCache *point_cache[2]; /* definition is in DNA_object_force.h */ + struct ListBase ptcaches[2]; + struct WTURBULENCE *wt; // WTURBULENCE object, if active + int pad3; + float strength; + int res_wt[3]; + int maxres_wt; short noise; /* noise type: wave, curl, anisotropic */ short pad2; - int pad; - int pad3; + int amplify; } SmokeDomainSettings; @@ -99,10 +99,17 @@ typedef struct SmokeFlowSettings { int pad; } SmokeFlowSettings; +/* + struct BVHTreeFromMesh *bvh; + float mat[4][4]; + float mat_old[4][4]; + */ + /* collision objects (filled with smoke) */ typedef struct SmokeCollSettings { struct SmokeModifierData *smd; /* for fast RNA access */ struct BVHTree *bvhtree; /* bounding volume hierarchy for this cloth object */ + struct DerivedMesh *dm; float *points; float *points_old; float *vel; diff --git a/source/blender/makesdna/DNA_sound_types.h b/source/blender/makesdna/DNA_sound_types.h index 5dedd20e1e4..5f6ebf60865 100644 --- a/source/blender/makesdna/DNA_sound_types.h +++ b/source/blender/makesdna/DNA_sound_types.h @@ -37,45 +37,46 @@ /* stupid... could easily be solved */ #include "DNA_view2d_types.h" -/* extern int noaudio; * defined in sound.c . also not very nice */ -/* extern ListBase *samples; don't do this in DNA, but in BKE_... instead */ - -struct bSample; struct Ipo; struct PackedFile; struct SpaceLink; -/* should not be here! */ -# -# -typedef struct bSample { - ID id; - void *data; - void *snd_sample; - short type, bits; - short channels; - int len, rate; -// int buffer; - int alindex; - char fakedata[16]; - int flags; - char name[160]; - struct PackedFile * packedfile; - short us; -} bSample; - - +// runtime only - no saving +typedef struct SoundHandle { + struct SoundHandle *next, *prev; + struct bSound *source; + void *handle; + int state; + int startframe; + int endframe; + int frameskip; + int mute; + int changed; + float volume; + float pad; +} SoundHandle; + +typedef struct Sound3D +{ + float min_gain; + float max_gain; + float reference_distance; + float max_distance; + float rolloff_factor; + float cone_inner_angle; + float cone_outer_angle; + float cone_outer_gain; +} Sound3D; typedef struct bSound { ID id; char name[160]; - struct bSample *sample; - void *stream; + void *stream; // AUD_XXX deprecated struct PackedFile *packedfile; - struct PackedFile *newpackedfile; - void *snd_sound; - struct Ipo *ipo; - float volume, panning; + struct PackedFile *newpackedfile; // AUD_XXX deprecated + void *snd_sound; // AUD_XXX used for AUD_Sound now + struct Ipo *ipo; // AUD_XXX deprecated + float volume, panning; // AUD_XXX deprecated /** * Sets the rollofffactor. The rollofffactor is a per-Source parameter * the application can use to increase or decrease the range of a source @@ -84,47 +85,42 @@ typedef struct bSound { * value of 0, which indicates that the application does not wish any * distance attenuation on the respective Source. */ - float attenuation; - float pitch; + float attenuation; // AUD_XXX deprecated + float pitch; // AUD_XXX deprecated /** * min_gain indicates the minimal gain which is always guaranteed for this sound */ - float min_gain; + float min_gain; // AUD_XXX deprecated /** * max_gain indicates the maximal gain which is always guaranteed for this sound */ - float max_gain; + float max_gain; // AUD_XXX deprecated /** * Sets the referencedistance at which the listener will experience gain. */ - float distance; - int flags; - int streamlen; - char channels; - char highprio; - char pad[10]; + float distance; // AUD_XXX deprecated + int flags; // AUD_XXX deprecated + int streamlen; // AUD_XXX deprecated + char channels; // AUD_XXX deprecated + char highprio; // AUD_XXX deprecated + char pad[10]; // AUD_XXX deprecated + + // AUD_XXX NEW + int type; + int changed; + struct bSound *child_sound; + void *cache; + + // SOUND_TYPE_LIMITER + float start, end; } bSound; -typedef struct bSoundListener { - ID id; - /** - * Overall gain - */ - float gain; - /** - * Sets a scaling to exaggerate or deemphasize the Doppler (pitch) shift - * resulting from the calculation. - */ - float dopplerfactor; - /** - * Sets the value of the propagation speed relative to which the source - * velocities are interpreted. - */ - float dopplervelocity; - short numsoundsblender; - short numsoundsgameengine; - -} bSoundListener; +typedef enum eSound_Type { + SOUND_TYPE_INVALID = -1, + SOUND_TYPE_FILE = 0, + SOUND_TYPE_BUFFER, + SOUND_TYPE_LIMITER +} eSound_Type; /* spacesound->flag */ #define SND_DRAWFRAMES 1 @@ -147,20 +143,6 @@ typedef struct SpaceSound { } SpaceSound; -enum SAMPLE_FileTypes { - SAMPLE_INVALID = -1, // must be negative - SAMPLE_UNKNOWN = 0, - SAMPLE_RAW, - SAMPLE_WAV, - SAMPLE_MP2, - SAMPLE_MP3, - SAMPLE_OGG_VORBIS, - SAMPLE_WMA, - SAMPLE_ASF, - SAMPLE_AIFF -}; - - #define SOUND_CHANNELS_STEREO 0 #define SOUND_CHANNELS_LEFT 1 #define SOUND_CHANNELS_RIGHT 2 @@ -173,8 +155,6 @@ enum SAMPLE_FileTypes { #define SOUND_FLAGS_PRIORITY (1 << 5) #define SOUND_FLAGS_SEQUENCE (1 << 6) -#define SAMPLE_NEEDS_SAVE (1 << 0) - /* to DNA_sound_types.h*/ #endif diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h index d24d9af4177..6fdc3a7787b 100644 --- a/source/blender/makesdna/DNA_space_types.h +++ b/source/blender/makesdna/DNA_space_types.h @@ -508,6 +508,13 @@ typedef struct SpaceConsole { } SpaceConsole; +typedef struct SpaceUserPref { + SpaceLink *next, *prev; + ListBase regionbase; /* storage of regions for inactive spaces */ + int spacetype; + + int pad; +} SpaceUserPref; /* view3d Now in DNA_view3d_types.h */ @@ -713,6 +720,7 @@ enum FileSortTypeE { #define SIPO_DRAWTIME (1<<4) #define SIPO_SELCUVERTSONLY (1<<5) #define SIPO_DRAWNAMES (1<<6) +#define SIPO_SLIDERS (1<<7) /* SpaceIpo->mode (Graph Editor Mode) */ enum { @@ -821,7 +829,7 @@ enum { #define TIME_ALL_3D_WIN 2 #define TIME_ALL_ANIM_WIN 4 #define TIME_ALL_BUTS_WIN 8 -#define TIME_WITH_SEQ_AUDIO 16 +#define TIME_WITH_SEQ_AUDIO 16 // deprecated #define TIME_SEQ 32 #define TIME_ALL_IMAGE_WIN 64 #define TIME_CONTINUE_PHYSICS 128 @@ -861,7 +869,8 @@ enum { SPACE_NODE, SPACE_LOGIC, SPACE_CONSOLE, - SPACEICONMAX = SPACE_CONSOLE + SPACE_USERPREF, + SPACEICONMAX = SPACE_USERPREF }; #endif diff --git a/source/blender/makesdna/DNA_texture_types.h b/source/blender/makesdna/DNA_texture_types.h index 7325181ee14..1b6ed1bc032 100644 --- a/source/blender/makesdna/DNA_texture_types.h +++ b/source/blender/makesdna/DNA_texture_types.h @@ -53,17 +53,17 @@ typedef struct MTex { char uvname[32]; char projx, projy, projz, mapping; - float ofs[3], size[3]; + float ofs[3], size[3], rot; short texflag, colormodel, pmapto, pmaptoneg; - short normapspace, which_output, pad[2]; + short normapspace, which_output; + char brush_map_mode, pad[7]; float r, g, b, k; float def_var, rt; float colfac, norfac, varfac; float dispfac; float warpfac; - } MTex; #ifndef DNA_USHORT_FIX @@ -128,6 +128,55 @@ typedef struct EnvMap { short recalc, lastsize; } EnvMap; +typedef struct PointDensity { + short flag; + + short falloff_type; + float falloff_softness; + float radius; + short source; + short color_source; + int totpoints; + + int pdpad; + + struct Object *object; /* for 'Object' or 'Particle system' type - source object */ + struct ParticleSystem *psys; + short psys_cache_space; /* cache points in worldspace, object space, ... ? */ + short ob_cache_space; /* cache points in worldspace, object space, ... ? */ + + short pdpad2[2]; + + void *point_tree; /* the acceleration tree containing points */ + float *point_data; /* dynamically allocated extra for extra information, like particle age */ + + float noise_size; + short noise_depth; + short noise_influence; + short noise_basis; + short pdpad3[3]; + float noise_fac; + + float speed_scale; + struct ColorBand *coba; /* for time -> color */ + +} PointDensity; + +typedef struct VoxelData { + int resol[3]; + int interp_type; + short file_format; + short flag; + int pad; + + struct Object *object; /* for rendering smoke sims */ + float int_multiplier; + int still_frame; + char source_path[240]; + float *dataset; + +} VoxelData; + typedef struct Tex { ID id; struct AnimData *adt; /* animation data (must be immediately after id for utilities to use it) */ @@ -143,7 +192,11 @@ typedef struct Tex { float dist_amount, ns_outscale; /* newnoise: voronoi nearest neighbour weights, minkovsky exponent, distance metric & color type */ - float vn_w1, vn_w2, vn_w3, vn_w4, vn_mexp; + float vn_w1; + float vn_w2; + float vn_w3; + float vn_w4; + float vn_mexp; short vn_distm, vn_coltype; short noisedepth, noisetype; @@ -177,6 +230,8 @@ typedef struct Tex { struct ColorBand *coba; struct EnvMap *env; struct PreviewImage * preview; + struct PointDensity *pd; + struct VoxelData *vd; char use_nodes; char pad[7]; @@ -216,6 +271,8 @@ typedef struct TexMapping { #define TEX_MUSGRAVE 11 #define TEX_VORONOI 12 #define TEX_DISTNOISE 13 +#define TEX_POINTDENSITY 14 +#define TEX_VOXELDATA 15 /* musgrave stype */ #define TEX_MFRACTAL 0 @@ -392,6 +449,11 @@ typedef struct TexMapping { #define MTEX_BLEND_COLOR 13 #define MTEX_NUM_BLENDTYPES 14 +/* brush_map_mode */ +#define MTEX_MAP_MODE_FIXED 0 +#define MTEX_MAP_MODE_TILED 1 +#define MTEX_MAP_MODE_3D 2 + /* **************** EnvMap ********************* */ /* type */ @@ -408,5 +470,59 @@ typedef struct TexMapping { #define ENV_NORMAL 1 #define ENV_OSA 2 +/* **************** PointDensity ********************* */ + +/* source */ +#define TEX_PD_PSYS 0 +#define TEX_PD_OBJECT 1 +#define TEX_PD_FILE 2 + +/* falloff_type */ +#define TEX_PD_FALLOFF_STD 0 +#define TEX_PD_FALLOFF_SMOOTH 1 +#define TEX_PD_FALLOFF_SOFT 2 +#define TEX_PD_FALLOFF_CONSTANT 3 +#define TEX_PD_FALLOFF_ROOT 4 + +/* psys_cache_space */ +#define TEX_PD_OBJECTLOC 0 +#define TEX_PD_OBJECTSPACE 1 +#define TEX_PD_WORLDSPACE 2 + +/* flag */ +#define TEX_PD_TURBULENCE 1 + + +/* noise_influence */ +#define TEX_PD_NOISE_STATIC 0 +#define TEX_PD_NOISE_VEL 1 +#define TEX_PD_NOISE_AGE 2 +#define TEX_PD_NOISE_TIME 3 + +/* color_source */ +#define TEX_PD_COLOR_CONSTANT 0 +#define TEX_PD_COLOR_PARTAGE 1 +#define TEX_PD_COLOR_PARTSPEED 2 +#define TEX_PD_COLOR_PARTVEL 3 + +#define POINT_DATA_VEL 1 +#define POINT_DATA_LIFE 2 + +/******************** Voxel Data *****************************/ +/* flag */ +#define TEX_VD_STILL 1 + +/* interpolation */ +#define TEX_VD_NEARESTNEIGHBOR 0 +#define TEX_VD_LINEAR 1 +#define TEX_VD_TRICUBIC 2 + +/* file format */ +#define TEX_VD_BLENDERVOXEL 0 +#define TEX_VD_RAW_8BIT 1 +#define TEX_VD_RAW_16BIT 2 +#define TEX_VD_IMAGE_SEQUENCE 3 +#define TEX_VD_SMOKE 4 + #endif diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index f61b4b2904d..100f55ffe33 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -260,6 +260,7 @@ typedef struct bTheme { ThemeSpace ttime; ThemeSpace tnode; ThemeSpace tlogic; + ThemeSpace tuserpref; /* 20 sets of bone colors for this theme */ ThemeWireColor tarm[20]; @@ -293,6 +294,11 @@ typedef struct UserDef { short userpref, viewzoom; int mixbufsize; + int audiodevice; + int audiorate; + int audioformat; + int audiochannels; + int scrollback; /* console scrollback limit */ int dpi; /* range 48-128? */ short encoding; @@ -363,6 +369,7 @@ extern UserDef U; /* from blenkernel blender.c */ #define USER_RELPATHS (1 << 20) #define USER_DRAGIMMEDIATE (1 << 21) #define USER_DONT_DOSCRIPTLINKS (1 << 22) +#define USER_FILENOUI (1 << 23) /* viewzom */ #define USER_ZOOM_CONT 0 @@ -411,7 +418,6 @@ extern UserDef U; /* from blenkernel blender.c */ /* toolsettings->autokey_flag */ #define ANIMRECORD_FLAG_WITHNLA (1<<10) - /* transopts */ #define USER_TR_TOOLTIPS (1 << 0) #define USER_TR_BUTTONS (1 << 1) diff --git a/source/blender/makesdna/DNA_windowmanager_types.h b/source/blender/makesdna/DNA_windowmanager_types.h index b6a2b4c0544..7d03bbec1ee 100644 --- a/source/blender/makesdna/DNA_windowmanager_types.h +++ b/source/blender/makesdna/DNA_windowmanager_types.h @@ -54,6 +54,7 @@ struct StructRNA; struct PointerRNA; struct ReportList; struct Report; +struct uiLayout; #define OP_MAX_TYPENAME 64 #define KMAP_MAX_NAME 64 @@ -208,8 +209,8 @@ typedef struct wmOperatorType { * that the operator might still fail to execute even if this return true */ int (*poll)(struct bContext *); - /* panel for redo and repeat */ - void *(*uiBlock)(struct wmOperator *); + /* optional panel for redo and repeat, autogenerated if not set */ + void (*ui)(struct bContext *, struct PointerRNA *, struct uiLayout *); /* rna for properties */ struct StructRNA *srna; diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index 1b3175d7f55..ea7451ee77a 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -252,6 +252,7 @@ extern StructRNA RNA_MarbleTexture; extern StructRNA RNA_MaskModifier; extern StructRNA RNA_Material; extern StructRNA RNA_MaterialHalo; +extern StructRNA RNA_MaterialPhysics; extern StructRNA RNA_MaterialRaytraceMirror; extern StructRNA RNA_MaterialRaytraceTransparency; extern StructRNA RNA_MaterialSlot; @@ -304,8 +305,11 @@ extern StructRNA RNA_OperatorStrokeElement; extern StructRNA RNA_OrController; extern StructRNA RNA_OutflowFluidSettings; extern StructRNA RNA_PackedFile; +extern StructRNA RNA_Paint; extern StructRNA RNA_Panel; extern StructRNA RNA_Particle; +extern StructRNA RNA_ParticleBrush; +extern StructRNA RNA_ParticleEdit; extern StructRNA RNA_ParticleFluidSettings; extern StructRNA RNA_ParticleHairKey; extern StructRNA RNA_ParticleInstanceModifier; @@ -317,6 +321,8 @@ extern StructRNA RNA_ParticleTarget; extern StructRNA RNA_PluginSequence; extern StructRNA RNA_PluginTexture; extern StructRNA RNA_PointCache; +extern StructRNA RNA_PointDensity; +extern StructRNA RNA_PointDensityTexture; extern StructRNA RNA_PointerProperty; extern StructRNA RNA_Pose; extern StructRNA RNA_PoseChannel; @@ -328,6 +334,7 @@ extern StructRNA RNA_RadarSensor; extern StructRNA RNA_RandomSensor; extern StructRNA RNA_RaySensor; extern StructRNA RNA_Region; +extern StructRNA RNA_RenderEngine; extern StructRNA RNA_RenderLayer; extern StructRNA RNA_RenderPass; extern StructRNA RNA_RenderResult; @@ -378,6 +385,9 @@ extern StructRNA RNA_ShapeKeyPoint; extern StructRNA RNA_ShrinkwrapConstraint; extern StructRNA RNA_ShrinkwrapModifier; extern StructRNA RNA_SimpleDeformModifier; +extern StructRNA RNA_SmokeCollSettings; +extern StructRNA RNA_SmokeDomainSettings; +extern StructRNA RNA_SmokeFlowSettings; extern StructRNA RNA_SmokeModifier; extern StructRNA RNA_SmoothModifier; extern StructRNA RNA_SoftBodyModifier; @@ -386,17 +396,22 @@ extern StructRNA RNA_Sound; extern StructRNA RNA_SoundSequence; extern StructRNA RNA_Space; extern StructRNA RNA_Space3DView; -extern StructRNA RNA_SpaceButtonsWindow; extern StructRNA RNA_SpaceConsole; extern StructRNA RNA_SpaceDopeSheetEditor; extern StructRNA RNA_SpaceFileBrowser; extern StructRNA RNA_SpaceGraphEditor; extern StructRNA RNA_SpaceImageEditor; +extern StructRNA RNA_SpaceInfo; +extern StructRNA RNA_SpaceLogicEditor; extern StructRNA RNA_SpaceNLA; +extern StructRNA RNA_SpaceNodeEditor; extern StructRNA RNA_SpaceOutliner; +extern StructRNA RNA_SpaceProperties; extern StructRNA RNA_SpaceSequenceEditor; extern StructRNA RNA_SpaceTextEditor; +extern StructRNA RNA_SpaceTimeline; extern StructRNA RNA_SpaceUVEditor; +extern StructRNA RNA_SpaceUserPreferences; extern StructRNA RNA_SpeedControlSequence; extern StructRNA RNA_SpotLamp; extern StructRNA RNA_StretchToConstraint; @@ -442,16 +457,17 @@ extern StructRNA RNA_TextureSlot; extern StructRNA RNA_Theme; extern StructRNA RNA_ThemeAudioWindow; extern StructRNA RNA_ThemeBoneColorSet; -extern StructRNA RNA_ThemeButtonsWindow; extern StructRNA RNA_ThemeDopeSheet; extern StructRNA RNA_ThemeFileBrowser; extern StructRNA RNA_ThemeFontStyle; extern StructRNA RNA_ThemeGraphEditor; extern StructRNA RNA_ThemeImageEditor; +extern StructRNA RNA_ThemeInfo; extern StructRNA RNA_ThemeLogicEditor; extern StructRNA RNA_ThemeNLAEditor; extern StructRNA RNA_ThemeNodeEditor; extern StructRNA RNA_ThemeOutliner; +extern StructRNA RNA_ThemeProperties; extern StructRNA RNA_ThemeSequenceEditor; extern StructRNA RNA_ThemeStyle; extern StructRNA RNA_ThemeTextEditor; @@ -470,20 +486,22 @@ extern StructRNA RNA_TransformSequence; extern StructRNA RNA_UILayout; extern StructRNA RNA_UIListItem; extern StructRNA RNA_UVProjectModifier; +extern StructRNA RNA_UnitSettings; extern StructRNA RNA_UnknownType; extern StructRNA RNA_UserPreferences; -extern StructRNA RNA_UserPreferencesAutosave; extern StructRNA RNA_UserPreferencesEdit; extern StructRNA RNA_UserPreferencesFilePaths; extern StructRNA RNA_UserPreferencesLanguage; extern StructRNA RNA_UserPreferencesSystem; extern StructRNA RNA_UserPreferencesView; extern StructRNA RNA_UserSolidLight; -extern StructRNA RNA_VertexPaint; extern StructRNA RNA_VectorFont; extern StructRNA RNA_VertexGroup; extern StructRNA RNA_VertexGroupElement; +extern StructRNA RNA_VertexPaint; extern StructRNA RNA_VoronoiTexture; +extern StructRNA RNA_VoxelData; +extern StructRNA RNA_VoxelDataTexture; extern StructRNA RNA_WaveModifier; extern StructRNA RNA_Window; extern StructRNA RNA_WindowManager; @@ -559,9 +577,13 @@ char *RNA_struct_name_get_alloc(PointerRNA *ptr, char *fixedbuf, int fixedlen); const char *RNA_property_identifier(PropertyRNA *prop); PropertyType RNA_property_type(PropertyRNA *prop); PropertySubType RNA_property_subtype(PropertyRNA *prop); +PropertyUnit RNA_property_unit(PropertyRNA *prop); int RNA_property_flag(PropertyRNA *prop); -int RNA_property_array_length(PropertyRNA *prop); +int RNA_property_array_length(PointerRNA *ptr, PropertyRNA *prop); +int RNA_property_dynamic_array_set_length(PointerRNA *ptr, PropertyRNA *prop, int length); +char RNA_property_array_item_char(PropertyRNA *prop, int index); +unsigned short RNA_property_array_dimension(PropertyRNA *prop, unsigned short dim_size[]); int RNA_property_string_maxlength(PropertyRNA *prop); @@ -645,7 +667,7 @@ RawPropertyType RNA_property_raw_type(PropertyRNA *prop); void RNA_property_pointer_add(PointerRNA *ptr, PropertyRNA *prop); void RNA_property_pointer_remove(PointerRNA *ptr, PropertyRNA *prop); void RNA_property_collection_add(PointerRNA *ptr, PropertyRNA *prop, PointerRNA *r_ptr); -void RNA_property_collection_remove(PointerRNA *ptr, PropertyRNA *prop, int key); +int RNA_property_collection_remove(PointerRNA *ptr, PropertyRNA *prop, int key); void RNA_property_collection_clear(PointerRNA *ptr, PropertyRNA *prop); /* Path @@ -763,7 +785,7 @@ void RNA_collection_clear(PointerRNA *ptr, const char *name); int RNA_property_is_set(PointerRNA *ptr, const char *name); /* python compatible string representation of this property, (must be freed!) */ -char *RNA_property_as_string(PointerRNA *ptr, PropertyRNA *prop); +char *RNA_property_as_string(struct bContext *C, PointerRNA *ptr, PropertyRNA *prop); char *RNA_pointer_as_string(PointerRNA *ptr); /* Function */ diff --git a/source/blender/makesrna/RNA_define.h b/source/blender/makesrna/RNA_define.h index ae9eaba8646..1c6837bbcc8 100644 --- a/source/blender/makesrna/RNA_define.h +++ b/source/blender/makesrna/RNA_define.h @@ -63,6 +63,7 @@ void RNA_def_struct_path_func(StructRNA *srna, const char *path); void RNA_def_struct_identifier(StructRNA *srna, const char *identifier); void RNA_def_struct_ui_text(StructRNA *srna, const char *name, const char *description); void RNA_def_struct_ui_icon(StructRNA *srna, int icon); +void RNA_struct_free_extension(StructRNA *srna, ExtensionRNA *ext); void RNA_struct_free(BlenderRNA *brna, StructRNA *srna); /* Compact Property Definitions */ @@ -87,11 +88,15 @@ void RNA_def_enum_funcs(PropertyRNA *prop, EnumPropertyItemFunc itemfunc); PropertyRNA *RNA_def_float(StructOrFunctionRNA *cont, const char *identifier, float default_value, float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax); PropertyRNA *RNA_def_float_vector(StructOrFunctionRNA *cont, const char *identifier, int len, const float *default_value, float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax); PropertyRNA *RNA_def_float_color(StructOrFunctionRNA *cont, const char *identifier, int len, const float *default_value, float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax); -PropertyRNA *RNA_def_float_matrix(StructOrFunctionRNA *cont, const char *identifier, int len, const float *default_value, float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax); +PropertyRNA *RNA_def_float_matrix(StructOrFunctionRNA *cont, const char *identifier, int len, int rowsize, const float *default_value, float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax); PropertyRNA *RNA_def_float_rotation(StructOrFunctionRNA *cont, const char *identifier, int len, const float *default_value, float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax); PropertyRNA *RNA_def_float_array(StructOrFunctionRNA *cont, const char *identifier, int len, const float *default_value, float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax); + /* +PropertyRNA *RNA_def_float_dynamic_array(StructOrFunctionRNA *cont, const char *identifier, float hardmin, float hardmax, + const char *ui_name, const char *ui_description, float softmin, float softmax, unsigned int dimension, unsigned short dim_size[]); + */ PropertyRNA *RNA_def_float_percentage(StructOrFunctionRNA *cont, const char *identifier, float default_value, float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax); @@ -122,6 +127,7 @@ void RNA_def_property_collection_sdna(PropertyRNA *prop, const char *structname, void RNA_def_property_flag(PropertyRNA *prop, int flag); void RNA_def_property_clear_flag(PropertyRNA *prop, int flag); void RNA_def_property_array(PropertyRNA *prop, int arraylength); +void RNA_def_property_multidimensional_array(PropertyRNA *prop, int arraylength, unsigned short arraydimension, unsigned short dimsize[]); void RNA_def_property_range(PropertyRNA *prop, double min, double max); void RNA_def_property_enum_items(PropertyRNA *prop, const EnumPropertyItem *item); @@ -145,6 +151,7 @@ void RNA_def_property_ui_icon(PropertyRNA *prop, int icon, int consecutive); void RNA_def_property_update(PropertyRNA *prop, int noteflag, const char *updatefunc); void RNA_def_property_editable_func(PropertyRNA *prop, const char *editable); +void RNA_def_property_dynamic_array_funcs(PropertyRNA *prop, const char *getlength, const char *setlength); void RNA_def_property_boolean_funcs(PropertyRNA *prop, const char *get, const char *set); void RNA_def_property_int_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range); void RNA_def_property_float_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range); diff --git a/source/blender/makesrna/RNA_enum_types.h b/source/blender/makesrna/RNA_enum_types.h index 78e65e8fc06..06be0e69be5 100644 --- a/source/blender/makesrna/RNA_enum_types.h +++ b/source/blender/makesrna/RNA_enum_types.h @@ -29,6 +29,8 @@ /* Types */ +extern EnumPropertyItem object_mode_items[]; + extern EnumPropertyItem prop_mode_items[]; extern EnumPropertyItem space_type_items[]; extern EnumPropertyItem region_type_items[]; @@ -39,6 +41,8 @@ extern EnumPropertyItem boidrule_type_items[]; extern EnumPropertyItem beztriple_handle_type_items[]; extern EnumPropertyItem beztriple_interpolation_mode_items[]; +extern EnumPropertyItem keyingset_path_grouping_items[]; + extern EnumPropertyItem fmodifier_type_items[]; extern EnumPropertyItem nla_mode_extend_items[]; @@ -47,6 +51,8 @@ extern EnumPropertyItem nla_mode_blend_items[]; extern EnumPropertyItem event_value_items[]; extern EnumPropertyItem event_type_items[]; +extern EnumPropertyItem brush_sculpt_tool_items[]; + #endif /* RNA_ENUM_TYPES */ diff --git a/source/blender/makesrna/RNA_types.h b/source/blender/makesrna/RNA_types.h index a1e98ae8a17..1acbfb21385 100644 --- a/source/blender/makesrna/RNA_types.h +++ b/source/blender/makesrna/RNA_types.h @@ -66,17 +66,51 @@ typedef enum PropertyType { PROP_COLLECTION = 6 } PropertyType; +/* also update rna_property_subtype_unit when you change this */ +typedef enum PropertyUnit { + PROP_UNIT_NONE = (0<<16), + PROP_UNIT_LENGTH = (1<<16), /* m */ + PROP_UNIT_AREA = (2<<16), /* m^2 */ + PROP_UNIT_VOLUME = (3<<16), /* m^3 */ + PROP_UNIT_MASS = (4<<16), /* kg */ + PROP_UNIT_ROTATION = (5<<16), /* rad */ + PROP_UNIT_TIME = (6<<16), /* frame */ + PROP_UNIT_VELOCITY = (7<<16), /* m/s */ + PROP_UNIT_ACCELERATION = (8<<16) /* m/(s^2) */ +} PropertyUnit; + +#define RNA_SUBTYPE_UNIT(subtype) (subtype & 0x00FF0000) +#define RNA_SUBTYPE_UNIT_VALUE(subtype) (subtype>>16) + +/* also update rna_property_subtypename when you change this */ typedef enum PropertySubType { PROP_NONE = 0, - PROP_UNSIGNED = 1, - PROP_FILEPATH = 2, - PROP_DIRPATH = 3, - PROP_COLOR = 4, - PROP_VECTOR = 5, - PROP_MATRIX = 6, - PROP_ROTATION = 7, - PROP_NEVER_NULL = 8, - PROP_PERCENTAGE = 9 + + /* strings */ + PROP_FILEPATH = 1, + PROP_DIRPATH = 2, + + /* numbers */ + PROP_UNSIGNED = 13, + PROP_PERCENTAGE = 14, + PROP_ANGLE = 15|PROP_UNIT_ROTATION, + PROP_TIME = 16|PROP_UNIT_TIME, + PROP_DISTANCE = 17|PROP_UNIT_LENGTH, + + /* number arrays */ + PROP_COLOR = 20, + PROP_TRANSLATION = 21|PROP_UNIT_LENGTH, + PROP_DIRECTION = 22, + PROP_VELOCITY = 23|PROP_UNIT_VELOCITY, + PROP_ACCELERATION = 24|PROP_UNIT_ACCELERATION, + PROP_MATRIX = 25, + PROP_EULER = 26|PROP_UNIT_ROTATION, + PROP_QUATERNION = 27, + PROP_XYZ = 28, + PROP_RGB = 29, + + /* pointers */ + PROP_NEVER_NULL = 30, } PropertySubType; typedef enum PropertyFlag { @@ -118,7 +152,8 @@ typedef enum PropertyFlag { PROP_IDPROPERTY = 1024, PROP_RAW_ACCESS = 8192, PROP_RAW_ARRAY = 16384, - PROP_FREE_POINTERS = 32768 + PROP_FREE_POINTERS = 32768, + PROP_DYNAMIC = 131072 /* for dynamic arrays, and retvals of type string */ } PropertyFlag; typedef struct CollectionPropertyIterator { @@ -229,7 +264,7 @@ typedef int (*StructValidateFunc)(struct PointerRNA *ptr, void *data, int *have_ typedef int (*StructCallbackFunc)(struct PointerRNA *ptr, struct FunctionRNA *func, ParameterList *list); typedef void (*StructFreeFunc)(void *data); typedef struct StructRNA *(*StructRegisterFunc)(const struct bContext *C, struct ReportList *reports, void *data, - StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free); + const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free); typedef void (*StructUnregisterFunc)(const struct bContext *C, struct StructRNA *type); typedef struct StructRNA StructRNA; diff --git a/source/blender/makesrna/SConscript b/source/blender/makesrna/SConscript index be5c3fcdfdf..8a4f3912814 100644 --- a/source/blender/makesrna/SConscript +++ b/source/blender/makesrna/SConscript @@ -7,8 +7,8 @@ o = SConscript('intern/SConscript') objs += o incs = '#/intern/guardedalloc ../blenkernel ../blenlib ../makesdna intern .' -incs += ' ../windowmanager ../editors/include ../imbuf ../bmesh' -incs += ' ../render/extern/include' +incs += ' ../windowmanager ../editors/include ../imbuf' +incs += ' ../render/extern/include ../bmesh' defs = [] diff --git a/source/blender/makesrna/intern/CMakeLists.txt b/source/blender/makesrna/intern/CMakeLists.txt index ff0b198d9f9..50f48b0b683 100644 --- a/source/blender/makesrna/intern/CMakeLists.txt +++ b/source/blender/makesrna/intern/CMakeLists.txt @@ -42,6 +42,10 @@ SET(SRC INCLUDE_DIRECTORIES(../../../../intern/guardedalloc .. ../../makesdna ../../blenkernel ../../blenlib ../../windowmanager ../../editors/include ../../imbuf ../../render/extern/include ../../bmesh .) FILE(GLOB INC_FILES ../*.h ../../makesdna/*.h) +IF(WITH_GAMEENGINE) + ADD_DEFINITIONS(-DGAMEBLENDER) +ENDIF(WITH_GAMEENGINE) + IF(WITH_OPENEXR) ADD_DEFINITIONS(-DWITH_OPENEXR) ENDIF(WITH_OPENEXR) @@ -67,6 +71,10 @@ IF(NOT WITH_ELBEEM) ADD_DEFINITIONS(-DDISABLE_ELBEEM) ENDIF(NOT WITH_ELBEEM) +IF(WITH_FFTW3) + ADD_DEFINITIONS(-DFFTW3=1) +ENDIF(WITH_FFTW3) + # Build makesrna executable ADD_EXECUTABLE(makesrna ${SRC} ${INC_FILES}) TARGET_LINK_LIBRARIES(makesrna bf_dna) diff --git a/source/blender/makesrna/intern/SConscript b/source/blender/makesrna/intern/SConscript index 11504ec8391..4313ff3bec1 100644 --- a/source/blender/makesrna/intern/SConscript +++ b/source/blender/makesrna/intern/SConscript @@ -58,6 +58,9 @@ if env['WITH_BF_LCMS']: if env['WITH_BF_GAMEENGINE']: defs.append('GAMEBLENDER=1') + +if env['WITH_BF_FFTW3']: + defs.append('FFTW3=1') makesrna_tool.Append(CPPDEFINES=defs) diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index b5fc4d2e463..0c90a28a0e9 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -1198,7 +1198,13 @@ static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA dparm= dfunc->cont.properties.first; for(; dparm; dparm= dparm->next) { - ptrstr= (dparm->prop->type == PROP_POINTER || dparm->prop->arraylength > 0)? "*" : ""; + if(dparm->prop->arraylength > 0) + ptrstr= "*"; + else if(dparm->prop==func->ret) + ptrstr= ((dparm->prop->type == PROP_POINTER) && !(dparm->prop->flag & PROP_RNAPTR))? "*": ""; + else + ptrstr= (dparm->prop->type == PROP_POINTER)? "*": ""; + fprintf(f, "\t%s%s %s%s;\n", rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop), ptrstr, dparm->prop->identifier); } @@ -1274,7 +1280,7 @@ static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA if(func->ret) { dparm= rna_find_parameter_def(func->ret); - ptrstr= dparm->prop->type == PROP_POINTER || dparm->prop->arraylength > 0 ? "*" : ""; + ptrstr= (((dparm->prop->type == PROP_POINTER) && !(dparm->prop->flag & PROP_RNAPTR)) || (dparm->prop->arraylength > 0))? "*": ""; fprintf(f, "\t*((%s%s%s*)_retdata)= %s;\n", rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop), ptrstr, func->ret->identifier); } } @@ -1370,15 +1376,48 @@ static const char *rna_property_subtypename(PropertyType type) { switch(type) { case PROP_NONE: return "PROP_NONE"; - case PROP_UNSIGNED: return "PROP_UNSIGNED"; case PROP_FILEPATH: return "PROP_FILEPATH"; case PROP_DIRPATH: return "PROP_DIRPATH"; + case PROP_UNSIGNED: return "PROP_UNSIGNED"; + case PROP_PERCENTAGE: return "PROP_PERCENTAGE"; + case PROP_ANGLE: return "PROP_ANGLE"; + case PROP_TIME: return "PROP_TIME"; + case PROP_DISTANCE: return "PROP_DISTANCE"; case PROP_COLOR: return "PROP_COLOR"; - case PROP_VECTOR: return "PROP_VECTOR"; + case PROP_TRANSLATION: return "PROP_TRANSLATION"; + case PROP_DIRECTION: return "PROP_DIRECTION"; case PROP_MATRIX: return "PROP_MATRIX"; - case PROP_ROTATION: return "PROP_ROTATION"; + case PROP_EULER: return "PROP_EULER"; + case PROP_QUATERNION: return "PROP_QUATERNION"; + case PROP_VELOCITY: return "PROP_VELOCITY"; + case PROP_ACCELERATION: return "PROP_ACCELERATION"; + case PROP_XYZ: return "PROP_XYZ"; + case PROP_RGB: return "PROP_RGB"; case PROP_NEVER_NULL: return "PROP_NEVER_NULL"; - case PROP_PERCENTAGE: return "PROP_PERCENTAGE"; + default: { + /* incase we dont have a type preset that includes the subtype */ + if(RNA_SUBTYPE_UNIT(type)) { + return rna_property_subtypename(type & ~RNA_SUBTYPE_UNIT(type)); + } + else { + return "PROP_SUBTYPE_UNKNOWN"; + } + } + } +} + +static const char *rna_property_subtype_unit(PropertyType type) +{ + switch(RNA_SUBTYPE_UNIT(type)) { + case PROP_UNIT_NONE: return "PROP_UNIT_NONE"; + case PROP_UNIT_LENGTH: return "PROP_UNIT_LENGTH"; + case PROP_UNIT_AREA: return "PROP_UNIT_AREA"; + case PROP_UNIT_VOLUME: return "PROP_UNIT_VOLUME"; + case PROP_UNIT_MASS: return "PROP_UNIT_MASS"; + case PROP_UNIT_ROTATION: return "PROP_UNIT_ROTATION"; + case PROP_UNIT_TIME: return "PROP_UNIT_TIME"; + case PROP_UNIT_VELOCITY: return "PROP_UNIT_VELOCITY"; + case PROP_UNIT_ACCELERATION:return "PROP_UNIT_ACCELERATION"; default: return "PROP_UNKNOWN"; } } @@ -1483,7 +1522,7 @@ static void rna_generate_static_parameter_prototypes(BlenderRNA *brna, StructRNA if(dparm->prop==func->ret) { if(dparm->prop->arraylength) fprintf(f, "XXX no array return types yet"); /* XXX not supported */ - else if(dparm->prop->type == PROP_POINTER) + else if(dparm->prop->type == PROP_POINTER && !(dparm->prop->flag & PROP_RNAPTR)) fprintf(f, "%s%s *", rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop)); else fprintf(f, "%s%s ", rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop)); @@ -1684,7 +1723,15 @@ static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, Pr rna_print_c_string(f, prop->name); fprintf(f, ",\n\t"); rna_print_c_string(f, prop->description); fprintf(f, ",\n\t"); fprintf(f, "%d,\n", prop->icon); - fprintf(f, "\t%s, %s, %d,\n", rna_property_typename(prop->type), rna_property_subtypename(prop->subtype), prop->arraylength); + fprintf(f, "\t%s, %s|%s, %d,\n", rna_property_typename(prop->type), rna_property_subtypename(prop->subtype), rna_property_subtype_unit(prop->subtype), prop->arraylength); + { + int i; + int tot= sizeof(prop->dimsize) / sizeof(prop->dimsize[0]); + fprintf(f, "\t%s, %s, %d, {", rna_function_string(prop->getlength), rna_function_string(prop->setlength), (int)prop->arraydimension); + for(i= 0; i < tot; i++) { + fprintf(f, i == tot - 1 ? "%d},\n" : "%d, ", (int)prop->dimsize[i]); + } + } fprintf(f, "\t%s, %d, %s,\n", rna_function_string(prop->update), prop->noteflag, rna_function_string(prop->editable)); if(prop->flag & PROP_RAW_ACCESS) rna_set_raw_offset(f, srna, prop); @@ -1903,7 +1950,7 @@ RNAProcessItem PROCESS_ITEMS[]= { {"rna_ID.c", NULL, RNA_def_ID}, {"rna_texture.c", NULL, RNA_def_texture}, {"rna_action.c", NULL, RNA_def_action}, - {"rna_animation.c", NULL, RNA_def_animation}, + {"rna_animation.c", "rna_animation_api.c", RNA_def_animation}, {"rna_actuator.c", NULL, RNA_def_actuator}, {"rna_armature.c", NULL, RNA_def_armature}, {"rna_boid.c", NULL, RNA_def_boid}, @@ -1936,7 +1983,7 @@ RNAProcessItem PROCESS_ITEMS[]= { {"rna_pose.c", NULL, RNA_def_pose}, {"rna_property.c", NULL, RNA_def_gameproperty}, {"rna_render.c", NULL, RNA_def_render}, - {"rna_scene.c", NULL, RNA_def_scene}, + {"rna_scene.c", "rna_scene_api.c", RNA_def_scene}, {"rna_screen.c", NULL, RNA_def_screen}, {"rna_sculpt_paint.c", NULL, RNA_def_sculpt_paint}, {"rna_sensor.c", NULL, RNA_def_sensor}, @@ -2194,7 +2241,7 @@ static void rna_generate_header_cpp(BlenderRNA *brna, FILE *f) fprintf(f, "#include \"RNA_blender.h\"\n"); fprintf(f, "#include \"RNA_types.h\"\n"); - fprintf(f, cpp_classes); + fprintf(f, "%s", cpp_classes); fprintf(f, "/**************** Declarations ****************/\n\n"); diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c index cf3d59f78a0..f6e0a2468c4 100644 --- a/source/blender/makesrna/intern/rna_ID.c +++ b/source/blender/makesrna/intern/rna_ID.c @@ -152,6 +152,30 @@ IDProperty *rna_IDPropertyGroup_idproperties(PointerRNA *ptr, int create) return ptr->data; } +void rna_IDPropertyGroup_unregister(const bContext *C, StructRNA *type) +{ + RNA_struct_free(&BLENDER_RNA, type); +} + +StructRNA *rna_IDPropertyGroup_register(const bContext *C, ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free) +{ + PointerRNA dummyptr; + + /* create dummy pointer */ + RNA_pointer_create(NULL, &RNA_IDPropertyGroup, NULL, &dummyptr); + + /* validate the python class */ + if(validate(&dummyptr, data, NULL) != 0) + return NULL; + + return RNA_def_struct(&BLENDER_RNA, identifier, "IDPropertyGroup"); // XXX +} + +StructRNA* rna_IDPropertyGroup_refine(PointerRNA *ptr) +{ + return ptr->type; +} + #else static void rna_def_ID_properties(BlenderRNA *brna) @@ -210,6 +234,8 @@ static void rna_def_ID_properties(BlenderRNA *brna) srna= RNA_def_struct(brna, "IDPropertyGroup", NULL); RNA_def_struct_ui_text(srna, "ID Property Group", "Group of ID properties."); RNA_def_struct_idproperties_func(srna, "rna_IDPropertyGroup_idproperties"); + RNA_def_struct_register_funcs(srna, "rna_IDPropertyGroup_register", "rna_IDPropertyGroup_unregister"); + RNA_def_struct_refine_func(srna, "rna_IDPropertyGroup_refine"); } static void rna_def_ID(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index b0db6ae9de5..e71dcc2a586 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -343,10 +343,11 @@ const char *rna_ensure_property_name(PropertyRNA *prop) return ((IDProperty*)prop)->name; } -int rna_ensure_property_array_length(PropertyRNA *prop) +int rna_ensure_property_array_length(PointerRNA *ptr, PropertyRNA *prop) { - if(prop->magic == RNA_MAGIC) - return prop->arraylength; + if(prop->magic == RNA_MAGIC) { + return prop->getlength ? prop->getlength(ptr) : prop->arraylength; + } else { IDProperty *idprop= (IDProperty*)prop; @@ -539,14 +540,55 @@ PropertySubType RNA_property_subtype(PropertyRNA *prop) return rna_ensure_property(prop)->subtype; } +PropertyUnit RNA_property_unit(PropertyRNA *prop) +{ + return RNA_SUBTYPE_UNIT(rna_ensure_property(prop)->subtype); +} + int RNA_property_flag(PropertyRNA *prop) { return rna_ensure_property(prop)->flag; } -int RNA_property_array_length(PropertyRNA *prop) +int RNA_property_array_length(PointerRNA *ptr, PropertyRNA *prop) +{ + return rna_ensure_property_array_length(ptr, prop); +} + +int RNA_property_dynamic_array_set_length(PointerRNA *ptr, PropertyRNA *prop, int length) +{ + if (prop->setlength) + return prop->setlength(ptr, length); + else + prop->arraylength= length; /* function parameters only? */ + + return 1; +} + +unsigned short RNA_property_array_dimension(PropertyRNA *prop, unsigned short dimsize[]) { - return rna_ensure_property_array_length(prop); + if (dimsize && prop->arraydimension > 1) { + memcpy(dimsize, prop->dimsize, sizeof(prop->dimsize[0]) * (prop->arraydimension - 1)); + } + return prop->arraydimension; +} + +char RNA_property_array_item_char(PropertyRNA *prop, int index) +{ + const char *vectoritem= "XYZW"; + const char *quatitem= "WXYZ"; + const char *coloritem= "RGBA"; + PropertySubType subtype= rna_ensure_property(prop)->subtype; + + /* get string to use for array index */ + if ((index < 4) && (subtype == PROP_QUATERNION)) + return quatitem[index]; + else if((index < 4) && ELEM6(subtype, PROP_TRANSLATION, PROP_DIRECTION, PROP_XYZ, PROP_EULER, PROP_VELOCITY, PROP_ACCELERATION)) + return vectoritem[index]; + else if ((index < 4) && ELEM(subtype, PROP_COLOR, PROP_RGB)) + return coloritem[index]; + else + return '\0'; } void RNA_property_int_range(PointerRNA *ptr, PropertyRNA *prop, int *hardmin, int *hardmax) @@ -1236,8 +1278,15 @@ PointerRNA RNA_property_pointer_get(PointerRNA *ptr, PropertyRNA *prop) else if(pprop->get) { return pprop->get(ptr); } + else if(prop->flag & PROP_IDPROPERTY) { + /* XXX temporary hack to add it automatically, reading should + never do any write ops, to ensure thread safety etc .. */ + RNA_property_pointer_add(ptr, prop); + return RNA_property_pointer_get(ptr, prop); + } else { PointerRNA result; + memset(&result, 0, sizeof(result)); return result; } @@ -1375,7 +1424,7 @@ int RNA_property_collection_length(PointerRNA *ptr, PropertyRNA *prop) void RNA_property_collection_add(PointerRNA *ptr, PropertyRNA *prop, PointerRNA *r_ptr) { IDProperty *idprop; - //CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop; + CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop; if((idprop=rna_idproperty_check(&prop, ptr))) { IDPropertyTemplate val = {0}; @@ -1401,7 +1450,6 @@ void RNA_property_collection_add(PointerRNA *ptr, PropertyRNA *prop, PointerRNA MEM_freeN(item); } } -#if 0 else if(cprop->add){ if(!(cprop->add->flag & FUNC_USE_CONTEXT)) { /* XXX check for this somewhere else */ ParameterList params; @@ -1410,9 +1458,8 @@ void RNA_property_collection_add(PointerRNA *ptr, PropertyRNA *prop, PointerRNA RNA_parameter_list_free(¶ms); } } -#endif - else - printf("RNA_property_collection_add %s.%s: not implemented for this property.\n", ptr->type->identifier, prop->identifier); + /*else + printf("RNA_property_collection_add %s.%s: not implemented for this property.\n", ptr->type->identifier, prop->identifier);*/ if(r_ptr) { if(idprop) { @@ -1427,10 +1474,10 @@ void RNA_property_collection_add(PointerRNA *ptr, PropertyRNA *prop, PointerRNA } } -void RNA_property_collection_remove(PointerRNA *ptr, PropertyRNA *prop, int key) +int RNA_property_collection_remove(PointerRNA *ptr, PropertyRNA *prop, int key) { IDProperty *idprop; - //CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop; + CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop; if((idprop=rna_idproperty_check(&prop, ptr))) { IDProperty tmp, *array; @@ -1449,20 +1496,25 @@ void RNA_property_collection_remove(PointerRNA *ptr, PropertyRNA *prop, int key) IDP_ResizeIDPArray(idprop, len-1); } + + return 1; } - else if(prop->flag & PROP_IDPROPERTY); -#if 0 + else if(prop->flag & PROP_IDPROPERTY) + return 1; else if(cprop->remove){ if(!(cprop->remove->flag & FUNC_USE_CONTEXT)) { /* XXX check for this somewhere else */ ParameterList params; - RNA_parameter_list_create(&ptr, cprop->remove); + RNA_parameter_list_create(¶ms, ptr, cprop->remove); RNA_function_call(NULL, NULL, ptr, cprop->remove, ¶ms); RNA_parameter_list_free(¶ms); } + + return 0; } -#endif - else - printf("RNA_property_collection_remove %s.%s: only supported for id properties.\n", ptr->type->identifier, prop->identifier); + /*else + printf("RNA_property_collection_remove %s.%s: only supported for id properties.\n", ptr->type->identifier, prop->identifier);*/ + + return 0; } void RNA_property_collection_clear(PointerRNA *ptr, PropertyRNA *prop) @@ -1651,7 +1703,7 @@ static int rna_raw_access(ReportList *reports, PointerRNA *ptr, PropertyRNA *pro } /* check item array */ - itemlen= RNA_property_array_length(itemprop); + itemlen= RNA_property_array_length(&itemptr, itemprop); /* try to access as raw array */ if(RNA_property_collection_raw_array(ptr, prop, itemprop, &out)) { @@ -1703,7 +1755,7 @@ static int rna_raw_access(ReportList *reports, PointerRNA *ptr, PropertyRNA *pro iprop= RNA_struct_find_property(&itemptr, propname); if(iprop) { - itemlen= RNA_property_array_length(iprop); + itemlen= RNA_property_array_length(&itemptr, iprop); itemtype= RNA_property_type(iprop); } else { @@ -1966,9 +2018,10 @@ void rna_iterator_array_end(CollectionPropertyIterator *iter) { ArrayIterator *internal= iter->internal; - if(internal->free_ptr) + if(internal->free_ptr) { MEM_freeN(internal->free_ptr); - + internal->free_ptr= NULL; + } MEM_freeN(iter->internal); iter->internal= NULL; } @@ -2624,7 +2677,7 @@ char *RNA_pointer_as_string(PointerRNA *ptr) BLI_dynstr_append(dynstr, ", "); first_time= 0; - cstring = RNA_property_as_string(ptr, prop); + cstring = RNA_property_as_string(NULL, ptr, prop); BLI_dynstr_appendf(dynstr, "\"%s\":%s", propname, cstring); MEM_freeN(cstring); } @@ -2638,10 +2691,10 @@ char *RNA_pointer_as_string(PointerRNA *ptr) return cstring; } -char *RNA_property_as_string(PointerRNA *ptr, PropertyRNA *prop) +char *RNA_property_as_string(bContext *C, PointerRNA *ptr, PropertyRNA *prop) { int type = RNA_property_type(prop); - int len = RNA_property_array_length(prop); + int len = RNA_property_array_length(ptr, prop); int i; DynStr *dynstr= BLI_dynstr_new(); @@ -2707,7 +2760,7 @@ char *RNA_property_as_string(PointerRNA *ptr, PropertyRNA *prop) const char *identifier; int val = RNA_property_enum_get(ptr, prop); - if(RNA_property_enum_identifier(NULL, ptr, prop, val, &identifier)) { + if(RNA_property_enum_identifier(C, ptr, prop, val, &identifier)) { BLI_dynstr_appendf(dynstr, "'%s'", identifier); } else { @@ -2810,8 +2863,10 @@ const struct ListBase *RNA_function_defined_parameters(FunctionRNA *func) ParameterList *RNA_parameter_list_create(ParameterList *parms, PointerRNA *ptr, FunctionRNA *func) { PropertyRNA *parm; - int tot= 0; + void *data; + int tot= 0, size; + /* allocate data */ for(parm= func->cont.properties.first; parm; parm= parm->next) tot+= rna_parameter_size(parm); @@ -2819,6 +2874,44 @@ ParameterList *RNA_parameter_list_create(ParameterList *parms, PointerRNA *ptr, parms->func= func; parms->tot= tot; + /* set default values */ + data= parms->data; + + for(parm= func->cont.properties.first; parm; parm= parm->next) { + size= rna_parameter_size(parm); + + if(!(parm->flag & PROP_REQUIRED)) { + switch(parm->type) { + case PROP_BOOLEAN: + if(parm->arraylength) memcpy(data, &((BooleanPropertyRNA*)parm)->defaultarray, size); + else memcpy(data, &((BooleanPropertyRNA*)parm)->defaultvalue, size); + break; + case PROP_INT: + if(parm->arraylength) memcpy(data, &((IntPropertyRNA*)parm)->defaultarray, size); + else memcpy(data, &((IntPropertyRNA*)parm)->defaultvalue, size); + break; + case PROP_FLOAT: + if(parm->arraylength) memcpy(data, &((FloatPropertyRNA*)parm)->defaultarray, size); + else memcpy(data, &((FloatPropertyRNA*)parm)->defaultvalue, size); + break; + case PROP_ENUM: + memcpy(data, &((EnumPropertyRNA*)parm)->defaultvalue, size); + break; + case PROP_STRING: { + const char *defvalue= ((StringPropertyRNA*)parm)->defaultvalue; + if(defvalue && defvalue[0]) + memcpy(data, &defvalue, size); + break; + } + case PROP_POINTER: + case PROP_COLLECTION: + break; + } + } + + data= ((char*)data) + size; + } + return parms; } @@ -2831,6 +2924,12 @@ void RNA_parameter_list_free(ParameterList *parms) for(tot= 0; parm; parm= parm->next) { if(parm->type == PROP_COLLECTION) BLI_freelistN((ListBase*)((char*)parms->data+tot)); + else if (parm->flag & PROP_DYNAMIC) { + /* for dynamic arrays and strings, data is a pointer to an array */ + char *array= *(char**)((char*)parms->data+tot); + if(array) + MEM_freeN(array); + } tot+= rna_parameter_size(parm); } @@ -3203,7 +3302,7 @@ int RNA_function_call_direct_va(bContext *C, ReportList *reports, PointerRNA *pt type= RNA_property_type(parm); ftype= format[ofs++]; - len= RNA_property_array_length(parm); + len= RNA_property_array_length(&funcptr, parm); alen= rna_function_format_array_length(format, ofs, flen); if (len!=alen) { @@ -3268,7 +3367,7 @@ int RNA_function_call_direct_va(bContext *C, ReportList *reports, PointerRNA *pt type= RNA_property_type(parm); ftype= format[ofs++]; - len= RNA_property_array_length(parm); + len= RNA_property_array_length(&funcptr, parm); alen= rna_function_format_array_length(format, ofs, flen); if (len!=alen) { diff --git a/source/blender/makesrna/intern/rna_actuator.c b/source/blender/makesrna/intern/rna_actuator.c index 3eb88e706e9..473e726db60 100644 --- a/source/blender/makesrna/intern/rna_actuator.c +++ b/source/blender/makesrna/intern/rna_actuator.c @@ -51,8 +51,7 @@ void RNA_def_actuator(BlenderRNA *brna) {ACT_SCENE, "SCENE", 0, "Scene", ""}, {ACT_RANDOM, "RANDOM", 0, "Random", ""}, {ACT_MESSAGE, "MESSAGE", 0, "Message", ""}, - {ACT_ACTION, "ACTION", 0, "Action", ""}, - {ACT_CD, "CD", 0, "CD", ""}, + {ACT_ACTION, "ACTION", 0, "Action", ""}, {ACT_GAME, "GAME", 0, "Game", ""}, {ACT_VISIBILITY, "VISIBILITY", 0, "Visibility", ""}, {ACT_2DFILTER, "FILTER_2D", 0, "2D Filter", ""}, diff --git a/source/blender/makesrna/intern/rna_animation.c b/source/blender/makesrna/intern/rna_animation.c index e334e2b5e90..7652987ac86 100644 --- a/source/blender/makesrna/intern/rna_animation.c +++ b/source/blender/makesrna/intern/rna_animation.c @@ -36,6 +36,14 @@ #include "MEM_guardedalloc.h" +/* exported for use in API */ +EnumPropertyItem keyingset_path_grouping_items[] = { + {KSP_GROUP_NAMED, "NAMED", 0, "Named Group", ""}, + {KSP_GROUP_NONE, "NONE", 0, "None", ""}, + {KSP_GROUP_KSNAME, "KEYINGSET", 0, "Keying Set Name", ""}, + {KSP_GROUP_TEMPLATE_ITEM, "TEMPLATE", 0, "Innermost Context-Item Name", ""}, + {0, NULL, 0, NULL, NULL}}; + #ifdef RNA_RUNTIME static int rna_AnimData_action_editable(PointerRNA *ptr) @@ -90,13 +98,6 @@ void rna_def_keyingset_path(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; - static EnumPropertyItem prop_mode_grouping_items[] = { - {KSP_GROUP_NAMED, "NAMED", 0, "Named Group", ""}, - {KSP_GROUP_NONE, "NONE", 0, "None", ""}, - {KSP_GROUP_KSNAME, "KEYINGSET", 0, "Keying Set Name", ""}, - {KSP_GROUP_TEMPLATE_ITEM, "TEMPLATE", 0, "Innermost Context-Item Name", ""}, - {0, NULL, 0, NULL, NULL}}; - srna= RNA_def_struct(brna, "KeyingSetPath", NULL); RNA_def_struct_sdna(srna, "KS_Path"); RNA_def_struct_ui_text(srna, "Keying Set Path", "Path to a setting for use in a Keying Set."); @@ -112,7 +113,7 @@ void rna_def_keyingset_path(BlenderRNA *brna) /* Grouping */ prop= RNA_def_property(srna, "grouping", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "groupmode"); - RNA_def_property_enum_items(prop, prop_mode_grouping_items); + RNA_def_property_enum_items(prop, keyingset_path_grouping_items); RNA_def_property_ui_text(prop, "Grouping Method", "Method used to define which Group-name to use."); /* Path + Array Index */ @@ -170,7 +171,8 @@ void rna_def_keyingset(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "keyingflag", INSERTKEY_MATRIX); RNA_def_property_ui_text(prop, "Insert Keyframes - Visual", "Insert keyframes based on 'visual transforms'."); - + /* Keying Set API */ + RNA_api_keyingset(srna); } /* --- */ diff --git a/source/blender/makesrna/intern/rna_animation_api.c b/source/blender/makesrna/intern/rna_animation_api.c new file mode 100644 index 00000000000..6af87335e02 --- /dev/null +++ b/source/blender/makesrna/intern/rna_animation_api.c @@ -0,0 +1,89 @@ +/** + * $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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2009 Blender Foundation. + * All rights reserved. + * + * + * Contributor(s): Joshua Leung + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include <stdlib.h> +#include <stdio.h> + +#include "RNA_define.h" +#include "RNA_enum_types.h" +#include "RNA_types.h" + +#include "DNA_anim_types.h" +#include "DNA_object_types.h" +#include "DNA_scene_types.h" + +#ifdef RNA_RUNTIME + +#include "BKE_animsys.h" + +static void rna_KeyingSet_add_destination(KeyingSet *keyingset, ReportList *reports, + ID *id, char rna_path[], int array_index, int entire_array, + int grouping_method, char group_name[]) +{ + short flag = 0; + + /* validate flags */ + if (entire_array) + flag |= KSP_FLAG_WHOLE_ARRAY; + + /* if data is valid, call the API function for this */ + if (keyingset) { + BKE_keyingset_add_destination(keyingset, id, group_name, rna_path, array_index, flag, grouping_method); + } + else { + BKE_report(reports, RPT_ERROR, "Keying Set Destination could not be added."); + } +} + +#else + +void RNA_api_keyingset(StructRNA *srna) +{ + FunctionRNA *func; + PropertyRNA *parm; + + /* Add Destination */ + func= RNA_def_function(srna, "add_destination", "rna_KeyingSet_add_destination"); + RNA_def_function_ui_description(func, "Add a new destination for the Keying Set."); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + /* ID-block for target */ + parm= RNA_def_pointer(func, "target_id", "ID", "Target ID", "ID-Datablock for the destination."); + RNA_def_property_flag(parm, PROP_REQUIRED); + /* rna-path */ + parm= RNA_def_string(func, "rna_path", "", 256, "RNA-Path", "RNA-Path to destination property."); // xxx hopefully this is long enough + RNA_def_property_flag(parm, PROP_REQUIRED); + parm=RNA_def_int(func, "array_index", 0, 0, INT_MAX, "Array Index", "If applicable, the index ", 0, INT_MAX); + /* flags */ + parm=RNA_def_boolean(func, "entire_array", 1, "Entire Array", "When an 'array/vector' type is chosen (Location, Rotation, Color, etc.), entire array is to be used."); + /* grouping */ + parm=RNA_def_enum(func, "grouping_method", keyingset_path_grouping_items, KSP_GROUP_KSNAME, "Grouping Method", "Method used to define which Group-name to use."); + parm=RNA_def_string(func, "group_name", "", 64, "Group Name", "Name of Action Group to assign destination to (only if grouping mode is to use this name)."); +} + +#endif + diff --git a/source/blender/makesrna/intern/rna_armature.c b/source/blender/makesrna/intern/rna_armature.c index cf20e92b289..7bab7947843 100644 --- a/source/blender/makesrna/intern/rna_armature.c +++ b/source/blender/makesrna/intern/rna_armature.c @@ -495,13 +495,13 @@ static void rna_def_edit_bone(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Roll", "Bone rotation around head-tail axis."); RNA_def_property_update(prop, 0, "rna_Armature_editbone_transform_update"); - prop= RNA_def_property(srna, "head", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "head", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_float_sdna(prop, NULL, "head"); RNA_def_property_array(prop, 3); RNA_def_property_ui_text(prop, "Head", "Location of head end of the bone."); RNA_def_property_update(prop, 0, "rna_Armature_editbone_transform_update"); - prop= RNA_def_property(srna, "tail", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "tail", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_float_sdna(prop, NULL, "tail"); RNA_def_property_array(prop, 3); RNA_def_property_ui_text(prop, "Tail", "Location of tail end of the bone."); @@ -708,13 +708,13 @@ void rna_def_armature(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Ghosting Frame Step", "Frame step for Ghosts (not for 'On Keyframes' Onion-skining method)."); RNA_def_property_update(prop, 0, "rna_Armature_redraw_data"); - prop= RNA_def_property(srna, "ghost_start_frame", PROP_INT, PROP_NONE); + prop= RNA_def_property(srna, "ghost_start_frame", PROP_INT, PROP_TIME); RNA_def_property_int_sdna(prop, NULL, "ghostsf"); RNA_def_property_int_funcs(prop, NULL, "rna_Armature_ghost_start_frame_set", NULL); RNA_def_property_ui_text(prop, "Ghosting Start Frame", "Starting frame of range of Ghosts to display (not for 'Around Current Frame' Onion-skinning method)."); RNA_def_property_update(prop, 0, "rna_Armature_redraw_data"); - prop= RNA_def_property(srna, "ghost_end_frame", PROP_INT, PROP_NONE); + prop= RNA_def_property(srna, "ghost_end_frame", PROP_INT, PROP_TIME); RNA_def_property_int_sdna(prop, NULL, "ghostef"); RNA_def_property_int_funcs(prop, NULL, "rna_Armature_ghost_end_frame_set", NULL); RNA_def_property_ui_text(prop, "Ghosting End Frame", "End frame of range of Ghosts to display (not for 'Around Current Frame' Onion-skinning method)."); @@ -727,13 +727,13 @@ void rna_def_armature(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Paths Frame Step", "Number of frames between 'dots' on Bone Paths (when drawing)."); RNA_def_property_update(prop, 0, "rna_Armature_redraw_data"); - prop= RNA_def_property(srna, "path_start_frame", PROP_INT, PROP_NONE); + prop= RNA_def_property(srna, "path_start_frame", PROP_INT, PROP_TIME); RNA_def_property_int_sdna(prop, NULL, "pathsf"); RNA_def_property_int_funcs(prop, NULL, "rna_Armature_path_start_frame_set", NULL); RNA_def_property_ui_text(prop, "Paths Calculation Start Frame", "Starting frame of range of frames to use for Bone Path calculations."); RNA_def_property_update(prop, 0, "rna_Armature_update_data"); - prop= RNA_def_property(srna, "path_end_frame", PROP_INT, PROP_NONE); + prop= RNA_def_property(srna, "path_end_frame", PROP_INT, PROP_TIME); RNA_def_property_int_sdna(prop, NULL, "pathef"); RNA_def_property_int_funcs(prop, NULL, "rna_Armature_path_end_frame_set", NULL); RNA_def_property_ui_text(prop, "Paths Calculation End Frame", "End frame of range of frames to use for Bone Path calculations."); diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c index 2bb4333365b..9c453ac44df 100644 --- a/source/blender/makesrna/intern/rna_brush.c +++ b/source/blender/makesrna/intern/rna_brush.c @@ -32,6 +32,19 @@ #include "DNA_brush_types.h" #include "DNA_texture_types.h" +#include "IMB_imbuf.h" + +EnumPropertyItem brush_sculpt_tool_items[] = { + {SCULPT_TOOL_DRAW, "DRAW", 0, "Draw", ""}, + {SCULPT_TOOL_SMOOTH, "SMOOTH", 0, "Smooth", ""}, + {SCULPT_TOOL_PINCH, "PINCH", 0, "Pinch", ""}, + {SCULPT_TOOL_INFLATE, "INFLATE", 0, "Inflate", ""}, + {SCULPT_TOOL_GRAB, "GRAB", 0, "Grab", ""}, + {SCULPT_TOOL_LAYER, "LAYER", 0, "Layer", ""}, + {SCULPT_TOOL_FLATTEN, "FLATTEN", 0, "Flatten", ""}, + {SCULPT_TOOL_CLAY, "CLAY", 0, "Clay", ""}, + {0, NULL, 0, NULL, NULL}}; + #ifdef RNA_RUNTIME #include "MEM_guardedalloc.h" @@ -74,52 +87,24 @@ static void rna_Brush_active_texture_set(PointerRNA *ptr, PointerRNA value) } } -static float rna_Brush_rotation_get(PointerRNA *ptr) -{ - Brush *brush= (Brush*)ptr->data; - const float conv = 57.295779506; - return brush->rot * conv; -} - -static void rna_Brush_rotation_set(PointerRNA *ptr, float v) -{ - Brush *brush= (Brush*)ptr->data; - const float conv = 0.017453293; - brush->rot = v * conv; -} - #else void rna_def_brush(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; + static EnumPropertyItem prop_blend_items[] = { - {BRUSH_BLEND_MIX, "MIX", 0, "Mix", "Use mix blending mode while painting."}, - {BRUSH_BLEND_ADD, "ADD", 0, "Add", "Use add blending mode while painting."}, - {BRUSH_BLEND_SUB, "SUB", 0, "Subtract", "Use subtract blending mode while painting."}, - {BRUSH_BLEND_MUL, "MUL", 0, "Multiply", "Use multiply blending mode while painting."}, - {BRUSH_BLEND_LIGHTEN, "LIGHTEN", 0, "Lighten", "Use lighten blending mode while painting."}, - {BRUSH_BLEND_DARKEN, "DARKEN", 0, "Darken", "Use darken blending mode while painting."}, - {BRUSH_BLEND_ERASE_ALPHA, "ERASE_ALPHA", 0, "Erase Alpha", "Erase alpha while painting."}, - {BRUSH_BLEND_ADD_ALPHA, "ADD_ALPHA", 0, "Add Alpha", "Add alpha while painting."}, - {0, NULL, 0, NULL, NULL}}; - static EnumPropertyItem prop_texture_mode_items[] = { - {BRUSH_TEX_DRAG, "TEX_DRAG", 0, "Drag", ""}, - {BRUSH_TEX_TILE, "TEX_TILE", 0, "Tile", ""}, - {BRUSH_TEX_3D, "TEX_3D", 0, "3D", ""}, + {IMB_BLEND_MIX, "MIX", 0, "Mix", "Use mix blending mode while painting."}, + {IMB_BLEND_ADD, "ADD", 0, "Add", "Use add blending mode while painting."}, + {IMB_BLEND_SUB, "SUB", 0, "Subtract", "Use subtract blending mode while painting."}, + {IMB_BLEND_MUL, "MUL", 0, "Multiply", "Use multiply blending mode while painting."}, + {IMB_BLEND_LIGHTEN, "LIGHTEN", 0, "Lighten", "Use lighten blending mode while painting."}, + {IMB_BLEND_DARKEN, "DARKEN", 0, "Darken", "Use darken blending mode while painting."}, + {IMB_BLEND_ERASE_ALPHA, "ERASE_ALPHA", 0, "Erase Alpha", "Erase alpha while painting."}, + {IMB_BLEND_ADD_ALPHA, "ADD_ALPHA", 0, "Add Alpha", "Add alpha while painting."}, {0, NULL, 0, NULL, NULL}}; - static EnumPropertyItem prop_sculpt_tool_items[] = { - {SCULPT_TOOL_DRAW, "DRAW", 0, "Draw", ""}, - {SCULPT_TOOL_SMOOTH, "SMOOTH", 0, "Smooth", ""}, - {SCULPT_TOOL_PINCH, "PINCH", 0, "Pinch", ""}, - {SCULPT_TOOL_INFLATE, "INFLATE", 0, "Inflate", ""}, - {SCULPT_TOOL_GRAB, "GRAB", 0, "Grab", ""}, - {SCULPT_TOOL_LAYER, "LAYER", 0, "Layer", ""}, - {SCULPT_TOOL_FLATTEN, "FLATTEN", 0, "Flatten", ""}, - {SCULPT_TOOL_CLAY, "CLAY", 0, "Clay", ""}, - {0, NULL, 0, NULL, NULL}}; - + srna= RNA_def_struct(brna, "Brush", "ID"); RNA_def_struct_ui_text(srna, "Brush", "Brush datablock for storing brush settings for painting and sculpting."); RNA_def_struct_ui_icon(srna, ICON_BRUSH_DATA); @@ -129,13 +114,8 @@ void rna_def_brush(BlenderRNA *brna) RNA_def_property_enum_items(prop, prop_blend_items); RNA_def_property_ui_text(prop, "Blending mode", "Brush blending mode."); - prop= RNA_def_property(srna, "texture_mode", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "tex_mode"); - RNA_def_property_enum_items(prop, prop_texture_mode_items); - RNA_def_property_ui_text(prop, "Texture Mode", ""); - prop= RNA_def_property(srna, "sculpt_tool", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_items(prop, prop_sculpt_tool_items); + RNA_def_property_enum_items(prop, brush_sculpt_tool_items); RNA_def_property_ui_text(prop, "Sculpt Tool", ""); /* number values */ @@ -152,6 +132,14 @@ void rna_def_brush(BlenderRNA *brna) RNA_def_property_float_sdna(prop, NULL, "spacing"); RNA_def_property_range(prop, 1.0f, 100.0f); RNA_def_property_ui_text(prop, "Spacing", "Spacing between brush stamps."); + + prop= RNA_def_property(srna, "smooth_stroke_radius", PROP_INT, PROP_NONE); + RNA_def_property_range(prop, 10, 200); + RNA_def_property_ui_text(prop, "Smooth Stroke Radius", "Minimum distance from last point before stroke continues."); + + prop= RNA_def_property(srna, "smooth_stroke_factor", PROP_FLOAT, PROP_NONE); + RNA_def_property_range(prop, 0.5, 0.99); + RNA_def_property_ui_text(prop, "Smooth Stroke Factor", "Higher values give a smoother stroke."); prop= RNA_def_property(srna, "rate", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "rate"); @@ -167,12 +155,6 @@ void rna_def_brush(BlenderRNA *brna) RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Strength", "The amount of pressure on the brush."); - prop= RNA_def_property(srna, "rotation", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "rot"); - RNA_def_property_range(prop, 0, 360); - RNA_def_property_float_funcs(prop, "rna_Brush_rotation_get", "rna_Brush_rotation_set", NULL); - RNA_def_property_ui_text(prop, "Rotation", "Angle of the brush texture."); - /* flag */ prop= RNA_def_property(srna, "airbrush", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_AIRBRUSH); @@ -182,9 +164,9 @@ void rna_def_brush(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_TORUS); RNA_def_property_ui_text(prop, "Wrap", "Enable torus wrapping while painting."); - prop= RNA_def_property(srna, "opacity_pressure", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "strength_pressure", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_ALPHA_PRESSURE); - RNA_def_property_ui_text(prop, "Opacity Pressure", "Enable tablet pressure sensitivity for opacity."); + RNA_def_property_ui_text(prop, "Strength Pressure", "Enable tablet pressure sensitivity for strength."); prop= RNA_def_property(srna, "size_pressure", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_SIZE_PRESSURE); @@ -217,6 +199,10 @@ void rna_def_brush(BlenderRNA *brna) prop= RNA_def_property(srna, "smooth_stroke", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_SMOOTH_STROKE); RNA_def_property_ui_text(prop, "Smooth Stroke", "Brush lags behind mouse and follows a smoother path."); + + prop= RNA_def_property(srna, "persistent", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_PERSISTENT); + RNA_def_property_ui_text(prop, "Persistent", "Sculpts on a persistent layer of the mesh."); /* not exposed in the interface yet prop= RNA_def_property(srna, "fixed_tex", PROP_BOOLEAN, PROP_NONE); @@ -241,7 +227,7 @@ void rna_def_brush(BlenderRNA *brna) RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Clone Opacity", "Opacity of clone image display."); - prop= RNA_def_property(srna, "clone_offset", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "clone_offset", PROP_FLOAT, PROP_XYZ); RNA_def_property_float_sdna(prop, NULL, "clone.offset"); RNA_def_property_ui_text(prop, "Clone Offset", ""); RNA_def_property_ui_range(prop, -1.0f , 1.0f, 10.0f, 3); @@ -266,12 +252,12 @@ static void rna_def_operator_stroke_element(BlenderRNA *brna) srna= RNA_def_struct(brna, "OperatorStrokeElement", "IDPropertyGroup"); RNA_def_struct_ui_text(srna, "Operator Stroke Element", ""); - prop= RNA_def_property(srna, "location", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "location", PROP_FLOAT, PROP_XYZ); RNA_def_property_flag(prop, PROP_IDPROPERTY); RNA_def_property_array(prop, 3); RNA_def_property_ui_text(prop, "Location", ""); - prop= RNA_def_property(srna, "mouse", PROP_INT, PROP_VECTOR); + prop= RNA_def_property(srna, "mouse", PROP_FLOAT, PROP_XYZ); RNA_def_property_flag(prop, PROP_IDPROPERTY); RNA_def_property_array(prop, 2); RNA_def_property_ui_text(prop, "Mouse", ""); diff --git a/source/blender/makesrna/intern/rna_cloth.c b/source/blender/makesrna/intern/rna_cloth.c index 11443ddfde1..9096bfc2844 100644 --- a/source/blender/makesrna/intern/rna_cloth.c +++ b/source/blender/makesrna/intern/rna_cloth.c @@ -218,7 +218,7 @@ static void rna_def_cloth_sim_settings(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Mass Vertex Group", "Vertex Group for pinning of vertices."); RNA_def_property_update(prop, NC_OBJECT|ND_GEOM_DATA, "rna_cloth_update"); - prop= RNA_def_property(srna, "gravity", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "gravity", PROP_FLOAT, PROP_ACCELERATION); RNA_def_property_array(prop, 3); RNA_def_property_range(prop, -100.0, 100.0); RNA_def_property_float_funcs(prop, "rna_ClothSettings_gravity_get", "rna_ClothSettings_gravity_set", NULL); diff --git a/source/blender/makesrna/intern/rna_color.c b/source/blender/makesrna/intern/rna_color.c index f4248d18db3..420add2622a 100644 --- a/source/blender/makesrna/intern/rna_color.c +++ b/source/blender/makesrna/intern/rna_color.c @@ -130,7 +130,7 @@ static void rna_def_curvemappoint(BlenderRNA *brna) /* not editable for now, need to have CurveMapping to do curvemapping_changed */ - prop= RNA_def_property(srna, "location", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "location", PROP_FLOAT, PROP_XYZ); RNA_def_property_float_sdna(prop, NULL, "x"); RNA_def_property_array(prop, 2); RNA_def_property_clear_flag(prop, PROP_EDITABLE); diff --git a/source/blender/makesrna/intern/rna_constraint.c b/source/blender/makesrna/intern/rna_constraint.c index d08e59c11dc..a8dc0454cef 100644 --- a/source/blender/makesrna/intern/rna_constraint.c +++ b/source/blender/makesrna/intern/rna_constraint.c @@ -416,7 +416,7 @@ static void rna_def_constraint_kinematic(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Pole Sub-Target", ""); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_dependency_update"); - prop= RNA_def_property(srna, "pole_angle", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "pole_angle", PROP_FLOAT, PROP_ANGLE); // XXX - todo, convert to rad RNA_def_property_float_sdna(prop, NULL, "poleangle"); RNA_def_property_range(prop, 0.0, 180.f); RNA_def_property_ui_text(prop, "Pole Angle", "Pole rotation offset."); @@ -676,7 +676,7 @@ static void rna_def_constraint_minmax(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Use Rotation", "Use the target's rotation to determine floor."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "offset", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "offset", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_range(prop, 0.0, 100.f); RNA_def_property_ui_text(prop, "Offset", "Offset of floor from object center."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); @@ -768,13 +768,13 @@ static void rna_def_constraint_action(BlenderRNA *brna) RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "start_frame", PROP_INT, PROP_NONE); + prop= RNA_def_property(srna, "start_frame", PROP_INT, PROP_TIME); RNA_def_property_int_sdna(prop, NULL, "start"); RNA_def_property_range(prop, MINAFRAME, MAXFRAME); RNA_def_property_ui_text(prop, "Start Frame", "First frame of the Action to use."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "end_frame", PROP_INT, PROP_NONE); + prop= RNA_def_property(srna, "end_frame", PROP_INT, PROP_TIME); RNA_def_property_int_sdna(prop, NULL, "end"); RNA_def_property_range(prop, MINAFRAME, MAXFRAME); RNA_def_property_ui_text(prop, "End Frame", "Last frame of the Action to use."); @@ -871,7 +871,7 @@ static void rna_def_constraint_follow_path(BlenderRNA *brna) RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_dependency_update"); - prop= RNA_def_property(srna, "offset", PROP_INT, PROP_NONE); + prop= RNA_def_property(srna, "offset", PROP_INT, PROP_TIME); RNA_def_property_range(prop, -300000.0, 300000.f); RNA_def_property_ui_text(prop, "Offset", "Offset from the position corresponding to the time frame."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); @@ -938,7 +938,7 @@ static void rna_def_constraint_stretch_to(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Keep Axis", "Axis to maintain during stretch."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "original_length", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "original_length", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "orglength"); RNA_def_property_range(prop, 0.0, 100.f); RNA_def_property_ui_text(prop, "Original Length", "Length at rest position."); @@ -983,37 +983,37 @@ static void rna_def_constraint_rigid_body_joint(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Pivot Type", ""); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "pivot_x", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "pivot_x", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "pivX"); RNA_def_property_range(prop, -1000.0, 1000.f); RNA_def_property_ui_text(prop, "Pivot X", "Offset pivot on X."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "pivot_y", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "pivot_y", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "pivY"); RNA_def_property_range(prop, -1000.0, 1000.f); RNA_def_property_ui_text(prop, "Pivot Y", "Offset pivot on Y."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "pivot_z", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "pivot_z", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "pivZ"); RNA_def_property_range(prop, -1000.0, 1000.f); RNA_def_property_ui_text(prop, "Pivot Z", "Offset pivot on Z."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "axis_x", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "axis_x", PROP_FLOAT, PROP_ANGLE); // XXX - convert to radians RNA_def_property_float_sdna(prop, NULL, "axX"); RNA_def_property_range(prop, -360.0, 360.f); RNA_def_property_ui_text(prop, "Axis X", "Rotate pivot on X axis in degrees."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "axis_y", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "axis_y", PROP_FLOAT, PROP_ANGLE); // XXX - convert to radians RNA_def_property_float_sdna(prop, NULL, "axY"); RNA_def_property_range(prop, -360.0, 360.f); RNA_def_property_ui_text(prop, "Axis Y", "Rotate pivot on Y axis in degrees."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "axis_z", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "axis_z", PROP_FLOAT, PROP_ANGLE); // XXX - convert to radians RNA_def_property_float_sdna(prop, NULL, "axZ"); RNA_def_property_range(prop, -360.0, 360.f); RNA_def_property_ui_text(prop, "Axis Z", "Rotate pivot on Z axis in degrees."); @@ -1135,73 +1135,73 @@ static void rna_def_constraint_transform(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Extrapolate Motion", "Extrapolate ranges."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "from_min_x", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "from_min_x", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "from_min[0]"); RNA_def_property_range(prop, 0.0, 1000.f); RNA_def_property_ui_text(prop, "From Minimum X", "Bottom range of X axis source motion."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "from_min_y", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "from_min_y", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "from_min[1]"); RNA_def_property_range(prop, 0.0, 1000.f); RNA_def_property_ui_text(prop, "From Minimum Y", "Bottom range of Y axis source motion."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "from_min_z", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "from_min_z", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "from_min[2]"); RNA_def_property_range(prop, 0.0, 1000.f); RNA_def_property_ui_text(prop, "From Minimum Z", "Bottom range of Z axis source motion."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "from_max_x", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "from_max_x", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "from_max[0]"); RNA_def_property_range(prop, 0.0, 1000.f); RNA_def_property_ui_text(prop, "From Maximum X", "Top range of X axis source motion."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "from_max_y", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "from_max_y", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "from_max[1]"); RNA_def_property_range(prop, 0.0, 1000.f); RNA_def_property_ui_text(prop, "From Maximum Y", "Top range of Y axis source motion."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "from_max_z", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "from_max_z", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "from_max[2]"); RNA_def_property_range(prop, 0.0, 1000.f); RNA_def_property_ui_text(prop, "From Maximum Z", "Top range of Z axis source motion."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "to_min_x", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "to_min_x", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "to_min[0]"); RNA_def_property_range(prop, 0.0, 1000.f); RNA_def_property_ui_text(prop, "To Minimum X", "Bottom range of X axis destination motion."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "to_min_y", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "to_min_y", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "to_min[1]"); RNA_def_property_range(prop, 0.0, 1000.f); RNA_def_property_ui_text(prop, "To Minimum Y", "Bottom range of Y axis destination motion."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "to_min_z", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "to_min_z", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "to_min[2]"); RNA_def_property_range(prop, 0.0, 1000.f); RNA_def_property_ui_text(prop, "To Minimum Z", "Bottom range of Z axis destination motion."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "to_max_x", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "to_max_x", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "to_max[0]"); RNA_def_property_range(prop, 0.0, 1000.f); RNA_def_property_ui_text(prop, "To Maximum X", "Top range of X axis destination motion."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "to_max_y", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "to_max_y", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "to_max[1]"); RNA_def_property_range(prop, 0.0, 1000.f); RNA_def_property_ui_text(prop, "To Maximum Y", "Top range of Y axis destination motion."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "to_max_z", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "to_max_z", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "to_max[2]"); RNA_def_property_range(prop, 0.0, 1000.f); RNA_def_property_ui_text(prop, "To Maximum Z", "Top range of Z axis destination motion."); @@ -1247,37 +1247,37 @@ static void rna_def_constraint_location_limit(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Maximum Z", "Use the maximum Z value."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "minimum_x", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "minimum_x", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "xmin"); RNA_def_property_range(prop, -1000.0, 1000.f); RNA_def_property_ui_text(prop, "Minimum X", "Lowest X value to allow."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "minimum_y", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "minimum_y", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "ymin"); RNA_def_property_range(prop, -1000.0, 1000.f); RNA_def_property_ui_text(prop, "Minimum Y", "Lowest Y value to allow."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "minimum_z", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "minimum_z", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "zmin"); RNA_def_property_range(prop, -1000.0, 1000.f); RNA_def_property_ui_text(prop, "Minimum Z", "Lowest Z value to allow."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "maximum_x", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "maximum_x", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "xmax"); RNA_def_property_range(prop, -1000.0, 1000.f); RNA_def_property_ui_text(prop, "Maximum X", "Highest X value to allow."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "maximum_y", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "maximum_y", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "ymax"); RNA_def_property_range(prop, -1000.0, 1000.f); RNA_def_property_ui_text(prop, "Maximum Y", "Highest Y value to allow."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "maximum_z", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "maximum_z", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "zmax"); RNA_def_property_range(prop, -1000.0, 1000.f); RNA_def_property_ui_text(prop, "Maximum Z", "Highest Z value to allow."); @@ -1313,37 +1313,37 @@ static void rna_def_constraint_rotation_limit(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Limit Z", "Use the minimum Z value."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "minimum_x", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "minimum_x", PROP_FLOAT, PROP_ANGLE); RNA_def_property_float_sdna(prop, NULL, "xmin"); RNA_def_property_range(prop, -1000.0, 1000.f); RNA_def_property_ui_text(prop, "Minimum X", "Lowest X value to allow."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "minimum_y", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "minimum_y", PROP_FLOAT, PROP_ANGLE); RNA_def_property_float_sdna(prop, NULL, "ymin"); RNA_def_property_range(prop, -1000.0, 1000.f); RNA_def_property_ui_text(prop, "Minimum Y", "Lowest Y value to allow."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "minimum_z", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "minimum_z", PROP_FLOAT, PROP_ANGLE); RNA_def_property_float_sdna(prop, NULL, "zmin"); RNA_def_property_range(prop, -1000.0, 1000.f); RNA_def_property_ui_text(prop, "Minimum Z", "Lowest Z value to allow."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "maximum_x", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "maximum_x", PROP_FLOAT, PROP_ANGLE); RNA_def_property_float_sdna(prop, NULL, "xmax"); RNA_def_property_range(prop, -1000.0, 1000.f); RNA_def_property_ui_text(prop, "Maximum X", "Highest X value to allow."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "maximum_y", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "maximum_y", PROP_FLOAT, PROP_ANGLE); RNA_def_property_float_sdna(prop, NULL, "ymax"); RNA_def_property_range(prop, -1000.0, 1000.f); RNA_def_property_ui_text(prop, "Maximum Y", "Highest Y value to allow."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "maximum_z", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "maximum_z", PROP_FLOAT, PROP_ANGLE); RNA_def_property_float_sdna(prop, NULL, "zmax"); RNA_def_property_range(prop, -1000.0, 1000.f); RNA_def_property_ui_text(prop, "Maximum Z", "Highest Z value to allow."); @@ -1462,7 +1462,7 @@ static void rna_def_constraint_distance_limit(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Sub-Target", ""); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_dependency_update"); - prop= RNA_def_property(srna, "distance", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "distance", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "dist"); RNA_def_property_range(prop, 0.0, 100.f); RNA_def_property_ui_text(prop, "Distance", "Radius of limiting sphere."); @@ -1502,7 +1502,7 @@ static void rna_def_constraint_shrinkwrap(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Shrinkwrap Type", "Selects type of shrinkwrap algorithm for target position"); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "distance", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "distance", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "dist"); RNA_def_property_range(prop, 0.0, 100.f); RNA_def_property_ui_text(prop, "Distance", "Distance to Target."); diff --git a/source/blender/makesrna/intern/rna_context.c b/source/blender/makesrna/intern/rna_context.c index 5e164c6525f..7239fc1ff3d 100644 --- a/source/blender/makesrna/intern/rna_context.c +++ b/source/blender/makesrna/intern/rna_context.c @@ -31,10 +31,10 @@ #include "RNA_define.h" #include "RNA_types.h" -#ifdef RNA_RUNTIME - #include "BKE_context.h" +#ifdef RNA_RUNTIME + static PointerRNA rna_Context_manager_get(PointerRNA *ptr) { bContext *C= (bContext*)ptr->data; @@ -110,6 +110,12 @@ static PointerRNA rna_Context_user_preferences_get(PointerRNA *ptr) return newptr; } +static int rna_Context_mode_get(PointerRNA *ptr) +{ + bContext *C= (bContext*)ptr->data; + return CTX_data_mode_enum(C); +} + #else void RNA_def_context(BlenderRNA *brna) @@ -117,6 +123,23 @@ void RNA_def_context(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; + static EnumPropertyItem mode_items[] = { + {CTX_MODE_EDIT_MESH, "EDIT_MESH", 0, "Mesh Edit", ""}, + {CTX_MODE_EDIT_CURVE, "EDIT_CURVE", 0, "Curve Edit", ""}, + {CTX_MODE_EDIT_SURFACE, "EDIT_SURFACE", 0, "Surface Edit", ""}, + {CTX_MODE_EDIT_TEXT, "EDIT_TEXT", 0, "Edit Edit", ""}, + {CTX_MODE_EDIT_ARMATURE, "EDIT_ARMATURE", 0, "Armature Edit", ""}, // PARSKEL reuse will give issues + {CTX_MODE_EDIT_METABALL, "EDIT_METABALL", 0, "Metaball Edit", ""}, + {CTX_MODE_EDIT_LATTICE, "EDIT_LATTICE", 0, "Lattice Edit", ""}, + {CTX_MODE_POSE, "POSE", 0, "Pose ", ""}, + {CTX_MODE_SCULPT, "SCULPT", 0, "Sculpt", ""}, + {CTX_MODE_PAINT_WEIGHT, "PAINT_WEIGHT", 0, "Weight Paint", ""}, + {CTX_MODE_PAINT_VERTEX, "PAINT_VERTEX", 0, "Vertex Paint", ""}, + {CTX_MODE_PAINT_TEXTURE, "PAINT_TEXTURE", 0, "Texture Paint", ""}, + {CTX_MODE_PARTICLE, "PARTICLE", 0, "Particle", ""}, + {CTX_MODE_OBJECT, "OBJECT", 0, "Object", ""}, + {0, NULL, 0, NULL, NULL}}; + srna= RNA_def_struct(brna, "Context", NULL); RNA_def_struct_ui_text(srna, "Context", "Current windowmanager and data context."); RNA_def_struct_sdna(srna, "bContext"); @@ -177,6 +200,11 @@ void RNA_def_context(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_struct_type(prop, "UserPreferences"); RNA_def_property_pointer_funcs(prop, "rna_Context_user_preferences_get", NULL, NULL); + + prop= RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, mode_items); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_enum_funcs(prop, "rna_Context_mode_get", NULL, NULL); } #endif diff --git a/source/blender/makesrna/intern/rna_curve.c b/source/blender/makesrna/intern/rna_curve.c index 92b4dead516..1dd3d0e63c5 100644 --- a/source/blender/makesrna/intern/rna_curve.c +++ b/source/blender/makesrna/intern/rna_curve.c @@ -55,6 +55,7 @@ EnumPropertyItem beztriple_interpolation_mode_items[] = { #include "BKE_curve.h" #include "BKE_depsgraph.h" +#include "BKE_main.h" #include "WM_api.h" #include "WM_types.h" @@ -148,13 +149,20 @@ static void rna_BPoint_array_begin(CollectionPropertyIterator *iter, PointerRNA rna_iterator_array_begin(iter, (void*)nu->bp, sizeof(BPoint*), nu->pntsv>0 ? nu->pntsu*nu->pntsv : nu->pntsu, 0, NULL); } -static void rna_Curve_update(bContext *C, PointerRNA *ptr) +static void rna_Curve_update_data(bContext *C, PointerRNA *ptr) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); - Object *obedit= CTX_data_edit_object(C); - - DAG_object_flush_update(scene, obedit, OB_RECALC_DATA); - WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, scene); + Curve *cu= ptr->id.data; + Object *ob; + + for(ob=bmain->object.first; ob; ob= ob->id.next) { + if(ob->data == cu) { + /* XXX this will loop over all objects again (slow) */ + DAG_object_flush_update(scene, ob, OB_RECALC_DATA); + WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, ob); + } + } } #else @@ -172,38 +180,38 @@ static void rna_def_bpoint(BlenderRNA *brna) prop= RNA_def_property(srna, "selected", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "f1", 0); RNA_def_property_ui_text(prop, "Selected", "Selection status"); - RNA_def_property_update(prop, 0, "rna_Curve_update"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "hidden", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "hide", 0); RNA_def_property_ui_text(prop, "Hidden", "Visibility status"); - RNA_def_property_update(prop, 0, "rna_Curve_update"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); /* Vector value */ - prop= RNA_def_property(srna, "point", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "point", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_array(prop, 4); RNA_def_property_float_sdna(prop, NULL, "vec"); RNA_def_property_ui_text(prop, "Point", "Point coordinates"); - RNA_def_property_update(prop, 0, "rna_Curve_update"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); /* Number values */ prop= RNA_def_property(srna, "tilt", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "alfa"); /*RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);*/ RNA_def_property_ui_text(prop, "Tilt", "Tilt in 3d View"); - RNA_def_property_update(prop, 0, "rna_Curve_update"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "weight", PROP_FLOAT, PROP_NONE); RNA_def_property_range(prop, 0.01f, 100.0f); RNA_def_property_ui_text(prop, "Weight", "Softbody goal weight"); - RNA_def_property_update(prop, 0, "rna_Curve_update"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "bevel_radius", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "radius"); /*RNA_def_property_range(prop, 0.0f, 1.0f);*/ RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Bevel Radius", "Radius for bevelling"); - RNA_def_property_update(prop, 0, "rna_Curve_update"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); } static void rna_def_beztriple(BlenderRNA *brna) @@ -219,80 +227,80 @@ static void rna_def_beztriple(BlenderRNA *brna) prop= RNA_def_property(srna, "selected_handle1", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "f1", 0); RNA_def_property_ui_text(prop, "Handle 1 selected", "Handle 1 selection status"); - RNA_def_property_update(prop, 0, "rna_Curve_update"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "selected_handle2", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "f3", 0); RNA_def_property_ui_text(prop, "Handle 2 selected", "Handle 2 selection status"); - RNA_def_property_update(prop, 0, "rna_Curve_update"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "selected_control_point", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "f2", 0); RNA_def_property_ui_text(prop, "Control Point selected", "Control point selection status"); - RNA_def_property_update(prop, 0, "rna_Curve_update"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "hidden", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "hide", 0); RNA_def_property_ui_text(prop, "Hidden", "Visibility status"); - RNA_def_property_update(prop, 0, "rna_Curve_update"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); /* Enums */ prop= RNA_def_property(srna, "handle1_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "h1"); RNA_def_property_enum_items(prop, beztriple_handle_type_items); RNA_def_property_ui_text(prop, "Handle 1 Type", "Handle types"); - RNA_def_property_update(prop, 0, "rna_Curve_update"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "handle2_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "h2"); RNA_def_property_enum_items(prop, beztriple_handle_type_items); RNA_def_property_ui_text(prop, "Handle 2 Type", "Handle types"); - RNA_def_property_update(prop, 0, "rna_Curve_update"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "interpolation", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "ipo"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_enum_items(prop, beztriple_interpolation_mode_items); RNA_def_property_ui_text(prop, "Interpolation", "(For F-Curves Only) Interpolation to use for segment of curve starting from current BezTriple."); - RNA_def_property_update(prop, 0, "rna_Curve_update"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); /* Vector values */ - prop= RNA_def_property(srna, "handle1", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "handle1", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_array(prop, 3); RNA_def_property_float_funcs(prop, "rna_BezTriple_handle1_get", "rna_BezTriple_handle1_set", NULL); RNA_def_property_ui_text(prop, "Handle 1", "Coordinates of the first handle"); - RNA_def_property_update(prop, 0, "rna_Curve_update"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); - prop= RNA_def_property(srna, "control_point", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "control_point", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_array(prop, 3); RNA_def_property_float_funcs(prop, "rna_BezTriple_ctrlpoint_get", "rna_BezTriple_ctrlpoint_set", NULL); RNA_def_property_ui_text(prop, "Control Point", "Coordinates of the control point"); - RNA_def_property_update(prop, 0, "rna_Curve_update"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); - prop= RNA_def_property(srna, "handle2", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "handle2", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_array(prop, 3); RNA_def_property_float_funcs(prop, "rna_BezTriple_handle2_get", "rna_BezTriple_handle2_set", NULL); RNA_def_property_ui_text(prop, "Handle 2", "Coordinates of the second handle"); - RNA_def_property_update(prop, 0, "rna_Curve_update"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); /* Number values */ prop= RNA_def_property(srna, "tilt", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "alfa"); /*RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);*/ RNA_def_property_ui_text(prop, "Tilt", "Tilt in 3d View"); - RNA_def_property_update(prop, 0, "rna_Curve_update"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "weight", PROP_FLOAT, PROP_NONE); RNA_def_property_range(prop, 0.01f, 100.0f); RNA_def_property_ui_text(prop, "Weight", "Softbody goal weight"); - RNA_def_property_update(prop, 0, "rna_Curve_update"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "bevel_radius", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "radius"); /*RNA_def_property_range(prop, 0.0f, 1.0f);*/ RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Bevel Radius", "Radius for bevelling"); - RNA_def_property_update(prop, 0, "rna_Curve_update"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); } static void rna_def_path(BlenderRNA *brna, StructRNA *srna) @@ -304,28 +312,28 @@ static void rna_def_path(BlenderRNA *brna, StructRNA *srna) RNA_def_property_int_sdna(prop, NULL, "pathlen"); RNA_def_property_range(prop, 1, 32767); RNA_def_property_ui_text(prop, "Path Length", "If no speed IPO was set, the length of path in frames."); - RNA_def_property_update(prop, 0, "rna_Curve_update"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); /* flags */ prop= RNA_def_property(srna, "path", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_PATH); RNA_def_property_ui_text(prop, "Path", "Enable the curve to become a translation path."); - RNA_def_property_update(prop, 0, "rna_Curve_update"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "follow", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_FOLLOW); RNA_def_property_ui_text(prop, "Follow", "Make curve path children to rotate along the path."); - RNA_def_property_update(prop, 0, "rna_Curve_update"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "stretch", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_STRETCH); RNA_def_property_ui_text(prop, "Stretch", "Option for curve-deform: makes deformed child to stretch along entire path."); - RNA_def_property_update(prop, 0, "rna_Curve_update"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "offset_path_distance", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_OFFS_PATHDIST); RNA_def_property_ui_text(prop, "Offset Path Distance", "Children will use TimeOffs value as path distance offset."); - RNA_def_property_update(prop, 0, "rna_Curve_update"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); } static void rna_def_nurbs(BlenderRNA *brna, StructRNA *srna) @@ -336,12 +344,12 @@ static void rna_def_nurbs(BlenderRNA *brna, StructRNA *srna) prop= RNA_def_property(srna, "uv_orco", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_UV_ORCO); RNA_def_property_ui_text(prop, "UV Orco", "Forces to use UV coordinates for texture mapping 'orco'."); - RNA_def_property_update(prop, 0, "rna_Curve_update"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "vertex_normal_flip", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", CU_NOPUNOFLIP); RNA_def_property_ui_text(prop, "Vertex Normal Flip", "Flip vertex normals towards the camera during render"); - RNA_def_property_update(prop, 0, "rna_Curve_update"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); } static void rna_def_font(BlenderRNA *brna, StructRNA *srna) @@ -360,73 +368,74 @@ static void rna_def_font(BlenderRNA *brna, StructRNA *srna) prop= RNA_def_property(srna, "spacemode", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, prop_align_items); RNA_def_property_ui_text(prop, "Text Align", "Text align from the object center."); - RNA_def_property_update(prop, 0, "rna_Curve_update"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); /* number values */ prop= RNA_def_property(srna, "text_size", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "fsize"); RNA_def_property_range(prop, 0.1f, 10.0f); RNA_def_property_ui_text(prop, "Font size", ""); - RNA_def_property_update(prop, 0, "rna_Curve_update"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "line_dist", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "linedist"); RNA_def_property_range(prop, 0.0f, 10.0f); RNA_def_property_ui_text(prop, "Distance between lines of text", ""); - RNA_def_property_update(prop, 0, "rna_Curve_update"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "word_spacing", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "wordspace"); RNA_def_property_range(prop, 0.0f, 10.0f); RNA_def_property_ui_text(prop, "Spacing between words", ""); - RNA_def_property_update(prop, 0, "rna_Curve_update"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "spacing", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "spacing"); RNA_def_property_range(prop, 0.0f, 10.0f); RNA_def_property_ui_text(prop, "Global spacing between characters", ""); - RNA_def_property_update(prop, 0, "rna_Curve_update"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "shear", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "shear"); RNA_def_property_range(prop, -1.0f, 1.0f); RNA_def_property_ui_text(prop, "Shear", "Italic angle of the characters"); - RNA_def_property_update(prop, 0, "rna_Curve_update"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "x_offset", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "xof"); RNA_def_property_range(prop, -50.0f, 50.0f); RNA_def_property_ui_text(prop, "X Offset", "Horizontal offset from the object center"); - RNA_def_property_update(prop, 0, "rna_Curve_update"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "y_offset", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "yof"); RNA_def_property_range(prop, -50.0f, 50.0f); RNA_def_property_ui_text(prop, "Y Offset", "Vertical offset from the object center"); - RNA_def_property_update(prop, 0, "rna_Curve_update"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "ul_position", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "ulpos"); RNA_def_property_range(prop, -0.2f, 0.8f); RNA_def_property_ui_text(prop, "Underline position", "Vertical position of underline"); - RNA_def_property_update(prop, 0, "rna_Curve_update"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "ul_height", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "ulheight"); RNA_def_property_range(prop, -0.2f, 0.8f); RNA_def_property_ui_text(prop, "Underline thickness", ""); - RNA_def_property_update(prop, 0, "rna_Curve_update"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "active_textbox", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "actbox"); RNA_def_property_range(prop, 0, 100); RNA_def_property_ui_text(prop, "The active text box", ""); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); /* strings */ prop= RNA_def_property(srna, "family", PROP_STRING, PROP_NONE); RNA_def_property_string_maxlength(prop, 21); RNA_def_property_ui_text(prop, "Family", "Blender uses font from selfmade objects."); - RNA_def_property_update(prop, 0, "rna_Curve_update"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "str", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "str"); @@ -440,26 +449,28 @@ static void rna_def_font(BlenderRNA *brna, StructRNA *srna) RNA_def_property_pointer_sdna(prop, NULL, "textoncurve"); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Text on Curve", "Curve deforming text object."); - RNA_def_property_update(prop, 0, "rna_Curve_update"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "font", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "vfont"); RNA_def_property_ui_text(prop, "Font", ""); - RNA_def_property_update(prop, 0, "rna_Curve_update"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "textbox", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "tb"); RNA_def_property_ui_text(prop, "Textbox", ""); - RNA_def_property_update(prop, 0, "rna_Curve_update"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "edit_format", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "curinfo"); RNA_def_property_ui_text(prop, "Edit Format", "Editing settings character formatting."); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); /* flags */ prop= RNA_def_property(srna, "fast", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_FAST); RNA_def_property_ui_text(prop, "Fast", "Don't fill polygons while editing."); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); } static void rna_def_textbox(BlenderRNA *brna) @@ -475,25 +486,25 @@ static void rna_def_textbox(BlenderRNA *brna) RNA_def_property_float_sdna(prop, NULL, "x"); RNA_def_property_range(prop, -50.0f, 50.0f); RNA_def_property_ui_text(prop, "Textbox X Offset", ""); - RNA_def_property_update(prop, 0, "rna_Curve_update"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "y", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "y"); RNA_def_property_range(prop, -50.0f, 50.0f); RNA_def_property_ui_text(prop, "Textbox Y Offset", ""); - RNA_def_property_update(prop, 0, "rna_Curve_update"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "width", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "w"); RNA_def_property_range(prop, 0.0f, 50.0f); RNA_def_property_ui_text(prop, "Textbox Width", ""); - RNA_def_property_update(prop, 0, "rna_Curve_update"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "height", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "h"); RNA_def_property_range(prop, 0.0f, 50.0f); RNA_def_property_ui_text(prop, "Textbox Height", ""); - RNA_def_property_update(prop, 0, "rna_Curve_update"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); } static void rna_def_charinfo(BlenderRNA *brna) @@ -509,27 +520,27 @@ static void rna_def_charinfo(BlenderRNA *brna) prop= RNA_def_property(srna, "style", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_STYLE); RNA_def_property_ui_text(prop, "Style", ""); - RNA_def_property_update(prop, 0, "rna_Curve_update"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "bold", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_BOLD); RNA_def_property_ui_text(prop, "Bold", ""); - RNA_def_property_update(prop, 0, "rna_Curve_update"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "italic", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_ITALIC); RNA_def_property_ui_text(prop, "Italic", ""); - RNA_def_property_update(prop, 0, "rna_Curve_update"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "underline", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_UNDERLINE); RNA_def_property_ui_text(prop, "Underline", ""); - RNA_def_property_update(prop, 0, "rna_Curve_update"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "wrap", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_WRAP); RNA_def_property_ui_text(prop, "Wrap", ""); - RNA_def_property_update(prop, 0, "rna_Curve_update"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); } static void rna_def_surface(BlenderRNA *brna) @@ -587,37 +598,37 @@ static void rna_def_curve(BlenderRNA *brna) RNA_def_property_range(prop, 0, 32); RNA_def_property_ui_range(prop, 0, 32, 1.0, 0); RNA_def_property_ui_text(prop, "Bevel Resolution", "Bevel resolution when depth is non-zero and no specific bevel object has been defined."); - RNA_def_property_update(prop, 0, "rna_Curve_update"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "width", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "width"); RNA_def_property_ui_range(prop, 0, 2.0, 0.1, 0); RNA_def_property_ui_text(prop, "Width", "Scale the original width (1.0) based on given factor."); - RNA_def_property_update(prop, 0, "rna_Curve_update"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "extrude", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "ext1"); RNA_def_property_ui_range(prop, 0, 100.0, 0.1, 0); RNA_def_property_ui_text(prop, "Extrude", "Amount of curve extrusion when not using a bevel object."); - RNA_def_property_update(prop, 0, "rna_Curve_update"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "bevel_depth", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "ext2"); RNA_def_property_ui_range(prop, 0, 100.0, 0.1, 0); RNA_def_property_ui_text(prop, "Bevel Depth", "Bevel depth when not using a bevel object."); - RNA_def_property_update(prop, 0, "rna_Curve_update"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "resolution_u", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "resolu"); RNA_def_property_ui_range(prop, 1, 1024, 1, 0); RNA_def_property_ui_text(prop, "Resolution U", "Surface resolution in U direction."); - RNA_def_property_update(prop, 0, "rna_Curve_update"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "resolution_v", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "resolv"); RNA_def_property_ui_range(prop, 1, 1024, 1, 0); RNA_def_property_ui_text(prop, "Resolution V", "Surface resolution in V direction."); - RNA_def_property_update(prop, 0, "rna_Curve_update"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "render_resolution_u", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "resolu_ren"); @@ -633,41 +644,41 @@ static void rna_def_curve(BlenderRNA *brna) prop= RNA_def_property(srna, "eval_time", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "ctime"); RNA_def_property_ui_text(prop, "Evaluation Time", "Parametric position along the length of the curve that Objects 'following' it should be at."); - RNA_def_property_update(prop, 0, "rna_Curve_update"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); /* pointers */ prop= RNA_def_property(srna, "bevel_object", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "bevobj"); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Bevel Object", "Curve object name that defines the bevel shape."); - RNA_def_property_update(prop, 0, "rna_Curve_update"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "taper_object", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "taperobj"); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Taper Object", "Curve object name that defines the taper (width)."); - RNA_def_property_update(prop, 0, "rna_Curve_update"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); /* Flags */ prop= RNA_def_property(srna, "curve_2d", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", CU_3D); RNA_def_property_ui_text(prop, "2D Curve", "Define curve in two dimensions only. Note that fill only works when this is enabled."); - RNA_def_property_update(prop, 0, "rna_Curve_update"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "front", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_FRONT); RNA_def_property_ui_text(prop, "Front", "Draw filled front for extruded/beveled curves."); - RNA_def_property_update(prop, 0, "rna_Curve_update"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "back", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_BACK); RNA_def_property_ui_text(prop, "Back", "Draw filled back for extruded/beveled curves."); - RNA_def_property_update(prop, 0, "rna_Curve_update"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "retopo", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_RETOPO); RNA_def_property_ui_text(prop, "Retopo", "Turn on the re-topology tool."); - RNA_def_property_update(prop, 0, "rna_Curve_update"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); } static void rna_def_curve_nurb(BlenderRNA *brna) @@ -701,89 +712,107 @@ static void rna_def_curve_nurb(BlenderRNA *brna) RNA_def_property_enum_sdna(prop, NULL, "tilt_interp"); RNA_def_property_enum_items(prop, spline_interpolation_items); RNA_def_property_ui_text(prop, "Tilt Interpolation", "The type of tilt interpolation for 3D, Bezier curves."); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "radius_interpolation", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "radius_interp"); RNA_def_property_enum_items(prop, spline_interpolation_items); RNA_def_property_ui_text(prop, "Radius Interpolation", "The type of radius interpolation for Bezier curves."); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "point_count_u", PROP_INT, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* editing this needs knot recalc*/ RNA_def_property_int_sdna(prop, NULL, "pntsu"); RNA_def_property_ui_text(prop, "Points U", "Total number points for the curve or surface in the U direction"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "point_count_v", PROP_INT, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* editing this needs knot recalc*/ RNA_def_property_int_sdna(prop, NULL, "pntsv"); RNA_def_property_ui_text(prop, "Points V", "Total number points for the surface on the V direction"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "order_u", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "orderu"); RNA_def_property_range(prop, 2, 6); RNA_def_property_ui_text(prop, "Order U", "Nurbs order in the U direction (For curves and surfaces), Higher values let points influence a greater area"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "order_v", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "orderv"); RNA_def_property_range(prop, 2, 6); RNA_def_property_ui_text(prop, "Order V", "Nurbs order in the V direction (For surfaces only), Higher values let points influence a greater area"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "resolution_u", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "resolu"); RNA_def_property_range(prop, 1, 1024); RNA_def_property_ui_text(prop, "Resolution U", "Curve or Surface subdivisions per segment"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "resolution_v", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "resolv"); RNA_def_property_range(prop, 1, 1024); RNA_def_property_ui_text(prop, "Resolution V", "Surface subdivisions per segment"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "cyclic_u", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flagu", CU_CYCLIC); RNA_def_property_ui_text(prop, "Cyclic U", "Make this curve or surface a closed loop in the U direction."); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "cyclic_v", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flagv", CU_CYCLIC); RNA_def_property_ui_text(prop, "Cyclic V", "Make this surface a closed loop in the V direction."); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); /* Note, endpoint and bezier flags should never be on at the same time! */ prop= RNA_def_property(srna, "endpoint_u", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flagu", 2); RNA_def_property_ui_text(prop, "Endpoint U", "Make this nurbs curve or surface meet the endpoints in the U direction (Cyclic U must be disabled)."); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "endpoint_v", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flagv", 2); RNA_def_property_ui_text(prop, "Endpoint V", "Make this nurbs surface meet the endpoints in the V direction (Cyclic V must be disabled)."); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "bezier_u", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flagu", 4); RNA_def_property_ui_text(prop, "Bezier U", "Make this nurbs curve or surface act like a bezier spline in the U direction (Order U must be 3 or 4, Cyclic U must be disabled)."); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "bezier_v", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flagv", 4); RNA_def_property_ui_text(prop, "Bezier V", "Make this nurbs surface act like a bezier spline in the V direction (Order V must be 3 or 4, Cyclic V must be disabled)."); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "smooth", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_SMOOTH); RNA_def_property_ui_text(prop, "Smooth", "Smooth the normals of the surface or beveled curve."); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "hide", 1); RNA_def_property_ui_text(prop, "Hide", "Hide this curve in editmode."); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "material_index", PROP_INT, PROP_UNSIGNED); RNA_def_property_int_sdna(prop, NULL, "mat_nr"); RNA_def_property_ui_text(prop, "Material Index", ""); RNA_def_property_int_funcs(prop, NULL, NULL, "rna_Curve_material_index_range"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "character_index", PROP_INT, PROP_UNSIGNED); RNA_def_property_int_sdna(prop, NULL, "charidx"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* editing this needs knot recalc*/ - RNA_def_property_ui_text(prop, "Character Index", "the location of this character in the text data (only for text curves)"); + RNA_def_property_ui_text(prop, "Character Index", "Location of this character in the text data (only for text curves)"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); } void RNA_def_curve(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c index 42c6f74b6ec..1f51b3ff34c 100644 --- a/source/blender/makesrna/intern/rna_define.c +++ b/source/blender/makesrna/intern/rna_define.c @@ -77,6 +77,20 @@ void rna_remlink(ListBase *listbase, void *vlink) if (listbase->first == link) listbase->first = link->next; } +PropertyDefRNA *rna_findlink(ListBase *listbase, const char *identifier) +{ + Link *link; + + for(link=listbase->first; link; link=link->next) { + PropertyRNA *prop= ((PropertyDefRNA *)link)->prop; + if(prop && (strcmp(prop->identifier, identifier)==0)) { + return (PropertyDefRNA *)link; + } + } + + return NULL; +} + void rna_freelinkN(ListBase *listbase, void *vlink) { rna_remlink(listbase, vlink); @@ -444,6 +458,15 @@ void RNA_define_verify_sdna(int verify) DefRNA.verify= verify; } +void RNA_struct_free_extension(StructRNA *srna, ExtensionRNA *ext) +{ +#ifdef RNA_RUNTIME + ext->free(ext->data); /* decref's the PyObject that the srna owns */ + RNA_struct_blender_type_set(srna, NULL); /* this gets accessed again - XXX fixme */ + RNA_struct_py_type_set(srna, NULL); /* NULL the srna's value so RNA_struct_free wont complain of a leak */ +#endif +} + void RNA_struct_free(BlenderRNA *brna, StructRNA *srna) { #ifdef RNA_RUNTIME @@ -451,6 +474,12 @@ void RNA_struct_free(BlenderRNA *brna, StructRNA *srna) PropertyRNA *prop, *nextprop; PropertyRNA *parm, *nextparm; + if(srna->flag & STRUCT_RUNTIME) { + if(RNA_struct_py_type_get(srna)) { + fprintf(stderr, "StructRNA \"%s\" freed while holdng a python reference\n", srna->name); + } + } + for(prop=srna->cont.properties.first; prop; prop=nextprop) { nextprop= prop->next; @@ -482,6 +511,7 @@ void RNA_struct_free(BlenderRNA *brna, StructRNA *srna) if(srna->flag & STRUCT_RUNTIME) rna_freelinkN(&brna->structs, srna); + #endif } @@ -821,6 +851,13 @@ PropertyRNA *RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier } dcont= rna_find_container_def(cont); + + /* XXX - toto, detect supertype collisions */ + if(rna_findlink(&dcont->properties, identifier)) { + fprintf(stderr, "RNA_def_property: duplicate identifier \"%s\"\n", identifier); + DefRNA.error= 1; + } + dprop= MEM_callocN(sizeof(PropertyDefRNA), "PropertyDefRNA"); rna_addtail(&dcont->properties, dprop); } @@ -991,6 +1028,26 @@ void RNA_def_property_array(PropertyRNA *prop, int arraylength) DefRNA.error= 1; break; } + + prop->arraydimension= 1; +} + +void RNA_def_property_multidimensional_array(PropertyRNA *prop, int arraylength, unsigned short dimension, unsigned short dimsize[]) +{ + StructRNA *srna= DefRNA.laststruct; + + if (dimension < 1 || dimension > RNA_MAX_ARRAY_DIMENSION) { + fprintf(stderr, "RNA_def_property_multidimensional_array: %s.%s, array dimension must be between 1 and %d.\n", srna->identifier, prop->identifier, RNA_MAX_ARRAY_DIMENSION); + DefRNA.error= 1; + return; + } + + RNA_def_property_array(prop, arraylength); + + prop->arraydimension= dimension; + + if (dimension > 1) + memcpy(prop->dimsize, dimsize, sizeof(dimsize[0]) * (dimension - 1)); } void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description) @@ -1066,7 +1123,7 @@ void RNA_def_property_struct_type(PropertyRNA *prop, const char *type) StructRNA *srna= DefRNA.laststruct; if(!DefRNA.preprocess) { - fprintf(stderr, "RNA_def_property_struct_type: only during preprocessing.\n"); + fprintf(stderr, "RNA_def_property_struct_type %s.%s: only during preprocessing.\n", srna->identifier, prop->identifier); return; } @@ -1136,8 +1193,14 @@ void RNA_def_property_enum_items(PropertyRNA *prop, const EnumPropertyItem *item defaultfound= 1; } - if(!defaultfound) - eprop->defaultvalue= item[0].value; + if(!defaultfound) { + for(i=0; item[i].identifier; i++) { + if(item[i].identifier[0]) { + eprop->defaultvalue= item[i].value; + break; + } + } + } break; } @@ -1645,6 +1708,23 @@ void RNA_def_property_update(PropertyRNA *prop, int noteflag, const char *func) prop->update= (UpdateFunc)func; } +void RNA_def_property_dynamic_array_funcs(PropertyRNA *prop, const char *getlength, const char *setlength) +{ + if(!DefRNA.preprocess) { + fprintf(stderr, "RNA_def_property_*_funcs: only during preprocessing.\n"); + return; + } + + if (!(prop->flag & PROP_DYNAMIC)) { + fprintf(stderr, "RNA_def_property_dynamic_array_funcs: property is a not dynamic array.\n"); + DefRNA.error= 1; + return; + } + + if(getlength) prop->getlength= (PropArrayLengthGetFunc)getlength; + if(setlength) prop->setlength= (PropArrayLengthSetFunc)setlength; +} + void RNA_def_property_boolean_funcs(PropertyRNA *prop, const char *get, const char *set) { StructRNA *srna= DefRNA.laststruct; @@ -1877,7 +1957,7 @@ PropertyRNA *RNA_def_boolean_vector(StructOrFunctionRNA *cont_, const char *iden ContainerRNA *cont= cont_; PropertyRNA *prop; - prop= RNA_def_property(cont, identifier, PROP_BOOLEAN, PROP_VECTOR); + prop= RNA_def_property(cont, identifier, PROP_BOOLEAN, PROP_XYZ); // XXX if(len != 0) RNA_def_property_array(prop, len); if(default_value) RNA_def_property_boolean_array_default(prop, default_value); RNA_def_property_ui_text(prop, ui_name, ui_description); @@ -1906,7 +1986,7 @@ PropertyRNA *RNA_def_int_vector(StructOrFunctionRNA *cont_, const char *identifi ContainerRNA *cont= cont_; PropertyRNA *prop; - prop= RNA_def_property(cont, identifier, PROP_INT, PROP_VECTOR); + prop= RNA_def_property(cont, identifier, PROP_INT, PROP_XYZ); // XXX if(len != 0) RNA_def_property_array(prop, len); if(default_value) RNA_def_property_int_array_default(prop, default_value); if(hardmin != hardmax) RNA_def_property_range(prop, hardmin, hardmax); @@ -2015,7 +2095,7 @@ PropertyRNA *RNA_def_float_vector(StructOrFunctionRNA *cont_, const char *identi ContainerRNA *cont= cont_; PropertyRNA *prop; - prop= RNA_def_property(cont, identifier, PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(cont, identifier, PROP_FLOAT, PROP_XYZ); if(len != 0) RNA_def_property_array(prop, len); if(default_value) RNA_def_property_float_array_default(prop, default_value); if(hardmin != hardmax) RNA_def_property_range(prop, hardmin, hardmax); @@ -2042,14 +2122,15 @@ PropertyRNA *RNA_def_float_color(StructOrFunctionRNA *cont_, const char *identif } -PropertyRNA *RNA_def_float_matrix(StructOrFunctionRNA *cont_, const char *identifier, int len, const float *default_value, +PropertyRNA *RNA_def_float_matrix(StructOrFunctionRNA *cont_, const char *identifier, int len, int rowsize, const float *default_value, float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax) { ContainerRNA *cont= cont_; PropertyRNA *prop; + unsigned short dimsize[1]= {rowsize}; prop= RNA_def_property(cont, identifier, PROP_FLOAT, PROP_MATRIX); - if(len != 0) RNA_def_property_array(prop, len); + if(len != 0) RNA_def_property_multidimensional_array(prop, len, 2, dimsize); if(default_value) RNA_def_property_float_array_default(prop, default_value); if(hardmin != hardmax) RNA_def_property_range(prop, hardmin, hardmax); RNA_def_property_ui_text(prop, ui_name, ui_description); @@ -2064,7 +2145,7 @@ PropertyRNA *RNA_def_float_rotation(StructOrFunctionRNA *cont_, const char *iden ContainerRNA *cont= cont_; PropertyRNA *prop; - prop= RNA_def_property(cont, identifier, PROP_FLOAT, PROP_ROTATION); + prop= RNA_def_property(cont, identifier, PROP_FLOAT, PROP_EULER); // XXX if(len != 0) RNA_def_property_array(prop, len); if(default_value) RNA_def_property_float_array_default(prop, default_value); if(hardmin != hardmax) RNA_def_property_range(prop, hardmin, hardmax); @@ -2249,6 +2330,10 @@ int rna_parameter_size(PropertyRNA *parm) int len= parm->arraylength; if(len > 0) { + + if (parm->flag & PROP_DYNAMIC) + return sizeof(void *); + switch (ptype) { case PROP_BOOLEAN: case PROP_INT: @@ -2382,6 +2467,7 @@ void RNA_def_property_duplicate_pointers(PropertyRNA *prop) EnumPropertyItem *earray; float *farray; int *iarray; + int a; if(prop->identifier) prop->identifier= BLI_strdup(prop->identifier); if(prop->name) prop->name= BLI_strdup(prop->name); @@ -2415,7 +2501,14 @@ void RNA_def_property_duplicate_pointers(PropertyRNA *prop) earray= MEM_callocN(sizeof(EnumPropertyItem)*(eprop->totitem+1), "RNA_def_property_store"), memcpy(earray, eprop->item, sizeof(EnumPropertyItem)*(eprop->totitem+1)); eprop->item= earray; + + for(a=0; a<eprop->totitem; a++) { + if(eprop->item[a].identifier) eprop->item[a].identifier= BLI_strdup(eprop->item[a].identifier); + if(eprop->item[a].name) eprop->item[a].name= BLI_strdup(eprop->item[a].name); + if(eprop->item[a].description) eprop->item[a].description= BLI_strdup(eprop->item[a].description); + } } + break; } case PROP_FLOAT: { FloatPropertyRNA *fprop= (FloatPropertyRNA*)prop; @@ -2442,6 +2535,8 @@ void RNA_def_property_duplicate_pointers(PropertyRNA *prop) void RNA_def_property_free_pointers(PropertyRNA *prop) { if(prop->flag & PROP_FREE_POINTERS) { + int a; + if(prop->identifier) MEM_freeN((void*)prop->identifier); if(prop->name) MEM_freeN((void*)prop->name); if(prop->description) MEM_freeN((void*)prop->description); @@ -2465,6 +2560,13 @@ void RNA_def_property_free_pointers(PropertyRNA *prop) case PROP_ENUM: { EnumPropertyRNA *eprop= (EnumPropertyRNA*)prop; if(eprop->item) MEM_freeN((void*)eprop->item); + + for(a=0; a<eprop->totitem; a++) { + if(eprop->item[a].identifier) MEM_freeN((void*)eprop->item[a].identifier); + if(eprop->item[a].name) MEM_freeN((void*)eprop->item[a].name); + if(eprop->item[a].description) MEM_freeN((void*)eprop->item[a].description); + } + break; } case PROP_STRING: { StringPropertyRNA *sprop= (StringPropertyRNA*)prop; diff --git a/source/blender/makesrna/intern/rna_fcurve.c b/source/blender/makesrna/intern/rna_fcurve.c index ceef84b92df..fa6eea5f8a9 100644 --- a/source/blender/makesrna/intern/rna_fcurve.c +++ b/source/blender/makesrna/intern/rna_fcurve.c @@ -255,7 +255,7 @@ static void rna_def_fmodifier_envelope_ctrl(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Maximum Value", "Upper bound of envelope at this control-point."); /* Frame */ - prop= RNA_def_property(srna, "frame", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "frame", PROP_FLOAT, PROP_TIME); RNA_def_property_float_sdna(prop, NULL, "time"); RNA_def_property_ui_text(prop, "Frame", "Frame this control-point occurs on."); @@ -548,7 +548,7 @@ static void rna_def_fpoint(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Selected", "Selection status"); /* Vector value */ - prop= RNA_def_property(srna, "point", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "point", PROP_FLOAT, PROP_XYZ); RNA_def_property_array(prop, 2); RNA_def_property_float_sdna(prop, NULL, "vec"); RNA_def_property_ui_text(prop, "Point", "Point coordinates"); diff --git a/source/blender/makesrna/intern/rna_fluidsim.c b/source/blender/makesrna/intern/rna_fluidsim.c index ea4deae08e7..936e1700ed7 100644 --- a/source/blender/makesrna/intern/rna_fluidsim.c +++ b/source/blender/makesrna/intern/rna_fluidsim.c @@ -98,7 +98,7 @@ static void rna_FluidSettings_update_type(bContext *C, PointerRNA *ptr) part->type= PART_FLUID; psys->part= part; - psys->pointcache= BKE_ptcache_add(); + psys->pointcache= BKE_ptcache_add(&psys->ptcaches); psys->flag |= PSYS_ENABLED; BLI_addtail(&ob->particlesystem,psys); @@ -202,12 +202,12 @@ static void rna_def_fluidsim_domain(BlenderRNA *brna) RNA_def_property_range(prop, 1, 100); RNA_def_property_ui_text(prop, "Preview Resolution", "Preview resolution in X,Y and Z direction."); - prop= RNA_def_property(srna, "start_time", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "start_time", PROP_FLOAT, PROP_TIME); RNA_def_property_float_sdna(prop, NULL, "animStart"); RNA_def_property_range(prop, 0, 100); RNA_def_property_ui_text(prop, "Start Time", "Simulation time of the first blender frame."); - prop= RNA_def_property(srna, "end_time", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "end_time", PROP_FLOAT, PROP_TIME); RNA_def_property_float_sdna(prop, NULL, "animEnd"); RNA_def_property_range(prop, 0, 100); RNA_def_property_ui_text(prop, "End Time", "Simulation time of the last blender frame."); @@ -240,7 +240,7 @@ static void rna_def_fluidsim_domain(BlenderRNA *brna) /* advanced settings */ - prop= RNA_def_property(srna, "gravity", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "gravity", PROP_FLOAT, PROP_ACCELERATION); RNA_def_property_float_sdna(prop, NULL, "gravx"); RNA_def_property_array(prop, 3); RNA_def_property_range(prop, -1000.1, 1000.1); @@ -338,7 +338,7 @@ static void rna_def_fluidsim_fluid(BlenderRNA *brna) rna_def_fluidsim_volume(srna); - prop= RNA_def_property(srna, "initial_velocity", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "initial_velocity", PROP_FLOAT, PROP_VELOCITY); RNA_def_property_float_sdna(prop, NULL, "iniVelx"); RNA_def_property_array(prop, 3); RNA_def_property_range(prop, -1000.1, 1000.1); @@ -374,7 +374,7 @@ static void rna_def_fluidsim_inflow(BlenderRNA *brna) rna_def_fluidsim_volume(srna); - prop= RNA_def_property(srna, "inflow_velocity", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "inflow_velocity", PROP_FLOAT, PROP_VELOCITY); RNA_def_property_float_sdna(prop, NULL, "iniVelx"); RNA_def_property_array(prop, 3); RNA_def_property_range(prop, -1000.1, 1000.1); @@ -443,12 +443,12 @@ static void rna_def_fluidsim_control(BlenderRNA *brna) RNA_def_struct_sdna(srna, "FluidsimSettings"); RNA_def_struct_ui_text(srna, "Control Fluid Simulation Settings", "Fluid simulation settings for objects controlling the motion of fluid in the simulation."); - prop= RNA_def_property(srna, "start_time", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "start_time", PROP_FLOAT, PROP_TIME); RNA_def_property_float_sdna(prop, NULL, "cpsTimeStart"); RNA_def_property_range(prop, 0.0, 100.0); RNA_def_property_ui_text(prop, "Start Time", "Specifies time when the control particles are activated."); - prop= RNA_def_property(srna, "end_time", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "end_time", PROP_FLOAT, PROP_TIME); RNA_def_property_float_sdna(prop, NULL, "cpsTimeEnd"); RNA_def_property_range(prop, 0.0, 100.0); RNA_def_property_ui_text(prop, "End Time", "Specifies time when the control particles are deactivated."); diff --git a/source/blender/makesrna/intern/rna_group.c b/source/blender/makesrna/intern/rna_group.c index 1406ad1ae60..18c04fbfb50 100644 --- a/source/blender/makesrna/intern/rna_group.c +++ b/source/blender/makesrna/intern/rna_group.c @@ -52,7 +52,7 @@ void RNA_def_group(BlenderRNA *brna) RNA_def_struct_ui_text(srna, "Group", "Group of Object datablocks."); RNA_def_struct_ui_icon(srna, ICON_GROUP); - prop= RNA_def_property(srna, "dupli_offset", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "dupli_offset", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_float_sdna(prop, NULL, "dupli_ofs"); RNA_def_property_ui_text(prop, "Dupli Offset", "Offset from the center to use when instancing as DupliGroup."); RNA_def_property_ui_range(prop, -10000.0, 10000.0, 10, 4); diff --git a/source/blender/makesrna/intern/rna_image.c b/source/blender/makesrna/intern/rna_image.c index c74e46c17da..4d04f4ee1f3 100644 --- a/source/blender/makesrna/intern/rna_image.c +++ b/source/blender/makesrna/intern/rna_image.c @@ -93,7 +93,7 @@ static void rna_def_imageuser(BlenderRNA *brna) RNA_def_property_range(prop, -MAXFRAMEF, MAXFRAMEF); RNA_def_property_ui_text(prop, "Offset", "Offsets the number of the frame to use in the animation."); - prop= RNA_def_property(srna, "start_frame", PROP_INT, PROP_NONE); + prop= RNA_def_property(srna, "start_frame", PROP_INT, PROP_TIME); RNA_def_property_int_sdna(prop, NULL, "sfra"); RNA_def_property_range(prop, 1.0f, MAXFRAMEF); RNA_def_property_ui_text(prop, "Start Frame", "Sets the global starting frame of the movie."); @@ -219,7 +219,7 @@ static void rna_def_image(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Mapping", "Mapping type to use for this image in the game engine."); RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL); - prop= RNA_def_property(srna, "display_aspect", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "display_aspect", PROP_FLOAT, PROP_XYZ); RNA_def_property_float_sdna(prop, NULL, "aspx"); RNA_def_property_array(prop, 2); RNA_def_property_range(prop, 0.1f, 5000.0f); diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h index 99f527f8875..bd28085692f 100644 --- a/source/blender/makesrna/intern/rna_internal.h +++ b/source/blender/makesrna/intern/rna_internal.h @@ -181,6 +181,9 @@ struct StructRNA *rna_ID_refine(struct PointerRNA *ptr); struct IDProperty *rna_ID_idproperties(struct PointerRNA *ptr, int create); void rna_ID_fake_user_set(struct PointerRNA *ptr, int value); struct IDProperty *rna_IDPropertyGroup_idproperties(struct PointerRNA *ptr, int create); +void rna_IDPropertyGroup_unregister(const struct bContext *C, struct StructRNA *type); +struct StructRNA *rna_IDPropertyGroup_register(const struct bContext *C, struct ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free); +struct StructRNA* rna_IDPropertyGroup_refine(struct PointerRNA *ptr); void rna_object_vgroup_name_index_get(struct PointerRNA *ptr, char *value, int index); int rna_object_vgroup_name_index_length(struct PointerRNA *ptr, int index); @@ -194,9 +197,11 @@ void rna_Object_update_data(struct bContext *C, struct PointerRNA *ptr); /* API functions */ +void RNA_api_keyingset(struct StructRNA *srna); void RNA_api_main(struct StructRNA *srna); void RNA_api_mesh(struct StructRNA *srna); void RNA_api_object(struct StructRNA *srna); +void RNA_api_scene(struct StructRNA *srna); void RNA_api_ui_layout(struct StructRNA *srna); void RNA_api_wm(struct StructRNA *srna); @@ -259,6 +264,7 @@ void rna_iterator_array_end(struct CollectionPropertyIterator *iter); void rna_addtail(struct ListBase *listbase, void *vlink); void rna_freelinkN(struct ListBase *listbase, void *vlink); void rna_freelistN(struct ListBase *listbase); +PropertyDefRNA *rna_findlink(ListBase *listbase, const char *identifier); StructDefRNA *rna_find_struct_def(StructRNA *srna); FunctionDefRNA *rna_find_function_def(FunctionRNA *func); diff --git a/source/blender/makesrna/intern/rna_internal_types.h b/source/blender/makesrna/intern/rna_internal_types.h index 12bd876ce52..d706fd5ac19 100644 --- a/source/blender/makesrna/intern/rna_internal_types.h +++ b/source/blender/makesrna/intern/rna_internal_types.h @@ -40,6 +40,7 @@ struct IDProperty; struct GHash; #define RNA_MAX_ARRAY 32 +#define RNA_MAX_ARRAY_DIMENSION 3 /* Function Callbacks */ @@ -49,6 +50,8 @@ typedef struct IDProperty* (*IDPropertiesFunc)(struct PointerRNA *ptr, int creat typedef struct StructRNA *(*StructRefineFunc)(struct PointerRNA *ptr); typedef char *(*StructPathFunc)(struct PointerRNA *ptr); +typedef int (*PropArrayLengthGetFunc)(struct PointerRNA *ptr); +typedef int (*PropArrayLengthSetFunc)(struct PointerRNA *ptr, int length); typedef int (*PropBooleanGetFunc)(struct PointerRNA *ptr); typedef void (*PropBooleanSetFunc)(struct PointerRNA *ptr, int value); typedef void (*PropBooleanArrayGetFunc)(struct PointerRNA *ptr, int *values); @@ -131,6 +134,14 @@ struct PropertyRNA { PropertySubType subtype; /* if an array this is > 0, specifying the length */ unsigned int arraylength; + /* these, if non-NULL, override arraylength */ + PropArrayLengthGetFunc getlength; + /* if NULL, length cannot be changed by a user */ + PropArrayLengthSetFunc setlength; + /* used only for dynamic arrays for now, default 1 */ + unsigned short arraydimension; + /* dimension sizes for dimensions greater than 1, first dimension size is not specified */ + unsigned short dimsize[RNA_MAX_ARRAY_DIMENSION - 1]; /* callback for updates on change */ UpdateFunc update; diff --git a/source/blender/makesrna/intern/rna_key.c b/source/blender/makesrna/intern/rna_key.c index 216a1d05079..88047cda12b 100644 --- a/source/blender/makesrna/intern/rna_key.c +++ b/source/blender/makesrna/intern/rna_key.c @@ -282,7 +282,7 @@ static void rna_def_keydata(BlenderRNA *brna) srna= RNA_def_struct(brna, "ShapeKeyPoint", NULL); RNA_def_struct_ui_text(srna, "Shape Key Point", "Point in a shape key."); - prop= RNA_def_property(srna, "co", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "co", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_array(prop, 3); RNA_def_property_float_funcs(prop, "rna_ShapeKeyPoint_co_get", "rna_ShapeKeyPoint_co_set", NULL); RNA_def_property_ui_text(prop, "Location", ""); @@ -291,7 +291,7 @@ static void rna_def_keydata(BlenderRNA *brna) srna= RNA_def_struct(brna, "ShapeKeyCurvePoint", NULL); RNA_def_struct_ui_text(srna, "Shape Key Curve Point", "Point in a shape key for curves."); - prop= RNA_def_property(srna, "co", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "co", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_array(prop, 3); RNA_def_property_float_funcs(prop, "rna_ShapeKeyPoint_co_get", "rna_ShapeKeyPoint_co_set", NULL); RNA_def_property_ui_text(prop, "Location", ""); @@ -305,19 +305,19 @@ static void rna_def_keydata(BlenderRNA *brna) srna= RNA_def_struct(brna, "ShapeKeyBezierPoint", NULL); RNA_def_struct_ui_text(srna, "Shape Key Bezier Point", "Point in a shape key for bezier curves."); - prop= RNA_def_property(srna, "co", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "co", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_array(prop, 3); RNA_def_property_float_funcs(prop, "rna_ShapeKeyBezierPoint_co_get", "rna_ShapeKeyBezierPoint_co_set", NULL); RNA_def_property_ui_text(prop, "Location", ""); RNA_def_property_update(prop, 0, "rna_Key_update_data"); - prop= RNA_def_property(srna, "handle_1_co", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "handle_1_co", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_array(prop, 3); RNA_def_property_float_funcs(prop, "rna_ShapeKeyBezierPoint_handle_1_co_get", "rna_ShapeKeyBezierPoint_handle_1_co_set", NULL); RNA_def_property_ui_text(prop, "Handle 1 Location", ""); RNA_def_property_update(prop, 0, "rna_Key_update_data"); - prop= RNA_def_property(srna, "handle_2_co", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "handle_2_co", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_array(prop, 3); RNA_def_property_float_funcs(prop, "rna_ShapeKeyBezierPoint_handle_2_co_get", "rna_ShapeKeyBezierPoint_handle_2_co_set", NULL); RNA_def_property_ui_text(prop, "Handle 2 Location", ""); @@ -351,7 +351,7 @@ static void rna_def_keyblock(BlenderRNA *brna) RNA_def_struct_name_property(srna, prop); /* keys need to be sorted to edit this */ - prop= RNA_def_property(srna, "frame", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "frame", PROP_FLOAT, PROP_TIME); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_float_sdna(prop, NULL, "pos"); RNA_def_property_ui_text(prop, "Frame", "Frame for absolute keys."); diff --git a/source/blender/makesrna/intern/rna_lamp.c b/source/blender/makesrna/intern/rna_lamp.c index 299bd37496b..57aa1ba2736 100644 --- a/source/blender/makesrna/intern/rna_lamp.c +++ b/source/blender/makesrna/intern/rna_lamp.c @@ -151,13 +151,13 @@ static void rna_def_lamp_mtex(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Shadow", "Lets the texture affect the shadow color of the lamp."); RNA_def_property_update(prop, NC_TEXTURE, NULL); - prop= RNA_def_property(srna, "color_factor", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "color_factor", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "colfac"); RNA_def_property_ui_range(prop, 0, 1, 10, 3); RNA_def_property_ui_text(prop, "Color Factor", "Amount texture affects color values."); RNA_def_property_update(prop, NC_TEXTURE, NULL); - prop= RNA_def_property(srna, "shadow_factor", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "shadow_factor", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "colfac"); RNA_def_property_ui_range(prop, 0, 1, 10, 3); RNA_def_property_ui_text(prop, "Shadow Factor", "Amount texture affects shadow."); @@ -314,7 +314,7 @@ static void rna_def_lamp(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Type", "Type of Lamp."); RNA_def_property_update(prop, NC_LAMP|ND_LIGHTING_DRAW, NULL); - prop= RNA_def_property(srna, "distance", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "distance", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "dist"); RNA_def_property_ui_range(prop, 0, 1000, 1.0, 2); RNA_def_property_ui_text(prop, "Distance", "Falloff distance - the light is at half the original intensity at this point."); @@ -465,7 +465,7 @@ static void rna_def_lamp_shadow(StructRNA *srna, int spot, int area) RNA_def_property_ui_text(prop, "Shadow Adaptive Threshold", "Threshold for Adaptive Sampling (Raytraced shadows)."); RNA_def_property_update(prop, NC_LAMP|ND_LIGHTING, NULL); - prop= RNA_def_property(srna, "shadow_soft_size", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "shadow_soft_size", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "soft"); RNA_def_property_ui_range(prop, 0, 100, 0.1, 3); RNA_def_property_ui_text(prop, "Shadow Soft Size", "Light size for ray shadow sampling (Raytraced shadows)."); @@ -526,13 +526,13 @@ static void rna_def_area_lamp(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Shape", "Shape of the area lamp."); RNA_def_property_update(prop, NC_LAMP|ND_LIGHTING_DRAW, NULL); - prop= RNA_def_property(srna, "size", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "size", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "area_size"); RNA_def_property_ui_range(prop, 0, 100, 0.1, 3); RNA_def_property_ui_text(prop, "Size", "Size of the area of the area Lamp, X direction size for Rectangle shapes."); RNA_def_property_update(prop, NC_LAMP|ND_LIGHTING_DRAW, NULL); - prop= RNA_def_property(srna, "size_y", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "size_y", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "area_sizey"); RNA_def_property_ui_range(prop, 0, 100, 0.1, 3); RNA_def_property_ui_text(prop, "Size Y", "Size of the area of the area Lamp in the Y direction for Rectangle shapes."); @@ -628,13 +628,13 @@ static void rna_def_spot_lamp(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Spot Size", "Angle of the spotlight beam in degrees."); RNA_def_property_update(prop, NC_LAMP|ND_LIGHTING_DRAW, NULL); - prop= RNA_def_property(srna, "shadow_buffer_clip_start", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "shadow_buffer_clip_start", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "clipsta"); RNA_def_property_range(prop, 0.0f, 9999.0f); RNA_def_property_ui_text(prop, "Shadow Buffer Clip Start", "Shadow map clip start: objects closer will not generate shadows"); RNA_def_property_update(prop, NC_LAMP|ND_LIGHTING_DRAW, NULL); - prop= RNA_def_property(srna, "shadow_buffer_clip_end", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "shadow_buffer_clip_end", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "clipend"); RNA_def_property_range(prop, 0.0f, 9999.0f); RNA_def_property_ui_text(prop, "Shadow Buffer Clip End", "Shadow map clip end beyond which objects will not generate shadows."); diff --git a/source/blender/makesrna/intern/rna_lattice.c b/source/blender/makesrna/intern/rna_lattice.c index 03a1dc9ec8f..b53a0589ba6 100644 --- a/source/blender/makesrna/intern/rna_lattice.c +++ b/source/blender/makesrna/intern/rna_lattice.c @@ -178,13 +178,13 @@ static void rna_def_latticepoint(BlenderRNA *brna) RNA_def_struct_sdna(srna, "BPoint"); RNA_def_struct_ui_text(srna, "LatticePoint", "Point in the lattice grid."); - prop= RNA_def_property(srna, "co", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "co", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_array(prop, 3); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_float_funcs(prop, "rna_LatticePoint_co_get", NULL, NULL); RNA_def_property_ui_text(prop, "Location", ""); - prop= RNA_def_property(srna, "deformed_co", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "deformed_co", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_float_sdna(prop, NULL, "vec"); RNA_def_property_array(prop, 3); RNA_def_property_ui_text(prop, "Deformed Location", ""); diff --git a/source/blender/makesrna/intern/rna_main.c b/source/blender/makesrna/intern/rna_main.c index 26fc3c2941e..4a24027f7e9 100644 --- a/source/blender/makesrna/intern/rna_main.c +++ b/source/blender/makesrna/intern/rna_main.c @@ -220,34 +220,34 @@ void RNA_def_main(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; - const char *lists[][5]= { - {"cameras", "Camera", "rna_Main_camera_begin", "Cameras", "Camera datablocks."}, - {"scenes", "Scene", "rna_Main_scene_begin", "Scenes", "Scene datablocks."}, - {"objects", "Object", "rna_Main_object_begin", "Objects", "Object datablocks."}, - {"materials", "Material", "rna_Main_mat_begin", "Materials", "Material datablocks."}, - {"nodetrees", "NodeTree", "rna_Main_nodetree_begin", "Node Trees", "Nodetree datablocks."}, - {"meshes", "Mesh", "rna_Main_mesh_begin", "Meshes", "Mesh datablocks."}, - {"lamps", "Lamp", "rna_Main_lamp_begin", "Lamps", "Lamp datablocks."}, - {"libraries", "Library", "rna_Main_library_begin", "Libraries", "Library datablocks."}, - {"screens", "Screen", "rna_Main_screen_begin", "Screens", "Screen datablocks."}, - {"windowmanagers", "WindowManager", "rna_Main_wm_begin", "Window Managers", "Window manager datablocks."}, - {"images", "Image", "rna_Main_image_begin", "Images", "Image datablocks."}, - {"lattices", "Lattice", "rna_Main_latt_begin", "Lattices", "Lattice datablocks."}, - {"curves", "Curve", "rna_Main_curve_begin", "Curves", "Curve datablocks."}, - {"metaballs", "MetaBall", "rna_Main_mball_begin", "Metaballs", "Metaball datablocks."}, - {"vfonts", "VectorFont", "rna_Main_vfont_begin", "Vector Fonts", "Vector font datablocks."}, - {"textures", "Texture", "rna_Main_tex_begin", "Textures", "Texture datablocks."}, - {"brushes", "Brush", "rna_Main_brush_begin", "Brushes", "Brush datablocks."}, - {"worlds", "World", "rna_Main_world_begin", "Worlds", "World datablocks."}, - {"groups", "Group", "rna_Main_group_begin", "Groups", "Group datablocks."}, - {"keys", "ID", "rna_Main_key_begin", "Keys", "Key datablocks."}, - {"scripts", "ID", "rna_Main_script_begin", "Scripts", "Script datablocks."}, - {"texts", "Text", "rna_Main_text_begin", "Texts", "Text datablocks."}, - {"sounds", "ID", "rna_Main_sound_begin", "Sounds", "Sound datablocks."}, - {"armatures", "Armature", "rna_Main_armature_begin", "Armatures", "Armature datablocks."}, - {"actions", "Action", "rna_Main_action_begin", "Actions", "Action datablocks."}, - {"particles", "ParticleSettings", "rna_Main_particle_begin", "Particles", "Particle datablocks."}, - {NULL, NULL, NULL, NULL, NULL}}; + const char *lists[][7]= { + {"cameras", "Camera", "rna_Main_camera_begin", "Cameras", "Camera datablocks.", NULL, NULL}, + {"scenes", "Scene", "rna_Main_scene_begin", "Scenes", "Scene datablocks.", NULL, NULL}, + {"objects", "Object", "rna_Main_object_begin", "Objects", "Object datablocks.", NULL, NULL}, + {"materials", "Material", "rna_Main_mat_begin", "Materials", "Material datablocks.", NULL, NULL}, + {"nodegroups", "NodeTree", "rna_Main_nodetree_begin", "Node Groups", "Node group datablocks.", NULL, NULL}, + {"meshes", "Mesh", "rna_Main_mesh_begin", "Meshes", "Mesh datablocks.", "add_mesh", "remove_mesh"}, + {"lamps", "Lamp", "rna_Main_lamp_begin", "Lamps", "Lamp datablocks.", NULL, NULL}, + {"libraries", "Library", "rna_Main_library_begin", "Libraries", "Library datablocks.", NULL, NULL}, + {"screens", "Screen", "rna_Main_screen_begin", "Screens", "Screen datablocks.", NULL, NULL}, + {"windowmanagers", "WindowManager", "rna_Main_wm_begin", "Window Managers", "Window manager datablocks.", NULL, NULL}, + {"images", "Image", "rna_Main_image_begin", "Images", "Image datablocks.", NULL, NULL}, + {"lattices", "Lattice", "rna_Main_latt_begin", "Lattices", "Lattice datablocks.", NULL, NULL}, + {"curves", "Curve", "rna_Main_curve_begin", "Curves", "Curve datablocks.", NULL, NULL} , + {"metaballs", "MetaBall", "rna_Main_mball_begin", "Metaballs", "Metaball datablocks.", NULL, NULL}, + {"vfonts", "VectorFont", "rna_Main_vfont_begin", "Vector Fonts", "Vector font datablocks.", NULL, NULL}, + {"textures", "Texture", "rna_Main_tex_begin", "Textures", "Texture datablocks.", NULL, NULL}, + {"brushes", "Brush", "rna_Main_brush_begin", "Brushes", "Brush datablocks.", NULL, NULL}, + {"worlds", "World", "rna_Main_world_begin", "Worlds", "World datablocks.", NULL, NULL}, + {"groups", "Group", "rna_Main_group_begin", "Groups", "Group datablocks.", NULL, NULL}, + {"keys", "ID", "rna_Main_key_begin", "Keys", "Key datablocks.", NULL, NULL}, + {"scripts", "ID", "rna_Main_script_begin", "Scripts", "Script datablocks.", NULL, NULL}, + {"texts", "Text", "rna_Main_text_begin", "Texts", "Text datablocks.", NULL, NULL}, + {"sounds", "ID", "rna_Main_sound_begin", "Sounds", "Sound datablocks.", NULL, NULL}, + {"armatures", "Armature", "rna_Main_armature_begin", "Armatures", "Armature datablocks.", NULL, NULL}, + {"actions", "Action", "rna_Main_action_begin", "Actions", "Action datablocks.", NULL, NULL}, + {"particles", "ParticleSettings", "rna_Main_particle_begin", "Particles", "Particle datablocks.", NULL, NULL}, + {NULL, NULL, NULL, NULL, NULL, NULL, NULL}}; int i; srna= RNA_def_struct(brna, "Main", NULL); @@ -264,7 +264,7 @@ void RNA_def_main(BlenderRNA *brna) { prop= RNA_def_property(srna, lists[i][0], PROP_COLLECTION, PROP_NONE); RNA_def_property_struct_type(prop, lists[i][1]); - RNA_def_property_collection_funcs(prop, lists[i][2], "rna_iterator_listbase_next", "rna_iterator_listbase_end", "rna_iterator_listbase_get", 0, 0, 0, 0, 0); + RNA_def_property_collection_funcs(prop, lists[i][2], "rna_iterator_listbase_next", "rna_iterator_listbase_end", "rna_iterator_listbase_get", 0, 0, 0, lists[i][5], lists[i][6]); RNA_def_property_ui_text(prop, lists[i][3], lists[i][4]); } diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c index 87efe6c39c0..cde65f46e5c 100644 --- a/source/blender/makesrna/intern/rna_material.c +++ b/source/blender/makesrna/intern/rna_material.c @@ -41,6 +41,8 @@ #include "BKE_texture.h" +#include "ED_node.h" + static PointerRNA rna_Material_mirror_get(PointerRNA *ptr) { return rna_pointer_inherit_refine(ptr, &RNA_MaterialRaytraceMirror, ptr->id.data); @@ -66,6 +68,11 @@ static PointerRNA rna_Material_strand_get(PointerRNA *ptr) return rna_pointer_inherit_refine(ptr, &RNA_MaterialStrand, ptr->id.data); } +static PointerRNA rna_Material_physics_get(PointerRNA *ptr) +{ + return rna_pointer_inherit_refine(ptr, &RNA_MaterialPhysics, ptr->id.data); +} + static void rna_Material_type_set(PointerRNA *ptr, int value) { Material *ma= (Material*)ptr->data; @@ -191,6 +198,15 @@ static void rna_Material_use_specular_ramp_set(PointerRNA *ptr, int value) ma->ramp_spec= add_colorband(0); } +void rna_Material_use_nodes_set(PointerRNA *ptr, int value) +{ + Material *ma= (Material*)ptr->data; + + ma->use_nodes= value; + if(ma->use_nodes && ma->nodetree==NULL) + ED_node_shader_default(ma); +} + #else static void rna_def_material_mtex(BlenderRNA *brna) @@ -403,7 +419,7 @@ static void rna_def_material_mtex(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Specular Color Factor", "Amount texture affects specular color."); RNA_def_property_update(prop, NC_TEXTURE, NULL); - prop= RNA_def_property(srna, "colordiff_factor", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "colordiff_factor", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "colfac"); RNA_def_property_ui_range(prop, 0, 1, 10, 3); RNA_def_property_ui_text(prop, "Diffuse Color Factor", "Amount texture affects diffuse color."); @@ -463,6 +479,75 @@ static void rna_def_material_mtex(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Ambient Factor", "Amount texture affects ambient."); RNA_def_property_update(prop, NC_TEXTURE, NULL); + /* volume material */ + prop= RNA_def_property(srna, "map_coloremission", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_EMISSION_COL); + RNA_def_property_ui_text(prop, "Emission Color", "Causes the texture to affect the colour of emission"); + RNA_def_property_update(prop, NC_TEXTURE, NULL); + + prop= RNA_def_property(srna, "map_colorabsorption", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_ABSORPTION_COL); + RNA_def_property_ui_text(prop, "Absorption Color", "Causes the texture to affect the result colour after absorption"); + RNA_def_property_update(prop, NC_TEXTURE, NULL); + + prop= RNA_def_property(srna, "map_density", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_DENSITY); + RNA_def_property_ui_text(prop, "Density", "Causes the texture to affect the volume's density"); + RNA_def_property_update(prop, NC_TEXTURE, NULL); + + prop= RNA_def_property(srna, "map_emission", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_EMISSION); + RNA_def_property_ui_text(prop, "Emission", "Causes the texture to affect the volume's emission"); + RNA_def_property_update(prop, NC_TEXTURE, NULL); + + prop= RNA_def_property(srna, "map_absorption", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_ABSORPTION); + RNA_def_property_ui_text(prop, "Absorption", "Causes the texture to affect the volume's absorption"); + RNA_def_property_update(prop, NC_TEXTURE, NULL); + + prop= RNA_def_property(srna, "map_scattering", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_SCATTERING); + RNA_def_property_ui_text(prop, "Scattering", "Causes the texture to affect the volume's scattering"); + RNA_def_property_update(prop, NC_TEXTURE, NULL); + + prop= RNA_def_property(srna, "coloremission_factor", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "colfac"); + RNA_def_property_ui_range(prop, 0, 1, 10, 3); + RNA_def_property_ui_text(prop, "Emission Color Factor", "Amount texture affects emission color."); + RNA_def_property_update(prop, NC_TEXTURE, NULL); + + prop= RNA_def_property(srna, "colorabsorption_factor", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "colfac"); + RNA_def_property_ui_range(prop, 0, 1, 10, 3); + RNA_def_property_ui_text(prop, "Absorpion Color Factor", "Amount texture affects diffuse color."); + RNA_def_property_update(prop, NC_TEXTURE, NULL); + + prop= RNA_def_property(srna, "density_factor", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "varfac"); + RNA_def_property_ui_range(prop, 0, 1, 10, 3); + RNA_def_property_ui_text(prop, "Density Factor", "Amount texture affects density."); + RNA_def_property_update(prop, NC_TEXTURE, NULL); + + prop= RNA_def_property(srna, "emission_factor", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "varfac"); + RNA_def_property_ui_range(prop, 0, 1, 10, 3); + RNA_def_property_ui_text(prop, "Emission Factor", "Amount texture affects emission."); + RNA_def_property_update(prop, NC_TEXTURE, NULL); + + prop= RNA_def_property(srna, "absorption_factor", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "varfac"); + RNA_def_property_ui_range(prop, 0, 1, 10, 3); + RNA_def_property_ui_text(prop, "Absorption Factor", "Amount texture affects absorption."); + RNA_def_property_update(prop, NC_TEXTURE, NULL); + + prop= RNA_def_property(srna, "scattering_factor", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "varfac"); + RNA_def_property_ui_range(prop, 0, 1, 10, 3); + RNA_def_property_ui_text(prop, "Scattering Factor", "Amount texture affects scattering."); + RNA_def_property_update(prop, NC_TEXTURE, NULL); + + /* end volume material */ + prop= RNA_def_property(srna, "enabled", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_funcs(prop, "rna_MaterialTextureSlot_enabled_get", "rna_MaterialTextureSlot_enabled_set"); RNA_def_property_ui_text(prop, "Enabled", "Enable this material texture slot."); @@ -522,10 +607,16 @@ static void rna_def_material_colors(StructRNA *srna) RNA_def_property_ui_text(prop, "Mirror Color", "Mirror color of the material."); RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); - prop= RNA_def_property(srna, "alpha", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "alpha", PROP_FLOAT, PROP_PERCENTAGE); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Alpha", "Alpha transparency of the material."); RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING_DRAW, NULL); + + prop= RNA_def_property(srna, "specular_alpha", PROP_FLOAT, PROP_PERCENTAGE); + RNA_def_property_float_sdna(prop, NULL, "spectra"); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_ui_text(prop, "Specular Alpha", "Alpha transparency for specular areas."); + RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); /* Color bands */ prop= RNA_def_property(srna, "use_diffuse_ramp", PROP_BOOLEAN, PROP_NONE); @@ -594,7 +685,7 @@ static void rna_def_material_diffuse(StructRNA *srna) RNA_def_property_ui_text(prop, "Diffuse Shader Model", ""); RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); - prop= RNA_def_property(srna, "diffuse_reflection", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "diffuse_reflection", PROP_FLOAT, PROP_PERCENTAGE); RNA_def_property_float_sdna(prop, NULL, "ref"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Diffuse Reflection", "Amount of diffuse reflection."); @@ -611,7 +702,7 @@ static void rna_def_material_diffuse(StructRNA *srna) RNA_def_property_ui_text(prop, "Diffuse Toon Size", "Size of diffuse toon area."); RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); - prop= RNA_def_property(srna, "diffuse_toon_smooth", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "diffuse_toon_smooth", PROP_FLOAT, PROP_PERCENTAGE); RNA_def_property_float_sdna(prop, NULL, "param[1]"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Diffuse Toon Smooth", "Smoothness of diffuse toon area."); @@ -655,7 +746,7 @@ static void rna_def_material_raymirror(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Enabled", "Enable raytraced reflections."); RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); - prop= RNA_def_property(srna, "reflect", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "reflect", PROP_FLOAT, PROP_PERCENTAGE); RNA_def_property_float_sdna(prop, NULL, "ray_mirror"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Reflect", "Sets the amount mirror reflection for raytrace."); @@ -667,19 +758,19 @@ static void rna_def_material_raymirror(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Fresnel", "Power of Fresnel for mirror reflection."); RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); - prop= RNA_def_property(srna, "fresnel_fac", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "fresnel_factor", PROP_FLOAT, PROP_PERCENTAGE); RNA_def_property_float_sdna(prop, NULL, "fresnel_mir_i"); RNA_def_property_range(prop, 0.0f, 5.0f); RNA_def_property_ui_text(prop, "Fresnel Factor", "Blending factor for Fresnel."); RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); - prop= RNA_def_property(srna, "gloss", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "gloss", PROP_FLOAT, PROP_PERCENTAGE); RNA_def_property_float_sdna(prop, NULL, "gloss_mir"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Gloss", "The shininess of the reflection. Values < 1.0 give diffuse, blurry reflections."); RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); - prop= RNA_def_property(srna, "gloss_anisotropic", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "gloss_anisotropic", PROP_FLOAT, PROP_PERCENTAGE); RNA_def_property_float_sdna(prop, NULL, "aniso_gloss_mir"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Gloss Anisotropy", "The shape of the reflection, from 0.0 (circular) to 1.0 (fully stretched along the tangent."); @@ -691,7 +782,7 @@ static void rna_def_material_raymirror(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Gloss Samples", "Number of cone samples averaged for blurry reflections."); RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); - prop= RNA_def_property(srna, "gloss_threshold", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "gloss_threshold", PROP_FLOAT, PROP_PERCENTAGE); RNA_def_property_float_sdna(prop, NULL, "adapt_thresh_mir"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Gloss Threshold", "Threshold for adaptive sampling. If a sample contributes less than this amount (as a percentage), sampling is stopped."); @@ -703,7 +794,7 @@ static void rna_def_material_raymirror(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Depth", "Maximum allowed number of light inter-reflections."); RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); - prop= RNA_def_property(srna, "distance", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "distance", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "dist_mir"); RNA_def_property_range(prop, 0.0f, 10000.0f); RNA_def_property_ui_text(prop, "Maximum Distance", "Maximum distance of reflected rays. Reflections further than this range fade to sky color or material color."); @@ -726,11 +817,6 @@ static void rna_def_material_raytra(BlenderRNA *brna) RNA_def_struct_nested(brna, srna, "Material"); RNA_def_struct_ui_text(srna, "Material Raytrace Transparency", "Raytraced refraction settings for a Material datablock."); - prop= RNA_def_property(srna, "enabled", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_RAYTRANSP); /* use bitflags */ - RNA_def_property_ui_text(prop, "Enabled", "Enables raytracing for transparent refraction rendering."); - RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); - prop= RNA_def_property(srna, "ior", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "ang"); RNA_def_property_range(prop, 1.0f, 3.0f); @@ -743,13 +829,13 @@ static void rna_def_material_raytra(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Fresnel", "Power of Fresnel for transparency (Ray or ZTransp)."); RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); - prop= RNA_def_property(srna, "fresnel_fac", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "fresnel_factor", PROP_FLOAT, PROP_PERCENTAGE); RNA_def_property_float_sdna(prop, NULL, "fresnel_tra_i"); RNA_def_property_range(prop, 1.0f, 5.0f); RNA_def_property_ui_text(prop, "Fresnel Factor", "Blending factor for Fresnel."); RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); - prop= RNA_def_property(srna, "gloss", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "gloss", PROP_FLOAT, PROP_PERCENTAGE); RNA_def_property_float_sdna(prop, NULL, "gloss_tra"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Gloss", "The clarity of the refraction. Values < 1.0 give diffuse, blurry refractions."); @@ -761,7 +847,7 @@ static void rna_def_material_raytra(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Gloss Samples", "Number of cone samples averaged for blurry refractions."); RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); - prop= RNA_def_property(srna, "gloss_threshold", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "gloss_threshold", PROP_FLOAT, PROP_PERCENTAGE); RNA_def_property_float_sdna(prop, NULL, "adapt_thresh_tra"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Gloss Threshold", "Threshold for adaptive sampling. If a sample contributes less than this amount (as a percentage), sampling is stopped."); @@ -773,13 +859,13 @@ static void rna_def_material_raytra(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Depth", "Maximum allowed number of light inter-refractions."); RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); - prop= RNA_def_property(srna, "filter", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "filter", PROP_FLOAT, PROP_PERCENTAGE); RNA_def_property_float_sdna(prop, NULL, "filter"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Filter", "Amount to blend in the material's diffuse color in raytraced transparency (simulating absorption)."); RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); - prop= RNA_def_property(srna, "limit", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "limit", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "tx_limit"); RNA_def_property_range(prop, 0.0f, 100.0f); RNA_def_property_ui_text(prop, "Limit", "Maximum depth for light to travel through the transparent material before becoming fully filtered (0.0 is disabled)."); @@ -790,14 +876,161 @@ static void rna_def_material_raytra(BlenderRNA *brna) RNA_def_property_range(prop, 0.1f, 10.0f); RNA_def_property_ui_text(prop, "Falloff", "Falloff power for transmissivity filter effect (1.0 is linear)."); RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); +} + +static void rna_def_material_volume(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + static EnumPropertyItem prop_scattering_items[] = { + {MA_VOL_SHADE_NONE, "NONE", 0, "None", ""}, + {MA_VOL_SHADE_SINGLE, "SINGLE_SCATTERING", 0, "Single Scattering", ""}, + {MA_VOL_SHADE_MULTIPLE, "MULTIPLE_SCATTERING", 0, "Multiple Scattering", ""}, + {MA_VOL_SHADE_SINGLEPLUSMULTIPLE, "SINGLE_PLUS_MULTIPLE_SCATTERING", 0, "Single + Multiple Scattering", ""}, + {0, NULL, 0, NULL, NULL}}; + + static EnumPropertyItem prop_stepsize_items[] = { + {MA_VOL_STEP_RANDOMIZED, "RANDOMIZED", 0, "Randomized", ""}, + {MA_VOL_STEP_CONSTANT, "CONSTANT", 0, "Constant", ""}, + //{MA_VOL_STEP_ADAPTIVE, "ADAPTIVE", 0, "Adaptive", ""}, + {0, NULL, 0, NULL, NULL}}; + + static EnumPropertyItem prop_phasefunction_items[] = { + {MA_VOL_PH_ISOTROPIC, "ISOTROPIC", 0, "Isotropic", ""}, + {MA_VOL_PH_MIEHAZY, "MIE_HAZY", 0, "Mie Hazy", ""}, + {MA_VOL_PH_MIEMURKY, "MIE_MURKY", 0, "Mie Murky", ""}, + {MA_VOL_PH_RAYLEIGH, "RAYLEIGH", 0, "Rayleigh", ""}, + {MA_VOL_PH_HG, "HENYEY-GREENSTEIN", 0, "Henyey-Greenstein", ""}, + {MA_VOL_PH_SCHLICK, "SCHLICK", 0, "Schlick", ""}, + {0, NULL, 0, NULL, NULL}}; + + srna= RNA_def_struct(brna, "MaterialVolume", NULL); + RNA_def_struct_sdna(srna, "VolumeSettings"); + RNA_def_struct_nested(brna, srna, "Material"); + RNA_def_struct_ui_text(srna, "Material Volume", "Volume rendering settings for a Material datablock."); - prop= RNA_def_property(srna, "specular_opacity", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "spectra"); + prop= RNA_def_property(srna, "step_calculation", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "stepsize_type"); + RNA_def_property_enum_items(prop, prop_stepsize_items); + RNA_def_property_ui_text(prop, "Step Calculation", "Method of calculating the steps through the volume"); + RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); + + prop= RNA_def_property(srna, "step_size", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "stepsize"); + RNA_def_property_range(prop, 0.0f, FLT_MAX); + RNA_def_property_ui_range(prop, 0.0f, 1.0f, 1, 3); + RNA_def_property_ui_text(prop, "Step Size", "Distance between subsequent volume depth samples."); + RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); + + prop= RNA_def_property(srna, "shading_step_size", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "shade_stepsize"); + RNA_def_property_range(prop, 0.0f, FLT_MAX); + RNA_def_property_ui_range(prop, 0.0f, 1.0f, 1, 3); + RNA_def_property_ui_text(prop, "Shading Step Size", "Distance between subsequent volume shading samples."); + RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); + + prop= RNA_def_property(srna, "scattering_mode", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "shade_type"); + RNA_def_property_enum_items(prop, prop_scattering_items); + RNA_def_property_ui_text(prop, "Scattering Mode", "Method of shading, attenuating, and scattering light through the volume"); + RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); + + prop= RNA_def_property(srna, "light_cache", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "shadeflag", MA_VOL_PRECACHESHADING); /* use bitflags */ + RNA_def_property_ui_text(prop, "Light Cache", "Pre-calculate the shading information into a voxel grid, speeds up shading at slightly less accuracy"); + RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); + + prop= RNA_def_property(srna, "cache_resolution", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "precache_resolution"); + RNA_def_property_range(prop, 0, 1024); + RNA_def_property_ui_text(prop, "Resolution", "Resolution of the voxel grid, low resolutions are faster, high resolutions use more memory."); + RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); + + prop= RNA_def_property(srna, "ms_diffusion", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "ms_diff"); + RNA_def_property_range(prop, 0.0f, FLT_MAX); + RNA_def_property_ui_text(prop, "Diffusion", "Diffusion factor, the strength of the blurring effect"); + RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); + + prop= RNA_def_property(srna, "ms_spread", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "ms_steps"); + RNA_def_property_range(prop, 0, 1024); + RNA_def_property_ui_text(prop, "Spread", "Simulation steps, the effective distance over which the light is diffused"); + RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); + + prop= RNA_def_property(srna, "ms_intensity", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "ms_intensity"); + RNA_def_property_range(prop, 0.0f, FLT_MAX); + RNA_def_property_ui_text(prop, "Intensity", "Multiplier for multiple scattered light energy"); + RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); + + prop= RNA_def_property(srna, "depth_cutoff", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "depth_cutoff"); RNA_def_property_range(prop, 0.0f, 1.0f); - RNA_def_property_ui_text(prop, "Specular Opacity", "Makes specular areas opaque on transparent materials."); + RNA_def_property_ui_text(prop, "Depth Cutoff", "Stop ray marching early if transmission drops below this luminance - higher values give speedups in dense volumes at the expense of accuracy."); + RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); + + prop= RNA_def_property(srna, "density", PROP_FLOAT, PROP_PERCENTAGE); + RNA_def_property_float_sdna(prop, NULL, "density"); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_ui_text(prop, "Density", "The base density of the volume"); + RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); + + prop= RNA_def_property(srna, "density_scale", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "density_scale"); + RNA_def_property_range(prop, 0.0f, FLT_MAX); + RNA_def_property_ui_range(prop, 0.0f, 10.0f, 1, 3); + RNA_def_property_ui_text(prop, "Density Scale", "Multiplier for the material's density"); + RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); + + prop= RNA_def_property(srna, "absorption", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "absorption"); + RNA_def_property_range(prop, 0.0f, FLT_MAX); + RNA_def_property_ui_range(prop, 0.0f, 10.0f, 1, 3); + RNA_def_property_ui_text(prop, "Absorption", "Amount of light that gets absorbed by the volume - higher values mean light travels less distance"); + RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); + + prop= RNA_def_property(srna, "absorption_color", PROP_FLOAT, PROP_COLOR); + RNA_def_property_float_sdna(prop, NULL, "absorption_col"); + RNA_def_property_array(prop, 3); + RNA_def_property_ui_text(prop, "Absorption Color", ""); + RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING_DRAW, NULL); + + prop= RNA_def_property(srna, "scattering", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "scattering"); + RNA_def_property_range(prop, 0.0f, FLT_MAX); + RNA_def_property_ui_range(prop, 0.0f, 10.0f, 1 ,3); + RNA_def_property_ui_text(prop, "Scattering", "Amount of light that gets scattered by the volume - values > 1.0 are non-physical"); + RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); + + prop= RNA_def_property(srna, "emission", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "emission"); + RNA_def_property_range(prop, 0.0f, FLT_MAX); + RNA_def_property_ui_range(prop, 0.0f, 10.0f, 1, 3); + RNA_def_property_ui_text(prop, "Emission", "Amount of light that gets emitted by the volume"); + RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); + + prop= RNA_def_property(srna, "emission_color", PROP_FLOAT, PROP_COLOR); + RNA_def_property_float_sdna(prop, NULL, "emission_col"); + RNA_def_property_array(prop, 3); + RNA_def_property_ui_text(prop, "Emission Color", ""); + RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING_DRAW, NULL); + + prop= RNA_def_property(srna, "phase_function", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "phasefunc_type"); + RNA_def_property_enum_items(prop, prop_phasefunction_items); + RNA_def_property_ui_text(prop, "Phase Function", "Isotropic/Anisotropic scattering"); + RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); + + prop= RNA_def_property(srna, "asymmetry", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "phasefunc_g"); + RNA_def_property_range(prop, -1.0f, 1.0f); + RNA_def_property_ui_text(prop, "Asymmetry", "Continuum between forward scattering and back scattering"); RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); } + static void rna_def_material_halo(BlenderRNA *brna) { StructRNA *srna; @@ -820,7 +1053,7 @@ static void rna_def_material_halo(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Hardness", "Sets the hardness of the halo."); RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); - prop= RNA_def_property(srna, "add", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "add", PROP_FLOAT, PROP_PERCENTAGE); RNA_def_property_float_sdna(prop, NULL, "add"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Add", "Sets the strength of the add effect."); @@ -936,7 +1169,7 @@ static void rna_def_material_sss(BlenderRNA *brna) RNA_def_struct_nested(brna, srna, "Material"); RNA_def_struct_ui_text(srna, "Material Subsurface Scattering", "Diffuse subsurface scattering settings for a Material datablock."); - prop= RNA_def_property(srna, "radius", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "radius", PROP_FLOAT, PROP_RGB|PROP_UNIT_LENGTH); RNA_def_property_float_sdna(prop, NULL, "sss_radius"); RNA_def_property_range(prop, 0.001, FLT_MAX); RNA_def_property_ui_range(prop, 0.001, 10000, 1, 3); @@ -966,13 +1199,13 @@ static void rna_def_material_sss(BlenderRNA *brna) RNA_def_property_ui_text(prop, "IOR", "Index of refraction (higher values are denser)."); RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); - prop= RNA_def_property(srna, "color_factor", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "color_factor", PROP_FLOAT, PROP_PERCENTAGE); RNA_def_property_float_sdna(prop, NULL, "sss_colfac"); RNA_def_property_ui_range(prop, 0, 1, 10, 3); RNA_def_property_ui_text(prop, "Color Factor", "Blend factor for SSS colors."); RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); - prop= RNA_def_property(srna, "texture_factor", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "texture_factor", PROP_FLOAT, PROP_PERCENTAGE); RNA_def_property_float_sdna(prop, NULL, "sss_texfac"); RNA_def_property_ui_range(prop, 0, 1, 10, 3); RNA_def_property_ui_text(prop, "Texture Factor", "Texture scatting blend factor."); @@ -1014,7 +1247,7 @@ void rna_def_material_specularity(StructRNA *srna) RNA_def_property_ui_text(prop, "Specular Shader Model", ""); RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); - prop= RNA_def_property(srna, "specular_reflection", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "specular_reflection", PROP_FLOAT, PROP_PERCENTAGE); RNA_def_property_float_sdna(prop, NULL, "spec"); RNA_def_property_range(prop, 0, 1); RNA_def_property_ui_text(prop, "Specularity Intensity", ""); @@ -1043,7 +1276,7 @@ void rna_def_material_specularity(StructRNA *srna) RNA_def_property_ui_text(prop, "Specular Toon Size", "Size of specular toon area."); RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); - prop= RNA_def_property(srna, "specular_toon_smooth", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "specular_toon_smooth", PROP_FLOAT, PROP_PERCENTAGE); RNA_def_property_float_sdna(prop, NULL, "param[3]"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Specular Toon Smooth", "Ssmoothness of specular toon area."); @@ -1076,10 +1309,10 @@ void rna_def_material_strand(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Surface Diffuse", "Make diffuse shading more similar to shading the surface."); RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); - prop= RNA_def_property(srna, "blend_distance", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "blend_distance", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "strand_surfnor"); RNA_def_property_range(prop, 0, 10); - RNA_def_property_ui_text(prop, "Blend Distance", "Distance in Blender units over which to blend in the surface normal."); + RNA_def_property_ui_text(prop, "Blend Distance", "Worldspace distance over which to blend in the surface normal."); RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); prop= RNA_def_property(srna, "blender_units", PROP_BOOLEAN, PROP_NONE); @@ -1123,6 +1356,46 @@ void rna_def_material_strand(BlenderRNA *brna) RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); } +void rna_def_material_physics(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna= RNA_def_struct(brna, "MaterialPhysics", NULL); + RNA_def_struct_sdna(srna, "Material"); + RNA_def_struct_nested(brna, srna, "Material"); + RNA_def_struct_ui_text(srna, "Material Physics", "Physics settings for a Material datablock."); + + prop= RNA_def_property(srna, "align_to_normal", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_FH_NOR); + RNA_def_property_ui_text(prop, "Align to Normal", "Align dynamic game objects along the surface normal, when inside the physics distance area"); + + prop= RNA_def_property(srna, "friction", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "friction"); + RNA_def_property_range(prop, 0, 100); + RNA_def_property_ui_text(prop, "Friction", "Coulomb friction coeffecient, when inside the physics distance area"); + + prop= RNA_def_property(srna, "force", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "fh"); + RNA_def_property_range(prop, 0, 1); + RNA_def_property_ui_text(prop, "Force", "Upward spring force, when inside the physics distance area"); + + prop= RNA_def_property(srna, "elasticity", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "reflect"); + RNA_def_property_range(prop, 0, 1); + RNA_def_property_ui_text(prop, "Elasticity", "Elasticity of collisions"); + + prop= RNA_def_property(srna, "distance", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "fhdist"); + RNA_def_property_range(prop, 0, 20); + RNA_def_property_ui_text(prop, "Distance", "Distance of the physics area"); + + prop= RNA_def_property(srna, "damp", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "xyfrict"); + RNA_def_property_range(prop, 0, 1); + RNA_def_property_ui_text(prop, "Damping", "Damping of the spring force, when inside the physics distance area"); +} + void RNA_def_material(BlenderRNA *brna) { StructRNA *srna; @@ -1131,9 +1404,13 @@ void RNA_def_material(BlenderRNA *brna) static EnumPropertyItem prop_type_items[] = { {MA_TYPE_SURFACE, "SURFACE", 0, "Surface", "Render object as a surface."}, {MA_TYPE_WIRE, "WIRE", 0, "Wire", "Render the edges of faces as wires (not supported in ray tracing)."}, - // {MA_TYPE_VOLUME, "VOLUME", 0, "Volume", "Render object as a volume."}, + {MA_TYPE_VOLUME, "VOLUME", 0, "Volume", "Render object as a volume."}, {MA_TYPE_HALO, "HALO", 0, "Halo", "Render object as halo particles."}, {0, NULL, 0, NULL, NULL}}; + static EnumPropertyItem transparency_items[] = { + {MA_ZTRANSP, "Z_TRANSPARENCY", 0, "Z Transparency", "Use alpha buffer for transparent faces."}, + {MA_RAYTRANSP, "RAYTRACE", 0, "Raytrace", "Use raytracing for transparent refraction rendering."}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "Material", "ID"); RNA_def_struct_ui_text(srna, "Material", "Material datablock to defined the appearance of geometric objects for rendering."); @@ -1145,19 +1422,31 @@ void RNA_def_material(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Type", "Material type defining how the object is rendered."); RNA_def_property_enum_funcs(prop, NULL, "rna_Material_type_set", NULL); RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING_DRAW, NULL); + + prop= RNA_def_property(srna, "transparency", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_TRANSP); + RNA_def_property_ui_text(prop, "Transparency", "Render material as transparent."); + RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); + + prop= RNA_def_property(srna, "transparency_method", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_bitflag_sdna(prop, NULL, "mode"); + RNA_def_property_enum_items(prop, transparency_items); + RNA_def_property_ui_text(prop, "Transparency Method", "Method to use for rendering transparency."); + RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); - prop= RNA_def_property(srna, "ambient", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "ambient", PROP_FLOAT, PROP_PERCENTAGE); RNA_def_property_float_sdna(prop, NULL, "amb"); RNA_def_property_range(prop, 0, 1); RNA_def_property_ui_text(prop, "Ambient", "Amount of global ambient color the material receives."); RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); prop= RNA_def_property(srna, "emit", PROP_FLOAT, PROP_NONE); - RNA_def_property_range(prop, 0, 2); + RNA_def_property_range(prop, 0, FLT_MAX); + RNA_def_property_ui_range(prop, 0, 2.0f, 10, 2); RNA_def_property_ui_text(prop, "Emit", "Amount of light to emit."); RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); - prop= RNA_def_property(srna, "translucency", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "translucency", PROP_FLOAT, PROP_PERCENTAGE); RNA_def_property_range(prop, 0, 1); RNA_def_property_ui_text(prop, "Translucency", "Amount of diffuse shading on the back side."); RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); @@ -1182,7 +1471,7 @@ void RNA_def_material(BlenderRNA *brna) RNA_def_property_range(prop, 0, 10); RNA_def_property_ui_text(prop, "Shadow Buffer Bias", "Factor to multiply shadow buffer bias with (0 is ignore.)"); - prop= RNA_def_property(srna, "shadow_casting_alpha", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "shadow_casting_alpha", PROP_FLOAT, PROP_PERCENTAGE); RNA_def_property_float_sdna(prop, NULL, "shad_alpha"); RNA_def_property_range(prop, 0.001, 1); RNA_def_property_ui_text(prop, "Shadow Casting Alpha", "Shadow casting alpha, only in use for Irregular Shadowbuffer."); @@ -1217,11 +1506,6 @@ void RNA_def_material(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Shadeless", "Makes this material insensitive to light or shadow."); RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); - prop= RNA_def_property(srna, "z_transparency", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_ZTRA); - RNA_def_property_ui_text(prop, "Z Transparency", "Enable alpha buffer for transparent faces."); - RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); - prop= RNA_def_property(srna, "vertex_color_light", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_VERTEXCOL); RNA_def_property_ui_text(prop, "Vertex Color Light", "Add vertex colors as additional lighting."); @@ -1267,11 +1551,6 @@ void RNA_def_material(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Exclude Mist", "Excludes this material from mist effects (in world settings)"); RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); - prop= RNA_def_property(srna, "radiosity", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_RADIO); - RNA_def_property_ui_text(prop, "Radiosity", "Include this material in radiosity calculations"); - RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); - prop= RNA_def_property(srna, "transparent_shadows", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_SHADOW_TRA); RNA_def_property_ui_text(prop, "Transparent Shadows", "Allow this object to receive transparent shadows casted through other objects"); @@ -1308,6 +1587,11 @@ void RNA_def_material(BlenderRNA *brna) RNA_def_property_pointer_funcs(prop, "rna_Material_transp_get", NULL, NULL); RNA_def_property_ui_text(prop, "Raytrace Transparency", "Raytraced reflection settings for the material."); + prop= RNA_def_property(srna, "volume", PROP_POINTER, PROP_NEVER_NULL); + RNA_def_property_pointer_sdna(prop, NULL, "vol"); + RNA_def_property_struct_type(prop, "MaterialVolume"); + RNA_def_property_ui_text(prop, "Volume", "Volume settings for the material."); + prop= RNA_def_property(srna, "halo", PROP_POINTER, PROP_NEVER_NULL); RNA_def_property_struct_type(prop, "MaterialHalo"); RNA_def_property_pointer_funcs(prop, "rna_Material_halo_get", NULL, NULL); @@ -1322,12 +1606,23 @@ void RNA_def_material(BlenderRNA *brna) RNA_def_property_struct_type(prop, "MaterialStrand"); RNA_def_property_pointer_funcs(prop, "rna_Material_strand_get", NULL, NULL); RNA_def_property_ui_text(prop, "Strand", "Strand settings for the material."); + + prop= RNA_def_property(srna, "physics", PROP_POINTER, PROP_NEVER_NULL); + RNA_def_property_struct_type(prop, "MaterialPhysics"); + RNA_def_property_pointer_funcs(prop, "rna_Material_physics_get", NULL, NULL); + RNA_def_property_ui_text(prop, "Physics", "Game physics settings."); /* nodetree */ prop= RNA_def_property(srna, "node_tree", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "nodetree"); RNA_def_property_ui_text(prop, "Node Tree", "Node tree for node based materials."); + prop= RNA_def_property(srna, "use_nodes", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "use_nodes", 1); + RNA_def_property_boolean_funcs(prop, NULL, "rna_Material_use_nodes_set"); + RNA_def_property_ui_text(prop, "Use Nodes", "Use shader nodes to render the material."); + RNA_def_property_update(prop, NC_MATERIAL, NULL); + /* common */ rna_def_animdata_common(srna); rna_def_mtex_common(srna, "rna_Material_mtex_begin", "rna_Material_active_texture_get", @@ -1340,10 +1635,12 @@ void RNA_def_material(BlenderRNA *brna) /* nested structs */ rna_def_material_raymirror(brna); rna_def_material_raytra(brna); + rna_def_material_volume(brna); rna_def_material_halo(brna); rna_def_material_sss(brna); rna_def_material_mtex(brna); rna_def_material_strand(brna); + rna_def_material_physics(brna); } void rna_def_mtex_common(StructRNA *srna, const char *begin, const char *activeget, const char *activeset, const char *structname) diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c index 24050eb5085..914291a259b 100644 --- a/source/blender/makesrna/intern/rna_mesh.c +++ b/source/blender/makesrna/intern/rna_mesh.c @@ -10,7 +10,7 @@ * * 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 + * 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 @@ -360,6 +360,55 @@ static void rna_MeshTextureFace_uv1_set(PointerRNA *ptr, const float *values) mloopuv->uv[1] = values[1]; } +static int rna_CustomDataData_numverts(PointerRNA *ptr, int type) +{ + /*BMESH_TODO + Mesh *me= (Mesh*)ptr->id.data; + CustomData *fdata= rna_mesh_fdata(me); + CustomDataLayer *cdl; + int a; + size_t b; + + for(cdl=fdata->layers, a=0; a<fdata->totlayer; cdl++, a++) { + if(cdl->type == type) { + b= ((char*)ptr->data - ((char*)cdl->data))/CustomData_sizeof(type); + if(b >= 0 && b < me->totface) + return (me->mface[b].v4? 4: 3); + } + } + + return 0;*/ + return 0; +} + +static int rna_MeshTextureFace_uv_get_length(PointerRNA *ptr) +{ + //return rna_CustomDataData_numverts(ptr, CD_MTFACE) * 2; + return 0; //BMESH_TODO +} + +static int rna_MeshTextureFace_uv_set_length(PointerRNA *ptr, int length) +{ + //return length == rna_MeshTextureFace_uv_get_length(ptr); + return 0; //BMESH_TODO +} + +static void rna_MeshTextureFace_uv_get(PointerRNA *ptr, float *values) +{ + //MTFace *mtface= (MTFace*)ptr->data; + //int totvert= rna_CustomDataData_numverts(ptr, CD_MTFACE); + + //memcpy(values, mtface->uv, totvert * 2 * sizeof(float)); +} + +static void rna_MeshTextureFace_uv_set(PointerRNA *ptr, const float *values) +{ + //MTFace *mtface= (MTFace*)ptr->data; + //int totvert= rna_CustomDataData_numverts(ptr, CD_MTFACE); + + //memcpy(mtface->uv, values, totvert * 2 * sizeof(float)); +} + static void rna_MeshTextureFaceLayer_data_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) { Mesh *me= (Mesh*)ptr->id.data; @@ -622,6 +671,40 @@ static void rna_TextureFace_image_set(PointerRNA *ptr, PointerRNA value) tf->tpage= (struct Image*)id; } +static int rna_MeshFace_verts_get_length(PointerRNA *ptr) +{ + MFace *face= (MFace*)ptr->data; + return face->v4 ? 4 : 3; +} + +static int rna_MeshFace_verts_set_length(PointerRNA *ptr, int length) +{ + MFace *face= (MFace*)ptr->data; + if (length == 3) { + face->v4= 0; + } + else if(length == 4) { + face->v4= 1; + } + else + return 0; + + return 1; +} + +static void rna_MeshFace_verts_get(PointerRNA *ptr, int *values) +{ + MFace *face= (MFace*)ptr->data; + int verts[4] = {face->v1, face->v2, face->v3, face->v4}; + memcpy(values, verts, (face->v4 ? 4 : 3) * sizeof(int)); +} + +static void rna_MeshFace_verts_set(PointerRNA *ptr, const int *values) +{ + MFace *face= (MFace*)ptr->data; + memcpy(&face->v1, values, (face->v4 ? 4 : 3) * sizeof(int)); +} + /* path construction */ static char *rna_VertexGroupElement_path(PointerRNA *ptr) @@ -764,10 +847,10 @@ static void rna_def_mvert(BlenderRNA *brna) RNA_def_struct_path_func(srna, "rna_MeshVertex_path"); RNA_def_struct_ui_icon(srna, ICON_VERTEXSEL); - prop= RNA_def_property(srna, "co", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "co", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_ui_text(prop, "Location", ""); - prop= RNA_def_property(srna, "normal", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "normal", PROP_FLOAT, PROP_DIRECTION); RNA_def_property_float_sdna(prop, NULL, "no"); RNA_def_property_float_funcs(prop, "rna_MeshVertex_normal_get", NULL, NULL); RNA_def_property_ui_text(prop, "Normal", "Vertex Normal"); @@ -844,11 +927,21 @@ static void rna_def_mface(BlenderRNA *brna) RNA_def_struct_path_func(srna, "rna_MeshFace_path"); RNA_def_struct_ui_icon(srna, ICON_FACESEL); + /* + // XXX allows creating invalid meshes prop= RNA_def_property(srna, "verts", PROP_INT, PROP_UNSIGNED); RNA_def_property_int_sdna(prop, NULL, "v1"); RNA_def_property_array(prop, 4); RNA_def_property_ui_text(prop, "Vertices", "Vertex indices"); + */ + // XXX allows creating invalid meshes + prop= RNA_def_property(srna, "verts", PROP_INT, PROP_UNSIGNED); + RNA_def_property_array(prop, 4); + RNA_def_property_flag(prop, PROP_DYNAMIC); + RNA_def_property_dynamic_array_funcs(prop, "rna_MeshFace_verts_get_length", "rna_MeshFace_verts_set_length"); + RNA_def_property_int_funcs(prop, "rna_MeshFace_verts_get", "rna_MeshFace_verts_set", NULL); + RNA_def_property_ui_text(prop, "Vertices", "Vertex indices"); prop= RNA_def_property(srna, "material_index", PROP_INT, PROP_UNSIGNED); RNA_def_property_int_sdna(prop, NULL, "mat_nr"); @@ -867,7 +960,7 @@ static void rna_def_mface(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "flag", ME_SMOOTH); RNA_def_property_ui_text(prop, "Smooth", ""); - prop= RNA_def_property(srna, "normal", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "normal", PROP_FLOAT, PROP_DIRECTION); RNA_def_property_array(prop, 3); RNA_def_property_range(prop, -1.0f, 1.0f); RNA_def_property_clear_flag(prop, PROP_EDITABLE); @@ -885,6 +978,7 @@ static void rna_def_mtexpoly(BlenderRNA *brna) {TF_ALPHA, "ALPHA", 0, "Alpha", "Render polygon transparent, depending on alpha channel of the texture"}, {TF_CLIP, "CLIPALPHA", 0, "Clip Alpha", "Use the images alpha values clipped with no blending (binary alpha)"}, {0, NULL, 0, NULL, NULL}}; + unsigned short uv_dim[1]= {2}; srna= RNA_def_struct(brna, "MeshTextureFaceLayer", NULL); RNA_def_struct_ui_text(srna, "Mesh Texture Face Layer", "Layer of texture faces in a Mesh datablock."); @@ -983,6 +1077,13 @@ static void rna_def_mtexpoly(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "unwrap", TF_PIN1); RNA_def_property_array(prop, 4); RNA_def_property_ui_text(prop, "UV Pinned", ""); + + prop= RNA_def_property(srna, "uv", PROP_FLOAT, PROP_XYZ); + RNA_def_property_multidimensional_array(prop, 4 * 2, 2, uv_dim); + RNA_def_property_flag(prop, PROP_DYNAMIC); + RNA_def_property_dynamic_array_funcs(prop, "rna_MeshTextureFace_uv_get_length", "rna_MeshTextureFace_uv_set_length"); + RNA_def_property_float_funcs(prop, "rna_MeshTextureFace_uv_get", "rna_MeshTextureFace_uv_set", NULL); + RNA_def_property_ui_text(prop, "UV", ""); } static void rna_def_msticky(BlenderRNA *brna) @@ -995,7 +1096,7 @@ static void rna_def_msticky(BlenderRNA *brna) RNA_def_struct_ui_text(srna, "Mesh Vertex Sticky Texture Coordinate", "Stricky texture coordinate."); RNA_def_struct_path_func(srna, "rna_MeshSticky_path"); - prop= RNA_def_property(srna, "co", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "co", PROP_FLOAT, PROP_XYZ); RNA_def_property_ui_text(prop, "Location", "Sticky texture coordinate location."); } @@ -1111,18 +1212,18 @@ void rna_def_texmat_common(StructRNA *srna, const char *texspace_editable) 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."); - prop= RNA_def_property(srna, "texspace_loc", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "texspace_loc", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_float_sdna(prop, NULL, "loc"); RNA_def_property_ui_text(prop, "Texure Space Location", "Texture space location."); RNA_def_property_editable_func(prop, texspace_editable); - prop= RNA_def_property(srna, "texspace_size", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "texspace_size", PROP_FLOAT, PROP_XYZ); RNA_def_property_float_sdna(prop, NULL, "size"); RNA_def_property_ui_text(prop, "Texture Space Size", "Texture space size."); RNA_def_property_editable_func(prop, texspace_editable); /* not supported yet - prop= RNA_def_property(srna, "texspace_rot", PROP_FLOAT, PROP_ROTATION); + prop= RNA_def_property(srna, "texspace_rot", PROP_FLOAT, PROP_EULER); RNA_def_property_float(prop, NULL, "rot"); RNA_def_property_ui_text(prop, "Texture Space Rotation", "Texture space rotation"); RNA_def_property_editable_func(prop, texspace_editable);*/ @@ -1248,6 +1349,64 @@ static void rna_def_mesh(BlenderRNA *brna) RNA_def_property_pointer_sdna(prop, NULL, "key"); RNA_def_property_ui_text(prop, "Shape Keys", ""); + /* Mesh Draw Options for Edit Mode*/ + + prop= RNA_def_property(srna, "draw_edges", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "drawflag", ME_DRAWEDGES); + RNA_def_property_ui_text(prop, "Draw Edges", "Displays selected edges using hilights in the 3d view and UV editor"); + RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); + + prop= RNA_def_property(srna, "draw_faces", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "drawflag", ME_DRAWFACES); + RNA_def_property_ui_text(prop, "Draw Faces", "Displays all faces as shades in the 3d view and UV editor"); + RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); + + prop= RNA_def_property(srna, "draw_normals", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "drawflag", ME_DRAWNORMALS); + RNA_def_property_ui_text(prop, "Draw Normals", "Displays face normals as lines"); + RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); + + prop= RNA_def_property(srna, "draw_vertex_normals", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "drawflag", ME_DRAW_VNORMALS); + RNA_def_property_ui_text(prop, "Draw Vertex Normals", "Displays vertex normals as lines"); + RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); + + prop= RNA_def_property(srna, "draw_creases", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "drawflag", ME_DRAWCREASES); + RNA_def_property_ui_text(prop, "Draw Creases", "Displays creases created for subsurf weighting"); + RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); + + prop= RNA_def_property(srna, "draw_bevel_weights", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "drawflag", ME_DRAWBWEIGHTS); + RNA_def_property_ui_text(prop, "Draw Bevel Weights", "Displays weights created for the Bevel modifier"); + RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); + + prop= RNA_def_property(srna, "draw_seams", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "drawflag", ME_DRAWSEAMS); + RNA_def_property_ui_text(prop, "Draw Seams", "Displays UV unwrapping seams"); + RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); + + prop= RNA_def_property(srna, "draw_sharp", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "drawflag", ME_DRAWSHARP); + RNA_def_property_ui_text(prop, "Draw Sharp", "Displays sharp edges, used with the EdgeSplit modifier"); + RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); + + + prop= RNA_def_property(srna, "draw_edge_lenght", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "drawflag", ME_DRAW_EDGELEN); + RNA_def_property_ui_text(prop, "Edge Length", "Displays selected edge lengths"); + RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); + + prop= RNA_def_property(srna, "draw_edge_angle", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "drawflag", ME_DRAW_EDGEANG); + RNA_def_property_ui_text(prop, "Edge Angles", "Displays the angles in the selected edges in degrees"); + RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); + + prop= RNA_def_property(srna, "draw_face_area", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "drawflag", ME_DRAW_FACEAREA); + RNA_def_property_ui_text(prop, "Face Area", "Displays the area of selected faces"); + RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); + rna_def_texmat_common(srna, "rna_Mesh_texspace_editable"); RNA_api_mesh(srna); diff --git a/source/blender/makesrna/intern/rna_meta.c b/source/blender/makesrna/intern/rna_meta.c index e142bc4b2aa..7b14a7a4712 100644 --- a/source/blender/makesrna/intern/rna_meta.c +++ b/source/blender/makesrna/intern/rna_meta.c @@ -39,6 +39,7 @@ #include "BKE_mball.h" #include "BKE_depsgraph.h" +#include "BKE_main.h" #include "WM_types.h" #include "WM_api.h" @@ -51,29 +52,19 @@ static int rna_Meta_texspace_editable(PointerRNA *ptr) static void rna_MetaBall_update_data(bContext *C, PointerRNA *ptr) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); - Object *active_object = CTX_data_active_object(C); - Object *obedit= CTX_data_edit_object(C); - - if(obedit) { - copy_mball_properties(scene, obedit); - WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, obedit); - DAG_object_flush_update(scene, obedit, OB_RECALC_DATA); + MetaBall *mb= ptr->id.data; + Object *ob; + + for(ob=bmain->object.first; ob; ob= ob->id.next) { + if(ob->data == mb) { + copy_mball_properties(scene, ob); + /* XXX this will loop over all objects again (slow) */ + DAG_object_flush_update(scene, ob, OB_RECALC_DATA); + WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, ob); + } } - else if(active_object) { - copy_mball_properties(scene, active_object); - WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, active_object); - DAG_object_flush_update(scene, active_object, OB_RECALC_DATA); - } -} - -static void rna_MetaElem_update_data(bContext *C, PointerRNA *ptr) -{ - Scene *scene= CTX_data_scene(C); - Object *obedit= CTX_data_edit_object(C); - - WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, obedit); - DAG_object_flush_update(scene, obedit, OB_RECALC_DATA); } #else @@ -99,59 +90,59 @@ void rna_def_metaelement(BlenderRNA *brna) prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, prop_type_items); RNA_def_property_ui_text(prop, "Type", "Metaball types."); - RNA_def_property_update(prop, 0, "rna_MetaElem_update_data"); + RNA_def_property_update(prop, 0, "rna_MetaBall_update_data"); /* number values */ - prop= RNA_def_property(srna, "location", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "location", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_float_sdna(prop, NULL, "x"); RNA_def_property_array(prop, 3); RNA_def_property_ui_text(prop, "Location", ""); - RNA_def_property_update(prop, 0, "rna_MetaElem_update_data"); + RNA_def_property_update(prop, 0, "rna_MetaBall_update_data"); - prop= RNA_def_property(srna, "rotation", PROP_FLOAT, PROP_ROTATION); + prop= RNA_def_property(srna, "rotation", PROP_FLOAT, PROP_QUATERNION); RNA_def_property_float_sdna(prop, NULL, "quat"); RNA_def_property_ui_text(prop, "Rotation", ""); - RNA_def_property_update(prop, 0, "rna_MetaElem_update_data"); + RNA_def_property_update(prop, 0, "rna_MetaBall_update_data"); - prop= RNA_def_property(srna, "radius", PROP_FLOAT, PROP_UNSIGNED); + prop= RNA_def_property(srna, "radius", PROP_FLOAT, PROP_UNSIGNED|PROP_UNIT_LENGTH); RNA_def_property_float_sdna(prop, NULL, "rad"); RNA_def_property_ui_text(prop, "Radius", ""); - RNA_def_property_update(prop, 0, "rna_MetaElem_update_data"); + RNA_def_property_update(prop, 0, "rna_MetaBall_update_data"); - prop= RNA_def_property(srna, "sizex", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "size_x", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "expx"); RNA_def_property_range(prop, 0.0f, 20.0f); RNA_def_property_ui_text(prop, "Size X", "Size of element, use of components depends on element type."); - RNA_def_property_update(prop, 0, "rna_MetaElem_update_data"); + RNA_def_property_update(prop, 0, "rna_MetaBall_update_data"); - prop= RNA_def_property(srna, "sizey", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "size_y", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "expy"); RNA_def_property_range(prop, 0.0f, 20.0f); RNA_def_property_ui_text(prop, "Size Y", "Size of element, use of components depends on element type."); - RNA_def_property_update(prop, 0, "rna_MetaElem_update_data"); + RNA_def_property_update(prop, 0, "rna_MetaBall_update_data"); - prop= RNA_def_property(srna, "sizez", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "size_z", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "expz"); RNA_def_property_range(prop, 0.0f, 20.0f); RNA_def_property_ui_text(prop, "Size Z", "Size of element, use of components depends on element type."); - RNA_def_property_update(prop, 0, "rna_MetaElem_update_data"); + RNA_def_property_update(prop, 0, "rna_MetaBall_update_data"); prop= RNA_def_property(srna, "stiffness", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "s"); RNA_def_property_range(prop, 0.0f, 10.0f); RNA_def_property_ui_text(prop, "Stiffness", "Stiffness defines how much of the element to fill."); - RNA_def_property_update(prop, 0, "rna_MetaElem_update_data"); + RNA_def_property_update(prop, 0, "rna_MetaBall_update_data"); /* flags */ prop= RNA_def_property(srna, "negative", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", MB_NEGATIVE); RNA_def_property_ui_text(prop, "Negative", "Set metaball as negative one."); - RNA_def_property_update(prop, 0, "rna_MetaElem_update_data"); + RNA_def_property_update(prop, 0, "rna_MetaBall_update_data"); prop= RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", MB_HIDE); RNA_def_property_ui_text(prop, "Hide", "Hide element."); - RNA_def_property_update(prop, 0, "rna_MetaElem_update_data"); + RNA_def_property_update(prop, 0, "rna_MetaBall_update_data"); } void rna_def_metaball(BlenderRNA *brna) @@ -174,7 +165,7 @@ void rna_def_metaball(BlenderRNA *brna) RNA_def_property_struct_type(prop, "MetaElement"); RNA_def_property_ui_text(prop, "Elements", "Meta elements."); - prop= RNA_def_property(srna, "last_selected_element", PROP_POINTER, PROP_NONE); + prop= RNA_def_property(srna, "active_element", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "lastelem"); RNA_def_property_ui_text(prop, "Last selected element.", "Last selected element."); @@ -185,13 +176,13 @@ void rna_def_metaball(BlenderRNA *brna) RNA_def_property_update(prop, 0, "rna_MetaBall_update_data"); /* number values */ - prop= RNA_def_property(srna, "wire_size", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "wire_size", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "wiresize"); RNA_def_property_range(prop, 0.050f, 1.0f); RNA_def_property_ui_text(prop, "Wire Size", "Polygonization resolution in the 3D viewport."); RNA_def_property_update(prop, 0, "rna_MetaBall_update_data"); - prop= RNA_def_property(srna, "render_size", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "render_size", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "rendersize"); RNA_def_property_range(prop, 0.050f, 1.0f); RNA_def_property_ui_text(prop, "Render Size", "Polygonization resolution in rendering."); diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index 9771e83468b..bb073d19a46 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -43,40 +43,42 @@ #include "WM_types.h" EnumPropertyItem modifier_type_items[] ={ - {eModifierType_Armature, "ARMATURE", ICON_MOD_ARMATURE, "Armature", ""}, + {0, "", 0, "Generate", ""}, {eModifierType_Array, "ARRAY", ICON_MOD_ARRAY, "Array", ""}, {eModifierType_Bevel, "BEVEL", ICON_MOD_BEVEL, "Bevel", ""}, {eModifierType_Boolean, "BOOLEAN", ICON_MOD_BOOLEAN, "Boolean", ""}, {eModifierType_Build, "BUILD", ICON_MOD_BUILD, "Build", ""}, + {eModifierType_Decimate, "DECIMATE", ICON_MOD_DECIM, "Decimate", ""}, + {eModifierType_EdgeSplit, "EDGE_SPLIT", ICON_MOD_EDGESPLIT, "Edge Split", ""}, + {eModifierType_Mask, "MASK", ICON_MOD_MASK, "Mask", ""}, + {eModifierType_Mirror, "MIRROR", ICON_MOD_MIRROR, "Mirror", ""}, + {eModifierType_Multires, "MULTIRES", ICON_MOD_MULTIRES, "Multiresolution", ""}, + {eModifierType_Subsurf, "SUBSURF", ICON_MOD_SUBSURF, "Subdivision Surface", ""}, + {eModifierType_UVProject, "UV_PROJECT", ICON_MOD_UVPROJECT, "UV Project", ""}, + {0, "", 0, "Deform", ""}, + {eModifierType_Armature, "ARMATURE", ICON_MOD_ARMATURE, "Armature", ""}, {eModifierType_Cast, "CAST", ICON_MOD_CAST, "Cast", ""}, - {eModifierType_Cloth, "CLOTH", ICON_MOD_CLOTH, "Cloth", ""}, - {eModifierType_Collision, "COLLISION", ICON_MOD_PHYSICS, "Collision", ""}, {eModifierType_Curve, "CURVE", ICON_MOD_CURVE, "Curve", ""}, - {eModifierType_Decimate, "DECIMATE", ICON_MOD_DECIM, "Decimate", ""}, {eModifierType_Displace, "DISPLACE", ICON_MOD_DISPLACE, "Displace", ""}, - {eModifierType_EdgeSplit, "EDGE_SPLIT", ICON_MOD_EDGESPLIT, "Edge Split", ""}, - {eModifierType_Explode, "EXPLODE", ICON_MOD_EXPLODE, "Explode", ""}, - {eModifierType_Fluidsim, "FLUID_SIMULATION", ICON_MOD_FLUIDSIM, "Fluid Simulation", ""}, {eModifierType_Hook, "HOOK", ICON_HOOK, "Hook", ""}, {eModifierType_Lattice, "LATTICE", ICON_MOD_LATTICE, "Lattice", ""}, - {eModifierType_Mask, "MASK", ICON_MOD_MASK, "Mask", ""}, {eModifierType_MeshDeform, "MESH_DEFORM", ICON_MOD_MESHDEFORM, "Mesh Deform", ""}, - {eModifierType_Mirror, "MIRROR", ICON_MOD_MIRROR, "Mirror", ""}, - {eModifierType_Multires, "MULTIRES", ICON_MOD_MULTIRES, "Multiresolution", ""}, - {eModifierType_ParticleInstance, "PARTICLE_INSTANCE", ICON_MOD_PARTICLES, "Particle Instance", ""}, - {eModifierType_ParticleSystem, "PARTICLE_SYSTEM", ICON_MOD_PARTICLES, "Particle System", ""}, {eModifierType_Shrinkwrap, "SHRINKWRAP", ICON_MOD_SHRINKWRAP, "Shrinkwrap", ""}, {eModifierType_SimpleDeform, "SIMPLE_DEFORM", ICON_MOD_SIMPLEDEFORM, "Simple Deform", ""}, - {eModifierType_Smoke, "SMOKE", 0, "Smoke", ""}, {eModifierType_Smooth, "SMOOTH", ICON_MOD_SMOOTH, "Smooth", ""}, - {eModifierType_Softbody, "SOFTBODY", ICON_MOD_SOFT, "Soft Body", ""}, - {eModifierType_Subsurf, "SUBSURF", ICON_MOD_SUBSURF, "Subdivision Surface", ""}, - {eModifierType_Surface, "SURFACE", ICON_MOD_PHYSICS, "Surface", ""}, - {eModifierType_UVProject, "UV_PROJECT", ICON_MOD_UVPROJECT, "UV Project", ""}, {eModifierType_Wave, "WAVE", ICON_MOD_WAVE, "Wave", ""}, + {0, "", 0, "Physics", ""}, + {eModifierType_Cloth, "CLOTH", ICON_MOD_CLOTH, "Cloth", ""}, + {eModifierType_Collision, "COLLISION", ICON_MOD_PHYSICS, "Collision", ""}, + {eModifierType_Explode, "EXPLODE", ICON_MOD_EXPLODE, "Explode", ""}, + {eModifierType_Fluidsim, "FLUID_SIMULATION", ICON_MOD_FLUIDSIM, "Fluid Simulation", ""}, + {eModifierType_ParticleInstance, "PARTICLE_INSTANCE", ICON_MOD_PARTICLES, "Particle Instance", ""}, + {eModifierType_ParticleSystem, "PARTICLE_SYSTEM", ICON_MOD_PARTICLES, "Particle System", ""}, + {eModifierType_Smoke, "SMOKE", 0, "Smoke", ""}, + {eModifierType_Softbody, "SOFT_BODY", ICON_MOD_SOFT, "Soft Body", ""}, + {eModifierType_Surface, "SURFACE", ICON_MOD_PHYSICS, "Surface", ""}, {0, NULL, 0, NULL, NULL}}; - #ifdef RNA_RUNTIME #include "BKE_context.h" @@ -86,7 +88,7 @@ EnumPropertyItem modifier_type_items[] ={ static void rna_UVProject_projectors_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) { UVProjectModifierData *uvp= (UVProjectModifierData*)ptr->data; - rna_iterator_array_begin(iter, (void*)uvp->projectors, sizeof(Object*), 10, 0, NULL); + rna_iterator_array_begin(iter, (void*)uvp->projectors, sizeof(Object*), uvp->num_projectors, 0, NULL); } static StructRNA* rna_Modifier_refine(struct PointerRNA *ptr) @@ -181,13 +183,15 @@ static void rna_Smoke_set_type(bContext *C, PointerRNA *ptr) { SmokeModifierData *smd= (SmokeModifierData *)ptr->data; Object *ob= (Object*)ptr->id.data; + + // nothing changed + if((smd->type & MOD_SMOKE_TYPE_DOMAIN) && smd->domain) + return; smokeModifier_free(smd); // XXX TODO: completely free all 3 pointers smokeModifier_createType(smd); // create regarding of selected type - // particle_system_slot_add_exec(C, NULL); - // particle_system_slot_remove_exec(C, NULL); - if(smd->type == MOD_SMOKE_TYPE_DOMAIN) + if(smd->type & MOD_SMOKE_TYPE_DOMAIN) ob->dt = OB_WIRE; // update dependancy since a domain - other type switch could have happened @@ -396,6 +400,34 @@ static PointerRNA rna_CollisionModifier_settings_get(PointerRNA *ptr) return rna_pointer_inherit_refine(ptr, &RNA_CollisionSettings, ob->pd); } +static PointerRNA rna_UVProjector_object_get(PointerRNA *ptr) +{ + Object **ob= (Object**)ptr->data; + return rna_pointer_inherit_refine(ptr, &RNA_Object, *ob); +} + +static void rna_UVProjector_object_set(PointerRNA *ptr, PointerRNA value) +{ + Object **ob= (Object**)ptr->data; + + if(*ob) + id_us_min((ID*)*ob); + if(value.data) + id_us_plus((ID*)value.data); + + *ob= value.data; +} + +static void rna_UVProjectModifier_num_projectors_set(PointerRNA *ptr, int value) +{ + UVProjectModifierData *md= (UVProjectModifierData*)ptr->data; + int a; + + md->num_projectors= CLAMPIS(value, 1, MOD_UVPROJECT_MAX); + for(a=md->num_projectors; a<MOD_UVPROJECT_MAX; a++) + md->projectors[a]= NULL; +} + #else static void rna_def_property_subdivision_common(StructRNA *srna, const char type[]) @@ -538,12 +570,12 @@ static void rna_def_modifier_build(BlenderRNA *brna) RNA_def_struct_sdna(srna, "BuildModifierData"); RNA_def_struct_ui_icon(srna, ICON_MOD_BUILD); - prop= RNA_def_property(srna, "start", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "start", PROP_FLOAT, PROP_TIME); RNA_def_property_range(prop, MINAFRAMEF, MAXFRAMEF); RNA_def_property_ui_text(prop, "Start", "Specify the start frame of the effect."); RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); - prop= RNA_def_property(srna, "length", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "length", PROP_FLOAT, PROP_TIME); RNA_def_property_range(prop, 1, MAXFRAMEF); RNA_def_property_ui_text(prop, "Length", "Specify the total time the build effect requires"); RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); @@ -697,32 +729,32 @@ static void rna_def_modifier_wave(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Time Offset", "Either the starting frame (for positive speed) or ending frame (for negative speed.)"); RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); - prop= RNA_def_property(srna, "lifetime", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "lifetime", PROP_FLOAT, PROP_TIME); RNA_def_property_range(prop, MINAFRAMEF, MAXFRAMEF); RNA_def_property_ui_text(prop, "Lifetime", ""); RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); - prop= RNA_def_property(srna, "damping_time", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "damping_time", PROP_FLOAT, PROP_TIME); RNA_def_property_float_sdna(prop, NULL, "damp"); RNA_def_property_range(prop, MINAFRAMEF, MAXFRAMEF); RNA_def_property_ui_text(prop, "Damping Time", ""); RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); - prop= RNA_def_property(srna, "falloff_radius", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "falloff_radius", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "falloff"); RNA_def_property_range(prop, 0, FLT_MAX); RNA_def_property_ui_range(prop, 0, 100, 100, 2); RNA_def_property_ui_text(prop, "Falloff Radius", ""); RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); - prop= RNA_def_property(srna, "start_position_x", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "start_position_x", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "startx"); RNA_def_property_range(prop, -FLT_MAX, FLT_MAX); RNA_def_property_ui_range(prop, -100, 100, 100, 2); RNA_def_property_ui_text(prop, "Start Position X", ""); RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); - prop= RNA_def_property(srna, "start_position_y", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "start_position_y", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "starty"); RNA_def_property_range(prop, -FLT_MAX, FLT_MAX); RNA_def_property_ui_range(prop, -100, 100, 100, 2); @@ -853,7 +885,7 @@ static void rna_def_modifier_hook(BlenderRNA *brna) RNA_def_struct_sdna(srna, "HookModifierData"); RNA_def_struct_ui_icon(srna, ICON_HOOK); - prop= RNA_def_property(srna, "falloff", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "falloff", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_range(prop, 0, FLT_MAX); RNA_def_property_ui_range(prop, 0, 100, 100, 2); RNA_def_property_ui_text(prop, "Falloff", "If not zero, the distance from the hook where influence ends."); @@ -868,6 +900,11 @@ static void rna_def_modifier_hook(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Object", "Parent Object for hook, also recalculates and clears offset"); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_dependency_update"); + + prop= RNA_def_property(srna, "subtarget", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "subtarget"); + RNA_def_property_ui_text(prop, "Sub-Target", "Name of Parent Bone for hook (if applicable), also recalculates and clears offset"); + RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_dependency_update"); prop= RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "name"); @@ -953,7 +990,7 @@ static void rna_def_modifier_array(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Count", "Number of duplicates to make."); RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); - prop= RNA_def_property(srna, "length", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "length", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_range(prop, 0, INT_MAX); RNA_def_property_ui_range(prop, 0, 10000, 10, 2); RNA_def_property_ui_text(prop, "Length", "Length to fit array within."); @@ -967,22 +1004,22 @@ static void rna_def_modifier_array(BlenderRNA *brna) RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_dependency_update"); /* Offset parameters */ - prop= RNA_def_property(srna, "constant_offset", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "constant_offset", PROP_BOOLEAN, PROP_TRANSLATION); RNA_def_property_boolean_sdna(prop, NULL, "offset_type", MOD_ARR_OFF_CONST); RNA_def_property_ui_text(prop, "Constant Offset", ""); RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); - prop= RNA_def_property(srna, "constant_offset_displacement", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "constant_offset_displacement", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_float_sdna(prop, NULL, "offset"); RNA_def_property_ui_text(prop, "Constant Offset Displacement", ""); RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); - prop= RNA_def_property(srna, "relative_offset", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "relative_offset", PROP_BOOLEAN, PROP_TRANSLATION); RNA_def_property_boolean_sdna(prop, NULL, "offset_type", MOD_ARR_OFF_RELATIVE); RNA_def_property_ui_text(prop, "Relative Offset", ""); RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); - prop= RNA_def_property(srna, "relative_offset_displacement", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "relative_offset_displacement", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_float_sdna(prop, NULL, "scale"); RNA_def_property_ui_text(prop, "Relative Offset Displacement", ""); RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); @@ -998,7 +1035,7 @@ static void rna_def_modifier_array(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Merge Vertices", "Merge vertices in first and last duplicates."); RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); - prop= RNA_def_property(srna, "merge_distance", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "merge_distance", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "merge_dist"); RNA_def_property_range(prop, 0, FLT_MAX); RNA_def_property_ui_range(prop, 0, 1, 1, 4); @@ -1136,7 +1173,7 @@ static void rna_def_modifier_uvproject(BlenderRNA *brna) PropertyRNA *prop; srna= RNA_def_struct(brna, "UVProjectModifier", "Modifier"); - RNA_def_struct_ui_text(srna, "UVProject Modifier", "UV projection modifier to sets UVs from a projector."); + RNA_def_struct_ui_text(srna, "UV Project Modifier", "UV projection modifier to sets UVs from a projector."); RNA_def_struct_sdna(srna, "UVProjectModifierData"); RNA_def_struct_ui_icon(srna, ICON_MOD_UVPROJECT); @@ -1146,9 +1183,15 @@ static void rna_def_modifier_uvproject(BlenderRNA *brna) RNA_def_property_string_funcs(prop, NULL, NULL, "rna_UVProjectModifier_uvlayer_set"); RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); + prop= RNA_def_property(srna, "num_projectors", PROP_INT, PROP_NONE); + RNA_def_property_ui_text(prop, "Number of Projectors", "Number of projectors to use."); + RNA_def_property_int_funcs(prop, NULL, "rna_UVProjectModifier_num_projectors_set", NULL); + RNA_def_property_range(prop, 1, MOD_UVPROJECT_MAX); + RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); + prop= RNA_def_property(srna, "projectors", PROP_COLLECTION, PROP_NONE); - RNA_def_property_struct_type(prop, "Object"); - RNA_def_property_collection_funcs(prop, "rna_UVProject_projectors_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_dereference_get", 0, 0, 0, 0, 0); + RNA_def_property_struct_type(prop, "UVProjector"); + RNA_def_property_collection_funcs(prop, "rna_UVProject_projectors_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", 0, 0, 0, 0, 0); RNA_def_property_ui_text(prop, "Projectors", ""); prop= RNA_def_property(srna, "image", PROP_POINTER, PROP_NONE); @@ -1174,6 +1217,15 @@ static void rna_def_modifier_uvproject(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_UVPROJECT_OVERRIDEIMAGE); RNA_def_property_ui_text(prop, "Override Image", "Override faces' current images with the given image."); RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); + + srna= RNA_def_struct(brna, "UVProjector", NULL); + RNA_def_struct_ui_text(srna, "UVProjector", "UV projector used by the UV project modifier."); + + prop= RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "Object"); + RNA_def_property_pointer_funcs(prop, "rna_UVProjector_object_get", "rna_UVProjector_object_set", NULL); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Object", "Object to use as projector transform."); } static void rna_def_modifier_smooth(BlenderRNA *brna) @@ -1280,7 +1332,7 @@ static void rna_def_modifier_cast(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Factor", ""); RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); - prop= RNA_def_property(srna, "radius", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "radius", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_range(prop, 0, FLT_MAX); RNA_def_property_ui_range(prop, 0, 100, 10, 2); RNA_def_property_ui_text(prop, "Radius", "Only deform vertices within this distance from the center of the effect (leave as 0 for infinite.)"); @@ -1860,7 +1912,7 @@ void RNA_def_modifier(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "mode", eModifierMode_Realtime); RNA_def_property_ui_text(prop, "Realtime", "Realtime display of a modifier."); RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); - RNA_def_property_ui_icon(prop, ICON_VIEW3D, 0); + RNA_def_property_ui_icon(prop, ICON_RESTRICT_VIEW_OFF, 0); prop= RNA_def_property(srna, "render", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "mode", eModifierMode_Render); diff --git a/source/blender/makesrna/intern/rna_nla.c b/source/blender/makesrna/intern/rna_nla.c index a9b289f314b..079d3db70aa 100644 --- a/source/blender/makesrna/intern/rna_nla.c +++ b/source/blender/makesrna/intern/rna_nla.c @@ -297,12 +297,12 @@ void rna_def_nlastrip(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Blending", "Method used for combining strip's result with accumulated result."); /* Strip extents */ - prop= RNA_def_property(srna, "start_frame", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "start_frame", PROP_FLOAT, PROP_TIME); RNA_def_property_float_sdna(prop, NULL, "start"); RNA_def_property_float_funcs(prop, NULL, "rna_NlaStrip_start_frame_set", NULL); RNA_def_property_ui_text(prop, "Start Frame", ""); - prop= RNA_def_property(srna, "end_frame", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "end_frame", PROP_FLOAT, PROP_TIME); RNA_def_property_float_sdna(prop, NULL, "end"); RNA_def_property_float_funcs(prop, NULL, "rna_NlaStrip_end_frame_set", NULL); RNA_def_property_ui_text(prop, "End Frame", ""); @@ -328,12 +328,12 @@ void rna_def_nlastrip(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Action", "Action referenced by this strip."); /* Action extents */ - prop= RNA_def_property(srna, "action_start_frame", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "action_start_frame", PROP_FLOAT, PROP_TIME); RNA_def_property_float_sdna(prop, NULL, "actstart"); RNA_def_property_float_funcs(prop, NULL, "rna_NlaStrip_action_start_frame_set", NULL); RNA_def_property_ui_text(prop, "Action Start Frame", ""); - prop= RNA_def_property(srna, "action_end_frame", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "action_end_frame", PROP_FLOAT, PROP_TIME); RNA_def_property_float_sdna(prop, NULL, "actend"); RNA_def_property_float_funcs(prop, NULL, "rna_NlaStrip_action_end_frame_set", NULL); RNA_def_property_ui_text(prop, "Action End Frame", ""); @@ -371,7 +371,7 @@ void rna_def_nlastrip(BlenderRNA *brna) RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Influence", "Amount the strip contributes to the current result."); - prop= RNA_def_property(srna, "strip_time", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "strip_time", PROP_FLOAT, PROP_TIME); RNA_def_property_ui_text(prop, "Strip Time", "Frame of referenced Action to evaluate."); // TODO: should the animated_influence/time settings be animatable themselves? diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index a03b59556e1..23e79831292 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -1354,7 +1354,7 @@ static void rna_def_node(BlenderRNA *brna) RNA_def_struct_sdna(srna, "bNode"); RNA_def_struct_refine_func(srna, "rna_Node_refine"); - prop = RNA_def_property(srna, "location", PROP_FLOAT, PROP_VECTOR); + prop = RNA_def_property(srna, "location", PROP_FLOAT, PROP_XYZ); RNA_def_property_float_sdna(prop, NULL, "locx"); RNA_def_property_array(prop, 2); RNA_def_property_range(prop, -10000.0f, 10000.0f); diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index 7e26cb00394..f0b055bd0e8 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -41,6 +41,18 @@ #include "WM_types.h" + +EnumPropertyItem object_mode_items[] = { + {OB_MODE_OBJECT, "OBJECT", ICON_OBJECT_DATAMODE, "Object", ""}, + {OB_MODE_EDIT, "EDIT", ICON_EDITMODE_HLT, "Edit", ""}, + {OB_MODE_SCULPT, "SCULPT", ICON_SCULPTMODE_HLT, "Sculpt", ""}, + {OB_MODE_VERTEX_PAINT, "VERTEX_PAINT", ICON_VPAINT_HLT, "Vertex Paint", ""}, + {OB_MODE_WEIGHT_PAINT, "WEIGHT_PAINT", ICON_WPAINT_HLT, "Weight Paint", ""}, + {OB_MODE_TEXTURE_PAINT, "TEXTURE_PAINT", ICON_TPAINT_HLT, "Texture Paint", ""}, + {OB_MODE_PARTICLE_EDIT, "PARTICLE_EDIT", ICON_PARTICLEMODE, "Particle Edit", ""}, + {OB_MODE_POSE, "POSE", ICON_POSE_HLT, "Pose", ""}, + {0, NULL, 0, NULL, NULL}}; + static EnumPropertyItem parent_type_items[] = { {PAROBJECT, "OBJECT", 0, "Object", ""}, {PARCURVE, "CURVE", 0, "Curve", ""}, @@ -824,10 +836,10 @@ static void rna_def_object_game_settings(BlenderRNA *brna) RNA_def_property_range(prop, 0.01, 10000.0); RNA_def_property_ui_text(prop, "Mass", "Mass of the object."); - prop= RNA_def_property(srna, "radius", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "radius", PROP_FLOAT, PROP_NONE|PROP_UNIT_LENGTH); RNA_def_property_float_sdna(prop, NULL, "inertia"); RNA_def_property_range(prop, 0.01, 10.0); - RNA_def_property_ui_text(prop, "Radius", "Radius for Bounding sphere and Fh/Fh Rot."); + RNA_def_property_ui_text(prop, "Radius", "Radius of bounding sphere and material physics"); RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL); prop= RNA_def_property(srna, "no_sleeping", PROP_BOOLEAN, PROP_NONE); @@ -887,13 +899,13 @@ static void rna_def_object_game_settings(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Lock Z Rotation Axis", "Disable simulation of angular motion along the Z axis."); - prop= RNA_def_property(srna, "do_fh", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "material_physics", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_DO_FH); - RNA_def_property_ui_text(prop, "Do Fh", "Use Fh settings in materials."); + RNA_def_property_ui_text(prop, "Use Material Physics", "Use physics settings in materials."); - prop= RNA_def_property(srna, "rotation_fh", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "rotate_from_normal", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_ROT_FH); - RNA_def_property_ui_text(prop, "Rotation Fh", "Use face normal to rotate Object"); + RNA_def_property_ui_text(prop, "Rotate From Normal", "Use face normal to rotate object, so that it points away from the surface"); prop= RNA_def_property(srna, "form_factor", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "formfactor"); @@ -904,7 +916,7 @@ static void rna_def_object_game_settings(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_ANISOTROPIC_FRICTION); RNA_def_property_ui_text(prop, "Anisotropic Friction", "Enable anisotropic friction."); - prop= RNA_def_property(srna, "friction_coefficients", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "friction_coefficients", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "anisotropicFriction"); RNA_def_property_range(prop, 0.0, 1.0); RNA_def_property_ui_text(prop, "Friction Coefficients", "Relative friction coefficient in the in the X, Y and Z directions, when anisotropic friction is enabled."); @@ -922,7 +934,7 @@ static void rna_def_object_game_settings(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_CHILD); RNA_def_property_ui_text(prop, "Collison Compound", "Add children to form a compound collision object."); - prop= RNA_def_property(srna, "collision_margin", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "collision_margin", PROP_FLOAT, PROP_NONE|PROP_UNIT_LENGTH); RNA_def_property_float_sdna(prop, NULL, "margin"); RNA_def_property_range(prop, 0.0, 1.0); RNA_def_property_ui_text(prop, "Collision Margin", "Extra margin around object for collision detection, small amount required for stability."); @@ -1017,6 +1029,8 @@ static void rna_def_object(BlenderRNA *brna) {OB_DUPLIGROUP, "GROUP", 0, "Group", "Enable group instancing."}, {0, NULL, 0, NULL, NULL}}; + unsigned short matrix_dimsize[]= {4}; + srna= RNA_def_struct(brna, "Object", "ID"); RNA_def_struct_ui_text(srna, "Object", "Object datablock defining an object in a scene.."); RNA_def_struct_clear_flag(srna, STRUCT_ID_REFCOUNT); @@ -1036,6 +1050,12 @@ static void rna_def_object(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Type", "Type of Object."); + prop= RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "mode"); + RNA_def_property_enum_items(prop, object_mode_items); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Mode", "Object interaction mode."); + prop= RNA_def_property(srna, "layers", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "lay", 1); RNA_def_property_array(prop, 20); @@ -1124,47 +1144,47 @@ static void rna_def_object(BlenderRNA *brna) /* transform */ - prop= RNA_def_property(srna, "location", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "location", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_float_sdna(prop, NULL, "loc"); RNA_def_property_ui_text(prop, "Location", "Location of the object."); RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_update"); - prop= RNA_def_property(srna, "delta_location", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "delta_location", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_float_sdna(prop, NULL, "dloc"); RNA_def_property_ui_text(prop, "Delta Location", "Extra added translation to object location."); RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_update"); - prop= RNA_def_property(srna, "rotation", PROP_FLOAT, PROP_ROTATION); + prop= RNA_def_property(srna, "rotation", PROP_FLOAT, PROP_EULER); RNA_def_property_float_sdna(prop, NULL, "rot"); RNA_def_property_ui_text(prop, "Rotation", "Rotation of the object."); RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_update"); - prop= RNA_def_property(srna, "delta_rotation", PROP_FLOAT, PROP_ROTATION); + prop= RNA_def_property(srna, "delta_rotation", PROP_FLOAT, PROP_EULER); RNA_def_property_float_sdna(prop, NULL, "drot"); RNA_def_property_ui_text(prop, "Delta Rotation", "Extra added rotation to the rotation of the object."); RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_update"); - prop= RNA_def_property(srna, "scale", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "scale", PROP_FLOAT, PROP_XYZ); RNA_def_property_float_sdna(prop, NULL, "size"); RNA_def_property_ui_text(prop, "Scale", "Scaling of the object."); RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_update"); - prop= RNA_def_property(srna, "delta_scale", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "delta_scale", PROP_FLOAT, PROP_XYZ); RNA_def_property_float_sdna(prop, NULL, "dsize"); RNA_def_property_ui_text(prop, "Delta Scale", "Extra added scaling to the scale of the object."); RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_update"); - prop= RNA_def_property(srna, "lock_location", PROP_BOOLEAN, PROP_VECTOR); + prop= RNA_def_property(srna, "lock_location", PROP_BOOLEAN, PROP_XYZ); RNA_def_property_boolean_sdna(prop, NULL, "protectflag", OB_LOCK_LOCX); RNA_def_property_array(prop, 3); RNA_def_property_ui_text(prop, "Lock Location", "Lock editing of location in the interface."); - prop= RNA_def_property(srna, "lock_rotation", PROP_BOOLEAN, PROP_VECTOR); + prop= RNA_def_property(srna, "lock_rotation", PROP_BOOLEAN, PROP_XYZ); RNA_def_property_boolean_sdna(prop, NULL, "protectflag", OB_LOCK_ROTX); RNA_def_property_array(prop, 3); RNA_def_property_ui_text(prop, "Lock Rotation", "Lock editing of rotation in the interface."); - prop= RNA_def_property(srna, "lock_scale", PROP_BOOLEAN, PROP_VECTOR); + prop= RNA_def_property(srna, "lock_scale", PROP_BOOLEAN, PROP_XYZ); RNA_def_property_boolean_sdna(prop, NULL, "protectflag", OB_LOCK_SCALEX); RNA_def_property_array(prop, 3); RNA_def_property_ui_text(prop, "Lock Scale", "Lock editing of scale in the interface."); @@ -1172,7 +1192,7 @@ static void rna_def_object(BlenderRNA *brna) /* matrix */ prop= RNA_def_property(srna, "matrix", PROP_FLOAT, PROP_MATRIX); RNA_def_property_float_sdna(prop, NULL, "obmat"); - RNA_def_property_array(prop, 16); + RNA_def_property_multidimensional_array(prop, 16, 2, matrix_dimsize); RNA_def_property_ui_text(prop, "Matrix", "Transformation matrix."); /* collections */ @@ -1218,7 +1238,7 @@ static void rna_def_object(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Empty Draw Type", "Viewport display style for empties."); RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL); - prop= RNA_def_property(srna, "empty_draw_size", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "empty_draw_size", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "empty_drawsize"); RNA_def_property_range(prop, 0.01, 10.0); RNA_def_property_ui_text(prop, "Empty Draw Size", "Size of of display for empties in the viewport."); @@ -1344,25 +1364,25 @@ static void rna_def_object(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Dupli Group", "Instance an existing group."); RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_dependency_update"); - prop= RNA_def_property(srna, "dupli_frames_start", PROP_INT, PROP_NONE); + prop= RNA_def_property(srna, "dupli_frames_start", PROP_INT, PROP_NONE|PROP_UNIT_TIME); RNA_def_property_int_sdna(prop, NULL, "dupsta"); RNA_def_property_range(prop, 1, 32767); RNA_def_property_ui_text(prop, "Dupli Frames Start", "Start frame for DupliFrames."); RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_update"); - prop= RNA_def_property(srna, "dupli_frames_end", PROP_INT, PROP_NONE); + prop= RNA_def_property(srna, "dupli_frames_end", PROP_INT, PROP_NONE|PROP_UNIT_TIME); RNA_def_property_int_sdna(prop, NULL, "dupend"); RNA_def_property_range(prop, 1, 32767); RNA_def_property_ui_text(prop, "Dupli Frames End", "End frame for DupliFrames."); RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_update"); - prop= RNA_def_property(srna, "dupli_frames_on", PROP_INT, PROP_NONE); + prop= RNA_def_property(srna, "dupli_frames_on", PROP_INT, PROP_NONE|PROP_UNIT_TIME); RNA_def_property_int_sdna(prop, NULL, "dupon"); RNA_def_property_range(prop, 1, 1500); RNA_def_property_ui_text(prop, "Dupli Frames On", "Number of frames to use between DupOff frames."); RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_update"); - prop= RNA_def_property(srna, "dupli_frames_off", PROP_INT, PROP_NONE); + prop= RNA_def_property(srna, "dupli_frames_off", PROP_INT, PROP_NONE|PROP_UNIT_TIME); RNA_def_property_int_sdna(prop, NULL, "dupoff"); RNA_def_property_range(prop, 0, 1500); RNA_def_property_ui_text(prop, "Dupli Frames Off", "Recurring frames to exclude from the Dupliframes."); @@ -1370,7 +1390,7 @@ static void rna_def_object(BlenderRNA *brna) /* time offset */ - prop= RNA_def_property(srna, "time_offset", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "time_offset", PROP_FLOAT, PROP_NONE|PROP_UNIT_TIME); RNA_def_property_float_sdna(prop, NULL, "sf"); RNA_def_property_range(prop, MINAFRAMEF, MAXFRAMEF); RNA_def_property_ui_text(prop, "Time Offset", "Animation offset in frames for IPO's and dupligroup instances."); @@ -1455,11 +1475,6 @@ static void rna_def_object(BlenderRNA *brna) RNA_def_property_struct_type(prop, "Pose"); RNA_def_property_ui_text(prop, "Pose", "Current pose for armatures."); - prop= RNA_def_property(srna, "pose_mode", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", OB_POSEMODE); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Pose Mode", "Object with armature data is in pose mode."); - /* shape keys */ prop= RNA_def_property(srna, "shape_key_lock", PROP_BOOLEAN, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_object_force.c b/source/blender/makesrna/intern/rna_object_force.c index e229afedc62..932bef9969d 100644 --- a/source/blender/makesrna/intern/rna_object_force.c +++ b/source/blender/makesrna/intern/rna_object_force.c @@ -148,6 +148,7 @@ static void rna_Cache_idname_change(bContext *C, PointerRNA *ptr) if(new_name) { if(pid2 && cache->flag & PTCACHE_DISK_CACHE) { + /* TODO: change to simple file rename */ strcpy(name, cache->name); strcpy(cache->name, cache->prev_name); @@ -169,6 +170,87 @@ static void rna_Cache_idname_change(bContext *C, PointerRNA *ptr) BLI_freelistN(&pidlist); } +static void rna_Cache_list_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) +{ + Object *ob = ptr->id.data; + PointCache *cache= ptr->data; + PTCacheID *pid; + ListBase pidlist; + + BKE_ptcache_ids_from_object(&pidlist, ob); + + for(pid=pidlist.first; pid; pid=pid->next) { + if(pid->cache == cache) { + rna_iterator_listbase_begin(iter, pid->ptcaches, NULL); + break; + } + } + + BLI_freelistN(&pidlist); +} +static void rna_Cache_active_point_cache_index_range(PointerRNA *ptr, int *min, int *max) +{ + Object *ob = ptr->id.data; + PointCache *cache= ptr->data; + PTCacheID *pid; + ListBase pidlist; + + BKE_ptcache_ids_from_object(&pidlist, ob); + + *min= 0; + *max= 0; + + for(pid=pidlist.first; pid; pid=pid->next) { + if(pid->cache == cache) { + *max= BLI_countlist(pid->ptcaches)-1; + *max= MAX2(0, *max); + break; + } + } + + BLI_freelistN(&pidlist); +} + +static int rna_Cache_active_point_cache_index_get(PointerRNA *ptr) +{ + Object *ob = ptr->id.data; + PointCache *cache= ptr->data; + PTCacheID *pid; + ListBase pidlist; + int num = 0; + + BKE_ptcache_ids_from_object(&pidlist, ob); + + for(pid=pidlist.first; pid; pid=pid->next) { + if(pid->cache == cache) { + num = BLI_findindex(pid->ptcaches, cache); + break; + } + } + + BLI_freelistN(&pidlist); + + return num; +} + +static void rna_Cache_active_point_cache_index_set(struct PointerRNA *ptr, int value) +{ + Object *ob = ptr->id.data; + PointCache *cache= ptr->data; + PTCacheID *pid; + ListBase pidlist; + + BKE_ptcache_ids_from_object(&pidlist, ob); + + for(pid=pidlist.first; pid; pid=pid->next) { + if(pid->cache == cache) { + *(pid->cache_ptr) = BLI_findlink(pid->ptcaches, value); + break; + } + } + + BLI_freelistN(&pidlist); +} static int rna_SoftBodySettings_use_edges_get(PointerRNA *ptr) { Object *data= (Object*)(ptr->id.data); @@ -371,13 +453,14 @@ static void rna_def_pointcache(BlenderRNA *brna) srna= RNA_def_struct(brna, "PointCache", NULL); RNA_def_struct_ui_text(srna, "Point Cache", "Point cache for physics simulations."); + RNA_def_struct_ui_icon(srna, ICON_PHYSICS); - prop= RNA_def_property(srna, "start_frame", PROP_INT, PROP_NONE); + prop= RNA_def_property(srna, "start_frame", PROP_INT, PROP_TIME); RNA_def_property_int_sdna(prop, NULL, "startframe"); RNA_def_property_range(prop, 1, 300000); RNA_def_property_ui_text(prop, "Start", "Frame on which the simulation starts."); - prop= RNA_def_property(srna, "end_frame", PROP_INT, PROP_NONE); + prop= RNA_def_property(srna, "end_frame", PROP_INT, PROP_TIME); RNA_def_property_int_sdna(prop, NULL, "endframe"); RNA_def_property_range(prop, 1, 300000); RNA_def_property_ui_text(prop, "End", "Frame on which the simulation stops."); @@ -420,6 +503,7 @@ static void rna_def_pointcache(BlenderRNA *brna) RNA_def_property_string_sdna(prop, NULL, "name"); RNA_def_property_ui_text(prop, "Name", "Cache name"); RNA_def_property_update(prop, NC_OBJECT, "rna_Cache_idname_change"); + RNA_def_struct_name_property(srna, prop); prop= RNA_def_property(srna, "filepath", PROP_STRING, PROP_DIRPATH); RNA_def_property_string_sdna(prop, NULL, "path"); @@ -440,6 +524,16 @@ static void rna_def_pointcache(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "flag", PTCACHE_EXTERNAL); RNA_def_property_ui_text(prop, "External", "Read cache from an external location"); RNA_def_property_update(prop, NC_OBJECT, "rna_Cache_idname_change"); + + prop= RNA_def_property(srna, "point_cache_list", PROP_COLLECTION, PROP_NONE); + RNA_def_property_collection_funcs(prop, "rna_Cache_list_begin", "rna_iterator_listbase_next", "rna_iterator_listbase_end", "rna_iterator_listbase_get", 0, 0, 0, 0, 0); + RNA_def_property_struct_type(prop, "PointCache"); + RNA_def_property_ui_text(prop, "Point Cache List", "Point cache list"); + + prop= RNA_def_property(srna, "active_point_cache_index", PROP_INT, PROP_UNSIGNED); + RNA_def_property_int_funcs(prop, "rna_Cache_active_point_cache_index_get", "rna_Cache_active_point_cache_index_set", "rna_Cache_active_point_cache_index_range"); + RNA_def_property_ui_text(prop, "Active Point Cache Index", ""); + RNA_def_property_update(prop, NC_OBJECT, "rna_Cache_change"); } static void rna_def_collision(BlenderRNA *brna) @@ -770,13 +864,13 @@ static void rna_def_game_softbody(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "flag", OB_BSB_BENDING_CONSTRAINTS); RNA_def_property_ui_text(prop, "Bending Const", "Enable bending constraints"); - prop= RNA_def_property(srna, "enable_rs_collision", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "cluster_rigid_to_softbody", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "collisionflags", OB_BSB_COL_CL_RS); - RNA_def_property_ui_text(prop, "Cluster Collision RS", "Enable cluster collision between soft and rigid body"); + RNA_def_property_ui_text(prop, "Rigid to Soft Body", "Enable cluster collision between soft and rigid body"); - prop= RNA_def_property(srna, "enable_ss_collision", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "cluster_soft_to_softbody", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "collisionflags", OB_BSB_COL_CL_SS); - RNA_def_property_ui_text(prop, "Cluster Collision SS", "Enable cluster collision between soft and soft body"); + RNA_def_property_ui_text(prop, "Soft to Soft Body", "Enable cluster collision between soft and soft body"); } static void rna_def_softbody(BlenderRNA *brna) @@ -810,7 +904,7 @@ static void rna_def_softbody(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Mass", ""); RNA_def_property_update(prop, NC_OBJECT|ND_GEOM_DATA, "rna_Object_update_data"); - prop= RNA_def_property(srna, "gravity", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "gravity", PROP_FLOAT, PROP_ACCELERATION); RNA_def_property_float_sdna(prop, NULL, "grav"); RNA_def_property_range(prop, -10.0f, 10.0f); RNA_def_property_ui_text(prop, "Gravitation", "Apply gravitation to point movement"); diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c index 3ebdd61ca50..e0dbc232e06 100644 --- a/source/blender/makesrna/intern/rna_particle.c +++ b/source/blender/makesrna/intern/rna_particle.c @@ -536,7 +536,7 @@ static void rna_def_particle_hair_key(BlenderRNA *brna) RNA_def_struct_sdna(srna, "HairKey"); RNA_def_struct_ui_text(srna, "Particle Hair Key", "Particle key for hair particle system."); - prop= RNA_def_property(srna, "location", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "location", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_float_sdna(prop, NULL, "co"); RNA_def_property_ui_text(prop, "Location", "Key location."); @@ -555,19 +555,19 @@ static void rna_def_particle_key(BlenderRNA *brna) srna = RNA_def_struct(brna, "ParticleKey", NULL); RNA_def_struct_ui_text(srna, "Particle Key", "Key location for a particle over time."); - prop= RNA_def_property(srna, "location", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "location", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_float_sdna(prop, NULL, "co"); RNA_def_property_ui_text(prop, "Location", "Key location."); - prop= RNA_def_property(srna, "velocity", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "velocity", PROP_FLOAT, PROP_VELOCITY); RNA_def_property_float_sdna(prop, NULL, "vel"); RNA_def_property_ui_text(prop, "Velocity", "Key velocity"); - prop= RNA_def_property(srna, "rotation", PROP_FLOAT, PROP_ROTATION); + prop= RNA_def_property(srna, "rotation", PROP_FLOAT, PROP_QUATERNION); RNA_def_property_float_sdna(prop, NULL, "rot"); RNA_def_property_ui_text(prop, "Rotation", "Key rotation quaterion."); - prop= RNA_def_property(srna, "angular_velocity", PROP_FLOAT, PROP_ROTATION); + prop= RNA_def_property(srna, "angular_velocity", PROP_FLOAT, PROP_VELOCITY); RNA_def_property_float_sdna(prop, NULL, "ave"); RNA_def_property_ui_text(prop, "Angular Velocity", "Key angular velocity."); @@ -616,35 +616,35 @@ static void rna_def_particle(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Stick Object", "Object that particle sticks to when dead"); /* Particle State & Previous State */ - prop= RNA_def_property(srna, "location", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "location", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_float_sdna(prop, NULL, "state.co"); RNA_def_property_ui_text(prop, "Particle Location", ""); - prop= RNA_def_property(srna, "velocity", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "velocity", PROP_FLOAT, PROP_VELOCITY); RNA_def_property_float_sdna(prop, NULL, "state.vel"); RNA_def_property_ui_text(prop, "Particle Velocity", ""); - prop= RNA_def_property(srna, "angular_velocity", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "angular_velocity", PROP_FLOAT, PROP_VELOCITY); RNA_def_property_float_sdna(prop, NULL, "state.ave"); RNA_def_property_ui_text(prop, "Angular Velocity", ""); - prop= RNA_def_property(srna, "rotation", PROP_FLOAT, PROP_ROTATION); + prop= RNA_def_property(srna, "rotation", PROP_FLOAT, PROP_QUATERNION); RNA_def_property_float_sdna(prop, NULL, "state.rot"); RNA_def_property_ui_text(prop, "Rotation", ""); - prop= RNA_def_property(srna, "prev_location", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "prev_location", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_float_sdna(prop, NULL, "prev_state.co"); RNA_def_property_ui_text(prop, "Previous Particle Location", ""); - prop= RNA_def_property(srna, "prev_velocity", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "prev_velocity", PROP_FLOAT, PROP_VELOCITY); RNA_def_property_float_sdna(prop, NULL, "prev_state.vel"); RNA_def_property_ui_text(prop, "Previous Particle Velocity", ""); - prop= RNA_def_property(srna, "prev_angular_velocity", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "prev_angular_velocity", PROP_FLOAT, PROP_VELOCITY); RNA_def_property_float_sdna(prop, NULL, "prev_state.ave"); RNA_def_property_ui_text(prop, "Previous Angular Velocity", ""); - prop= RNA_def_property(srna, "prev_rotation", PROP_FLOAT, PROP_ROTATION); + prop= RNA_def_property(srna, "prev_rotation", PROP_FLOAT, PROP_QUATERNION); RNA_def_property_float_sdna(prop, NULL, "prev_state.rot"); RNA_def_property_ui_text(prop, "Previous Rotation", ""); @@ -662,17 +662,17 @@ static void rna_def_particle(BlenderRNA *brna) /* Random variables */ - prop= RNA_def_property(srna, "random_rotation", PROP_FLOAT, PROP_ROTATION); + prop= RNA_def_property(srna, "random_rotation", PROP_FLOAT, PROP_QUATERNION); RNA_def_property_float_sdna(prop, NULL, "r_rot"); // RNA_def_property_range(prop, lowerLimitf, upperLimitf); RNA_def_property_ui_text(prop, "Random Rotation", ""); - prop= RNA_def_property(srna, "random_a_velocity", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "random_a_velocity", PROP_FLOAT, PROP_VELOCITY); RNA_def_property_float_sdna(prop, NULL, "r_ave"); // RNA_def_property_range(prop, lowerLimitf, upperLimitf); RNA_def_property_ui_text(prop, "Random Angular Velocity", ""); - prop= RNA_def_property(srna, "random_velocity", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "random_velocity", PROP_FLOAT, PROP_VELOCITY); RNA_def_property_float_sdna(prop, NULL, "r_ve"); // RNA_def_property_range(prop, lowerLimitf, upperLimitf); RNA_def_property_ui_text(prop, "Random Velocity", ""); @@ -681,16 +681,16 @@ static void rna_def_particle(BlenderRNA *brna) // float fuv[4], foffset; /* coordinates on face/edge number "num" and depth along*/ // /* face normal for volume emission */ - prop= RNA_def_property(srna, "birthtime", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "birthtime", PROP_FLOAT, PROP_TIME); RNA_def_property_float_sdna(prop, NULL, "time"); // RNA_def_property_range(prop, lowerLimitf, upperLimitf); RNA_def_property_ui_text(prop, "Birth Time", ""); - prop= RNA_def_property(srna, "lifetime", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "lifetime", PROP_FLOAT, PROP_TIME); // RNA_def_property_range(prop, lowerLimitf, upperLimitf); RNA_def_property_ui_text(prop, "Lifetime", ""); - prop= RNA_def_property(srna, "die_time", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "die_time", PROP_FLOAT, PROP_TIME); RNA_def_property_float_sdna(prop, NULL, "dietime"); // RNA_def_property_range(prop, lowerLimitf, upperLimitf); RNA_def_property_ui_text(prop, "Die Time", ""); @@ -1261,7 +1261,7 @@ static void rna_def_particle_settings(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Random Tilt", "Random tilt of the billboards"); RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo"); - prop= RNA_def_property(srna, "billboard_offset", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "billboard_offset", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_float_sdna(prop, NULL, "bb_offset"); RNA_def_property_array(prop, 2); RNA_def_property_range(prop, -100.0f, 100.0f); @@ -1312,7 +1312,7 @@ static void rna_def_particle_settings(BlenderRNA *brna) RNA_def_property_ui_text(prop, "End", "Frame # to stop emitting particles."); RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); - prop= RNA_def_property(srna, "lifetime", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "lifetime", PROP_FLOAT, PROP_TIME); RNA_def_property_range(prop, 1.0f, MAXFRAMEF); RNA_def_property_ui_text(prop, "Lifetime", "Specify the life span of the particles"); RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); @@ -1465,14 +1465,14 @@ static void rna_def_particle_settings(BlenderRNA *brna) /* global physical properties */ - prop= RNA_def_property(srna, "acceleration", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "acceleration", PROP_FLOAT, PROP_ACCELERATION); RNA_def_property_float_sdna(prop, NULL, "acc"); RNA_def_property_array(prop, 3); RNA_def_property_range(prop, -200.0f, 200.0f); RNA_def_property_ui_text(prop, "Acceleration", "Constant acceleration"); RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); - prop= RNA_def_property(srna, "gravity", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "gravity", PROP_FLOAT, PROP_ACCELERATION); RNA_def_property_float_sdna(prop, NULL, "acc[2]"); RNA_def_property_range(prop, -200.0f, 200.0f); RNA_def_property_ui_text(prop, "Gravity", "Constant acceleration in global Z axis direction"); @@ -1837,7 +1837,7 @@ static void rna_def_particle_target(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Target Particle System", "The index of particle system on the target object."); RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_target_reset"); - prop= RNA_def_property(srna, "time", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "time", PROP_FLOAT, PROP_TIME); RNA_def_property_float_sdna(prop, NULL, "time"); RNA_def_property_range(prop, 0.0, 30000.0f); //TODO: replace 30000 with MAXFRAMEF when available in 2.5 RNA_def_property_ui_text(prop, "Time", ""); diff --git a/source/blender/makesrna/intern/rna_pose.c b/source/blender/makesrna/intern/rna_pose.c index 0148ce819d4..bfebc5ee49f 100644 --- a/source/blender/makesrna/intern/rna_pose.c +++ b/source/blender/makesrna/intern/rna_pose.c @@ -151,12 +151,72 @@ static int rna_PoseChannel_has_ik_get(PointerRNA *ptr) return ED_pose_channel_in_IK_chain(ob, pchan); } +static PointerRNA rna_PoseChannel_bone_group_get(PointerRNA *ptr) +{ + Object *ob= (Object*)ptr->id.data; + bPose *pose= (ob) ? ob->pose : NULL; + bPoseChannel *pchan= (bPoseChannel*)ptr->data; + bActionGroup *grp; + + if (pose) + grp= BLI_findlink(&pose->agroups, pchan->agrp_index-1); + else + grp= NULL; + + return rna_pointer_inherit_refine(ptr, &RNA_BoneGroup, grp); +} + +static void rna_PoseChannel_bone_group_set(PointerRNA *ptr, PointerRNA value) +{ + Object *ob= (Object*)ptr->id.data; + bPose *pose= (ob) ? ob->pose : NULL; + bPoseChannel *pchan= (bPoseChannel*)ptr->data; + + if (pose) + pchan->agrp_index= BLI_findindex(&pose->agroups, value.data) + 1; + else + pchan->agrp_index= 0; +} + +static int rna_PoseChannel_bone_group_index_get(PointerRNA *ptr) +{ + bPoseChannel *pchan= (bPoseChannel*)ptr->data; + return MAX2(pchan->agrp_index-1, 0); +} + +static void rna_PoseChannel_bone_group_index_set(PointerRNA *ptr, int value) +{ + bPoseChannel *pchan= (bPoseChannel*)ptr->data; + pchan->agrp_index= value+1; +} + +static void rna_PoseChannel_bone_group_index_range(PointerRNA *ptr, int *min, int *max) +{ + Object *ob= (Object*)ptr->id.data; + bPose *pose= (ob) ? ob->pose : NULL; + + *min= 0; + + if (pose) { + *max= BLI_countlist(&pose->agroups)-1; + *max= MAX2(0, *max); + } + else + *max= 0; +} + static PointerRNA rna_Pose_active_bone_group_get(PointerRNA *ptr) { bPose *pose= (bPose*)ptr->data; return rna_pointer_inherit_refine(ptr, &RNA_BoneGroup, BLI_findlink(&pose->agroups, pose->active_group-1)); } +static void rna_Pose_active_bone_group_set(PointerRNA *ptr, PointerRNA value) +{ + bPose *pose= (bPose*)ptr->data; + pose->active_group= BLI_findindex(&pose->agroups, value.data) + 1; +} + static int rna_Pose_active_bone_group_index_get(PointerRNA *ptr) { bPose *pose= (bPose*)ptr->data; @@ -304,72 +364,36 @@ static void rna_def_pose_channel(BlenderRNA *brna) RNA_def_struct_ui_text(srna, "Pose Channel", "Channel defining pose data for a bone in a Pose."); RNA_def_struct_path_func(srna, "rna_PoseChannel_path"); RNA_def_struct_idproperties_func(srna, "rna_PoseChannel_idproperties"); - + + /* Bone Constraints */ prop= RNA_def_property(srna, "constraints", PROP_COLLECTION, PROP_NONE); RNA_def_property_struct_type(prop, "Constraint"); RNA_def_property_ui_text(prop, "Constraints", "Constraints that act on this PoseChannel."); + /* Name + Selection Status */ prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); RNA_def_property_string_funcs(prop, NULL, NULL, "rna_PoseChannel_name_set"); RNA_def_property_ui_text(prop, "Name", ""); RNA_def_struct_name_property(srna, prop); - - prop= RNA_def_property(srna, "has_ik", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_funcs(prop, "rna_PoseChannel_has_ik_get", NULL); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Has IK", "Is part of an IK chain."); - RNA_def_property_update(prop, NC_OBJECT|ND_POSE|ND_TRANSFORM, "rna_Pose_update"); - - prop= RNA_def_property(srna, "ik_dof_x", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_negative_sdna(prop, NULL, "ikflag", BONE_IK_NO_XDOF); - RNA_def_property_ui_text(prop, "IK X DoF", "Allow movement around the X axis."); - RNA_def_property_update(prop, NC_OBJECT|ND_POSE|ND_TRANSFORM, "rna_Pose_update"); - - prop= RNA_def_property(srna, "ik_dof_y", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_negative_sdna(prop, NULL, "ikflag", BONE_IK_NO_YDOF); - RNA_def_property_ui_text(prop, "IK Y DoF", "Allow movement around the Y axis."); - RNA_def_property_update(prop, NC_OBJECT|ND_POSE|ND_TRANSFORM, "rna_Pose_update"); - - prop= RNA_def_property(srna, "ik_dof_z", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_negative_sdna(prop, NULL, "ikflag", BONE_IK_NO_ZDOF); - RNA_def_property_ui_text(prop, "IK Z DoF", "Allow movement around the Z axis."); - RNA_def_property_update(prop, NC_OBJECT|ND_POSE|ND_TRANSFORM, "rna_Pose_update"); - - prop= RNA_def_property(srna, "ik_limit_x", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "ikflag", BONE_IK_XLIMIT); - RNA_def_property_ui_text(prop, "IK X Limit", "Limit movement around the X axis."); - RNA_def_property_update(prop, NC_OBJECT|ND_POSE|ND_TRANSFORM, "rna_Pose_update"); - - prop= RNA_def_property(srna, "ik_limit_y", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "ikflag", BONE_IK_YLIMIT); - RNA_def_property_ui_text(prop, "IK Y Limit", "Limit movement around the Y axis."); - RNA_def_property_update(prop, NC_OBJECT|ND_POSE|ND_TRANSFORM, "rna_Pose_update"); - - prop= RNA_def_property(srna, "ik_limit_z", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "ikflag", BONE_IK_ZLIMIT); - RNA_def_property_ui_text(prop, "IK Z Limit", "Limit movement around the Z axis."); - RNA_def_property_update(prop, NC_OBJECT|ND_POSE|ND_TRANSFORM, "rna_Pose_update"); prop= RNA_def_property(srna, "selected", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "selectflag", BONE_SELECTED); RNA_def_property_ui_text(prop, "Selected", ""); - - prop= RNA_def_property(srna, "bone_group_index", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "agrp_index"); - RNA_def_property_ui_text(prop, "Bone Group Index", "Bone Group this pose channel belongs to (0=no group)."); - prop= RNA_def_property(srna, "path_start_frame", PROP_INT, PROP_NONE); + /* Baked Bone Path cache data s*/ + prop= RNA_def_property(srna, "path_start_frame", PROP_INT, PROP_TIME); RNA_def_property_int_sdna(prop, NULL, "pathsf"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Bone Paths Calculation Start Frame", "Starting frame of range of frames to use for Bone Path calculations."); RNA_def_property_update(prop, NC_OBJECT|ND_POSE|ND_TRANSFORM, "rna_Pose_update"); - prop= RNA_def_property(srna, "path_end_frame", PROP_INT, PROP_NONE); + prop= RNA_def_property(srna, "path_end_frame", PROP_INT, PROP_TIME); RNA_def_property_int_sdna(prop, NULL, "pathef"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Bone Paths Calculation End Frame", "End frame of range of frames to use for Bone Path calculations."); RNA_def_property_update(prop, NC_OBJECT|ND_POSE|ND_TRANSFORM, "rna_Pose_update"); - + + /* Relationships to other bones */ prop= RNA_def_property(srna, "bone", PROP_POINTER, PROP_NEVER_NULL); RNA_def_property_struct_type(prop, "Bone"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); @@ -384,23 +408,24 @@ static void rna_def_pose_channel(BlenderRNA *brna) RNA_def_property_struct_type(prop, "PoseChannel"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Child", "Child of this pose channel."); - - prop= RNA_def_property(srna, "location", PROP_FLOAT, PROP_VECTOR); + + /* Transformation settings */ + prop= RNA_def_property(srna, "location", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_float_sdna(prop, NULL, "loc"); RNA_def_property_ui_text(prop, "Location", ""); RNA_def_property_update(prop, NC_OBJECT|ND_POSE|ND_TRANSFORM, "rna_Pose_update"); - prop= RNA_def_property(srna, "scale", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "scale", PROP_FLOAT, PROP_XYZ); RNA_def_property_float_sdna(prop, NULL, "size"); RNA_def_property_ui_text(prop, "Scale", ""); RNA_def_property_update(prop, NC_OBJECT|ND_POSE|ND_TRANSFORM, "rna_Pose_update"); - prop= RNA_def_property(srna, "rotation", PROP_FLOAT, PROP_ROTATION); + prop= RNA_def_property(srna, "rotation", PROP_FLOAT, PROP_QUATERNION); RNA_def_property_float_sdna(prop, NULL, "quat"); RNA_def_property_ui_text(prop, "Rotation", "Rotation in Quaternions."); RNA_def_property_update(prop, NC_OBJECT|ND_POSE|ND_TRANSFORM, "rna_Pose_update"); - prop= RNA_def_property(srna, "euler_rotation", PROP_FLOAT, PROP_ROTATION); + prop= RNA_def_property(srna, "euler_rotation", PROP_FLOAT, PROP_EULER); RNA_def_property_float_sdna(prop, NULL, "eul"); RNA_def_property_float_funcs(prop, "rna_PoseChannel_euler_rotation_get", "rna_PoseChannel_euler_rotation_set", NULL); RNA_def_property_ui_text(prop, "Rotation (Euler)", "Rotation in Eulers."); @@ -429,45 +454,83 @@ static void rna_def_pose_channel(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Constraint Inverse Matrix", "4x4 matrix, defines transform from final position to unconstrained position."); */ - prop= RNA_def_property(srna, "pose_head", PROP_FLOAT, PROP_VECTOR); + /* Head/Tail Coordinates (in Pose Space) - Automatically calculated... */ + prop= RNA_def_property(srna, "pose_head", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Pose Head Position", "Location of head of the channel's bone."); - prop= RNA_def_property(srna, "pose_tail", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "pose_tail", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Pose Tail Position", "Location of tail of the channel's bone."); + + /* IK Settings */ + prop= RNA_def_property(srna, "has_ik", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_funcs(prop, "rna_PoseChannel_has_ik_get", NULL); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Has IK", "Is part of an IK chain."); + RNA_def_property_update(prop, NC_OBJECT|ND_POSE|ND_TRANSFORM, "rna_Pose_update"); - prop= RNA_def_property(srna, "ik_min_x", PROP_FLOAT, PROP_ROTATION); + prop= RNA_def_property(srna, "ik_dof_x", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "ikflag", BONE_IK_NO_XDOF); + RNA_def_property_ui_text(prop, "IK X DoF", "Allow movement around the X axis."); + RNA_def_property_update(prop, NC_OBJECT|ND_POSE|ND_TRANSFORM, "rna_Pose_update"); + + prop= RNA_def_property(srna, "ik_dof_y", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "ikflag", BONE_IK_NO_YDOF); + RNA_def_property_ui_text(prop, "IK Y DoF", "Allow movement around the Y axis."); + RNA_def_property_update(prop, NC_OBJECT|ND_POSE|ND_TRANSFORM, "rna_Pose_update"); + + prop= RNA_def_property(srna, "ik_dof_z", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "ikflag", BONE_IK_NO_ZDOF); + RNA_def_property_ui_text(prop, "IK Z DoF", "Allow movement around the Z axis."); + RNA_def_property_update(prop, NC_OBJECT|ND_POSE|ND_TRANSFORM, "rna_Pose_update"); + + prop= RNA_def_property(srna, "ik_limit_x", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "ikflag", BONE_IK_XLIMIT); + RNA_def_property_ui_text(prop, "IK X Limit", "Limit movement around the X axis."); + RNA_def_property_update(prop, NC_OBJECT|ND_POSE|ND_TRANSFORM, "rna_Pose_update"); + + prop= RNA_def_property(srna, "ik_limit_y", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "ikflag", BONE_IK_YLIMIT); + RNA_def_property_ui_text(prop, "IK Y Limit", "Limit movement around the Y axis."); + RNA_def_property_update(prop, NC_OBJECT|ND_POSE|ND_TRANSFORM, "rna_Pose_update"); + + prop= RNA_def_property(srna, "ik_limit_z", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "ikflag", BONE_IK_ZLIMIT); + RNA_def_property_ui_text(prop, "IK Z Limit", "Limit movement around the Z axis."); + RNA_def_property_update(prop, NC_OBJECT|ND_POSE|ND_TRANSFORM, "rna_Pose_update"); + + prop= RNA_def_property(srna, "ik_min_x", PROP_FLOAT, PROP_ANGLE); RNA_def_property_float_sdna(prop, NULL, "limitmin[0]"); RNA_def_property_range(prop, -180.0f, 0.0f); RNA_def_property_ui_text(prop, "IK X Minimum", "Minimum angles for IK Limit"); RNA_def_property_update(prop, NC_OBJECT|ND_POSE|ND_TRANSFORM, "rna_Pose_update"); - prop= RNA_def_property(srna, "ik_max_x", PROP_FLOAT, PROP_ROTATION); + prop= RNA_def_property(srna, "ik_max_x", PROP_FLOAT, PROP_ANGLE); RNA_def_property_float_sdna(prop, NULL, "limitmax[0]"); RNA_def_property_range(prop, 0.0f, 180.0f); RNA_def_property_ui_text(prop, "IK X Maximum", "Maximum angles for IK Limit"); RNA_def_property_update(prop, NC_OBJECT|ND_POSE|ND_TRANSFORM, "rna_Pose_update"); - prop= RNA_def_property(srna, "ik_min_y", PROP_FLOAT, PROP_ROTATION); + prop= RNA_def_property(srna, "ik_min_y", PROP_FLOAT, PROP_ANGLE); RNA_def_property_float_sdna(prop, NULL, "limitmin[1]"); RNA_def_property_range(prop, -180.0f, 0.0f); RNA_def_property_ui_text(prop, "IK Y Minimum", "Minimum angles for IK Limit"); RNA_def_property_update(prop, NC_OBJECT|ND_POSE|ND_TRANSFORM, "rna_Pose_update"); - prop= RNA_def_property(srna, "ik_max_y", PROP_FLOAT, PROP_ROTATION); + prop= RNA_def_property(srna, "ik_max_y", PROP_FLOAT, PROP_ANGLE); RNA_def_property_float_sdna(prop, NULL, "limitmax[1]"); RNA_def_property_range(prop, 0.0f, 180.0f); RNA_def_property_ui_text(prop, "IK Y Maximum", "Maximum angles for IK Limit"); RNA_def_property_update(prop, NC_OBJECT|ND_POSE|ND_TRANSFORM, "rna_Pose_update"); - prop= RNA_def_property(srna, "ik_min_z", PROP_FLOAT, PROP_ROTATION); + prop= RNA_def_property(srna, "ik_min_z", PROP_FLOAT, PROP_ANGLE); RNA_def_property_float_sdna(prop, NULL, "limitmin[2]"); RNA_def_property_range(prop, -180.0f, 0.0f); RNA_def_property_ui_text(prop, "IK Z Minimum", "Minimum angles for IK Limit"); RNA_def_property_update(prop, NC_OBJECT|ND_POSE|ND_TRANSFORM, "rna_Pose_update"); - prop= RNA_def_property(srna, "ik_max_z", PROP_FLOAT, PROP_ROTATION); + prop= RNA_def_property(srna, "ik_max_z", PROP_FLOAT, PROP_ANGLE); RNA_def_property_float_sdna(prop, NULL, "limitmax[2]"); RNA_def_property_range(prop, 0.0f, 180.0f); RNA_def_property_ui_text(prop, "IK Z Maximum", "Maximum angles for IK Limit"); @@ -496,22 +559,42 @@ static void rna_def_pose_channel(BlenderRNA *brna) RNA_def_property_range(prop, 0.0f,1.0f); RNA_def_property_ui_text(prop, "IK Stretch", "Allow scaling of the bone for IK."); RNA_def_property_update(prop, NC_OBJECT|ND_POSE|ND_TRANSFORM, "rna_Pose_update"); - - prop= RNA_def_property(srna, "custom", PROP_POINTER, PROP_NONE); + + /* custom bone shapes */ + prop= RNA_def_property(srna, "custom_shape", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "custom"); + RNA_def_property_struct_type(prop, "Object"); + RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Custom Object", "Object that defines custom draw type for this bone."); - RNA_def_property_update(prop, NC_OBJECT|ND_POSE|ND_TRANSFORM, "rna_Pose_update"); - - prop= RNA_def_property(srna, "lock_location", PROP_BOOLEAN, PROP_VECTOR); + RNA_def_property_update(prop, NC_OBJECT|ND_POSE, "rna_Pose_update"); + + /* bone groups */ + prop= RNA_def_property(srna, "bone_group_index", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "agrp_index"); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_int_funcs(prop, "rna_PoseChannel_bone_group_index_get", "rna_PoseChannel_bone_group_index_set", "rna_PoseChannel_bone_group_index_range"); + RNA_def_property_ui_text(prop, "Bone Group Index", "Bone Group this pose channel belongs to (0=no group)."); + RNA_def_property_update(prop, NC_OBJECT|ND_POSE, "rna_Pose_update"); + + prop= RNA_def_property(srna, "bone_group", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "BoneGroup"); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_pointer_funcs(prop, "rna_PoseChannel_bone_group_get", "rna_PoseChannel_bone_group_set", NULL); + RNA_def_property_ui_text(prop, "Bone Group", "Bone Group this pose channel belongs to"); + RNA_def_property_update(prop, NC_OBJECT|ND_POSE, "rna_Pose_update"); + + /* transform locks */ + prop= RNA_def_property(srna, "lock_location", PROP_BOOLEAN, PROP_XYZ); RNA_def_property_boolean_sdna(prop, NULL, "protectflag", OB_LOCK_LOCX); RNA_def_property_array(prop, 3); RNA_def_property_ui_text(prop, "Lock Location", "Lock editing of location in the interface."); - prop= RNA_def_property(srna, "lock_rotation", PROP_BOOLEAN, PROP_VECTOR); + prop= RNA_def_property(srna, "lock_rotation", PROP_BOOLEAN, PROP_XYZ); RNA_def_property_boolean_sdna(prop, NULL, "protectflag", OB_LOCK_ROTX); RNA_def_property_array(prop, 3); RNA_def_property_ui_text(prop, "Lock Rotation", "Lock editing of rotation in the interface."); - prop= RNA_def_property(srna, "lock_scale", PROP_BOOLEAN, PROP_VECTOR); + prop= RNA_def_property(srna, "lock_scale", PROP_BOOLEAN, PROP_XYZ); RNA_def_property_boolean_sdna(prop, NULL, "protectflag", OB_LOCK_SCALEX); RNA_def_property_array(prop, 3); RNA_def_property_ui_text(prop, "Lock Scale", "Lock editing of scale in the interface."); @@ -541,8 +624,9 @@ static void rna_def_pose(BlenderRNA *brna) prop= RNA_def_property(srna, "active_bone_group", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "BoneGroup"); + RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_pointer_funcs(prop, "rna_Pose_active_bone_group_get", "rna_Pose_active_bone_group_set", NULL); - RNA_def_property_ui_text(prop, "Active Bone Group", "Bone groups of the pose."); + RNA_def_property_ui_text(prop, "Active Bone Group", "Active bone group for this pose."); RNA_def_property_update(prop, NC_OBJECT|ND_POSE, "rna_Pose_update"); prop= RNA_def_property(srna, "active_bone_group_index", PROP_INT, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_render.c b/source/blender/makesrna/intern/rna_render.c index 7268d560282..9137e596da1 100644 --- a/source/blender/makesrna/intern/rna_render.c +++ b/source/blender/makesrna/intern/rna_render.c @@ -106,11 +106,12 @@ static void rna_RenderEngine_unregister(const bContext *C, StructRNA *type) if(!et) return; + RNA_struct_free_extension(type, &et->ext); BLI_freelinkN(&R_engines, et); RNA_struct_free(&BLENDER_RNA, type); } -static StructRNA *rna_RenderEngine_register(const bContext *C, ReportList *reports, void *data, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free) +static StructRNA *rna_RenderEngine_register(const bContext *C, ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free) { RenderEngineType *et, dummyet = {0}; RenderEngine dummyengine= {0}; @@ -272,10 +273,17 @@ static void rna_def_render_result(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; + FunctionRNA *func; srna= RNA_def_struct(brna, "RenderResult", NULL); RNA_def_struct_ui_text(srna, "Render Result", "Result of rendering, including all layers and passes."); + func= RNA_def_function(srna, "load_from_file", "RE_result_load_from_file"); + RNA_def_function_ui_description(func, "Copies the pixels of this render result from an image file."); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + prop= RNA_def_string(func, "filename", "", 0, "Filename", "Filename to load into this render tile, must be no smaller then the render result"); + RNA_def_property_flag(prop, PROP_REQUIRED); + RNA_define_verify_sdna(0); prop= RNA_def_property(srna, "resolution_x", PROP_INT, PROP_NONE); @@ -302,15 +310,11 @@ static void rna_def_render_layer(BlenderRNA *brna) srna= RNA_def_struct(brna, "RenderLayer", NULL); RNA_def_struct_ui_text(srna, "Render Layer", ""); - func= RNA_def_function(srna, "rect_from_file", "RE_layer_rect_from_file"); + func= RNA_def_function(srna, "load_from_file", "RE_layer_load_from_file"); RNA_def_function_ui_description(func, "Copies the pixels of this renderlayer from an image file."); RNA_def_function_flag(func, FUNC_USE_REPORTS); prop= RNA_def_string(func, "filename", "", 0, "Filename", "Filename to load into this render tile, must be no smaller then the renderlayer"); RNA_def_property_flag(prop, PROP_REQUIRED); - prop= RNA_def_int(func, "x", 0, 0, INT_MAX, "Offset X", "Offset the position to copy from if the image is larger then the render layer", 0, INT_MAX); - RNA_def_property_flag(prop, PROP_REQUIRED); - prop= RNA_def_int(func, "y", 0, 0, INT_MAX, "Offset Y", "Offset the position to copy from if the image is larger then the render layer", 0, INT_MAX); - RNA_def_property_flag(prop, PROP_REQUIRED); RNA_define_verify_sdna(0); diff --git a/source/blender/makesrna/intern/rna_rna.c b/source/blender/makesrna/intern/rna_rna.c index 385c7f5b2b1..57ed5ccef39 100644 --- a/source/blender/makesrna/intern/rna_rna.c +++ b/source/blender/makesrna/intern/rna_rna.c @@ -407,12 +407,25 @@ static int rna_Property_subtype_get(PointerRNA *ptr) return prop->subtype; } +static int rna_Property_unit_get(PointerRNA *ptr) +{ + PropertyRNA *prop= (PropertyRNA*)ptr->data; + rna_idproperty_check(&prop, ptr); + return RNA_SUBTYPE_UNIT(prop->subtype); +} + static int rna_Property_editable_get(PointerRNA *ptr) { PropertyRNA *prop= (PropertyRNA*)ptr->data; return RNA_property_editable(ptr, prop); } +static int rna_Property_use_return_get(PointerRNA *ptr) +{ + PropertyRNA *prop= (PropertyRNA*)ptr->data; + return prop->flag & PROP_RETURN ? 1:0; +} + static int rna_Property_array_length_get(PointerRNA *ptr) { PropertyRNA *prop= (PropertyRNA*)ptr->data; @@ -769,15 +782,32 @@ static void rna_def_property(BlenderRNA *brna) {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem subtype_items[] = { {PROP_NONE, "NONE", 0, "None", ""}, - {PROP_UNSIGNED, "UNSIGNED", 0, "Unsigned Number", ""}, {PROP_FILEPATH, "FILE_PATH", 0, "File Path", ""}, {PROP_DIRPATH, "DIRECTORY_PATH", 0, "Directory Path", ""}, + {PROP_UNSIGNED, "UNSIGNED", 0, "Unsigned Number", ""}, + {PROP_PERCENTAGE, "PERCENTAGE", 0, "Percentage", ""}, + {PROP_ANGLE, "ANGLE", 0, "Angle", ""}, + {PROP_TIME, "TIME", 0, "Time", ""}, + {PROP_DISTANCE, "DISTANCE", 0, "Distance", ""}, {PROP_COLOR, "COLOR", 0, "Color", ""}, - {PROP_VECTOR, "VECTOR", 0, "Vector", ""}, + {PROP_TRANSLATION, "TRANSLATION", 0, "Translation", ""}, + {PROP_DIRECTION, "DIRECTION", 0, "Direction", ""}, {PROP_MATRIX, "MATRIX", 0, "Matrix", ""}, - {PROP_ROTATION, "ROTATION", 0, "Rotation", ""}, + {PROP_EULER, "EULER", 0, "Euler", ""}, + {PROP_QUATERNION, "QUATERNION", 0, "Quaternion", ""}, + {PROP_XYZ, "XYZ", 0, "XYZ", ""}, + {PROP_RGB, "RGB", 0, "RGB", ""}, {PROP_NEVER_NULL, "NEVER_NULL", 0, "Never Null", ""}, - {PROP_PERCENTAGE, "PERCENTAGE", 0, "Percentage", ""}, + {0, NULL, 0, NULL, NULL}}; + static EnumPropertyItem unit_items[] = { + {PROP_UNIT_NONE, "NONE", 0, "None", ""}, + {PROP_UNIT_LENGTH, "LENGTH", 0, "Length", ""}, + {PROP_UNIT_AREA, "AREA", 0, "Area", ""}, + {PROP_UNIT_VOLUME, "VOLUME", 0, "Volume", ""}, + {PROP_UNIT_ROTATION, "ROTATION", 0, "Rotation", ""}, + {PROP_UNIT_TIME, "TIME", 0, "Time", ""}, + {PROP_UNIT_VELOCITY, "VELOCITY", 0, "Velocity", ""}, + {PROP_UNIT_ACCELERATION, "ACCELERATION", 0, "Acceleration", ""}, {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "Property", NULL); @@ -813,11 +843,22 @@ static void rna_def_property(BlenderRNA *brna) RNA_def_property_enum_funcs(prop, "rna_Property_subtype_get", NULL, NULL); RNA_def_property_ui_text(prop, "Subtype", "Semantic interpretation of the property."); + prop= RNA_def_property(srna, "unit", PROP_ENUM, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_enum_items(prop, unit_items); + RNA_def_property_enum_funcs(prop, "rna_Property_unit_get", NULL, NULL); + RNA_def_property_ui_text(prop, "Unit", "Type of units for this property."); + prop= RNA_def_property(srna, "editable", PROP_BOOLEAN, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_boolean_funcs(prop, "rna_Property_editable_get", NULL); RNA_def_property_ui_text(prop, "Editable", "Property is editable through RNA."); + prop= RNA_def_property(srna, "use_return", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_boolean_funcs(prop, "rna_Property_use_return_get", NULL); + RNA_def_property_ui_text(prop, "Return", "True when this property is a return value from an rna function.."); + prop= RNA_def_property(srna, "registered", PROP_BOOLEAN, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_boolean_funcs(prop, "rna_Property_registered_get", NULL); @@ -875,15 +916,17 @@ static void rna_def_number_property(StructRNA *srna, PropertyType type) RNA_def_property_ui_text(prop, "Default", "Default value for this number"); switch(type) { - case PROP_BOOLEAN: - RNA_def_property_boolean_funcs(prop, "rna_BoolProperty_default_get", NULL); - break; - case PROP_INT: - RNA_def_property_int_funcs(prop, "rna_IntProperty_default_get", NULL, NULL); - break; - case PROP_FLOAT: - RNA_def_property_float_funcs(prop, "rna_FloatProperty_default_get", NULL, NULL); - break; + case PROP_BOOLEAN: + RNA_def_property_boolean_funcs(prop, "rna_BoolProperty_default_get", NULL); + break; + case PROP_INT: + RNA_def_property_int_funcs(prop, "rna_IntProperty_default_get", NULL, NULL); + break; + case PROP_FLOAT: + RNA_def_property_float_funcs(prop, "rna_FloatProperty_default_get", NULL, NULL); + break; + default: + break; } diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 2066ebe18a9..209c771834d 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -30,6 +30,7 @@ #include "rna_internal.h" #include "DNA_scene_types.h" +#include "DNA_userdef_types.h" #ifdef WITH_FFMPEG #include "BKE_writeffmpeg.h" @@ -52,6 +53,7 @@ EnumPropertyItem prop_mode_items[] ={ #ifdef RNA_RUNTIME +#include "DNA_anim_types.h" #include "DNA_node_types.h" #include "BKE_context.h" @@ -60,6 +62,9 @@ EnumPropertyItem prop_mode_items[] ={ #include "BLI_threads.h" +#include "ED_info.h" +#include "ED_node.h" + #include "RE_pipeline.h" PointerRNA rna_Scene_objects_get(CollectionPropertyIterator *iter) @@ -174,6 +179,54 @@ static void rna_Scene_frame_update(bContext *C, PointerRNA *ptr) //ED_update_for_newframe(C); } +static int rna_Scene_active_keying_set_editable(PointerRNA *ptr) +{ + Scene *scene= (Scene *)ptr->data; + + /* only editable if there are some Keying Sets to change to */ + return (scene->keyingsets.first != NULL); +} + +static PointerRNA rna_Scene_active_keying_set_get(PointerRNA *ptr) +{ + Scene *scene= (Scene *)ptr->data; + return rna_pointer_inherit_refine(ptr, &RNA_KeyingSet, BLI_findlink(&scene->keyingsets, scene->active_keyingset-1)); +} + +static void rna_Scene_active_keying_set_set(PointerRNA *ptr, PointerRNA value) +{ + Scene *scene= (Scene *)ptr->data; + KeyingSet *ks= (KeyingSet*)value.data; + scene->active_keyingset= BLI_findindex(&scene->keyingsets, ks) + 1; +} + +static int rna_Scene_active_keying_set_index_get(PointerRNA *ptr) +{ + Scene *scene= (Scene *)ptr->data; + return MAX2(scene->active_keyingset-1, 0); +} + +static void rna_Scene_active_keying_set_index_set(PointerRNA *ptr, int value) +{ + Scene *scene= (Scene *)ptr->data; + scene->active_keyingset= value+1; +} + +static void rna_Scene_active_keying_set_index_range(PointerRNA *ptr, int *min, int *max) +{ + Scene *scene= (Scene *)ptr->data; + + *min= 0; + *max= BLI_countlist(&scene->keyingsets)-1; + *max= MAX2(0, *max); +} + + +static char *rna_SceneRenderData_path(PointerRNA *ptr) +{ + return BLI_sprintfN("render_data"); +} + static int rna_SceneRenderData_threads_get(PointerRNA *ptr) { RenderData *rd= (RenderData*)ptr->data; @@ -321,6 +374,15 @@ static void rna_SceneRenderLayer_pass_update(bContext *C, PointerRNA *ptr) ntreeCompositForceHidden(scene->nodetree, scene); } +void rna_Scene_use_nodes_set(PointerRNA *ptr, int value) +{ + Scene *scene= (Scene*)ptr->data; + + scene->use_nodes= value; + if(scene->use_nodes && scene->nodetree==NULL) + ED_node_composit_default(scene); +} + #else static void rna_def_tool_settings(BlenderRNA *brna) @@ -354,6 +416,11 @@ static void rna_def_tool_settings(BlenderRNA *brna) {SCE_SNAP_TARGET_MEDIAN, "MEDIAN", 0, "Median", "Snap median onto target."}, {SCE_SNAP_TARGET_ACTIVE, "ACTIVE", 0, "Active", "Snap active onto target."}, {0, NULL, 0, NULL, NULL}}; + + static EnumPropertyItem auto_key_items[] = { + {AUTOKEY_MODE_NORMAL, "ADD_REPLACE_KEYS", 0, "Add & Replace", ""}, + {AUTOKEY_MODE_EDITKEYS, "REPLACE_KEYS", 0, "Replace", ""}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "ToolSettings", NULL); RNA_def_struct_ui_text(srna, "Tool Settings", ""); @@ -416,6 +483,20 @@ static void rna_def_tool_settings(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "snap_flag", SCE_SNAP_PEEL_OBJECT); RNA_def_property_ui_text(prop, "Snap Peel Object", "Consider objects as whole when finding volume center."); RNA_def_property_ui_icon(prop, ICON_SNAP_PEEL_OBJECT, 0); + + /* Auto Keying */ + prop= RNA_def_property(srna, "enable_auto_key", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "autokey_mode", AUTOKEY_ON); + RNA_def_property_ui_text(prop, "Auto Keying", "Automatic keyframe insertion for Objects and Bones"); + + prop= RNA_def_property(srna, "autokey_mode", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "autokey_mode"); + RNA_def_property_enum_items(prop, auto_key_items); + RNA_def_property_ui_text(prop, "Auto-Keying Mode", "Mode of automatic keyframe insertion for Objects and Bones"); + + prop= RNA_def_property(srna, "record_with_nla", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "autokey_flag", ANIMRECORD_FLAG_WITHNLA); + RNA_def_property_ui_text(prop, "Layered", "Add a new NLA Track + Strip for every loop/pass made over the animation to allow non-destructive tweaking."); /* UV */ prop= RNA_def_property(srna, "uv_selection_mode", PROP_ENUM, PROP_NONE); @@ -443,6 +524,40 @@ static void rna_def_tool_settings(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Vertex Group Weight", "Weight to assign in vertex groups."); } + +static void rna_def_unit_settings(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + static EnumPropertyItem unit_systems[] = { + {USER_UNIT_NONE, "NONE", 0, "None", ""}, + {USER_UNIT_METRIC, "METRIC", 0, "Metric", ""}, + {USER_UNIT_IMPERIAL, "IMPERIAL", 0, "Imperial", ""}, + {0, NULL, 0, NULL, NULL}}; + + srna= RNA_def_struct(brna, "UnitSettings", NULL); + RNA_def_struct_ui_text(srna, "Unit Settings", ""); + + /* Units */ + prop= RNA_def_property(srna, "system", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, unit_systems); + RNA_def_property_ui_text(prop, "Unit System", "The unit system to use for button display."); + RNA_def_property_update(prop, NC_WINDOW, NULL); + + prop= RNA_def_property(srna, "scale_length", PROP_FLOAT, PROP_UNSIGNED); + RNA_def_property_ui_text(prop, "Unit Scale", "Scale to use when converting between blender units and dimensions."); + RNA_def_property_range(prop, 0.00001, 100000.0); + RNA_def_property_ui_range(prop, 0.001, 100.0, 0.1, 3); + RNA_def_property_update(prop, NC_WINDOW, NULL); + + prop= RNA_def_property(srna, "use_separate", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", USER_UNIT_OPT_SPLIT); + RNA_def_property_ui_text(prop, "Separate Units", "Display units in pairs."); + RNA_def_property_update(prop, NC_WINDOW, NULL); +} + + void rna_def_render_layer_common(StructRNA *srna, int scene) { PropertyRNA *prop; @@ -673,9 +788,9 @@ void rna_def_scene_game_data(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem framing_types_items[] ={ - {SCE_GAMEFRAMING_BARS, "BARS", 0, "Stretch", ""}, - {SCE_GAMEFRAMING_EXTEND, "EXTEND", 0, "Extend", ""}, - {SCE_GAMEFRAMING_SCALE, "SCALE", 0, "Scale", ""}, + {SCE_GAMEFRAMING_BARS, "LETTERBOX", 0, "Letterbox", "Show the entire viewport in the display window, using bar horizontally or vertically"}, + {SCE_GAMEFRAMING_EXTEND, "EXTEND", 0, "Extend", "Show the entire viewport in the display window, viewing more horizontally or vertically"}, + {SCE_GAMEFRAMING_SCALE, "SCALE", 0, "Scale", "Stretch or squeeze the viewport to fill the display window"}, {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem dome_modes_items[] ={ @@ -698,7 +813,7 @@ void rna_def_scene_game_data(BlenderRNA *brna) {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem stereo_items[] ={ - {STEREO_NOSTEREO, "NO_STEREO", 0, "No Stereo", ""}, + {STEREO_NOSTEREO, "NONE", 0, "None", ""}, {STEREO_ENABLED, "STEREO", 0, "Stereo", ""}, {STEREO_DOME, "DOME", 0, "Dome", ""}, {0, NULL, 0, NULL, NULL}}; @@ -712,6 +827,12 @@ void rna_def_scene_game_data(BlenderRNA *brna) {WOPHY_BULLET, "BULLET", 0, "Bullet", ""}, {0, NULL, 0, NULL, NULL}}; + static EnumPropertyItem material_items[] ={ + {GAME_MAT_TEXFACE, "TEXTURE_FACE", 0, "Texture Face", "Single texture face materials."}, + {GAME_MAT_MULTITEX, "MULTITEXTURE", 0, "Multitexture", "Multitexture materials."}, + {GAME_MAT_GLSL, "GLSL", 0, "GLSL", "OpenGL shading language shaders."}, + {0, NULL, 0, NULL, NULL}}; + srna= RNA_def_struct(brna, "SceneGameData", NULL); RNA_def_struct_sdna(srna, "GameData"); RNA_def_struct_nested(brna, srna, "Scene"); @@ -818,7 +939,7 @@ void rna_def_scene_game_data(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Physics Engine", "Physics engine used for physics simulation in the game engine."); RNA_def_property_update(prop, NC_SCENE, NULL); - prop= RNA_def_property(srna, "physics_gravity", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "physics_gravity", PROP_FLOAT, PROP_ACCELERATION); RNA_def_property_float_sdna(prop, NULL, "gravity"); RNA_def_property_range(prop, 0.0, 25.0); RNA_def_property_ui_text(prop, "Physics Gravity", "Gravitational constant used for physics simulation in the game engine."); @@ -876,6 +997,74 @@ void rna_def_scene_game_data(BlenderRNA *brna) RNA_def_property_range(prop, 0.0, 1000.0); RNA_def_property_ui_text(prop, "box radius", "Radius of the activity bubble, in Manhattan length. Objects outside the box are activity-culled"); RNA_def_property_update(prop, NC_SCENE, NULL); + + /* booleans */ + prop= RNA_def_property(srna, "all_frames", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GAME_ENABLE_ALL_FRAMES); + RNA_def_property_ui_text(prop, "All Frames", "Render as many frames as possible, rather than respecting framerate."); + RNA_def_property_update(prop, NC_SCENE, NULL); + + prop= RNA_def_property(srna, "show_debug_properties", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GAME_SHOW_DEBUG_PROPS); + RNA_def_property_ui_text(prop, "Show Debug Properties", "Show properties marked for debugging while the game runs."); + RNA_def_property_update(prop, NC_SCENE, NULL); + + prop= RNA_def_property(srna, "show_framerate_profile", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GAME_SHOW_FRAMERATE); + RNA_def_property_ui_text(prop, "Show Framerate and Profile", "Show framerate and profiling information while the game runs."); + RNA_def_property_update(prop, NC_SCENE, NULL); + + prop= RNA_def_property(srna, "show_physics_visualization", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GAME_SHOW_PHYSICS); + RNA_def_property_ui_text(prop, "Show Physics Visualization", "Show a visualization of physics bounds and interactions."); + RNA_def_property_update(prop, NC_SCENE, NULL); + + prop= RNA_def_property(srna, "display_lists", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GAME_DISPLAY_LISTS); + RNA_def_property_ui_text(prop, "Display Lists", "Use display lists to speed up rendering by keeping geometry on the GPU."); + RNA_def_property_update(prop, NC_SCENE, NULL); + + prop= RNA_def_property(srna, "deprecation_warnings", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", GAME_IGNORE_DEPRECATION_WARNINGS); + RNA_def_property_ui_text(prop, "Deprecation Warnings", "Print warnings when using deprecated features in the python API."); + RNA_def_property_update(prop, NC_SCENE, NULL); + + /* materials */ + prop= RNA_def_property(srna, "material_mode", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "matmode"); + RNA_def_property_enum_items(prop, material_items); + RNA_def_property_ui_text(prop, "Material Mode", "Material mode to use for rendering."); + RNA_def_property_update(prop, NC_SCENE, NULL); + + prop= RNA_def_property(srna, "glsl_lights", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", GAME_GLSL_NO_LIGHTS); + RNA_def_property_ui_text(prop, "GLSL Lights", "Use lights for GLSL rendering."); + RNA_def_property_update(prop, NC_SCENE, NULL); + + prop= RNA_def_property(srna, "glsl_shaders", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", GAME_GLSL_NO_SHADERS); + RNA_def_property_ui_text(prop, "GLSL Shaders", "Use shaders for GLSL rendering."); + RNA_def_property_update(prop, NC_SCENE, NULL); + + prop= RNA_def_property(srna, "glsl_shadows", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", GAME_GLSL_NO_SHADOWS); + RNA_def_property_ui_text(prop, "GLSL Shadows", "Use shadows for GLSL rendering."); + RNA_def_property_update(prop, NC_SCENE, NULL); + + prop= RNA_def_property(srna, "glsl_ramps", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", GAME_GLSL_NO_RAMPS); + RNA_def_property_ui_text(prop, "GLSL Ramps", "Use ramps for GLSL rendering."); + RNA_def_property_update(prop, NC_SCENE, NULL); + + prop= RNA_def_property(srna, "glsl_nodes", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", GAME_GLSL_NO_NODES); + RNA_def_property_ui_text(prop, "GLSL Nodes", "Use nodes for GLSL rendering."); + RNA_def_property_update(prop, NC_SCENE, NULL); + + prop= RNA_def_property(srna, "glsl_extra_textures", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", GAME_GLSL_NO_EXTRA_TEX); + RNA_def_property_ui_text(prop, "GLSL Extra Textures", "Use extra textures like normal or specular maps for GLSL rendering."); + RNA_def_property_update(prop, NC_SCENE, NULL); } static void rna_def_scene_render_layer(BlenderRNA *brna) @@ -955,27 +1144,28 @@ static void rna_def_scene_render_data(BlenderRNA *brna) static EnumPropertyItem image_type_items[] = { + {0, "", 0, "Image", NULL}, {R_PNG, "PNG", 0, "PNG", ""}, {R_JPEG90, "JPEG", 0, "JPEG", ""}, #ifdef WITH_OPENJPEG {R_JP2, "JPEG2000", 0, "JPEG 2000", ""}, #endif - {R_TIFF, "TIFF", 0, "TIFF", ""}, // XXX only with G.have_libtiff {R_BMP, "BMP", 0, "BMP", ""}, {R_TARGA, "TARGA", 0, "Targa", ""}, {R_RAWTGA, "RAWTARGA", 0, "Targa Raw", ""}, //{R_DDS, "DDS", 0, "DDS", ""}, // XXX not yet implemented {R_HAMX, "HAMX", 0, "HamX", ""}, {R_IRIS, "IRIS", 0, "Iris", ""}, - {0, "", 0, NULL, NULL}, + {0, "", 0, " ", NULL}, #ifdef WITH_OPENEXR {R_OPENEXR, "OPENEXR", 0, "OpenEXR", ""}, {R_MULTILAYER, "MULTILAYER", 0, "MultiLayer", ""}, #endif + {R_TIFF, "TIFF", 0, "TIFF", ""}, // XXX only with G.have_libtiff {R_RADHDR, "RADHDR", 0, "Radiance HDR", ""}, {R_CINEON, "CINEON", 0, "Cineon", ""}, {R_DPX, "DPX", 0, "DPX", ""}, - {0, "", 0, NULL, NULL}, + {0, "", 0, "Movie", NULL}, {R_AVIRAW, "AVIRAW", 0, "AVI Raw", ""}, {R_AVIJPEG, "AVIJPEG", 0, "AVI JPEG", ""}, #ifdef _WIN32 @@ -998,7 +1188,6 @@ static void rna_def_scene_render_data(BlenderRNA *brna) #endif {R_FFMPEG, "FFMPEG", 0, "FFMpeg", ""}, #endif - {0, "", 0, NULL, NULL}, {R_FRAMESERVER, "FRAMESERVER", 0, "Frame Server", ""}, {0, NULL, 0, NULL, NULL}}; @@ -1081,6 +1270,7 @@ static void rna_def_scene_render_data(BlenderRNA *brna) srna= RNA_def_struct(brna, "SceneRenderData", NULL); RNA_def_struct_sdna(srna, "RenderData"); RNA_def_struct_nested(brna, srna, "Scene"); + RNA_def_struct_path_func(srna, "rna_SceneRenderData_path"); RNA_def_struct_ui_text(srna, "Render Data", "Rendering settings for a Scene datablock."); prop= RNA_def_property(srna, "color_mode", PROP_ENUM, PROP_NONE); @@ -1365,6 +1555,11 @@ static void rna_def_scene_render_data(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Fields Still", "Disable the time difference between fields."); RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + prop= RNA_def_property(srna, "sync_audio", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "audio.flag", AUDIO_SYNC); + RNA_def_property_ui_text(prop, "Sync Audio", "Play back and sync with audio from Sequence Editor"); + RNA_def_property_update(prop, NC_SCENE, NULL); + prop= RNA_def_property(srna, "render_shadows", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "mode", R_SHADOW); RNA_def_property_ui_text(prop, "Render Shadows", "Calculate shadows while rendering."); @@ -1480,7 +1675,12 @@ static void rna_def_scene_render_data(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "scemode", R_FREE_IMAGE); RNA_def_property_ui_text(prop, "Free Image Textures", "Free all image texture from memory after render, to save memory before compositing."); RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); - + + prop= RNA_def_property(srna, "free_unused_nodes", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "scemode", R_FREE_IMAGE); + RNA_def_property_ui_text(prop, "Free Unused Nodes", "Free Nodes that are not used while compositing, to save memory."); + RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + prop= RNA_def_property(srna, "save_buffers", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "scemode", R_EXR_TILE_FILE); RNA_def_property_boolean_funcs(prop, "rna_SceneRenderData_save_buffers_get", NULL); @@ -1624,6 +1824,7 @@ void RNA_def_scene(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; + FunctionRNA *func; /* Struct definition */ srna= RNA_def_struct(brna, "Scene", "ID"); @@ -1641,7 +1842,7 @@ void RNA_def_scene(BlenderRNA *brna) RNA_def_property_ui_text(prop, "World", "World used for rendering the scene."); RNA_def_property_update(prop, NC_WORLD, NULL); - prop= RNA_def_property(srna, "cursor_location", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "cursor_location", PROP_FLOAT, PROP_XYZ|PROP_UNIT_LENGTH); RNA_def_property_float_sdna(prop, NULL, "cursor"); RNA_def_property_ui_text(prop, "Cursor Location", "3D cursor location."); RNA_def_property_ui_range(prop, -10000.0, 10000.0, 10, 4); @@ -1663,28 +1864,28 @@ void RNA_def_scene(BlenderRNA *brna) /* Frame Range Stuff */ - prop= RNA_def_property(srna, "current_frame", PROP_INT, PROP_NONE); + prop= RNA_def_property(srna, "current_frame", PROP_INT, PROP_TIME); RNA_def_property_clear_flag(prop, PROP_ANIMATEABLE); RNA_def_property_int_sdna(prop, NULL, "r.cfra"); RNA_def_property_range(prop, MINAFRAME, MAXFRAME); RNA_def_property_ui_text(prop, "Current Frame", ""); RNA_def_property_update(prop, NC_SCENE|ND_FRAME, "rna_Scene_frame_update"); - prop= RNA_def_property(srna, "start_frame", PROP_INT, PROP_NONE); + prop= RNA_def_property(srna, "start_frame", PROP_INT, PROP_TIME); RNA_def_property_clear_flag(prop, PROP_ANIMATEABLE); RNA_def_property_int_sdna(prop, NULL, "r.sfra"); RNA_def_property_int_funcs(prop, NULL, "rna_Scene_start_frame_set", NULL); RNA_def_property_ui_text(prop, "Start Frame", ""); RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); - prop= RNA_def_property(srna, "end_frame", PROP_INT, PROP_NONE); + prop= RNA_def_property(srna, "end_frame", PROP_INT, PROP_TIME); RNA_def_property_clear_flag(prop, PROP_ANIMATEABLE); RNA_def_property_int_sdna(prop, NULL, "r.efra"); RNA_def_property_int_funcs(prop, NULL, "rna_Scene_end_frame_set", NULL); RNA_def_property_ui_text(prop, "End Frame", ""); RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); - prop= RNA_def_property(srna, "frame_step", PROP_INT, PROP_NONE); + prop= RNA_def_property(srna, "frame_step", PROP_INT, PROP_TIME); RNA_def_property_clear_flag(prop, PROP_ANIMATEABLE); RNA_def_property_int_sdna(prop, NULL, "frame_step"); RNA_def_property_ui_text(prop, "Frame Step", "Number of frames to skip forward while rendering/playing back each frame"); @@ -1697,14 +1898,14 @@ void RNA_def_scene(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Use Preview Range", ""); RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); - prop= RNA_def_property(srna, "preview_range_start_frame", PROP_INT, PROP_NONE); + prop= RNA_def_property(srna, "preview_range_start_frame", PROP_INT, PROP_TIME); RNA_def_property_clear_flag(prop, PROP_ANIMATEABLE); RNA_def_property_int_sdna(prop, NULL, "r.psfra"); RNA_def_property_int_funcs(prop, NULL, "rna_Scene_preview_range_start_frame_set", NULL); RNA_def_property_ui_text(prop, "Preview Range Start Frame", ""); RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); - prop= RNA_def_property(srna, "preview_range_end_frame", PROP_INT, PROP_NONE); + prop= RNA_def_property(srna, "preview_range_end_frame", PROP_INT, PROP_TIME); RNA_def_property_clear_flag(prop, PROP_ANIMATEABLE); RNA_def_property_int_sdna(prop, NULL, "r.pefra"); RNA_def_property_int_funcs(prop, NULL, "rna_Scene_preview_range_end_frame_set", NULL); @@ -1720,6 +1921,12 @@ void RNA_def_scene(BlenderRNA *brna) /* Nodes (Compositing) */ prop= RNA_def_property(srna, "nodetree", PROP_POINTER, PROP_NONE); RNA_def_property_ui_text(prop, "Node Tree", "Compositing node tree."); + + prop= RNA_def_property(srna, "use_nodes", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "use_nodes", 1); + RNA_def_property_boolean_funcs(prop, NULL, "rna_Scene_use_nodes_set"); + RNA_def_property_ui_text(prop, "Use Nodes", "Enable the compositing node tree."); + RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); /* Sequencer */ prop= RNA_def_property(srna, "sequence_editor", PROP_POINTER, PROP_NONE); @@ -1728,24 +1935,40 @@ void RNA_def_scene(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Sequence Editor", ""); /* Keying Sets */ - // TODO: hide the fact that active keyingset is an int? - prop= RNA_def_property(srna, "keyingsets", PROP_COLLECTION, PROP_NONE); + prop= RNA_def_property(srna, "keying_sets", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "keyingsets", NULL); RNA_def_property_struct_type(prop, "KeyingSet"); RNA_def_property_ui_text(prop, "Keying Sets", "Keying Sets for this Scene."); + RNA_def_property_update(prop, NC_SCENE|ND_KEYINGSET, NULL); - prop= RNA_def_property(srna, "active_keyingset", PROP_INT, PROP_NONE); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Active Keying Set", "Current Keying Set index."); + prop= RNA_def_property(srna, "active_keying_set", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "KeyingSet"); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_editable_func(prop, "rna_Scene_active_keying_set_editable"); + RNA_def_property_pointer_funcs(prop, "rna_Scene_active_keying_set_get", "rna_Scene_active_keying_set_set", NULL); + RNA_def_property_ui_text(prop, "Active Keying Set", "Active Keying Set used to insert/delete keyframes."); + RNA_def_property_update(prop, NC_SCENE|ND_KEYINGSET, NULL); + + prop= RNA_def_property(srna, "active_keying_set_index", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "active_keyingset"); + RNA_def_property_int_funcs(prop, "rna_Scene_active_keying_set_index_get", "rna_Scene_active_keying_set_index_set", "rna_Scene_active_keying_set_index_range"); + RNA_def_property_ui_text(prop, "Active Keying Set Index", "Current Keying Set index."); + RNA_def_property_update(prop, NC_SCENE|ND_KEYINGSET, NULL); /* Tool Settings */ - prop= RNA_def_property(srna, "tool_settings", PROP_POINTER, PROP_NONE); + prop= RNA_def_property(srna, "tool_settings", PROP_POINTER, PROP_NEVER_NULL); RNA_def_property_pointer_sdna(prop, NULL, "toolsettings"); RNA_def_property_struct_type(prop, "ToolSettings"); RNA_def_property_ui_text(prop, "Tool Settings", ""); + + /* Unit Settings */ + prop= RNA_def_property(srna, "unit_settings", PROP_POINTER, PROP_NEVER_NULL); + RNA_def_property_pointer_sdna(prop, NULL, "unit"); + RNA_def_property_struct_type(prop, "UnitSettings"); + RNA_def_property_ui_text(prop, "Unit Settings", "Unit editing settings"); /* Render Data */ - prop= RNA_def_property(srna, "render_data", PROP_POINTER, PROP_NONE); + prop= RNA_def_property(srna, "render_data", PROP_POINTER, PROP_NEVER_NULL); RNA_def_property_pointer_sdna(prop, NULL, "r"); RNA_def_property_struct_type(prop, "SceneRenderData"); RNA_def_property_ui_text(prop, "Render Data", ""); @@ -1757,15 +1980,24 @@ void RNA_def_scene(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Timeline Markers", "Markers used in all timelines for the current scene."); /* Game Settings */ - prop= RNA_def_property(srna, "game_data", PROP_POINTER, PROP_NONE); + prop= RNA_def_property(srna, "game_data", PROP_POINTER, PROP_NEVER_NULL); RNA_def_property_pointer_sdna(prop, NULL, "gm"); RNA_def_property_struct_type(prop, "SceneGameData"); RNA_def_property_ui_text(prop, "Game Data", ""); + + /* Statistics */ + func= RNA_def_function(srna, "statistics", "ED_info_stats_string"); + prop= RNA_def_string(func, "statistics", "", 0, "Statistics", ""); + RNA_def_function_return(func, prop); rna_def_tool_settings(brna); + rna_def_unit_settings(brna); rna_def_scene_render_data(brna); rna_def_scene_game_data(brna); rna_def_scene_render_layer(brna); + + /* Scene API */ + RNA_api_scene(srna); } #endif diff --git a/source/blender/makesrna/intern/rna_scene_api.c b/source/blender/makesrna/intern/rna_scene_api.c new file mode 100644 index 00000000000..26047ab5dc3 --- /dev/null +++ b/source/blender/makesrna/intern/rna_scene_api.c @@ -0,0 +1,100 @@ +/** + * $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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2009 Blender Foundation. + * All rights reserved. + * + * + * Contributor(s): Joshua Leung + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include <stdlib.h> +#include <stdio.h> + +#include "RNA_define.h" +#include "RNA_enum_types.h" +#include "RNA_types.h" + +#include "DNA_anim_types.h" +#include "DNA_object_types.h" +#include "DNA_scene_types.h" + +#ifdef RNA_RUNTIME + +#include "BKE_animsys.h" + +// Scene API stuff from kazanbas branch here... + + +static KeyingSet *rna_Scene_add_keying_set(Scene *sce, ReportList *reports, + char name[], int absolute, int insertkey_needed, int insertkey_visual) +{ + KeyingSet *ks= NULL; + short flag=0, keyingflag=0; + + /* validate flags */ + if (absolute) + flag |= KEYINGSET_ABSOLUTE; + if (insertkey_needed) + keyingflag |= INSERTKEY_NEEDED; + if (insertkey_visual) + keyingflag |= INSERTKEY_MATRIX; + + /* call the API func, and set the active keyingset index */ + ks= BKE_keyingset_add(&sce->keyingsets, name, flag, keyingflag); + + if (ks) { + sce->active_keyingset= BLI_countlist(&sce->keyingsets); + return ks; + } + else { + BKE_report(reports, RPT_ERROR, "Keying Set could not be added."); + return NULL; + } +} + +#else + +void RNA_api_scene(StructRNA *srna) +{ + FunctionRNA *func; + PropertyRNA *parm; + + // Scene API stuff from kazanbas branch here... + + /* Add Keying Set */ + func= RNA_def_function(srna, "add_keying_set", "rna_Scene_add_keying_set"); + RNA_def_function_ui_description(func, "Add a new Keying Set to Scene."); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + /* returns the new KeyingSet */ + parm= RNA_def_pointer(func, "keyingset", "KeyingSet", "", "Newly created Keying Set."); + RNA_def_function_return(func, parm); + /* name */ + RNA_def_string(func, "name", "KeyingSet", 64, "Name", "Name of Keying Set"); + /* flags */ + RNA_def_boolean(func, "absolute", 1, "Absolute", "Keying Set defines specific paths/settings to be keyframed (i.e. is not reliant on context info)"); + /* keying flags */ + RNA_def_boolean(func, "insertkey_needed", 0, "Insert Keyframes - Only Needed", "Only insert keyframes where they're needed in the relevant F-Curves."); + RNA_def_boolean(func, "insertkey_visual", 0, "Insert Keyframes - Visual", "Insert keyframes based on 'visual transforms'."); +} + +#endif + diff --git a/source/blender/makesrna/intern/rna_screen.c b/source/blender/makesrna/intern/rna_screen.c index e3171d38932..7a243327bd1 100644 --- a/source/blender/makesrna/intern/rna_screen.c +++ b/source/blender/makesrna/intern/rna_screen.c @@ -71,9 +71,15 @@ static void rna_Screen_scene_update(bContext *C, PointerRNA *ptr) } } +static int rna_Screen_animation_playing_get(PointerRNA *ptr) +{ + bScreen *sc= (bScreen*)ptr->data; + return (sc->animtimer != NULL); +} + #else -static void rna_def_scrarea(BlenderRNA *brna) +static void rna_def_area(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; @@ -119,7 +125,7 @@ static void rna_def_region(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Region ID", "Uniqute ID for this region."); } -static void rna_def_bscreen(BlenderRNA *brna) +static void rna_def_screen(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; @@ -139,12 +145,17 @@ static void rna_def_bscreen(BlenderRNA *brna) RNA_def_property_collection_sdna(prop, NULL, "areabase", NULL); RNA_def_property_struct_type(prop, "Area"); RNA_def_property_ui_text(prop, "Areas", "Areas the screen is subdivided into."); + + prop= RNA_def_property(srna, "animation_playing", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_boolean_funcs(prop, "rna_Screen_animation_playing_get", NULL); + RNA_def_property_ui_text(prop, "Animation Playing", "Animation playback is active."); } void RNA_def_screen(BlenderRNA *brna) { - rna_def_bscreen(brna); - rna_def_scrarea(brna); + rna_def_screen(brna); + rna_def_area(brna); rna_def_region(brna); } diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c index 1e512d8f9bb..c2c906e38f2 100644 --- a/source/blender/makesrna/intern/rna_sculpt_paint.c +++ b/source/blender/makesrna/intern/rna_sculpt_paint.c @@ -31,6 +31,8 @@ #include "DNA_scene_types.h" +#include "BKE_paint.h" + #ifdef RNA_RUNTIME static PointerRNA rna_ParticleEdit_brush_get(PointerRNA *ptr) @@ -49,20 +51,67 @@ static PointerRNA rna_ParticleBrush_curve_get(PointerRNA *ptr) return rna_pointer_inherit_refine(ptr, &RNA_CurveMapping, NULL); } +static void rna_Paint_brushes_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) +{ + Paint *p= (Paint*)ptr->data; + rna_iterator_array_begin(iter, (void*)p->brushes, sizeof(Brush*), p->brush_count, 0, NULL); +} + +static int rna_Paint_brushes_length(PointerRNA *ptr) +{ + Paint *p= (Paint*)ptr->data; + + return p->brush_count; +} + +static PointerRNA rna_Paint_active_brush_get(PointerRNA *ptr) +{ + return rna_pointer_inherit_refine(ptr, &RNA_Brush, paint_brush(ptr->data)); +} + +static void rna_Paint_active_brush_set(PointerRNA *ptr, PointerRNA value) +{ + paint_brush_set(ptr->data, value.data); +} + #else -static void rna_def_sculpt(BlenderRNA *brna) +static void rna_def_paint(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; - srna= RNA_def_struct(brna, "Sculpt", NULL); - RNA_def_struct_ui_text(srna, "Sculpt", ""); - + srna= RNA_def_struct(brna, "Paint", NULL); + RNA_def_struct_ui_text(srna, "Paint", ""); + + prop= RNA_def_property(srna, "brushes", PROP_COLLECTION, PROP_NONE); + RNA_def_property_struct_type(prop, "Brush"); + RNA_def_property_collection_funcs(prop, "rna_Paint_brushes_begin", + "rna_iterator_array_next", + "rna_iterator_array_end", + "rna_iterator_array_dereference_get", + "rna_Paint_brushes_length", 0, 0, 0, 0); + RNA_def_property_ui_text(prop, "Brushes", "Brushes selected for this paint mode."); + + prop= RNA_def_property(srna, "active_brush_index", PROP_INT, PROP_NONE); + RNA_def_property_range(prop, 0, INT_MAX); + + /* Fake property to get active brush directly, rather than integer index */ prop= RNA_def_property(srna, "brush", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "Brush"); - RNA_def_property_ui_text(prop, "Brush", ""); + RNA_def_property_pointer_funcs(prop, "rna_Paint_active_brush_get", "rna_Paint_active_brush_set", NULL); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Brush", "Active paint brush."); +} + +static void rna_def_sculpt(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + srna= RNA_def_struct(brna, "Sculpt", "Paint"); + RNA_def_struct_ui_text(srna, "Sculpt", ""); + prop= RNA_def_property(srna, "symmetry_x", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flags", SCULPT_SYMM_X); RNA_def_property_ui_text(prop, "Symmetry X", "Mirror brush across the X axis."); @@ -110,14 +159,10 @@ static void rna_def_vertex_paint(BlenderRNA *brna) {6, "DARKEN", 0, "Darken", "Use darken blending mode while painting."}, {0, NULL, 0, NULL, NULL}}; - srna= RNA_def_struct(brna, "VertexPaint", NULL); + srna= RNA_def_struct(brna, "VertexPaint", "Paint"); RNA_def_struct_sdna(srna, "VPaint"); RNA_def_struct_ui_text(srna, "Vertex Paint", "Properties of vertex and weight paint mode."); - prop= RNA_def_property(srna, "brush", PROP_POINTER, PROP_NONE); - RNA_def_property_struct_type(prop, "Brush"); - RNA_def_property_ui_text(prop, "Brush", ""); - prop= RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, prop_mode_items); RNA_def_property_ui_text(prop, "Brush Mode", "Mode in which color is painted."); @@ -159,14 +204,10 @@ static void rna_def_image_paint(BlenderRNA *brna) {PAINT_TOOL_CLONE, "CLONE", 0, "Clone", ""}, {0, NULL, 0, NULL, NULL}}; - srna= RNA_def_struct(brna, "ImagePaint", NULL); + srna= RNA_def_struct(brna, "ImagePaint", "Paint"); RNA_def_struct_sdna(srna, "ImagePaintSettings"); RNA_def_struct_ui_text(srna, "Image Paint", "Properties of image and texture painting mode."); - prop= RNA_def_property(srna, "brush", PROP_POINTER, PROP_NONE); - RNA_def_property_struct_type(prop, "Brush"); - RNA_def_property_ui_text(prop, "Brush", ""); - prop= RNA_def_property(srna, "tool", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, tool_items); RNA_def_property_ui_text(prop, "Tool", ""); @@ -353,6 +394,7 @@ static void rna_def_particle_edit(BlenderRNA *brna) void RNA_def_sculpt_paint(BlenderRNA *brna) { + rna_def_paint(brna); rna_def_sculpt(brna); rna_def_vertex_paint(brna); rna_def_image_paint(brna); diff --git a/source/blender/makesrna/intern/rna_sequence.c b/source/blender/makesrna/intern/rna_sequence.c index 8ca023dc57c..470909f4eff 100644 --- a/source/blender/makesrna/intern/rna_sequence.c +++ b/source/blender/makesrna/intern/rna_sequence.c @@ -192,10 +192,8 @@ static StructRNA* rna_Sequence_refine(struct PointerRNA *ptr) case SEQ_SCENE: return &RNA_SceneSequence; case SEQ_MOVIE: - case SEQ_MOVIE_AND_HD_SOUND: return &RNA_MovieSequence; - case SEQ_RAM_SOUND: - case SEQ_HD_SOUND: + case SEQ_SOUND: return &RNA_SoundSequence; case SEQ_CROSS: case SEQ_ADD: @@ -362,9 +360,7 @@ static void rna_def_sequence(BlenderRNA *brna) {SEQ_META, "META", 0, "Meta", ""}, {SEQ_SCENE, "SCENE", 0, "Scene", ""}, {SEQ_MOVIE, "MOVIE", 0, "Movie", ""}, - {SEQ_RAM_SOUND, "RAM_SOUND", 0, "Ram Sound", ""}, - {SEQ_HD_SOUND, "HD_SOUND", 0, "HD Sound", ""}, - {SEQ_MOVIE_AND_HD_SOUND, "MOVIE_AND_HD_SOUND", 0, "Movie and HD Sound", ""}, + {SEQ_SOUND, "_SOUND", 0, "Sound", ""}, {SEQ_EFFECT, "REPLACE", 0, "Replace", ""}, {SEQ_CROSS, "CROSS", 0, "Cross", ""}, {SEQ_ADD, "ADD", 0, "Add", ""}, @@ -442,38 +438,39 @@ static void rna_def_sequence(BlenderRNA *brna) /* strip positioning */ - prop= RNA_def_property(srna, "length", PROP_INT, PROP_UNSIGNED); + prop= RNA_def_property(srna, "length", PROP_INT, PROP_TIME); RNA_def_property_int_sdna(prop, NULL, "len"); RNA_def_property_range(prop, 1, MAXFRAME); RNA_def_property_ui_text(prop, "Length", "The length of the contents of this strip before the handles are applied"); RNA_def_property_int_funcs(prop, "rna_SequenceEditor_length_get", "rna_SequenceEditor_length_set",NULL); - - prop= RNA_def_property(srna, "start_frame", PROP_INT, PROP_UNSIGNED); + RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); + + prop= RNA_def_property(srna, "start_frame", PROP_INT, PROP_TIME); RNA_def_property_int_sdna(prop, NULL, "start"); RNA_def_property_ui_text(prop, "Start Frame", ""); RNA_def_property_int_funcs(prop, NULL, "rna_SequenceEditor_start_frame_set",NULL); // overlap tests and calc_seq_disp RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); - prop= RNA_def_property(srna, "start_offset", PROP_INT, PROP_UNSIGNED); + prop= RNA_def_property(srna, "start_offset", PROP_INT, PROP_TIME); RNA_def_property_int_sdna(prop, NULL, "startofs"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); // overlap tests RNA_def_property_ui_text(prop, "Start Offset", ""); RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); - prop= RNA_def_property(srna, "end_offset", PROP_INT, PROP_UNSIGNED); + prop= RNA_def_property(srna, "end_offset", PROP_INT, PROP_TIME); RNA_def_property_int_sdna(prop, NULL, "endofs"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); // overlap tests RNA_def_property_ui_text(prop, "End offset", ""); RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); - prop= RNA_def_property(srna, "start_still", PROP_INT, PROP_UNSIGNED); + prop= RNA_def_property(srna, "start_still", PROP_INT, PROP_TIME); RNA_def_property_int_sdna(prop, NULL, "startstill"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); // overlap tests RNA_def_property_range(prop, 0, MAXFRAME); RNA_def_property_ui_text(prop, "Start Still", ""); RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); - prop= RNA_def_property(srna, "end_still", PROP_INT, PROP_UNSIGNED); + prop= RNA_def_property(srna, "end_still", PROP_INT, PROP_TIME); RNA_def_property_int_sdna(prop, NULL, "endstill"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); // overlap tests RNA_def_property_range(prop, 0, MAXFRAME); @@ -616,21 +613,6 @@ static void rna_def_filter_video(StructRNA *srna) RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); } -static void rna_def_filter_sound(StructRNA *srna) -{ - PropertyRNA *prop; - - prop= RNA_def_property(srna, "sound_gain", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "level"); - RNA_def_property_range(prop, -96.0f, 6.0f); - RNA_def_property_ui_text(prop, "Sound Gain", "Sound level in dB (0 = full volume)."); - - prop= RNA_def_property(srna, "sound_pan", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "pan"); - RNA_def_property_range(prop, -1.0f, 1.0f); - RNA_def_property_ui_text(prop, "Sound Pan", "Stereo sound balance."); -} - static void rna_def_proxy(StructRNA *srna) { PropertyRNA *prop; @@ -657,11 +639,13 @@ static void rna_def_input(StructRNA *srna) RNA_def_property_int_sdna(prop, NULL, "anim_startofs"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); // overlap test RNA_def_property_ui_text(prop, "Animation Start Offset", "Animation start offset (trim start)."); + RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); prop= RNA_def_property(srna, "animation_end_offset", PROP_INT, PROP_UNSIGNED); RNA_def_property_int_sdna(prop, NULL, "anim_endofs"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); // overlap test RNA_def_property_ui_text(prop, "Animation End Offset", "Animation end offset (trim end)."); + RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); } static void rna_def_image(BlenderRNA *brna) @@ -761,7 +745,7 @@ static void rna_def_sound(BlenderRNA *brna) RNA_def_struct_sdna(srna, "Sequence"); prop= RNA_def_property(srna, "sound", PROP_POINTER, PROP_NONE); - RNA_def_property_struct_type(prop, "UnknownType"); + RNA_def_property_struct_type(prop, "Sound"); RNA_def_property_ui_text(prop, "Sound", "Sound datablock used by this sequence (RAM audio only)."); prop= RNA_def_property(srna, "filename", PROP_STRING, PROP_FILEPATH); @@ -772,7 +756,6 @@ static void rna_def_sound(BlenderRNA *brna) RNA_def_property_string_sdna(prop, NULL, "strip->dir"); RNA_def_property_ui_text(prop, "Directory", ""); - rna_def_filter_sound(srna); rna_def_input(srna); } @@ -833,21 +816,25 @@ static void rna_def_wipe(BlenderRNA *brna) RNA_def_property_float_sdna(prop, NULL, "edgeWidth"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Blur Width", "Width of the blur edge, in percentage relative to the image size."); + RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); prop= RNA_def_property(srna, "angle", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "angle"); RNA_def_property_range(prop, -90.0f, 90.0f); RNA_def_property_ui_text(prop, "Angle", "Edge angle."); + RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); prop= RNA_def_property(srna, "direction", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "forward"); RNA_def_property_enum_items(prop, wipe_direction_items); RNA_def_property_ui_text(prop, "Direction", "Wipe direction."); + RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); prop= RNA_def_property(srna, "transition_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "wipetype"); RNA_def_property_enum_items(prop, wipe_type_items); RNA_def_property_ui_text(prop, "Transition Type", ""); + RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); } static void rna_def_glow(BlenderRNA *brna) @@ -863,30 +850,36 @@ static void rna_def_glow(BlenderRNA *brna) RNA_def_property_float_sdna(prop, NULL, "fMini"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Threshold", "Minimum intensity to trigger a glow"); + RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); prop= RNA_def_property(srna, "clamp", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "fClamp"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Clamp", "rightness limit of intensity."); + RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); prop= RNA_def_property(srna, "boost_factor", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "fBoost"); RNA_def_property_range(prop, 0.0f, 10.0f); RNA_def_property_ui_text(prop, "Boost Factor", "Brightness multiplier."); + RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); prop= RNA_def_property(srna, "blur_distance", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "dDist"); RNA_def_property_range(prop, 0.5f, 20.0f); RNA_def_property_ui_text(prop, "Blur Distance", "Radius of glow effect."); + RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); prop= RNA_def_property(srna, "quality", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "dQuality"); RNA_def_property_range(prop, 1, 5); RNA_def_property_ui_text(prop, "Quality", "Accuracy of the blur effect."); + RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); prop= RNA_def_property(srna, "only_boost", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "bNoComp", 0); RNA_def_property_ui_text(prop, "Only Boost", "Show the glow buffer only."); + RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); } static void rna_def_transform(BlenderRNA *brna) @@ -915,60 +908,72 @@ static void rna_def_transform(BlenderRNA *brna) RNA_def_property_float_sdna(prop, NULL, "ScalexIni"); RNA_def_property_ui_text(prop, "Scale Start X", ""); RNA_def_property_ui_range(prop, 0, 10, 3, 10); + RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); prop= RNA_def_property(srna, "scale_start_y", PROP_FLOAT, PROP_UNSIGNED); RNA_def_property_float_sdna(prop, NULL, "ScaleyIni"); RNA_def_property_ui_text(prop, "Scale Start Y", ""); RNA_def_property_ui_range(prop, 0, 10, 3, 10); - + RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); + prop= RNA_def_property(srna, "scale_end_x", PROP_FLOAT, PROP_UNSIGNED); RNA_def_property_float_sdna(prop, NULL, "ScalexFin"); RNA_def_property_ui_text(prop, "Scale End X", ""); RNA_def_property_ui_range(prop, 0, 10, 3, 10); + RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); prop= RNA_def_property(srna, "scale_end_y", PROP_FLOAT, PROP_UNSIGNED); RNA_def_property_float_sdna(prop, NULL, "ScaleyFin"); RNA_def_property_ui_text(prop, "Scale End Y", ""); RNA_def_property_ui_range(prop, 0, 10, 3, 10); + RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); prop= RNA_def_property(srna, "translate_start_x", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "xIni"); RNA_def_property_ui_text(prop, "Translate Start X", ""); RNA_def_property_ui_range(prop, -500.0f, 500.0f, 3, 10); - + RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); + prop= RNA_def_property(srna, "translate_start_y", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "yIni"); RNA_def_property_ui_text(prop, "Translate Start Y", ""); RNA_def_property_ui_range(prop, -500.0f, 500.0f, 3, 10); - + RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); + prop= RNA_def_property(srna, "translate_end_x", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "xFin"); RNA_def_property_ui_text(prop, "Translate End X", ""); RNA_def_property_ui_range(prop, -500.0f, 500.0f, 3, 10); + RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); prop= RNA_def_property(srna, "translate_end_y", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "yFin"); RNA_def_property_ui_text(prop, "Translate End Y", ""); RNA_def_property_ui_range(prop, -500.0f, 500.0f, 3, 10); + RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); prop= RNA_def_property(srna, "rotation_start", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "rotIni"); RNA_def_property_range(prop, 0.0f, 360.0f); RNA_def_property_ui_text(prop, "Rotation Start", ""); + RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); prop= RNA_def_property(srna, "rotation_end", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "rotFin"); RNA_def_property_range(prop, 0.0f, 360.0f); RNA_def_property_ui_text(prop, "Rotation End", ""); + RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); prop= RNA_def_property(srna, "translation_unit", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "percent"); RNA_def_property_enum_items(prop, translation_unit_items); RNA_def_property_ui_text(prop, "Translation Unit", ""); + RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); prop= RNA_def_property(srna, "interpolation", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, interpolation_items); RNA_def_property_ui_text(prop, "Interpolation", ""); + RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); } static void rna_def_solid_color(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_smoke.c b/source/blender/makesrna/intern/rna_smoke.c index cedbc992dde..d7c70d8b9e9 100644 --- a/source/blender/makesrna/intern/rna_smoke.c +++ b/source/blender/makesrna/intern/rna_smoke.c @@ -46,6 +46,7 @@ #include "BKE_context.h" #include "BKE_depsgraph.h" #include "BKE_particle.h" +#include "BKE_pointcache.h" #include "ED_object.h" @@ -78,12 +79,14 @@ static void rna_Smoke_reset_dependancy(bContext *C, PointerRNA *ptr) rna_Smoke_dependency_update(C, ptr); } +#if 0 static void rna_Smoke_redraw(bContext *C, PointerRNA *ptr) { SmokeDomainSettings *settings = (SmokeDomainSettings*)ptr->data; settings->flags |= MOD_SMOKE_VIEW_REDRAWNICE; } +#endif static char *rna_SmokeDomainSettings_path(PointerRNA *ptr) { @@ -118,7 +121,9 @@ static void rna_def_smoke_domain_settings(BlenderRNA *brna) static EnumPropertyItem prop_noise_type_items[] = { {MOD_SMOKE_NOISEWAVE, "NOISEWAVE", 0, "Wavelet", ""}, - /* {MOD_SMOKE_NOISEFFT, "NOISEFFT", 0, "FFT", ""}, */ +#if FFTW3 == 1 + {MOD_SMOKE_NOISEFFT, "NOISEFFT", 0, "FFT", ""}, +#endif /* {MOD_SMOKE_NOISECURL, "NOISECURL", 0, "Curl", ""}, */ {0, NULL, 0, NULL, NULL}}; @@ -134,51 +139,19 @@ static void rna_def_smoke_domain_settings(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Max Res", "Maximal resolution used in the fluid domain."); RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Smoke_reset"); - prop= RNA_def_property(srna, "color", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "omega"); - RNA_def_property_range(prop, 0.02, 1.0); - RNA_def_property_ui_range(prop, 0.02, 1.0, 0.02, 2); - RNA_def_property_ui_text(prop, "Color", "Smoke color (0 = black, 1 = white)."); - RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Smoke_redraw"); - - prop= RNA_def_property(srna, "amplify", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "amplify"); - RNA_def_property_range(prop, 1, 10); - RNA_def_property_ui_range(prop, 1, 10, 1, 0); - RNA_def_property_ui_text(prop, "Amplification", "Enhance the resolution of smoke by this factor using noise."); - RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Smoke_reset"); - - prop= RNA_def_property(srna, "highres", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_SMOKE_HIGHRES); - RNA_def_property_ui_text(prop, "High res", "Show high resolution (using amplification)."); - RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL); - - prop= RNA_def_property(srna, "noise_type", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "noise"); - RNA_def_property_enum_items(prop, prop_noise_type_items); - RNA_def_property_ui_text(prop, "Noise Method", "Noise method which is used for creating the high resolution"); - RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Smoke_reset"); - - prop= RNA_def_property(srna, "visibility", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "visibility"); - RNA_def_property_range(prop, 1, 15); - RNA_def_property_ui_range(prop, 1, 15, 1, 0); - RNA_def_property_ui_text(prop, "Display", "How much of the resolution should be shown during preview (every 2nd, 3rd, etc)."); - RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Smoke_redraw"); - prop= RNA_def_property(srna, "alpha", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "alpha"); RNA_def_property_range(prop, -5.0, 5.0); RNA_def_property_ui_range(prop, -5.0, 5.0, 0.02, 5); RNA_def_property_ui_text(prop, "Gravity", "Higher value results in sinking smoke"); - RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, NULL); + RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Smoke_reset"); prop= RNA_def_property(srna, "beta", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "beta"); RNA_def_property_range(prop, -5.0, 5.0); RNA_def_property_ui_range(prop, -5.0, 5.0, 0.02, 5); RNA_def_property_ui_text(prop, "Heat", "Higher value results in faster rising smoke."); - RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, NULL); + RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Smoke_reset"); prop= RNA_def_property(srna, "coll_group", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "coll_group"); @@ -200,6 +173,63 @@ static void rna_def_smoke_domain_settings(BlenderRNA *brna) RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Effector Group", "Limit effectors to this group."); RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Smoke_reset_dependancy"); + + prop= RNA_def_property(srna, "dissolve_speed", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "diss_speed"); + RNA_def_property_range(prop, 1.0, 100.0); + RNA_def_property_ui_range(prop, 1.0, 1000.0, 1, 0); + RNA_def_property_ui_text(prop, "Dissolve Speed", "Dissolve Speed"); + RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Smoke_reset"); + + prop= RNA_def_property(srna, "highres", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_SMOKE_HIGHRES); + RNA_def_property_ui_text(prop, "High Resolution Smoke", "Enable high resolution smoke"); + RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, NULL); + + prop= RNA_def_property(srna, "dissolve_smoke", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_SMOKE_DISSOLVE); + RNA_def_property_ui_text(prop, "Dissolve Smoke", "Enable smoke to disappear over time."); + RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Smoke_reset"); + + prop= RNA_def_property(srna, "dissolve_smoke_log", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_SMOKE_DISSOLVE_LOG); + RNA_def_property_ui_text(prop, "Logarithmic dissolve", "Using 1/x "); + RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Smoke_reset"); + + prop= RNA_def_property(srna, "point_cache", PROP_POINTER, PROP_NEVER_NULL); + RNA_def_property_pointer_sdna(prop, NULL, "point_cache[0]"); + RNA_def_property_struct_type(prop, "PointCache"); + RNA_def_property_ui_text(prop, "Point Cache", ""); + + prop= RNA_def_property(srna, "show_highres", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "viewsettings", MOD_SMOKE_SHOWHIGHRES); + RNA_def_property_ui_text(prop, "High res", "Show high resolution (using amplification)."); + RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL); + + prop= RNA_def_property(srna, "noise_type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "noise"); + RNA_def_property_enum_items(prop, prop_noise_type_items); + RNA_def_property_ui_text(prop, "Noise Method", "Noise method which is used for creating the high resolution"); + RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Smoke_reset"); + + prop= RNA_def_property(srna, "amplify", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "amplify"); + RNA_def_property_range(prop, 1, 10); + RNA_def_property_ui_range(prop, 1, 10, 1, 0); + RNA_def_property_ui_text(prop, "Amplification", "Enhance the resolution of smoke by this factor using noise."); + RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Smoke_reset"); + + prop= RNA_def_property(srna, "strength", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "strength"); + RNA_def_property_range(prop, 1.0, 10.0); + RNA_def_property_ui_range(prop, 1.0, 10.0, 1, 2); + RNA_def_property_ui_text(prop, "Strength", "Strength of wavelet noise"); + RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Smoke_reset"); + + prop= RNA_def_property(srna, "point_cache_turbulence", PROP_POINTER, PROP_NEVER_NULL); + RNA_def_property_pointer_sdna(prop, NULL, "point_cache[1]"); + RNA_def_property_struct_type(prop, "PointCache"); + RNA_def_property_ui_text(prop, "Point Cache", ""); } static void rna_def_smoke_flow_settings(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_sound.c b/source/blender/makesrna/intern/rna_sound.c index 363a5595b43..a029ef85544 100644 --- a/source/blender/makesrna/intern/rna_sound.c +++ b/source/blender/makesrna/intern/rna_sound.c @@ -36,96 +36,6 @@ #else -/* sample and listener are internal .. */ - -#if 0 -static void rna_def_sample(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - - /* sound types */ - static EnumPropertyItem prop_sample_type_items[] = { - {SAMPLE_INVALID, "INVALID", 0, "Invalid", ""}, - {SAMPLE_UNKNOWN, "UNKNOWN", 0, "Unknown", ""}, - {SAMPLE_RAW, "RAW", 0, "Raw", ""}, - {SAMPLE_WAV, "WAV", 0, "WAV", "Uncompressed"}, - {SAMPLE_MP2, "MP2", 0, "MP2", "MPEG-1 Audio Layer 2"}, - {SAMPLE_MP3, "MP3", 0, "MP3", "MPEG-1 Audio Layer 3"}, - {SAMPLE_OGG_VORBIS, "OGG_VORBIS", 0, "Ogg Vorbis", ""}, - {SAMPLE_WMA, "WMA", 0, "WMA", "Windows Media Audio"}, - {SAMPLE_ASF, "ASF", 0, "ASF", "Windows Advanced Systems Format"}, - {SAMPLE_AIFF, "AIFF", 0, "AIFF", "Audio Interchange File Format"}, - {0, NULL, 0, NULL, NULL}}; - - srna= RNA_def_struct(brna, "SoundSample", "ID"); - RNA_def_struct_sdna(srna, "bSample"); - RNA_def_struct_ui_text(srna, "SoundSample", "Sound data loaded from a sound datablock."); - - prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_items(prop, prop_sample_type_items); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Types", ""); - - prop= RNA_def_property(srna, "filename", PROP_STRING, PROP_FILEPATH); - RNA_def_property_string_sdna(prop, NULL, "name"); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Filename", "Full path filename of the sample"); - - prop= RNA_def_property(srna, "length", PROP_INT, PROP_UNSIGNED); - RNA_def_property_int_sdna(prop, NULL, "len"); - RNA_def_property_ui_text(prop, "Length", "The length of sample in seconds"); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - - prop= RNA_def_property(srna, "rate", PROP_INT, PROP_UNSIGNED); - RNA_def_property_ui_text(prop, "Rate", "Sample rate in kHz"); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - - prop= RNA_def_property(srna, "bits", PROP_INT, PROP_UNSIGNED); - RNA_def_property_ui_text(prop, "Bits", "Bit-depth of sample"); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - - prop= RNA_def_property(srna, "channels", PROP_INT, PROP_UNSIGNED); - RNA_def_property_ui_text(prop, "Channels", "Number of channels (mono=1; stereo=2)"); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); -} - -static void rna_def_soundlistener(BlenderRNA *brna) -{ - - StructRNA *srna; - PropertyRNA *prop; - - srna= RNA_def_struct(brna, "SoundListener", "ID"); - RNA_def_struct_sdna(srna, "bSoundListener"); - RNA_def_struct_ui_text(srna, "Sound Listener", "Sound listener defining parameters about how sounds are played."); - - prop= RNA_def_property(srna, "gain", PROP_FLOAT, PROP_NONE); - RNA_def_property_ui_text(prop, "Gain", "Overall volume for Game Engine sound."); - RNA_def_property_ui_range(prop, 0.0, 1.0, 10, 4); - - prop= RNA_def_property(srna, "doppler_factor", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "dopplerfactor"); - RNA_def_property_ui_text(prop, "Doppler Factor", "Amount of Doppler effect in Game Engine sound."); - RNA_def_property_ui_range(prop, 0.0, 10.0, 1, 4); - - prop= RNA_def_property(srna, "doppler_velocity", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "dopplervelocity"); - RNA_def_property_ui_text(prop, "Doppler Velocity", "The speed of sound in the Game Engine."); - RNA_def_property_ui_range(prop, 0.0, 10000.0, 0.1, 4); - - prop= RNA_def_property(srna, "num_sounds_blender", PROP_INT, PROP_UNSIGNED); - RNA_def_property_int_sdna(prop, NULL, "numsoundsblender"); - RNA_def_property_ui_text(prop, "Total Sounds in Blender", "The total number of sounds currently linked and available."); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - - prop= RNA_def_property(srna, "num_sounds_gameengine", PROP_INT, PROP_UNSIGNED); - RNA_def_property_int_sdna(prop, NULL, "numsoundsgameengine"); - RNA_def_property_ui_text(prop, "Total Sounds in Game Engine", "The total number of sounds in the Game Engine."); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); -} -#endif - static void rna_def_sound(BlenderRNA *brna) { StructRNA *srna; @@ -138,10 +48,6 @@ static void rna_def_sound(BlenderRNA *brna) //rna_def_ipo_common(srna); - /*prop= RNA_def_property(srna, "sample", PROP_POINTER, PROP_NONE); - RNA_def_property_struct_type(prop, "SoundSample"); - RNA_def_property_ui_text(prop, "Sample", "Sound sample.");*/ - prop= RNA_def_property(srna, "filename", PROP_STRING, PROP_FILEPATH); RNA_def_property_string_sdna(prop, NULL, "name"); RNA_def_property_ui_text(prop, "Filename", "Sound sample file used by this Sound datablock."); @@ -149,77 +55,10 @@ static void rna_def_sound(BlenderRNA *brna) prop= RNA_def_property(srna, "packed_file", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "packedfile"); RNA_def_property_ui_text(prop, "Packed File", ""); - - /* game engine settings */ - prop= RNA_def_property(srna, "volume", PROP_FLOAT, PROP_UNSIGNED); - RNA_def_property_float_sdna(prop, NULL, "volume"); - RNA_def_property_ui_range(prop, 0.0, 1.0, 10, 4); - RNA_def_property_ui_text(prop, "Volume", "Game engine only: volume for this sound."); - - prop= RNA_def_property(srna, "pitch", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "pitch"); - RNA_def_property_ui_range(prop, -12.0, 12.0, 10, 4); - RNA_def_property_ui_text(prop, "Pitch", "Game engine only: set the pitch of this sound."); - - prop= RNA_def_property(srna, "loop", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flags", SOUND_FLAGS_LOOP); - RNA_def_property_ui_text(prop, "Sound Loop", "Game engine only: toggle between looping on/off."); - - prop= RNA_def_property(srna, "ping_pong", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flags", SOUND_FLAGS_BIDIRECTIONAL_LOOP); - RNA_def_property_ui_text(prop, "Ping Pong", "Game engine only: Toggle between A->B and A->B->A looping."); - - prop= RNA_def_property(srna, "sound_3d", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flags", SOUND_FLAGS_3D); - RNA_def_property_ui_text(prop, "3D Sound", "Game engine only: turns 3D sound on."); - - prop= RNA_def_property(srna, "attenuation", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "attenuation"); - RNA_def_property_range(prop, 0.0, 5.0); - RNA_def_property_ui_text(prop, "Attenuation", "Game engine only: sets the surround scaling factor for 3D sound."); - - /* gain */ - prop= RNA_def_property(srna, "min_gain", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "min_gain"); - RNA_def_property_range(prop, 0.0, 1.0); - RNA_def_property_ui_text(prop, "Min Gain", "Minimal gain which is always guaranteed for this sound."); - - prop= RNA_def_property(srna, "max_gain", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "max_gain"); - RNA_def_property_range(prop, 0.0, 1.0); - RNA_def_property_ui_text(prop, "Max Gain", "Maximal gain which is always guaranteed for this sound."); - - prop= RNA_def_property(srna, "reference_distance", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "distance"); - RNA_def_property_ui_text(prop, "Reference Distance", "Reference distance at which the listener will experience gain."); - RNA_def_property_ui_range(prop, 0.0, 1000.0, 10, 4); /* NOT used anywhere */ - - /* unused - prop= RNA_def_property(srna, "panning", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "panning"); - RNA_def_property_ui_range(prop, -1.0, 1.0, 10, 4); - RNA_def_property_ui_text(prop, "Panning", "Pan the sound from left to right"); */ - - /* unused - prop= RNA_def_property(srna, "fixed_volume", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flags", SOUND_FLAGS_FIXED_VOLUME); - RNA_def_property_ui_text(prop, "Fixed Volume", "Constraint sound to fixed volume."); */ - - /* unused - prop= RNA_def_property(srna, "fixed_panning", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flags", SOUND_FLAGS_FIXED_PANNING); - RNA_def_property_ui_text(prop, "Fixed Panning", "Constraint sound to fixed panning."); */ - - /* unused - prop= RNA_def_property(srna, "priority", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flags", SOUND_FLAGS_PRIORITY); - RNA_def_property_ui_text(prop, "Priority", "Make sound higher priority."); */ } void RNA_def_sound(BlenderRNA *brna) { - //rna_def_sample(brna); - //rna_def_soundlistener(brna); rna_def_sound(brna); } diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 793970dea49..a754d619741 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -33,10 +33,13 @@ #include "rna_internal.h" #include "DNA_action_types.h" +#include "DNA_node_types.h" #include "DNA_object_types.h" #include "DNA_space_types.h" #include "DNA_view3d_types.h" +#include "BKE_paint.h" + #include "WM_types.h" EnumPropertyItem space_type_items[] = { @@ -44,10 +47,10 @@ EnumPropertyItem space_type_items[] = { {SPACE_VIEW3D, "VIEW_3D", 0, "3D View", ""}, {SPACE_IPO, "GRAPH_EDITOR", 0, "Graph Editor", ""}, {SPACE_OUTLINER, "OUTLINER", 0, "Outliner", ""}, - {SPACE_BUTS, "BUTTONS_WINDOW", 0, "Buttons Window", ""}, + {SPACE_BUTS, "PROPERTIES", 0, "Properties", ""}, {SPACE_FILE, "FILE_BROWSER", 0, "File Browser", ""}, {SPACE_IMAGE, "IMAGE_EDITOR", 0, "Image Editor", ""}, - {SPACE_INFO, "USER_PREFERENCES", 0, "User Preferences", ""}, + {SPACE_INFO, "INFO", 0, "Info", ""}, {SPACE_SEQ, "SEQUENCE_EDITOR", 0, "Sequence Editor", ""}, {SPACE_TEXT, "TEXT_EDITOR", 0, "Text Editor", ""}, //{SPACE_IMASEL, "IMAGE_BROWSER", 0, "Image Browser", ""}, @@ -59,6 +62,7 @@ EnumPropertyItem space_type_items[] = { {SPACE_NODE, "NODE_EDITOR", 0, "Node Editor", ""}, {SPACE_LOGIC, "LOGIC_EDITOR", 0, "Logic Editor", ""}, {SPACE_CONSOLE, "CONSOLE", 0, "Console", ""}, + {SPACE_USERPREF, "USER_PREFERENCES", 0, "User Preferences", ""}, {0, NULL, 0, NULL, NULL}}; #define DC_RGB {0, "COLOR", ICON_IMAGE_RGB, "Color", "Draw image with RGB colors."} @@ -83,6 +87,7 @@ static EnumPropertyItem dc_all_items[] = {DC_RGB, DC_RGBA, DC_ALPHA, DC_Z, DC_LC #include "BKE_context.h" #include "ED_image.h" +#include "ED_screen.h" #include "IMB_imbuf_types.h" @@ -98,13 +103,13 @@ static StructRNA* rna_Space_refine(struct PointerRNA *ptr) case SPACE_OUTLINER: return &RNA_SpaceOutliner; case SPACE_BUTS: - return &RNA_SpaceButtonsWindow; + return &RNA_SpaceProperties; case SPACE_FILE: return &RNA_SpaceFileBrowser; case SPACE_IMAGE: return &RNA_SpaceImageEditor; - /*case SPACE_INFO: - return &RNA_SpaceUserPreferences;*/ + case SPACE_INFO: + return &RNA_SpaceInfo; case SPACE_SEQ: return &RNA_SpaceSequenceEditor; case SPACE_TEXT: @@ -118,15 +123,17 @@ static StructRNA* rna_Space_refine(struct PointerRNA *ptr) case SPACE_NLA: return &RNA_SpaceNLA; /*case SPACE_SCRIPT: - return &RNA_SpaceScriptsWindow; + return &RNA_SpaceScriptsWindow;*/ case SPACE_TIME: return &RNA_SpaceTimeline; case SPACE_NODE: return &RNA_SpaceNodeEditor; case SPACE_LOGIC: - return &RNA_SpaceLogicEditor;*/ + return &RNA_SpaceLogicEditor; case SPACE_CONSOLE: return &RNA_SpaceConsole; + case SPACE_USERPREF: + return &RNA_SpaceUserPreferences; default: return &RNA_Space; } @@ -144,7 +151,7 @@ static void rna_SpaceImageEditor_paint_update(bContext *C, PointerRNA *ptr) Scene *scene= CTX_data_scene(C); if(scene) - brush_check_exists(&scene->toolsettings->imapaint.brush); + paint_init(&scene->toolsettings->imapaint.paint, PAINT_CURSOR_TEXTURE_PAINT); } static int rna_SpaceImageEditor_show_render_get(PointerRNA *ptr) @@ -227,9 +234,9 @@ void rna_SpaceFileBrowser_params_set(PointerRNA *ptr, PointerRNA value) sfile->params= value.data; } -/* Space Buttons */ +/* Space Properties */ -StructRNA *rna_SpaceButtonsWindow_pin_id_typef(PointerRNA *ptr) +StructRNA *rna_SpaceProperties_pin_id_typef(PointerRNA *ptr) { SpaceButs *sbuts= (SpaceButs*)(ptr->data); @@ -239,7 +246,7 @@ StructRNA *rna_SpaceButtonsWindow_pin_id_typef(PointerRNA *ptr) return &RNA_ID; } -void rna_SpaceButtonsWindow_align_set(PointerRNA *ptr, int value) +void rna_SpaceProperties_align_set(PointerRNA *ptr, int value) { SpaceButs *sbuts= (SpaceButs*)(ptr->data); @@ -303,6 +310,13 @@ static void rna_View3D_display_background_image_set(PointerRNA *ptr, int value) } } +/* Space Time */ +static void rna_SpaceTime_redraw_update(bContext *C, PointerRNA *ptr) +{ + SpaceTime *st= (SpaceTime*)ptr->data; + ED_screen_animation_timer_update(C, st->redraws); +} + #else static void rna_def_space(BlenderRNA *brna) @@ -509,11 +523,11 @@ static void rna_def_space_3dview(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem viewport_shading_items[] = { - {OB_BOUNDBOX, "BOUNDBOX", 0, "Bounding Box", "Display the object's local bounding boxes only"}, - {OB_WIRE, "WIREFRAME", 0, "Wireframe", "Display the object as wire edges"}, - {OB_SOLID, "SOLID", 0, "Solid", "Display the object solid, lit with default OpenGL lights"}, - {OB_SHADED, "SHADED", 0, "Shaded", "Display the object solid, with preview shading interpolated at vertices"}, - {OB_TEXTURE, "TEXTURED", 0, "Textured", "Display the object solid, with face-assigned textures"}, + {OB_BOUNDBOX, "BOUNDBOX", ICON_BBOX, "Bounding Box", "Display the object's local bounding boxes only"}, + {OB_WIRE, "WIREFRAME", ICON_WIRE, "Wireframe", "Display the object as wire edges"}, + {OB_SOLID, "SOLID", ICON_SOLID, "Solid", "Display the object solid, lit with default OpenGL lights"}, + {OB_SHADED, "SHADED", ICON_SMOOTH, "Shaded", "Display the object solid, with preview shading interpolated at vertices"}, + {OB_TEXTURE, "TEXTURED", ICON_POTATO, "Textured", "Display the object solid, with face-assigned textures"}, {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem pivot_items[] = { @@ -564,19 +578,19 @@ static void rna_def_space_3dview(BlenderRNA *brna) RNA_def_property_range(prop, 1.0f, 250.0f); RNA_def_property_update(prop, NC_WINDOW, NULL); - prop= RNA_def_property(srna, "clip_start", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "clip_start", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "near"); RNA_def_property_range(prop, 0.0f, FLT_MAX); RNA_def_property_ui_text(prop, "Clip Start", "3D View near clipping distance."); RNA_def_property_update(prop, NC_WINDOW, NULL); - prop= RNA_def_property(srna, "clip_end", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "clip_end", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "far"); RNA_def_property_range(prop, 1.0f, FLT_MAX); RNA_def_property_ui_text(prop, "Clip End", "3D View far clipping distance."); RNA_def_property_update(prop, NC_WINDOW, NULL); - prop= RNA_def_property(srna, "grid_spacing", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "grid_spacing", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "grid"); RNA_def_property_ui_text(prop, "Grid Spacing", "The distance between 3D View grid lines."); RNA_def_property_range(prop, 0.0f, FLT_MAX); @@ -708,9 +722,9 @@ static void rna_def_space_buttons(BlenderRNA *brna) {BUT_VERTICAL, "VERTICAL", 0, "Vertical", ""}, {0, NULL, 0, NULL, NULL}}; - srna= RNA_def_struct(brna, "SpaceButtonsWindow", "Space"); + srna= RNA_def_struct(brna, "SpaceProperties", "Space"); RNA_def_struct_sdna(srna, "SpaceButs"); - RNA_def_struct_ui_text(srna, "Buttons Space", "Buttons Window space data"); + RNA_def_struct_ui_text(srna, "Properties Space", "Properties space data"); prop= RNA_def_property(srna, "context", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "mainb"); @@ -721,7 +735,7 @@ static void rna_def_space_buttons(BlenderRNA *brna) prop= RNA_def_property(srna, "align", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "align"); RNA_def_property_enum_items(prop, align_items); - RNA_def_property_enum_funcs(prop, NULL, "rna_SpaceButtonsWindow_align_set", NULL); + RNA_def_property_enum_funcs(prop, NULL, "rna_SpaceProperties_align_set", NULL); RNA_def_property_ui_text(prop, "Align", "Arrangement of the panels."); RNA_def_property_update(prop, NC_WINDOW, NULL); @@ -734,7 +748,7 @@ static void rna_def_space_buttons(BlenderRNA *brna) prop= RNA_def_property(srna, "pin_id", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "pinid"); RNA_def_property_struct_type(prop, "ID"); - RNA_def_property_pointer_funcs(prop, NULL, NULL, "rna_SpaceButtonsWindow_pin_id_typef"); + RNA_def_property_pointer_funcs(prop, NULL, NULL, "rna_SpaceProperties_pin_id_typef"); RNA_def_property_flag(prop, PROP_EDITABLE); } @@ -836,11 +850,11 @@ static void rna_def_space_sequencer(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem display_mode_items[] = { - {SEQ_DRAW_SEQUENCE, "SEQUENCER", 0, "Sequencer", ""}, - {SEQ_DRAW_IMG_IMBUF, "IMAGE", 0, "Image Preview", ""}, - {SEQ_DRAW_IMG_WAVEFORM, "WAVEFORM", 0, "Luma Waveform", ""}, - {SEQ_DRAW_IMG_VECTORSCOPE, "VECTOR_SCOPE", 0, "Chroma Vectorscope", ""}, - {SEQ_DRAW_IMG_HISTOGRAM, "HISTOGRAM", 0, "Histogram", ""}, + {SEQ_DRAW_SEQUENCE, "SEQUENCER", ICON_SEQ_SEQUENCER, "Sequencer", ""}, + {SEQ_DRAW_IMG_IMBUF, "IMAGE", ICON_SEQ_PREVIEW, "Image Preview", ""}, + {SEQ_DRAW_IMG_WAVEFORM, "WAVEFORM", ICON_SEQ_LUMA_WAVEFORM, "Luma Waveform", ""}, + {SEQ_DRAW_IMG_VECTORSCOPE, "VECTOR_SCOPE", ICON_SEQ_CHROMA_SCOPE, "Chroma Vectorscope", ""}, + {SEQ_DRAW_IMG_HISTOGRAM, "HISTOGRAM", ICON_SEQ_HISTOGRAM, "Histogram", ""}, {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "SpaceSequenceEditor", "Space"); @@ -1061,6 +1075,10 @@ static void rna_def_space_graph(BlenderRNA *brna) RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", SIPO_NODRAWCFRANUM); RNA_def_property_ui_text(prop, "Show Frame Number Indicator", "Show frame number beside the current frame indicator line."); + prop= RNA_def_property(srna, "show_sliders", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", SIPO_SLIDERS); + RNA_def_property_ui_text(prop, "Show Sliders", "Show sliders beside F-Curve channels."); + prop= RNA_def_property(srna, "show_handles", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SIPO_NOHANDLES); RNA_def_property_ui_text(prop, "Show Handles", "Show handles of Bezier control points."); @@ -1104,6 +1122,59 @@ static void rna_def_space_nla(BlenderRNA *brna) // TODO... autosnap, dopesheet? } +static void rna_def_space_time(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna= RNA_def_struct(brna, "SpaceTimeline", "Space"); + RNA_def_struct_sdna(srna, "SpaceTime"); + RNA_def_struct_ui_text(srna, "Space Timeline Editor", "Timeline editor space data."); + + /* Define Anim Playback Areas */ + + prop= RNA_def_property(srna, "play_top_left", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "redraws", TIME_REGION); + RNA_def_property_ui_text(prop, "Top-Left 3D Window", ""); + RNA_def_property_update(prop, 0, "rna_SpaceTime_redraw_update"); + + prop= RNA_def_property(srna, "play_all_3d", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "redraws", TIME_ALL_3D_WIN); + RNA_def_property_ui_text(prop, "All 3D Windows", ""); + RNA_def_property_update(prop, 0, "rna_SpaceTime_redraw_update"); + + prop= RNA_def_property(srna, "play_anim", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "redraws", TIME_ALL_ANIM_WIN); + RNA_def_property_ui_text(prop, "Animation Windows", ""); + RNA_def_property_update(prop, 0, "rna_SpaceTime_redraw_update"); + + prop= RNA_def_property(srna, "play_buttons", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "redraws", TIME_ALL_BUTS_WIN); + RNA_def_property_ui_text(prop, "Properties Windows", ""); + RNA_def_property_update(prop, 0, "rna_SpaceTime_redraw_update"); + + prop= RNA_def_property(srna, "play_image", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "redraws", TIME_ALL_IMAGE_WIN); + RNA_def_property_ui_text(prop, "Image Windows", ""); + RNA_def_property_update(prop, 0, "rna_SpaceTime_redraw_update"); + + prop= RNA_def_property(srna, "play_sequencer", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "redraws", TIME_SEQ); + RNA_def_property_ui_text(prop, "Sequencer Windows", ""); + RNA_def_property_update(prop, 0, "rna_SpaceTime_redraw_update"); + + /* Other options */ + + prop= RNA_def_property(srna, "continue_physics", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "redraws", TIME_CONTINUE_PHYSICS); + RNA_def_property_ui_text(prop, "Continue Physics", "During playblack, continue physics simulations regardless of the frame number"); + + prop= RNA_def_property(srna, "only_selected", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", TIME_ONLYACTSEL); + RNA_def_property_ui_text(prop, "Only Selected channels", "Show keyframes only from active/selected channels."); + RNA_def_property_update(prop, NC_WINDOW, NULL); +} + static void rna_def_console_line(BlenderRNA *brna) { StructRNA *srna; @@ -1314,7 +1385,85 @@ static void rna_def_space_filebrowser(BlenderRNA *brna) RNA_def_property_pointer_sdna(prop, NULL, "params"); RNA_def_property_pointer_funcs(prop, NULL, "rna_SpaceFileBrowser_params_set", NULL); RNA_def_property_ui_text(prop, "Filebrowser Parameter", "Parameters and Settings for the Filebrowser."); +} + +static void rna_def_space_info(BlenderRNA *brna) +{ + StructRNA *srna; + + srna= RNA_def_struct(brna, "SpaceInfo", "Space"); + RNA_def_struct_sdna(srna, "SpaceInfo"); + RNA_def_struct_ui_text(srna, "Space Info", "Info space data."); +} + +static void rna_def_space_userpref(BlenderRNA *brna) +{ + StructRNA *srna; + + srna= RNA_def_struct(brna, "SpaceUserPreferences", "Space"); + RNA_def_struct_sdna(srna, "SpaceUserPref"); + RNA_def_struct_ui_text(srna, "Space User Preferences", "User preferences space data."); +} + +static void rna_def_space_node(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + static EnumPropertyItem tree_type_items[] = { + {NTREE_SHADER, "MATERIAL", ICON_MATERIAL, "Material", "Material nodes."}, + {NTREE_TEXTURE, "TEXTURE", ICON_TEXTURE, "Texture", "Texture nodes."}, + {NTREE_COMPOSIT, "COMPOSITING", ICON_RENDERLAYERS, "Compositing", "Compositing nodes."}, + {0, NULL, 0, NULL, NULL}}; + + static EnumPropertyItem texture_type_items[] = { + {SNODE_TEX_OBJECT, "OBJECT", ICON_OBJECT_DATA, "Object", "Edit texture nodes from Object."}, + {SNODE_TEX_WORLD, "WORLD", ICON_WORLD_DATA, "World", "Edit texture nodes from World."}, + {SNODE_TEX_BRUSH, "BRUSH", ICON_BRUSH_DATA, "Brush", "Edit texture nodes from Brush."}, + {0, NULL, 0, NULL, NULL}}; + + srna= RNA_def_struct(brna, "SpaceNodeEditor", "Space"); + RNA_def_struct_sdna(srna, "SpaceNode"); + RNA_def_struct_ui_text(srna, "Space Node Editor", "Node editor space data."); + + prop= RNA_def_property(srna, "tree_type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "treetype"); + RNA_def_property_enum_items(prop, tree_type_items); + RNA_def_property_ui_text(prop, "Tree Type", "Node tree type to display and edit."); + RNA_def_property_update(prop, NC_NODE, NULL); + + prop= RNA_def_property(srna, "texture_type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "texfrom"); + RNA_def_property_enum_items(prop, texture_type_items); + RNA_def_property_ui_text(prop, "Texture Type", "Type of data to take texture from."); + RNA_def_property_update(prop, NC_NODE, NULL); + + prop= RNA_def_property(srna, "id", PROP_POINTER, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "ID", "Datablock whose nodes are being edited."); + + prop= RNA_def_property(srna, "id_from", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "from"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "ID From", "Datablock from which the edited datablock is linked."); + + prop= RNA_def_property(srna, "nodetree", PROP_POINTER, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Node Tree", "Node tree being displayed and edited."); + + prop= RNA_def_property(srna, "backdrop", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", SNODE_BACKDRAW); + RNA_def_property_ui_text(prop, "Backdrop", "Use active Viewer Node output as backdrop for compositing nodes."); + RNA_def_property_update(prop, NC_NODE, NULL); +} + +static void rna_def_space_logic(BlenderRNA *brna) +{ + StructRNA *srna; + srna= RNA_def_struct(brna, "SpaceLogicEditor", "Space"); + RNA_def_struct_sdna(srna, "SpaceLogic"); + RNA_def_struct_ui_text(srna, "Space Logic Editor", "Logic editor space data."); } void RNA_def_space(BlenderRNA *brna) @@ -1332,8 +1481,13 @@ void RNA_def_space(BlenderRNA *brna) rna_def_space_dopesheet(brna); rna_def_space_graph(brna); rna_def_space_nla(brna); + rna_def_space_time(brna); rna_def_space_console(brna); rna_def_console_line(brna); + rna_def_space_info(brna); + rna_def_space_userpref(brna); + rna_def_space_node(brna); + rna_def_space_logic(brna); } #endif diff --git a/source/blender/makesrna/intern/rna_texture.c b/source/blender/makesrna/intern/rna_texture.c index 694f980e5e9..a949d26f51a 100644 --- a/source/blender/makesrna/intern/rna_texture.c +++ b/source/blender/makesrna/intern/rna_texture.c @@ -36,6 +36,9 @@ #include "DNA_material_types.h" #include "DNA_texture_types.h" #include "DNA_world_types.h" +#include "DNA_node_types.h" + +#include "BKE_node.h" #include "WM_types.h" @@ -50,6 +53,7 @@ static EnumPropertyItem texture_filter_items[] = { #ifdef RNA_RUNTIME #include "BKE_texture.h" +#include "ED_node.h" StructRNA *rna_Texture_refine(struct PointerRNA *ptr) { @@ -82,11 +86,32 @@ StructRNA *rna_Texture_refine(struct PointerRNA *ptr) return &RNA_VoronoiTexture; case TEX_DISTNOISE: return &RNA_DistortedNoiseTexture; + case TEX_POINTDENSITY: + return &RNA_PointDensityTexture; + case TEX_VOXELDATA: + return &RNA_VoxelDataTexture; default: return &RNA_Texture; } } +static void rna_Texture_type_set(PointerRNA *ptr, int value) +{ + Tex *tex= (Tex*)ptr->data; + + if (value == TEX_VOXELDATA) { + if (tex->vd == NULL) { + tex->vd = BKE_add_voxeldata(); + } + } else if (value == TEX_POINTDENSITY) { + if (tex->pd == NULL) { + tex->pd = BKE_add_pointdensity(); + } + } + + tex->type = value; +} + static int rna_TextureSlot_name_length(PointerRNA *ptr) { MTex *mtex= ptr->data; @@ -107,6 +132,65 @@ static void rna_TextureSlot_name_get(PointerRNA *ptr, char *str) strcpy(str, ""); } +static int rna_TextureSlot_output_node_get(PointerRNA *ptr) +{ + MTex *mtex= ptr->data; + Tex *tex= mtex->tex; + int cur= mtex->which_output; + + if(tex) { + bNodeTree *ntree= tex->nodetree; + bNode *node; + if(ntree) { + for(node= ntree->nodes.first; node; node= node->next) { + if(node->type == TEX_NODE_OUTPUT) { + if(cur == node->custom1) + return cur; + } + } + } + } + + mtex->which_output= 0; + return 0; +} + + +static EnumPropertyItem *rna_TextureSlot_output_node_itemf(bContext *C, PointerRNA *ptr, int *free) +{ + MTex *mtex= ptr->data; + Tex *tex= mtex->tex; + EnumPropertyItem *item= NULL; + int totitem= 0; + + if(tex && C) { /* Note, tex/mtex/ntree can be invalid of C is NULL, TODO - can this give valid results when C is NULL? */ + bNodeTree *ntree= tex->nodetree; + if(ntree) { + EnumPropertyItem tmp= {0, "", 0, "", ""}; + bNode *node; + + tmp.value = 0; + tmp.name = "Not Specified"; + tmp.identifier = "NOT_SPECIFIED"; + RNA_enum_item_add(&item, &totitem, &tmp); + + for(node= ntree->nodes.first; node; node= node->next) { + if(node->type == TEX_NODE_OUTPUT) { + tmp.value= node->custom1; + tmp.name= ((TexNodeOutput*)node->storage)->name; + tmp.identifier = tmp.name; + RNA_enum_item_add(&item, &totitem, &tmp); + } + } + } + } + + RNA_enum_item_end(&item, &totitem); + + *free = 1; + return item; +} + static void rna_Texture_use_color_ramp_set(PointerRNA *ptr, int value) { Tex *tex= (Tex*)ptr->data; @@ -118,6 +202,17 @@ static void rna_Texture_use_color_ramp_set(PointerRNA *ptr, int value) tex->coba= add_colorband(0); } +void rna_Texture_use_nodes_set(PointerRNA *ptr, int v) +{ + Tex *tex= (Tex*)ptr->data; + + tex->use_nodes = v; + tex->type = 0; + + if(v && tex->nodetree==NULL) + ED_node_texture_default(tex); +} + static void rna_ImageTexture_mipmap_set(PointerRNA *ptr, int value) { Tex *tex= (Tex*)ptr->data; @@ -147,6 +242,20 @@ static EnumPropertyItem *rna_ImageTexture_filter_itemf(bContext *C, PointerRNA * return item; } +static float rna_TextureSlot_angle_get(PointerRNA *ptr) +{ + MTex *tex= (MTex*)ptr->data; + const float conv = 57.295779506; + return tex->rot * conv; +} + +static void rna_TextureSlot_angle_set(PointerRNA *ptr, float v) +{ + MTex *tex= (MTex*)ptr->data; + const float conv = 0.017453293; + tex->rot = v * conv; +} + #else static void rna_def_color_ramp_element(BlenderRNA *brna) @@ -209,27 +318,27 @@ static void rna_def_texmapping(BlenderRNA *brna) srna= RNA_def_struct(brna, "TexMapping", NULL); RNA_def_struct_ui_text(srna, "Texture Mapping", "Mapping settings"); - prop= RNA_def_property(srna, "location", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "location", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_float_sdna(prop, NULL, "loc"); RNA_def_property_ui_text(prop, "Location", ""); RNA_def_property_update(prop, NC_TEXTURE, NULL); - prop= RNA_def_property(srna, "rotation", PROP_FLOAT, PROP_ROTATION); + prop= RNA_def_property(srna, "rotation", PROP_FLOAT, PROP_EULER); RNA_def_property_float_sdna(prop, NULL, "rot"); RNA_def_property_ui_text(prop, "Rotation", ""); RNA_def_property_update(prop, NC_TEXTURE, NULL); - prop= RNA_def_property(srna, "scale", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "scale", PROP_FLOAT, PROP_XYZ); RNA_def_property_float_sdna(prop, NULL, "size"); RNA_def_property_ui_text(prop, "Scale", ""); RNA_def_property_update(prop, NC_TEXTURE, NULL); - prop= RNA_def_property(srna, "minimum", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "minimum", PROP_FLOAT, PROP_XYZ); RNA_def_property_float_sdna(prop, NULL, "min"); RNA_def_property_ui_text(prop, "Minimum", "Minimum value for clipping"); RNA_def_property_update(prop, NC_TEXTURE, NULL); - prop= RNA_def_property(srna, "maximum", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "maximum", PROP_FLOAT, PROP_XYZ); RNA_def_property_float_sdna(prop, NULL, "max"); RNA_def_property_ui_text(prop, "Maximum", "Maximum value for clipping"); RNA_def_property_update(prop, NC_TEXTURE, NULL); @@ -267,6 +376,16 @@ static void rna_def_mtex(BlenderRNA *brna) {MTEX_BLEND_COLOR, "COLOR", 0, "Color", ""}, {0, NULL, 0, NULL, NULL}}; + static EnumPropertyItem prop_map_mode_items[] = { + {MTEX_MAP_MODE_FIXED, "FIXED", 0, "Fixed", ""}, + {MTEX_MAP_MODE_TILED, "TILED", 0, "Tiled", ""}, + {MTEX_MAP_MODE_3D, "3D", 0, "3D", ""}, + {0, NULL, 0, NULL, NULL}}; + + static EnumPropertyItem output_node_items[] = { + {0, "DUMMY", 0, "Dummy", ""}, + {0, NULL, 0, NULL, NULL}}; + srna= RNA_def_struct(brna, "TextureSlot", NULL); RNA_def_struct_sdna(srna, "MTex"); RNA_def_struct_ui_text(srna, "Texture Slot", "Texture slot defining the mapping and influence of a texture."); @@ -287,13 +406,13 @@ static void rna_def_mtex(BlenderRNA *brna) RNA_def_property_update(prop, NC_TEXTURE, NULL); /* mapping */ - prop= RNA_def_property(srna, "offset", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "offset", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_float_sdna(prop, NULL, "ofs"); RNA_def_property_ui_range(prop, -10, 10, 10, 2); RNA_def_property_ui_text(prop, "Offset", "Fine tunes texture mapping X, Y and Z locations."); RNA_def_property_update(prop, NC_TEXTURE, NULL); - prop= RNA_def_property(srna, "size", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "size", PROP_FLOAT, PROP_XYZ); RNA_def_property_ui_range(prop, -100, 100, 10, 2); RNA_def_property_ui_text(prop, "Size", "Sets scaling for the texture's X, Y and Z sizes."); RNA_def_property_update(prop, NC_TEXTURE, NULL); @@ -325,23 +444,41 @@ static void rna_def_mtex(BlenderRNA *brna) RNA_def_property_ui_text(prop, "RGB to Intensity", "Converts texture RGB values to intensity (gray) values."); RNA_def_property_update(prop, NC_TEXTURE, NULL); - prop= RNA_def_property(srna, "default_value", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "angle", PROP_FLOAT, PROP_ANGLE); + RNA_def_property_float_sdna(prop, NULL, "rot"); + RNA_def_property_range(prop, 0, 360); + RNA_def_property_float_funcs(prop, "rna_TextureSlot_angle_get", "rna_TextureSlot_angle_set", NULL); + RNA_def_property_ui_text(prop, "Angle", "Defines brush texture rotation."); + RNA_def_property_update(prop, NC_TEXTURE, NULL); + + prop= RNA_def_property(srna, "brush_map_mode", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, prop_map_mode_items); + RNA_def_property_ui_text(prop, "Mode", ""); + + prop= RNA_def_property(srna, "default_value", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "def_var"); RNA_def_property_ui_range(prop, 0, 1, 10, 3); RNA_def_property_ui_text(prop, "Default Value", "Value to use for Ref, Spec, Amb, Emit, Alpha, RayMir, TransLu and Hard."); RNA_def_property_update(prop, NC_TEXTURE, NULL); - prop= RNA_def_property(srna, "variable_factor", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "variable_factor", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "varfac"); RNA_def_property_ui_range(prop, 0, 1, 10, 3); RNA_def_property_ui_text(prop, "Variable Factor", "Amount texture affects other values."); RNA_def_property_update(prop, NC_TEXTURE, NULL); - prop= RNA_def_property(srna, "normal_factor", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "normal_factor", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "norfac"); RNA_def_property_ui_range(prop, 0, 5, 10, 3); RNA_def_property_ui_text(prop, "Normal Factor", "Amount texture affects normal values."); RNA_def_property_update(prop, NC_TEXTURE, NULL); + + prop= RNA_def_property(srna, "output_node", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "which_output"); + RNA_def_property_enum_items(prop, output_node_items); + RNA_def_property_enum_funcs(prop, "rna_TextureSlot_output_node_get", NULL, "rna_TextureSlot_output_node_itemf"); + RNA_def_property_ui_text(prop, "Output Node", "Which output node to use, for node-based textures."); + RNA_def_property_update(prop, NC_TEXTURE, NULL); } static void rna_def_filter_size_common(StructRNA *srna) @@ -1085,17 +1222,34 @@ static void rna_def_texture_voronoi(BlenderRNA *brna) RNA_def_struct_ui_text(srna, "Voronoi", "Procedural voronoi texture."); RNA_def_struct_sdna(srna, "Tex"); - prop= RNA_def_property(srna, "feature_weights", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "weight_1", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "vn_w1"); - RNA_def_property_array(prop, 4); RNA_def_property_range(prop, -2, 2); - RNA_def_property_ui_text(prop, "Feature Weights", ""); + RNA_def_property_ui_text(prop, "Weight 1", "Voronoi feature weight 1"); + RNA_def_property_update(prop, NC_TEXTURE, NULL); + + prop= RNA_def_property(srna, "weight_2", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "vn_w2"); + RNA_def_property_range(prop, -2, 2); + RNA_def_property_ui_text(prop, "Weight 2", "Voronoi feature weight 2"); + RNA_def_property_update(prop, NC_TEXTURE, NULL); + + prop= RNA_def_property(srna, "weight_3", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "vn_w3"); + RNA_def_property_range(prop, -2, 2); + RNA_def_property_ui_text(prop, "Weight 3", "Voronoi feature weight 3"); + RNA_def_property_update(prop, NC_TEXTURE, NULL); + + prop= RNA_def_property(srna, "weight_4", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "vn_w4"); + RNA_def_property_range(prop, -2, 2); + RNA_def_property_ui_text(prop, "Weight 4", "Voronoi feature weight 4"); RNA_def_property_update(prop, NC_TEXTURE, NULL); prop= RNA_def_property(srna, "minkovsky_exponent", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "vn_mexp"); RNA_def_property_range(prop, 0.01, 10); - RNA_def_property_ui_text(prop, "Minkovsky Exponent", ""); + RNA_def_property_ui_text(prop, "Minkovsky Exponent", "Minkovsky exponent"); RNA_def_property_update(prop, NC_TEXTURE, NULL); prop= RNA_def_property(srna, "distance_metric", PROP_ENUM, PROP_NONE); @@ -1153,13 +1307,13 @@ static void rna_def_texture_distorted_noise(BlenderRNA *brna) RNA_def_property_update(prop, NC_TEXTURE, NULL); prop= RNA_def_property(srna, "noise_basis", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "noisebasis"); + RNA_def_property_enum_sdna(prop, NULL, "noisebasis2"); RNA_def_property_enum_items(prop, prop_noise_basis_items); RNA_def_property_ui_text(prop, "Noise Basis", "Sets the noise basis used for turbulence"); RNA_def_property_update(prop, NC_TEXTURE, NULL); prop= RNA_def_property(srna, "noise_distortion", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "noisebasis2"); + RNA_def_property_enum_sdna(prop, NULL, "noisebasis"); RNA_def_property_enum_items(prop, prop_noise_basis_items); RNA_def_property_ui_text(prop, "Noise Distortion", "Sets the noise basis for the distortion"); RNA_def_property_update(prop, NC_TEXTURE, NULL); @@ -1171,6 +1325,200 @@ static void rna_def_texture_distorted_noise(BlenderRNA *brna) RNA_def_property_update(prop, NC_TEXTURE, NULL); } +static void rna_def_texture_pointdensity(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + static EnumPropertyItem point_source_items[] = { + {TEX_PD_PSYS, "PARTICLE_SYSTEM", 0, "Particle System", "Generate point density from a particle system"}, + {TEX_PD_OBJECT, "OBJECT", 0, "Object Vertices", "Generate point density from an object's vertices"}, + {0, NULL, 0, NULL, NULL}}; + + static EnumPropertyItem falloff_items[] = { + {TEX_PD_FALLOFF_STD, "STANDARD", 0, "Standard", ""}, + {TEX_PD_FALLOFF_SMOOTH, "SMOOTH", 0, "Smooth", ""}, + {TEX_PD_FALLOFF_SOFT, "SOFT", 0, "Soft", ""}, + {TEX_PD_FALLOFF_CONSTANT, "CONSTANT", 0, "Constant", "Density is constant within lookup radius"}, + {TEX_PD_FALLOFF_ROOT, "ROOT", 0, "Root", ""}, + {0, NULL, 0, NULL, NULL}}; + + static EnumPropertyItem color_source_items[] = { + {TEX_PD_COLOR_CONSTANT, "CONSTANT", 0, "Constant", ""}, + {TEX_PD_COLOR_PARTAGE, "PARTICLE_AGE", 0, "Particle Age", "Lifetime mapped as 0.0 - 1.0 intensity"}, + {TEX_PD_COLOR_PARTSPEED, "PARTICLE_SPEED", 0, "Particle Speed", "Particle speed (absolute magnitude of velocity) mapped as 0.0-1.0 intensity"}, + {TEX_PD_COLOR_PARTVEL, "PARTICLE_VELOCITY", 0, "Particle Velocity", "XYZ velocity mapped to RGB colors"}, + {0, NULL, 0, NULL, NULL}}; + + static EnumPropertyItem turbulence_influence_items[] = { + {TEX_PD_NOISE_STATIC, "STATIC", 0, "Static", "Noise patterns will remain unchanged, faster and suitable for stills"}, + {TEX_PD_NOISE_VEL, "PARTICLE_VELOCITY", 0, "Particle Velocity", "Turbulent noise driven by particle velocity"}, + {TEX_PD_NOISE_AGE, "PARTICLE_AGE", 0, "Particle Age", "Turbulent noise driven by the particle's age between birth and death"}, + {TEX_PD_NOISE_TIME, "GLOBAL_TIME", 0, "Global Time", "Turbulent noise driven by the global current frame"}, + {0, NULL, 0, NULL, NULL}}; + + srna= RNA_def_struct(brna, "PointDensity", NULL); + RNA_def_struct_sdna(srna, "PointDensity"); + RNA_def_struct_ui_text(srna, "PointDensity", "Point density settings."); + + prop= RNA_def_property(srna, "point_source", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "source"); + RNA_def_property_enum_items(prop, point_source_items); + RNA_def_property_ui_text(prop, "Point Source", "Point data to use as renderable point density"); + RNA_def_property_update(prop, NC_TEXTURE, NULL); + + prop= RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "object"); + RNA_def_property_ui_text(prop, "Object", "Object to take point data from"); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_update(prop, NC_TEXTURE, NULL); + + prop= RNA_def_property(srna, "particle_system", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "psys"); + RNA_def_property_ui_text(prop, "Particle System", "Particle System to render as points"); + RNA_def_property_struct_type(prop, "ParticleSystem"); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_update(prop, NC_TEXTURE, NULL); + + prop= RNA_def_property(srna, "radius", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "radius"); + RNA_def_property_range(prop, 0.01, FLT_MAX); + RNA_def_property_ui_text(prop, "Radius", "Radius from the shaded sample to look for points within"); + RNA_def_property_update(prop, NC_TEXTURE, NULL); + + prop= RNA_def_property(srna, "falloff", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "falloff_type"); + RNA_def_property_enum_items(prop, falloff_items); + RNA_def_property_ui_text(prop, "Falloff", "Method of attenuating density by distance from the point"); + RNA_def_property_update(prop, NC_TEXTURE, NULL); + + prop= RNA_def_property(srna, "falloff_softness", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "falloff_softness"); + RNA_def_property_range(prop, 0.01, FLT_MAX); + RNA_def_property_ui_text(prop, "Softness", "Softness of the 'soft' falloff option"); + RNA_def_property_update(prop, NC_TEXTURE, NULL); + + prop= RNA_def_property(srna, "color_source", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "color_source"); + RNA_def_property_enum_items(prop, color_source_items); + RNA_def_property_ui_text(prop, "Color Source", "Data to derive color results from"); + RNA_def_property_update(prop, NC_TEXTURE, NULL); + + prop= RNA_def_property(srna, "turbulence", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", TEX_PD_TURBULENCE); + RNA_def_property_ui_text(prop, "Turbulence", "Add directed noise to the density at render-time"); + RNA_def_property_update(prop, NC_TEXTURE, NULL); + + prop= RNA_def_property(srna, "turbulence_size", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "noise_size"); + RNA_def_property_range(prop, 0.01, FLT_MAX); + RNA_def_property_ui_text(prop, "Size", "Scale of the added turbulent noise"); + RNA_def_property_update(prop, NC_TEXTURE, NULL); + + prop= RNA_def_property(srna, "turbulence_depth", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "noise_depth"); + RNA_def_property_range(prop, 0, INT_MAX); + RNA_def_property_ui_text(prop, "Depth", "Level of detail in the added turbulent noise"); + RNA_def_property_update(prop, NC_TEXTURE, NULL); + + prop= RNA_def_property(srna, "turbulence_influence", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "noise_influence"); + RNA_def_property_enum_items(prop, turbulence_influence_items); + RNA_def_property_ui_text(prop, "Turbulence Influence", "Method for driving added turbulent noise"); + RNA_def_property_update(prop, NC_TEXTURE, NULL); + + + + srna= RNA_def_struct(brna, "PointDensityTexture", "Texture"); + RNA_def_struct_sdna(srna, "Tex"); + RNA_def_struct_ui_text(srna, "Point Density", "Settings for the Point Density texture"); + + prop= RNA_def_property(srna, "pointdensity", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "pd"); + RNA_def_property_struct_type(prop, "PointDensity"); + RNA_def_property_ui_text(prop, "Point Density", "The point density settings associated with this texture"); + RNA_def_property_update(prop, NC_TEXTURE, NULL); +} + +static void rna_def_texture_voxeldata(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + static EnumPropertyItem interpolation_type_items[] = { + {TEX_VD_NEARESTNEIGHBOR, "NEREASTNEIGHBOR", 0, "Nearest Neighbor", "No interpolation, fast but blocky and low quality."}, + {TEX_VD_LINEAR, "TRILINEAR", 0, "Trilinear", "Good smoothness and speed"}, + {TEX_VD_TRICUBIC, "TRICUBIC", 0, "Tricubic", "High quality interpolation, but slow"}, + {0, NULL, 0, NULL, NULL}}; + + static EnumPropertyItem file_format_items[] = { + {TEX_VD_BLENDERVOXEL, "BLENDER_VOXEL", 0, "Blender Voxel", "Default binary voxel file format"}, + {TEX_VD_RAW_8BIT, "RAW_8BIT", 0, "8 bit RAW", "8 bit greyscale binary data"}, + {TEX_VD_IMAGE_SEQUENCE, "IMAGE_SEQUENCE", 0, "Image Sequence", "Generate voxels from a sequence of image slices"}, + {TEX_VD_SMOKE, "SMOKE", 0, "Smoke", "Render voxels from a Blender smoke simulation"}, + {0, NULL, 0, NULL, NULL}}; + + srna= RNA_def_struct(brna, "VoxelData", NULL); + RNA_def_struct_sdna(srna, "VoxelData"); + RNA_def_struct_ui_text(srna, "VoxelData", "Voxel data settings."); + + prop= RNA_def_property(srna, "interpolation", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "interp_type"); + RNA_def_property_enum_items(prop, interpolation_type_items); + RNA_def_property_ui_text(prop, "Interpolation", "Method to interpolate/smooth values between voxel cells"); + RNA_def_property_update(prop, NC_TEXTURE, NULL); + + prop= RNA_def_property(srna, "intensity", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "int_multiplier"); + RNA_def_property_range(prop, 0.01, FLT_MAX); + RNA_def_property_ui_text(prop, "Intensity", "Multiplier for intensity values"); + RNA_def_property_update(prop, NC_TEXTURE, NULL); + + prop= RNA_def_property(srna, "file_format", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "file_format"); + RNA_def_property_enum_items(prop, file_format_items); + RNA_def_property_ui_text(prop, "File Format", "Format of the source data set to render "); + RNA_def_property_update(prop, NC_TEXTURE, NULL); + + prop= RNA_def_property(srna, "source_path", PROP_STRING, PROP_FILEPATH); + RNA_def_property_string_sdna(prop, NULL, "source_path"); + RNA_def_property_ui_text(prop, "Source Path", "The external source data file to use"); + RNA_def_property_update(prop, NC_TEXTURE, NULL); + + prop= RNA_def_property(srna, "resolution", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "resol"); + RNA_def_property_ui_text(prop, "Resolution", "Resolution of the voxel grid."); + RNA_def_property_update(prop, NC_TEXTURE, NULL); + + prop= RNA_def_property(srna, "still", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", TEX_VD_STILL); + RNA_def_property_ui_text(prop, "Still Frame Only", "Always render a still frame from the voxel data sequence"); + RNA_def_property_update(prop, NC_TEXTURE, NULL); + + prop= RNA_def_property(srna, "still_frame_number", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "still_frame"); + RNA_def_property_range(prop, 0, INT_MAX); + RNA_def_property_ui_text(prop, "Still Frame Number", "The frame number to always use"); + RNA_def_property_update(prop, NC_TEXTURE, NULL); + + prop= RNA_def_property(srna, "domain_object", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "object"); + RNA_def_property_ui_text(prop, "Domain Object", "Object used as the smoke simulation domain"); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_update(prop, NC_TEXTURE, NULL); + + + srna= RNA_def_struct(brna, "VoxelDataTexture", "Texture"); + RNA_def_struct_sdna(srna, "Tex"); + RNA_def_struct_ui_text(srna, "Voxel Data", "Settings for the Voxel Data texture"); + + prop= RNA_def_property(srna, "voxeldata", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "vd"); + RNA_def_property_struct_type(prop, "VoxelData"); + RNA_def_property_ui_text(prop, "Voxel Data", "The voxel data associated with this texture"); + RNA_def_property_update(prop, NC_TEXTURE, NULL); +} + static void rna_def_texture(BlenderRNA *brna) { StructRNA *srna; @@ -1191,6 +1539,8 @@ static void rna_def_texture(BlenderRNA *brna) {TEX_MUSGRAVE, "MUSGRAVE", ICON_TEXTURE, "Musgrave", ""}, {TEX_VORONOI, "VORONOI", ICON_TEXTURE, "Voronoi", ""}, {TEX_DISTNOISE, "DISTORTED_NOISE", ICON_TEXTURE, "Distorted Noise", ""}, + {TEX_POINTDENSITY, "POINT_DENSITY", ICON_TEXTURE, "Point Density", ""}, + {TEX_VOXELDATA, "VOXEL_DATA", ICON_TEXTURE, "Voxel Data", ""}, {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "Texture", "ID"); @@ -1203,6 +1553,7 @@ static void rna_def_texture(BlenderRNA *brna) //RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_enum_sdna(prop, NULL, "type"); RNA_def_property_enum_items(prop, prop_type_items); + RNA_def_property_enum_funcs(prop, NULL, "rna_Texture_type_set", NULL); RNA_def_property_ui_text(prop, "Type", ""); RNA_def_property_update(prop, NC_TEXTURE, NULL); @@ -1237,7 +1588,19 @@ static void rna_def_texture(BlenderRNA *brna) RNA_def_property_range(prop, 0, 2); RNA_def_property_ui_text(prop, "RGB Factor", ""); RNA_def_property_update(prop, NC_TEXTURE, NULL); - + + /* nodetree */ + prop= RNA_def_property(srna, "use_nodes", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "use_nodes", 1); + RNA_def_property_boolean_funcs(prop, NULL, "rna_Texture_use_nodes_set"); + RNA_def_property_ui_text(prop, "Use Nodes", "Make this a node-based texture"); + RNA_def_property_update(prop, NC_TEXTURE, NULL); + + prop= RNA_def_property(srna, "node_tree", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "nodetree"); + RNA_def_property_ui_text(prop, "Node Tree", "Node tree for node-based textures"); + RNA_def_property_update(prop, NC_TEXTURE, NULL); + rna_def_animdata_common(srna); /* specific types */ @@ -1254,6 +1617,8 @@ static void rna_def_texture(BlenderRNA *brna) rna_def_texture_musgrave(brna); rna_def_texture_voronoi(brna); rna_def_texture_distorted_noise(brna); + rna_def_texture_pointdensity(brna); + rna_def_texture_voxeldata(brna); /* XXX add more types here .. */ } diff --git a/source/blender/makesrna/intern/rna_timeline.c b/source/blender/makesrna/intern/rna_timeline.c index d42603e1952..5e20fca15f0 100644 --- a/source/blender/makesrna/intern/rna_timeline.c +++ b/source/blender/makesrna/intern/rna_timeline.c @@ -49,7 +49,7 @@ static void rna_def_timeline_marker(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Name", ""); RNA_def_struct_name_property(srna, prop); - prop= RNA_def_property(srna, "frame", PROP_INT, PROP_NONE); + prop= RNA_def_property(srna, "frame", PROP_INT, PROP_TIME); RNA_def_property_ui_text(prop, "Frame", "The frame on which the timeline marker appears."); } diff --git a/source/blender/makesrna/intern/rna_ui.c b/source/blender/makesrna/intern/rna_ui.c index 590f85fedd7..f16180451a7 100644 --- a/source/blender/makesrna/intern/rna_ui.c +++ b/source/blender/makesrna/intern/rna_ui.c @@ -138,6 +138,8 @@ static void rna_Panel_unregister(const bContext *C, StructRNA *type) if(!(art=region_type_find(NULL, pt->space_type, pt->region_type))) return; + RNA_struct_free_extension(type, &pt->ext); + BLI_freelinkN(&art->paneltypes, pt); RNA_struct_free(&BLENDER_RNA, type); @@ -146,7 +148,7 @@ static void rna_Panel_unregister(const bContext *C, StructRNA *type) WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL); } -static StructRNA *rna_Panel_register(const bContext *C, ReportList *reports, void *data, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free) +static StructRNA *rna_Panel_register(const bContext *C, ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free) { ARegionType *art; PanelType *pt, dummypt = {0}; @@ -233,6 +235,8 @@ static void rna_Header_unregister(const bContext *C, StructRNA *type) if(!(art=region_type_find(NULL, ht->space_type, RGN_TYPE_HEADER))) return; + RNA_struct_free_extension(type, &ht->ext); + BLI_freelinkN(&art->headertypes, ht); RNA_struct_free(&BLENDER_RNA, type); @@ -241,7 +245,7 @@ static void rna_Header_unregister(const bContext *C, StructRNA *type) WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL); } -static StructRNA *rna_Header_register(const bContext *C, ReportList *reports, void *data, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free) +static StructRNA *rna_Header_register(const bContext *C, ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free) { ARegionType *art; HeaderType *ht, dummyht = {0}; @@ -347,6 +351,8 @@ static void rna_Menu_unregister(const bContext *C, StructRNA *type) if(!(art=region_type_find(NULL, mt->space_type, RGN_TYPE_HEADER))) return; + RNA_struct_free_extension(type, &mt->ext); + BLI_freelinkN(&art->menutypes, mt); RNA_struct_free(&BLENDER_RNA, type); @@ -355,7 +361,7 @@ static void rna_Menu_unregister(const bContext *C, StructRNA *type) WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL); } -static StructRNA *rna_Menu_register(const bContext *C, ReportList *reports, void *data, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free) +static StructRNA *rna_Menu_register(const bContext *C, ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free) { ARegionType *art; MenuType *mt, dummymt = {0}; diff --git a/source/blender/makesrna/intern/rna_ui_api.c b/source/blender/makesrna/intern/rna_ui_api.c index 67ade9998ed..7fc2d75a708 100644 --- a/source/blender/makesrna/intern/rna_ui_api.c +++ b/source/blender/makesrna/intern/rna_ui_api.c @@ -37,6 +37,23 @@ #ifdef RNA_RUNTIME +static void rna_uiItemR(uiLayout *layout, char *name, int icon, PointerRNA *ptr, char *propname, int expand, int slider, int toggle) +{ + int flag= 0; + + flag |= (slider)? UI_ITEM_R_SLIDER: 0; + flag |= (expand)? UI_ITEM_R_EXPAND: 0; + flag |= (toggle)? UI_ITEM_R_TOGGLE: 0; + + uiItemR(layout, name, icon, ptr, propname, flag); +} + +static PointerRNA rna_uiItemO(uiLayout *layout, char *name, int icon, char *opname, int properties) +{ + int flag= (properties)? UI_ITEM_O_RETURN_PROPS: 0; + return uiItemFullO(layout, name, icon, opname, NULL, uiLayoutGetOperatorContext(layout), flag); +} + #else #define DEF_ICON(name) {name, #name, 0, #name, ""}, @@ -119,10 +136,10 @@ void RNA_api_ui_layout(StructRNA *srna) func= RNA_def_function(srna, "split", "uiLayoutSplit"); parm= RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in."); RNA_def_function_return(func, parm); - RNA_def_float(func, "percentage", 0.5f, 0.0f, 1.0f, "Percentage", "Percentage of width to split at.", 0.0f, 1.0f); + RNA_def_float(func, "percentage", 0.0f, 0.0f, 1.0f, "Percentage", "Percentage of width to split at.", 0.0f, 1.0f); /* items */ - func= RNA_def_function(srna, "itemR", "uiItemR"); + func= RNA_def_function(srna, "itemR", "rna_uiItemR"); api_ui_item_common(func); api_ui_item_rna_common(func); RNA_def_boolean(func, "expand", 0, "", "Expand button to show more detail."); @@ -150,8 +167,12 @@ void RNA_api_ui_layout(StructRNA *srna) parm= RNA_def_string(func, "search_property", "", 0, "", "Identifier of search collection property."); RNA_def_property_flag(parm, PROP_REQUIRED); - func= RNA_def_function(srna, "itemO", "uiItemO"); + func= RNA_def_function(srna, "itemO", "rna_uiItemO"); api_ui_item_op_common(func); + parm= RNA_def_boolean(func, "properties", 0, "Properties", "Return operator properties to fill in manually."); + parm= RNA_def_pointer(func, "return_properties", "OperatorProperties", "", "Operator properties to fill in, return when 'properties' is set to true."); + RNA_def_property_flag(parm, PROP_REQUIRED|PROP_RNAPTR); + RNA_def_function_return(func, parm); func= RNA_def_function(srna, "item_enumO", "uiItemEnumO_string"); api_ui_item_op_common(func); @@ -220,6 +241,7 @@ void RNA_api_ui_layout(StructRNA *srna) /* templates */ func= RNA_def_function(srna, "template_header", "uiTemplateHeader"); RNA_def_function_flag(func, FUNC_USE_CONTEXT); + RNA_def_boolean(func, "menus", 1, "", "The header has menus, and should show menu expander."); func= RNA_def_function(srna, "template_ID", "uiTemplateID"); RNA_def_function_flag(func, FUNC_USE_CONTEXT); @@ -243,11 +265,13 @@ void RNA_api_ui_layout(StructRNA *srna) parm= RNA_def_pointer(func, "id", "ID", "", "ID datablock."); RNA_def_property_flag(parm, PROP_REQUIRED); parm= RNA_def_pointer(func, "parent", "ID", "", "ID datablock."); + parm= RNA_def_pointer(func, "slot", "TextureSlot", "", "Texture slot."); func= RNA_def_function(srna, "template_curve_mapping", "uiTemplateCurveMapping"); parm= RNA_def_pointer(func, "curvemap", "CurveMapping", "", "Curve mapping pointer."); RNA_def_property_flag(parm, PROP_REQUIRED); RNA_def_enum(func, "type", curve_type_items, 0, "Type", "Type of curves to display."); + RNA_def_boolean(func, "compact", 0, "", "Use more compact curve mapping."); func= RNA_def_function(srna, "template_color_ramp", "uiTemplateColorRamp"); parm= RNA_def_pointer(func, "ramp", "ColorRamp", "", "Color ramp pointer."); @@ -287,6 +311,9 @@ void RNA_api_ui_layout(StructRNA *srna) func= RNA_def_function(srna, "template_header_3D", "uiTemplateHeader3D"); RNA_def_function_flag(func, FUNC_USE_CONTEXT); + func= RNA_def_function(srna, "view3d_select_faceselmenu", "uiTemplate_view3d_select_faceselmenu"); + RNA_def_function_flag(func, FUNC_USE_CONTEXT); + func= RNA_def_function(srna, "template_texture_image", "uiTemplateTextureImage"); RNA_def_function_flag(func, FUNC_USE_CONTEXT); parm= RNA_def_pointer(func, "texture", "Texture", "", ""); diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index f1fd11a0094..946aa1cd682 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -37,6 +37,8 @@ #include "BKE_utildefines.h" +#include "BKE_sound.h" + #ifdef RNA_RUNTIME static void rna_userdef_lmb_select_set(struct PointerRNA *ptr,int value) @@ -116,6 +118,11 @@ static PointerRNA rna_UserDef_system_get(PointerRNA *ptr) return rna_pointer_inherit_refine(ptr, &RNA_UserPreferencesSystem, ptr->data); } +static void rna_UserDef_audio_update(bContext *C, PointerRNA *ptr) +{ + sound_init(C); +} + #else static void rna_def_userdef_theme_ui_font_style(BlenderRNA *brna) @@ -683,7 +690,7 @@ static void rna_def_userdef_theme_space_graph(BlenderRNA *brna) srna= RNA_def_struct(brna, "ThemeGraphEditor", NULL); RNA_def_struct_sdna(srna, "ThemeSpace"); - RNA_def_struct_ui_text(srna, "Theme Graph Editor", "Theme settings for the Ipo Editor."); + RNA_def_struct_ui_text(srna, "Theme Graph Editor", "Theme settings for the graph editor."); rna_def_userdef_theme_spaces_main(srna, SPACE_IPO); @@ -820,19 +827,33 @@ static void rna_def_userdef_theme_space_outliner(BlenderRNA *brna) rna_def_userdef_theme_spaces_main(srna, SPACE_OUTLINER); } -static void rna_def_userdef_theme_space_info(BlenderRNA *brna) +static void rna_def_userdef_theme_space_userpref(BlenderRNA *brna) { StructRNA *srna; - /* space_info */ + /* space_userpref */ srna= RNA_def_struct(brna, "ThemeUserPreferences", NULL); RNA_def_struct_sdna(srna, "ThemeSpace"); RNA_def_struct_ui_text(srna, "Theme User Preferences", "Theme settings for the User Preferences."); + rna_def_userdef_theme_spaces_main(srna, SPACE_USERPREF); +} + +static void rna_def_userdef_theme_space_info(BlenderRNA *brna) +{ + StructRNA *srna; + + /* space_info */ + + srna= RNA_def_struct(brna, "ThemeInfo", NULL); + RNA_def_struct_sdna(srna, "ThemeSpace"); + RNA_def_struct_ui_text(srna, "Theme Info", "Theme settings for Info."); + rna_def_userdef_theme_spaces_main(srna, SPACE_INFO); } + static void rna_def_userdef_theme_space_text(BlenderRNA *brna) { StructRNA *srna; @@ -990,9 +1011,9 @@ static void rna_def_userdef_theme_space_buts(BlenderRNA *brna) /* space_buts */ - srna= RNA_def_struct(brna, "ThemeButtonsWindow", NULL); + srna= RNA_def_struct(brna, "ThemeProperties", NULL); RNA_def_struct_sdna(srna, "ThemeSpace"); - RNA_def_struct_ui_text(srna, "Theme Buttons Window", "Theme settings for the Buttons Window."); + RNA_def_struct_ui_text(srna, "Theme Properties", "Theme settings for the Properties."); rna_def_userdef_theme_spaces_main(srna, SPACE_BUTS); @@ -1393,10 +1414,10 @@ static void rna_def_userdef_themes(BlenderRNA *brna) RNA_def_property_struct_type(prop, "ThemeSequenceEditor"); RNA_def_property_ui_text(prop, "Sequence Editor", ""); - prop= RNA_def_property(srna, "buttons_window", PROP_POINTER, PROP_NEVER_NULL); + prop= RNA_def_property(srna, "properties", PROP_POINTER, PROP_NEVER_NULL); RNA_def_property_pointer_sdna(prop, NULL, "tbuts"); - RNA_def_property_struct_type(prop, "ThemeButtonsWindow"); - RNA_def_property_ui_text(prop, "Buttons Window", ""); + RNA_def_property_struct_type(prop, "ThemeProperties"); + RNA_def_property_ui_text(prop, "Properties", ""); prop= RNA_def_property(srna, "text_editor", PROP_POINTER, PROP_NEVER_NULL); RNA_def_property_pointer_sdna(prop, NULL, "text"); @@ -1423,8 +1444,13 @@ static void rna_def_userdef_themes(BlenderRNA *brna) RNA_def_property_struct_type(prop, "ThemeOutliner"); RNA_def_property_ui_text(prop, "Outliner", ""); - prop= RNA_def_property(srna, "user_preferences", PROP_POINTER, PROP_NEVER_NULL); + prop= RNA_def_property(srna, "info", PROP_POINTER, PROP_NEVER_NULL); RNA_def_property_pointer_sdna(prop, NULL, "tinfo"); + RNA_def_property_struct_type(prop, "ThemeInfo"); + RNA_def_property_ui_text(prop, "Info", ""); + + prop= RNA_def_property(srna, "user_preferences", PROP_POINTER, PROP_NEVER_NULL); + RNA_def_property_pointer_sdna(prop, NULL, "tuserpref"); RNA_def_property_struct_type(prop, "ThemeUserPreferences"); RNA_def_property_ui_text(prop, "User Preferences", ""); @@ -1453,6 +1479,7 @@ static void rna_def_userdef_dothemes(BlenderRNA *brna) rna_def_userdef_theme_space_node(brna); rna_def_userdef_theme_space_outliner(brna); rna_def_userdef_theme_space_info(brna); + rna_def_userdef_theme_space_userpref(brna); rna_def_userdef_theme_space_sound(brna); rna_def_userdef_theme_space_logic(brna); rna_def_userdef_theme_colorset(brna); @@ -1472,7 +1499,7 @@ static void rna_def_userdef_solidlight(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "flag", 1); RNA_def_property_ui_text(prop, "Enabled", "Enable this OpenGL light in solid draw mode."); - prop= RNA_def_property(srna, "direction", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "direction", PROP_FLOAT, PROP_DIRECTION); RNA_def_property_float_sdna(prop, NULL, "vec"); RNA_def_property_array(prop, 3); RNA_def_property_ui_text(prop, "Direction", "The direction that the OpenGL light is shining."); @@ -1635,16 +1662,19 @@ static void rna_def_userdef_view(BlenderRNA *brna) prop= RNA_def_property(srna, "show_mini_axis", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "uiflag", USER_SHOW_ROTVIEWICON); RNA_def_property_ui_text(prop, "Show Mini Axis", "Show a small rotating 3D axis in the bottom left corner of the 3D View."); + RNA_def_property_update(prop, NC_WINDOW, NULL); prop= RNA_def_property(srna, "mini_axis_size", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "rvisize"); RNA_def_property_range(prop, 10, 64); RNA_def_property_ui_text(prop, "Mini Axis Size", "The axis icon's size."); + RNA_def_property_update(prop, NC_WINDOW, NULL); prop= RNA_def_property(srna, "mini_axis_brightness", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "rvibright"); RNA_def_property_range(prop, 0, 10); RNA_def_property_ui_text(prop, "Mini Axis Brightness", "The brightness of the icon."); + RNA_def_property_update(prop, NC_WINDOW, NULL); /* middle mouse button */ prop= RNA_def_property(srna, "middle_mouse_rotate", PROP_BOOLEAN, PROP_NONE); @@ -1678,16 +1708,19 @@ static void rna_def_userdef_view(BlenderRNA *brna) prop= RNA_def_property(srna, "use_manipulator", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "tw_flag", 1); RNA_def_property_ui_text(prop, "Manipulator", "Use 3d transform manipulator."); + RNA_def_property_update(prop, NC_WINDOW, NULL); prop= RNA_def_property(srna, "manipulator_size", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "tw_size"); RNA_def_property_range(prop, 2, 40); RNA_def_property_ui_text(prop, "Manipulator Size", "Diameter of widget, in 10 pixel units."); + RNA_def_property_update(prop, NC_WINDOW, NULL); prop= RNA_def_property(srna, "manipulator_handle_size", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "tw_handlesize"); RNA_def_property_range(prop, 2, 40); RNA_def_property_ui_text(prop, "Manipulator Handle Size", "Size of widget handles as percentage of widget radius."); + RNA_def_property_update(prop, NC_WINDOW, NULL); prop= RNA_def_property(srna, "manipulator_hotspot", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "tw_hotspot"); @@ -1698,6 +1731,7 @@ static void rna_def_userdef_view(BlenderRNA *brna) RNA_def_property_int_sdna(prop, NULL, "obcenter_dia"); RNA_def_property_range(prop, 4, 10); RNA_def_property_ui_text(prop, "Object Center Size", "Diameter in Pixels for Object/Lamp center display."); + RNA_def_property_update(prop, NC_WINDOW, NULL); prop= RNA_def_property(srna, "ndof_pan_speed", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "ndof_pan"); @@ -1819,11 +1853,9 @@ static void rna_def_userdef_edit(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "gp_settings", GP_PAINT_DOSMOOTH); RNA_def_property_ui_text(prop, "Grease Pencil Smooth Stroke", "Smooth the final stroke."); -#if 0 prop= RNA_def_property(srna, "grease_pencil_simplify_stroke", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "gp_settings", GP_PAINT_DOSIMPLIFY); RNA_def_property_ui_text(prop, "Grease Pencil Simplify Stroke", "Simplify the final stroke."); -#endif prop= RNA_def_property(srna, "grease_pencil_eraser_radius", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "gp_eraser"); @@ -1977,6 +2009,47 @@ static void rna_def_userdef_system(BlenderRNA *brna) {512, "AUDIO_SAMPLES_512", 0, "512", "Set audio mixing buffer size to 512 samples"}, {1024, "AUDIO_SAMPLES_1024", 0, "1024", "Set audio mixing buffer size to 1024 samples"}, {2048, "AUDIO_SAMPLES_2048", 0, "2048", "Set audio mixing buffer size to 2048 samples"}, + {4096, "AUDIO_SAMPLES_4096", 0, "4096", "Set audio mixing buffer size to 4096 samples"}, + {8192, "AUDIO_SAMPLES_8192", 0, "8192", "Set audio mixing buffer size to 8192 samples"}, + {16384, "AUDIO_SAMPLES_16384", 0, "16384", "Set audio mixing buffer size to 16384 samples"}, + {32768, "AUDIO_SAMPLES_32768", 0, "32768", "Set audio mixing buffer size to 32768 samples"}, + {0, NULL, 0, NULL, NULL}}; + + static EnumPropertyItem audio_device_items[] = { + {0, "AUDIO_DEVICE_NULL", 0, "No Audio", "Null device - there will be no audio output."}, + {1, "AUDIO_DEVICE_SDL", 0, "SDL", "SDL device - simple direct media layer, recommended for sequencer usage."}, + {2, "AUDIO_DEVICE_OPENAL", 0, "OpenAL", "OpenAL device - supports 3D audio, recommended for game engine usage."}, + {3, "AUDIO_DEVICE_JACK", 0, "Jack", "Jack device - open source pro audio, recommended for pro audio users."}, + {0, NULL, 0, NULL, NULL}}; + + static EnumPropertyItem audio_rate_items[] = { +// {8000, "AUDIO_RATE_8000", 0, "8 kHz", "Set audio sampling rate to 8000 samples per second."}, +// {11025, "AUDIO_RATE_11025", 0, "11.025 kHz", "Set audio sampling rate to 11025 samples per second."}, +// {16000, "AUDIO_RATE_16000", 0, "16 kHz", "Set audio sampling rate to 16000 samples per second."}, +// {22050, "AUDIO_RATE_22050", 0, "22.05 kHz", "Set audio sampling rate to 22050 samples per second."}, +// {32000, "AUDIO_RATE_32000", 0, "32 kHz", "Set audio sampling rate to 32000 samples per second."}, + {44100, "AUDIO_RATE_44100", 0, "44.1 kHz", "Set audio sampling rate to 44100 samples per second."}, + {48000, "AUDIO_RATE_48000", 0, "48 kHz", "Set audio sampling rate to 48000 samples per second."}, +// {88200, "AUDIO_RATE_88200", 0, "88.2 kHz", "Set audio sampling rate to 88200 samples per second."}, + {96000, "AUDIO_RATE_96000", 0, "96 kHz", "Set audio sampling rate to 96000 samples per second."}, + {192000, "AUDIO_RATE_192000", 0, "192 kHz", "Set audio sampling rate to 192000 samples per second."}, + {0, NULL, 0, NULL, NULL}}; + + static EnumPropertyItem audio_format_items[] = { + {0x01, "AUDIO_FORMAT_U8", 0, "8-bit Unsigned", "Set audio sample format to 8 bit unsigned integer."}, + {0x12, "AUDIO_FORMAT_S16", 0, "16-bit Signed", "Set audio sample format to 16 bit signed integer."}, + {0x13, "AUDIO_FORMAT_S24", 0, "24-bit Signed", "Set audio sample format to 24 bit signed integer."}, + {0x14, "AUDIO_FORMAT_S32", 0, "32-bit Signed", "Set audio sample format to 32 bit signed integer."}, + {0x24, "AUDIO_FORMAT_FLOAT", 0, "32-bit Float", "Set audio sample format to 32 bit float."}, + {0x28, "AUDIO_FORMAT_DOUBLE", 0, "64-bit Float", "Set audio sample format to 64 bit float."}, + {0, NULL, 0, NULL, NULL}}; + + static EnumPropertyItem audio_channel_items[] = { + {1, "AUDIO_CHANNELS_MONO", 0, "Mono", "Set audio channels to mono."}, + {2, "AUDIO_CHANNELS_STEREO", 0, "Stereo", "Set audio channels to stereo."}, + {4, "AUDIO_CHANNELS_SURROUND4", 0, "4 Channels", "Set audio channels to 4 channels."}, + {6, "AUDIO_CHANNELS_SURROUND51", 0, "5.1 Surround", "Set audio channels to 5.1 surround sound."}, + {8, "AUDIO_CHANNELS_SURROUND71", 0, "7.1 Surround", "Set audio channels to 7.1 surround sound."}, {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem draw_method_items[] = { @@ -2078,6 +2151,31 @@ static void rna_def_userdef_system(BlenderRNA *brna) RNA_def_property_enum_sdna(prop, NULL, "mixbufsize"); RNA_def_property_enum_items(prop, audio_mixing_samples_items); RNA_def_property_ui_text(prop, "Audio Mixing Buffer", "Sets the number of samples used by the audio mixing buffer."); + RNA_def_property_update(prop, 0, "rna_UserDef_audio_update"); + + prop= RNA_def_property(srna, "audio_device", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "audiodevice"); + RNA_def_property_enum_items(prop, audio_device_items); + RNA_def_property_ui_text(prop, "Audio Device", "Sets the audio output device."); + RNA_def_property_update(prop, 0, "rna_UserDef_audio_update"); + + prop= RNA_def_property(srna, "audio_sample_rate", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "audiorate"); + RNA_def_property_enum_items(prop, audio_rate_items); + RNA_def_property_ui_text(prop, "Audio Sample Rate", "Sets the audio sample rate."); + RNA_def_property_update(prop, 0, "rna_UserDef_audio_update"); + + prop= RNA_def_property(srna, "audio_sample_format", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "audioformat"); + RNA_def_property_enum_items(prop, audio_format_items); + RNA_def_property_ui_text(prop, "Audio Sample Format", "Sets the audio sample format."); + RNA_def_property_update(prop, 0, "rna_UserDef_audio_update"); + + prop= RNA_def_property(srna, "audio_channels", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "audiochannels"); + RNA_def_property_enum_items(prop, audio_channel_items); + RNA_def_property_ui_text(prop, "Audio Channels", "Sets the audio channel count."); + RNA_def_property_update(prop, 0, "rna_UserDef_audio_update"); #if 0 prop= RNA_def_property(srna, "verse_master", PROP_STRING, PROP_NONE); @@ -2108,6 +2206,10 @@ static void rna_def_userdef_filepaths(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "flag", USER_FILECOMPRESS); RNA_def_property_ui_text(prop, "Compress File", "Enable file compression when saving .blend files."); + prop= RNA_def_property(srna, "load_ui", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", USER_FILENOUI); + RNA_def_property_ui_text(prop, "Load UI", "Load user interface setup when loading .blend files."); + prop= RNA_def_property(srna, "fonts_directory", PROP_STRING, PROP_DIRPATH); RNA_def_property_string_sdna(prop, NULL, "fontdir"); RNA_def_property_ui_text(prop, "Fonts Directory", "The default directory to search for loading fonts."); diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c index 4a2154bc3cf..eaed0100386 100644 --- a/source/blender/makesrna/intern/rna_wm.c +++ b/source/blender/makesrna/intern/rna_wm.c @@ -297,7 +297,7 @@ static void rna_def_operator_utils(BlenderRNA *brna) srna= RNA_def_struct(brna, "OperatorMousePath", "IDPropertyGroup"); RNA_def_struct_ui_text(srna, "Operator Mouse Path", "Mouse path values for operators that record such paths."); - prop= RNA_def_property(srna, "loc", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "loc", PROP_FLOAT, PROP_XYZ); RNA_def_property_flag(prop, PROP_IDPROPERTY); RNA_def_property_array(prop, 2); RNA_def_property_ui_text(prop, "Location", "Mouse location."); diff --git a/source/blender/makesrna/intern/rna_world.c b/source/blender/makesrna/intern/rna_world.c index f23b893539d..525a4446932 100644 --- a/source/blender/makesrna/intern/rna_world.c +++ b/source/blender/makesrna/intern/rna_world.c @@ -154,25 +154,25 @@ static void rna_def_world_mtex(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Object", "Object to use for mapping with Object texture coordinates."); RNA_def_property_update(prop, NC_TEXTURE, NULL); - prop= RNA_def_property(srna, "blend_factor", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "blend_factor", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "varfac"); RNA_def_property_ui_range(prop, 0, 1, 10, 3); RNA_def_property_ui_text(prop, "Blend Factor", "Amount texture affects color progression of the background."); RNA_def_property_update(prop, NC_TEXTURE, NULL); - prop= RNA_def_property(srna, "horizon_factor", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "horizon_factor", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "colfac"); RNA_def_property_ui_range(prop, 0, 1, 10, 3); RNA_def_property_ui_text(prop, "Horizon Factor", "Amount texture affects color of the horizon."); RNA_def_property_update(prop, NC_TEXTURE, NULL); - prop= RNA_def_property(srna, "zenith_up_factor", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "zenith_up_factor", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "colfac"); RNA_def_property_ui_range(prop, 0, 1, 10, 3); RNA_def_property_ui_text(prop, "Zenith Up Factor", "Amount texture affects color of the zenith above."); RNA_def_property_update(prop, NC_TEXTURE, NULL); - prop= RNA_def_property(srna, "zenith_down_factor", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "zenith_down_factor", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "colfac"); RNA_def_property_ui_range(prop, 0, 1, 10, 3); RNA_def_property_ui_text(prop, "Zenith Down Factor", "Amount texture affects color of the zenith below."); @@ -216,7 +216,7 @@ static void rna_def_ambient_occlusion(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "mode", WO_AMB_OCC); RNA_def_property_ui_text(prop, "Enabled", "Use Ambient Occlusion to add light based on distance between elements, creating the illusion of omnipresent light"); - prop= RNA_def_property(srna, "distance", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "distance", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "aodist"); RNA_def_property_ui_text(prop, "Distance", "Length of rays, defines how far away other faces give occlusion effect."); @@ -319,19 +319,19 @@ static void rna_def_world_mist(BlenderRNA *brna) RNA_def_property_range(prop, 0, 1); RNA_def_property_ui_text(prop, "Intensity", "Intensity of the mist effect."); - prop= RNA_def_property(srna, "start", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "start", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "miststa"); RNA_def_property_range(prop, 0, FLT_MAX); RNA_def_property_ui_range(prop, 0, 10000, 10, 2); RNA_def_property_ui_text(prop, "Start", "Starting distance of the mist, measured from the camera"); - prop= RNA_def_property(srna, "depth", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "depth", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "mistdist"); RNA_def_property_range(prop, 0, FLT_MAX); RNA_def_property_ui_range(prop, 0, 10000, 10, 2); RNA_def_property_ui_text(prop, "Depth", "The distance over which the mist effect fades in"); - prop= RNA_def_property(srna, "height", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "height", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "misthi"); RNA_def_property_range(prop, 0, 100); RNA_def_property_ui_text(prop, "Height", "Control how much mist density decreases with height"); @@ -363,7 +363,7 @@ static void rna_def_world_stars(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Size", "Average screen dimension of stars."); RNA_def_property_update(prop, NC_WORLD, NULL); - prop= RNA_def_property(srna, "min_distance", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "min_distance", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "starmindist"); RNA_def_property_range(prop, 0, 1000); RNA_def_property_ui_text(prop, "Minimum Distance", "Minimum distance to the camera for stars."); diff --git a/source/blender/nodes/CMakeLists.txt b/source/blender/nodes/CMakeLists.txt index 664aacf11ab..bba96adf25e 100644 --- a/source/blender/nodes/CMakeLists.txt +++ b/source/blender/nodes/CMakeLists.txt @@ -29,9 +29,8 @@ SET(INC . ../../../intern/guardedalloc ../editors/include ../blenlib ../makesdna ../render/extern/include ../../../intern/decimation/extern ../makesrna ../imbuf ../avi ../../../intern/elbeem/extern - ../../../intern/iksolver/extern ../blenloader ../quicktime + ../../../intern/iksolver/extern ../blenloader ../blenkernel ../../../extern/glew/include ../gpu - ${SDL_INC} ${ZLIB_INC} ) @@ -40,7 +39,7 @@ IF(WITH_OPENEXR) ENDIF(WITH_OPENEXR) IF(WITH_QUICKTIME) - SET(INC ${INC} ${QUICKTIME_INC}) + SET(INC ${INC} ../quicktime ${QUICKTIME_INC}) ADD_DEFINITIONS(-DWITH_QUICKTIME) ENDIF(WITH_QUICKTIME) diff --git a/source/blender/nodes/intern/SHD_nodes/SHD_dynamic.c b/source/blender/nodes/intern/SHD_nodes/SHD_dynamic.c index fbc56dfcc83..693a20b5b0f 100644 --- a/source/blender/nodes/intern/SHD_nodes/SHD_dynamic.c +++ b/source/blender/nodes/intern/SHD_nodes/SHD_dynamic.c @@ -34,9 +34,7 @@ #endif /* TODO, support python3.x */ -#if PY_VERSION_HEX >= 0x03000000 #define DISABLE_PYTHON 1 -#endif #include "DNA_text_types.h" #include "BKE_text.h" diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_at.c b/source/blender/nodes/intern/TEX_nodes/TEX_at.c index 80f232ccd0c..4d714d91130 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_at.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_at.c @@ -38,12 +38,14 @@ static bNodeSocketType outputs[]= { { -1, 0, "" } }; -static void colorfn(float *out, float *coord, bNode *node, bNodeStack **in, short thread) +static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread) { + TexParams np = *p; float new_coord[3]; + np.coord = new_coord; - tex_input_vec(new_coord, in[1], coord, thread); - tex_input_rgba(out, in[0], new_coord, thread); + tex_input_vec(new_coord, in[1], p, thread); + tex_input_rgba(out, in[0], &np, thread); } static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out) diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_bricks.c b/source/blender/nodes/intern/TEX_nodes/TEX_bricks.c index 80cbd6188ee..f1f3b0919ae 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_bricks.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_bricks.c @@ -21,7 +21,7 @@ * * The Original Code is: all of this file. * - * Contributor(s): none yet. + * Contributor(s): Robin Allen * * ***** END GPL LICENSE BLOCK ***** */ @@ -57,8 +57,10 @@ static float noise(int n) /* fast integer noise */ return 0.5f * ((float)nn / 1073741824.0f); } -static void colorfn(float *out, float *coord, bNode *node, bNodeStack **in, short thread) +static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread) { + float *coord = p->coord; + float x = coord[0]; float y = coord[1]; @@ -71,14 +73,14 @@ static void colorfn(float *out, float *coord, bNode *node, bNodeStack **in, shor float bricks2[4]; float mortar[4]; - float mortar_thickness = tex_input_value(in[3], coord, thread); - float bias = tex_input_value(in[4], coord, thread); - float brick_width = tex_input_value(in[5], coord, thread); - float row_height = tex_input_value(in[6], coord, thread); + float mortar_thickness = tex_input_value(in[3], p, thread); + float bias = tex_input_value(in[4], p, thread); + float brick_width = tex_input_value(in[5], p, thread); + float row_height = tex_input_value(in[6], p, thread); - tex_input_rgba(bricks1, in[0], coord, thread); - tex_input_rgba(bricks2, in[1], coord, thread); - tex_input_rgba(mortar, in[2], coord, thread); + tex_input_rgba(bricks1, in[0], p, thread); + tex_input_rgba(bricks2, in[1], p, thread); + tex_input_rgba(mortar, in[2], p, thread); rownum = (int)floor(y / row_height); diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_checker.c b/source/blender/nodes/intern/TEX_nodes/TEX_checker.c index 60357782e25..b889f1e2164 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_checker.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_checker.c @@ -21,7 +21,7 @@ * * The Original Code is: all of this file. * - * Contributor(s): none yet. + * Contributor(s): Robin Allen * * ***** END GPL LICENSE BLOCK ***** */ @@ -40,12 +40,12 @@ static bNodeSocketType outputs[]= { { -1, 0, "" } }; -static void colorfn(float *out, float *coord, bNode *node, bNodeStack **in, short thread) +static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread) { - float x = coord[0]; - float y = coord[1]; - float z = coord[2]; - float sz = tex_input_value(in[2], coord, thread); + float x = p->coord[0]; + float y = p->coord[1]; + float z = p->coord[2]; + float sz = tex_input_value(in[2], p, thread); /* 0.00001 because of unit sized stuff */ int xi = (int)fabs(floor(0.00001 + x / sz)); @@ -53,9 +53,9 @@ static void colorfn(float *out, float *coord, bNode *node, bNodeStack **in, shor int zi = (int)fabs(floor(0.00001 + z / sz)); if( (xi % 2 == yi % 2) == (zi % 2) ) { - tex_input_rgba(out, in[0], coord, thread); + tex_input_rgba(out, in[0], p, thread); } else { - tex_input_rgba(out, in[1], coord, thread); + tex_input_rgba(out, in[1], p, thread); } } diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_compose.c b/source/blender/nodes/intern/TEX_nodes/TEX_compose.c index 26576befa3e..9fc4b2ff7c2 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_compose.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_compose.c @@ -21,7 +21,7 @@ * * The Original Code is: all of this file. * - * Contributor(s): none yet. + * Contributor(s): Robin Allen * * ***** END GPL LICENSE BLOCK ***** */ @@ -40,11 +40,11 @@ static bNodeSocketType outputs[]= { { -1, 0, "" } }; -static void colorfn(float *out, float *coord, bNode *node, bNodeStack **in, short thread) +static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread) { int i; for(i = 0; i < 4; i++) - out[i] = tex_input_value(in[i], coord, thread); + out[i] = tex_input_value(in[i], p, thread); } static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out) diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_coord.c b/source/blender/nodes/intern/TEX_nodes/TEX_coord.c index da487c190af..e5c2b309fb3 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_coord.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_coord.c @@ -33,11 +33,11 @@ static bNodeSocketType outputs[]= { { -1, 0, "" } }; -static void vectorfn(float *out, float *coord, bNode *node, bNodeStack **in, short thread) +static void vectorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread) { - out[0] = coord[0]; - out[1] = coord[1]; - out[2] = coord[2]; + out[0] = p->coord[0]; + out[1] = p->coord[1]; + out[2] = p->coord[2]; } static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out) diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_curves.c b/source/blender/nodes/intern/TEX_nodes/TEX_curves.c index 7d1366b5b18..61ebcea7360 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_curves.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_curves.c @@ -21,7 +21,7 @@ * * The Original Code is: all of this file. * - * Contributor(s): none yet. + * Contributor(s): Robin Allen * * ***** END GPL LICENSE BLOCK ***** */ @@ -36,14 +36,13 @@ static bNodeSocketType time_outputs[]= { { -1, 0, "" } }; -static void time_colorfn(float *out, float *coord, bNode *node, bNodeStack **in, short thread) +static void time_colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread) { /* stack order output: fac */ float fac= 0.0f; - // XXX SOLVE! these functions should get the TexCallData pointer -// if(node->custom1 < node->custom2) -// fac = (scene->r.cfra - node->custom1)/(float)(node->custom2-node->custom1); + if(node->custom1 < node->custom2) + fac = (p->cfra - node->custom1)/(float)(node->custom2-node->custom1); fac = curvemapping_evaluateF(node->storage, 0, fac); out[0] = CLAMPIS(fac, 0.0f, 1.0f); @@ -90,10 +89,10 @@ static bNodeSocketType rgb_outputs[]= { { -1, 0, "" } }; -static void rgb_colorfn(float *out, float *coord, bNode *node, bNodeStack **in, short thread) +static void rgb_colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread) { float cin[4]; - tex_input_rgba(cin, in[0], coord, thread); + tex_input_rgba(cin, in[0], p, thread); curvemapping_evaluateRGBF(node->storage, out, cin); out[3] = cin[3]; diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_decompose.c b/source/blender/nodes/intern/TEX_nodes/TEX_decompose.c index c08eb12a18f..f7a409f0230 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_decompose.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_decompose.c @@ -21,7 +21,7 @@ * * The Original Code is: all of this file. * - * Contributor(s): none yet. + * Contributor(s): Robin Allen * * ***** END GPL LICENSE BLOCK ***** */ @@ -41,27 +41,27 @@ static bNodeSocketType outputs[]= { { -1, 0, "" } }; -static void valuefn_r(float *out, float *coord, bNode *node, bNodeStack **in, short thread) +static void valuefn_r(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread) { - tex_input_rgba(out, in[0], coord, thread); + tex_input_rgba(out, in[0], p, thread); *out = out[0]; } -static void valuefn_g(float *out, float *coord, bNode *node, bNodeStack **in, short thread) +static void valuefn_g(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread) { - tex_input_rgba(out, in[0], coord, thread); + tex_input_rgba(out, in[0], p, thread); *out = out[1]; } -static void valuefn_b(float *out, float *coord, bNode *node, bNodeStack **in, short thread) +static void valuefn_b(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread) { - tex_input_rgba(out, in[0], coord, thread); + tex_input_rgba(out, in[0], p, thread); *out = out[2]; } -static void valuefn_a(float *out, float *coord, bNode *node, bNodeStack **in, short thread) +static void valuefn_a(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread) { - tex_input_rgba(out, in[0], coord, thread); + tex_input_rgba(out, in[0], p, thread); *out = out[3]; } diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_distance.c b/source/blender/nodes/intern/TEX_nodes/TEX_distance.c index d23eb6bc589..4e145e26b72 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_distance.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_distance.c @@ -41,12 +41,12 @@ static bNodeSocketType outputs[]= { { -1, 0, "" } }; -static void valuefn(float *out, float *coord, bNode *node, bNodeStack **in, short thread) +static void valuefn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread) { float coord1[3], coord2[3]; - tex_input_vec(coord1, in[0], coord, thread); - tex_input_vec(coord2, in[1], coord, thread); + tex_input_vec(coord1, in[0], p, thread); + tex_input_vec(coord2, in[1], p, thread); *out = VecLenf(coord2, coord1); } diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_hueSatVal.c b/source/blender/nodes/intern/TEX_nodes/TEX_hueSatVal.c index bb1a49fb235..192c7a39ee8 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_hueSatVal.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_hueSatVal.c @@ -65,15 +65,15 @@ static void do_hue_sat_fac(bNode *node, float *out, float hue, float sat, float } } -static void colorfn(float *out, float *coord, bNode *node, bNodeStack **in, short thread) +static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread) { - float hue = tex_input_value(in[0], coord, thread); - float sat = tex_input_value(in[1], coord, thread); - float val = tex_input_value(in[2], coord, thread); - float fac = tex_input_value(in[3], coord, thread); + float hue = tex_input_value(in[0], p, thread); + float sat = tex_input_value(in[1], p, thread); + float val = tex_input_value(in[2], p, thread); + float fac = tex_input_value(in[3], p, thread); float col[4]; - tex_input_rgba(col, in[4], coord, thread); + tex_input_rgba(col, in[4], p, thread); hue += 0.5f; /* [-.5, .5] -> [0, 1] */ diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_image.c b/source/blender/nodes/intern/TEX_nodes/TEX_image.c index b84088da154..0a55af70b52 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_image.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_image.c @@ -22,7 +22,7 @@ * * The Original Code is: all of this file. * - * Contributor(s): none yet. + * Contributor(s): Robin Allen * * ***** END GPL LICENSE BLOCK ***** */ @@ -34,10 +34,10 @@ static bNodeSocketType outputs[]= { { -1, 0, "" } }; -static void colorfn(float *out, float *coord, bNode *node, bNodeStack **in, short thread) +static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread) { - float x = coord[0]; - float y = coord[1]; + float x = p->coord[0]; + float y = p->coord[1]; Image *ima= (Image *)node->id; ImageUser *iuser= (ImageUser *)node->storage; diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_invert.c b/source/blender/nodes/intern/TEX_nodes/TEX_invert.c index 09716951009..5663f897ff5 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_invert.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_invert.c @@ -21,7 +21,7 @@ * * The Original Code is: all of this file. * - * Contributor(s): none yet. + * Contributor(s): Robin Allen * * ***** END GPL LICENSE BLOCK ***** */ @@ -39,11 +39,11 @@ static bNodeSocketType outputs[]= { { -1, 0, "" } }; -static void colorfn(float *out, float *coord, bNode *node, bNodeStack **in, short thread) +static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread) { float col[4]; - tex_input_rgba(col, in[0], coord, thread); + tex_input_rgba(col, in[0], p, thread); col[0] = 1.0f - col[0]; col[1] = 1.0f - col[1]; diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_math.c b/source/blender/nodes/intern/TEX_nodes/TEX_math.c index bac91fc0901..4ee04140fca 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_math.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_math.c @@ -21,7 +21,7 @@ * * The Original Code is: all of this file. * - * Contributor(s): none yet. + * Contributor(s): Robin Allen * * ***** END GPL LICENSE BLOCK ***** */ @@ -42,10 +42,10 @@ static bNodeSocketType outputs[]= { { -1, 0, "" } }; -static void valuefn(float *out, float *coord, bNode *node, bNodeStack **in, short thread) +static void valuefn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread) { - float in0 = tex_input_value(in[0], coord, thread); - float in1 = tex_input_value(in[1], coord, thread); + float in0 = tex_input_value(in[0], p, thread); + float in1 = tex_input_value(in[1], p, thread); switch(node->custom1){ diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_mixRgb.c b/source/blender/nodes/intern/TEX_nodes/TEX_mixRgb.c index b1ccb7a3d07..24bdde70127 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_mixRgb.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_mixRgb.c @@ -21,7 +21,7 @@ * * The Original Code is: all of this file. * - * Contributor(s): none yet. + * Contributor(s): Robin Allen * * ***** END GPL LICENSE BLOCK ***** */ @@ -41,13 +41,13 @@ static bNodeSocketType outputs[]= { { -1, 0, "" } }; -static void colorfn(float *out, float *coord, bNode *node, bNodeStack **in, short thread) +static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread) { - float fac = tex_input_value(in[0], coord, thread); + float fac = tex_input_value(in[0], p, thread); float col1[4], col2[4]; - tex_input_rgba(col1, in[1], coord, thread); - tex_input_rgba(col2, in[2], coord, thread); + tex_input_rgba(col1, in[1], p, thread); + tex_input_rgba(col2, in[2], p, thread); CLAMP(fac, 0.0f, 1.0f); diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_output.c b/source/blender/nodes/intern/TEX_nodes/TEX_output.c index 060ea8d7e67..7ce5ec88c48 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_output.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_output.c @@ -21,7 +21,7 @@ * * The Original Code is: all of this file. * - * Contributor(s): none yet. + * Contributor(s): Robin Allen * * ***** END GPL LICENSE BLOCK ***** */ @@ -35,6 +35,48 @@ static bNodeSocketType inputs[]= { { -1, 0, "" } }; +static void osa( + void (*input_fn)(float *, bNodeStack *, TexParams *, short), + float *out, + bNodeStack *in, + TexParams *p, + short thread +){ + if(!p->dxt) { + input_fn(out, in, p, thread); + } else { + float sample[4] = {0}; + float coord[3]; + TexParams sp = *p; + int i; + + sp.coord = coord; + sp.dxt = sp.dyt = 0; + + QUATCOPY(out, sample); + + for(i=0; i<5; i++) { + VECCOPY(coord, p->coord); + + if(i < 4) + { + if(i % 2) VECADD(coord, coord, p->dxt); + if(i > 1) VECADD(coord, coord, p->dyt); + } + else + { + VECADDFAC(coord, coord, p->dxt, 0.5); + VECADDFAC(coord, coord, p->dyt, 0.5); + } + + input_fn(sample, in, &sp, thread); + + QUATADDFAC(out, out, sample, 0.2); + } + } +} + + /* applies to render pipeline */ static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out) { @@ -49,14 +91,17 @@ static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out) if(!cdata->do_preview) { if(cdata->which_output == node->custom1) { - tex_input_rgba(&target->tr, in[0], cdata->coord, cdata->thread); + TexParams params; + params_from_cdata(¶ms, cdata); + + osa(tex_input_rgba, &target->tr, in[0], ¶ms, cdata->thread); target->tin = (target->tr + target->tg + target->tb) / 3.0f; target->talpha = 1.0f; if(target->nor) { if(in[1]->hasinput) - tex_input_vec(target->nor, in[1], cdata->coord, cdata->thread); + osa(tex_input_vec, target->nor, in[1], ¶ms, cdata->thread); else target->nor = 0; } @@ -64,13 +109,85 @@ static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out) } } -static void init(bNode* node) +static void unique_name(bNode *node) { - TexNodeOutput *tno = MEM_callocN(sizeof(TexNodeOutput), "TEX_output"); - strcpy(tno->name, "Default"); - node->storage= tno; + TexNodeOutput *tno = (TexNodeOutput *)node->storage; + char *new_name = 0; + int new_len; + int suffix; + bNode *i; + char *name = tno->name; + + i = node; + while(i->prev) i = i->prev; + for(; i; i=i->next) { + if( + i == node || + i->type != TEX_NODE_OUTPUT || + strcmp(name, ((TexNodeOutput*)(i->storage))->name) + ) + continue; + + if(!new_name) { + int len = strlen(name); + if(len >= 4 && sscanf(name + len - 4, ".%03d", &suffix) == 1) { + new_len = len; + } else { + suffix = 0; + new_len = len + 4; + if(new_len > 31) + new_len = 31; + } + + new_name = malloc(new_len + 1); + strcpy(new_name, name); + name = new_name; + } + sprintf(new_name + new_len - 4, ".%03d", ++suffix); + } + + if(new_name) { + strcpy(tno->name, new_name); + free(new_name); + } +} + +static void assign_index(struct bNode *node) +{ + bNode *tnode; + int index = 1; + + tnode = node; + while(tnode->prev) + tnode = tnode->prev; + + check_index: + for(; tnode; tnode= tnode->next) + if(tnode->type == TEX_NODE_OUTPUT && tnode != node) + if(tnode->custom1 == index) { + index ++; + goto check_index; + } + + node->custom1 = index; } +static void init(bNode *node) +{ + TexNodeOutput *tno = MEM_callocN(sizeof(TexNodeOutput), "TEX_output"); + node->storage= tno; + + strcpy(tno->name, "Default"); + unique_name(node); + assign_index(node); +} + +static void copy(bNode *orig, bNode *new) +{ + node_copy_standard_storage(orig, new); + unique_name(new); + assign_index(new); +} bNodeType tex_node_output= { /* *next,*prev */ NULL, NULL, @@ -85,6 +202,6 @@ bNodeType tex_node_output= { /* butfunc */ NULL, /* initfunc */ init, /* freestoragefunc */ node_free_standard_storage, - /* copystoragefunc */ node_copy_standard_storage, + /* copystoragefunc */ copy, /* id */ NULL }; diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_proc.c b/source/blender/nodes/intern/TEX_nodes/TEX_proc.c index ec65cf186a8..ce7324e2085 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_proc.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_proc.c @@ -21,7 +21,7 @@ * * The Original Code is: all of this file. * - * Contributor(s): none yet. + * Contributor(s): Robin Allen * * ***** END GPL LICENSE BLOCK ***** */ @@ -51,7 +51,7 @@ static bNodeSocketType outputs_color_only[]= { { SOCK_RGBA, 1, "Color 2", 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f } /* Calls multitex and copies the result to the outputs. Called by xxx_exec, which handles inputs. */ -static void do_proc(float *result, float *coord, float *col1, float *col2, char is_normal, Tex *tex, short thread) +static void do_proc(float *result, TexParams *p, float *col1, float *col2, char is_normal, Tex *tex, short thread) { TexResult texres; int textype; @@ -62,7 +62,7 @@ static void do_proc(float *result, float *coord, float *col1, float *col2, char else texres.nor = NULL; - textype = multitex_thread(tex, coord, 0, 0, 0, &texres, thread, 0); + textype = multitex_thread(tex, p->coord, p->dxt, p->dyt, 0, &texres, thread, 0); if(is_normal) return; @@ -76,11 +76,11 @@ static void do_proc(float *result, float *coord, float *col1, float *col2, char } } -typedef void (*MapFn) (Tex *tex, bNodeStack **in, float *coord, short thread); +typedef void (*MapFn) (Tex *tex, bNodeStack **in, TexParams *p, short thread); static void texfn( float *result, - float *coord, + TexParams *p, bNode *node, bNodeStack **in, char is_normal, @@ -89,12 +89,12 @@ static void texfn( { Tex tex = *((Tex*)(node->storage)); float col1[4], col2[4]; - tex_input_rgba(col1, in[0], coord, thread); - tex_input_rgba(col2, in[1], coord, thread); + tex_input_rgba(col1, in[0], p, thread); + tex_input_rgba(col2, in[1], p, thread); - map_inputs(&tex, in, coord, thread); + map_inputs(&tex, in, p, thread); - do_proc(result, coord, col1, col2, is_normal, &tex, thread); + do_proc(result, p, col1, col2, is_normal, &tex, thread); } static int count_outputs(bNode *node) @@ -110,17 +110,17 @@ static int count_outputs(bNode *node) /* Boilerplate generators */ #define ProcNoInputs(name) \ - static void name##_map_inputs(Tex *tex, bNodeStack **in, float *coord, short thread) \ + static void name##_map_inputs(Tex *tex, bNodeStack **in, TexParams *p, short thread) \ {} #define ProcDef(name) \ - static void name##_colorfn(float *result, float *coord, bNode *node, bNodeStack **in, short thread) \ + static void name##_colorfn(float *result, TexParams *p, bNode *node, bNodeStack **in, short thread) \ { \ - texfn(result, coord, node, in, 0, &name##_map_inputs, thread); \ + texfn(result, p, node, in, 0, &name##_map_inputs, thread); \ } \ - static void name##_normalfn(float *result, float *coord, bNode *node, bNodeStack **in, short thread) \ + static void name##_normalfn(float *result, TexParams *p, bNode *node, bNodeStack **in, short thread) \ { \ - texfn(result, coord, node, in, 1, &name##_map_inputs, thread); \ + texfn(result, p, node, in, 1, &name##_map_inputs, thread); \ } \ static void name##_exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out) \ { \ @@ -144,15 +144,15 @@ static bNodeSocketType voronoi_inputs[]= { { -1, 0, "" } }; -static void voronoi_map_inputs(Tex *tex, bNodeStack **in, float *coord, short thread) +static void voronoi_map_inputs(Tex *tex, bNodeStack **in, TexParams *p, short thread) { - tex->vn_w1 = tex_input_value(in[I+0], coord, thread); - tex->vn_w2 = tex_input_value(in[I+1], coord, thread); - tex->vn_w3 = tex_input_value(in[I+2], coord, thread); - tex->vn_w4 = tex_input_value(in[I+3], coord, thread); + tex->vn_w1 = tex_input_value(in[I+0], p, thread); + tex->vn_w2 = tex_input_value(in[I+1], p, thread); + tex->vn_w3 = tex_input_value(in[I+2], p, thread); + tex->vn_w4 = tex_input_value(in[I+3], p, thread); - tex->ns_outscale = tex_input_value(in[I+4], coord, thread); - tex->noisesize = tex_input_value(in[I+5], coord, thread); + tex->ns_outscale = tex_input_value(in[I+4], p, thread); + tex->noisesize = tex_input_value(in[I+5], p, thread); } ProcDef(voronoi) @@ -170,9 +170,9 @@ static bNodeSocketType magic_inputs[]= { { SOCK_VALUE, 1, "Turbulence", 5.0f, 0.0f, 0.0f, 0.0f, 0.0f, 200.0f }, { -1, 0, "" } }; -static void magic_map_inputs(Tex *tex, bNodeStack **in, float *coord, short thread) +static void magic_map_inputs(Tex *tex, bNodeStack **in, TexParams *p, short thread) { - tex->turbul = tex_input_value(in[I+0], coord, thread); + tex->turbul = tex_input_value(in[I+0], p, thread); } ProcDef(magic) @@ -183,10 +183,10 @@ static bNodeSocketType marble_inputs[]= { { SOCK_VALUE, 1, "Turbulence", 5.0f, 0.0f, 0.0f, 0.0f, 0.0f, 200.0f }, { -1, 0, "" } }; -static void marble_map_inputs(Tex *tex, bNodeStack **in, float *coord, short thread) +static void marble_map_inputs(Tex *tex, bNodeStack **in, TexParams *p, short thread) { - tex->noisesize = tex_input_value(in[I+0], coord, thread); - tex->turbul = tex_input_value(in[I+1], coord, thread); + tex->noisesize = tex_input_value(in[I+0], p, thread); + tex->turbul = tex_input_value(in[I+1], p, thread); } ProcDef(marble) @@ -196,9 +196,9 @@ static bNodeSocketType clouds_inputs[]= { { SOCK_VALUE, 1, "Size", 0.25f, 0.0f, 0.0f, 0.0f, 0.0001f, 2.0f }, { -1, 0, "" } }; -static void clouds_map_inputs(Tex *tex, bNodeStack **in, float *coord, short thread) +static void clouds_map_inputs(Tex *tex, bNodeStack **in, TexParams *p, short thread) { - tex->noisesize = tex_input_value(in[I+0], coord, thread); + tex->noisesize = tex_input_value(in[I+0], p, thread); } ProcDef(clouds) @@ -209,10 +209,10 @@ static bNodeSocketType distnoise_inputs[]= { { SOCK_VALUE, 1, "Distortion", 1.00f, 0.0f, 0.0f, 0.0f, 0.0000f, 10.0f }, { -1, 0, "" } }; -static void distnoise_map_inputs(Tex *tex, bNodeStack **in, float *coord, short thread) +static void distnoise_map_inputs(Tex *tex, bNodeStack **in, TexParams *p, short thread) { - tex->noisesize = tex_input_value(in[I+0], coord, thread); - tex->dist_amount = tex_input_value(in[I+1], coord, thread); + tex->noisesize = tex_input_value(in[I+0], p, thread); + tex->dist_amount = tex_input_value(in[I+1], p, thread); } ProcDef(distnoise) @@ -223,10 +223,10 @@ static bNodeSocketType wood_inputs[]= { { SOCK_VALUE, 1, "Turbulence", 5.0f, 0.0f, 0.0f, 0.0f, 0.0f, 200.0f }, { -1, 0, "" } }; -static void wood_map_inputs(Tex *tex, bNodeStack **in, float *coord, short thread) +static void wood_map_inputs(Tex *tex, bNodeStack **in, TexParams *p, short thread) { - tex->noisesize = tex_input_value(in[I+0], coord, thread); - tex->turbul = tex_input_value(in[I+1], coord, thread); + tex->noisesize = tex_input_value(in[I+0], p, thread); + tex->turbul = tex_input_value(in[I+1], p, thread); } ProcDef(wood) @@ -241,13 +241,13 @@ static bNodeSocketType musgrave_inputs[]= { { SOCK_VALUE, 1, "Size", 0.25f, 0.0f, 0.0f, 0.0f, 0.0001f, 2.0f }, { -1, 0, "" } }; -static void musgrave_map_inputs(Tex *tex, bNodeStack **in, float *coord, short thread) +static void musgrave_map_inputs(Tex *tex, bNodeStack **in, TexParams *p, short thread) { - tex->mg_H = tex_input_value(in[I+0], coord, thread); - tex->mg_lacunarity = tex_input_value(in[I+1], coord, thread); - tex->mg_octaves = tex_input_value(in[I+2], coord, thread); - tex->ns_outscale = tex_input_value(in[I+3], coord, thread); - tex->noisesize = tex_input_value(in[I+4], coord, thread); + tex->mg_H = tex_input_value(in[I+0], p, thread); + tex->mg_lacunarity = tex_input_value(in[I+1], p, thread); + tex->mg_octaves = tex_input_value(in[I+2], p, thread); + tex->ns_outscale = tex_input_value(in[I+3], p, thread); + tex->noisesize = tex_input_value(in[I+4], p, thread); } ProcDef(musgrave) @@ -266,10 +266,10 @@ static bNodeSocketType stucci_inputs[]= { { SOCK_VALUE, 1, "Turbulence", 5.0f, 0.0f, 0.0f, 0.0f, 0.0f, 200.0f }, { -1, 0, "" } }; -static void stucci_map_inputs(Tex *tex, bNodeStack **in, float *coord, short thread) +static void stucci_map_inputs(Tex *tex, bNodeStack **in, TexParams *p, short thread) { - tex->noisesize = tex_input_value(in[I+0], coord, thread); - tex->turbul = tex_input_value(in[I+1], coord, thread); + tex->noisesize = tex_input_value(in[I+0], p, thread); + tex->turbul = tex_input_value(in[I+1], p, thread); } ProcDef(stucci) diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_rotate.c b/source/blender/nodes/intern/TEX_nodes/TEX_rotate.c index 3a2c2b1def1..0fd95642be6 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_rotate.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_rotate.c @@ -21,7 +21,7 @@ * * The Original Code is: all of this file. * - * Contributor(s): none yet. + * Contributor(s): Robin Allen * * ***** END GPL LICENSE BLOCK ***** */ @@ -42,9 +42,10 @@ static bNodeSocketType outputs[]= { { -1, 0, "" } }; -static void colorfn(float *out, float *coord, bNode *node, bNodeStack **in, short thread) +static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread) { float new_coord[3]; + float *coord = p->coord; float ax[4]; float para[3]; @@ -53,13 +54,13 @@ static void colorfn(float *out, float *coord, bNode *node, bNodeStack **in, shor float magsq, ndx; - float a = tex_input_value(in[1], coord, thread); + float a = tex_input_value(in[1], p, thread); float cos_a = cos(a * 2 * M_PI); float sin_a = sin(a * 2 * M_PI); // x' = xcosa + n(n.x)(1-cosa)+(x*n)sina - tex_input_vec(ax, in[2], coord, thread); + tex_input_vec(ax, in[2], p, thread); magsq = ax[0]*ax[0] + ax[1]*ax[1] + ax[2]*ax[2]; if(magsq == 0) magsq = 1; @@ -86,7 +87,11 @@ static void colorfn(float *out, float *coord, bNode *node, bNodeStack **in, shor new_coord[1] = para[1] + perp[1] + cp[1]; new_coord[2] = para[2] + perp[2] + cp[2]; - tex_input_rgba(out, in[0], new_coord, thread); + { + TexParams np = *p; + np.coord = new_coord; + tex_input_rgba(out, in[0], &np, thread); + } } static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out) { diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_scale.c b/source/blender/nodes/intern/TEX_nodes/TEX_scale.c index 792c3468e9f..3d4415365aa 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_scale.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_scale.c @@ -21,7 +21,7 @@ * * The Original Code is: all of this file. * - * Contributor(s): none yet. + * Contributor(s): Robin Allen * * ***** END GPL LICENSE BLOCK ***** */ @@ -40,17 +40,19 @@ static bNodeSocketType outputs[]= { { -1, 0, "" } }; -static void colorfn(float *out, float *coord, bNode *node, bNodeStack **in, short thread) +static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread) { float scale[3], new_coord[3]; + TexParams np = *p; + np.coord = new_coord; - tex_input_vec(scale, in[1], coord, thread); + tex_input_vec(scale, in[1], p, thread); - new_coord[0] = coord[0] * scale[0]; - new_coord[1] = coord[1] * scale[1]; - new_coord[2] = coord[2] * scale[2]; + new_coord[0] = p->coord[0] * scale[0]; + new_coord[1] = p->coord[1] * scale[1]; + new_coord[2] = p->coord[2] * scale[2]; - tex_input_rgba(out, in[0], new_coord, thread); + tex_input_rgba(out, in[0], &np, thread); } static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out) { diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_texture.c b/source/blender/nodes/intern/TEX_nodes/TEX_texture.c index 30492b84764..0ca80a82271 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_texture.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_texture.c @@ -21,7 +21,7 @@ * * The Original Code is: all of this file. * - * Contributor(s): none yet. + * Contributor(s): Robin Allen * * ***** END GPL LICENSE BLOCK ***** */ @@ -40,10 +40,11 @@ static bNodeSocketType outputs[]= { { -1, 0, "" } }; -static void colorfn(float *out, float *coord, bNode *node, bNodeStack **in, short thread) +static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread) { static float red[] = {1,0,0,1}; static float white[] = {1,1,1,1}; + float *coord = p->coord; Tex *nodetex = (Tex *)node->id; @@ -60,8 +61,8 @@ static void colorfn(float *out, float *coord, bNode *node, bNodeStack **in, shor float nor[] = {0,0,0}; float col1[4], col2[4]; - tex_input_rgba(col1, in[0], coord, thread); - tex_input_rgba(col2, in[1], coord, thread); + tex_input_rgba(col1, in[0], p, thread); + tex_input_rgba(col2, in[1], p, thread); texres.nor = nor; textype = multitex_ext(nodetex, coord, 0, 0, 0, &texres); diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_translate.c b/source/blender/nodes/intern/TEX_nodes/TEX_translate.c index cadd27612f4..ba3dcfa27a2 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_translate.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_translate.c @@ -21,7 +21,7 @@ * * The Original Code is: all of this file. * - * Contributor(s): none yet. + * Contributor(s): Robin Allen * * ***** END GPL LICENSE BLOCK ***** */ @@ -40,17 +40,19 @@ static bNodeSocketType outputs[]= { { -1, 0, "" } }; -static void colorfn(float *out, float *coord, bNode *node, bNodeStack **in, short thread) +static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread) { float offset[3], new_coord[3]; + TexParams np = *p; + np.coord = new_coord; - tex_input_vec(offset, in[1], coord, thread); + tex_input_vec(offset, in[1], p, thread); - new_coord[0] = coord[0] + offset[0]; - new_coord[1] = coord[1] + offset[1]; - new_coord[2] = coord[2] + offset[2]; + new_coord[0] = p->coord[0] + offset[0]; + new_coord[1] = p->coord[1] + offset[1]; + new_coord[2] = p->coord[2] + offset[2]; - tex_input_rgba(out, in[0], new_coord, thread); + tex_input_rgba(out, in[0], &np, thread); } static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out) { diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_valToNor.c b/source/blender/nodes/intern/TEX_nodes/TEX_valToNor.c index 0d24652a8f6..75b88c3a460 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_valToNor.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_valToNor.c @@ -39,28 +39,32 @@ static bNodeSocketType outputs[]= { { -1, 0, "" } }; -static void normalfn(float *out, float *coord, bNode *node, bNodeStack **in, short thread) +static void normalfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread) { float new_coord[3]; + float *coord = p->coord; - float nabla = tex_input_value(in[1], coord, thread); + float nabla = tex_input_value(in[1], p, thread); float val; float nor[3]; + + TexParams np = *p; + np.coord = new_coord; - val = tex_input_value(in[0], coord, thread); + val = tex_input_value(in[0], p, thread); new_coord[0] = coord[0] + nabla; new_coord[1] = coord[1]; new_coord[2] = coord[2]; - nor[0] = tex_input_value(in[0], new_coord, thread); + nor[0] = tex_input_value(in[0], &np, thread); new_coord[0] = coord[0]; new_coord[1] = coord[1] + nabla; - nor[1] = tex_input_value(in[0], new_coord, thread); + nor[1] = tex_input_value(in[0], &np, thread); new_coord[1] = coord[1]; new_coord[2] = coord[2] + nabla; - nor[2] = tex_input_value(in[0], new_coord, thread); + nor[2] = tex_input_value(in[0], &np, thread); out[0] = val-nor[0]; out[1] = val-nor[1]; diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_valToRgb.c b/source/blender/nodes/intern/TEX_nodes/TEX_valToRgb.c index 71d9cb07e18..90a444bcff0 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_valToRgb.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_valToRgb.c @@ -22,7 +22,7 @@ * * The Original Code is: all of this file. * - * Contributor(s): none yet. + * Contributor(s): Robin Allen * * ***** END GPL LICENSE BLOCK ***** */ @@ -39,10 +39,10 @@ static bNodeSocketType valtorgb_out[]= { { -1, 0, "" } }; -static void valtorgb_colorfn(float *out, float *coord, bNode *node, bNodeStack **in, short thread) +static void valtorgb_colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread) { if(node->storage) { - float fac = tex_input_value(in[0], coord, thread); + float fac = tex_input_value(in[0], p, thread); do_colorband(node->storage, fac, out); } @@ -87,10 +87,10 @@ static bNodeSocketType rgbtobw_out[]= { }; -static void rgbtobw_valuefn(float *out, float *coord, bNode *node, bNodeStack **in, short thread) +static void rgbtobw_valuefn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread) { float cin[4]; - tex_input_rgba(cin, in[0], coord, thread); + tex_input_rgba(cin, in[0], p, thread); *out = cin[0] * 0.35f + cin[1] * 0.45f + cin[2] * 0.2f; } diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_viewer.c b/source/blender/nodes/intern/TEX_nodes/TEX_viewer.c index acdaacf873c..2d29b03b38c 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_viewer.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_viewer.c @@ -21,7 +21,7 @@ * * The Original Code is: all of this file. * - * Contributor(s): none yet. + * Contributor(s): Robin Allen * * ***** END GPL LICENSE BLOCK ***** */ diff --git a/source/blender/nodes/intern/TEX_util.c b/source/blender/nodes/intern/TEX_util.c index 867e754f960..2c21627dad9 100644 --- a/source/blender/nodes/intern/TEX_util.c +++ b/source/blender/nodes/intern/TEX_util.c @@ -47,17 +47,19 @@ #define PREV_RES 128 /* default preview resolution */ -void tex_call_delegate(TexDelegate *dg, float *out, float *coord, short thread) +int preview_flag = 0; + +void tex_call_delegate(TexDelegate *dg, float *out, TexParams *params, short thread) { if(dg->node->need_exec) - dg->fn(out, coord, dg->node, dg->in, thread); + dg->fn(out, params, dg->node, dg->in, thread); } -void tex_input(float *out, int sz, bNodeStack *in, float *coord, short thread) +void tex_input(float *out, int sz, bNodeStack *in, TexParams *params, short thread) { TexDelegate *dg = in->data; if(dg) { - tex_call_delegate(dg, in->vec, coord, thread); + tex_call_delegate(dg, in->vec, params, thread); if(in->hasoutput && in->sockettype == SOCK_VALUE) in->vec[1] = in->vec[2] = in->vec[0]; @@ -65,14 +67,14 @@ void tex_input(float *out, int sz, bNodeStack *in, float *coord, short thread) memcpy(out, in->vec, sz * sizeof(float)); } -void tex_input_vec(float *out, bNodeStack *in, float *coord, short thread) +void tex_input_vec(float *out, bNodeStack *in, TexParams *params, short thread) { - tex_input(out, 3, in, coord, thread); + tex_input(out, 3, in, params, thread); } -void tex_input_rgba(float *out, bNodeStack *in, float *coord, short thread) +void tex_input_rgba(float *out, bNodeStack *in, TexParams *params, short thread) { - tex_input(out, 4, in, coord, thread); + tex_input(out, 4, in, params, thread); if(in->hasoutput && in->sockettype == SOCK_VALUE) { @@ -88,10 +90,10 @@ void tex_input_rgba(float *out, bNodeStack *in, float *coord, short thread) } } -float tex_input_value(bNodeStack *in, float *coord, short thread) +float tex_input_value(bNodeStack *in, TexParams *params, short thread) { float out[4]; - tex_input_vec(out, in, coord, thread); + tex_input_vec(out, in, params, thread); return out[0]; } @@ -108,12 +110,6 @@ static void init_preview(bNode *node) if(node->preview==NULL) node->preview= MEM_callocN(sizeof(bNodePreview), "node preview"); - if(node->preview->rect) - if(node->preview->xsize!=xsize && node->preview->ysize!=ysize) { - MEM_freeN(node->preview->rect); - node->preview->rect= NULL; - } - if(node->preview->rect==NULL) { node->preview->rect= MEM_callocN(4*xsize + xsize*ysize*sizeof(float)*4, "node preview rect"); node->preview->xsize= xsize; @@ -121,11 +117,23 @@ static void init_preview(bNode *node) } } +void params_from_cdata(TexParams *out, TexCallData *in) +{ + out->coord = in->coord; + out->dxt = in->dxt; + out->dyt = in->dyt; + out->cfra = in->cfra; +} + void tex_do_preview(bNode *node, bNodeStack *ns, TexCallData *cdata) { int x, y; float *result; bNodePreview *preview; + float coord[3] = {0, 0, 0}; + TexParams params; + int resolution; + int xsize, ysize; if(!cdata->do_preview) return; @@ -136,16 +144,25 @@ void tex_do_preview(bNode *node, bNodeStack *ns, TexCallData *cdata) init_preview(node); preview = node->preview; + xsize = preview->xsize; + ysize = preview->ysize; - for(x=0; x<preview->xsize; x++) - for(y=0; y<preview->ysize; y++) + params.dxt = 0; + params.dyt = 0; + params.cfra = cdata->cfra; + params.coord = coord; + + resolution = (xsize < ysize) ? xsize : ysize; + + for(x=0; x<xsize; x++) + for(y=0; y<ysize; y++) { - cdata->coord[0] = ((float) x / preview->xsize) * 2 - 1; - cdata->coord[1] = ((float) y / preview->ysize) * 2 - 1; + params.coord[0] = ((float) x / resolution) * 2 - 1; + params.coord[1] = ((float) y / resolution) * 2 - 1; - result = preview->rect + 4 * (preview->xsize*y + x); + result = preview->rect + 4 * (xsize*y + x); - tex_input_rgba(result, ns, cdata->coord, cdata->thread); + tex_input_rgba(result, ns, ¶ms, cdata->thread); } } @@ -192,38 +209,41 @@ void ntreeTexCheckCyclics(struct bNodeTree *ntree) } } -void ntreeTexExecTree(bNodeTree *nodes, TexResult *texres, float *coord, char do_preview, short thread, Tex *tex, short which_output, int cfra) -{ +void ntreeTexExecTree( + bNodeTree *nodes, + TexResult *texres, + float *coord, + float *dxt, float *dyt, + short thread, + Tex *tex, + short which_output, + int cfra +){ TexResult dummy_texres; TexCallData data; + /* 0 means don't care, so just use first */ + if(which_output == 0) + which_output = 1; + if(!texres) texres = &dummy_texres; data.coord = coord; + data.dxt = dxt; + data.dyt = dyt; data.target = texres; - data.do_preview = do_preview; + data.do_preview = preview_flag; data.thread = thread; data.which_output = which_output; data.cfra= cfra; + preview_flag = 0; + ntreeExecTree(nodes, &data, thread); } -void ntreeTexUpdatePreviews(bNodeTree* nodetree) +void ntreeTexSetPreviewFlag(int doit) { - Tex *tex; - float coord[] = {0,0,0}; - TexResult dummy_texres; - - for(tex= G.main->tex.first; tex; tex= tex->id.next) - if(tex->nodetree == nodetree) break; - if(!tex) return; - - dummy_texres.nor = 0; - - ntreeBeginExecTree(nodetree); - ntreeTexExecTree(nodetree, &dummy_texres, coord, 1, 0, tex, 0, 0); - ntreeEndExecTree(nodetree); - + preview_flag = doit; } char* ntreeTexOutputMenu(bNodeTree *ntree) @@ -267,19 +287,3 @@ char* ntreeTexOutputMenu(bNodeTree *ntree) return str; } -void ntreeTexAssignIndex(struct bNodeTree *ntree, struct bNode *node) -{ - bNode *tnode; - int index = 0; - - check_index: - for(tnode= ntree->nodes.first; tnode; tnode= tnode->next) - if(tnode->type == TEX_NODE_OUTPUT && tnode != node) - if(tnode->custom1 == index) { - index ++; - goto check_index; - } - - node->custom1 = index; -} - diff --git a/source/blender/nodes/intern/TEX_util.h b/source/blender/nodes/intern/TEX_util.h index e560aa57921..87a9cf288d6 100644 --- a/source/blender/nodes/intern/TEX_util.h +++ b/source/blender/nodes/intern/TEX_util.h @@ -71,13 +71,20 @@ typedef struct TexCallData { TexResult *target; float *coord; + float *dxt, *dyt; char do_preview; short thread; short which_output; int cfra; } TexCallData; -typedef void(*TexFn) (float *out, float *coord, bNode *node, bNodeStack **in, short thread); +typedef struct TexParams { + float *coord; + float *dxt, *dyt; + int cfra; +} TexParams; + +typedef void(*TexFn) (float *out, TexParams *params, bNode *node, bNodeStack **in, short thread); typedef struct TexDelegate { TexFn fn; @@ -86,16 +93,17 @@ typedef struct TexDelegate { int type; } TexDelegate; -void tex_call_delegate(TexDelegate*, float *out, float *coord, short thread); +void tex_call_delegate(TexDelegate*, float *out, TexParams *params, short thread); -void tex_input_rgba(float *out, bNodeStack *in, float *coord, short thread); -void tex_input_vec(float *out, bNodeStack *in, float *coord, short thread); -float tex_input_value(bNodeStack *in, float *coord, short thread); +void tex_input_rgba(float *out, bNodeStack *in, TexParams *params, short thread); +void tex_input_vec(float *out, bNodeStack *in, TexParams *params, short thread); +float tex_input_value(bNodeStack *in, TexParams *params, short thread); void tex_output(bNode *node, bNodeStack **in, bNodeStack *out, TexFn texfn); void tex_do_preview(bNode *node, bNodeStack *ns, TexCallData *cdata); -void ntreeTexUpdatePreviews( bNodeTree* nodetree ); -void ntreeTexExecTree(bNodeTree *nodes, TexResult *texres, float *coord, char do_preview, short thread, struct Tex *tex, short which_output, int cfra); - +void ntreeTexExecTree(bNodeTree *nodes, TexResult *texres, float *coord, float *dxt, float *dyt, short thread, struct Tex *tex, short which_output, int cfra); + +void params_from_cdata(TexParams *out, TexCallData *in); + #endif diff --git a/source/blender/python/BPY_extern.h b/source/blender/python/BPY_extern.h index db0404c33a8..acb45790ed2 100644 --- a/source/blender/python/BPY_extern.h +++ b/source/blender/python/BPY_extern.h @@ -122,7 +122,7 @@ extern "C" { void BPY_pydriver_update(void); float BPY_pydriver_eval(struct ChannelDriver *driver); - int BPY_button_eval(char *expr, double *value); + int BPY_button_eval(struct bContext *C, char *expr, double *value); /* format importer hook */ int BPY_call_importloader( char *name ); diff --git a/source/blender/python/epy_doc_gen.py b/source/blender/python/epy_doc_gen.py index 8630a0c8f8e..6a515648340 100644 --- a/source/blender/python/epy_doc_gen.py +++ b/source/blender/python/epy_doc_gen.py @@ -76,6 +76,7 @@ def write_func(rna, ident, out, func_type): rna_func_desc = rna.description.strip() items = rna.parameters.items() + for rna_prop_identifier, rna_prop in items: if rna_prop_identifier=='rna_type': continue @@ -88,13 +89,25 @@ def write_func(rna, ident, out, func_type): rna_prop_type = rna_prop.type.lower() # enum, float, int, boolean + # only for rna functions, operators should not get pointers as args + if rna_prop_type=='pointer': + rna_prop_type_refine = "L{%s}" % rna_prop.fixed_type.identifier + else: + rna_prop_type_refine = rna_prop_type + + try: length = rna_prop.array_length except: length = 0 array_str = get_array_str(length) - kw_type_str= "@type %s: %s%s" % (rna_prop_identifier, rna_prop_type, array_str) - kw_param_str= "@param %s: %s" % (rna_prop_identifier, rna_prop.description.strip()) + if rna_prop.use_return: + kw_type_str= "@rtype: %s%s" % (rna_prop_type_refine, array_str) + kw_param_str= "@return: %s" % (rna_prop.description.strip()) + else: + kw_type_str= "@type %s: %s%s" % (rna_prop_identifier, rna_prop_type_refine, array_str) + kw_param_str= "@param %s: %s" % (rna_prop_identifier, rna_prop.description.strip()) + kw_param_set = False if func_type=='OPERATOR': @@ -159,8 +172,11 @@ def write_func(rna, ident, out, func_type): # stora else: # currently functions dont have a default value - kw_args.append('%s' % (rna_prop_identifier)) - + if not rna_prop.use_return: + kw_args.append('%s' % (rna_prop_identifier)) + else: + kw_param_set = True + # Same for operators and functions kw_arg_attrs.append(kw_type_str) @@ -174,7 +190,8 @@ def write_func(rna, ident, out, func_type): out.write(ident+'\t%s\n' % rna_func_desc) for desc in kw_arg_attrs: out.write(ident+'\t%s\n' % desc) - out.write(ident+'\t@rtype: None\n') + + # out.write(ident+'\t@rtype: None\n') # implicit out.write(ident+'\t"""\n') @@ -183,6 +200,7 @@ def rna2epy(target_path): # Use for faster lookups # use rna_struct.identifier as the key for each dict + rna_struct_dict = {} # store identifier:rna lookups rna_full_path_dict = {} # store the result of full_rna_struct_path(rna_struct) rna_children_dict = {} # store all rna_structs nested from here rna_references_dict = {} # store a list of rna path strings that reference this type @@ -199,8 +217,12 @@ def rna2epy(target_path): if rna_base: out.write(ident+ 'class %s(%s):\n' % (identifier, rna_base.identifier)) + rna_base_prop_keys = rna_base.properties.keys() # could be cached + rna_base_func_keys = [f.identifier for f in rna_base.functions] else: out.write(ident+ 'class %s:\n' % identifier) + rna_base_prop_keys = [] + rna_base_func_keys = [] out.write(ident+ '\t"""\n') @@ -232,11 +254,9 @@ def rna2epy(target_path): for rna_prop_identifier, rna_prop in rna_struct.properties.items(): - if rna_prop_identifier=='RNA': - continue - - if rna_prop_identifier=='rna_type': - continue + if rna_prop_identifier=='RNA': continue + if rna_prop_identifier=='rna_type': continue + if rna_prop_identifier in rna_base_prop_keys: continue # does this prop exist in our parent class, if so skip rna_desc = rna_prop.description.strip() @@ -269,7 +289,8 @@ def rna2epy(target_path): out.write(ident+ '\t@ivar %s: %s in (%s)\n' % (rna_prop_identifier, rna_desc, ', '.join(rna_prop.items.keys()))) else: out.write(ident+ '\t@ivar %s: %s in...\n' % (rna_prop_identifier, rna_desc)) - for e in rna_prop.items.keys(): + for e, e_rna_prop in rna_prop.items.items(): + #out.write(ident+ '\t\t- %s: %s\n' % (e, e_rna_prop.description)) # XXX - segfaults, FIXME out.write(ident+ '\t\t- %s\n' % e) out.write(ident+ '\t@type %s: %s%s%s\n' % (rna_prop_identifier, rna_prop_type, array_str, readonly_str)) @@ -290,7 +311,8 @@ def rna2epy(target_path): # Write functions # for rna_func in rna_struct.functions: # Better ignore inherited (line below) for rna_func in rna_functions_dict[identifier]: - write_func(rna_func, ident+'\t', out, 'FUNCTION') + if rna_func not in rna_base_func_keys: + write_func(rna_func, ident+'\t', out, 'FUNCTION') out.write('\n') @@ -313,13 +335,18 @@ def rna2epy(target_path): structs = [] for rna_type_name in dir(bpy.types): rna_type = getattr(bpy.types, rna_type_name) - if hasattr(rna_type, '__rna__'): + + try: rna_struct = rna_type.__rna__ + except: rna_struct = None + + if rna_struct: #if not rna_type_name.startswith('__'): - rna_struct = rna_type.__rna__ + identifier = rna_struct.identifier structs.append( (base_id(rna_struct), identifier, rna_struct) ) - + # Simple lookup + rna_struct_dict[identifier] = rna_struct # Store full rna path 'GameObjectSettings' -> 'Object.GameObjectSettings' rna_full_path_dict[identifier] = full_rna_struct_path(rna_struct) @@ -377,16 +404,21 @@ def rna2epy(target_path): # precalc vars to avoid a lot of looping for (rna_base, identifier, rna_struct) in structs: + if rna_base: + rna_base_prop_keys = rna_struct_dict[rna_base].properties.keys() # could cache + rna_base_func_keys = [f.identifier for f in rna_struct_dict[rna_base].functions] + else: + rna_base_prop_keys = [] + rna_base_func_keys= [] # rna_struct_path = full_rna_struct_path(rna_struct) rna_struct_path = rna_full_path_dict[identifier] for rna_prop_identifier, rna_prop in rna_struct.properties.items(): - if rna_prop_identifier=='RNA': - continue - if rna_prop_identifier=='rna_type': - continue + if rna_prop_identifier=='RNA': continue + if rna_prop_identifier=='rna_type': continue + if rna_prop_identifier in rna_base_prop_keys: continue try: rna_prop_ptr = rna_prop.fixed_type except: rna_prop_ptr = None @@ -395,7 +427,21 @@ def rna2epy(target_path): if rna_prop_ptr: rna_references_dict[rna_prop_ptr.identifier].append( "%s.%s" % (rna_struct_path, rna_prop_identifier) ) - + for rna_func in rna_struct.functions: + for rna_prop_identifier, rna_prop in rna_func.parameters.items(): + + if rna_prop_identifier=='RNA': continue + if rna_prop_identifier=='rna_type': continue + if rna_prop_identifier in rna_base_func_keys: continue + + + try: rna_prop_ptr = rna_prop.fixed_type + except: rna_prop_ptr = None + + # Does this property point to me? + if rna_prop_ptr: + rna_references_dict[rna_prop_ptr.identifier].append( "%s.%s" % (rna_struct_path, rna_func.identifier) ) + # Store nested children nested = rna_struct.nested diff --git a/source/blender/python/generic/BGL.c b/source/blender/python/generic/BGL.c index 773e8958fbb..aa4e557126e 100644 --- a/source/blender/python/generic/BGL.c +++ b/source/blender/python/generic/BGL.c @@ -67,7 +67,7 @@ static int Buffer_ass_slice( PyObject * self, int begin, int end, PyObject * seq ); static PySequenceMethods Buffer_SeqMethods = { - ( inquiry ) Buffer_len, /*sq_length */ + ( lenfunc ) Buffer_len, /*sq_length */ ( binaryfunc ) 0, /*sq_concat */ ( ssizeargfunc ) 0, /*sq_repeat */ ( ssizeargfunc ) Buffer_item, /*sq_item */ @@ -83,13 +83,7 @@ static PyObject *Buffer_getattr( PyObject * self, char *name ); static PyObject *Buffer_repr( PyObject * self ); PyTypeObject buffer_Type = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /* ob_size */ -#endif "buffer", /*tp_name */ sizeof( Buffer ), /*tp_basicsize */ 0, /*tp_itemsize */ @@ -1090,7 +1084,6 @@ static struct PyMethodDef BGL_methods[] = { {NULL, NULL, 0, NULL} }; -#if (PY_VERSION_HEX >= 0x03000000) static struct PyModuleDef BGL_module_def = { PyModuleDef_HEAD_INIT, "BGL", /* m_name */ @@ -1102,17 +1095,13 @@ static struct PyModuleDef BGL_module_def = { 0, /* m_clear */ 0, /* m_free */ }; -#endif -PyObject *BGL_Init(const char *from) + +PyObject *BGL_Init(void) { PyObject *mod, *dict, *item; -#if (PY_VERSION_HEX >= 0x03000000) mod = PyModule_Create(&BGL_module_def); PyDict_SetItemString(PySys_GetObject("modules"), BGL_module_def.m_name, mod); -#else - mod= Py_InitModule(from, BGL_methods); -#endif dict= PyModule_GetDict(mod); if( PyType_Ready( &buffer_Type) < 0) diff --git a/source/blender/python/generic/BGL.h b/source/blender/python/generic/BGL.h index acd4d3adca3..35547de989f 100644 --- a/source/blender/python/generic/BGL.h +++ b/source/blender/python/generic/BGL.h @@ -42,9 +42,8 @@ #include <Python.h> #include <GL/glew.h> -#include "../intern/bpy_compat.h" -PyObject *BGL_Init( const char *from ); +PyObject *BGL_Init(void); /*@ Buffer Object */ /*@ For Python access to OpenGL functions requiring a pointer. */ @@ -305,31 +304,30 @@ typedef struct _Buffer { #define ret_def_void #define ret_set_void -/* would use Py_RETURN_NONE - except for py 2.3 doesnt have it */ -#define ret_ret_void { Py_INCREF(Py_None); return Py_None; } +#define ret_ret_void return Py_INCREF(Py_None), Py_None #define ret_def_GLint int ret_int #define ret_set_GLint ret_int= -#define ret_ret_GLint return PyLong_FromLong(ret_int); +#define ret_ret_GLint return PyLong_FromLong(ret_int) #define ret_def_GLuint unsigned int ret_uint #define ret_set_GLuint ret_uint= -#define ret_ret_GLuint return PyLong_FromLong((long) ret_uint); +#define ret_ret_GLuint return PyLong_FromLong((long) ret_uint) #define ret_def_GLenum unsigned int ret_uint #define ret_set_GLenum ret_uint= -#define ret_ret_GLenum return PyLong_FromLong((long) ret_uint); +#define ret_ret_GLenum return PyLong_FromLong((long) ret_uint) #define ret_def_GLboolean unsigned char ret_bool #define ret_set_GLboolean ret_bool= -#define ret_ret_GLboolean return PyLong_FromLong((long) ret_bool); +#define ret_ret_GLboolean return PyLong_FromLong((long) ret_bool) #define ret_def_GLstring const unsigned char *ret_str; #define ret_set_GLstring ret_str= #define ret_ret_GLstring \ if (ret_str) {\ - return PyUnicode_FromString(ret_str);\ + return PyUnicode_FromString((const char *)ret_str);\ } else {\ PyErr_SetString(PyExc_AttributeError, "could not get opengl string");\ return NULL;\ diff --git a/source/blender/python/generic/Geometry.c b/source/blender/python/generic/Geometry.c index 3c713a5f62d..99d901275c9 100644 --- a/source/blender/python/generic/Geometry.c +++ b/source/blender/python/generic/Geometry.c @@ -78,7 +78,6 @@ struct PyMethodDef M_Geometry_methods[] = { {NULL, NULL, 0, NULL} }; -#if (PY_VERSION_HEX >= 0x03000000) static struct PyModuleDef M_Geometry_module_def = { PyModuleDef_HEAD_INIT, "Geometry", /* m_name */ @@ -90,19 +89,14 @@ static struct PyModuleDef M_Geometry_module_def = { 0, /* m_clear */ 0, /* m_free */ }; -#endif /*----------------------------MODULE INIT-------------------------*/ -PyObject *Geometry_Init(const char *from) +PyObject *Geometry_Init(void) { PyObject *submodule; -#if (PY_VERSION_HEX >= 0x03000000) submodule = PyModule_Create(&M_Geometry_module_def); PyDict_SetItemString(PySys_GetObject("modules"), M_Geometry_module_def.m_name, submodule); -#else - submodule = Py_InitModule3(from, M_Geometry_methods, M_Geometry_doc); -#endif return (submodule); } diff --git a/source/blender/python/generic/Geometry.h b/source/blender/python/generic/Geometry.h index c30768e6e9b..9257e3f80fc 100644 --- a/source/blender/python/generic/Geometry.h +++ b/source/blender/python/generic/Geometry.h @@ -34,6 +34,6 @@ #include <Python.h> #include "Mathutils.h" -PyObject *Geometry_Init( const char *from ); +PyObject *Geometry_Init(void); #endif /* EXPP_Geometry_H */ diff --git a/source/blender/python/generic/Makefile b/source/blender/python/generic/Makefile index 8faed3b622c..dc674478dab 100644 --- a/source/blender/python/generic/Makefile +++ b/source/blender/python/generic/Makefile @@ -1,5 +1,5 @@ # -# $Id: Makefile 21094 2009-06-23 00:09:26Z gsrb3d $ +# $Id$ # # ***** BEGIN GPL LICENSE BLOCK ***** # @@ -43,7 +43,7 @@ CPPFLAGS += -I$(NAN_PYTHON)/include/python$(NAN_PYTHON_VERSION) # PreProcessor stuff CPPFLAGS += -I$(NAN_GHOST)/include -CPPFLAGS += -I$(NAN_SOUNDSYSTEM)/include $(NAN_SDLCFLAGS) +CPPFLAGS += $(NAN_SDLCFLAGS) # modules CPPFLAGS += -I../../editors/include diff --git a/source/blender/python/generic/Mathutils.c b/source/blender/python/generic/Mathutils.c index 538dc6a8823..5915efca09d 100644 --- a/source/blender/python/generic/Mathutils.c +++ b/source/blender/python/generic/Mathutils.c @@ -94,7 +94,6 @@ struct PyMethodDef M_Mathutils_methods[] = { /*----------------------------MODULE INIT-------------------------*/ /* from can be Blender.Mathutils or GameLogic.Mathutils for the BGE */ -#if (PY_VERSION_HEX >= 0x03000000) static struct PyModuleDef M_Mathutils_module_def = { PyModuleDef_HEAD_INIT, "Mathutils", /* m_name */ @@ -106,21 +105,13 @@ static struct PyModuleDef M_Mathutils_module_def = { 0, /* m_clear */ 0, /* m_free */ }; -#endif -PyObject *Mathutils_Init(const char *from) +PyObject *Mathutils_Init(void) { PyObject *submodule; //seed the generator for the rand function BLI_srand((unsigned int) (PIL_check_seconds_timer() * 0x7FFFFFFF)); - -#if (PY_VERSION_HEX < 0x03000000) - vector_Type.tp_flags |= Py_TPFLAGS_CHECKTYPES; - matrix_Type.tp_flags |= Py_TPFLAGS_CHECKTYPES; - euler_Type.tp_flags |= Py_TPFLAGS_CHECKTYPES; - quaternion_Type.tp_flags |= Py_TPFLAGS_CHECKTYPES; -#endif if( PyType_Ready( &vector_Type ) < 0 ) return NULL; @@ -131,12 +122,8 @@ PyObject *Mathutils_Init(const char *from) if( PyType_Ready( &quaternion_Type ) < 0 ) return NULL; -#if (PY_VERSION_HEX >= 0x03000000) submodule = PyModule_Create(&M_Mathutils_module_def); PyDict_SetItemString(PySys_GetObject("modules"), M_Mathutils_module_def.m_name, submodule); -#else - submodule = Py_InitModule3(from, M_Mathutils_methods, M_Mathutils_doc); -#endif /* each type has its own new() function */ PyModule_AddObject( submodule, "Vector", (PyObject *)&vector_Type ); diff --git a/source/blender/python/generic/Mathutils.h b/source/blender/python/generic/Mathutils.h index 9716414e587..29cbd203741 100644 --- a/source/blender/python/generic/Mathutils.h +++ b/source/blender/python/generic/Mathutils.h @@ -32,7 +32,6 @@ #define EXPP_Mathutils_H #include <Python.h> -#include "../intern/bpy_compat.h" #include "vector.h" #include "matrix.h" #include "quat.h" @@ -55,10 +54,7 @@ PyObject *BaseMathObject_getOwner( BaseMathObject * self, void * ); PyObject *BaseMathObject_getWrapped( BaseMathObject *self, void * ); void BaseMathObject_dealloc(BaseMathObject * self); - - - -PyObject *Mathutils_Init( const char * from ); +PyObject *Mathutils_Init(void); PyObject *quat_rotation(PyObject *arg1, PyObject *arg2); diff --git a/source/blender/python/generic/bpy_internal_import.c b/source/blender/python/generic/bpy_internal_import.c index fe97c4d493b..c45101819ca 100644 --- a/source/blender/python/generic/bpy_internal_import.c +++ b/source/blender/python/generic/bpy_internal_import.c @@ -179,20 +179,12 @@ static PyObject *blender_import( PyObject * self, PyObject * args, PyObject * k PyObject *newmodule; //PyObject_Print(args, stderr, 0); -#if (PY_VERSION_HEX >= 0x02060000) int dummy_val; /* what does this do?*/ static char *kwlist[] = {"name", "globals", "locals", "fromlist", "level", 0}; if( !PyArg_ParseTupleAndKeywords( args, kw, "s|OOOi:bpy_import_meth", kwlist, &name, &globals, &locals, &fromlist, &dummy_val) ) return NULL; -#else - static char *kwlist[] = {"name", "globals", "locals", "fromlist", 0}; - - if( !PyArg_ParseTupleAndKeywords( args, kw, "s|OOO:bpy_import_meth", kwlist, - &name, &globals, &locals, &fromlist ) ) - return NULL; -#endif /* import existing builtin modules or modules that have been imported alredy */ newmodule = PyImport_ImportModuleEx( name, globals, locals, fromlist ); diff --git a/source/blender/python/generic/bpy_internal_import.h b/source/blender/python/generic/bpy_internal_import.h index 7b692f3607f..79c01e1c6a6 100644 --- a/source/blender/python/generic/bpy_internal_import.h +++ b/source/blender/python/generic/bpy_internal_import.h @@ -32,7 +32,6 @@ #define EXPP_bpy_import_h #include <Python.h> -#include "../intern/bpy_compat.h" #include "compile.h" /* for the PyCodeObject */ #include "eval.h" /* for PyEval_EvalCode */ diff --git a/source/blender/python/generic/euler.c b/source/blender/python/generic/euler.c index b29bbd2055e..754eb634a0d 100644 --- a/source/blender/python/generic/euler.c +++ b/source/blender/python/generic/euler.c @@ -242,7 +242,7 @@ static PyObject *Euler_Rotate(EulerObject * self, PyObject *args) PyErr_SetString(PyExc_TypeError, "euler.rotate():expected angle (float) and axis (x,y,z)"); return NULL; } - if(!STREQ3(axis,"x","y","z")){ + if(ELEM3(*axis, 'x', 'y', 'z') && axis[1]=='\0'){ PyErr_SetString(PyExc_TypeError, "euler.rotate(): expected axis to be 'x', 'y' or 'z'"); return NULL; } @@ -508,7 +508,7 @@ static int Euler_ass_slice(EulerObject * self, int begin, int end, } //-----------------PROTCOL DECLARATIONS-------------------------- static PySequenceMethods Euler_SeqMethods = { - (inquiry) Euler_len, /* sq_length */ + (lenfunc) Euler_len, /* sq_length */ (binaryfunc) 0, /* sq_concat */ (ssizeargfunc) 0, /* sq_repeat */ (ssizeargfunc) Euler_item, /* sq_item */ @@ -547,13 +547,7 @@ static PyGetSetDef Euler_getseters[] = { //------------------PY_OBECT DEFINITION-------------------------- PyTypeObject euler_Type = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /* ob_size */ -#endif "euler", //tp_name sizeof(EulerObject), //tp_basicsize 0, //tp_itemsize diff --git a/source/blender/python/generic/euler.h b/source/blender/python/generic/euler.h index 16cf5d8c983..22d87dbb766 100644 --- a/source/blender/python/generic/euler.h +++ b/source/blender/python/generic/euler.h @@ -32,7 +32,6 @@ #define EXPP_euler_h #include <Python.h> -#include "../intern/bpy_compat.h" extern PyTypeObject euler_Type; #define EulerObject_Check(_v) PyObject_TypeCheck((_v), &euler_Type) diff --git a/source/blender/python/generic/matrix.c b/source/blender/python/generic/matrix.c index 210751eaaf1..c1cc4ef1f4c 100644 --- a/source/blender/python/generic/matrix.c +++ b/source/blender/python/generic/matrix.c @@ -37,14 +37,17 @@ static PyObject *column_vector_multiplication(MatrixObject * mat, VectorObject* /* matrix vector callbacks */ int mathutils_matrix_vector_cb_index= -1; -static int mathutils_matrix_vector_check(MatrixObject *self) +static int mathutils_matrix_vector_check(PyObject *self_p) { + MatrixObject *self= (MatrixObject*)self_p; return BaseMath_ReadCallback(self); } -static int mathutils_matrix_vector_get(MatrixObject *self, int subtype, float *vec_from) +static int mathutils_matrix_vector_get(PyObject *self_p, int subtype, float *vec_from) { + MatrixObject *self= (MatrixObject*)self_p; int i; + if(!BaseMath_ReadCallback(self)) return 0; @@ -54,9 +57,11 @@ static int mathutils_matrix_vector_get(MatrixObject *self, int subtype, float *v return 1; } -static int mathutils_matrix_vector_set(MatrixObject *self, int subtype, float *vec_to) +static int mathutils_matrix_vector_set(PyObject *self_p, int subtype, float *vec_to) { + MatrixObject *self= (MatrixObject*)self_p; int i; + if(!BaseMath_ReadCallback(self)) return 0; @@ -67,8 +72,10 @@ static int mathutils_matrix_vector_set(MatrixObject *self, int subtype, float *v return 1; } -static int mathutils_matrix_vector_get_index(MatrixObject *self, int subtype, float *vec_from, int index) +static int mathutils_matrix_vector_get_index(PyObject *self_p, int subtype, float *vec_from, int index) { + MatrixObject *self= (MatrixObject*)self_p; + if(!BaseMath_ReadCallback(self)) return 0; @@ -76,8 +83,10 @@ static int mathutils_matrix_vector_get_index(MatrixObject *self, int subtype, fl return 1; } -static int mathutils_matrix_vector_set_index(MatrixObject *self, int subtype, float *vec_to, int index) +static int mathutils_matrix_vector_set_index(PyObject *self_p, int subtype, float *vec_to, int index) { + MatrixObject *self= (MatrixObject*)self_p; + if(!BaseMath_ReadCallback(self)) return 0; @@ -988,7 +997,7 @@ static PyObject* Matrix_inv(MatrixObject *self) /*-----------------PROTOCOL DECLARATIONS--------------------------*/ static PySequenceMethods Matrix_SeqMethods = { - (inquiry) Matrix_len, /* sq_length */ + (lenfunc) Matrix_len, /* sq_length */ (binaryfunc) 0, /* sq_concat */ (ssizeargfunc) 0, /* sq_repeat */ (ssizeargfunc) Matrix_item, /* sq_item */ @@ -998,8 +1007,6 @@ static PySequenceMethods Matrix_SeqMethods = { }; - -#if (PY_VERSION_HEX >= 0x03000000) static PyObject *Matrix_subscript(MatrixObject* self, PyObject* item) { if (PyIndex_Check(item)) { @@ -1071,11 +1078,8 @@ static PyMappingMethods Matrix_AsMapping = { (binaryfunc)Matrix_subscript, (objobjargproc)Matrix_ass_subscript }; -#endif /* (PY_VERSION_HEX >= 0x03000000) */ - -#if (PY_VERSION_HEX >= 0x03000000) static PyNumberMethods Matrix_NumMethods = { (binaryfunc) Matrix_add, /*nb_add*/ (binaryfunc) Matrix_sub, /*nb_subtract*/ @@ -1112,33 +1116,6 @@ static PyNumberMethods Matrix_NumMethods = { 0, /* nb_inplace_true_divide */ 0, /* nb_index */ }; -#else -static PyNumberMethods Matrix_NumMethods = { - (binaryfunc) Matrix_add, /* __add__ */ - (binaryfunc) Matrix_sub, /* __sub__ */ - (binaryfunc) Matrix_mul, /* __mul__ */ - (binaryfunc) 0, /* __div__ */ - (binaryfunc) 0, /* __mod__ */ - (binaryfunc) 0, /* __divmod__ */ - (ternaryfunc) 0, /* __pow__ */ - (unaryfunc) 0, /* __neg__ */ - (unaryfunc) 0, /* __pos__ */ - (unaryfunc) 0, /* __abs__ */ - (inquiry) 0, /* __nonzero__ */ - (unaryfunc) Matrix_inv, /* __invert__ */ - (binaryfunc) 0, /* __lshift__ */ - (binaryfunc) 0, /* __rshift__ */ - (binaryfunc) 0, /* __and__ */ - (binaryfunc) 0, /* __xor__ */ - (binaryfunc) 0, /* __or__ */ - /*(coercion)*/ 0, /* __coerce__ */ - (unaryfunc) 0, /* __int__ */ - (unaryfunc) 0, /* __long__ */ - (unaryfunc) 0, /* __float__ */ - (unaryfunc) 0, /* __oct__ */ - (unaryfunc) 0, /* __hex__ */ -}; -#endif static PyObject *Matrix_getRowSize( MatrixObject * self, void *type ) { @@ -1164,13 +1141,7 @@ static PyGetSetDef Matrix_getseters[] = { /*------------------PY_OBECT DEFINITION--------------------------*/ PyTypeObject matrix_Type = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /* ob_size */ -#endif "matrix", /*tp_name*/ sizeof(MatrixObject), /*tp_basicsize*/ 0, /*tp_itemsize*/ @@ -1182,11 +1153,7 @@ PyTypeObject matrix_Type = { (reprfunc) Matrix_repr, /*tp_repr*/ &Matrix_NumMethods, /*tp_as_number*/ &Matrix_SeqMethods, /*tp_as_sequence*/ -#if (PY_VERSION_HEX >= 0x03000000) &Matrix_AsMapping, /*tp_as_mapping*/ -#else - 0, -#endif 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ diff --git a/source/blender/python/generic/quat.c b/source/blender/python/generic/quat.c index bcd66e0fc82..172d2574fcb 100644 --- a/source/blender/python/generic/quat.c +++ b/source/blender/python/generic/quat.c @@ -611,7 +611,7 @@ static PyObject *Quaternion_mul(PyObject * q1, PyObject * q2) //-----------------PROTOCOL DECLARATIONS-------------------------- static PySequenceMethods Quaternion_SeqMethods = { - (inquiry) Quaternion_len, /* sq_length */ + (lenfunc) Quaternion_len, /* sq_length */ (binaryfunc) 0, /* sq_concat */ (ssizeargfunc) 0, /* sq_repeat */ (ssizeargfunc) Quaternion_item, /* sq_item */ @@ -620,7 +620,6 @@ static PySequenceMethods Quaternion_SeqMethods = { (ssizessizeobjargproc) Quaternion_ass_slice, /* sq_ass_slice */ }; -#if (PY_VERSION_HEX >= 0x03000000) static PyNumberMethods Quaternion_NumMethods = { (binaryfunc) Quaternion_add, /*nb_add*/ (binaryfunc) Quaternion_sub, /*nb_subtract*/ @@ -657,33 +656,6 @@ static PyNumberMethods Quaternion_NumMethods = { 0, /* nb_inplace_true_divide */ 0, /* nb_index */ }; -#else -static PyNumberMethods Quaternion_NumMethods = { - (binaryfunc) Quaternion_add, /* __add__ */ - (binaryfunc) Quaternion_sub, /* __sub__ */ - (binaryfunc) Quaternion_mul, /* __mul__ */ - (binaryfunc) 0, /* __div__ */ - (binaryfunc) 0, /* __mod__ */ - (binaryfunc) 0, /* __divmod__ */ - (ternaryfunc) 0, /* __pow__ */ - (unaryfunc) 0, /* __neg__ */ - (unaryfunc) 0, /* __pos__ */ - (unaryfunc) 0, /* __abs__ */ - (inquiry) 0, /* __nonzero__ */ - (unaryfunc) 0, /* __invert__ */ - (binaryfunc) 0, /* __lshift__ */ - (binaryfunc) 0, /* __rshift__ */ - (binaryfunc) 0, /* __and__ */ - (binaryfunc) 0, /* __xor__ */ - (binaryfunc) 0, /* __or__ */ - /*(coercion)*/ 0, /* __coerce__ */ - (unaryfunc) 0, /* __int__ */ - (unaryfunc) 0, /* __long__ */ - (unaryfunc) 0, /* __float__ */ - (unaryfunc) 0, /* __oct__ */ - (unaryfunc) 0, /* __hex__ */ -}; -#endif static PyObject *Quaternion_getAxis( QuaternionObject * self, void *type ) { @@ -778,13 +750,7 @@ static PyGetSetDef Quaternion_getseters[] = { //------------------PY_OBECT DEFINITION-------------------------- PyTypeObject quaternion_Type = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /* ob_size */ -#endif "quaternion", //tp_name sizeof(QuaternionObject), //tp_basicsize 0, //tp_itemsize diff --git a/source/blender/python/generic/quat.h b/source/blender/python/generic/quat.h index 8cf963b54c6..2934bef0ad3 100644 --- a/source/blender/python/generic/quat.h +++ b/source/blender/python/generic/quat.h @@ -32,7 +32,6 @@ #define EXPP_quat_h #include <Python.h> -#include "../intern/bpy_compat.h" extern PyTypeObject quaternion_Type; #define QuaternionObject_Check(_v) PyObject_TypeCheck((_v), &quaternion_Type) diff --git a/source/blender/python/generic/vector.c b/source/blender/python/generic/vector.c index 1101524c1c5..0bed1bc38d2 100644 --- a/source/blender/python/generic/vector.c +++ b/source/blender/python/generic/vector.c @@ -1054,25 +1054,15 @@ static PyObject* Vector_richcmpr(PyObject *objectA, PyObject *objectB, int compa /*-----------------PROTCOL DECLARATIONS--------------------------*/ static PySequenceMethods Vector_SeqMethods = { - (inquiry) Vector_len, /* sq_length */ + (lenfunc) Vector_len, /* sq_length */ (binaryfunc) 0, /* sq_concat */ (ssizeargfunc) 0, /* sq_repeat */ (ssizeargfunc) Vector_item, /* sq_item */ -#if (PY_VERSION_HEX < 0x03000000) - (ssizessizeargfunc) Vector_slice, /* sq_slice */ /* PY2 ONLY */ -#else - NULL, -#endif + NULL, /* py3 deprecated slice func */ (ssizeobjargproc) Vector_ass_item, /* sq_ass_item */ -#if (PY_VERSION_HEX < 0x03000000) - (ssizessizeobjargproc) Vector_ass_slice, /* sq_ass_slice */ /* PY2 ONLY */ -#else - NULL, -#endif + NULL, /* py3 deprecated slice assign func */ }; - -#if (PY_VERSION_HEX >= 0x03000000) static PyObject *Vector_subscript(VectorObject* self, PyObject* item) { if (PyIndex_Check(item)) { @@ -1144,9 +1134,8 @@ static PyMappingMethods Vector_AsMapping = { (binaryfunc)Vector_subscript, (objobjargproc)Vector_ass_subscript }; -#endif /* (PY_VERSION_HEX >= 0x03000000) */ - -#if (PY_VERSION_HEX >= 0x03000000) + + static PyNumberMethods Vector_NumMethods = { (binaryfunc) Vector_add, /*nb_add*/ (binaryfunc) Vector_sub, /*nb_subtract*/ @@ -1183,53 +1172,6 @@ static PyNumberMethods Vector_NumMethods = { Vector_idiv, /* nb_inplace_true_divide */ 0, /* nb_index */ }; -#else -static PyNumberMethods Vector_NumMethods = { - (binaryfunc) Vector_add, /* __add__ */ - (binaryfunc) Vector_sub, /* __sub__ */ - (binaryfunc) Vector_mul, /* __mul__ */ - (binaryfunc) Vector_div, /* __div__ */ - (binaryfunc) NULL, /* __mod__ */ - (binaryfunc) NULL, /* __divmod__ */ - (ternaryfunc) NULL, /* __pow__ */ - (unaryfunc) Vector_neg, /* __neg__ */ - (unaryfunc) NULL, /* __pos__ */ - (unaryfunc) NULL, /* __abs__ */ - (inquiry) NULL, /* __nonzero__ */ - (unaryfunc) NULL, /* __invert__ */ - (binaryfunc) NULL, /* __lshift__ */ - (binaryfunc) NULL, /* __rshift__ */ - (binaryfunc) NULL, /* __and__ */ - (binaryfunc) NULL, /* __xor__ */ - (binaryfunc) NULL, /* __or__ */ - /*(coercion)*/ NULL, /* __coerce__ */ - (unaryfunc) NULL, /* __int__ */ - (unaryfunc) NULL, /* __long__ */ - (unaryfunc) NULL, /* __float__ */ - (unaryfunc) NULL, /* __oct__ */ - (unaryfunc) NULL, /* __hex__ */ - - /* Added in release 2.0 */ - (binaryfunc) Vector_iadd, /*__iadd__*/ - (binaryfunc) Vector_isub, /*__isub__*/ - (binaryfunc) Vector_imul, /*__imul__*/ - (binaryfunc) Vector_idiv, /*__idiv__*/ - (binaryfunc) NULL, /*__imod__*/ - (ternaryfunc) NULL, /*__ipow__*/ - (binaryfunc) NULL, /*__ilshift__*/ - (binaryfunc) NULL, /*__irshift__*/ - (binaryfunc) NULL, /*__iand__*/ - (binaryfunc) NULL, /*__ixor__*/ - (binaryfunc) NULL, /*__ior__*/ - - /* Added in release 2.2 */ - /* The following require the Py_TPFLAGS_HAVE_CLASS flag */ - (binaryfunc) NULL, /*__floordiv__ __rfloordiv__*/ - (binaryfunc) NULL, /*__truediv__ __rfloordiv__*/ - (binaryfunc) NULL, /*__ifloordiv__*/ - (binaryfunc) NULL, /*__itruediv__*/ -}; -#endif /*------------------PY_OBECT DEFINITION--------------------------*/ @@ -1325,7 +1267,7 @@ static PyObject *Vector_getSwizzle(VectorObject * self, void *closure) /* Unpack the axes from the closure into an array. */ axisA = 0; - swizzleClosure = (unsigned int) closure; + swizzleClosure = GET_INT_FROM_POINTER(closure); while (swizzleClosure & SWIZZLE_VALID_AXIS) { axisB = swizzleClosure & SWIZZLE_AXIS; @@ -1365,7 +1307,7 @@ static int Vector_setSwizzle(VectorObject * self, PyObject * value, void *closur /* Check that the closure can be used with this vector: even 2D vectors have swizzles defined for axes z and w, but they would be invalid. */ - swizzleClosure = (unsigned int) closure; + swizzleClosure = GET_INT_FROM_POINTER(closure); while (swizzleClosure & SWIZZLE_VALID_AXIS) { axisA = swizzleClosure & SWIZZLE_AXIS; @@ -1382,7 +1324,7 @@ static int Vector_setSwizzle(VectorObject * self, PyObject * value, void *closur /* Copy vector contents onto swizzled axes. */ vecVal = (VectorObject*) value; axisB = 0; - swizzleClosure = (unsigned int) closure; + swizzleClosure = GET_INT_FROM_POINTER(closure); while (swizzleClosure & SWIZZLE_VALID_AXIS && axisB < vecVal->size) { axisA = swizzleClosure & SWIZZLE_AXIS; @@ -1398,7 +1340,7 @@ static int Vector_setSwizzle(VectorObject * self, PyObject * value, void *closur { /* Copy list contents onto swizzled axes. */ listLen = PyList_Size(value); - swizzleClosure = (unsigned int) closure; + swizzleClosure = GET_INT_FROM_POINTER(closure); axisB = 0; while (swizzleClosure & SWIZZLE_VALID_AXIS && axisB < listLen) { @@ -1423,7 +1365,7 @@ static int Vector_setSwizzle(VectorObject * self, PyObject * value, void *closur else if (((scalarVal = (float)PyFloat_AsDouble(value)) == -1.0 && PyErr_Occurred())==0) { /* Assign the same value to each axis. */ - swizzleClosure = (unsigned int) closure; + swizzleClosure = GET_INT_FROM_POINTER(closure); while (swizzleClosure & SWIZZLE_VALID_AXIS) { axisA = swizzleClosure & SWIZZLE_AXIS; @@ -1482,342 +1424,342 @@ static PyGetSetDef Vector_getseters[] = { NULL}, /* autogenerated swizzle attrs, see python script below */ - {"xx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS)))}, /* 36 */ - {"xxx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 292 */ - {"xxxx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2340 */ - {"xxxy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2852 */ - {"xxxz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3364 */ - {"xxxw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3876 */ - {"xxy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 356 */ - {"xxyx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2404 */ - {"xxyy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2916 */ - {"xxyz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3428 */ - {"xxyw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3940 */ - {"xxz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 420 */ - {"xxzx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2468 */ - {"xxzy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2980 */ - {"xxzz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3492 */ - {"xxzw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4004 */ - {"xxw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 484 */ - {"xxwx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2532 */ - {"xxwy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3044 */ - {"xxwz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3556 */ - {"xxww", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4068 */ - {"xy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS)))}, /* 44 */ - {"xyx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 300 */ - {"xyxx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2348 */ - {"xyxy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2860 */ - {"xyxz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3372 */ - {"xyxw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3884 */ - {"xyy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 364 */ - {"xyyx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2412 */ - {"xyyy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2924 */ - {"xyyz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3436 */ - {"xyyw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3948 */ - {"xyz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 428 */ - {"xyzx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2476 */ - {"xyzy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2988 */ - {"xyzz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3500 */ - {"xyzw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4012 */ - {"xyw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 492 */ - {"xywx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2540 */ - {"xywy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3052 */ - {"xywz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3564 */ - {"xyww", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4076 */ - {"xz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS)))}, /* 52 */ - {"xzx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 308 */ - {"xzxx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2356 */ - {"xzxy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2868 */ - {"xzxz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3380 */ - {"xzxw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3892 */ - {"xzy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 372 */ - {"xzyx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2420 */ - {"xzyy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2932 */ - {"xzyz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3444 */ - {"xzyw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3956 */ - {"xzz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 436 */ - {"xzzx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2484 */ - {"xzzy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2996 */ - {"xzzz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3508 */ - {"xzzw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4020 */ - {"xzw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 500 */ - {"xzwx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2548 */ - {"xzwy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3060 */ - {"xzwz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3572 */ - {"xzww", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4084 */ - {"xw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS)))}, /* 60 */ - {"xwx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 316 */ - {"xwxx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2364 */ - {"xwxy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2876 */ - {"xwxz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3388 */ - {"xwxw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3900 */ - {"xwy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 380 */ - {"xwyx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2428 */ - {"xwyy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2940 */ - {"xwyz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3452 */ - {"xwyw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3964 */ - {"xwz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 444 */ - {"xwzx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2492 */ - {"xwzy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3004 */ - {"xwzz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3516 */ - {"xwzw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4028 */ - {"xww", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 508 */ - {"xwwx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2556 */ - {"xwwy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3068 */ - {"xwwz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3580 */ - {"xwww", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4092 */ - {"yx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS)))}, /* 37 */ - {"yxx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 293 */ - {"yxxx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2341 */ - {"yxxy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2853 */ - {"yxxz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3365 */ - {"yxxw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3877 */ - {"yxy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 357 */ - {"yxyx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2405 */ - {"yxyy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2917 */ - {"yxyz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3429 */ - {"yxyw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3941 */ - {"yxz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 421 */ - {"yxzx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2469 */ - {"yxzy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2981 */ - {"yxzz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3493 */ - {"yxzw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4005 */ - {"yxw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 485 */ - {"yxwx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2533 */ - {"yxwy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3045 */ - {"yxwz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3557 */ - {"yxww", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4069 */ - {"yy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS)))}, /* 45 */ - {"yyx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 301 */ - {"yyxx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2349 */ - {"yyxy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2861 */ - {"yyxz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3373 */ - {"yyxw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3885 */ - {"yyy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 365 */ - {"yyyx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2413 */ - {"yyyy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2925 */ - {"yyyz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3437 */ - {"yyyw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3949 */ - {"yyz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 429 */ - {"yyzx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2477 */ - {"yyzy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2989 */ - {"yyzz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3501 */ - {"yyzw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4013 */ - {"yyw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 493 */ - {"yywx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2541 */ - {"yywy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3053 */ - {"yywz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3565 */ - {"yyww", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4077 */ - {"yz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS)))}, /* 53 */ - {"yzx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 309 */ - {"yzxx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2357 */ - {"yzxy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2869 */ - {"yzxz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3381 */ - {"yzxw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3893 */ - {"yzy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 373 */ - {"yzyx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2421 */ - {"yzyy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2933 */ - {"yzyz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3445 */ - {"yzyw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3957 */ - {"yzz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 437 */ - {"yzzx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2485 */ - {"yzzy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2997 */ - {"yzzz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3509 */ - {"yzzw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4021 */ - {"yzw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 501 */ - {"yzwx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2549 */ - {"yzwy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3061 */ - {"yzwz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3573 */ - {"yzww", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4085 */ - {"yw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS)))}, /* 61 */ - {"ywx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 317 */ - {"ywxx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2365 */ - {"ywxy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2877 */ - {"ywxz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3389 */ - {"ywxw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3901 */ - {"ywy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 381 */ - {"ywyx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2429 */ - {"ywyy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2941 */ - {"ywyz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3453 */ - {"ywyw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3965 */ - {"ywz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 445 */ - {"ywzx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2493 */ - {"ywzy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3005 */ - {"ywzz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3517 */ - {"ywzw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4029 */ - {"yww", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 509 */ - {"ywwx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2557 */ - {"ywwy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3069 */ - {"ywwz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3581 */ - {"ywww", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4093 */ - {"zx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS)))}, /* 38 */ - {"zxx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 294 */ - {"zxxx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2342 */ - {"zxxy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2854 */ - {"zxxz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3366 */ - {"zxxw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3878 */ - {"zxy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 358 */ - {"zxyx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2406 */ - {"zxyy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2918 */ - {"zxyz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3430 */ - {"zxyw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3942 */ - {"zxz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 422 */ - {"zxzx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2470 */ - {"zxzy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2982 */ - {"zxzz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3494 */ - {"zxzw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4006 */ - {"zxw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 486 */ - {"zxwx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2534 */ - {"zxwy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3046 */ - {"zxwz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3558 */ - {"zxww", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4070 */ - {"zy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS)))}, /* 46 */ - {"zyx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 302 */ - {"zyxx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2350 */ - {"zyxy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2862 */ - {"zyxz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3374 */ - {"zyxw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3886 */ - {"zyy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 366 */ - {"zyyx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2414 */ - {"zyyy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2926 */ - {"zyyz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3438 */ - {"zyyw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3950 */ - {"zyz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 430 */ - {"zyzx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2478 */ - {"zyzy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2990 */ - {"zyzz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3502 */ - {"zyzw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4014 */ - {"zyw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 494 */ - {"zywx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2542 */ - {"zywy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3054 */ - {"zywz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3566 */ - {"zyww", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4078 */ - {"zz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS)))}, /* 54 */ - {"zzx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 310 */ - {"zzxx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2358 */ - {"zzxy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2870 */ - {"zzxz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3382 */ - {"zzxw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3894 */ - {"zzy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 374 */ - {"zzyx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2422 */ - {"zzyy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2934 */ - {"zzyz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3446 */ - {"zzyw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3958 */ - {"zzz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 438 */ - {"zzzx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2486 */ - {"zzzy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2998 */ - {"zzzz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3510 */ - {"zzzw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4022 */ - {"zzw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 502 */ - {"zzwx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2550 */ - {"zzwy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3062 */ - {"zzwz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3574 */ - {"zzww", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4086 */ - {"zw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS)))}, /* 62 */ - {"zwx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 318 */ - {"zwxx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2366 */ - {"zwxy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2878 */ - {"zwxz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3390 */ - {"zwxw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3902 */ - {"zwy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 382 */ - {"zwyx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2430 */ - {"zwyy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2942 */ - {"zwyz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3454 */ - {"zwyw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3966 */ - {"zwz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 446 */ - {"zwzx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2494 */ - {"zwzy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3006 */ - {"zwzz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3518 */ - {"zwzw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4030 */ - {"zww", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 510 */ - {"zwwx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2558 */ - {"zwwy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3070 */ - {"zwwz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3582 */ - {"zwww", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4094 */ - {"wx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS)))}, /* 39 */ - {"wxx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 295 */ - {"wxxx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2343 */ - {"wxxy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2855 */ - {"wxxz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3367 */ - {"wxxw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3879 */ - {"wxy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 359 */ - {"wxyx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2407 */ - {"wxyy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2919 */ - {"wxyz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3431 */ - {"wxyw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3943 */ - {"wxz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 423 */ - {"wxzx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2471 */ - {"wxzy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2983 */ - {"wxzz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3495 */ - {"wxzw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4007 */ - {"wxw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 487 */ - {"wxwx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2535 */ - {"wxwy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3047 */ - {"wxwz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3559 */ - {"wxww", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4071 */ - {"wy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS)))}, /* 47 */ - {"wyx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 303 */ - {"wyxx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2351 */ - {"wyxy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2863 */ - {"wyxz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3375 */ - {"wyxw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3887 */ - {"wyy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 367 */ - {"wyyx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2415 */ - {"wyyy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2927 */ - {"wyyz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3439 */ - {"wyyw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3951 */ - {"wyz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 431 */ - {"wyzx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2479 */ - {"wyzy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2991 */ - {"wyzz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3503 */ - {"wyzw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4015 */ - {"wyw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 495 */ - {"wywx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2543 */ - {"wywy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3055 */ - {"wywz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3567 */ - {"wyww", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4079 */ - {"wz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS)))}, /* 55 */ - {"wzx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 311 */ - {"wzxx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2359 */ - {"wzxy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2871 */ - {"wzxz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3383 */ - {"wzxw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3895 */ - {"wzy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 375 */ - {"wzyx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2423 */ - {"wzyy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2935 */ - {"wzyz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3447 */ - {"wzyw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3959 */ - {"wzz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 439 */ - {"wzzx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2487 */ - {"wzzy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2999 */ - {"wzzz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3511 */ - {"wzzw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4023 */ - {"wzw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 503 */ - {"wzwx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2551 */ - {"wzwy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3063 */ - {"wzwz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3575 */ - {"wzww", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4087 */ - {"ww", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS)))}, /* 63 */ - {"wwx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 319 */ - {"wwxx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2367 */ - {"wwxy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2879 */ - {"wwxz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3391 */ - {"wwxw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3903 */ - {"wwy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 383 */ - {"wwyx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2431 */ - {"wwyy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2943 */ - {"wwyz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3455 */ - {"wwyw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3967 */ - {"wwz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 447 */ - {"wwzx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2495 */ - {"wwzy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3007 */ - {"wwzz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3519 */ - {"wwzw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4031 */ - {"www", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 511 */ - {"wwwx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2559 */ - {"wwwy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3071 */ - {"wwwz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3583 */ - {"wwww", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4095 */ + {"xx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS)))}, /* 36 */ + {"xxx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 292 */ + {"xxxx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2340 */ + {"xxxy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2852 */ + {"xxxz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3364 */ + {"xxxw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3876 */ + {"xxy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 356 */ + {"xxyx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2404 */ + {"xxyy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2916 */ + {"xxyz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3428 */ + {"xxyw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3940 */ + {"xxz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 420 */ + {"xxzx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2468 */ + {"xxzy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2980 */ + {"xxzz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3492 */ + {"xxzw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4004 */ + {"xxw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 484 */ + {"xxwx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2532 */ + {"xxwy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3044 */ + {"xxwz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3556 */ + {"xxww", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4068 */ + {"xy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS)))}, /* 44 */ + {"xyx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 300 */ + {"xyxx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2348 */ + {"xyxy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2860 */ + {"xyxz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3372 */ + {"xyxw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3884 */ + {"xyy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 364 */ + {"xyyx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2412 */ + {"xyyy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2924 */ + {"xyyz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3436 */ + {"xyyw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3948 */ + {"xyz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 428 */ + {"xyzx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2476 */ + {"xyzy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2988 */ + {"xyzz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3500 */ + {"xyzw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4012 */ + {"xyw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 492 */ + {"xywx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2540 */ + {"xywy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3052 */ + {"xywz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3564 */ + {"xyww", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4076 */ + {"xz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS)))}, /* 52 */ + {"xzx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 308 */ + {"xzxx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2356 */ + {"xzxy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2868 */ + {"xzxz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3380 */ + {"xzxw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3892 */ + {"xzy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 372 */ + {"xzyx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2420 */ + {"xzyy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2932 */ + {"xzyz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3444 */ + {"xzyw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3956 */ + {"xzz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 436 */ + {"xzzx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2484 */ + {"xzzy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2996 */ + {"xzzz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3508 */ + {"xzzw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4020 */ + {"xzw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 500 */ + {"xzwx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2548 */ + {"xzwy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3060 */ + {"xzwz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3572 */ + {"xzww", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4084 */ + {"xw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS)))}, /* 60 */ + {"xwx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 316 */ + {"xwxx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2364 */ + {"xwxy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2876 */ + {"xwxz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3388 */ + {"xwxw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3900 */ + {"xwy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 380 */ + {"xwyx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2428 */ + {"xwyy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2940 */ + {"xwyz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3452 */ + {"xwyw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3964 */ + {"xwz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 444 */ + {"xwzx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2492 */ + {"xwzy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3004 */ + {"xwzz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3516 */ + {"xwzw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4028 */ + {"xww", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 508 */ + {"xwwx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2556 */ + {"xwwy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3068 */ + {"xwwz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3580 */ + {"xwww", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4092 */ + {"yx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS)))}, /* 37 */ + {"yxx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 293 */ + {"yxxx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2341 */ + {"yxxy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2853 */ + {"yxxz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3365 */ + {"yxxw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3877 */ + {"yxy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 357 */ + {"yxyx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2405 */ + {"yxyy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2917 */ + {"yxyz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3429 */ + {"yxyw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3941 */ + {"yxz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 421 */ + {"yxzx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2469 */ + {"yxzy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2981 */ + {"yxzz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3493 */ + {"yxzw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4005 */ + {"yxw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 485 */ + {"yxwx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2533 */ + {"yxwy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3045 */ + {"yxwz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3557 */ + {"yxww", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4069 */ + {"yy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS)))}, /* 45 */ + {"yyx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 301 */ + {"yyxx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2349 */ + {"yyxy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2861 */ + {"yyxz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3373 */ + {"yyxw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3885 */ + {"yyy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 365 */ + {"yyyx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2413 */ + {"yyyy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2925 */ + {"yyyz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3437 */ + {"yyyw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3949 */ + {"yyz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 429 */ + {"yyzx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2477 */ + {"yyzy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2989 */ + {"yyzz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3501 */ + {"yyzw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4013 */ + {"yyw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 493 */ + {"yywx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2541 */ + {"yywy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3053 */ + {"yywz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3565 */ + {"yyww", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4077 */ + {"yz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS)))}, /* 53 */ + {"yzx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 309 */ + {"yzxx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2357 */ + {"yzxy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2869 */ + {"yzxz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3381 */ + {"yzxw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3893 */ + {"yzy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 373 */ + {"yzyx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2421 */ + {"yzyy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2933 */ + {"yzyz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3445 */ + {"yzyw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3957 */ + {"yzz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 437 */ + {"yzzx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2485 */ + {"yzzy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2997 */ + {"yzzz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3509 */ + {"yzzw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4021 */ + {"yzw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 501 */ + {"yzwx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2549 */ + {"yzwy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3061 */ + {"yzwz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3573 */ + {"yzww", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4085 */ + {"yw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS)))}, /* 61 */ + {"ywx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 317 */ + {"ywxx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2365 */ + {"ywxy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2877 */ + {"ywxz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3389 */ + {"ywxw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3901 */ + {"ywy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 381 */ + {"ywyx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2429 */ + {"ywyy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2941 */ + {"ywyz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3453 */ + {"ywyw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3965 */ + {"ywz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 445 */ + {"ywzx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2493 */ + {"ywzy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3005 */ + {"ywzz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3517 */ + {"ywzw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4029 */ + {"yww", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 509 */ + {"ywwx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2557 */ + {"ywwy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3069 */ + {"ywwz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3581 */ + {"ywww", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((1|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4093 */ + {"zx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS)))}, /* 38 */ + {"zxx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 294 */ + {"zxxx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2342 */ + {"zxxy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2854 */ + {"zxxz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3366 */ + {"zxxw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3878 */ + {"zxy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 358 */ + {"zxyx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2406 */ + {"zxyy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2918 */ + {"zxyz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3430 */ + {"zxyw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3942 */ + {"zxz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 422 */ + {"zxzx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2470 */ + {"zxzy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2982 */ + {"zxzz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3494 */ + {"zxzw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4006 */ + {"zxw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 486 */ + {"zxwx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2534 */ + {"zxwy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3046 */ + {"zxwz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3558 */ + {"zxww", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4070 */ + {"zy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS)))}, /* 46 */ + {"zyx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 302 */ + {"zyxx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2350 */ + {"zyxy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2862 */ + {"zyxz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3374 */ + {"zyxw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3886 */ + {"zyy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 366 */ + {"zyyx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2414 */ + {"zyyy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2926 */ + {"zyyz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3438 */ + {"zyyw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3950 */ + {"zyz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 430 */ + {"zyzx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2478 */ + {"zyzy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2990 */ + {"zyzz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3502 */ + {"zyzw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4014 */ + {"zyw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 494 */ + {"zywx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2542 */ + {"zywy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3054 */ + {"zywz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3566 */ + {"zyww", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4078 */ + {"zz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS)))}, /* 54 */ + {"zzx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 310 */ + {"zzxx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2358 */ + {"zzxy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2870 */ + {"zzxz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3382 */ + {"zzxw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3894 */ + {"zzy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 374 */ + {"zzyx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2422 */ + {"zzyy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2934 */ + {"zzyz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3446 */ + {"zzyw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3958 */ + {"zzz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 438 */ + {"zzzx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2486 */ + {"zzzy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2998 */ + {"zzzz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3510 */ + {"zzzw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4022 */ + {"zzw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 502 */ + {"zzwx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2550 */ + {"zzwy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3062 */ + {"zzwz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3574 */ + {"zzww", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4086 */ + {"zw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS)))}, /* 62 */ + {"zwx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 318 */ + {"zwxx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2366 */ + {"zwxy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2878 */ + {"zwxz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3390 */ + {"zwxw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3902 */ + {"zwy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 382 */ + {"zwyx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2430 */ + {"zwyy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2942 */ + {"zwyz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3454 */ + {"zwyw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3966 */ + {"zwz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 446 */ + {"zwzx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2494 */ + {"zwzy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3006 */ + {"zwzz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3518 */ + {"zwzw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4030 */ + {"zww", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 510 */ + {"zwwx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2558 */ + {"zwwy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3070 */ + {"zwwz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3582 */ + {"zwww", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((2|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4094 */ + {"wx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS)))}, /* 39 */ + {"wxx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 295 */ + {"wxxx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2343 */ + {"wxxy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2855 */ + {"wxxz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3367 */ + {"wxxw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3879 */ + {"wxy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 359 */ + {"wxyx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2407 */ + {"wxyy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2919 */ + {"wxyz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3431 */ + {"wxyw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3943 */ + {"wxz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 423 */ + {"wxzx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2471 */ + {"wxzy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2983 */ + {"wxzz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3495 */ + {"wxzw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4007 */ + {"wxw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 487 */ + {"wxwx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2535 */ + {"wxwy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3047 */ + {"wxwz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3559 */ + {"wxww", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4071 */ + {"wy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS)))}, /* 47 */ + {"wyx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 303 */ + {"wyxx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2351 */ + {"wyxy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2863 */ + {"wyxz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3375 */ + {"wyxw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3887 */ + {"wyy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 367 */ + {"wyyx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2415 */ + {"wyyy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2927 */ + {"wyyz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3439 */ + {"wyyw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3951 */ + {"wyz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 431 */ + {"wyzx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2479 */ + {"wyzy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2991 */ + {"wyzz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3503 */ + {"wyzw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4015 */ + {"wyw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 495 */ + {"wywx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2543 */ + {"wywy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3055 */ + {"wywz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3567 */ + {"wyww", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4079 */ + {"wz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS)))}, /* 55 */ + {"wzx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 311 */ + {"wzxx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2359 */ + {"wzxy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2871 */ + {"wzxz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3383 */ + {"wzxw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3895 */ + {"wzy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 375 */ + {"wzyx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2423 */ + {"wzyy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2935 */ + {"wzyz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3447 */ + {"wzyw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3959 */ + {"wzz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 439 */ + {"wzzx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2487 */ + {"wzzy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2999 */ + {"wzzz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3511 */ + {"wzzw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4023 */ + {"wzw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 503 */ + {"wzwx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2551 */ + {"wzwy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3063 */ + {"wzwz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3575 */ + {"wzww", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4087 */ + {"ww", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS)))}, /* 63 */ + {"wwx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 319 */ + {"wwxx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2367 */ + {"wwxy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2879 */ + {"wwxz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3391 */ + {"wwxw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3903 */ + {"wwy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 383 */ + {"wwyx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2431 */ + {"wwyy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2943 */ + {"wwyz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3455 */ + {"wwyw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3967 */ + {"wwz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 447 */ + {"wwzx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2495 */ + {"wwzy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3007 */ + {"wwzz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3519 */ + {"wwzw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4031 */ + {"www", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 511 */ + {"wwwx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2559 */ + {"wwwy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3071 */ + {"wwwz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3583 */ + {"wwww", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(((3|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4095 */ {NULL,NULL,NULL,NULL,NULL} /* Sentinel */ }; @@ -1854,7 +1796,7 @@ items.sort(key = lambda a: a[0].replace('x', '0').replace('y', '1').replace('z', unique = set() for key, val in items: num = eval(val) - print '\t{"%s", %s(getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)%s)}, // %s' % (key, (' '*(4-len(key))), axis_dict[key], num) + print '\t{"%s", %s(getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, SET_INT_IN_POINTER(%s)}, // %s' % (key, (' '*(4-len(key))), axis_dict[key], num) unique.add(num) if len(unique) != len(items): @@ -1872,13 +1814,7 @@ if len(unique) != len(items): */ PyTypeObject vector_Type = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /* ob_size */ -#endif /* For printing, in format "<module>.<name>" */ "vector", /* char *tp_name; */ sizeof( VectorObject ), /* int tp_basicsize; */ @@ -1897,11 +1833,7 @@ PyTypeObject vector_Type = { &Vector_NumMethods, /* PyNumberMethods *tp_as_number; */ &Vector_SeqMethods, /* PySequenceMethods *tp_as_sequence; */ -#if (PY_VERSION_HEX >= 0x03000000) &Vector_AsMapping, /* PyMappingMethods *tp_as_mapping; */ -#else - NULL, -#endif /* More standard operations (here for binary compatibility) */ diff --git a/source/blender/python/generic/vector.h b/source/blender/python/generic/vector.h index 316e0ced673..fba53d2e2bf 100644 --- a/source/blender/python/generic/vector.h +++ b/source/blender/python/generic/vector.h @@ -31,7 +31,6 @@ #define EXPP_vector_h #include <Python.h> -#include "../intern/bpy_compat.h" extern PyTypeObject vector_Type; #define VectorObject_Check(_v) PyObject_TypeCheck((_v), &vector_Type) diff --git a/source/blender/python/intern/Makefile b/source/blender/python/intern/Makefile index e0e0e942151..419092cbe21 100644 --- a/source/blender/python/intern/Makefile +++ b/source/blender/python/intern/Makefile @@ -1,5 +1,5 @@ # -# $Id: Makefile 21094 2009-06-23 00:09:26Z gsrb3d $ +# $Id$ # # ***** BEGIN GPL LICENSE BLOCK ***** # @@ -43,7 +43,7 @@ CPPFLAGS += -I$(NAN_PYTHON)/include/python$(NAN_PYTHON_VERSION) # PreProcessor stuff CPPFLAGS += -I$(NAN_GHOST)/include -CPPFLAGS += -I$(NAN_SOUNDSYSTEM)/include $(NAN_SDLCFLAGS) +CPPFLAGS += $(NAN_SDLCFLAGS) # modules CPPFLAGS += -I../../editors/include diff --git a/source/blender/python/intern/bpy_array.c b/source/blender/python/intern/bpy_array.c new file mode 100644 index 00000000000..d52bfda202d --- /dev/null +++ b/source/blender/python/intern/bpy_array.c @@ -0,0 +1,235 @@ +/** + * + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * Contributor(s): Arystanbek Dyussenov + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include "Python.h" + +#include "bpy_rna.h" + +#include "RNA_access.h" + +#include "BLI_string.h" + +#include "MEM_guardedalloc.h" + +typedef void (*ItemConvertFunc)(PyObject *, char *); +typedef int (*ItemTypeCheckFunc)(PyObject *); +typedef void (*RNA_SetArrayFunc)(PointerRNA *, PropertyRNA *, const char *); + +/* Ensures that a python sequence has an expected number of items/sub-items and items are of expected type. */ +static int pyrna_validate_array(PyObject *seq, unsigned short dim, unsigned short totdim, unsigned short dim_size[], + ItemTypeCheckFunc check_item_type, const char *item_type_str, char *error_str, int error_str_size) +{ + int i; + if (dim < totdim) { + for (i= 0; i < PySequence_Length(seq); i++) { + PyObject *item; + int ok= 1; + item= PySequence_GetItem(seq, i); + + if (!PySequence_Check(item)) { + BLI_snprintf(error_str, error_str_size, "expected a %d-dimensional sequence of %s", (int)totdim, item_type_str); + ok= 0; + } + else if (PySequence_Length(item) != dim_size[dim - 1]) { + BLI_snprintf(error_str, error_str_size, "dimension %d should contain %d items", (int)dim, (int)dim_size[dim - 1]); + ok= 0; + } + + if (!pyrna_validate_array(item, dim + 1, totdim, dim_size, check_item_type, item_type_str, error_str, error_str_size)) { + ok= 0; + } + + Py_DECREF(item); + + if (!ok) + return 0; + } + } + else { + for (i= 0; i < PySequence_Length(seq); i++) { + PyObject *item= PySequence_GetItem(seq, i); + + if (!check_item_type(item)) { + Py_DECREF(item); + + BLI_snprintf(error_str, error_str_size, "sequence items should be of type %s", item_type_str); + return 0; + } + + Py_DECREF(item); + } + } + + return 1; +} + +/* Returns the number of items in a single- or multi-dimensional sequence. */ +static int pyrna_count_items(PyObject *seq) +{ + int totitem= 0; + + if (PySequence_Check(seq)) { + int i; + for (i= 0; i < PySequence_Length(seq); i++) { + PyObject *item= PySequence_GetItem(seq, i); + totitem += pyrna_count_items(item); + Py_DECREF(item); + } + } + else + totitem= 1; + + return totitem; +} + +static int pyrna_apply_array_length(PointerRNA *ptr, PropertyRNA *prop, int totitem, char *error_str, int error_str_size) +{ + if (RNA_property_flag(prop) & PROP_DYNAMIC) { + /* length can be flexible */ + if (RNA_property_array_length(ptr, prop) != totitem) { + if (!RNA_property_dynamic_array_set_length(ptr, prop, totitem)) { + BLI_snprintf(error_str, error_str_size, "%s.%s: array length cannot be changed to %d", RNA_struct_identifier(ptr->type), RNA_property_identifier(prop), totitem); + return 0; + } + } + } + else { + /* length is a constraint */ + int len= RNA_property_array_length(ptr, prop); + if (totitem != len) { + BLI_snprintf(error_str, error_str_size, "sequence must have length of %d", len); + return 0; + } + } + return 1; +} + +static char *pyrna_py_to_array(PyObject *seq, unsigned short dim, unsigned short totdim, char *data, unsigned int item_size, ItemConvertFunc convert_item) +{ + unsigned int i; + for (i= 0; i < PySequence_Length(seq); i++) { + PyObject *item= PySequence_GetItem(seq, i); + + if (dim < totdim) { + data= pyrna_py_to_array(item, dim + 1, totdim, data, item_size, convert_item); + } + else { + convert_item(item, data); + data += item_size; + } + + Py_DECREF(item); + } + + return data; +} + +static int pyrna_py_to_array_generic(PyObject *py, PointerRNA *ptr, PropertyRNA *prop, char *param_data, char *error_str, int error_str_size, + ItemTypeCheckFunc check_item_type, const char *item_type_str, int item_size, ItemConvertFunc convert_item, RNA_SetArrayFunc rna_set_array) +{ + unsigned short totdim, dim_size[100]; + int totitem; + char *data= NULL; + + totdim= RNA_property_array_dimension(prop, dim_size); + + if (!pyrna_validate_array(py, 1, totdim, dim_size, check_item_type, item_type_str, error_str, error_str_size)) + return 0; + + totitem= pyrna_count_items(py); + + if (!pyrna_apply_array_length(ptr, prop, totitem, error_str, error_str_size)) + return 0; + + if (totitem) { + if (!param_data || RNA_property_flag(prop) & PROP_DYNAMIC) + data= MEM_callocN(item_size * totitem, "pyrna primitive type array"); + else + data= param_data; + + pyrna_py_to_array(py, 1, totdim, data, item_size, convert_item); + + if (param_data) { + if (RNA_property_flag(prop) & PROP_DYNAMIC) { + /* not freeing allocated mem, RNA_parameter_list_free will do this */ + *(char**)param_data= data; + } + } + else { + /* NULL can only pass through in case RNA property arraylength is 0 (impossible?) */ + rna_set_array(ptr, prop, data); + MEM_freeN(data); + } + } + + return 1; +} + +static void pyrna_py_to_float(PyObject *py, char *data) +{ + *(float*)data= (float)PyFloat_AsDouble(py); +} + +static void pyrna_py_to_int(PyObject *py, char *data) +{ + *(int*)data= (int)PyLong_AsSsize_t(py); +} + +static void pyrna_py_to_boolean(PyObject *py, char *data) +{ + *(int*)data= (int)PyObject_IsTrue(py); +} + +static int py_float_check(PyObject *py) +{ + return PyFloat_Check(py); +} + +static int py_int_check(PyObject *py) +{ + return PyLong_Check(py); +} + +static int py_bool_check(PyObject *py) +{ + return PyBool_Check(py); +} + +int pyrna_py_to_float_array(PyObject *py, PointerRNA *ptr, PropertyRNA *prop, char *param_data, char *error_str, int error_str_size) +{ + return pyrna_py_to_array_generic(py, ptr, prop, param_data, error_str, error_str_size, + py_float_check, "float", sizeof(float), pyrna_py_to_float, (RNA_SetArrayFunc)RNA_property_float_set_array); +} + +int pyrna_py_to_int_array(PyObject *py, PointerRNA *ptr, PropertyRNA *prop, char *param_data, char *error_str, int error_str_size) +{ + return pyrna_py_to_array_generic(py, ptr, prop, param_data, error_str, error_str_size, + py_int_check, "int", sizeof(int), pyrna_py_to_int, (RNA_SetArrayFunc)RNA_property_int_set_array); +} + +int pyrna_py_to_boolean_array(PyObject *py, PointerRNA *ptr, PropertyRNA *prop, char *param_data, char *error_str, int error_str_size) +{ + return pyrna_py_to_array_generic(py, ptr, prop, param_data, error_str, error_str_size, + py_bool_check, "boolean", sizeof(int), pyrna_py_to_boolean, (RNA_SetArrayFunc)RNA_property_boolean_set_array); +} diff --git a/source/blender/python/intern/bpy_compat.h b/source/blender/python/intern/bpy_compat.h deleted file mode 100644 index b9e02d62a57..00000000000 --- a/source/blender/python/intern/bpy_compat.h +++ /dev/null @@ -1,126 +0,0 @@ -/** - * $Id: bpy_compat.h 21427 2009-07-08 14:26:43Z ton $ - * - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * Contributor(s): Campbell Barton - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/* This file is only to contain definitions to functions that enable - * the python api to compile with different python versions. - * no utility functions please - */ - -#ifndef BPY_COMPAT_H__ -#define BPY_COMPAT_H__ - -/* if you are NOT using python 3.0 - define these */ -#if PY_VERSION_HEX < 0x03000000 -#define _PyUnicode_AsString PyString_AsString - -#undef PyUnicode_Check -#define PyUnicode_Check PyString_Check - -#define PyLong_FromSsize_t PyInt_FromLong -#define PyLong_AsSsize_t PyInt_AsLong - -#undef PyLong_Check -#define PyLong_Check PyInt_Check - - -#ifdef PyUnicode_FromString -#undef PyUnicode_FromString -#endif -#define PyUnicode_FromString PyString_FromString - -#ifdef PyUnicode_FromFormat -#undef PyUnicode_FromFormat -#endif -#define PyUnicode_FromFormat PyString_FromFormat - -#endif - -#ifndef Py_REFCNT -#define Py_REFCNT(ob) (((PyObject*)(ob))->ob_refcnt) -#endif - -#ifndef Py_TYPE -#define Py_TYPE(ob) (((PyObject*)(ob))->ob_type) -#endif - -#ifndef Py_TYPE -#define Py_SIZE(ob) (((PyVarObject*)(ob))->ob_size) -#endif - -/* older then python 2.6 - define these */ -// #if (PY_VERSION_HEX < 0x02060000) -// #endif - -/* older then python 2.5 - define these */ -#if (PY_VERSION_HEX < 0x02050000) -#define Py_ssize_t ssize_t -typedef Py_ssize_t (*lenfunc)(PyObject *); -#ifndef Py_RETURN_NONE -#define Py_RETURN_NONE return Py_BuildValue("O", Py_None) -#endif -#ifndef Py_RETURN_FALSE -#define Py_RETURN_FALSE return PyBool_FromLong(0) -#endif -#ifndef Py_RETURN_TRUE -#define Py_RETURN_TRUE return PyBool_FromLong(1) -#endif - -#define PyInt_FromSsize_t PyInt_FromLong -#define PyNumber_AsSsize_t(ob, exc) PyInt_AsLong(ob) -#define PyIndex_Check(ob) PyInt_Check(ob) - - -#endif - - -#if PY_VERSION_HEX < 0x03000000 -#ifndef ssizeargfunc -#define ssizeargfunc intargfunc -#endif - -#ifndef ssizessizeargfunc -#define ssizessizeargfunc intintargfunc -#endif - -#ifndef ssizeobjargproc -#define ssizeobjargproc intobjargproc -#endif - -#ifndef ssizessizeobjargproc -#define ssizessizeobjargproc intintobjargproc -#endif -#endif - - - -/* defined in bpy_util.c */ -#if PY_VERSION_HEX < 0x03000000 -PyObject *Py_CmpToRich(int op, int cmp); -#endif - -#ifndef Py_CmpToRich -PyObject *Py_CmpToRich(int op, int cmp); /* bpy_util.c */ -#endif - -#endif /* BPY_COMPAT_H__ */ diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c index 707c5769357..bd2ae02f81a 100644 --- a/source/blender/python/intern/bpy_interface.c +++ b/source/blender/python/intern/bpy_interface.c @@ -14,8 +14,6 @@ #include "compile.h" /* for the PyCodeObject */ #include "eval.h" /* for PyEval_EvalCode */ -#include "bpy_compat.h" - #include "bpy_rna.h" #include "bpy_operator.h" #include "bpy_ui.h" @@ -45,6 +43,80 @@ #include "../generic/BGL.h" +/* for internal use, when starting and ending python scripts */ + +/* incase a python script triggers another python call, stop bpy_context_clear from invalidating */ +static int py_call_level= 0; + + +// only for tests +#define TIME_PY_RUN + +#ifdef TIME_PY_RUN +#include "PIL_time.h" +static int bpy_timer_count = 0; +static double bpy_timer; /* time since python starts */ +static double bpy_timer_run; /* time for each python script run */ +static double bpy_timer_run_tot; /* accumulate python runs */ +#endif + +void bpy_context_set(bContext *C, PyGILState_STATE *gilstate) +{ + py_call_level++; + + if(gilstate) + *gilstate = PyGILState_Ensure(); + + if(py_call_level==1) { + + BPY_update_modules(); /* can give really bad results if this isnt here */ + + if(C) { // XXX - should always be true. + BPy_SetContext(C); + bpy_import_main_set(CTX_data_main(C)); + } + else { + fprintf(stderr, "ERROR: Python context called with a NULL Context. this should not happen!\n"); + } + +#ifdef TIME_PY_RUN + if(bpy_timer_count==0) { + /* record time from the beginning */ + bpy_timer= PIL_check_seconds_timer(); + bpy_timer_run = bpy_timer_run_tot = 0.0; + } + bpy_timer_run= PIL_check_seconds_timer(); + + + bpy_timer_count++; +#endif + } +} + +void bpy_context_clear(bContext *C, PyGILState_STATE *gilstate) +{ + py_call_level--; + + if(gilstate) + PyGILState_Release(*gilstate); + + if(py_call_level < 0) { + fprintf(stderr, "ERROR: Python context internal state bug. this should not happen!\n"); + } + else if(py_call_level==0) { + // XXX - Calling classes currently wont store the context :\, cant set NULL because of this. but this is very flakey still. + //BPy_SetContext(NULL); + //bpy_import_main_set(NULL); + +#ifdef TIME_PY_RUN + bpy_timer_run_tot += PIL_check_seconds_timer() - bpy_timer_run; + bpy_timer_count++; +#endif + + } +} + + void BPY_free_compiled_text( struct Text *text ) { if( text->compiled ) { @@ -75,23 +147,22 @@ static void bpy_init_modules( void ) /* stand alone utility modules not related to blender directly */ - Geometry_Init("Geometry"); - Mathutils_Init("Mathutils"); - BGL_Init("BGL"); -} - -#if (PY_VERSION_HEX < 0x02050000) -PyObject *PyImport_ImportModuleLevel(char *name, void *a, void *b, void *c, int d) -{ - return PyImport_ImportModule(name); + Geometry_Init(); + Mathutils_Init(); + BGL_Init(); } -#endif void BPY_update_modules( void ) { +#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); PyModule_AddObject( mod, "data", BPY_rna_module() ); - PyModule_AddObject( mod, "types", BPY_rna_types() ); + PyModule_AddObject( mod, "types", BPY_rna_types() ); // atm this does not need updating +#endif + + /* refreshes the main struct */ + BPY_update_rna_module(); + } /***************************************************************************** @@ -106,9 +177,6 @@ static PyObject *CreateGlobalDictionary( bContext *C ) PyDict_SetItemString( dict, "__name__", item ); Py_DECREF(item); - // XXX - evil, need to access context - BPy_SetContext(C); - // XXX - put somewhere more logical { PyMethodDef *ml; @@ -173,9 +241,10 @@ void BPY_start_python( int argc, char **argv ) Py_Initialize( ); -#if (PY_VERSION_HEX < 0x03000000) - PySys_SetArgv( argc, argv); -#else + /*convert argv to wchar_t*/ + // PySys_SetArgv( argc, argv); // broken in py3, not a huge deal + + /*temporarily set argv*/ /* sigh, why do python guys not have a char** version anymore? :( */ { int i; @@ -187,7 +256,6 @@ void BPY_start_python( int argc, char **argv ) PySys_SetObject("argv", py_argv); Py_DECREF(py_argv); } -#endif /* Initialize thread support (also acquires lock) */ PyEval_InitThreads(); @@ -205,38 +273,57 @@ void BPY_start_python( int argc, char **argv ) PyDict_SetItemString(d, "__import__", item=PyCFunction_New(bpy_import_meth, NULL)); Py_DECREF(item); } + pyrna_alloc_types(); + py_tstate = PyGILState_GetThisThreadState(); PyEval_ReleaseThread(py_tstate); } void BPY_end_python( void ) { + // fprintf(stderr, "Ending Python!\n"); + PyGILState_Ensure(); /* finalizing, no need to grab the state */ // free other python data. - //BPY_rna_free_types(); + pyrna_free_types(); + + /* clear all python data from structs */ Py_Finalize( ); - return; +#ifdef TIME_PY_RUN + // measure time since py started + bpy_timer = PIL_check_seconds_timer() - bpy_timer; + + printf("*bpy stats* - "); + printf("tot exec: %d, ", bpy_timer_count); + printf("tot run: %.4fsec, ", bpy_timer_run_tot); + if(bpy_timer_count>0) + printf("average run: %.6fsec, ", (bpy_timer_run_tot/bpy_timer_count)); + + if(bpy_timer>0.0) + printf("tot usage %.4f%%", (bpy_timer_run_tot/bpy_timer)*100.0); + + printf("\n"); + + // fprintf(stderr, "Ending Python Done!\n"); + +#endif + } /* Can run a file or text block */ int BPY_run_python_script( bContext *C, const char *fn, struct Text *text, struct ReportList *reports) { - PyObject *py_dict, *py_result; + PyObject *py_dict, *py_result= NULL; PyGILState_STATE gilstate; if (fn==NULL && text==NULL) { return 0; } - //BPY_start_python(); - - gilstate = PyGILState_Ensure(); - - BPY_update_modules(); /* can give really bad results if this isnt here */ - bpy_import_main_set(CTX_data_main(C)); + bpy_context_set(C, &gilstate); py_dict = CreateGlobalDictionary(C); @@ -251,13 +338,11 @@ int BPY_run_python_script( bContext *C, const char *fn, struct Text *text, struc MEM_freeN( buf ); if( PyErr_Occurred( ) ) { - BPy_errors_to_report(reports); BPY_free_compiled_text( text ); - PyGILState_Release(gilstate); - return 0; } } - py_result = PyEval_EvalCode( text->compiled, py_dict, py_dict ); + if(text->compiled) + py_result = PyEval_EvalCode( text->compiled, py_dict, py_dict ); } else { #if 0 @@ -287,10 +372,9 @@ int BPY_run_python_script( bContext *C, const char *fn, struct Text *text, struc } Py_DECREF(py_dict); - PyGILState_Release(gilstate); - bpy_import_main_set(NULL); - //BPY_end_python(); + bpy_context_clear(C, &gilstate); + return py_result ? 1:0; } @@ -473,12 +557,7 @@ void BPY_run_ui_scripts(bContext *C, int reload) PyGILState_STATE gilstate; PyObject *sys_path; - gilstate = PyGILState_Ensure(); - - // XXX - evil, need to access context - BPy_SetContext(C); - bpy_import_main_set(CTX_data_main(C)); - + bpy_context_set(C, &gilstate); sys_path= PySys_GetObject("path"); /* borrow */ PyList_Insert(sys_path, 0, Py_None); /* place holder, resizes the list */ @@ -537,12 +616,14 @@ void BPY_run_ui_scripts(bContext *C, int reload) PyList_SetSlice(sys_path, 0, 1, NULL); /* remove the first item */ - bpy_import_main_set(NULL); + bpy_context_clear(C, &gilstate); - PyGILState_Release(gilstate); #ifdef TIME_REGISTRATION printf("script time %f\n", (PIL_check_seconds_timer()-time)); #endif + + /* reset the timer so as not to take loading into the stats */ + bpy_timer_count = 0; } /* ****************************************** */ @@ -740,3 +821,56 @@ float BPY_pydriver_eval (ChannelDriver *driver) return result; } + +int BPY_button_eval(bContext *C, char *expr, double *value) +{ + PyGILState_STATE gilstate; + PyObject *dict, *retval; + int error_ret = 0; + + if (!value || !expr || expr[0]=='\0') return -1; + + bpy_context_set(C, &gilstate); + + dict= CreateGlobalDictionary(C); + retval = PyRun_String(expr, Py_eval_input, dict, dict); + + if (retval == NULL) { + error_ret= -1; + } + else { + double val; + + if(PyTuple_Check(retval)) { + /* Users my have typed in 10km, 2m + * add up all values */ + int i; + val= 0.0; + + for(i=0; i<PyTuple_GET_SIZE(retval); i++) { + val+= PyFloat_AsDouble(PyTuple_GET_ITEM(retval, i)); + } + } + else { + val = PyFloat_AsDouble(retval); + } + Py_DECREF(retval); + + if(val==-1 && PyErr_Occurred()) { + error_ret= -1; + } + else { + *value= val; + } + } + + if(error_ret) { + BPy_errors_to_report(CTX_wm_reports(C)); + } + + Py_DECREF(dict); + bpy_context_clear(C, &gilstate); + + return error_ret; +} + diff --git a/source/blender/python/intern/bpy_operator.c b/source/blender/python/intern/bpy_operator.c index 034440d77ac..e431f2a21e9 100644 --- a/source/blender/python/intern/bpy_operator.c +++ b/source/blender/python/intern/bpy_operator.c @@ -30,7 +30,6 @@ #include "bpy_operator.h" #include "bpy_operator_wrap.h" #include "bpy_rna.h" /* for setting arg props only - pyrna_py_to_prop() */ -#include "bpy_compat.h" #include "bpy_util.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 080d2e8ce6a..9a74bf0aee8 100644 --- a/source/blender/python/intern/bpy_operator_wrap.c +++ b/source/blender/python/intern/bpy_operator_wrap.c @@ -37,7 +37,6 @@ #include "RNA_define.h" #include "bpy_rna.h" -#include "bpy_compat.h" #include "bpy_util.h" #include "../generic/bpy_internal_import.h" // our own imports @@ -93,11 +92,9 @@ static int PYTHON_OT_generic(int mode, bContext *C, wmOperator *op, wmEvent *eve PointerRNA ptr_event; PyObject *py_operator; - PyGILState_STATE gilstate = PyGILState_Ensure(); + PyGILState_STATE gilstate; - bpy_import_main_set(CTX_data_main(C)); - - BPY_update_modules(); // XXX - the RNA pointers can change so update before running, would like a nicer solutuon for this. + bpy_context_set(C, &gilstate); args = PyTuple_New(1); PyTuple_SET_ITEM(args, 0, PyObject_GetAttrString(py_class, "__rna__")); // need to use an rna instance as the first arg @@ -221,8 +218,7 @@ static int PYTHON_OT_generic(int mode, bContext *C, wmOperator *op, wmEvent *eve } #endif - PyGILState_Release(gilstate); - bpy_import_main_set(NULL); + bpy_context_clear(C, &gilstate); return ret_flag; } @@ -299,7 +295,7 @@ void PYTHON_OT_wrapper(wmOperatorType *ot, void *userdata) PyObject *py_func_ptr, *py_kw, *py_srna_cobject, *py_ret; item = PyList_GET_ITEM(props, i); - if (PyArg_ParseTuple(item, "O!O!", &PyCObject_Type, &py_func_ptr, &PyDict_Type, &py_kw)) { + if (PyArg_ParseTuple(item, "O!O!:PYTHON_OT_wrapper", &PyCObject_Type, &py_func_ptr, &PyDict_Type, &py_kw)) { PyObject *(*pyfunc)(PyObject *, PyObject *, PyObject *); pyfunc = PyCObject_AsVoidPtr(py_func_ptr); @@ -309,6 +305,8 @@ void PYTHON_OT_wrapper(wmOperatorType *ot, void *userdata) if (py_ret) { Py_DECREF(py_ret); } else { + fprintf(stderr, "BPy Operator \"%s\" registration error: %s item %d could not run\n", ot->idname, PYOP_ATTR_PROP, i); + PyLineSpit(); PyErr_Print(); PyErr_Clear(); } diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index 27bfb89b963..3902a9fd9b5 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -23,7 +23,6 @@ */ #include "bpy_rna.h" -#include "bpy_compat.h" #include "bpy_util.h" //#include "blendef.h" #include "BLI_dynstr.h" @@ -133,6 +132,8 @@ Mathutils_Callback mathutils_rna_matrix_cb = { #endif +static StructRNA *pyrna_struct_as_srna(PyObject *self); + static int pyrna_struct_compare( BPy_StructRNA * a, BPy_StructRNA * b ) { return (a->ptr.data==b->ptr.data) ? 0 : -1; @@ -245,7 +246,7 @@ PyObject * pyrna_prop_to_py(PointerRNA *ptr, PropertyRNA *prop) { PyObject *ret; int type = RNA_property_type(prop); - int len = RNA_property_array_length(prop); + int len = RNA_property_array_length(ptr, prop); if (len > 0) { /* resolve the array from a new pytype */ @@ -256,7 +257,11 @@ PyObject * pyrna_prop_to_py(PointerRNA *ptr, PropertyRNA *prop) /* return a mathutils vector where possible */ if(RNA_property_type(prop)==PROP_FLOAT) { switch(RNA_property_subtype(prop)) { - case PROP_VECTOR: + case PROP_TRANSLATION: + case PROP_DIRECTION: + case PROP_VELOCITY: + case PROP_ACCELERATION: + case PROP_XYZ: if(len>=2 && len <= 4) { PyObject *vec_cb= newVectorObject_cb(ret, len, mathutils_rna_array_cb_index, FALSE); Py_DECREF(ret); /* the vector owns now */ @@ -275,7 +280,8 @@ PyObject * pyrna_prop_to_py(PointerRNA *ptr, PropertyRNA *prop) ret= mat_cb; /* return the matrix instead */ } break; - case PROP_ROTATION: + case PROP_EULER: + case PROP_QUATERNION: if(len==3) { /* euler */ PyObject *eul_cb= newEulerObject_cb(ret, mathutils_rna_array_cb_index, FALSE); Py_DECREF(ret); /* the matrix owns now */ @@ -463,128 +469,43 @@ int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyObject *v { /* XXX hard limits should be checked here */ int type = RNA_property_type(prop); - int len = RNA_property_array_length(prop); + int len = RNA_property_array_length(ptr, prop); if (len > 0) { - PyObject *item; - int py_len = -1; - int i; - + char error_str[512]; + int ok= 1; #ifdef USE_MATHUTILS if(MatrixObject_Check(value)) { MatrixObject *mat = (MatrixObject*)value; if(!BaseMath_ReadCallback(mat)) return -1; - - py_len = mat->rowSize * mat->colSize; } else /* continue... */ #endif - if (PySequence_Check(value)) { - py_len= (int)PySequence_Length(value); - } - else { + if (!PySequence_Check(value)) { PyErr_Format(PyExc_TypeError, "%.200s RNA array assignment expected a sequence instead of %.200s instance.", error_prefix, Py_TYPE(value)->tp_name); return -1; } /* done getting the length */ - if (py_len != len) { - PyErr_Format(PyExc_TypeError, "%.200s python sequence length %d did not match the RNA array length %d.", error_prefix, py_len, len); - return -1; - } - /* for arrays we have a limited number of types */ switch (type) { case PROP_BOOLEAN: - { - int *param_arr; - if(data) param_arr= (int*)data; - else param_arr= MEM_mallocN(sizeof(int) * len, "pyrna bool array"); - - - /* collect the variables before assigning, incase one of them is incorrect */ - for (i=0; i<len; i++) { - item = PySequence_GetItem(value, i); - param_arr[i] = PyObject_IsTrue( item ); - Py_DECREF(item); - - if (param_arr[i] < 0) { - if(data==NULL) - MEM_freeN(param_arr); - PyErr_Format(PyExc_AttributeError, "%.200s one or more of the values in the sequence is not a boolean", error_prefix); - return -1; - } - } - if(data==NULL) { - RNA_property_boolean_set_array(ptr, prop, param_arr); - MEM_freeN(param_arr); - } - + ok= pyrna_py_to_boolean_array(value, ptr, prop, data, error_str, sizeof(error_str)); break; - } case PROP_INT: - { - int *param_arr; - if(data) param_arr= (int*)data; - else param_arr= MEM_mallocN(sizeof(int) * len, "pyrna int array"); - - - /* collect the variables */ - for (i=0; i<len; i++) { - item = PySequence_GetItem(value, i); - param_arr[i] = (int)PyLong_AsSsize_t(item); /* deal with any errors later */ - Py_DECREF(item); - } - - if (PyErr_Occurred()) { - if(data==NULL) - MEM_freeN(param_arr); - PyErr_Format(PyExc_AttributeError, "%.200s one or more of the values in the sequence could not be used as an int", error_prefix); - return -1; - } - if(data==NULL) { - RNA_property_int_set_array(ptr, prop, param_arr); - MEM_freeN(param_arr); - } + ok= pyrna_py_to_int_array(value, ptr, prop, data, error_str, sizeof(error_str)); break; - } case PROP_FLOAT: - { - float *param_arr; - if(data) param_arr = (float*)data; - else param_arr = MEM_mallocN(sizeof(float) * len, "pyrna float array"); - - -#ifdef USE_MATHUTILS - if(MatrixObject_Check(value) && RNA_property_subtype(prop) == PROP_MATRIX) { - MatrixObject *mat = (MatrixObject*)value; - memcpy(param_arr, mat->contigPtr, sizeof(float) * len); - } else /* continue... */ -#endif - { - /* collect the variables */ - for (i=0; i<len; i++) { - item = PySequence_GetItem(value, i); - param_arr[i] = (float)PyFloat_AsDouble(item); /* deal with any errors later */ - Py_DECREF(item); - } - } - - if (PyErr_Occurred()) { - if(data==NULL) - MEM_freeN(param_arr); - PyErr_Format(PyExc_AttributeError, "%.200s one or more of the values in the sequence could not be used as a float", error_prefix); - return -1; - } - if(data==NULL) { - RNA_property_float_set_array(ptr, prop, param_arr); - MEM_freeN(param_arr); - } + ok= pyrna_py_to_float_array(value, ptr, prop, data, error_str, sizeof(error_str)); break; } + if (!ok) { + PyErr_Format(PyExc_AttributeError, "%.200s %s", error_prefix, error_str); + return -1; } - } else { + } + else { /* Normal Property (not an array) */ /* see if we can coorce into a python type - PropertyType */ @@ -856,7 +777,7 @@ static Py_ssize_t pyrna_prop_len( BPy_PropertyRNA * self ) if (RNA_property_type(self->prop) == PROP_COLLECTION) { len = RNA_property_collection_length(&self->ptr, self->prop); } else { - len = RNA_property_array_length(self->prop); + len = RNA_property_array_length(&self->ptr, self->prop); if (len==0) { /* not an array*/ PyErr_SetString(PyExc_AttributeError, "len() only available for collection RNA types"); @@ -882,7 +803,7 @@ static PyObject *prop_subscript_collection_int(BPy_PropertyRNA * self, int keynu } static PyObject *prop_subscript_array_int(BPy_PropertyRNA * self, int keynum) { - int len= RNA_property_array_length(self->prop); + int len= RNA_property_array_length(&self->ptr, self->prop); if(keynum < 0) keynum += len; @@ -904,10 +825,6 @@ static PyObject *prop_subscript_collection_str(BPy_PropertyRNA * self, char *key } /* static PyObject *prop_subscript_array_str(BPy_PropertyRNA * self, char *keyname) */ - - - -#if PY_VERSION_HEX >= 0x03000000 static PyObject *prop_subscript_collection_slice(BPy_PropertyRNA * self, int start, int stop) { PointerRNA newptr; @@ -942,7 +859,6 @@ static PyObject *prop_subscript_array_slice(BPy_PropertyRNA * self, int start, i return list; } -#endif static PyObject *prop_subscript_collection(BPy_PropertyRNA * self, PyObject *key) { @@ -956,7 +872,6 @@ static PyObject *prop_subscript_collection(BPy_PropertyRNA * self, PyObject *key return prop_subscript_collection_int(self, i); } -#if PY_VERSION_HEX >= 0x03000000 else if (PySlice_Check(key)) { int len= RNA_property_collection_length(&self->ptr, self->prop); Py_ssize_t start, stop, step, slicelength; @@ -975,7 +890,6 @@ static PyObject *prop_subscript_collection(BPy_PropertyRNA * self, PyObject *key return NULL; } } -#endif else { PyErr_Format(PyExc_TypeError, "invalid rna key, key must be a string or an int instead of %.200s instance.", Py_TYPE(key)->tp_name); return NULL; @@ -993,9 +907,8 @@ static PyObject *prop_subscript_array(BPy_PropertyRNA * self, PyObject *key) return NULL; return prop_subscript_array_int(self, PyLong_AsSsize_t(key)); } -#if PY_VERSION_HEX >= 0x03000000 else if (PySlice_Check(key)) { - int len= RNA_property_array_length(self->prop); + int len= RNA_property_array_length(&self->ptr, self->prop); Py_ssize_t start, stop, step, slicelength; if (PySlice_GetIndicesEx((PySliceObject*)key, len, &start, &stop, &step, &slicelength) < 0) @@ -1012,7 +925,6 @@ static PyObject *prop_subscript_array(BPy_PropertyRNA * self, PyObject *key) return NULL; } } -#endif else { PyErr_SetString(PyExc_AttributeError, "invalid key, key must be an int"); return NULL; @@ -1023,7 +935,7 @@ static PyObject *pyrna_prop_subscript( BPy_PropertyRNA * self, PyObject *key ) { if (RNA_property_type(self->prop) == PROP_COLLECTION) { return prop_subscript_collection(self, key); - } else if (RNA_property_array_length(self->prop)) { /* arrays are currently fixed length, zero length means its not an array */ + } else if (RNA_property_array_length(&self->ptr, self->prop)) { /* arrays are currently fixed length, zero length means its not an array */ return prop_subscript_array(self, key); } else { PyErr_SetString(PyExc_TypeError, "rna type is not an array or a collection"); @@ -1032,7 +944,6 @@ static PyObject *pyrna_prop_subscript( BPy_PropertyRNA * self, PyObject *key ) } -#if PY_VERSION_HEX >= 0x03000000 static int prop_subscript_ass_array_slice(BPy_PropertyRNA * self, int begin, int end, PyObject *value) { int count; @@ -1049,12 +960,11 @@ static int prop_subscript_ass_array_slice(BPy_PropertyRNA * self, int begin, int return 0; } -#endif static int prop_subscript_ass_array_int(BPy_PropertyRNA * self, int keynum, PyObject *value) { - int len= RNA_property_array_length(self->prop); + int len= RNA_property_array_length(&self->ptr, self->prop); if(keynum < 0) keynum += len; @@ -1087,9 +997,8 @@ static int pyrna_prop_ass_subscript( BPy_PropertyRNA * self, PyObject *key, PyOb return prop_subscript_ass_array_int(self, i, value); } -#if PY_VERSION_HEX >= 0x03000000 else if (PySlice_Check(key)) { - int len= RNA_property_array_length(self->prop); + int len= RNA_property_array_length(&self->ptr, self->prop); Py_ssize_t start, stop, step, slicelength; if (PySlice_GetIndicesEx((PySliceObject*)key, len, &start, &stop, &step, &slicelength) < 0) @@ -1106,7 +1015,6 @@ static int pyrna_prop_ass_subscript( BPy_PropertyRNA * self, PyObject *key, PyOb return -1; } } -#endif else { PyErr_SetString(PyExc_AttributeError, "invalid key, key must be an int"); return -1; @@ -1458,7 +1366,39 @@ static PyObject *pyrna_prop_get(BPy_PropertyRNA *self, PyObject *args) } -#if (PY_VERSION_HEX >= 0x03000000) /* foreach needs py3 */ +static PyObject *pyrna_prop_add(BPy_PropertyRNA *self, PyObject *args) +{ + PointerRNA newptr; + + RNA_property_collection_add(&self->ptr, self->prop, &newptr); + if(!newptr.data) { + PyErr_SetString( PyExc_TypeError, "add() not supported for this collection"); + return NULL; + } + else { + return pyrna_struct_CreatePyObject(&newptr); + } +} + +static PyObject *pyrna_prop_remove(BPy_PropertyRNA *self, PyObject *args) +{ + PyObject *ret; + int key= 0; + + if (!PyArg_ParseTuple(args, "i:remove", &key)) + return NULL; + + if(!RNA_property_collection_remove(&self->ptr, self->prop, key)) { + PyErr_SetString( PyExc_TypeError, "remove() not supported for this collection"); + return NULL; + } + + ret = Py_None; + Py_INCREF(ret); + + return ret; +} + static void foreach_attr_type( BPy_PropertyRNA *self, char *attr, /* values to assign */ RawPropertyType *raw_type, int *attr_tot, int *attr_signed ) @@ -1471,7 +1411,7 @@ static void foreach_attr_type( BPy_PropertyRNA *self, char *attr, RNA_PROP_BEGIN(&self->ptr, itemptr, self->prop) { prop = RNA_struct_find_property(&itemptr, attr); *raw_type= RNA_property_raw_type(prop); - *attr_tot = RNA_property_array_length(prop); + *attr_tot = RNA_property_array_length(&itemptr, prop); *attr_signed= (RNA_property_subtype(prop)==PROP_UNSIGNED) ? FALSE:TRUE; break; } @@ -1510,7 +1450,7 @@ static int foreach_parse_args( if (RNA_property_type(self->prop) == PROP_COLLECTION) array_tot = RNA_property_collection_length(&self->ptr, self->prop); else - array_tot = RNA_property_array_length(self->prop); + array_tot = RNA_property_array_length(&self->ptr, self->prop); target_tot= array_tot * (*attr_tot); @@ -1693,7 +1633,6 @@ static PyObject *pyrna_prop_foreach_set(BPy_PropertyRNA *self, PyObject *args) { return foreach_getset(self, args, 1); } -#endif /* #if (PY_VERSION_HEX >= 0x03000000) */ /* A bit of a kludge, make a list out of a collection or array, * then return the lists iter function, not especially fast but convenient for now */ @@ -1704,7 +1643,7 @@ PyObject *pyrna_prop_iter(BPy_PropertyRNA *self) if (ret==NULL) { /* collection did not work, try array */ - int len = RNA_property_array_length(self->prop); + int len = RNA_property_array_length(&self->ptr, self->prop); if (len) { int i; @@ -1744,11 +1683,13 @@ static struct PyMethodDef pyrna_prop_methods[] = { {"get", (PyCFunction)pyrna_prop_get, METH_VARARGS, NULL}, -#if (PY_VERSION_HEX >= 0x03000000) + {"add", (PyCFunction)pyrna_prop_add, METH_VARARGS, NULL}, + {"remove", (PyCFunction)pyrna_prop_remove, METH_VARARGS, NULL}, + /* array accessor function */ {"foreach_get", (PyCFunction)pyrna_prop_foreach_get, METH_VARARGS, NULL}, {"foreach_set", (PyCFunction)pyrna_prop_foreach_set, METH_VARARGS, NULL}, -#endif + {NULL, NULL, 0, NULL} }; @@ -1793,7 +1734,7 @@ PyObject *pyrna_param_to_py(PointerRNA *ptr, PropertyRNA *prop, void *data) { PyObject *ret; int type = RNA_property_type(prop); - int len = RNA_property_array_length(prop); + int len = RNA_property_array_length(ptr, prop); int a; @@ -2112,13 +2053,7 @@ static PyObject * pyrna_func_call(PyObject * self, PyObject *args, PyObject *kw) /*-----------------------BPy_StructRNA method def------------------------------*/ PyTypeObject pyrna_struct_Type = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /* ob_size */ -#endif "StructRNA", /* tp_name */ sizeof( BPy_StructRNA ), /* tp_basicsize */ 0, /* tp_itemsize */ @@ -2197,14 +2132,7 @@ PyTypeObject pyrna_struct_Type = { /*-----------------------BPy_PropertyRNA method def------------------------------*/ PyTypeObject pyrna_prop_Type = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /* ob_size */ -#endif - "PropertyRNA", /* tp_name */ sizeof( BPy_PropertyRNA ), /* tp_basicsize */ 0, /* tp_itemsize */ @@ -2287,7 +2215,7 @@ static void pyrna_subtype_set_rna(PyObject *newclass, StructRNA *srna) PyObject *item; Py_INCREF(newclass); - + if (RNA_struct_py_type_get(srna)) PyObSpit("RNA WAS SET - ", RNA_struct_py_type_get(srna)); @@ -2297,18 +2225,47 @@ static void pyrna_subtype_set_rna(PyObject *newclass, StructRNA *srna) /* Not 100% needed but useful, * having an instance within a type looks wrong however this instance IS an rna type */ + + /* python deals with the curcular ref */ RNA_pointer_create(NULL, &RNA_Struct, srna, &ptr); item = pyrna_struct_CreatePyObject(&ptr); + + //item = PyCObject_FromVoidPtr(srna, NULL); PyDict_SetItemString(((PyTypeObject *)newclass)->tp_dict, "__rna__", item); Py_DECREF(item); /* done with rna instance */ } +/* +static StructRNA *srna_from_self(PyObject *self); +PyObject *BPy_GetStructRNA(PyObject *self) +{ + StructRNA *srna= pyrna_struct_as_srna(self); + PointerRNA ptr; + PyObject *ret; + + RNA_pointer_create(NULL, &RNA_Struct, srna, &ptr); + ret= pyrna_struct_CreatePyObject(&ptr); + + if(ret) { + return ret; + } + else { + Py_RETURN_NONE; + } +} +*/ + static struct PyMethodDef pyrna_struct_subtype_methods[] = { - {"FloatProperty", (PyCFunction)BPy_FloatProperty, METH_VARARGS|METH_KEYWORDS, ""}, - {"IntProperty", (PyCFunction)BPy_IntProperty, METH_VARARGS|METH_KEYWORDS, ""}, {"BoolProperty", (PyCFunction)BPy_BoolProperty, METH_VARARGS|METH_KEYWORDS, ""}, + {"IntProperty", (PyCFunction)BPy_IntProperty, METH_VARARGS|METH_KEYWORDS, ""}, + {"FloatProperty", (PyCFunction)BPy_FloatProperty, METH_VARARGS|METH_KEYWORDS, ""}, {"StringProperty", (PyCFunction)BPy_StringProperty, METH_VARARGS|METH_KEYWORDS, ""}, + {"EnumProperty", (PyCFunction)BPy_EnumProperty, METH_VARARGS|METH_KEYWORDS, ""}, + {"PointerProperty", (PyCFunction)BPy_PointerProperty, METH_VARARGS|METH_KEYWORDS, ""}, + {"CollectionProperty", (PyCFunction)BPy_CollectionProperty, METH_VARARGS|METH_KEYWORDS, ""}, + +// {"__get_rna", (PyCFunction)BPy_GetStructRNA, METH_NOARGS, ""}, {NULL, NULL, 0, NULL} }; @@ -2343,18 +2300,26 @@ PyObject* pyrna_srna_Subtype(StructRNA *srna) if(base && base != srna) { /*/printf("debug subtype %s %p\n", RNA_struct_identifier(srna), srna); */ py_base= pyrna_srna_Subtype(base); + Py_DECREF(py_base); /* srna owns, this is only to pass as an arg */ } if(py_base==NULL) { py_base= (PyObject *)&pyrna_struct_Type; - Py_INCREF(py_base); } - newclass = PyObject_CallFunction( (PyObject*)&PyType_Type, "s(N){ssss}", idname, py_base, "__module__","bpy.types", "__doc__",descr); + /* always use O not N when calling, N causes refcount errors */ + newclass = PyObject_CallFunction( (PyObject*)&PyType_Type, "s(O){ssss}", idname, py_base, "__module__","bpy.types", "__doc__",descr); + /* newclass will now have 2 ref's, ???, probably 1 is internal since decrefing here segfaults */ + + /* PyObSpit("new class ref", newclass); */ if (newclass) { + + /* srna owns one, and the other is owned by the caller */ pyrna_subtype_set_rna(newclass, srna); - // PyObSpit("NewStructRNA Type: ", (PyObject *)newclass); + + Py_DECREF(newclass); /* let srna own */ + /* attach functions into the class * so you can do... bpy.types.Scene.SomeFunction() @@ -2377,9 +2342,21 @@ PyObject* pyrna_srna_Subtype(StructRNA *srna) return newclass; } +/* use for subtyping so we know which srna is used for a PointerRNA */ +static StructRNA *srna_from_ptr(PointerRNA *ptr) +{ + if(ptr->type == &RNA_Struct) { + return ptr->data; + } + else { + return ptr->type; + } +} + +/* always returns a new ref, be sure to decref when done */ PyObject* pyrna_struct_Subtype(PointerRNA *ptr) { - return pyrna_srna_Subtype((ptr->type == &RNA_Struct) ? ptr->data : ptr->type); + return pyrna_srna_Subtype(srna_from_ptr(ptr)); } /*-----------------------CreatePyObject---------------------------------*/ @@ -2395,6 +2372,7 @@ PyObject *pyrna_struct_CreatePyObject( PointerRNA *ptr ) if (tp) { pyrna = (BPy_StructRNA *) tp->tp_alloc(tp, 0); + Py_DECREF(tp); /* srna owns, cant hold a ref */ } else { fprintf(stderr, "Could not make type\n"); @@ -2432,8 +2410,11 @@ PyObject *pyrna_prop_CreatePyObject( PointerRNA *ptr, PropertyRNA *prop ) return ( PyObject * ) pyrna; } +/* bpy.data from python */ +static PointerRNA *rna_module_ptr= NULL; PyObject *BPY_rna_module( void ) { + BPy_StructRNA *pyrna; PointerRNA ptr; #ifdef USE_MATHUTILS // register mathutils callbacks, ok to run more then once. @@ -2453,8 +2434,15 @@ PyObject *BPY_rna_module( void ) /* for now, return the base RNA type rather then a real module */ RNA_main_pointer_create(G.main, &ptr); + pyrna= (BPy_StructRNA *)pyrna_struct_CreatePyObject(&ptr); - return pyrna_struct_CreatePyObject(&ptr); + rna_module_ptr= &pyrna->ptr; + return (PyObject *)pyrna; +} + +void BPY_update_rna_module(void) +{ + RNA_main_pointer_create(G.main, rna_module_ptr); } #if 0 @@ -2500,8 +2488,8 @@ static PyObject *pyrna_basetype_getattro( BPy_BaseTypeRNA * self, PyObject *pyna static PyObject *pyrna_basetype_dir(BPy_BaseTypeRNA *self); static struct PyMethodDef pyrna_basetype_methods[] = { {"__dir__", (PyCFunction)pyrna_basetype_dir, METH_NOARGS, ""}, - {"register", (PyCFunction)pyrna_basetype_register, METH_VARARGS, ""}, - {"unregister", (PyCFunction)pyrna_basetype_unregister, METH_VARARGS, ""}, + {"register", (PyCFunction)pyrna_basetype_register, METH_O, ""}, + {"unregister", (PyCFunction)pyrna_basetype_unregister, METH_O, ""}, {NULL, NULL, 0, NULL} }; @@ -2548,14 +2536,16 @@ PyObject *BPY_rna_types(void) } static struct PyMethodDef props_methods[] = { - {"FloatProperty", (PyCFunction)BPy_FloatProperty, METH_VARARGS|METH_KEYWORDS, ""}, - {"IntProperty", (PyCFunction)BPy_IntProperty, METH_VARARGS|METH_KEYWORDS, ""}, {"BoolProperty", (PyCFunction)BPy_BoolProperty, METH_VARARGS|METH_KEYWORDS, ""}, + {"IntProperty", (PyCFunction)BPy_IntProperty, METH_VARARGS|METH_KEYWORDS, ""}, + {"FloatProperty", (PyCFunction)BPy_FloatProperty, METH_VARARGS|METH_KEYWORDS, ""}, {"StringProperty", (PyCFunction)BPy_StringProperty, METH_VARARGS|METH_KEYWORDS, ""}, + {"EnumProperty", (PyCFunction)BPy_EnumProperty, METH_VARARGS|METH_KEYWORDS, ""}, + {"PointerProperty", (PyCFunction)BPy_PointerProperty, METH_VARARGS|METH_KEYWORDS, ""}, + {"CollectionProperty", (PyCFunction)BPy_CollectionProperty, METH_VARARGS|METH_KEYWORDS, ""}, {NULL, NULL, 0, NULL} }; -#if PY_VERSION_HEX >= 0x03000000 static struct PyModuleDef props_module = { PyModuleDef_HEAD_INIT, "bpy.props", @@ -2564,16 +2554,11 @@ static struct PyModuleDef props_module = { props_methods, NULL, NULL, NULL, NULL }; -#endif PyObject *BPY_rna_props( void ) { PyObject *submodule; -#if PY_VERSION_HEX >= 0x03000000 submodule= PyModule_Create(&props_module); -#else /* Py2.x */ - submodule= Py_InitModule3( "bpy.props", props_methods, "" ); -#endif /* INCREF since its its assumed that all these functions return the * module with a new ref like PyDict_New, since they are passed to @@ -2583,18 +2568,92 @@ PyObject *BPY_rna_props( void ) return submodule; } +static StructRNA *pyrna_struct_as_srna(PyObject *self) +{ + BPy_StructRNA *py_srna; + StructRNA *srna; + + /* ack, PyObject_GetAttrString wont look up this types tp_dict first :/ */ + if(PyType_Check(self)) { + py_srna = (BPy_StructRNA *)PyDict_GetItemString(((PyTypeObject *)self)->tp_dict, "__rna__"); + Py_XINCREF(py_srna); + } + + if(py_srna==NULL) + py_srna = (BPy_StructRNA*)PyObject_GetAttrString(self, "__rna__"); + + if(py_srna==NULL) { + PyErr_SetString(PyExc_SystemError, "internal error, self had no __rna__ attribute, should never happen."); + return NULL; + } + + if(!BPy_StructRNA_Check(py_srna)) { + PyErr_Format(PyExc_SystemError, "internal error, __rna__ was of type %.200s, instead of %.200s instance.", Py_TYPE(py_srna)->tp_name, pyrna_struct_Type.tp_name); + Py_DECREF(py_srna); + return NULL; + } + + if(py_srna->ptr.type != &RNA_Struct) { + PyErr_SetString(PyExc_SystemError, "internal error, __rna__ was not a RNA_Struct type of rna struct."); + Py_DECREF(py_srna); + return NULL; + } + + srna= py_srna->ptr.data; + Py_DECREF(py_srna); + + return srna; +} + + /* Orphan functions, not sure where they should go */ +/* get the srna for methods attached to types */ +/* */ +static StructRNA *srna_from_self(PyObject *self) +{ + /* a bit sloppy but would cause a very confusing bug if + * an error happened to be set here */ + PyErr_Clear(); + + if(self==NULL) { + return NULL; + } + else if (PyCObject_Check(self)) { + return PyCObject_AsVoidPtr(self); + } + else if (PyType_Check(self)==0) { + return NULL; + } + /* These cases above not errors, they just mean the type was not compatible + * After this any errors will be raised in the script */ + + return pyrna_struct_as_srna(self); +} + +/* operators use this so it can store the args given but defer running + * it until the operator runs where these values are used to setup the + * default args for that operator instance */ +static PyObject *bpy_prop_deferred_return(void *func, PyObject *kw) +{ + PyObject *ret = PyTuple_New(2); + PyTuple_SET_ITEM(ret, 0, PyCObject_FromVoidPtr(func, NULL)); + PyTuple_SET_ITEM(ret, 1, kw); + Py_INCREF(kw); + return ret; +} /* Function that sets RNA, NOTE - self is NULL when called from python, but being abused from C so we can pass the srna allong * This isnt incorrect since its a python object - but be careful */ -PyObject *BPy_FloatProperty(PyObject *self, PyObject *args, PyObject *kw) + +PyObject *BPy_BoolProperty(PyObject *self, PyObject *args, PyObject *kw) { - static char *kwlist[] = {"attr", "name", "description", "min", "max", "soft_min", "soft_max", "default", NULL}; + static char *kwlist[] = {"attr", "name", "description", "default", NULL}; char *id, *name="", *description=""; - float min=FLT_MIN, max=FLT_MAX, soft_min=FLT_MIN, soft_max=FLT_MAX, def=0.0f; + int def=0; PropertyRNA *prop; - - if (!PyArg_ParseTupleAndKeywords(args, kw, "s|ssfffff:FloatProperty", kwlist, &id, &name, &description, &min, &max, &soft_min, &soft_max, &def)) + StructRNA *srna; + + if (!PyArg_ParseTupleAndKeywords(args, kw, "s|ssi:BoolProperty", kwlist, &id, &name, &description, &def)) return NULL; if (PyTuple_Size(args) > 0) { @@ -2602,34 +2661,17 @@ PyObject *BPy_FloatProperty(PyObject *self, PyObject *args, PyObject *kw) return NULL; } - if (self && PyCObject_Check(self)) { - StructRNA *srna = PyCObject_AsVoidPtr(self); - prop= RNA_def_float(srna, id, def, min, max, name, description, soft_min, soft_max); + srna= srna_from_self(self); + if(srna==NULL && PyErr_Occurred()) { + return NULL; /* self's type was compatible but error getting the srna */ + } + else if(srna) { + prop= RNA_def_boolean(srna, id, def, name, description); RNA_def_property_duplicate_pointers(prop); Py_RETURN_NONE; - } else if(self && PyType_Check(self)) { - PyObject *pyob= PyObject_GetAttrString(self, "__rna__"); - - if(pyob && BPy_StructRNA_Check(pyob)) { - BPy_StructRNA *py_srna= (BPy_StructRNA*)pyob; - - if(py_srna->ptr.data && py_srna->ptr.type == &RNA_Struct) { - if(RNA_struct_is_ID(py_srna->ptr.data)) { - prop= RNA_def_float(py_srna->ptr.data, id, def, min, max, name, description, soft_min, soft_max); - RNA_def_property_duplicate_pointers(prop); - Py_RETURN_NONE; - } - } - } - - PyErr_SetString(PyExc_ValueError, "only works on ID types"); - return NULL; - } else { - PyObject *ret = PyTuple_New(2); - PyTuple_SET_ITEM(ret, 0, PyCObject_FromVoidPtr((void *)BPy_FloatProperty, NULL)); - PyTuple_SET_ITEM(ret, 1, kw); - Py_INCREF(kw); - return ret; + } + else { /* operators defer running this function */ + return bpy_prop_deferred_return((void *)BPy_BoolProperty, kw); } } @@ -2639,7 +2681,8 @@ PyObject *BPy_IntProperty(PyObject *self, PyObject *args, PyObject *kw) char *id, *name="", *description=""; int min=INT_MIN, max=INT_MAX, soft_min=INT_MIN, soft_max=INT_MAX, def=0; PropertyRNA *prop; - + StructRNA *srna; + if (!PyArg_ParseTupleAndKeywords(args, kw, "s|ssiiiii:IntProperty", kwlist, &id, &name, &description, &min, &max, &soft_min, &soft_max, &def)) return NULL; @@ -2648,45 +2691,59 @@ PyObject *BPy_IntProperty(PyObject *self, PyObject *args, PyObject *kw) return NULL; } - if (self && PyCObject_Check(self)) { - StructRNA *srna = PyCObject_AsVoidPtr(self); + srna= srna_from_self(self); + if(srna==NULL && PyErr_Occurred()) { + return NULL; /* self's type was compatible but error getting the srna */ + } + else if(srna) { prop= RNA_def_int(srna, id, def, min, max, name, description, soft_min, soft_max); RNA_def_property_duplicate_pointers(prop); Py_RETURN_NONE; - } else if(self && PyType_Check(self)) { - PyObject *pyob= PyObject_GetAttrString(self, "__rna__"); - - if(pyob && BPy_StructRNA_Check(pyob)) { - BPy_StructRNA *py_srna= (BPy_StructRNA*)pyob; + } + else { /* operators defer running this function */ + return bpy_prop_deferred_return((void *)BPy_IntProperty, kw); + } +} - if(py_srna->ptr.data && py_srna->ptr.type == &RNA_Struct) { - if(RNA_struct_is_ID(py_srna->ptr.data)) { - prop= RNA_def_int(py_srna->ptr.data, id, def, min, max, name, description, soft_min, soft_max); - RNA_def_property_duplicate_pointers(prop); - Py_RETURN_NONE; - } - } - } +PyObject *BPy_FloatProperty(PyObject *self, PyObject *args, PyObject *kw) +{ + static char *kwlist[] = {"attr", "name", "description", "min", "max", "soft_min", "soft_max", "default", NULL}; + char *id, *name="", *description=""; + float min=FLT_MIN, max=FLT_MAX, soft_min=FLT_MIN, soft_max=FLT_MAX, def=0.0f; + PropertyRNA *prop; + StructRNA *srna; - PyErr_SetString(PyExc_ValueError, "only works on ID types"); + if (!PyArg_ParseTupleAndKeywords(args, kw, "s|ssfffff:FloatProperty", kwlist, &id, &name, &description, &min, &max, &soft_min, &soft_max, &def)) return NULL; - } else { - PyObject *ret = PyTuple_New(2); - PyTuple_SET_ITEM(ret, 0, PyCObject_FromVoidPtr((void *)BPy_IntProperty, NULL)); - PyTuple_SET_ITEM(ret, 1, kw); - Py_INCREF(kw); - return ret; + + if (PyTuple_Size(args) > 0) { + PyErr_SetString(PyExc_ValueError, "all args must be keywors"); // TODO - py3 can enforce this. + return NULL; + } + + srna= srna_from_self(self); + if(srna==NULL && PyErr_Occurred()) { + return NULL; /* self's type was compatible but error getting the srna */ + } + else if(srna) { + prop= RNA_def_float(srna, id, def, min, max, name, description, soft_min, soft_max); + RNA_def_property_duplicate_pointers(prop); + Py_RETURN_NONE; + } + else { /* operators defer running this function */ + return bpy_prop_deferred_return((void *)BPy_FloatProperty, kw); } } -PyObject *BPy_BoolProperty(PyObject *self, PyObject *args, PyObject *kw) +PyObject *BPy_StringProperty(PyObject *self, PyObject *args, PyObject *kw) { - static char *kwlist[] = {"attr", "name", "description", "default", NULL}; - char *id, *name="", *description=""; - int def=0; + static char *kwlist[] = {"attr", "name", "description", "maxlen", "default", NULL}; + char *id, *name="", *description="", *def=""; + int maxlen=0; PropertyRNA *prop; - - if (!PyArg_ParseTupleAndKeywords(args, kw, "s|ssi:BoolProperty", kwlist, &id, &name, &description, &def)) + StructRNA *srna; + + if (!PyArg_ParseTupleAndKeywords(args, kw, "s|ssis:StringProperty", kwlist, &id, &name, &description, &maxlen, &def)) return NULL; if (PyTuple_Size(args) > 0) { @@ -2694,81 +2751,236 @@ PyObject *BPy_BoolProperty(PyObject *self, PyObject *args, PyObject *kw) return NULL; } - if (self && PyCObject_Check(self)) { - StructRNA *srna = PyCObject_AsVoidPtr(self); - prop= RNA_def_boolean(srna, id, def, name, description); + srna= srna_from_self(self); + if(srna==NULL && PyErr_Occurred()) { + return NULL; /* self's type was compatible but error getting the srna */ + } + else if(srna) { + prop= RNA_def_string(srna, id, def, maxlen, name, description); RNA_def_property_duplicate_pointers(prop); Py_RETURN_NONE; - } else if(self && PyType_Check(self)) { - PyObject *pyob= PyObject_GetAttrString(self, "__rna__"); + } + else { /* operators defer running this function */ + return bpy_prop_deferred_return((void *)BPy_StringProperty, kw); + } +} - if(pyob && BPy_StructRNA_Check(pyob)) { - BPy_StructRNA *py_srna= (BPy_StructRNA*)pyob; +static EnumPropertyItem *enum_items_from_py(PyObject *value, const char *def, int *defvalue) +{ + EnumPropertyItem *items= NULL; + PyObject *item; + int seq_len, i, totitem= 0; + + if(!PySequence_Check(value)) { + PyErr_SetString(PyExc_TypeError, "expected a sequence of tuples for the enum items"); + return NULL; + } - if(py_srna->ptr.data && py_srna->ptr.type == &RNA_Struct) { - if(RNA_struct_is_ID(py_srna->ptr.data)) { - prop= RNA_def_boolean(py_srna->ptr.data, id, def, name, description); - RNA_def_property_duplicate_pointers(prop); - Py_RETURN_NONE; - } - } + seq_len = PySequence_Length(value); + for(i=0; i<seq_len; i++) { + EnumPropertyItem tmp= {0, "", 0, "", ""}; + + item= PySequence_GetItem(value, i); + if(item==NULL || PyTuple_Check(item)==0) { + PyErr_SetString(PyExc_TypeError, "expected a sequence of tuples for the enum items"); + if(items) MEM_freeN(items); + Py_XDECREF(item); + return NULL; } - PyErr_SetString(PyExc_ValueError, "only works on ID types"); - return NULL; - } else { - PyObject *ret = PyTuple_New(2); - PyTuple_SET_ITEM(ret, 0, PyCObject_FromVoidPtr((void *)BPy_BoolProperty, NULL)); - PyTuple_SET_ITEM(ret, 1, kw); - Py_INCREF(kw); - return ret; + if(!PyArg_ParseTuple(item, "sss", &tmp.identifier, &tmp.name, &tmp.description)) { + PyErr_SetString(PyExc_TypeError, "expected an identifier, name and description in the tuple"); + Py_DECREF(item); + return NULL; + } + + tmp.value= i; + RNA_enum_item_add(&items, &totitem, &tmp); + + if(def[0] && strcmp(def, tmp.identifier) == 0) + *defvalue= tmp.value; + + Py_DECREF(item); } + + if(!def[0]) + *defvalue= 0; + + RNA_enum_item_end(&items, &totitem); + + return items; } -PyObject *BPy_StringProperty(PyObject *self, PyObject *args, PyObject *kw) +PyObject *BPy_EnumProperty(PyObject *self, PyObject *args, PyObject *kw) { - static char *kwlist[] = {"attr", "name", "description", "maxlen", "default", NULL}; + static char *kwlist[] = {"attr", "items", "name", "description", "default", NULL}; char *id, *name="", *description="", *def=""; - int maxlen=0; + int defvalue=0; + PyObject *items= Py_None; + EnumPropertyItem *eitems; PropertyRNA *prop; + StructRNA *srna; + + if (!PyArg_ParseTupleAndKeywords(args, kw, "sO|sss:EnumProperty", kwlist, &id, &items, &name, &description, &def)) + return NULL; - if (!PyArg_ParseTupleAndKeywords(args, kw, "s|ssis:StringProperty", kwlist, &id, &name, &description, &maxlen, &def)) + if (PyTuple_Size(args) > 0) { + PyErr_SetString(PyExc_ValueError, "all args must be keywors"); // TODO - py3 can enforce this. + return NULL; + } + + srna= srna_from_self(self); + if(srna==NULL && PyErr_Occurred()) { + return NULL; /* self's type was compatible but error getting the srna */ + } + else if(srna) { + eitems= enum_items_from_py(items, def, &defvalue); + if(!eitems) + return NULL; + + prop= RNA_def_enum(srna, id, eitems, defvalue, name, description); + RNA_def_property_duplicate_pointers(prop); + MEM_freeN(eitems); + + Py_RETURN_NONE; + } + else { /* operators defer running this function */ + return bpy_prop_deferred_return((void *)BPy_EnumProperty, kw); + } +} + +static StructRNA *pointer_type_from_py(PyObject *value) +{ + StructRNA *srna; + + srna= srna_from_self(value); + if(!srna) { + PyErr_SetString(PyExc_SystemError, "expected an RNA type derived from IDPropertyGroup"); + return NULL; + } + + if(!RNA_struct_is_a(srna, &RNA_IDPropertyGroup)) { + PyErr_SetString(PyExc_SystemError, "expected an RNA type derived from IDPropertyGroup"); + return NULL; + } + + return srna; +} + +PyObject *BPy_PointerProperty(PyObject *self, PyObject *args, PyObject *kw) +{ + static char *kwlist[] = {"attr", "type", "name", "description", NULL}; + char *id, *name="", *description=""; + PropertyRNA *prop; + StructRNA *srna, *ptype; + PyObject *type= Py_None; + + if (!PyArg_ParseTupleAndKeywords(args, kw, "sO|ss:PointerProperty", kwlist, &id, &type, &name, &description)) return NULL; if (PyTuple_Size(args) > 0) { PyErr_SetString(PyExc_ValueError, "all args must be keywors"); // TODO - py3 can enforce this. return NULL; } + + srna= srna_from_self(self); + if(srna==NULL && PyErr_Occurred()) { + return NULL; /* self's type was compatible but error getting the srna */ + } + else if(srna) { + ptype= pointer_type_from_py(type); + if(!ptype) + return NULL; + + prop= RNA_def_pointer_runtime(srna, id, ptype, name, description); + RNA_def_property_duplicate_pointers(prop); + Py_RETURN_NONE; + } + else { /* operators defer running this function */ + return bpy_prop_deferred_return((void *)BPy_PointerProperty, kw); + } + return NULL; +} + +PyObject *BPy_CollectionProperty(PyObject *self, PyObject *args, PyObject *kw) +{ + static char *kwlist[] = {"attr", "type", "name", "description", NULL}; + char *id, *name="", *description=""; + PropertyRNA *prop; + StructRNA *srna, *ptype; + PyObject *type= Py_None; + + if (!PyArg_ParseTupleAndKeywords(args, kw, "sO|ss:CollectionProperty", kwlist, &id, &type, &name, &description)) + return NULL; - if (self && PyCObject_Check(self)) { - StructRNA *srna = PyCObject_AsVoidPtr(self); - prop= RNA_def_string(srna, id, def, maxlen, name, description); + if (PyTuple_Size(args) > 0) { + PyErr_SetString(PyExc_ValueError, "all args must be keywors"); // TODO - py3 can enforce this. + return NULL; + } + + srna= srna_from_self(self); + if(srna==NULL && PyErr_Occurred()) { + return NULL; /* self's type was compatible but error getting the srna */ + } + else if(srna) { + ptype= pointer_type_from_py(type); + if(!ptype) + return NULL; + + prop= RNA_def_collection_runtime(srna, id, ptype, name, description); RNA_def_property_duplicate_pointers(prop); Py_RETURN_NONE; - } else if(self && PyType_Check(self)) { - PyObject *pyob= PyObject_GetAttrString(self, "__rna__"); + } + else { /* operators defer running this function */ + return bpy_prop_deferred_return((void *)BPy_CollectionProperty, kw); + } + return NULL; +} - if(pyob && BPy_StructRNA_Check(pyob)) { - BPy_StructRNA *py_srna= (BPy_StructRNA*)pyob; +static int deferred_register_props(PyObject *py_class, StructRNA *srna) +{ + PyObject *props, *dummy_args, *item; + int i; - if(py_srna->ptr.data && py_srna->ptr.type == &RNA_Struct) { - if(RNA_struct_is_ID(py_srna->ptr.data)) { - prop= RNA_def_string(py_srna->ptr.data, id, def, maxlen, name, description); - RNA_def_property_duplicate_pointers(prop); - Py_RETURN_NONE; - } + props= PyObject_GetAttrString(py_class, "__props__"); + + if(!props) { + PyErr_Clear(); + return 1; + } + + dummy_args = PyTuple_New(0); + + for(i=0; i<PyList_Size(props); i++) { + PyObject *py_func_ptr, *py_kw, *py_srna_cobject, *py_ret; + item = PyList_GET_ITEM(props, i); + + if(PyArg_ParseTuple(item, "O!O!", &PyCObject_Type, &py_func_ptr, &PyDict_Type, &py_kw)) { + PyObject *(*pyfunc)(PyObject *, PyObject *, PyObject *); + pyfunc = PyCObject_AsVoidPtr(py_func_ptr); + py_srna_cobject = PyCObject_FromVoidPtr(srna, NULL); + + py_ret = pyfunc(py_srna_cobject, dummy_args, py_kw); + Py_DECREF(py_srna_cobject); + + if(py_ret) { + Py_DECREF(py_ret); + } + else { + Py_DECREF(dummy_args); + return 0; } } - - PyErr_SetString(PyExc_ValueError, "only works on ID types"); - return NULL; - } else { - PyObject *ret = PyTuple_New(2); - PyTuple_SET_ITEM(ret, 0, PyCObject_FromVoidPtr((void *)BPy_StringProperty, NULL)); - PyTuple_SET_ITEM(ret, 1, kw); - Py_INCREF(kw); - return ret; + else { + PyErr_Clear(); + PyErr_SetString(PyExc_AttributeError, "expected list of dicts for __props__."); + Py_DECREF(dummy_args); + return 0; + } } + + Py_DECREF(dummy_args); + return 1; } /*-------------------- Type Registration ------------------------*/ @@ -2918,9 +3130,10 @@ static int bpy_class_call(PointerRNA *ptr, FunctionRNA *func, ParameterList *par void *retdata= NULL; int err= 0, i, flag; - PyGILState_STATE gilstate = PyGILState_Ensure(); + PyGILState_STATE gilstate; - BPY_update_modules(); // XXX - the RNA pointers can change so update before running, would like a nicer solution for this. + bContext *C= BPy_GetContext(); // XXX - NEEDS FIXING, QUITE BAD. + bpy_context_set(C, &gilstate); py_class= RNA_struct_py_type_get(ptr->type); @@ -2996,57 +3209,103 @@ static int bpy_class_call(PointerRNA *ptr, FunctionRNA *func, ParameterList *par PyErr_Clear(); } - PyGILState_Release(gilstate); + bpy_context_clear(C, &gilstate); return err; } static void bpy_class_free(void *pyob_ptr) { + PyObject *self= (PyObject *)pyob_ptr; + PyGILState_STATE gilstate; + + gilstate = PyGILState_Ensure(); + + PyDict_Clear(((PyTypeObject*)self)->tp_dict); + if(G.f&G_DEBUG) { - if(((PyObject *)pyob_ptr)->ob_refcnt > 1) - PyObSpit("zombie class - ref should be 1", (PyObject *)pyob_ptr); + if(self->ob_refcnt > 1) { + PyObSpit("zombie class - ref should be 1", self); + } } + Py_DECREF((PyObject *)pyob_ptr); + + PyGILState_Release(gilstate); } -PyObject *pyrna_basetype_register(PyObject *self, PyObject *args) +void pyrna_alloc_types(void) { - bContext *C= NULL; - PyObject *py_class, *item; - ReportList reports; - StructRegisterFunc reg; - BPy_StructRNA *py_srna; - StructRNA *srna; + PyGILState_STATE gilstate; - if(!PyArg_ParseTuple(args, "O:register", &py_class)) - return NULL; + PointerRNA ptr; + PropertyRNA *prop; - if(!PyType_Check(py_class)) { - PyErr_SetString(PyExc_AttributeError, "expected a Type subclassed from a registerable rna type (no a Type object)."); - return NULL; + gilstate = PyGILState_Ensure(); + + /* avoid doing this lookup for every getattr */ + RNA_blender_rna_pointer_create(&ptr); + prop = RNA_struct_find_property(&ptr, "structs"); + + RNA_PROP_BEGIN(&ptr, itemptr, prop) { + Py_DECREF(pyrna_struct_Subtype(&itemptr)); } + RNA_PROP_END; + + PyGILState_Release(gilstate); +} - /* check we got an __rna__ attribute */ - item= PyObject_GetAttrString(py_class, "__rna__"); - if(!item || !BPy_StructRNA_Check(item)) { - Py_XDECREF(item); - PyErr_SetString(PyExc_AttributeError, "expected a Type subclassed from a registerable rna type (no __rna__ property)."); - return NULL; +void pyrna_free_types(void) +{ + PointerRNA ptr; + PropertyRNA *prop; + + /* avoid doing this lookup for every getattr */ + RNA_blender_rna_pointer_create(&ptr); + prop = RNA_struct_find_property(&ptr, "structs"); + + + RNA_PROP_BEGIN(&ptr, itemptr, prop) { + StructRNA *srna= srna_from_ptr(&itemptr); + void *py_ptr= RNA_struct_py_type_get(srna); + + if(py_ptr) { +#if 0 // XXX - should be able to do this but makes python crash on exit + bpy_class_free(py_ptr); +#endif + RNA_struct_py_type_set(srna, NULL); + } } + RNA_PROP_END; +} - /* check the __rna__ attribute has the right type */ - Py_DECREF(item); - py_srna= (BPy_StructRNA*)item; +/* Note! MemLeak XXX + * + * There is currently a bug where moving registering a python class does + * not properly manage refcounts from the python class, since the srna owns + * the python class this should not be so tricky but changing the references as + * youd expect when changing ownership crashes blender on exit so I had to comment out + * the decref. This is not so bad because the leak only happens when re-registering (hold F8) + * - Should still be fixed - Campbell + * */ - if(py_srna->ptr.type != &RNA_Struct) { - PyErr_SetString(PyExc_AttributeError, "expected a Type subclassed from a registerable rna type (not a Struct)."); +PyObject *pyrna_basetype_register(PyObject *self, PyObject *py_class) +{ + bContext *C= NULL; + ReportList reports; + StructRegisterFunc reg; + StructRNA *srna; + StructRNA *srna_new; + PyObject *item; + const char *identifier= ""; + + srna= pyrna_struct_as_srna(py_class); + if(srna==NULL) return NULL; - } /* check that we have a register callback for this type */ - reg= RNA_struct_register(py_srna->ptr.data); + reg= RNA_struct_register(srna); if(!reg) { PyErr_SetString(PyExc_AttributeError, "expected a Type subclassed from a registerable rna type (no register supported)."); @@ -3056,11 +3315,19 @@ PyObject *pyrna_basetype_register(PyObject *self, PyObject *args) /* get the context, so register callback can do necessary refreshes */ C= BPy_GetContext(); - /* call the register callback */ + /* call the register callback with reports & identifier */ BKE_reports_init(&reports, RPT_STORE); - srna= reg(C, &reports, py_class, bpy_class_validate, bpy_class_call, bpy_class_free); - if(!srna) { + item= PyObject_GetAttrString(py_class, "__name__"); + + if(item) { + identifier= _PyUnicode_AsString(item); + Py_DECREF(item); /* no need to keep a ref, the class owns it */ + } + + srna_new= reg(C, &reports, py_class, identifier, bpy_class_validate, bpy_class_call, bpy_class_free); + + if(!srna_new) { BPy_reports_to_error(&reports); BKE_reports_clear(&reports); return NULL; @@ -3068,44 +3335,32 @@ PyObject *pyrna_basetype_register(PyObject *self, PyObject *args) BKE_reports_clear(&reports); - pyrna_subtype_set_rna(py_class, srna); /* takes a ref to py_class */ + pyrna_subtype_set_rna(py_class, srna_new); /* takes a ref to py_class */ + + /* old srna still references us, keep the check incase registering somehow can free it */ + if(RNA_struct_py_type_get(srna)) { + RNA_struct_py_type_set(srna, NULL); + // Py_DECREF(py_class); // shuld be able to do this XXX since the old rna adds a new ref. + } + + if(!deferred_register_props(py_class, srna_new)) + return NULL; Py_RETURN_NONE; } -PyObject *pyrna_basetype_unregister(PyObject *self, PyObject *args) +PyObject *pyrna_basetype_unregister(PyObject *self, PyObject *py_class) { bContext *C= NULL; - PyObject *py_class, *item; - BPy_StructRNA *py_srna; StructUnregisterFunc unreg; + StructRNA *srna; - if(!PyArg_ParseTuple(args, "O:unregister", &py_class)) - return NULL; - - if(!PyType_Check(py_class)) { - PyErr_SetString(PyExc_AttributeError, "expected a Type subclassed from a registerable rna type (no a Type object)."); - return NULL; - } - - /* check we got an __rna__ attribute */ - item= PyDict_GetItemString(((PyTypeObject*)py_class)->tp_dict, "__rna__"); /* borrow ref */ - - if(!item || !BPy_StructRNA_Check(item)) { - PyErr_SetString(PyExc_AttributeError, "expected a Type subclassed from a registerable rna type (no __rna__ property)."); - return NULL; - } - - /* check the __rna__ attribute has the right type */ - py_srna= (BPy_StructRNA*)item; - - if(py_srna->ptr.type != &RNA_Struct) { - PyErr_SetString(PyExc_AttributeError, "expected a Type subclassed from a registerable rna type (not a Struct)."); + srna= pyrna_struct_as_srna(py_class); + if(srna==NULL) return NULL; - } /* check that we have a unregister callback for this type */ - unreg= RNA_struct_unregister(py_srna->ptr.data); + unreg= RNA_struct_unregister(srna); if(!unreg) { PyErr_SetString(PyExc_AttributeError, "expected a Type subclassed from a registerable rna type (no unregister supported)."); @@ -3114,13 +3369,9 @@ PyObject *pyrna_basetype_unregister(PyObject *self, PyObject *args) /* get the context, so register callback can do necessary refreshes */ C= BPy_GetContext(); - /* call unregister */ - unreg(C, py_srna->ptr.data); - - /* remove reference to old type */ - Py_DECREF(py_class); + unreg(C, srna); /* calls bpy_class_free, this decref's py_class */ Py_RETURN_NONE; } diff --git a/source/blender/python/intern/bpy_rna.h b/source/blender/python/intern/bpy_rna.h index 9138fd511b0..d65849ad8a4 100644 --- a/source/blender/python/intern/bpy_rna.h +++ b/source/blender/python/intern/bpy_rna.h @@ -61,6 +61,7 @@ typedef struct { #define BPy_BaseTypeRNA BPy_PropertyRNA PyObject *BPY_rna_module( void ); +void BPY_update_rna_module( void ); /*PyObject *BPY_rna_doc( void );*/ PyObject *BPY_rna_types( void ); PyObject *BPY_rna_props( void ); @@ -74,13 +75,25 @@ int pyrna_pydict_to_props(PointerRNA *ptr, PyObject *kw, int all_args, const cha PyObject * pyrna_prop_to_py(PointerRNA *ptr, PropertyRNA *prop); /* functions for setting up new props - experemental */ -PyObject *BPy_FloatProperty(PyObject *self, PyObject *args, PyObject *kw); -PyObject *BPy_IntProperty(PyObject *self, PyObject *args, PyObject *kw); PyObject *BPy_BoolProperty(PyObject *self, PyObject *args, PyObject *kw); +PyObject *BPy_IntProperty(PyObject *self, PyObject *args, PyObject *kw); +PyObject *BPy_FloatProperty(PyObject *self, PyObject *args, PyObject *kw); PyObject *BPy_StringProperty(PyObject *self, PyObject *args, PyObject *kw); +PyObject *BPy_EnumProperty(PyObject *self, PyObject *args, PyObject *kw); +PyObject *BPy_PointerProperty(PyObject *self, PyObject *args, PyObject *kw); +PyObject *BPy_CollectionProperty(PyObject *self, PyObject *args, PyObject *kw); /* function for registering types */ PyObject *pyrna_basetype_register(PyObject *self, PyObject *args); PyObject *pyrna_basetype_unregister(PyObject *self, PyObject *args); +/* called before stopping python */ +void pyrna_alloc_types(void); +void pyrna_free_types(void); + +/* primitive type conversion */ +int pyrna_py_to_boolean_array(PyObject *py, PointerRNA *ptr, PropertyRNA *prop, char *param_data, char *error_str, int error_str_size); +int pyrna_py_to_int_array(PyObject *py, PointerRNA *ptr, PropertyRNA *prop, char *param_data, char *error_str, int error_str_size); +int pyrna_py_to_float_array(PyObject *py, PointerRNA *ptr, PropertyRNA *prop, char *param_data, char *error_str, int error_str_size); + #endif diff --git a/source/blender/python/intern/bpy_ui.c b/source/blender/python/intern/bpy_ui.c index 59e566b3b37..f03a83bee9c 100644 --- a/source/blender/python/intern/bpy_ui.c +++ b/source/blender/python/intern/bpy_ui.c @@ -26,7 +26,6 @@ #include "bpy_util.h" #include "bpy_rna.h" /* for rna buttons */ #include "bpy_operator.h" /* for setting button operator properties */ -#include "bpy_compat.h" #include "WM_types.h" /* for WM_OP_INVOKE_DEFAULT & friends */ @@ -47,7 +46,6 @@ static struct PyMethodDef ui_methods[] = { {NULL, NULL, 0, NULL} }; -#if PY_VERSION_HEX >= 0x03000000 static struct PyModuleDef ui_module = { PyModuleDef_HEAD_INIT, "bpy.ui", @@ -56,16 +54,11 @@ static struct PyModuleDef ui_module = { ui_methods, NULL, NULL, NULL, NULL }; -#endif PyObject *BPY_ui_module( void ) { - PyObject *submodule, *mod; -#if PY_VERSION_HEX >= 0x03000000 + PyObject *submodule; submodule= PyModule_Create(&ui_module); -#else /* Py2.x */ - submodule= Py_InitModule3( "bpy.ui", ui_methods, "" ); -#endif /* INCREF since its its assumed that all these functions return the * module with a new ref like PyDict_New, since they are passed to diff --git a/source/blender/python/intern/bpy_util.c b/source/blender/python/intern/bpy_util.c index 3084cc1f871..be343843acc 100644 --- a/source/blender/python/intern/bpy_util.c +++ b/source/blender/python/intern/bpy_util.c @@ -124,7 +124,6 @@ int BPY_flag_from_seq(BPY_flag_def *flagdef, PyObject *seq, int *flag) /* Copied from pythons 3's Object.c */ -#ifndef Py_CmpToRich PyObject * Py_CmpToRich(int op, int cmp) { @@ -160,7 +159,6 @@ Py_CmpToRich(int op, int cmp) Py_INCREF(res); return res; } -#endif /* for debugging */ void PyObSpit(char *name, PyObject *var) { @@ -170,7 +168,7 @@ void PyObSpit(char *name, PyObject *var) { } else { PyObject_Print(var, stderr, 0); - fprintf(stderr, " ref:%d ", var->ob_refcnt); + fprintf(stderr, " ref:%d ", (int)var->ob_refcnt); fprintf(stderr, " ptr:%p", (void *)var); fprintf(stderr, " type:"); @@ -373,11 +371,7 @@ PyObject *BPY_exception_buffer(void) * string_io = StringIO.StringIO() */ -#if PY_VERSION_HEX < 0x03000000 - if(! (string_io_mod= PyImport_ImportModule("StringIO")) ) { -#else if(! (string_io_mod= PyImport_ImportModule("io")) ) { -#endif goto error_cleanup; } else if (! (string_io = PyObject_CallMethod(string_io_mod, "StringIO", NULL))) { goto error_cleanup; diff --git a/source/blender/python/intern/bpy_util.h b/source/blender/python/intern/bpy_util.h index 470dd4c2a45..0400d595520 100644 --- a/source/blender/python/intern/bpy_util.h +++ b/source/blender/python/intern/bpy_util.h @@ -27,7 +27,10 @@ #ifndef BPY_UTIL_H #define BPY_UTIL_H -#include "bpy_compat.h" +#if PY_VERSION_HEX < 0x03010000 +#error "Python versions below 3.1 are not supported anymore, you'll need to update your python." +#endif + #include "RNA_types.h" /* for EnumPropertyItem only */ struct EnumPropertyItem; @@ -47,6 +50,8 @@ void PyObSpit(char *name, PyObject *var); void PyLineSpit(void); void BPY_getFileAndNum(char **filename, int *lineno); +PyObject *Py_CmpToRich(int op, int cmp); + PyObject *BPY_exception_buffer(void); /* own python like utility function */ @@ -72,7 +77,7 @@ int BPY_class_validate(const char *class_type, PyObject *class, PyObject *base_c char *BPy_enum_as_string(struct EnumPropertyItem *item); -#define BLANK_PYTHON_TYPE {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} +#define BLANK_PYTHON_TYPE {PyVarObject_HEAD_INIT(NULL, 0) 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} /* error reporting */ int BPy_reports_to_error(struct ReportList *reports); @@ -82,4 +87,8 @@ int BPy_errors_to_report(struct ReportList *reports); struct bContext *BPy_GetContext(void); void BPy_SetContext(struct bContext *C); +extern void bpy_context_set(struct bContext *C, PyGILState_STATE *gilstate); +extern void bpy_context_clear(struct bContext *C, PyGILState_STATE *gilstate); + + #endif diff --git a/source/blender/render/CMakeLists.txt b/source/blender/render/CMakeLists.txt index 411bd61c3ff..ad96b9db166 100644 --- a/source/blender/render/CMakeLists.txt +++ b/source/blender/render/CMakeLists.txt @@ -28,8 +28,9 @@ FILE(GLOB SRC intern/source/*.c) SET(INC intern/include ../../../intern/guardedalloc ../blenlib ../makesdna - extern/include ../blenkernel ../radiosity/extern/include ../imbuf - ../quicktime ../include ../../kernel/gen_messaging ../blenloader + extern/include ../blenkernel ../imbuf + ../include ../../kernel/gen_messaging ../blenloader + ../../../intern/smoke/extern ../makesrna ) @@ -38,7 +39,7 @@ IF(WITH_OPENEXR) ENDIF(WITH_OPENEXR) IF(WITH_QUICKTIME) - SET(INC ${INC} ${QUICKTIME_INC}) + SET(INC ${INC} ../quicktime ${QUICKTIME_INC}) ADD_DEFINITIONS(-DWITH_QUICKTIME) ENDIF(WITH_QUICKTIME) diff --git a/source/blender/render/SConscript b/source/blender/render/SConscript index dbd9f65254b..db151775b96 100644 --- a/source/blender/render/SConscript +++ b/source/blender/render/SConscript @@ -6,7 +6,7 @@ sources = env.Glob('intern/source/*.c') incs = 'intern/include #/intern/guardedalloc ../blenlib ../makesdna ../makesrna' incs += ' extern/include ../blenkernel ../radiosity/extern/include ../imbuf' -incs += ' ../include ../blenloader' +incs += ' ../include ../blenloader ../../../intern/smoke/extern' defs = [] diff --git a/source/blender/render/extern/include/RE_pipeline.h b/source/blender/render/extern/include/RE_pipeline.h index 2df3a0a4f8b..bf02af6ac36 100644 --- a/source/blender/render/extern/include/RE_pipeline.h +++ b/source/blender/render/extern/include/RE_pipeline.h @@ -266,7 +266,8 @@ typedef struct RenderEngine { ListBase fullresult; } RenderEngine; -void RE_layer_rect_from_file(RenderLayer *layer, struct ReportList *reports, char *filename, int x, int y); +void RE_layer_load_from_file(RenderLayer *layer, struct ReportList *reports, char *filename); +void RE_result_load_from_file(RenderResult *result, struct ReportList *reports, char *filename); struct RenderResult *RE_engine_begin_result(RenderEngine *engine, int x, int y, int w, int h); void RE_engine_update_result(RenderEngine *engine, struct RenderResult *result); diff --git a/source/blender/render/extern/include/RE_shader_ext.h b/source/blender/render/extern/include/RE_shader_ext.h index 0ad48fe97a9..435e3ddc07f 100644 --- a/source/blender/render/extern/include/RE_shader_ext.h +++ b/source/blender/render/extern/include/RE_shader_ext.h @@ -55,7 +55,6 @@ typedef struct ShadeResult float refl[3]; float refr[3]; float nor[3]; - float rad[3]; float winspeed[4]; } ShadeResult; @@ -113,7 +112,7 @@ typedef struct ShadeInput /* internal face coordinates */ float u, v, dx_u, dx_v, dy_u, dy_v; - float co[3], view[3]; + float co[3], view[3], camera_co[3]; /* copy from material, keep synced so we can do memcopy */ /* current size: 23*4 */ @@ -132,7 +131,7 @@ typedef struct ShadeInput float layerfac; /* texture coordinates */ - float lo[3], gl[3], ref[3], orn[3], winco[3], sticky[3], vcol[4], rad[3]; + float lo[3], gl[3], ref[3], orn[3], winco[3], sticky[3], vcol[4]; float refcol[4], displace[3]; float strandco, tang[3], nmaptang[3], stress, winspeed[4]; float duplilo[3], dupliuv[3]; @@ -161,6 +160,7 @@ typedef struct ShadeInput int samplenr; /* sample counter, to detect if we should do shadow again */ int depth; /* 1 or larger on raytrace shading */ + int volume_depth; /* number of intersections through volumes */ /* stored copy of original face normal (facenor) * before flipping. Used in Front/back output on geometry node */ diff --git a/source/blender/render/intern/include/pointdensity.h b/source/blender/render/intern/include/pointdensity.h new file mode 100644 index 00000000000..93cdef3b14e --- /dev/null +++ b/source/blender/render/intern/include/pointdensity.h @@ -0,0 +1,44 @@ +/* + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): Matt Ebb + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#ifndef POINTDENSITY_H +#define POINTDENSITY_H + +/** + * Make point density kd-trees for all point density textures in the scene + */ + +struct Render; +struct TexResult; + +void make_pointdensities(struct Render *re); +void free_pointdensities(struct Render *re); +int pointdensitytex(struct Tex *tex, float *texvec, struct TexResult *texres); + +#endif /* POINTDENSITY_H */ + diff --git a/source/blender/render/intern/include/render_types.h b/source/blender/render/intern/include/render_types.h index ab3758781ce..c4910f7733d 100644 --- a/source/blender/render/intern/include/render_types.h +++ b/source/blender/render/intern/include/render_types.h @@ -201,6 +201,9 @@ struct Render ListBase customdata_names; struct Object *excludeob; + ListBase render_volumes_inside; + ListBase volumes; + ListBase volume_precache_parts; /* arena for allocating data for use during render, for * example dynamic TFaces to go in the VlakRen structure. @@ -292,7 +295,9 @@ typedef struct ObjectInstanceRen { float dupliorco[3], dupliuv[2]; float (*duplitexmat)[4]; - + + struct VolumePrecache *volume_precache; + float *vectors; int totvector; } ObjectInstanceRen; @@ -402,6 +407,45 @@ typedef struct StrandRen { float orco[3]; } StrandRen; +/* ------------------------------------------------------------------------- */ + +typedef struct VolumeOb +{ + struct VolumeOb *next, *prev; + struct Material *ma; + struct ObjectRen *obr; +} VolumeOb; + +typedef struct MatInside { + struct MatInside *next, *prev; + struct Material *ma; +} MatInside; + +typedef struct VolPrecachePart +{ + struct VolPrecachePart *next, *prev; + struct RayTree *tree; + struct ShadeInput *shi; + struct ObjectInstanceRen *obi; + int num; + int minx, maxx; + int miny, maxy; + int minz, maxz; + int res[3]; + float bbmin[3]; + float voxel[3]; + int working, done; +} VolPrecachePart; + +typedef struct VolumePrecache +{ + int res[3]; + float *data_r; + float *data_g; + float *data_b; +} VolumePrecache; + +/* ------------------------------------------------------------------------- */ struct LampRen; struct MTex; diff --git a/source/blender/render/intern/include/shading.h b/source/blender/render/intern/include/shading.h index d195f32d5ef..95bccd2be1e 100644 --- a/source/blender/render/intern/include/shading.h +++ b/source/blender/render/intern/include/shading.h @@ -33,6 +33,7 @@ struct VlakRen; struct StrandSegment; struct StrandPoint; struct ObjectInstanceRen obi; +struct Isect; /* shadeinput.c */ @@ -52,6 +53,7 @@ typedef struct ShadeSample { /* also the node shader callback */ void shade_material_loop(struct ShadeInput *shi, struct ShadeResult *shr); +void shade_volume_loop(struct ShadeInput *shi, struct ShadeResult *shr); void shade_input_set_triangle_i(struct ShadeInput *shi, struct ObjectInstanceRen *obi, struct VlakRen *vlr, short i1, short i2, short i3); void shade_input_set_triangle(struct ShadeInput *shi, volatile int obi, volatile int facenr, int normal_flip); @@ -87,7 +89,11 @@ void shade_color(struct ShadeInput *shi, ShadeResult *shr); void ambient_occlusion_to_diffuse(struct ShadeInput *shi, float *diff); void ambient_occlusion(struct ShadeInput *shi); +ListBase *get_lights(struct ShadeInput *shi); float lamp_get_visibility(struct LampRen *lar, float *co, float *lv, float *dist); void lamp_get_shadow(struct LampRen *lar, ShadeInput *shi, float inp, float *shadfac, int do_real); float fresnel_fac(float *view, float *vn, float fresnel, float fac); + +/* rayshade.c */ +extern void shade_ray(struct Isect *is, struct ShadeInput *shi, struct ShadeResult *shr); diff --git a/source/blender/render/intern/include/texture.h b/source/blender/render/intern/include/texture.h index c254b768292..78d6a912af1 100644 --- a/source/blender/render/intern/include/texture.h +++ b/source/blender/render/intern/include/texture.h @@ -56,6 +56,7 @@ void do_halo_tex(struct HaloRen *har, float xn, float yn, float *colf); void do_sky_tex(float *rco, float *lo, float *dxyview, float *hor, float *zen, float *blend, int skyflag, short thread); void do_material_tex(struct ShadeInput *shi); void do_lamp_tex(LampRen *la, float *lavec, struct ShadeInput *shi, float *colf, int effect); +void do_volume_tex(struct ShadeInput *shi, float *xyz, int mapto_flag, float *col, float *val); void init_render_textures(Render *re); void end_render_textures(void); diff --git a/source/blender/render/intern/include/volume_precache.h b/source/blender/render/intern/include/volume_precache.h new file mode 100644 index 00000000000..dbd02759a63 --- /dev/null +++ b/source/blender/render/intern/include/volume_precache.h @@ -0,0 +1,34 @@ +/** + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): Matt Ebb. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +void volume_precache(Render *re); +void free_volume_precache(Render *re); +int point_inside_volume_objectinstance(ObjectInstanceRen *obi, float *co); +int using_lightcache(Material *ma); + +#define VOL_MS_TIMESTEP 0.1f diff --git a/source/blender/render/intern/include/volumetric.h b/source/blender/render/intern/include/volumetric.h new file mode 100644 index 00000000000..026b4840ea3 --- /dev/null +++ b/source/blender/render/intern/include/volumetric.h @@ -0,0 +1,47 @@ +/** + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): Matt Ebb. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +float vol_get_stepsize(struct ShadeInput *shi, int context); +float vol_get_density(struct ShadeInput *shi, float *co); +void vol_get_scattering(ShadeInput *shi, float *scatter_col, float *co, float stepsize, float density); + +void shade_volume_outside(ShadeInput *shi, ShadeResult *shr); +void shade_volume_inside(ShadeInput *shi, ShadeResult *shr); +void shade_volume_shadow(struct ShadeInput *shi, struct ShadeResult *shr, struct Isect *last_is); + +#define STEPSIZE_VIEW 0 +#define STEPSIZE_SHADE 1 + +#define VOL_IS_BACKFACE 1 +#define VOL_IS_SAMEMATERIAL 2 + +#define VOL_BOUNDS_DEPTH 0 +#define VOL_BOUNDS_SS 1 + +#define VOL_SHADE_OUTSIDE 0 +#define VOL_SHADE_INSIDE 1 diff --git a/source/blender/render/intern/include/voxeldata.h b/source/blender/render/intern/include/voxeldata.h new file mode 100644 index 00000000000..b291bdc096d --- /dev/null +++ b/source/blender/render/intern/include/voxeldata.h @@ -0,0 +1,45 @@ +/** + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): Raul Fernandez Hernandez (Farsthary), Matt Ebb. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#ifndef VOXELDATA_H +#define VOXELDATA_H + +struct Render; +struct TexResult; + +typedef struct VoxelDataHeader +{ + int resolX, resolY, resolZ; + int frames; +} VoxelDataHeader; + +void make_voxeldata(struct Render *re); +void free_voxeldata(struct Render *re); +int voxeldatatex(struct Tex *tex, float *texvec, struct TexResult *texres); + +#endif /* VOXELDATA_H */ diff --git a/source/blender/render/intern/source/Makefile b/source/blender/render/intern/source/Makefile index 3c8d0f637a3..c313549f9b9 100644 --- a/source/blender/render/intern/source/Makefile +++ b/source/blender/render/intern/source/Makefile @@ -39,7 +39,6 @@ CFLAGS += $(LEVEL_1_C_WARNINGS) # The external modules follow after. There should be a nicer way to say this. CPPFLAGS += -I../include CPPFLAGS += -I../../extern/include -CPPFLAGS += -I../../../radiosity/extern/include CPPFLAGS += -I../../../blenlib CPPFLAGS += -I../../../imbuf CPPFLAGS += -I../../../makesdna @@ -51,6 +50,7 @@ CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include # not very neat: the rest of blender.. CPPFLAGS += -I../../../editors/include CPPFLAGS += $(NAN_SDLCFLAGS) +CPPFLAGS += -I../../../../../intern/smoke/extern ifeq ($(WITH_QUICKTIME), true) CPPFLAGS += -DWITH_QUICKTIME diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c index 296405c963b..f9a993609da 100644 --- a/source/blender/render/intern/source/convertblender.c +++ b/source/blender/render/intern/source/convertblender.c @@ -100,6 +100,8 @@ #include "envmap.h" #include "occlusion.h" +#include "pointdensity.h" +#include "voxeldata.h" #include "render_types.h" #include "rendercore.h" #include "renderdatabase.h" @@ -108,6 +110,7 @@ #include "shading.h" #include "strand.h" #include "texture.h" +#include "volume_precache.h" #include "sss.h" #include "strand.h" #include "zbuf.h" @@ -895,7 +898,7 @@ static void flag_render_node_material(Render *re, bNodeTree *ntree) if(GS(node->id->name)==ID_MA) { Material *ma= (Material *)node->id; - if(ma->mode & MA_ZTRA) + if((ma->mode & MA_TRANSP) && (ma->mode & MA_ZTRANSP)) re->flag |= R_ZTRA; ma->flag |= MA_IS_USED; @@ -917,7 +920,8 @@ static Material *give_render_material(Render *re, Object *ob, int nr) if(re->r.mode & R_SPEED) ma->texco |= NEED_UV; - if(ma->mode & MA_ZTRA) + if(ma->material_type == MA_TYPE_VOLUME) ma->mode |= MA_TRANSP; + if((ma->mode & MA_TRANSP) && (ma->mode & MA_ZTRANSP)) re->flag |= R_ZTRA; /* for light groups */ @@ -2976,6 +2980,52 @@ static void use_mesh_edge_lookup(ObjectRen *obr, DerivedMesh *dm, MEdge *medge, } } +static void free_camera_inside_volumes(Render *re) +{ + BLI_freelistN(&re->render_volumes_inside); +} + +static void init_camera_inside_volumes(Render *re) +{ + ObjectInstanceRen *obi; + VolumeOb *vo; + float co[3] = {0.f, 0.f, 0.f}; + + for(vo= re->volumes.first; vo; vo= vo->next) { + for(obi= re->instancetable.first; obi; obi= obi->next) { + if (obi->obr == vo->obr) { + if (point_inside_volume_objectinstance(obi, co)) { + MatInside *mi; + + mi = MEM_mallocN(sizeof(MatInside), "camera inside material"); + mi->ma = vo->ma; + + BLI_addtail(&(re->render_volumes_inside), mi); + } + } + } + } + + /* debug { + MatInside *m; + for (m=re->render_volumes_inside.first; m; m=m->next) { + printf("matinside: ma: %s \n", m->ma->id.name+2); + } + }*/ +} + +static void add_volume(Render *re, ObjectRen *obr, Material *ma) +{ + struct VolumeOb *vo; + + vo = MEM_mallocN(sizeof(VolumeOb), "volume object"); + + vo->ma = ma; + vo->obr = obr; + + BLI_addtail(&re->volumes, vo); +} + static void init_render_mesh(Render *re, ObjectRen *obr, int timeoffset) { Object *ob= obr->ob; @@ -3025,11 +3075,9 @@ static void init_render_mesh(Render *re, ObjectRen *obr, int timeoffset) } need_nmap_tangent= 1; } - - /* radio faces need autosmooth, to separate shared vertices in corners */ - if(re->r.mode & R_RADIO) - if(ma->mode & MA_RADIO) - do_autosmooth= 1; + + if (ma->material_type == MA_TYPE_VOLUME) + add_volume(re, obr, ma); } } @@ -3799,7 +3847,7 @@ static void set_phong_threshold(ObjectRen *obr) static void set_fullsample_flag(Render *re, ObjectRen *obr) { VlakRen *vlr; - int a, trace; + int a, trace, mode; if(re->osa==0) return; @@ -3808,12 +3856,14 @@ static void set_fullsample_flag(Render *re, ObjectRen *obr) for(a=obr->totvlak-1; a>=0; a--) { vlr= RE_findOrAddVlak(obr, a); + mode= vlr->mat->mode; - if(vlr->mat->mode & MA_FULL_OSA) + if(mode & MA_FULL_OSA) vlr->flag |= R_FULL_OSA; else if(trace) { - if(vlr->mat->mode & MA_SHLESS); - else if(vlr->mat->mode & (MA_RAYTRANSP|MA_RAYMIRROR)) + if(mode & MA_SHLESS); + else if(vlr->mat->material_type == MA_TYPE_VOLUME); + else if((mode & MA_RAYMIRROR) || ((mode & MA_TRANSP) && (mode & MA_RAYTRANSP))) /* for blurry reflect/refract, better to take more samples * inside the raytrace than as OSA samples */ if ((vlr->mat->gloss_mir == 1.0) && (vlr->mat->gloss_tra == 1.0)) @@ -4338,6 +4388,8 @@ void RE_Database_Free(Render *re) curvemapping_free(lar->curfalloff); } + free_volume_precache(re); + BLI_freelistN(&re->lampren); BLI_freelistN(&re->lights); @@ -4364,6 +4416,11 @@ void RE_Database_Free(Render *re) end_render_materials(); end_render_textures(); + free_pointdensities(re); + free_voxeldata(re); + + free_camera_inside_volumes(re); + if(re->wrld.aosphere) { MEM_freeN(re->wrld.aosphere); re->wrld.aosphere= NULL; @@ -4756,6 +4813,8 @@ void RE_Database_FromScene(Render *re, Scene *scene, int use_camera_view) /* MAKE RENDER DATA */ database_init_objects(re, lay, 0, 0, 0, 0); + + init_camera_inside_volumes(re); if(!re->test_break(re->tbh)) { int tothalo; @@ -4804,6 +4863,13 @@ void RE_Database_FromScene(Render *re, Scene *scene, int use_camera_view) /* ENVIRONMENT MAPS */ if(!re->test_break(re->tbh)) make_envmaps(re); + + /* point density texture */ + if(!re->test_break(re->tbh)) + make_pointdensities(re); + /* voxel data texture */ + if(!re->test_break(re->tbh)) + make_voxeldata(re); } if(!re->test_break(re->tbh)) @@ -4820,6 +4886,11 @@ void RE_Database_FromScene(Render *re, Scene *scene, int use_camera_view) if((re->r.mode & R_SSS) && !re->test_break(re->tbh)) if(re->r.renderer==R_INTERN) make_sss_tree(re); + + if(!re->test_break(re->tbh)) + if(re->r.mode & R_RAYTRACE) + volume_precache(re); + } if(re->test_break(re->tbh)) diff --git a/source/blender/render/intern/source/occlusion.c b/source/blender/render/intern/source/occlusion.c index feef3dd424a..a15377a8c6d 100644 --- a/source/blender/render/intern/source/occlusion.c +++ b/source/blender/render/intern/source/occlusion.c @@ -630,7 +630,7 @@ static OcclusionTree *occ_tree_build(Render *re) if((a & 255)==0) vlr= obr->vlaknodes[a>>8].vlak; else vlr++; - if(vlr->mat->mode & MA_TRACEBLE) + if((vlr->mat->mode & MA_TRACEBLE) && (vlr->mat->material_type == MA_TYPE_SURFACE)) totface++; } } @@ -663,7 +663,7 @@ static OcclusionTree *occ_tree_build(Render *re) if((a & 255)==0) vlr= obr->vlaknodes[a>>8].vlak; else vlr++; - if(vlr->mat->mode & MA_TRACEBLE) { + if((vlr->mat->mode & MA_TRACEBLE) && (vlr->mat->material_type == MA_TYPE_SURFACE)) { tree->face[b].obi= c; tree->face[b].facenr= a; tree->occlusion[b]= 1.0f; diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index 14df6b8ec9f..a6b089c6029 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -868,33 +868,26 @@ static void renderresult_add_names(RenderResult *rr) strcpy(rpass->name, get_pass_name(rpass->passtype, -1)); } - -/* only for temp buffer files, makes exact copy of render result */ -static void read_render_result(Render *re, int sample) +/* called for reading temp files, and for external engines */ +static int read_render_result_from_file(char *filename, RenderResult *rr) { RenderLayer *rl; RenderPass *rpass; void *exrhandle= IMB_exr_get_handle(); int rectx, recty; - char str[FILE_MAX]; - - RE_FreeRenderResult(re->result); - re->result= new_render_result(re, &re->disprect, 0, RR_USEMEM); - render_unique_exr_name(re, str, sample); - if(IMB_exr_begin_read(exrhandle, str, &rectx, &recty)==0) { + if(IMB_exr_begin_read(exrhandle, filename, &rectx, &recty)==0) { IMB_exr_close(exrhandle); - printf("cannot read: %s\n", str); - return; + return 0; } - printf("read exr tmp file: %s\n", str); - - if(re->result == NULL || rectx!=re->result->rectx || recty!=re->result->recty) { + if(rr == NULL || rectx!=rr->rectx || recty!=rr->recty) { printf("error in reading render result\n"); + IMB_exr_close(exrhandle); + return 0; } else { - for(rl= re->result->layers.first; rl; rl= rl->next) { + for(rl= rr->layers.first; rl; rl= rl->next) { /* combined */ if(rl->rectf) { @@ -914,10 +907,27 @@ static void read_render_result(Render *re, int sample) } IMB_exr_read_channels(exrhandle); - renderresult_add_names(re->result); + renderresult_add_names(rr); } IMB_exr_close(exrhandle); + + return 1; +} + +/* only for temp buffer files, makes exact copy of render result */ +static void read_render_result(Render *re, int sample) +{ + char str[FILE_MAX]; + + RE_FreeRenderResult(re->result); + re->result= new_render_result(re, &re->disprect, 0, RR_USEMEM); + + render_unique_exr_name(re, str, sample); + printf("read exr tmp file: %s\n", str); + + if(!read_render_result_from_file(str, re->result)) + printf("cannot read: %s\n", str); } /* *************************************************** */ @@ -2560,8 +2570,15 @@ static int render_initialize_from_scene(Render *re, Scene *scene, int anim, int /* check all scenes involved */ tag_scenes_for_render(re); - /* make sure dynamics are up to date */ - update_physics_cache(re, scene, anim_init); + /* + * Disabled completely for now, + * can be later set as render profile option + * and default for background render. + */ + if(0) { + /* make sure dynamics are up to date */ + update_physics_cache(re, scene, anim_init); + } if(scene->r.scemode & R_SINGLE_LAYER) push_render_result(re); @@ -2692,7 +2709,7 @@ void RE_BlenderAnim(Render *re, Scene *scene, int sfra, int efra, int tfra) re->result_ok= 0; if(BKE_imtype_is_movie(scene->r.imtype)) - mh->start_movie(&re->r, re->rectx, re->recty); + mh->start_movie(scene, &re->r, re->rectx, re->recty); if (mh->get_next_frame) { while (!(G.afbreek == 1)) { @@ -2937,7 +2954,7 @@ void RE_engine_update_stats(RenderEngine *engine, char *stats, char *info) /* loads in image into a result, size must match * x/y offsets are only used on a partial copy when dimensions dont match */ -void RE_layer_rect_from_file(RenderLayer *layer, ReportList *reports, char *filename, int x, int y) +void RE_layer_load_from_file(RenderLayer *layer, ReportList *reports, char *filename) { ImBuf *ibuf = IMB_loadiffname(filename, IB_rect); @@ -2948,7 +2965,7 @@ void RE_layer_rect_from_file(RenderLayer *layer, ReportList *reports, char *file memcpy(layer->rectf, ibuf->rect_float, sizeof(float)*4*layer->rectx*layer->recty); } else { - if ((ibuf->x - x >= layer->rectx) && (ibuf->y - y >= layer->recty)) { + if ((ibuf->x >= layer->rectx) && (ibuf->y >= layer->recty)) { ImBuf *ibuf_clip; if(ibuf->rect_float==NULL) @@ -2956,7 +2973,7 @@ void RE_layer_rect_from_file(RenderLayer *layer, ReportList *reports, char *file ibuf_clip = IMB_allocImBuf(layer->rectx, layer->recty, 32, IB_rectfloat, 0); if(ibuf_clip) { - IMB_rectcpy(ibuf_clip, ibuf, 0,0, x,y, layer->rectx, layer->recty); + IMB_rectcpy(ibuf_clip, ibuf, 0,0, 0,0, layer->rectx, layer->recty); memcpy(layer->rectf, ibuf_clip->rect_float, sizeof(float)*4*layer->rectx*layer->recty); IMB_freeImBuf(ibuf_clip); @@ -2976,6 +2993,15 @@ void RE_layer_rect_from_file(RenderLayer *layer, ReportList *reports, char *file BKE_reportf(reports, RPT_ERROR, "RE_result_rect_from_file: failed to load '%s'\n", filename); } } + +void RE_result_load_from_file(RenderResult *result, ReportList *reports, char *filename) +{ + if(!read_render_result_from_file(filename, result)) { + BKE_reportf(reports, RPT_ERROR, "RE_result_rect_from_file: failed to load '%s'\n", filename); + return; + } +} + static void external_render_3d(Render *re, RenderEngineType *type) { RenderEngine engine; diff --git a/source/blender/render/intern/source/pointdensity.c b/source/blender/render/intern/source/pointdensity.c new file mode 100644 index 00000000000..5f8cf5504fa --- /dev/null +++ b/source/blender/render/intern/source/pointdensity.c @@ -0,0 +1,484 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * Contributors: Matt Ebb + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include <math.h> +#include <stdlib.h> +#include <stdio.h> + +#include "MEM_guardedalloc.h" + +#include "BLI_arithb.h" +#include "BLI_blenlib.h" +#include "BLI_kdopbvh.h" + +#include "BKE_DerivedMesh.h" +#include "BKE_global.h" +#include "BKE_lattice.h" +#include "BKE_main.h" +#include "BKE_object.h" +#include "BKE_particle.h" +#include "BKE_texture.h" + +#include "DNA_texture_types.h" +#include "DNA_particle_types.h" + +#include "render_types.h" +#include "renderdatabase.h" +#include "texture.h" + +/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ +/* defined in pipeline.c, is hardcopy of active dynamic allocated Render */ +/* only to be used here in this file, it's for speed */ +extern struct Render R; +/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + + +static int point_data_used(PointDensity *pd) +{ + int pd_bitflag = 0; + + if ((pd->noise_influence == TEX_PD_NOISE_VEL) || (pd->color_source == TEX_PD_COLOR_PARTVEL) || (pd->color_source == TEX_PD_COLOR_PARTSPEED)) + pd_bitflag |= POINT_DATA_VEL; + if ((pd->noise_influence == TEX_PD_NOISE_AGE) || (pd->color_source == TEX_PD_COLOR_PARTAGE)) + pd_bitflag |= POINT_DATA_LIFE; + + return pd_bitflag; +} + + +/* additional data stored alongside the point density BVH, + * accessible by point index number to retrieve other information + * such as particle velocity or lifetime */ +static void alloc_point_data(PointDensity *pd, int total_particles, int point_data_used) +{ + int data_size = 0; + + if (point_data_used & POINT_DATA_VEL) { + /* store 3 channels of velocity data */ + data_size += 3; + } + if (point_data_used & POINT_DATA_LIFE) { + /* store 1 channel of lifetime data */ + data_size += 1; + } + + if (data_size) + pd->point_data = MEM_mallocN(sizeof(float)*data_size*total_particles, "particle point data"); +} + +static void pointdensity_cache_psys(Render *re, PointDensity *pd, Object *ob, ParticleSystem *psys) +{ + DerivedMesh* dm; + ParticleKey state; + ParticleData *pa=NULL; + float cfra = bsystem_time(re->scene, ob, (float)re->scene->r.cfra, 0.0); + int i, childexists; + int total_particles, offset=0; + int data_used = point_data_used(pd); + float partco[3]; + float obview[4][4]; + + + /* init everything */ + if (!psys || !ob || !pd) return; + + Mat4MulMat4(obview, re->viewinv, ob->obmat); + + /* Just to create a valid rendering context for particles */ + psys_render_set(ob, psys, re->viewmat, re->winmat, re->winx, re->winy, 0); + + dm = mesh_create_derived_render(re->scene, ob,CD_MASK_BAREMESH|CD_MASK_MTFACE|CD_MASK_MCOL); + + if ( !psys_check_enabled(ob, psys)) { + psys_render_restore(ob, psys); + return; + } + + /* in case ob->imat isn't up-to-date */ + Mat4Invert(ob->imat, ob->obmat); + + total_particles = psys->totpart+psys->totchild; + psys->lattice=psys_get_lattice(re->scene,ob,psys); + + pd->point_tree = BLI_bvhtree_new(total_particles, 0.0, 4, 6); + alloc_point_data(pd, total_particles, data_used); + pd->totpoints = total_particles; + if (data_used & POINT_DATA_VEL) offset = pd->totpoints*3; + + if (psys->totchild > 0 && !(psys->part->draw & PART_DRAW_PARENT)) + childexists = 1; + + for (i=0, pa=psys->particles; i < total_particles; i++, pa++) { + + state.time = cfra; + if(psys_get_particle_state(re->scene, ob, psys, i, &state, 0)) { + + VECCOPY(partco, state.co); + + if (pd->psys_cache_space == TEX_PD_OBJECTSPACE) + Mat4MulVecfl(ob->imat, partco); + else if (pd->psys_cache_space == TEX_PD_OBJECTLOC) { + float obloc[3]; + VECCOPY(obloc, ob->loc); + VecSubf(partco, partco, obloc); + } else { + /* TEX_PD_WORLDSPACE */ + } + + BLI_bvhtree_insert(pd->point_tree, i, partco, 1); + + if (data_used & POINT_DATA_VEL) { + pd->point_data[i*3 + 0] = state.vel[0]; + pd->point_data[i*3 + 1] = state.vel[1]; + pd->point_data[i*3 + 2] = state.vel[2]; + } + if (data_used & POINT_DATA_LIFE) { + float pa_time; + + if (i < psys->totpart) { + pa_time = (cfra - pa->time)/pa->lifetime; + } else { + ChildParticle *cpa= (psys->child + i) - psys->totpart; + float pa_birthtime, pa_dietime; + + pa_time = psys_get_child_time(psys, cpa, cfra, &pa_birthtime, &pa_dietime); + } + + pd->point_data[offset + i] = pa_time; + } + } + } + + BLI_bvhtree_balance(pd->point_tree); + dm->release(dm); + + if(psys->lattice){ + end_latt_deform(psys->lattice); + psys->lattice=0; + } + + psys_render_restore(ob, psys); +} + + +static void pointdensity_cache_object(Render *re, PointDensity *pd, ObjectRen *obr) +{ + int i; + + if (!obr || !pd) return; + if(!obr->vertnodes) return; + + /* in case ob->imat isn't up-to-date */ + Mat4Invert(obr->ob->imat, obr->ob->obmat); + + pd->point_tree = BLI_bvhtree_new(obr->totvert, 0.0, 4, 6); + pd->totpoints = obr->totvert; + + for(i=0; i<obr->totvert; i++) { + float ver_co[3]; + VertRen *ver= RE_findOrAddVert(obr, i); + + VECCOPY(ver_co, ver->co); + Mat4MulVecfl(re->viewinv, ver_co); + + if (pd->ob_cache_space == TEX_PD_OBJECTSPACE) { + Mat4MulVecfl(obr->ob->imat, ver_co); + } else if (pd->psys_cache_space == TEX_PD_OBJECTLOC) { + VecSubf(ver_co, ver_co, obr->ob->loc); + } else { + /* TEX_PD_WORLDSPACE */ + } + + BLI_bvhtree_insert(pd->point_tree, i, ver_co, 1); + } + + BLI_bvhtree_balance(pd->point_tree); + +} +static void cache_pointdensity(Render *re, Tex *tex) +{ + PointDensity *pd = tex->pd; + + if (pd->point_tree) { + BLI_bvhtree_free(pd->point_tree); + pd->point_tree = NULL; + } + + if (pd->source == TEX_PD_PSYS) { + Object *ob = pd->object; + + if (!ob) return; + if (!pd->psys) return; + + pointdensity_cache_psys(re, pd, ob, pd->psys); + } + else if (pd->source == TEX_PD_OBJECT) { + Object *ob = pd->object; + ObjectRen *obr; + int found=0; + + /* find the obren that corresponds to the object */ + for (obr=re->objecttable.first; obr; obr=obr->next) { + if (obr->ob == ob) { + found=1; + break; + } + } + if (!found) return; + + pointdensity_cache_object(re, pd, obr); + } +} + +static void free_pointdensity(Render *re, Tex *tex) +{ + PointDensity *pd = tex->pd; + + if (!pd) return; + + if (pd->point_tree) { + BLI_bvhtree_free(pd->point_tree); + pd->point_tree = NULL; + } + + if (pd->point_data) { + MEM_freeN(pd->point_data); + pd->point_data = NULL; + } + pd->totpoints = 0; +} + + + +void make_pointdensities(Render *re) +{ + Tex *tex; + + if(re->scene->r.scemode & R_PREVIEWBUTS) + return; + + re->i.infostr= "Caching Point Densities"; + re->stats_draw(re->sdh, &re->i); + + for (tex= G.main->tex.first; tex; tex= tex->id.next) { + if(tex->id.us && tex->type==TEX_POINTDENSITY) { + cache_pointdensity(re, tex); + } + } + + re->i.infostr= NULL; + re->stats_draw(re->sdh, &re->i); +} + +void free_pointdensities(Render *re) +{ + Tex *tex; + + if(re->scene->r.scemode & R_PREVIEWBUTS) + return; + + for (tex= G.main->tex.first; tex; tex= tex->id.next) { + if(tex->id.us && tex->type==TEX_POINTDENSITY) { + free_pointdensity(re, tex); + } + } +} + +typedef struct PointDensityRangeData +{ + float *density; + float squared_radius; + float *point_data; + float *vec; + float softness; + short falloff_type; + short noise_influence; + float *age; + int point_data_used; + int offset; +} PointDensityRangeData; + +void accum_density(void *userdata, int index, float squared_dist) +{ + PointDensityRangeData *pdr = (PointDensityRangeData *)userdata; + const float dist = (pdr->squared_radius - squared_dist) / pdr->squared_radius * 0.5f; + float density = 0.0f; + + if (pdr->falloff_type == TEX_PD_FALLOFF_STD) + density = dist; + else if (pdr->falloff_type == TEX_PD_FALLOFF_SMOOTH) + density = 3.0f*dist*dist - 2.0f*dist*dist*dist; + else if (pdr->falloff_type == TEX_PD_FALLOFF_SOFT) + density = pow(dist, pdr->softness); + else if (pdr->falloff_type == TEX_PD_FALLOFF_CONSTANT) + density = pdr->squared_radius; + else if (pdr->falloff_type == TEX_PD_FALLOFF_ROOT) + density = sqrt(dist); + + if (pdr->point_data_used & POINT_DATA_VEL) { + pdr->vec[0] += pdr->point_data[index*3 + 0]; //* density; + pdr->vec[1] += pdr->point_data[index*3 + 1]; //* density; + pdr->vec[2] += pdr->point_data[index*3 + 2]; //* density; + } + if (pdr->point_data_used & POINT_DATA_LIFE) { + *pdr->age += pdr->point_data[pdr->offset + index]; // * density; + } + + *pdr->density += density; +} + + +static void init_pointdensityrangedata(PointDensity *pd, PointDensityRangeData *pdr, float *density, float *vec, float *age) +{ + pdr->squared_radius = pd->radius*pd->radius; + pdr->density = density; + pdr->point_data = pd->point_data; + pdr->falloff_type = pd->falloff_type; + pdr->vec = vec; + pdr->age = age; + pdr->softness = pd->falloff_softness; + pdr->noise_influence = pd->noise_influence; + pdr->point_data_used = point_data_used(pd); + pdr->offset = (pdr->point_data_used & POINT_DATA_VEL)?pd->totpoints*3:0; +} + + +int pointdensitytex(Tex *tex, float *texvec, TexResult *texres) +{ + int retval = TEX_INT; + PointDensity *pd = tex->pd; + PointDensityRangeData pdr; + float density=0.0f, age=0.0f, time=0.0f; + float vec[3] = {0.0f, 0.0f, 0.0f}, co[3]; + float col[4]; + float turb, noise_fac; + int num=0; + + texres->tin = 0.0f; + + if ((!pd) || (!pd->point_tree)) + return 0; + + init_pointdensityrangedata(pd, &pdr, &density, vec, &age); + noise_fac = pd->noise_fac * 0.5f; /* better default */ + + VECCOPY(co, texvec); + + if (point_data_used(pd)) { + /* does a BVH lookup to find accumulated density and additional point data * + * stores particle velocity vector in 'vec', and particle lifetime in 'time' */ + num = BLI_bvhtree_range_query(pd->point_tree, co, pd->radius, accum_density, &pdr); + if (num > 0) { + age /= num; + VecMulf(vec, 1.0f/num); + } + + /* reset */ + density = vec[0] = vec[1] = vec[2] = 0.0f; + } + + if (pd->flag & TEX_PD_TURBULENCE) { + + if (pd->noise_influence == TEX_PD_NOISE_AGE) { + turb = BLI_gTurbulence(pd->noise_size, texvec[0]+age, texvec[1]+age, texvec[2]+age, pd->noise_depth, 0, pd->noise_basis); + } + else if (pd->noise_influence == TEX_PD_NOISE_TIME) { + time = R.cfra / (float)R.r.efra; + turb = BLI_gTurbulence(pd->noise_size, texvec[0]+time, texvec[1]+time, texvec[2]+time, pd->noise_depth, 0, pd->noise_basis); + //turb = BLI_turbulence(pd->noise_size, texvec[0]+time, texvec[1]+time, texvec[2]+time, pd->noise_depth); + } + else { + turb = BLI_gTurbulence(pd->noise_size, texvec[0]+vec[0], texvec[1]+vec[1], texvec[2]+vec[2], pd->noise_depth, 0, pd->noise_basis); + } + + turb -= 0.5f; /* re-center 0.0-1.0 range around 0 to prevent offsetting result */ + + /* now we have an offset coordinate to use for the density lookup */ + co[0] = texvec[0] + noise_fac * turb; + co[1] = texvec[1] + noise_fac * turb; + co[2] = texvec[2] + noise_fac * turb; + } + + /* BVH query with the potentially perturbed coordinates */ + num = BLI_bvhtree_range_query(pd->point_tree, co, pd->radius, accum_density, &pdr); + if (num > 0) { + age /= num; + VecMulf(vec, 1.0f/num); + } + + texres->tin = density; + BRICONT; + + if (pd->color_source == TEX_PD_COLOR_CONSTANT) + return retval; + + retval |= TEX_RGB; + + switch (pd->color_source) { + case TEX_PD_COLOR_PARTAGE: + if (pd->coba) { + if (do_colorband(pd->coba, age, col)) { + texres->talpha= 1; + VECCOPY(&texres->tr, col); + texres->tin *= col[3]; + texres->ta = texres->tin; + } + } + break; + case TEX_PD_COLOR_PARTSPEED: + { + float speed = VecLength(vec) * pd->speed_scale; + + if (pd->coba) { + if (do_colorband(pd->coba, speed, col)) { + texres->talpha= 1; + VECCOPY(&texres->tr, col); + texres->tin *= col[3]; + texres->ta = texres->tin; + } + } + break; + } + case TEX_PD_COLOR_PARTVEL: + texres->talpha= 1; + VecMulf(vec, pd->speed_scale); + VECCOPY(&texres->tr, vec); + texres->ta = texres->tin; + break; + case TEX_PD_COLOR_CONSTANT: + default: + texres->tr = texres->tg = texres->tb = texres->ta = 1.0f; + break; + } + BRICONTRGB; + + return retval; + + /* + if (texres->nor!=NULL) { + texres->nor[0] = texres->nor[1] = texres->nor[2] = 0.0f; + } + */ +} diff --git a/source/blender/render/intern/source/rayshade.c b/source/blender/render/intern/source/rayshade.c index 010930fcb85..4cc731611a4 100644 --- a/source/blender/render/intern/source/rayshade.c +++ b/source/blender/render/intern/source/rayshade.c @@ -54,6 +54,7 @@ #include "pixelshading.h" #include "shading.h" #include "texture.h" +#include "volumetric.h" #include "RE_raytrace.h" @@ -95,6 +96,17 @@ static int vlr_check_intersect(Isect *is, int ob, RayFace *face) return (is->lay & obi->lay); } +static int vlr_check_intersect_solid(Isect *is, int ob, RayFace *face) +{ + VlakRen *vlr = (VlakRen*)face; + + /* solid material types only */ + if (vlr->mat->material_type == MA_TYPE_SURFACE) + return 1; + else + return 0; +} + static float *vlr_get_transform(void *userdata, int i) { ObjectInstanceRen *obi= RAY_OBJECT_GET((Render*)userdata, i); @@ -205,7 +217,7 @@ void makeraytree(Render *re) re->stats_draw(re->sdh, &re->i); } -static void shade_ray(Isect *is, ShadeInput *shi, ShadeResult *shr) +void shade_ray(Isect *is, ShadeInput *shi, ShadeResult *shr) { VlakRen *vlr= (VlakRen*)is->face; ObjectInstanceRen *obi= RAY_OBJECT_GET(&R, is->ob); @@ -260,8 +272,14 @@ static void shade_ray(Isect *is, ShadeInput *shi, ShadeResult *shr) shade_input_flip_normals(shi); shade_input_set_shade_texco(shi); - - if(is->mode==RE_RAY_SHADOW_TRA) { + if (shi->mat->material_type == MA_TYPE_VOLUME) { + if(ELEM(is->mode, RE_RAY_SHADOW, RE_RAY_SHADOW_TRA)) { + shade_volume_shadow(shi, shr, is); + } else { + shade_volume_outside(shi, shr); + } + } + else if(is->mode==RE_RAY_SHADOW_TRA) { /* temp hack to prevent recursion */ if(shi->nodes==0 && shi->mat->nodetree && shi->mat->use_nodes) { ntreeShaderExecTree(shi->mat->nodetree, shi, shr); @@ -275,9 +293,20 @@ static void shade_ray(Isect *is, ShadeInput *shi, ShadeResult *shr) ntreeShaderExecTree(shi->mat->nodetree, shi, shr); shi->mat= vlr->mat; /* shi->mat is being set in nodetree */ } - else - shade_material_loop(shi, shr); - + else { + int tempdepth; + /* XXX dodgy business here, set ray depth to -1 + * to ignore raytrace in shade_material_loop() + * this could really use a refactor --Matt */ + if (shi->volume_depth == 0) { + tempdepth = shi->depth; + shi->depth = -1; + shade_material_loop(shi, shr); + shi->depth = tempdepth; + } else { + shade_material_loop(shi, shr); + } + } /* raytrace likes to separate the spec color */ VECSUB(shr->diff, shr->combined, shr->spec); } @@ -361,7 +390,7 @@ static float shade_by_transmission(Isect *is, ShadeInput *shi, ShadeResult *shr) { float dx, dy, dz, d, p; - if (0 == (shi->mat->mode & (MA_RAYTRANSP|MA_ZTRA))) + if (0 == (shi->mat->mode & MA_TRANSP)) return -1; if (shi->mat->tx_limit <= 0.0f) { @@ -468,7 +497,7 @@ static void traceray(ShadeInput *origshi, ShadeResult *origshr, short depth, flo if(depth>0) { - if(shi.mat->mode_l & (MA_RAYTRANSP|MA_ZTRA) && shr.alpha < 1.0f) { + if((shi.mat->mode_l & MA_TRANSP) && shr.alpha < 1.0f) { float nf, f, f1, refract[3], tracol[4]; tracol[0]= shi.r; @@ -476,7 +505,7 @@ static void traceray(ShadeInput *origshi, ShadeResult *origshr, short depth, flo tracol[2]= shi.b; tracol[3]= col[3]; // we pass on and accumulate alpha - if(shi.mat->mode & MA_RAYTRANSP) { + if((shi.mat->mode & MA_TRANSP) && (shi.mat->mode & MA_RAYTRANSP)) { /* odd depths: use normal facing viewer, otherwise flip */ if(traflag & RAY_TRAFLIP) { float norm[3]; @@ -1183,7 +1212,7 @@ void ray_trace(ShadeInput *shi, ShadeResult *shr) float diff[3]; int do_tra, do_mir; - do_tra= ((shi->mat->mode & (MA_RAYTRANSP)) && shr->alpha!=1.0f); + do_tra= ((shi->mat->mode & MA_TRANSP) && (shi->mat->mode & MA_RAYTRANSP) && shr->alpha!=1.0f); do_mir= ((shi->mat->mode & MA_RAYMIRROR) && shi->ray_mirror!=0.0f); @@ -1302,11 +1331,15 @@ static void ray_trace_shadow_tra(Isect *is, ShadeInput *origshi, int depth, int shi.nodes= origshi->nodes; shade_ray(is, &shi, &shr); - if (traflag & RAY_TRA) - d= shade_by_transmission(is, &shi, &shr); - - /* mix colors based on shadfac (rgb + amount of light factor) */ - addAlphaLight(is->col, shr.diff, shr.alpha, d*shi.mat->filter); + if (shi.mat->material_type == MA_TYPE_SURFACE) { + if (traflag & RAY_TRA) + d= shade_by_transmission(is, &shi, &shr); + + /* mix colors based on shadfac (rgb + amount of light factor) */ + addAlphaLight(is->col, shr.diff, shr.alpha, d*shi.mat->filter); + } else if (shi.mat->material_type == MA_TYPE_VOLUME) { + addAlphaLight(is->col, shr.combined, shr.alpha, 1.0f); + } if(depth>0 && is->col[3]>0.0f) { @@ -1607,7 +1640,7 @@ static void ray_ao_qmc(ShadeInput *shi, float *shadfac) prev = fac; - if(RE_ray_tree_intersect(R.raytree, &isec)) { + if(RE_ray_tree_intersect_check(R.raytree, &isec, vlr_check_intersect_solid)) { if (R.wrld.aomode & WO_AODIST) fac+= exp(-isec.labda*R.wrld.aodistfac); else fac+= 1.0f; } @@ -1732,7 +1765,7 @@ static void ray_ao_spheresamp(ShadeInput *shi, float *shadfac) isec.end[2] = shi->co[2] - maxdist*vec[2]; /* do the trace */ - if(RE_ray_tree_intersect(R.raytree, &isec)) { + if(RE_ray_tree_intersect_check(R.raytree, &isec, vlr_check_intersect_solid)) { if (R.wrld.aomode & WO_AODIST) sh+= exp(-isec.labda*R.wrld.aodistfac); else sh+= 1.0f; } diff --git a/source/blender/render/intern/source/raytrace.c b/source/blender/render/intern/source/raytrace.c index 09d3711885a..b34fe6a7039 100644 --- a/source/blender/render/intern/source/raytrace.c +++ b/source/blender/render/intern/source/raytrace.c @@ -931,7 +931,7 @@ int RE_ray_face_intersection(Isect *is, RayObjectTransformFunc transformfunc, Ra intersection to be detected in its neighbour face */ if(is->facecontr && is->faceisect); // optimizing, the tests below are not needed - else if(is->labda< .1) { + else if(is->labda< .1 && is->faceorig) { RayFace *face= is->faceorig; float *origv1, *origv2, *origv3, *origv4; short de= 0; diff --git a/source/blender/render/intern/source/rendercore.c b/source/blender/render/intern/source/rendercore.c index 3a3d6f57830..b774bf6374d 100644 --- a/source/blender/render/intern/source/rendercore.c +++ b/source/blender/render/intern/source/rendercore.c @@ -477,7 +477,7 @@ static void add_filt_passes(RenderLayer *rl, int curmask, int rectx, int offset, col= shr->refr; break; case SCE_PASS_RADIO: - col= shr->rad; + col= NULL; // removed shr->rad; break; case SCE_PASS_NORMAL: col= shr->nor; @@ -569,7 +569,7 @@ static void add_passes(RenderLayer *rl, int offset, ShadeInput *shi, ShadeResult col= shr->refr; break; case SCE_PASS_RADIO: - col= shr->rad; + col= NULL; // removed shr->rad; break; case SCE_PASS_NORMAL: col= shr->nor; diff --git a/source/blender/render/intern/source/shadeinput.c b/source/blender/render/intern/source/shadeinput.c index c860e9ac5d1..1a0edfd53ed 100644 --- a/source/blender/render/intern/source/shadeinput.c +++ b/source/blender/render/intern/source/shadeinput.c @@ -52,6 +52,7 @@ #include "shading.h" #include "strand.h" #include "texture.h" +#include "volumetric.h" #include "zbuf.h" /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ @@ -156,16 +157,21 @@ void shade_material_loop(ShadeInput *shi, ShadeResult *shr) /* depth >= 1 when ray-shading */ if(shi->depth==0) { if(R.r.mode & R_RAYTRACE) { - if(shi->ray_mirror!=0.0f || ((shi->mat->mode & MA_RAYTRANSP) && shr->alpha!=1.0f)) { + if(shi->ray_mirror!=0.0f || ((shi->mat->mode & MA_TRANSP) && (shi->mat->mode & MA_RAYTRANSP) && shr->alpha!=1.0f)) { /* ray trace works on combined, but gives pass info */ ray_trace(shi, shr); } } /* disable adding of sky for raytransp */ - if(shi->mat->mode & MA_RAYTRANSP) + if((shi->mat->mode & MA_TRANSP) && (shi->mat->mode & MA_RAYTRANSP)) if((shi->layflag & SCE_LAY_SKY) && (R.r.alphamode==R_ADDSKY)) shr->alpha= 1.0f; } + + if(R.r.mode & R_RAYTRACE) { + if (R.render_volumes_inside.first) + shade_volume_inside(shi, shr); + } } @@ -183,14 +189,18 @@ void shade_input_do_shade(ShadeInput *shi, ShadeResult *shr) /* copy all relevant material vars, note, keep this synced with render_types.h */ shade_input_init_material(shi); - shade_material_loop(shi, shr); + if (shi->mat->material_type == MA_TYPE_VOLUME) { + if(R.r.mode & R_RAYTRACE) + shade_volume_outside(shi, shr); + } else { /* MA_TYPE_SURFACE, MA_TYPE_WIRE */ + shade_material_loop(shi, shr); + } } /* copy additional passes */ if(shi->passflag & (SCE_PASS_VECTOR|SCE_PASS_NORMAL|SCE_PASS_RADIO)) { QUATCOPY(shr->winspeed, shi->winspeed); VECCOPY(shr->nor, shi->vn); - VECCOPY(shr->rad, shi->rad); } /* MIST */ @@ -211,11 +221,12 @@ void shade_input_do_shade(ShadeInput *shi, ShadeResult *shr) if(shr->alpha!=1.0f || alpha!=1.0f) { float fac= alpha*(shr->alpha); shr->combined[3]= fac; - shr->combined[0]*= fac; - shr->combined[1]*= fac; - shr->combined[2]*= fac; + + if (shi->mat->material_type!= MA_TYPE_VOLUME) + VecMulf(shr->combined, fac); } - else shr->combined[3]= 1.0f; + else + shr->combined[3]= 1.0f; /* add z */ shr->z= -shi->co[2]; @@ -558,10 +569,6 @@ void shade_input_set_strand_texco(ShadeInput *shi, StrandRen *strand, StrandVert shi->orn[2]= -shi->vn[2]; } - if(mode & MA_RADIO) { - /* not supported */ - } - if(texco & TEXCO_REFL) { /* mirror reflection color textures (and envmap) */ calc_R_ref(shi); /* wrong location for normal maps! XXXXXXXXXXXXXX */ @@ -580,8 +587,6 @@ void shade_input_set_strand_texco(ShadeInput *shi, StrandRen *strand, StrandVert } } - shi->rad[0]= shi->rad[1]= shi->rad[2]= 0.0f; - /* this only avalailable for scanline renders */ if(shi->depth==0) { if(texco & TEXCO_WINDOW) { @@ -705,6 +710,10 @@ void shade_input_calc_viewco(ShadeInput *shi, float x, float y, float z, float * } } + /* set camera coords - for scanline, it's always 0.0,0.0,0.0 (render is in camera space) + * however for raytrace it can be different - the position of the last intersection */ + shi->camera_co[0] = shi->camera_co[1] = shi->camera_co[2] = 0.0f; + /* cannot normalize earlier, code above needs it at viewplane level */ Normalize(view); } @@ -1154,24 +1163,6 @@ void shade_input_set_shade_texco(ShadeInput *shi) shi->orn[2]= -shi->vn[2]; } - if(mode & MA_RADIO) { - float *r1, *r2, *r3; - - r1= RE_vertren_get_rad(obr, v1, 0); - r2= RE_vertren_get_rad(obr, v2, 0); - r3= RE_vertren_get_rad(obr, v3, 0); - - if(r1 && r2 && r3) { - shi->rad[0]= (l*r3[0] - u*r1[0] - v*r2[0]); - shi->rad[1]= (l*r3[1] - u*r1[1] - v*r2[1]); - shi->rad[2]= (l*r3[2] - u*r1[2] - v*r2[2]); - } - else - shi->rad[0]= shi->rad[1]= shi->rad[2]= 0.0f; - } - else - shi->rad[0]= shi->rad[1]= shi->rad[2]= 0.0f; - if(texco & TEXCO_REFL) { /* mirror reflection color textures (and envmap) */ calc_R_ref(shi); /* wrong location for normal maps! XXXXXXXXXXXXXX */ @@ -1199,8 +1190,6 @@ void shade_input_set_shade_texco(ShadeInput *shi) } } } - else - shi->rad[0]= shi->rad[1]= shi->rad[2]= 0.0f; /* this only avalailable for scanline renders */ if(shi->depth==0) { diff --git a/source/blender/render/intern/source/shadeoutput.c b/source/blender/render/intern/source/shadeoutput.c index 88f940a5856..c2b45161179 100644 --- a/source/blender/render/intern/source/shadeoutput.c +++ b/source/blender/render/intern/source/shadeoutput.c @@ -58,7 +58,7 @@ extern struct Render R; /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ -static ListBase *get_lights(ShadeInput *shi) +ListBase *get_lights(ShadeInput *shi) { if(R.r.scemode & R_PREVIEWBUTS) @@ -1694,7 +1694,7 @@ void shade_lamp_loop(ShadeInput *shi, ShadeResult *shr) shi->alpha*= fresnel_fac(shi->view, shi->vn, ma->fresnel_tra_i, ma->fresnel_tra); /* note: shi->mode! */ - if(shi->mode & (MA_ZTRA|MA_RAYTRANSP)) { + if(shi->mode & MA_TRANSP) { if(shi->spectra!=0.0f) { float t = MAX3(shr->spec[0], shr->spec[1], shr->spec[2]); t *= shi->spectra; @@ -1711,11 +1711,12 @@ void shade_lamp_loop(ShadeInput *shi, ShadeResult *shr) shr->combined[1]+= shi->ambg; shr->combined[2]+= shi->ambb; + /* removed if(shi->combinedflag & SCE_PASS_RADIO) { shr->combined[0]+= shi->r*shi->amb*shi->rad[0]; shr->combined[1]+= shi->g*shi->amb*shi->rad[1]; shr->combined[2]+= shi->b*shi->amb*shi->rad[2]; - } + }*/ /* add AO in combined? */ if(R.wrld.mode & WO_AMB_OCC) { diff --git a/source/blender/render/intern/source/strand.c b/source/blender/render/intern/source/strand.c index d497e857392..9aa68175a50 100644 --- a/source/blender/render/intern/source/strand.c +++ b/source/blender/render/intern/source/strand.c @@ -234,8 +234,8 @@ void interpolate_shade_result(ShadeResult *shr1, ShadeResult *shr2, float t, Sha interpolate_vec3(shr1->refl, shr2->refl, t, negt, shr->refl); if(addpassflag & SCE_PASS_REFRACT) interpolate_vec3(shr1->refr, shr2->refr, t, negt, shr->refr); - if(addpassflag & SCE_PASS_RADIO) - interpolate_vec3(shr1->rad, shr2->rad, t, negt, shr->rad); + /* removed if(addpassflag & SCE_PASS_RADIO) + interpolate_vec3(shr1->rad, shr2->rad, t, negt, shr->rad);*/ if(addpassflag & SCE_PASS_MIST) interpolate_vec1(&shr1->mist, &shr2->mist, t, negt, &shr->mist); } diff --git a/source/blender/render/intern/source/texture.c b/source/blender/render/intern/source/texture.c index bb491efdaba..c706c6ccc11 100644 --- a/source/blender/render/intern/source/texture.c +++ b/source/blender/render/intern/source/texture.c @@ -65,6 +65,8 @@ #include "BKE_ipo.h" #include "envmap.h" +#include "pointdensity.h" +#include "voxeldata.h" #include "renderpipeline.h" #include "render_types.h" #include "rendercore.h" @@ -714,12 +716,12 @@ static float voronoiTex(Tex *tex, float *texvec, TexResult *texres) /* ------------------------------------------------------------------------- */ -static int evalnodes(Tex *tex, float *texvec, TexResult *texres, short thread, short which_output) +static int evalnodes(Tex *tex, float *texvec, float *dxt, float *dyt, TexResult *texres, short thread, short which_output) { short rv = TEX_INT; bNodeTree *nodes = tex->nodetree; - ntreeTexExecTree(nodes, texres, texvec, 0, thread, tex, which_output, R.r.cfra); + ntreeTexExecTree(nodes, texres, texvec, dxt, dyt, thread, tex, which_output, R.r.cfra); if(texres->nor) rv |= TEX_NOR; rv |= TEX_RGB; @@ -1180,7 +1182,7 @@ static int multitex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex, texres->talpha= 0; /* is set when image texture returns alpha (considered premul) */ if(tex->use_nodes && tex->nodetree) { - retval = evalnodes(tex, texvec, texres, thread, which_output); + retval = evalnodes(tex, texvec, dxt, dyt, texres, thread, which_output); } else switch(tex->type) { @@ -1262,6 +1264,13 @@ static int multitex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex, retval= mg_distNoiseTex(tex, tmpvec, texres); break; + case TEX_POINTDENSITY: + retval= pointdensitytex(tex, texvec, texres); + break; + case TEX_VOXELDATA: + retval= voxeldatatex(tex, texvec, texres); + break; + } if (tex->flag & TEX_COLORBAND) { @@ -1272,7 +1281,7 @@ static int multitex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex, texres->tg= col[1]; texres->tb= col[2]; texres->ta= col[3]; - retval |= 1; + retval |= TEX_RGB; } } return retval; @@ -2248,6 +2257,187 @@ void do_material_tex(ShadeInput *shi) } } + +void do_volume_tex(ShadeInput *shi, float *xyz, int mapto_flag, float *col, float *val) +{ + MTex *mtex; + Tex *tex; + TexResult texres= {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0, NULL}; + int tex_nr, rgbnor= 0; + float co[3], texvec[3]; + float fact, stencilTin=1.0; + + if (R.r.scemode & R_NO_TEX) return; + /* here: test flag if there's a tex (todo) */ + + for(tex_nr=0; tex_nr<MAX_MTEX; tex_nr++) { + /* separate tex switching */ + if(shi->mat->septex & (1<<tex_nr)) continue; + + if(shi->mat->mtex[tex_nr]) { + mtex= shi->mat->mtex[tex_nr]; + tex= mtex->tex; + if(tex==0) continue; + + /* only process if this texture is mapped + * to one that we're interested in */ + if (!(mtex->mapto & mapto_flag)) continue; + + /* 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) { + if(shi->obi && shi->obi->duplitexmat) + MTC_Mat4MulVecfl(shi->obi->duplitexmat, co); + } + MTC_Mat4MulVecfl(ob->imat, co); + } + } + /* not really orco, but 'local' */ + else if(mtex->texco==TEXCO_ORCO) { + + if(mtex->texflag & MTEX_DUPLI_MAPTO) { + VECCOPY(co, shi->duplilo); + } + else { + Object *ob= shi->obi->ob; + VECCOPY(co, xyz); + MTC_Mat4MulVecfl(ob->imat, co); + } + } + else if(mtex->texco==TEXCO_GLOB) { + VECCOPY(co, xyz); + MTC_Mat4MulVecfl(R.viewinv, co); + } + else continue; // can happen when texco defines disappear and it renders old files + + texres.nor= NULL; + + if(tex->type==TEX_IMAGE) { + continue; /* not supported yet */ + //do_2d_mapping(mtex, texvec, NULL, NULL, dxt, dyt); + } + else { + /* placement */ + if(mtex->projx) texvec[0]= mtex->size[0]*(co[mtex->projx-1]+mtex->ofs[0]); + else texvec[0]= mtex->size[0]*(mtex->ofs[0]); + + if(mtex->projy) texvec[1]= mtex->size[1]*(co[mtex->projy-1]+mtex->ofs[1]); + else texvec[1]= mtex->size[1]*(mtex->ofs[1]); + + if(mtex->projz) texvec[2]= mtex->size[2]*(co[mtex->projz-1]+mtex->ofs[2]); + else texvec[2]= mtex->size[2]*(mtex->ofs[2]); + } + + rgbnor= multitex(tex, texvec, NULL, NULL, 0, &texres, 0, mtex->which_output); /* NULL = dxt/dyt, 0 = shi->osatex - not supported */ + + /* texture output */ + + if( (rgbnor & TEX_RGB) && (mtex->texflag & MTEX_RGBTOINT)) { + texres.tin= (0.35*texres.tr+0.45*texres.tg+0.2*texres.tb); + rgbnor-= TEX_RGB; + } + if(mtex->texflag & MTEX_NEGATIVE) { + if(rgbnor & TEX_RGB) { + texres.tr= 1.0-texres.tr; + texres.tg= 1.0-texres.tg; + texres.tb= 1.0-texres.tb; + } + texres.tin= 1.0-texres.tin; + } + if(mtex->texflag & MTEX_STENCIL) { + if(rgbnor & TEX_RGB) { + fact= texres.ta; + texres.ta*= stencilTin; + stencilTin*= fact; + } + else { + fact= texres.tin; + texres.tin*= stencilTin; + stencilTin*= fact; + } + } + + + if((mapto_flag & (MAP_EMISSION_COL+MAP_ABSORPTION_COL)) && (mtex->mapto & (MAP_EMISSION_COL+MAP_ABSORPTION_COL))) { + float tcol[3], colfac; + + /* stencil maps on the texture control slider, not texture intensity value */ + colfac= mtex->colfac*stencilTin; + + if((rgbnor & TEX_RGB)==0) { + tcol[0]= mtex->r; + tcol[1]= mtex->g; + tcol[2]= mtex->b; + } else { + tcol[0]=texres.tr; + tcol[1]=texres.tg; + tcol[2]=texres.tb; + if(texres.talpha) + texres.tin= texres.ta; + } + + /* inverse gamma correction */ + if (R.r.color_mgt_flag & R_COLOR_MANAGEMENT) { + color_manage_linearize(tcol, tcol); + } + + /* used for emit */ + if((mapto_flag & MAP_EMISSION_COL) && (mtex->mapto & MAP_EMISSION_COL)) { + texture_rgb_blend(col, tcol, col, texres.tin, colfac, mtex->blendtype); + } + + /* MAP_COLMIR is abused for absorption colour at the moment */ + if((mapto_flag & MAP_ABSORPTION_COL) && (mtex->mapto & MAP_ABSORPTION_COL)) { + texture_rgb_blend(col, tcol, col, texres.tin, colfac, mtex->blendtype); + } + } + + if((mapto_flag & MAP_VARS) && (mtex->mapto & MAP_VARS)) { + /* stencil maps on the texture control slider, not texture intensity value */ + float varfac= mtex->varfac*stencilTin; + + /* convert RGB to intensity if intensity info isn't provided */ + if (!(rgbnor & TEX_INT)) { + if (rgbnor & TEX_RGB) { + if(texres.talpha) texres.tin= texres.ta; + else texres.tin= (0.35*texres.tr+0.45*texres.tg+0.2*texres.tb); + } + } + + if((mapto_flag & MAP_EMISSION) && (mtex->mapto & MAP_EMISSION)) { + int flip= mtex->maptoneg & MAP_EMISSION; + + *val = texture_value_blend(mtex->def_var, *val, texres.tin, varfac, mtex->blendtype, flip); + if(*val<0.0) *val= 0.0; + } + if((mapto_flag & MAP_DENSITY) && (mtex->mapto & MAP_DENSITY)) { + int flip= mtex->maptoneg & MAP_DENSITY; + + *val = texture_value_blend(mtex->def_var, *val, texres.tin, varfac, mtex->blendtype, flip); + CLAMP(*val, 0.0, 1.0); + } + if((mapto_flag & MAP_ABSORPTION) && (mtex->mapto & MAP_ABSORPTION)) { + int flip= mtex->maptoneg & MAP_ABSORPTION; + + *val = texture_value_blend(mtex->def_var, *val, texres.tin, varfac, mtex->blendtype, flip); + CLAMP(*val, 0.0, 1.0); + } + if((mapto_flag & MAP_SCATTERING) && (mtex->mapto & MAP_SCATTERING)) { + int flip= mtex->maptoneg & MAP_SCATTERING; + + *val = texture_value_blend(mtex->def_var, *val, texres.tin, varfac, mtex->blendtype, flip); + CLAMP(*val, 0.0, 1.0); + } + } + } + } +} + + /* ------------------------------------------------------------------------- */ void do_halo_tex(HaloRen *har, float xn, float yn, float *colf) diff --git a/source/blender/render/intern/source/volume_precache.c b/source/blender/render/intern/source/volume_precache.c new file mode 100644 index 00000000000..71200aa8b0d --- /dev/null +++ b/source/blender/render/intern/source/volume_precache.c @@ -0,0 +1,737 @@ +/** + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): Matt Ebb. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include <math.h> +#include <stdlib.h> +#include <string.h> +#include <float.h> + +#include "MEM_guardedalloc.h" + +#include "BLI_blenlib.h" +#include "BLI_arithb.h" +#include "BLI_threads.h" +#include "BLI_voxel.h" + +#include "PIL_time.h" + +#include "RE_shader_ext.h" +#include "RE_raytrace.h" + +#include "DNA_material_types.h" + +#include "render_types.h" +#include "renderdatabase.h" +#include "volumetric.h" +#include "volume_precache.h" + +#if defined( _MSC_VER ) && !defined( __cplusplus ) +# define inline __inline +#endif // defined( _MSC_VER ) && !defined( __cplusplus ) + +#include "BKE_global.h" + +/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ +/* defined in pipeline.c, is hardcopy of active dynamic allocated Render */ +/* only to be used here in this file, it's for speed */ +extern struct Render R; +/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +/* *** utility code to set up an individual raytree for objectinstance, for checking inside/outside *** */ + +/* Recursive test for intersections, from a point inside the mesh, to outside + * Number of intersections (depth) determine if a point is inside or outside the mesh */ +int intersect_outside_volume(RayTree *tree, Isect *isect, float *offset, int limit, int depth) +{ + if (limit == 0) return depth; + + if (RE_ray_tree_intersect(tree, isect)) { + float hitco[3]; + + hitco[0] = isect->start[0] + isect->labda*isect->vec[0]; + hitco[1] = isect->start[1] + isect->labda*isect->vec[1]; + hitco[2] = isect->start[2] + isect->labda*isect->vec[2]; + VecAddf(isect->start, hitco, offset); + + return intersect_outside_volume(tree, isect, offset, limit-1, depth+1); + } else { + return depth; + } +} + +/* Uses ray tracing to check if a point is inside or outside an ObjectInstanceRen */ +int point_inside_obi(RayTree *tree, ObjectInstanceRen *obi, float *co) +{ + float maxsize = RE_ray_tree_max_size(tree); + Isect isect; + float vec[3] = {0.0f,0.0f,1.0f}; + int final_depth=0, depth=0, limit=20; + + /* set up the isect */ + memset(&isect, 0, sizeof(isect)); + VECCOPY(isect.start, co); + isect.end[0] = co[0] + vec[0] * maxsize; + isect.end[1] = co[1] + vec[1] * maxsize; + isect.end[2] = co[2] + vec[2] * maxsize; + + /* and give it a little offset to prevent self-intersections */ + VecMulf(vec, 1e-5); + VecAddf(isect.start, isect.start, vec); + + isect.mode= RE_RAY_MIRROR; + isect.face_last= NULL; + isect.lay= -1; + + final_depth = intersect_outside_volume(tree, &isect, vec, limit, depth); + + /* even number of intersections: point is outside + * odd number: point is inside */ + if (final_depth % 2 == 0) return 0; + else return 1; +} + +static int inside_check_func(Isect *is, int ob, RayFace *face) +{ + return 1; +} +static void vlr_face_coords(RayFace *face, float **v1, float **v2, float **v3, float **v4) +{ + VlakRen *vlr= (VlakRen*)face; + + *v1 = (vlr->v1)? vlr->v1->co: NULL; + *v2 = (vlr->v2)? vlr->v2->co: NULL; + *v3 = (vlr->v3)? vlr->v3->co: NULL; + *v4 = (vlr->v4)? vlr->v4->co: NULL; +} + +RayTree *create_raytree_obi(ObjectInstanceRen *obi, float *bbmin, float *bbmax) +{ + int v; + VlakRen *vlr= NULL; + + /* create empty raytree */ + RayTree *tree = RE_ray_tree_create(64, obi->obr->totvlak, bbmin, bbmax, + vlr_face_coords, inside_check_func, NULL, NULL); + + /* fill it with faces */ + for(v=0; v<obi->obr->totvlak; v++) { + if((v & 255)==0) + vlr= obi->obr->vlaknodes[v>>8].vlak; + else + vlr++; + + RE_ray_tree_add_face(tree, 0, vlr); + } + + RE_ray_tree_done(tree); + + return tree; +} + +/* *** light cache filtering *** */ + +static float get_avg_surrounds(float *cache, int *res, int xx, int yy, int zz) +{ + int x, y, z, x_, y_, z_; + int added=0; + float tot=0.0f; + + for (z=-1; z <= 1; z++) { + z_ = zz+z; + if (z_ >= 0 && z_ <= res[2]-1) { + + for (y=-1; y <= 1; y++) { + y_ = yy+y; + if (y_ >= 0 && y_ <= res[1]-1) { + + for (x=-1; x <= 1; x++) { + x_ = xx+x; + if (x_ >= 0 && x_ <= res[0]-1) { + + if (cache[ V_I(x_, y_, z_, res) ] > 0.0f) { + tot += cache[ V_I(x_, y_, z_, res) ]; + added++; + } + + } + } + } + } + } + } + + tot /= added; + + return ((added>0)?tot:0.0f); +} + +/* function to filter the edges of the light cache, where there was no volume originally. + * For each voxel which was originally external to the mesh, it finds the average values of + * the surrounding internal voxels and sets the original external voxel to that average amount. + * Works almost a bit like a 'dilate' filter */ +static void lightcache_filter(VolumePrecache *vp) +{ + int x, y, z; + + for (z=0; z < vp->res[2]; z++) { + for (y=0; y < vp->res[1]; y++) { + for (x=0; x < vp->res[0]; x++) { + /* trigger for outside mesh */ + if (vp->data_r[ V_I(x, y, z, vp->res) ] < -0.5f) + vp->data_r[ V_I(x, y, z, vp->res) ] = get_avg_surrounds(vp->data_r, vp->res, x, y, z); + if (vp->data_g[ V_I(x, y, z, vp->res) ] < -0.5f) + vp->data_g[ V_I(x, y, z, vp->res) ] = get_avg_surrounds(vp->data_g, vp->res, x, y, z); + if (vp->data_b[ V_I(x, y, z, vp->res) ] < -0.5f) + vp->data_b[ V_I(x, y, z, vp->res) ] = get_avg_surrounds(vp->data_b, vp->res, x, y, z); + } + } + } +} + +static inline int ms_I(int x, int y, int z, int *n) //has a pad of 1 voxel surrounding the core for boundary simulation +{ + return z*(n[1]+2)*(n[0]+2) + y*(n[0]+2) + x; +} + + +/* *** multiple scattering approximation *** */ + +/* get the total amount of light energy in the light cache. used to normalise after multiple scattering */ +static float total_ss_energy(VolumePrecache *vp) +{ + int x, y, z; + int *res = vp->res; + float energy=0.f; + + for (z=0; z < res[2]; z++) { + for (y=0; y < res[1]; y++) { + for (x=0; x < res[0]; x++) { + if (vp->data_r[ V_I(x, y, z, res) ] > 0.f) energy += vp->data_r[ V_I(x, y, z, res) ]; + if (vp->data_g[ V_I(x, y, z, res) ] > 0.f) energy += vp->data_g[ V_I(x, y, z, res) ]; + if (vp->data_b[ V_I(x, y, z, res) ] > 0.f) energy += vp->data_b[ V_I(x, y, z, res) ]; + } + } + } + + return energy; +} + +static float total_ms_energy(float *sr, float *sg, float *sb, int *res) +{ + int x, y, z, i; + float energy=0.f; + + for (z=1;z<=res[2];z++) { + for (y=1;y<=res[1];y++) { + for (x=1;x<=res[0];x++) { + + i = ms_I(x,y,z,res); + if (sr[i] > 0.f) energy += sr[i]; + if (sg[i] > 0.f) energy += sg[i]; + if (sb[i] > 0.f) energy += sb[i]; + } + } + } + + return energy; +} + +static void ms_diffuse(int b, float* x0, float* x, float diff, int *n) +{ + int i, j, k, l; + const float dt = VOL_MS_TIMESTEP; + const float a = dt*diff*n[0]*n[1]*n[2]; + + for (l=0; l<20; l++) + { + for (k=1; k<=n[2]; k++) + { + for (j=1; j<=n[1]; j++) + { + for (i=1; i<=n[0]; i++) + { + x[ms_I(i,j,k,n)] = (x0[ms_I(i,j,k,n)] + a*( + x[ms_I(i-1,j,k,n)]+x[ms_I(i+1,j,k,n)]+ + x[ms_I(i,j-1,k,n)]+x[ms_I(i,j+1,k,n)]+ + x[ms_I(i,j,k-1,n)]+x[ms_I(i,j,k+1,n)]))/(1+6*a); + } + } + } + } +} + +void multiple_scattering_diffusion(Render *re, VolumePrecache *vp, Material *ma) +{ + const float diff = ma->vol.ms_diff * 0.001f; /* compensate for scaling for a nicer UI range */ + const float simframes = ma->vol.ms_steps; + const int shade_type = ma->vol.shade_type; + float fac = ma->vol.ms_intensity; + + int x, y, z, m; + int *n = vp->res; + const int size = (n[0]+2)*(n[1]+2)*(n[2]+2); + double time, lasttime= PIL_check_seconds_timer(); + float total; + float c=1.0f; + int i; + float origf; /* factor for blending in original light cache */ + float energy_ss, energy_ms; + + float *sr0=(float *)MEM_callocN(size*sizeof(float), "temporary multiple scattering buffer"); + float *sr=(float *)MEM_callocN(size*sizeof(float), "temporary multiple scattering buffer"); + float *sg0=(float *)MEM_callocN(size*sizeof(float), "temporary multiple scattering buffer"); + float *sg=(float *)MEM_callocN(size*sizeof(float), "temporary multiple scattering buffer"); + float *sb0=(float *)MEM_callocN(size*sizeof(float), "temporary multiple scattering buffer"); + float *sb=(float *)MEM_callocN(size*sizeof(float), "temporary multiple scattering buffer"); + + total = (float)(n[0]*n[1]*n[2]*simframes); + + energy_ss = total_ss_energy(vp); + + /* Scattering as diffusion pass */ + for (m=0; m<simframes; m++) + { + /* add sources */ + for (z=1; z<=n[2]; z++) + { + for (y=1; y<=n[1]; y++) + { + for (x=1; x<=n[0]; x++) + { + i = V_I((x-1), (y-1), (z-1), n); + time= PIL_check_seconds_timer(); + c++; + + if (vp->data_r[i] > 0.f) + sr[ms_I(x,y,z,n)] += vp->data_r[i]; + if (vp->data_g[i] > 0.f) + sg[ms_I(x,y,z,n)] += vp->data_g[i]; + if (vp->data_b[i] > 0.f) + sb[ms_I(x,y,z,n)] += vp->data_b[i]; + + /* Displays progress every second */ + if(time-lasttime>1.0f) { + char str[64]; + sprintf(str, "Simulating multiple scattering: %d%%", (int) + (100.0f * (c / total))); + re->i.infostr= str; + re->stats_draw(re->sdh, &re->i); + re->i.infostr= NULL; + lasttime= time; + } + } + } + } + SWAP(float *, sr, sr0); + SWAP(float *, sg, sg0); + SWAP(float *, sb, sb0); + + /* main diffusion simulation */ + ms_diffuse(0, sr0, sr, diff, n); + ms_diffuse(0, sg0, sg, diff, n); + ms_diffuse(0, sb0, sb, diff, n); + + if (re->test_break(re->tbh)) break; + } + + /* normalisation factor to conserve energy */ + energy_ms = total_ms_energy(sr, sg, sb, n); + fac *= (energy_ss / energy_ms); + + /* blend multiple scattering back in the light cache */ + if (shade_type == MA_VOL_SHADE_SINGLEPLUSMULTIPLE) { + /* conserve energy - half single, half multiple */ + origf = 0.5f; + fac *= 0.5f; + } else { + origf = 0.0f; + } + + for (z=1;z<=n[2];z++) + { + for (y=1;y<=n[1];y++) + { + for (x=1;x<=n[0];x++) + { + int index=(x-1)*n[1]*n[2] + (y-1)*n[2] + z-1; + vp->data_r[index] = origf * vp->data_r[index] + fac * sr[ms_I(x,y,z,n)]; + vp->data_g[index] = origf * vp->data_g[index] + fac * sg[ms_I(x,y,z,n)]; + vp->data_b[index] = origf * vp->data_b[index] + fac * sb[ms_I(x,y,z,n)]; + } + } + } + + MEM_freeN(sr0); + MEM_freeN(sr); + MEM_freeN(sg0); + MEM_freeN(sg); + MEM_freeN(sb0); + MEM_freeN(sb); +} + + + +#if 0 // debug stuff +static void *vol_precache_part_test(void *data) +{ + VolPrecachePart *pa = data; + + printf("part number: %d \n", pa->num); + printf("done: %d \n", pa->done); + printf("x min: %d x max: %d \n", pa->minx, pa->maxx); + printf("y min: %d y max: %d \n", pa->miny, pa->maxy); + printf("z min: %d z max: %d \n", pa->minz, pa->maxz); + + return NULL; +} +#endif + +/* Iterate over the 3d voxel grid, and fill the voxels with scattering information + * + * It's stored in memory as 3 big float grids next to each other, one for each RGB channel. + * I'm guessing the memory alignment may work out better this way for the purposes + * of doing linear interpolation, but I haven't actually tested this theory! :) + */ +static void *vol_precache_part(void *data) +{ + VolPrecachePart *pa = (VolPrecachePart *)data; + ObjectInstanceRen *obi = pa->obi; + RayTree *tree = pa->tree; + ShadeInput *shi = pa->shi; + float density, scatter_col[3] = {0.f, 0.f, 0.f}; + float co[3]; + int x, y, z; + const int res[3]= {pa->res[0], pa->res[1], pa->res[2]}; + const float stepsize = vol_get_stepsize(shi, STEPSIZE_VIEW); + + for (z= pa->minz; z < pa->maxz; z++) { + co[2] = pa->bbmin[2] + (pa->voxel[2] * z); + + for (y= pa->miny; y < pa->maxy; y++) { + co[1] = pa->bbmin[1] + (pa->voxel[1] * y); + + for (x=pa->minx; x < pa->maxx; x++) { + co[0] = pa->bbmin[0] + (pa->voxel[0] * x); + + // don't bother if the point is not inside the volume mesh + if (!point_inside_obi(tree, obi, co)) { + obi->volume_precache->data_r[ V_I(x, y, z, res) ] = -1.0f; + obi->volume_precache->data_g[ V_I(x, y, z, res) ] = -1.0f; + obi->volume_precache->data_b[ V_I(x, y, z, res) ] = -1.0f; + continue; + } + + VecCopyf(shi->view, co); + Normalize(shi->view); + density = vol_get_density(shi, co); + vol_get_scattering(shi, scatter_col, co, stepsize, density); + + obi->volume_precache->data_r[ V_I(x, y, z, res) ] = scatter_col[0]; + obi->volume_precache->data_g[ V_I(x, y, z, res) ] = scatter_col[1]; + obi->volume_precache->data_b[ V_I(x, y, z, res) ] = scatter_col[2]; + } + } + } + + pa->done = 1; + + return 0; +} + + +static void precache_setup_shadeinput(Render *re, ObjectInstanceRen *obi, Material *ma, ShadeInput *shi) +{ + memset(shi, 0, sizeof(ShadeInput)); + shi->depth= 1; + shi->mask= 1; + shi->mat = ma; + shi->vlr = NULL; + memcpy(&shi->r, &shi->mat->r, 23*sizeof(float)); // note, keep this synced with render_types.h + shi->har= shi->mat->har; + shi->obi= obi; + shi->obr= obi->obr; + shi->lay = re->scene->lay; +} + +static void precache_init_parts(Render *re, RayTree *tree, ShadeInput *shi, ObjectInstanceRen *obi, int totthread, int *parts) +{ + VolumePrecache *vp = obi->volume_precache; + int i=0, x, y, z; + float voxel[3]; + int sizex, sizey, sizez; + float *bbmin=obi->obr->boundbox[0], *bbmax=obi->obr->boundbox[1]; + int *res; + int minx, maxx; + int miny, maxy; + int minz, maxz; + + if (!vp) return; + + BLI_freelistN(&re->volume_precache_parts); + + /* currently we just subdivide the box, number of threads per side */ + parts[0] = parts[1] = parts[2] = totthread; + res = vp->res; + + VecSubf(voxel, bbmax, bbmin); + if ((voxel[0] < FLT_EPSILON) || (voxel[1] < FLT_EPSILON) || (voxel[2] < FLT_EPSILON)) + return; + voxel[0] /= res[0]; + voxel[1] /= res[1]; + voxel[2] /= res[2]; + + for (x=0; x < parts[0]; x++) { + sizex = ceil(res[0] / (float)parts[0]); + minx = x * sizex; + maxx = minx + sizex; + maxx = (maxx>res[0])?res[0]:maxx; + + for (y=0; y < parts[1]; y++) { + sizey = ceil(res[1] / (float)parts[1]); + miny = y * sizey; + maxy = miny + sizey; + maxy = (maxy>res[1])?res[1]:maxy; + + for (z=0; z < parts[2]; z++) { + VolPrecachePart *pa= MEM_callocN(sizeof(VolPrecachePart), "new precache part"); + + sizez = ceil(res[2] / (float)parts[2]); + minz = z * sizez; + maxz = minz + sizez; + maxz = (maxz>res[2])?res[2]:maxz; + + pa->done = 0; + pa->working = 0; + + pa->num = i; + pa->tree = tree; + pa->shi = shi; + pa->obi = obi; + VECCOPY(pa->bbmin, bbmin); + VECCOPY(pa->voxel, voxel); + VECCOPY(pa->res, res); + + pa->minx = minx; pa->maxx = maxx; + pa->miny = miny; pa->maxy = maxy; + pa->minz = minz; pa->maxz = maxz; + + + BLI_addtail(&re->volume_precache_parts, pa); + + i++; + } + } + } +} + +static VolPrecachePart *precache_get_new_part(Render *re) +{ + VolPrecachePart *pa, *nextpa=NULL; + + for (pa = re->volume_precache_parts.first; pa; pa=pa->next) + { + if (pa->done==0 && pa->working==0) { + nextpa = pa; + break; + } + } + + return nextpa; +} + +static void precache_resolution(VolumePrecache *vp, float *bbmin, float *bbmax, int res) +{ + float dim[3], div; + + VecSubf(dim, bbmax, bbmin); + + div = MAX3(dim[0], dim[1], dim[2]); + dim[0] /= div; + dim[1] /= div; + dim[2] /= div; + + vp->res[0] = dim[0] * (float)res; + vp->res[1] = dim[1] * (float)res; + vp->res[2] = dim[2] * (float)res; +} + +/* Precache a volume into a 3D voxel grid. + * The voxel grid is stored in the ObjectInstanceRen, + * in camera space, aligned with the ObjectRen's bounding box. + * Resolution is defined by the user. + */ +void vol_precache_objectinstance_threads(Render *re, ObjectInstanceRen *obi, Material *ma) +{ + VolumePrecache *vp; + VolPrecachePart *nextpa, *pa; + RayTree *tree; + ShadeInput shi; + ListBase threads; + float *bbmin=obi->obr->boundbox[0], *bbmax=obi->obr->boundbox[1]; + int parts[3], totparts; + + int caching=1, counter=0; + int totthread = re->r.threads; + + double time, lasttime= PIL_check_seconds_timer(); + + R = *re; + + /* create a raytree with just the faces of the instanced ObjectRen, + * used for checking if the cached point is inside or outside. */ + tree = create_raytree_obi(obi, bbmin, bbmax); + if (!tree) return; + + vp = MEM_callocN(sizeof(VolumePrecache), "volume light cache"); + precache_resolution(vp, bbmin, bbmax, ma->vol.precache_resolution); + + vp->data_r = MEM_callocN(sizeof(float)*vp->res[0]*vp->res[1]*vp->res[2], "volume light cache data red channel"); + vp->data_g = MEM_callocN(sizeof(float)*vp->res[0]*vp->res[1]*vp->res[2], "volume light cache data green channel"); + vp->data_b = MEM_callocN(sizeof(float)*vp->res[0]*vp->res[1]*vp->res[2], "volume light cache data blue channel"); + obi->volume_precache = vp; + + /* Need a shadeinput to calculate scattering */ + precache_setup_shadeinput(re, obi, ma, &shi); + + precache_init_parts(re, tree, &shi, obi, totthread, parts); + totparts = parts[0] * parts[1] * parts[2]; + + BLI_init_threads(&threads, vol_precache_part, totthread); + + while(caching) { + + if(BLI_available_threads(&threads) && !(re->test_break(re->tbh))) { + nextpa = precache_get_new_part(re); + if (nextpa) { + nextpa->working = 1; + BLI_insert_thread(&threads, nextpa); + } + } + else PIL_sleep_ms(50); + + caching=0; + counter=0; + for(pa= re->volume_precache_parts.first; pa; pa= pa->next) { + + if(pa->done) { + counter++; + BLI_remove_thread(&threads, pa); + } else + caching = 1; + } + + if (re->test_break(re->tbh) && BLI_available_threads(&threads)==totthread) + caching=0; + + time= PIL_check_seconds_timer(); + if(time-lasttime>1.0f) { + char str[64]; + sprintf(str, "Precaching volume: %d%%", (int)(100.0f * ((float)counter / (float)totparts))); + re->i.infostr= str; + re->stats_draw(re->sdh, &re->i); + re->i.infostr= NULL; + lasttime= time; + } + } + + BLI_end_threads(&threads); + BLI_freelistN(&re->volume_precache_parts); + + if(tree) { + RE_ray_tree_free(tree); + tree= NULL; + } + + lightcache_filter(obi->volume_precache); + + if (ELEM(ma->vol.shade_type, MA_VOL_SHADE_MULTIPLE, MA_VOL_SHADE_SINGLEPLUSMULTIPLE)) + { + multiple_scattering_diffusion(re, vp, ma); + } +} + +int using_lightcache(Material *ma) +{ + return (((ma->vol.shadeflag & MA_VOL_PRECACHESHADING) && (ma->vol.shade_type == MA_VOL_SHADE_SINGLE)) + || (ELEM(ma->vol.shade_type, MA_VOL_SHADE_MULTIPLE, MA_VOL_SHADE_SINGLEPLUSMULTIPLE))); +} + +/* loop through all objects (and their associated materials) + * marked for pre-caching in convertblender.c, and pre-cache them */ +void volume_precache(Render *re) +{ + ObjectInstanceRen *obi; + VolumeOb *vo; + + for(vo= re->volumes.first; vo; vo= vo->next) { + if (using_lightcache(vo->ma)) { + for(obi= re->instancetable.first; obi; obi= obi->next) { + if (obi->obr == vo->obr) { + vol_precache_objectinstance_threads(re, obi, vo->ma); + } + } + } + } + + re->i.infostr= NULL; + re->stats_draw(re->sdh, &re->i); +} + +void free_volume_precache(Render *re) +{ + ObjectInstanceRen *obi; + + for(obi= re->instancetable.first; obi; obi= obi->next) { + if (obi->volume_precache != NULL) { + MEM_freeN(obi->volume_precache); + MEM_freeN(obi->volume_precache->data_r); + MEM_freeN(obi->volume_precache->data_g); + MEM_freeN(obi->volume_precache->data_b); + obi->volume_precache = NULL; + } + } + + BLI_freelistN(&re->volumes); +} + +int point_inside_volume_objectinstance(ObjectInstanceRen *obi, float *co) +{ + RayTree *tree; + int inside=0; + + tree = create_raytree_obi(obi, obi->obr->boundbox[0], obi->obr->boundbox[1]); + if (!tree) return 0; + + inside = point_inside_obi(tree, obi, co); + + RE_ray_tree_free(tree); + tree= NULL; + + return inside; +} + diff --git a/source/blender/render/intern/source/volumetric.c b/source/blender/render/intern/source/volumetric.c new file mode 100644 index 00000000000..13996905437 --- /dev/null +++ b/source/blender/render/intern/source/volumetric.c @@ -0,0 +1,688 @@ +/** + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): Matt Ebb, Raul Fernandez Hernandez (Farsthary) + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include <math.h> +#include <stdlib.h> +#include <string.h> +#include <float.h> + +#include "MEM_guardedalloc.h" + +#include "BLI_blenlib.h" +#include "BLI_arithb.h" +#include "BLI_rand.h" +#include "BLI_voxel.h" + +#include "RE_shader_ext.h" +#include "RE_raytrace.h" + +#include "DNA_material_types.h" +#include "DNA_group_types.h" +#include "DNA_lamp_types.h" + +#include "BKE_global.h" + +#include "render_types.h" +#include "pixelshading.h" +#include "shading.h" +#include "texture.h" +#include "volumetric.h" +#include "volume_precache.h" + +#if defined( _MSC_VER ) && !defined( __cplusplus ) +# define inline __inline +#endif // defined( _MSC_VER ) && !defined( __cplusplus ) + +/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ +/* defined in pipeline.c, is hardcopy of active dynamic allocated Render */ +/* only to be used here in this file, it's for speed */ +extern struct Render R; +/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + + +/* tracing */ + +static int vol_get_bounds(ShadeInput *shi, float *co, float *vec, float *hitco, Isect *isect, int intersect_type) +{ + float maxsize = RE_ray_tree_max_size(R.raytree); + + /* XXX TODO - get raytrace max distance from object instance's bounding box */ + /* need to account for scaling only, but keep coords in camera space... + * below code is WIP and doesn't work! + VecSubf(bb_dim, shi->obi->obr->boundbox[1], shi->obi->obr->boundbox[2]); + Mat3MulVecfl(shi->obi->nmat, bb_dim); + maxsize = VecLength(bb_dim); + */ + + VECCOPY(isect->start, co); + isect->end[0] = co[0] + vec[0] * maxsize; + isect->end[1] = co[1] + vec[1] * maxsize; + isect->end[2] = co[2] + vec[2] * maxsize; + + isect->mode= RE_RAY_MIRROR; + isect->oborig= RAY_OBJECT_SET(&R, shi->obi); + isect->face_last= NULL; + isect->ob_last= 0; + isect->lay= -1; + + if (intersect_type == VOL_BOUNDS_DEPTH) isect->faceorig= (RayFace*)shi->vlr; + else if (intersect_type == VOL_BOUNDS_SS) isect->faceorig= NULL; + + if(RE_ray_tree_intersect(R.raytree, isect)) + { + hitco[0] = isect->start[0] + isect->labda*isect->vec[0]; + hitco[1] = isect->start[1] + isect->labda*isect->vec[1]; + hitco[2] = isect->start[2] + isect->labda*isect->vec[2]; + return 1; + } else { + return 0; + } +} + +static void shade_intersection(ShadeInput *shi, float *col, Isect *is) +{ + ShadeInput shi_new; + ShadeResult shr_new; + + memset(&shi_new, 0, sizeof(ShadeInput)); + + shi_new.mask= shi->mask; + shi_new.osatex= shi->osatex; + shi_new.thread= shi->thread; + shi_new.depth = shi->depth + 1; + shi_new.volume_depth= shi->volume_depth + 1; + shi_new.xs= shi->xs; + shi_new.ys= shi->ys; + shi_new.lay= shi->lay; + shi_new.passflag= SCE_PASS_COMBINED; /* result of tracing needs no pass info */ + shi_new.combinedflag= 0xFFFFFF; /* ray trace does all options */ + shi_new.light_override= shi->light_override; + shi_new.mat_override= shi->mat_override; + + VECCOPY(shi_new.camera_co, is->start); + + memset(&shr_new, 0, sizeof(ShadeResult)); + + /* hardcoded limit of 100 for now - prevents problems in weird geometry */ + if (shi->volume_depth < 100) { + shade_ray(is, &shi_new, &shr_new); + } + + VecCopyf(col, shr_new.combined); + col[3] = shr_new.alpha; +} + +static void vol_trace_behind(ShadeInput *shi, VlakRen *vlr, float *co, float *col) +{ + Isect isect; + float maxsize = RE_ray_tree_max_size(R.raytree); + + VECCOPY(isect.start, co); + isect.end[0] = isect.start[0] + shi->view[0] * maxsize; + isect.end[1] = isect.start[1] + shi->view[1] * maxsize; + isect.end[2] = isect.start[2] + shi->view[2] * maxsize; + + isect.faceorig= (RayFace *)vlr; + + isect.mode= RE_RAY_MIRROR; + isect.oborig= RAY_OBJECT_SET(&R, shi->obi); + isect.face_last= NULL; + isect.ob_last= 0; + isect.lay= -1; + + /* check to see if there's anything behind the volume, otherwise shade the sky */ + if(RE_ray_tree_intersect(R.raytree, &isect)) { + shade_intersection(shi, col, &isect); + } else { + shadeSkyView(col, co, shi->view, NULL, shi->thread); + shadeSunView(col, shi->view); + } +} + +/* input shader data */ + +float vol_get_stepsize(struct ShadeInput *shi, int context) +{ + if (shi->mat->vol.stepsize_type == MA_VOL_STEP_RANDOMIZED) { + /* range between 0.75 and 1.25 */ + const float rnd = 0.5f * BLI_thread_frand(shi->thread) + 0.75f; + + if (context == STEPSIZE_VIEW) + return shi->mat->vol.stepsize * rnd; + else if (context == STEPSIZE_SHADE) + return shi->mat->vol.shade_stepsize * rnd; + } + else { // MA_VOL_STEP_CONSTANT + + if (context == STEPSIZE_VIEW) + return shi->mat->vol.stepsize; + else if (context == STEPSIZE_SHADE) + return shi->mat->vol.shade_stepsize; + } + + return shi->mat->vol.stepsize; +} + +/* trilinear interpolation */ +static void vol_get_precached_scattering(ShadeInput *shi, float *scatter_col, float *co) +{ + VolumePrecache *vp = shi->obi->volume_precache; + float bbmin[3], bbmax[3], dim[3]; + float sample_co[3]; + + if (!vp) return; + + /* convert input coords to 0.0, 1.0 */ + VECCOPY(bbmin, shi->obi->obr->boundbox[0]); + VECCOPY(bbmax, shi->obi->obr->boundbox[1]); + VecSubf(dim, bbmax, bbmin); + + sample_co[0] = ((co[0] - bbmin[0]) / dim[0]); + sample_co[1] = ((co[1] - bbmin[1]) / dim[1]); + sample_co[2] = ((co[2] - bbmin[2]) / dim[2]); + + scatter_col[0] = voxel_sample_trilinear(vp->data_r, vp->res, sample_co); + scatter_col[1] = voxel_sample_trilinear(vp->data_g, vp->res, sample_co); + scatter_col[2] = voxel_sample_trilinear(vp->data_b, vp->res, sample_co); +} + +float vol_get_density(struct ShadeInput *shi, float *co) +{ + float density = shi->mat->vol.density; + float density_scale = shi->mat->vol.density_scale; + float col[3] = {0.0, 0.0, 0.0}; + + do_volume_tex(shi, co, MAP_DENSITY, col, &density); + + return density * density_scale; +} + +/* scattering multiplier, values above 1.0 are non-physical, + * but can be useful to tweak lighting */ +float vol_get_scattering_fac(ShadeInput *shi, float *co) +{ + float scatter = shi->mat->vol.scattering; + float col[3] = {0.0, 0.0, 0.0}; + + do_volume_tex(shi, co, MAP_SCATTERING, col, &scatter); + + return scatter; +} + +/* compute emission component, amount of radiance to add per segment + * can be textured with 'emit' */ +void vol_get_emission(ShadeInput *shi, float *emission_col, float *co, float density) +{ + float emission = shi->mat->vol.emission; + VECCOPY(emission_col, shi->mat->vol.emission_col); + + do_volume_tex(shi, co, MAP_EMISSION+MAP_EMISSION_COL, emission_col, &emission); + + emission_col[0] = emission_col[0] * emission * density; + emission_col[1] = emission_col[1] * emission * density; + emission_col[2] = emission_col[2] * emission * density; +} + +void vol_get_absorption(ShadeInput *shi, float *absorb_col, float *co) +{ + float absorption = shi->mat->vol.absorption; + VECCOPY(absorb_col, shi->mat->vol.absorption_col); + + do_volume_tex(shi, co, MAP_ABSORPTION+MAP_ABSORPTION_COL, absorb_col, &absorption); + + absorb_col[0] = (1.0f - absorb_col[0]) * absorption; + absorb_col[1] = (1.0f - absorb_col[1]) * absorption; + absorb_col[2] = (1.0f - absorb_col[2]) * absorption; +} + + +/* phase function - determines in which directions the light + * is scattered in the volume relative to incoming direction + * and view direction */ +float vol_get_phasefunc(ShadeInput *shi, short phasefunc_type, float g, float *w, float *wp) +{ + const float costheta = Inpf(w, wp); + const float scale = M_PI; + + /* + * Scale constant is required, since Blender's shading system doesn't normalise for + * energy conservation - eg. scaling by 1/pi for a lambert shader. + * This makes volumes darker than other solid objects, for the same lighting intensity. + * To correct this, scale up the phase function values + * until Blender's shading system supports this better. --matt + */ + + switch (phasefunc_type) { + case MA_VOL_PH_MIEHAZY: + return scale * (0.5f + 4.5f * powf(0.5 * (1.f + costheta), 8.f)) / (4.f*M_PI); + case MA_VOL_PH_MIEMURKY: + return scale * (0.5f + 16.5f * powf(0.5 * (1.f + costheta), 32.f)) / (4.f*M_PI); + case MA_VOL_PH_RAYLEIGH: + return scale * 3.f/(16.f*M_PI) * (1 + costheta * costheta); + case MA_VOL_PH_HG: + return scale * (1.f / (4.f * M_PI) * (1.f - g*g) / powf(1.f + g*g - 2.f * g * costheta, 1.5f)); + case MA_VOL_PH_SCHLICK: + { + const float k = 1.55f * g - .55f * g * g * g; + const float kcostheta = k * costheta; + return scale * (1.f / (4.f * M_PI) * (1.f - k*k) / ((1.f - kcostheta) * (1.f - kcostheta))); + } + case MA_VOL_PH_ISOTROPIC: + default: + return scale * (1.f / (4.f * M_PI)); + } +} + +/* Compute attenuation, otherwise known as 'optical thickness', extinction, or tau. + * Used in the relationship Transmittance = e^(-attenuation) + */ +void vol_get_attenuation_seg(ShadeInput *shi, float *transmission, float stepsize, float *co, float density) +{ + /* input density = density at co */ + float tau[3] = {0.f, 0.f, 0.f}; + float absorb_col[3]; + + vol_get_absorption(shi, absorb_col, co); + + /* homogenous volume within the sampled distance */ + tau[0] = stepsize * density * absorb_col[0]; + tau[1] = stepsize * density * absorb_col[1]; + tau[2] = stepsize * density * absorb_col[2]; + + transmission[0] *= exp(-tau[0]); + transmission[1] *= exp(-tau[1]); + transmission[2] *= exp(-tau[2]); +} + +/* Compute attenuation, otherwise known as 'optical thickness', extinction, or tau. + * Used in the relationship Transmittance = e^(-attenuation) + */ +void vol_get_attenuation(ShadeInput *shi, float *transmission, float *co, float *endco, float density, float stepsize) +{ + /* input density = density at co */ + float tau[3] = {0.f, 0.f, 0.f}; + float absorb_col[3]; + int s, nsteps; + float step_vec[3], step_sta[3], step_end[3]; + const float dist = VecLenf(co, endco); + + vol_get_absorption(shi, absorb_col, co); + + nsteps = (int)((dist / stepsize) + 0.5); + + VecSubf(step_vec, endco, co); + VecMulf(step_vec, 1.0f / nsteps); + + VecCopyf(step_sta, co); + VecAddf(step_end, step_sta, step_vec); + + for (s = 0; s < nsteps; s++) { + if (s > 0) + density = vol_get_density(shi, step_sta); + + tau[0] += stepsize * density; + tau[1] += stepsize * density; + tau[2] += stepsize * density; + + if (s < nsteps-1) { + VecCopyf(step_sta, step_end); + VecAddf(step_end, step_end, step_vec); + } + } + VecMulVecf(tau, tau, absorb_col); + + transmission[0] *= exp(-tau[0]); + transmission[1] *= exp(-tau[1]); + transmission[2] *= exp(-tau[2]); +} + +void vol_shade_one_lamp(struct ShadeInput *shi, float *co, LampRen *lar, float *lacol, float stepsize, float density) +{ + float visifac, lv[3], lampdist; + float tr[3]={1.0,1.0,1.0}; + float hitco[3], *atten_co; + float p; + float scatter_fac; + float shade_stepsize = vol_get_stepsize(shi, STEPSIZE_SHADE); + + if (lar->mode & LA_LAYER) if((lar->lay & shi->obi->lay)==0) return; + if ((lar->lay & shi->lay)==0) return; + if (lar->energy == 0.0) return; + + if ((visifac= lamp_get_visibility(lar, co, lv, &lampdist)) == 0.f) return; + + VecCopyf(lacol, &lar->r); + + if(lar->mode & LA_TEXTURE) { + shi->osatex= 0; + do_lamp_tex(lar, lv, shi, lacol, LA_TEXTURE); + } + + VecMulf(lacol, visifac*lar->energy); + + if (ELEM(lar->type, LA_SUN, LA_HEMI)) + VECCOPY(lv, lar->vec); + VecMulf(lv, -1.0f); + + if (shi->mat->vol.shade_type != MA_VOL_SHADE_NONE) { + Isect is; + + /* find minimum of volume bounds, or lamp coord */ + if (vol_get_bounds(shi, co, lv, hitco, &is, VOL_BOUNDS_SS)) { + float dist = VecLenf(co, hitco); + VlakRen *vlr = (VlakRen *)is.face; + + /* simple internal shadowing */ + if (vlr->mat->material_type == MA_TYPE_SURFACE) { + lacol[0] = lacol[1] = lacol[2] = 0.0f; + return; + } + + if (ELEM(lar->type, LA_SUN, LA_HEMI)) + /* infinite lights, can never be inside volume */ + atten_co = hitco; + else if ( lampdist < dist ) { + atten_co = lar->co; + } else + atten_co = hitco; + + vol_get_attenuation(shi, tr, co, atten_co, density, shade_stepsize); + + VecMulVecf(lacol, lacol, tr); + } + else { + /* Point is on the outside edge of the volume, + * therefore no attenuation, full transmission. + * Radiance from lamp remains unchanged */ + } + } + + p = vol_get_phasefunc(shi, shi->mat->vol.phasefunc_type, shi->mat->vol.phasefunc_g, shi->view, lv); + VecMulf(lacol, p); + + scatter_fac = vol_get_scattering_fac(shi, co); + VecMulf(lacol, scatter_fac); +} + +/* single scattering only for now */ +void vol_get_scattering(ShadeInput *shi, float *scatter_col, float *co, float stepsize, float density) +{ + ListBase *lights; + GroupObject *go; + LampRen *lar; + + scatter_col[0] = scatter_col[1] = scatter_col[2] = 0.f; + + lights= get_lights(shi); + for(go=lights->first; go; go= go->next) + { + float lacol[3] = {0.f, 0.f, 0.f}; + lar= go->lampren; + + if (lar) { + vol_shade_one_lamp(shi, co, lar, lacol, stepsize, density); + VecAddf(scatter_col, scatter_col, lacol); + } + } +} + + +/* +The main volumetric integrator, using an emission/absorption/scattering model. + +Incoming radiance = + +outgoing radiance from behind surface * beam transmittance/attenuation ++ added radiance from all points along the ray due to participating media + --> radiance for each segment = + (radiance added by scattering + radiance added by emission) * beam transmittance/attenuation +*/ +static void volumeintegrate(struct ShadeInput *shi, float *col, float *co, float *endco) +{ + float tr[3] = {1.0f, 1.0f, 1.0f}; + float radiance[3] = {0.f, 0.f, 0.f}, d_radiance[3] = {0.f, 0.f, 0.f}; + float stepsize = vol_get_stepsize(shi, STEPSIZE_VIEW); + int nsteps, s; + float emit_col[3], scatter_col[3] = {0.0, 0.0, 0.0}; + float stepvec[3], step_sta[3], step_end[3], step_mid[3]; + float density; + const float depth_cutoff = shi->mat->vol.depth_cutoff; + + /* ray marching */ + nsteps = (int)((VecLenf(co, endco) / stepsize) + 0.5); + + VecSubf(stepvec, endco, co); + VecMulf(stepvec, 1.0f / nsteps); + VecCopyf(step_sta, co); + VecAddf(step_end, step_sta, stepvec); + + /* get radiance from all points along the ray due to participating media */ + for (s = 0; s < nsteps; s++) { + + density = vol_get_density(shi, step_sta); + + /* there's only any use in shading here if there's actually some density to shade! */ + if (density > 0.01f) { + + /* transmittance component (alpha) */ + vol_get_attenuation_seg(shi, tr, stepsize, co, density); + + step_mid[0] = step_sta[0] + (stepvec[0] * 0.5); + step_mid[1] = step_sta[1] + (stepvec[1] * 0.5); + step_mid[2] = step_sta[2] + (stepvec[2] * 0.5); + + /* incoming light via emission or scattering (additive) */ + vol_get_emission(shi, emit_col, step_mid, density); + + if (using_lightcache(shi->mat)) { + vol_get_precached_scattering(shi, scatter_col, step_mid); + } else + vol_get_scattering(shi, scatter_col, step_mid, stepsize, density); + + VecMulf(scatter_col, density); + VecAddf(d_radiance, emit_col, scatter_col); + + /* Lv += Tr * (Lve() + Ld) */ + VecMulVecf(d_radiance, tr, d_radiance); + VecMulf(d_radiance, stepsize); + + VecAddf(radiance, radiance, d_radiance); + } + + VecCopyf(step_sta, step_end); + VecAddf(step_end, step_end, stepvec); + + /* luminance rec. 709 */ + if ((0.2126*tr[0] + 0.7152*tr[1] + 0.0722*tr[2]) < depth_cutoff) break; + } + + /* multiply original color (behind volume) with beam transmittance over entire distance */ + VecMulVecf(col, tr, col); + VecAddf(col, col, radiance); + + /* alpha <-- transmission luminance */ + col[3] = 1.0f -(0.2126*tr[0] + 0.7152*tr[1] + 0.0722*tr[2]); +} + +/* the main entry point for volume shading */ +static void volume_trace(struct ShadeInput *shi, struct ShadeResult *shr, int inside_volume) +{ + float hitco[3], col[4] = {0.f,0.f,0.f,0.f}; + float *startco, *endco; + int trace_behind = 1; + const int ztransp= ((shi->depth==0) && (shi->mat->mode & MA_TRANSP) && (shi->mat->mode & MA_ZTRANSP)); + Isect is; + + /* check for shading an internal face a volume object directly */ + if (inside_volume == VOL_SHADE_INSIDE) + trace_behind = 0; + else if (inside_volume == VOL_SHADE_OUTSIDE) { + if (shi->flippednor) + inside_volume = VOL_SHADE_INSIDE; + } + + if (ztransp && inside_volume == VOL_SHADE_INSIDE) { + MatInside *mi; + int render_this=0; + + /* don't render the backfaces of ztransp volume materials. + + * volume shading renders the internal volume from between the + * near view intersection of the solid volume to the + * intersection on the other side, as part of the shading of + * the front face. + + * Because ztransp renders both front and back faces independently + * this will double up, so here we prevent rendering the backface as well, + * which would otherwise render the volume in between the camera and the backface + * --matt */ + + for (mi=R.render_volumes_inside.first; mi; mi=mi->next) { + /* weak... */ + if (mi->ma == shi->mat) render_this=1; + } + if (!render_this) return; + } + + + if (inside_volume == VOL_SHADE_INSIDE) + { + startco = shi->camera_co; + endco = shi->co; + + if (trace_behind) { + if (!ztransp) + /* trace behind the volume object */ + vol_trace_behind(shi, shi->vlr, endco, col); + } else { + /* we're tracing through the volume between the camera + * and a solid surface, so use that pre-shaded radiance */ + QUATCOPY(col, shr->combined); + } + + /* shade volume from 'camera' to 1st hit point */ + volumeintegrate(shi, col, startco, endco); + } + /* trace to find a backface, the other side bounds of the volume */ + /* (ray intersect ignores front faces here) */ + else if (vol_get_bounds(shi, shi->co, shi->view, hitco, &is, VOL_BOUNDS_DEPTH)) + { + VlakRen *vlr = (VlakRen *)is.face; + + startco = shi->co; + endco = hitco; + + if (!ztransp) { + /* if it's another face in the same material */ + if (vlr->mat == shi->mat) { + /* trace behind the 2nd (raytrace) hit point */ + vol_trace_behind(shi, (VlakRen *)is.face, endco, col); + } else { + shade_intersection(shi, col, &is); + } + } + + /* shade volume from 1st hit point to 2nd hit point */ + volumeintegrate(shi, col, startco, endco); + } + + if (ztransp) + col[3] = col[3]>1.f?1.f:col[3]; + else + col[3] = 1.f; + + VecCopyf(shr->combined, col); + shr->alpha = col[3]; + + VECCOPY(shr->diff, shr->combined); +} + +/* Traces a shadow through the object, + * pretty much gets the transmission over a ray path */ +void shade_volume_shadow(struct ShadeInput *shi, struct ShadeResult *shr, struct Isect *last_is) +{ + float hitco[3]; + float tr[3] = {1.0,1.0,1.0}; + Isect is; + float shade_stepsize = vol_get_stepsize(shi, STEPSIZE_SHADE); + float *startco, *endco; + float density=0.f; + + memset(shr, 0, sizeof(ShadeResult)); + + /* if 1st hit normal is facing away from the camera, + * then we're inside the volume already. */ + if (shi->flippednor) { + startco = last_is->start; + endco = shi->co; + } + /* trace to find a backface, the other side bounds of the volume */ + /* (ray intersect ignores front faces here) */ + else if (vol_get_bounds(shi, shi->co, shi->view, hitco, &is, VOL_BOUNDS_DEPTH)) { + startco = shi->co; + endco = hitco; + } + else { + shr->combined[0] = shr->combined[1] = shr->combined[2] = 0.f; + shr->alpha = shr->combined[3] = 1.f; + return; + } + + density = vol_get_density(shi, startco); + vol_get_attenuation(shi, tr, startco, endco, density, shade_stepsize); + + VecCopyf(shr->combined, tr); + shr->combined[3] = 1.0f -(0.2126*tr[0] + 0.7152*tr[1] + 0.0722*tr[2]); + shr->alpha = shr->combined[3]; +} + + +/* delivers a fully filled in ShadeResult, for all passes */ +void shade_volume_outside(ShadeInput *shi, ShadeResult *shr) +{ + memset(shr, 0, sizeof(ShadeResult)); + volume_trace(shi, shr, VOL_SHADE_OUTSIDE); +} + + +void shade_volume_inside(ShadeInput *shi, ShadeResult *shr) +{ + MatInside *m; + Material *mat_backup; + + //if (BLI_countlist(&R.render_volumes_inside) == 0) return; + + /* XXX: extend to multiple volumes perhaps later */ + mat_backup = shi->mat; + m = R.render_volumes_inside.first; + shi->mat = m->ma; + + volume_trace(shi, shr, VOL_SHADE_INSIDE); + + shi->mat = mat_backup; +} diff --git a/source/blender/render/intern/source/voxeldata.c b/source/blender/render/intern/source/voxeldata.c new file mode 100644 index 00000000000..836faeb05b9 --- /dev/null +++ b/source/blender/render/intern/source/voxeldata.c @@ -0,0 +1,342 @@ +/** + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): Raul Fernandez Hernandez (Farsthary), Matt Ebb. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include <math.h> +#include <stdlib.h> +#include <stdio.h> + +#include "MEM_guardedalloc.h" + +#include "BLI_arithb.h" +#include "BLI_blenlib.h" +#include "BLI_voxel.h" + +#include "IMB_imbuf.h" +#include "IMB_imbuf_types.h" + +#include "BKE_global.h" +#include "BKE_image.h" +#include "BKE_main.h" +#include "BKE_modifier.h" + +#include "smoke_API.h" + +#include "DNA_texture_types.h" +#include "DNA_object_types.h" +#include "DNA_modifier_types.h" +#include "DNA_smoke_types.h" + + +#include "render_types.h" +#include "renderdatabase.h" +#include "texture.h" +#include "voxeldata.h" + +void load_frame_blendervoxel(FILE *fp, float *F, int size, int frame, int offset) +{ + fseek(fp,frame*size*sizeof(float)+offset,0); + fread(F,sizeof(float),size,fp); +} + +void load_frame_raw8(FILE *fp, float *F, int size, int frame) +{ + char *tmp; + int i; + + tmp = (char *)MEM_mallocN(sizeof(char)*size, "temporary voxel file reading storage"); + + fseek(fp,(frame-1)*size*sizeof(char),0); + fread(tmp, sizeof(char), size, fp); + + for (i=0; i<size; i++) { + F[i] = (float)tmp[i] / 256.f; + } + MEM_freeN(tmp); +} + +void load_frame_image_sequence(Render *re, VoxelData *vd, Tex *tex) +{ + ImBuf *ibuf; + Image *ima = tex->ima; + ImageUser *iuser = &tex->iuser; + int x=0, y=0, z=0; + float *rf; + + if (!ima || !iuser) return; + + ima->source = IMA_SRC_SEQUENCE; + iuser->framenr = 1 + iuser->offset; + + /* find the first valid ibuf and use it to initialise the resolution of the data set */ + /* need to do this in advance so we know how much memory to allocate */ + ibuf= BKE_image_get_ibuf(ima, iuser); + while (!ibuf && (iuser->framenr < iuser->frames)) { + iuser->framenr++; + ibuf= BKE_image_get_ibuf(ima, iuser); + } + if (!ibuf) return; + if (!ibuf->rect_float) IMB_float_from_rect(ibuf); + + vd->flag |= TEX_VD_STILL; + vd->resol[0] = ibuf->x; + vd->resol[1] = ibuf->y; + vd->resol[2] = iuser->frames; + vd->dataset = MEM_mapallocN(sizeof(float)*(vd->resol[0])*(vd->resol[1])*(vd->resol[2]), "voxel dataset"); + + for (z=0; z < iuser->frames; z++) + { + /* get a new ibuf for each frame */ + if (z > 0) { + iuser->framenr++; + ibuf= BKE_image_get_ibuf(ima, iuser); + if (!ibuf) break; + if (!ibuf->rect_float) IMB_float_from_rect(ibuf); + } + rf = ibuf->rect_float; + + for (y=0; y < ibuf->y; y++) + { + for (x=0; x < ibuf->x; x++) + { + /* currently converted to monchrome */ + vd->dataset[ V_I(x, y, z, vd->resol) ] = (rf[0] + rf[1] + rf[2])*0.333f; + rf +=4; + } + } + + BKE_image_free_anim_ibufs(ima, iuser->framenr); + } +} + +void write_voxeldata_header(struct VoxelDataHeader *h, FILE *fp) +{ + fwrite(h,sizeof(struct VoxelDataHeader),1,fp); +} + +void read_voxeldata_header(FILE *fp, struct VoxelData *vd) +{ + VoxelDataHeader *h=(VoxelDataHeader *)MEM_mallocN(sizeof(VoxelDataHeader), "voxel data header"); + + rewind(fp); + fread(h,sizeof(VoxelDataHeader),1,fp); + + vd->resol[0]=h->resolX; + vd->resol[1]=h->resolY; + vd->resol[2]=h->resolZ; + + MEM_freeN(h); +} + +void init_frame_smoke(Render *re, VoxelData *vd, Tex *tex) +{ + Object *ob; + ModifierData *md; + + vd->dataset = NULL; + if (vd->object == NULL) return; + ob= vd->object; + + /* draw code for smoke */ + if( (md = (ModifierData *)modifiers_findByType(ob, eModifierType_Smoke)) ) + { + SmokeModifierData *smd = (SmokeModifierData *)md; + + if(smd->domain && smd->domain->fluid) { + //int big = (smd->domain->flags & MOD_SMOKE_HIGHRES); + int big=0; + + if (big) { + //smoke_turbulence_get_res(smd->domain->wt, vd->resol); + //vd->dataset = smoke_turbulence_get_density(smd->domain->wt); + } else { + VECCOPY(vd->resol, smd->domain->res); + vd->dataset = smoke_get_density(smd->domain->fluid); + } + } + } +} + +void cache_voxeldata(struct Render *re,Tex *tex) +{ + VoxelData *vd = tex->vd; + FILE *fp; + int size; + int curframe; + + if (!vd) return; + + /* image sequence gets special treatment */ + if (vd->file_format == TEX_VD_IMAGE_SEQUENCE) { + load_frame_image_sequence(re, vd, tex); + return; + } else if (vd->file_format == TEX_VD_SMOKE) { + init_frame_smoke(re, vd, tex); + return; + } + + if (!BLI_exists(vd->source_path)) return; + fp = fopen(vd->source_path,"rb"); + if (!fp) return; + + if (vd->file_format == TEX_VD_BLENDERVOXEL) + read_voxeldata_header(fp, vd); + + size = (vd->resol[0])*(vd->resol[1])*(vd->resol[2]); + vd->dataset = MEM_mapallocN(sizeof(float)*size, "voxel dataset"); + + if (vd->flag & TEX_VD_STILL) curframe = vd->still_frame; + else curframe = re->r.cfra; + + switch(vd->file_format) { + case TEX_VD_BLENDERVOXEL: + load_frame_blendervoxel(fp, vd->dataset, size, curframe-1, sizeof(VoxelDataHeader)); + break; + case TEX_VD_RAW_8BIT: + load_frame_raw8(fp, vd->dataset, size, curframe); + break; + } + + fclose(fp); +} + +void make_voxeldata(struct Render *re) +{ + Tex *tex; + + if(re->scene->r.scemode & R_PREVIEWBUTS) + return; + + re->i.infostr= "Loading voxel datasets"; + re->stats_draw(re->sdh, &re->i); + + /* XXX: should be doing only textures used in this render */ + for (tex= G.main->tex.first; tex; tex= tex->id.next) { + if(tex->id.us && tex->type==TEX_VOXELDATA) { + cache_voxeldata(re, tex); + } + } + + re->i.infostr= NULL; + re->stats_draw(re->sdh, &re->i); + +} + +static void free_voxeldata_one(Render *re, Tex *tex) +{ + VoxelData *vd = tex->vd; + + if (vd->dataset) { + MEM_freeN(vd->dataset); + vd->dataset = NULL; + } +} + + +void free_voxeldata(Render *re) +{ + Tex *tex; + + if(re->scene->r.scemode & R_PREVIEWBUTS) + return; + + for (tex= G.main->tex.first; tex; tex= tex->id.next) { + if(tex->id.us && tex->type==TEX_VOXELDATA) { + free_voxeldata_one(re, tex); + } + } +} + +int voxeldatatex(struct Tex *tex, float *texvec, struct TexResult *texres) +{ + int retval = TEX_INT; + VoxelData *vd = tex->vd; + float co[3], offset[3] = {0.5, 0.5, 0.5}; + + if ((!vd) || (vd->dataset==NULL)) { + texres->tin = 0.0f; + return 0; + } + + /* scale lookup from 0.0-1.0 (original location) to -1.0, 1.0, consistent with image texture tex coords */ + /* in implementation this works backwards, bringing sample locations from -1.0, 1.0 + * to the range 0.0, 1.0, before looking up in the voxel structure. */ + VecCopyf(co, texvec); + VecMulf(co, 0.5f); + VecAddf(co, co, offset); + + /* co is now in the range 0.0, 1.0 */ + switch (tex->extend) { + case TEX_CLIP: + { + if ((co[0] < 0.f || co[0] > 1.f) || (co[1] < 0.f || co[1] > 1.f) || (co[2] < 0.f || co[2] > 1.f)) { + texres->tin = 0.f; + return retval; + } + break; + } + case TEX_REPEAT: + { + co[0] = co[0] - floor(co[0]); + co[1] = co[1] - floor(co[1]); + co[2] = co[2] - floor(co[2]); + break; + } + case TEX_EXTEND: + { + CLAMP(co[0], 0.f, 1.f); + CLAMP(co[1], 0.f, 1.f); + CLAMP(co[2], 0.f, 1.f); + break; + } + } + + switch (vd->interp_type) { + case TEX_VD_NEARESTNEIGHBOR: + texres->tin = voxel_sample_nearest(vd->dataset, vd->resol, co); + break; + case TEX_VD_LINEAR: + texres->tin = voxel_sample_trilinear(vd->dataset, vd->resol, co); + break; + case TEX_VD_TRICUBIC: + texres->tin = voxel_sample_tricubic(vd->dataset, vd->resol, co); + break; + } + + texres->tin *= vd->int_multiplier; + BRICONT; + + texres->tr = texres->tin; + texres->tg = texres->tin; + texres->tb = texres->tin; + texres->ta = texres->tin; + BRICONTRGB; + + return retval; +} + + diff --git a/source/blender/render/intern/source/zbuf.c b/source/blender/render/intern/source/zbuf.c index 4436f3aa047..53a05dd0d67 100644 --- a/source/blender/render/intern/source/zbuf.c +++ b/source/blender/render/intern/source/zbuf.c @@ -2152,7 +2152,7 @@ void zbuffer_solid(RenderPart *pa, RenderLayer *rl, void(*fillfunc)(RenderPart*, if(obi->lay & lay) { if(vlr->mat!=ma) { ma= vlr->mat; - nofill= ma->mode & (MA_ZTRA|MA_ONLYCAST); + nofill= (ma->mode & MA_ONLYCAST) || ((ma->mode & MA_TRANSP) && (ma->mode & MA_ZTRANSP)); env= (ma->mode & MA_ENV); wire= (ma->material_type == MA_TYPE_WIRE); @@ -3306,7 +3306,7 @@ static int zbuffer_abuf(RenderPart *pa, APixstr *APixbuf, ListBase *apsmbase, Re if(vlr->mat!=ma) { ma= vlr->mat; - dofill= (ma->mode & MA_ZTRA) && !(ma->mode & MA_ONLYCAST); + dofill= ((ma->mode & MA_TRANSP) && (ma->mode & MA_ZTRANSP)) && !(ma->mode & MA_ONLYCAST); } if(dofill) { @@ -3480,7 +3480,7 @@ void merge_transp_passes(RenderLayer *rl, ShadeResult *shr) col= shr->refl; break; case SCE_PASS_RADIO: - col= shr->rad; + col= NULL; // removed shr->rad; break; case SCE_PASS_REFRACT: col= shr->refr; @@ -3582,7 +3582,7 @@ void add_transp_passes(RenderLayer *rl, int offset, ShadeResult *shr, float alph col= shr->refr; break; case SCE_PASS_RADIO: - col= shr->rad; + col= NULL; // removed shr->rad; break; case SCE_PASS_NORMAL: col= shr->nor; @@ -3817,8 +3817,8 @@ static int addtosamp_shr(ShadeResult *samp_shr, ShadeSample *ssamp, int addpassf if(addpassflag & SCE_PASS_REFRACT) addvecmul(samp_shr->refr, shr->refr, fac); - if(addpassflag & SCE_PASS_RADIO) - addvecmul(samp_shr->rad, shr->rad, fac); + /* removed if(addpassflag & SCE_PASS_RADIO) + addvecmul(samp_shr->rad, shr->rad, fac);*/ if(addpassflag & SCE_PASS_MIST) samp_shr->mist= samp_shr->mist+fac*shr->mist; diff --git a/source/blender/windowmanager/CMakeLists.txt b/source/blender/windowmanager/CMakeLists.txt index 088bdc99687..26d4ab20356 100644 --- a/source/blender/windowmanager/CMakeLists.txt +++ b/source/blender/windowmanager/CMakeLists.txt @@ -31,15 +31,15 @@ SET(INC . ../../../intern/guardedalloc ../../../intern/memutil ../blenlib ../makesdna ../makesrna ../blenkernel ../include ../imbuf ../render/extern/include - ../../../intern/bsp/extern ../radiosity/extern/include + ../../../intern/bsp/extern ../../../intern/decimation/extern ../blenloader - ../../kernel/gen_system ../../../intern/SoundSystem ../readstreamglue - ../quicktime ../../../intern/elbeem/extern + ../../kernel/gen_system ../readstreamglue + ../../../intern/elbeem/extern ../../../intern/ghost ../../../intern/opennl/extern ../../../extern/glew/include ../nodes ../gpu ../blenfont - ${SDL_INC} + ${OPENGL_INCLUDE_DIR} ) IF(WITH_INTERNATIONAL) @@ -51,7 +51,7 @@ IF(WITH_OPENEXR) ENDIF(WITH_OPENEXR) IF(WITH_QUICKTIME) - SET(INC ${INC} ${QUICKTIME_INC}) + SET(INC ${INC} ../quicktime ${QUICKTIME_INC}) ADD_DEFINITIONS(-DWITH_QUICKTIME) ENDIF(WITH_QUICKTIME) diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index decd855eae0..0f5558382c4 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -172,7 +172,7 @@ void WM_operator_properties_free(struct PointerRNA *ptr); void WM_operator_properties_filesel(struct wmOperatorType *ot, int filter); /* operator as a python command (resultuing string must be free'd) */ -char *WM_operator_pystring(struct wmOperatorType *ot, struct PointerRNA *opptr, int all_args); +char *WM_operator_pystring(struct bContext *C, struct wmOperatorType *ot, struct PointerRNA *opptr, int all_args); void WM_operator_bl_idname(char *to, const char *from); void WM_operator_py_idname(char *to, const char *from); diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h index a083d589d31..42ee6e926fc 100644 --- a/source/blender/windowmanager/WM_types.h +++ b/source/blender/windowmanager/WM_types.h @@ -133,6 +133,8 @@ typedef struct wmNotifier { #define NC_FILE (14<<24) #define NC_ANIMATION (15<<24) #define NC_CONSOLE (16<<24) +#define NC_NODE (17<<24) +#define NC_INFO (18<<24) /* data type, 256 entries is enough, it can overlap */ #define NOTE_DATA 0x00FF0000 @@ -144,8 +146,9 @@ typedef struct wmNotifier { /* NC_SCREEN screen */ #define ND_SCREENBROWSE (1<<16) -#define ND_SCREENCAST (2<<16) -#define ND_ANIMPLAY (3<<16) +#define ND_SCREENDELETE (2<<16) +#define ND_SCREENCAST (3<<16) +#define ND_ANIMPLAY (4<<16) /* NC_SCENE Scene */ #define ND_SCENEBROWSE (1<<16) @@ -160,6 +163,7 @@ typedef struct wmNotifier { #define ND_RENDER_RESULT (10<<16) #define ND_COMPO_RESULT (11<<16) #define ND_KEYINGSET (12<<16) +#define ND_SCENEDELETE (13<<16) /* NC_OBJECT Object */ #define ND_TRANSFORM (16<<16) @@ -279,10 +283,17 @@ typedef struct wmTimer { double delta; /* time since previous step in seconds */ double ltime; /* internal, last time timer was activated */ + double ntime; /* internal, next time we want to activate the timer */ + double stime; /* internal, when the timer started */ int sleep; /* internal, put timers to sleep when needed */ } wmTimer; +/* **************** Paint Cursor ******************* */ + +typedef void (*wmPaintCursorDraw)(struct bContext *C, int, int, void *customdata); + + /* ****************** Messages ********************* */ enum { diff --git a/source/blender/windowmanager/intern/Makefile b/source/blender/windowmanager/intern/Makefile index 8f0f47c52d0..f4d65975d43 100644 --- a/source/blender/windowmanager/intern/Makefile +++ b/source/blender/windowmanager/intern/Makefile @@ -44,7 +44,7 @@ CPPFLAGS += -I$(NAN_PYTHON)/include/python$(NAN_PYTHON_VERSION) CPPFLAGS += -I$(NAN_GHOST)/include CPPFLAGS += -I$(NAN_ELBEEM)/include -CPPFLAGS += -I$(NAN_SOUNDSYSTEM)/include $(NAN_SDLCFLAGS) +CPPFLAGS += $(NAN_SDLCFLAGS) # modules CPPFLAGS += -I../../editors/include @@ -58,7 +58,6 @@ CPPFLAGS += -I../../imbuf CPPFLAGS += -I../../blenloader CPPFLAGS += -I../../gpu CPPFLAGS += -I../../render/extern/include -CPPFLAGS += -I../../radiosity/extern/include CPPFLAGS += -I../../../kernel/gen_system CPPFLAGS += -I../../blenfont diff --git a/source/blender/windowmanager/intern/wm.c b/source/blender/windowmanager/intern/wm.c index d70a69c838d..bdb1877e77b 100644 --- a/source/blender/windowmanager/intern/wm.c +++ b/source/blender/windowmanager/intern/wm.c @@ -105,7 +105,7 @@ void wm_operator_register(bContext *C, wmOperator *op) /* Report the string representation of the operator */ - buf = WM_operator_pystring(op->type, op->ptr, 1); + buf = WM_operator_pystring(C, op->type, op->ptr, 1); BKE_report(CTX_wm_reports(C), RPT_OPERATOR, buf); MEM_freeN(buf); diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index d40e6c60bfd..6c34ed6f902 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -52,6 +52,7 @@ #include "BKE_pointcache.h" #include "ED_fileselect.h" +#include "ED_info.h" #include "ED_screen.h" #include "ED_space_api.h" #include "ED_util.h" @@ -129,7 +130,7 @@ static wmNotifier *wm_notifier_next(wmWindowManager *wm) void wm_event_do_notifiers(bContext *C) { wmWindowManager *wm= CTX_wm_manager(C); - wmNotifier *note; + wmNotifier *note, *next; wmWindow *win; if(wm==NULL) @@ -141,7 +142,9 @@ void wm_event_do_notifiers(bContext *C) CTX_wm_window_set(C, win); - for(note= wm->queue.first; note; note= note->next) { + for(note= wm->queue.first; note; note= next) { + next= note->next; + if(note->category==NC_WM) { if( ELEM(note->data, ND_FILEREAD, ND_FILESAVE)) { wm->file_saved= 1; @@ -156,16 +159,28 @@ void wm_event_do_notifiers(bContext *C) ED_screen_set(C, note->reference); // XXX hrms, think this over! printf("screen set %p\n", note->reference); } + else if(note->data==ND_SCREENDELETE) { + ED_screen_delete(C, note->reference); // XXX hrms, think this over! + printf("screen delete %p\n", note->reference); + } } else if(note->category==NC_SCENE) { if(note->data==ND_SCENEBROWSE) { ED_screen_set_scene(C, note->reference); // XXX hrms, think this over! printf("scene set %p\n", note->reference); } + if(note->data==ND_SCENEDELETE) { + ED_screen_delete_scene(C, note->reference); // XXX hrms, think this over! + printf("scene delete %p\n", note->reference); + } else if(note->data==ND_FRAME) do_anim= 1; } } + if(note->category == NC_SCENE || note->category == NC_OBJECT) { + ED_info_stats_clear(CTX_data_scene(C)); + WM_event_add_notifier(C, NC_INFO, NULL); + } } if(do_anim) { /* depsgraph gets called, might send more notifiers */ @@ -362,7 +377,7 @@ static wmOperator *wm_operator_create(wmWindowManager *wm, wmOperatorType *ot, P static void wm_operator_print(wmOperator *op) { - char *buf = WM_operator_pystring(op->type, op->ptr, 1); + char *buf = WM_operator_pystring(NULL, op->type, op->ptr, 1); printf("%s\n", buf); MEM_freeN(buf); } @@ -664,7 +679,19 @@ static int wm_eventmatch(wmEvent *winevent, wmKeymapItem *kmi) int kmitype= wm_userdef_event_map(kmi->type); if(kmi->inactive) return 0; - + + /* exception for middlemouse emulation */ + if((U.flag & USER_TWOBUTTONMOUSE) && (kmi->type == MIDDLEMOUSE)) { + if(winevent->type == LEFTMOUSE && winevent->alt) { + wmKeymapItem tmp= *kmi; + + tmp.type= winevent->type; + tmp.alt= winevent->alt; + if(wm_eventmatch(winevent, &tmp)) + return 1; + } + } + /* the matching rules */ if(kmitype==KM_TEXTINPUT) if(ISKEYBOARD(winevent->type)) return 1; @@ -683,8 +710,15 @@ static int wm_eventmatch(wmEvent *winevent, wmKeymapItem *kmi) if(winevent->alt != kmi->alt && !(winevent->alt & kmi->alt)) return 0; if(kmi->oskey!=KM_ANY) if(winevent->oskey != kmi->oskey && !(winevent->oskey & kmi->oskey)) return 0; + if(kmi->keymodifier) if(winevent->keymodifier!=kmi->keymodifier) return 0; + + /* key modifiers always check when event has it */ + /* otherwise regular keypresses with keymodifier still work */ + if(winevent->keymodifier) + if(ISKEYBOARD(winevent->type)) + if(winevent->keymodifier!=kmi->keymodifier) return 0; return 1; } @@ -1501,11 +1535,6 @@ void wm_event_add_ghostevent(wmWindow *win, int type, void *customdata) else event.type= MIDDLEMOUSE; - if(event.val) - event.keymodifier= evt->keymodifier= event.type; - else - event.keymodifier= evt->keymodifier= 0; - update_tablet_data(win, &event); wm_event_add(win, &event); @@ -1544,6 +1573,12 @@ void wm_event_add_ghostevent(wmWindow *win, int type, void *customdata) if(event.val==KM_PRESS && (evt->ctrl || evt->alt || evt->shift)) event.oskey= evt->oskey = 3; // define? } + else { + if(event.val==KM_PRESS && event.keymodifier==0) + evt->keymodifier= event.type; /* only set in eventstate, for next event */ + else if(event.val==KM_RELEASE && event.keymodifier==event.type) + event.keymodifier= evt->keymodifier= 0; + } /* if test_break set, it catches this. XXX Keep global for now? */ if(event.type==ESCKEY) diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index ffaa315f04e..9c30c99bbdd 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -68,6 +68,7 @@ #include "BKE_main.h" #include "BKE_packedFile.h" #include "BKE_report.h" +#include "BKE_sound.h" #include "BKE_texture.h" #include "BKE_utildefines.h" @@ -224,7 +225,7 @@ static void wm_init_userdef() { UI_init_userdef(); MEM_CacheLimiter_set_maximum(U.memcachelimit * 1024 * 1024); - + sound_init(); } void WM_read_file(bContext *C, char *name, ReportList *reports) @@ -252,7 +253,6 @@ void WM_read_file(bContext *C, char *name, ReportList *reports) wm_check(C); /* opens window(s), checks keymaps */ // XXX mainwindow_set_filename_to_title(G.main->name); -// XXX sound_initialize_sounds(); if(retval==2) wm_init_userdef(); // in case a userdef is read from regular .blend diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index 7179efb186d..9a268f8be17 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -38,7 +38,6 @@ #include "DNA_object_types.h" #include "DNA_scene_types.h" -#include "DNA_sound_types.h" #include "DNA_userdef_types.h" #include "DNA_windowmanager_types.h" @@ -90,17 +89,7 @@ #include "GPU_extensions.h" #include "GPU_draw.h" - - -/* XXX */ -static void sound_init_listener(void) -{ - G.listener = MEM_callocN(sizeof(bSoundListener), "soundlistener"); - G.listener->gain = 1.0; - G.listener->dopplerfactor = 1.0; - G.listener->dopplervelocity = 340.29f; -} - +#include "BKE_sound.h" static void wm_init_reports(bContext *C) { @@ -145,7 +134,6 @@ void WM_init(bContext *C) // glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); - sound_init_listener(); // init_node_butfuncs(); ED_preview_init_dbase(); @@ -184,7 +172,9 @@ extern void free_posebuf(); void WM_exit(bContext *C) { wmWindow *win; - + + sound_exit(); + /* first wrap up running stuff, we assume only the active WM is running */ /* modal handlers are on window level freed, others too? */ /* note; same code copied in wm_files.c */ @@ -216,16 +206,6 @@ void WM_exit(bContext *C) BKE_freecubetable(); -// if (G.background == 0) -// sound_end_all_sounds(); - - - /* before free_blender so py's gc happens while library still exists */ - /* needed at least for a rare sigsegv that can happen in pydrivers */ -#ifndef DISABLE_PYTHON - BPY_end_python(); -#endif - fastshade_free_render(); /* shaded view */ ED_preview_free_dbase(); /* frees a Main dbase, before free_blender! */ wm_free_reports(C); /* before free_blender! - since the ListBases get freed there */ @@ -245,10 +225,18 @@ void WM_exit(bContext *C) // free_txt_data(); -// sound_exit_audio(); - if(G.listener) MEM_freeN(G.listener); - - + +#ifndef DISABLE_PYTHON + /* XXX - old note */ + /* before free_blender so py's gc happens while library still exists */ + /* needed at least for a rare sigsegv that can happen in pydrivers */ + + /* 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(); +#endif + libtiff_exit(); #ifdef WITH_QUICKTIME @@ -272,12 +260,14 @@ void WM_exit(bContext *C) UI_exit(); BKE_userdef_free(); - RNA_exit(); + RNA_exit(); /* should be after BPY_end_python so struct python slots are cleared */ wm_ghost_exit(); CTX_free(C); + SYS_DeleteSystem(SYS_GetSystem()); + if(MEM_get_memory_blocks_in_use()!=0) { printf("Error Totblock: %d\n", MEM_get_memory_blocks_in_use()); MEM_printmemlist(); @@ -294,9 +284,6 @@ void WM_exit(bContext *C) } #endif - - SYS_DeleteSystem(SYS_GetSystem()); - exit(G.afbreek==1); } diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 41613d0ab78..5a385418e5d 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -322,7 +322,7 @@ void WM_operator_py_idname(char *to, const char *from) /* some.op -> SOME_OT_op */ void WM_operator_bl_idname(char *to, const char *from) { - char *sep= strstr(from, "."); + char *sep= strchr(from, '.'); if(sep) { int i, ofs= (sep-from); @@ -345,7 +345,7 @@ void WM_operator_bl_idname(char *to, const char *from) * When calling from an existing wmOperator do. * WM_operator_pystring(op->type, op->ptr); */ -char *WM_operator_pystring(wmOperatorType *ot, PointerRNA *opptr, int all_args) +char *WM_operator_pystring(bContext *C, wmOperatorType *ot, PointerRNA *opptr, int all_args) { const char *arg_name= NULL; char idname_py[OP_MAX_TYPENAME]; @@ -378,7 +378,7 @@ char *WM_operator_pystring(wmOperatorType *ot, PointerRNA *opptr, int all_args) if (strcmp(arg_name, "rna_type")==0) continue; - buf= RNA_property_as_string(opptr, prop); + buf= RNA_property_as_string(C, opptr, prop); ok= 1; @@ -388,7 +388,7 @@ char *WM_operator_pystring(wmOperatorType *ot, PointerRNA *opptr, int all_args) prop_default= RNA_struct_find_property(&opptr_default, arg_name); if(prop_default) { - buf_default= RNA_property_as_string(&opptr_default, prop_default); + buf_default= RNA_property_as_string(C, &opptr_default, prop_default); if(strcmp(buf, buf_default)==0) ok= 0; /* values match, dont bother printing */ @@ -543,7 +543,12 @@ static uiBlock *wm_block_create_redo(bContext *C, ARegion *ar, void *arg_op) RNA_pointer_create(&wm->id, op->type->srna, op->properties, &ptr); layout= uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, 300, 20, style); - uiDefAutoButsRNA(C, layout, &ptr, 2); + uiItemL(layout, op->type->name, 0); + + if(op->type->ui) + op->type->ui((bContext*)C, &ptr, layout); + else + uiDefAutoButsRNA(C, layout, &ptr, 2); uiPopupBoundsBlock(block, 4.0f, 0, 0); uiEndBlock(C, block); @@ -585,7 +590,12 @@ static uiBlock *wm_block_create_menu(bContext *C, ARegion *ar, void *arg_op) uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN|UI_BLOCK_RET_1); layout= uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, 300, 20, style); - uiDefAutoButsRNA(C, layout, op->ptr, 2); + uiItemL(layout, op->type->name, 0); + + if(op->type->ui) + op->type->ui(C, op->ptr, layout); + else + uiDefAutoButsRNA(C, layout, op->ptr, 2); uiPopupBoundsBlock(block, 4.0f, 0, 0); uiEndBlock(C, block); @@ -710,6 +720,7 @@ int wm_search_menu_poll(bContext *C) { if(CTX_wm_window(C)==NULL) return 0; if(CTX_wm_area(C) && CTX_wm_area(C)->spacetype==SPACE_CONSOLE) return 0; // XXX - so we can use the shortcut in the console + if(CTX_wm_area(C) && CTX_wm_area(C)->spacetype==SPACE_TEXT) return 0; // XXX - so we can use the spacebar in the text editor return 1; } @@ -731,7 +742,6 @@ static void WM_OT_window_duplicate(wmOperatorType *ot) ot->name= "Duplicate Window"; ot->idname= "WM_OT_window_duplicate"; - ot->invoke= WM_operator_confirm; ot->exec= wm_window_duplicate_op; ot->poll= WM_operator_winactive; } @@ -859,10 +869,17 @@ static void untitled(char *name) } } +static void load_set_load_ui(wmOperator *op) +{ + if(!RNA_property_is_set(op->ptr, "load_ui")) + RNA_boolean_set(op->ptr, "load_ui", !(U.flag & USER_FILENOUI)); +} static int wm_open_mainfile_invoke(bContext *C, wmOperator *op, wmEvent *event) { RNA_string_set(op->ptr, "filename", G.sce); + load_set_load_ui(op); + WM_event_add_fileselect(C, op); return OPERATOR_RUNNING_MODAL; @@ -871,7 +888,14 @@ static int wm_open_mainfile_invoke(bContext *C, wmOperator *op, wmEvent *event) static int wm_open_mainfile_exec(bContext *C, wmOperator *op) { char filename[FILE_MAX]; + RNA_string_get(op->ptr, "filename", filename); + load_set_load_ui(op); + + if(RNA_boolean_get(op->ptr, "load_ui")) + G.fileflags &= ~G_FILE_NO_UI; + else + G.fileflags |= G_FILE_NO_UI; // XXX wm in context is not set correctly after WM_read_file -> crash // do it before for now, but is this correct with multiple windows? @@ -892,6 +916,8 @@ static void WM_OT_open_mainfile(wmOperatorType *ot) ot->poll= WM_operator_winactive; WM_operator_properties_filesel(ot, FOLDERFILE|BLENDERFILE); + + RNA_def_boolean(ot->srna, "load_ui", 1, "Load UI", "Load user interface setup in the .blend file."); } static int wm_recover_last_session_exec(bContext *C, wmOperator *op) @@ -1025,7 +1051,6 @@ static void WM_OT_window_fullscreen_toggle(wmOperatorType *ot) ot->name= "Toggle Fullscreen"; ot->idname= "WM_OT_window_fullscreen_toggle"; - ot->invoke= WM_operator_confirm; ot->exec= wm_window_fullscreen_toggle_op; ot->poll= WM_operator_winactive; } @@ -1057,7 +1082,7 @@ static void WM_OT_exit_blender(wmOperatorType *ot) */ void *WM_paint_cursor_activate(wmWindowManager *wm, int (*poll)(bContext *C), - void (*draw)(bContext *C, int, int, void *customdata), void *customdata) + wmPaintCursorDraw draw, void *customdata) { wmPaintCursor *pc= MEM_callocN(sizeof(wmPaintCursor), "paint cursor"); @@ -1884,19 +1909,29 @@ void wm_window_keymap(wmWindowManager *wm) /* note, this doesn't replace existing keymap items */ WM_keymap_verify_item(keymap, "WM_OT_window_duplicate", WKEY, KM_PRESS, KM_CTRL|KM_ALT, 0); - WM_keymap_verify_item(keymap, "WM_OT_read_homefile", XKEY, KM_PRESS, KM_CTRL, 0); - WM_keymap_verify_item(keymap, "WM_OT_save_homefile", UKEY, KM_PRESS, KM_CTRL, 0); - WM_keymap_verify_item(keymap, "WM_OT_open_recentfile", OKEY, KM_PRESS, KM_CTRL, 0); - WM_keymap_verify_item(keymap, "WM_OT_open_mainfile", F1KEY, KM_PRESS, 0, 0); - WM_keymap_verify_item(keymap, "WM_OT_save_mainfile", WKEY, KM_PRESS, KM_CTRL, 0); - WM_keymap_verify_item(keymap, "WM_OT_save_as_mainfile", F2KEY, KM_PRESS, 0, 0); +// WM_keymap_add_item(keymap, "WM_OT_read_homefile", NKEY, KM_PRESS, KM_CTRL, 0); + WM_keymap_add_item(keymap, "WM_OT_read_homefile", XKEY, KM_PRESS, KM_CTRL, 0); + WM_keymap_add_item(keymap, "WM_OT_read_homefile", NKEY, KM_PRESS, KM_OSKEY, 0); + WM_keymap_add_item(keymap, "WM_OT_save_homefile", UKEY, KM_PRESS, KM_CTRL, 0); + WM_keymap_add_item(keymap, "WM_OT_save_homefile", UKEY, KM_PRESS, KM_OSKEY, 0); + WM_keymap_add_item(keymap, "WM_OT_open_recentfile", OKEY, KM_PRESS, KM_SHIFT|KM_CTRL, 0); + WM_keymap_add_item(keymap, "WM_OT_open_recentfile", OKEY, KM_PRESS, KM_SHIFT|KM_OSKEY, 0); +// WM_keymap_add_item(keymap, "WM_OT_open_mainfile", OKEY, KM_PRESS, KM_CTRL, 0); + WM_keymap_add_item(keymap, "WM_OT_open_mainfile", F1KEY, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "WM_OT_open_mainfile", OKEY, KM_PRESS, KM_OSKEY, 0); +// WM_keymap_add_item(keymap, "WM_OT_save_mainfile", SKEY, KM_PRESS, KM_CTRL, 0); + WM_keymap_add_item(keymap, "WM_OT_save_mainfile", WKEY, KM_PRESS, KM_CTRL, 0); + WM_keymap_add_item(keymap, "WM_OT_save_mainfile", SKEY, KM_PRESS, KM_OSKEY, 0); +// WM_keymap_add_item(keymap, "WM_OT_save_as_mainfile", SKEY, KM_PRESS, KM_SHIFT|KM_CTRL, 0); + WM_keymap_add_item(keymap, "WM_OT_save_as_mainfile", F2KEY, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "WM_OT_save_as_mainfile", SKEY, KM_PRESS, KM_SHIFT|KM_OSKEY, 0); WM_keymap_verify_item(keymap, "WM_OT_window_fullscreen_toggle", F11KEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_verify_item(keymap, "WM_OT_exit_blender", QKEY, KM_PRESS, KM_CTRL, 0); /* debug/testing */ WM_keymap_verify_item(keymap, "WM_OT_ten_timer", TKEY, KM_PRESS, KM_ALT|KM_CTRL, 0); WM_keymap_verify_item(keymap, "WM_OT_debug_menu", DKEY, KM_PRESS, KM_ALT|KM_CTRL, 0); - WM_keymap_verify_item(keymap, "WM_OT_search_menu", SPACEKEY, KM_PRESS, KM_CTRL, 0); + WM_keymap_verify_item(keymap, "WM_OT_search_menu", SPACEKEY, KM_PRESS, 0, 0); } diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index 4d80836dd05..d70516ef02e 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -26,6 +26,7 @@ * ***** END GPL LICENSE BLOCK ***** */ +#include <math.h> #include <stdlib.h> #include <stdio.h> #include <string.h> @@ -90,7 +91,7 @@ static void wm_window_check_position(rcti *rect) wm_get_screensize(&width, &height); #ifdef __APPLE__ - height -= 42; + height -= 70; #endif if(rect->xmin < 0) { @@ -207,7 +208,10 @@ wmWindow *wm_window_copy(bContext *C, wmWindow *winorig) win->sizey= winorig->sizey; /* duplicate assigns to window */ - ED_screen_duplicate(win, winorig->screen); + win->screen= ED_screen_duplicate(win, winorig->screen); + BLI_strncpy(win->screenname, win->screen->id.name+2, 21); + win->screen->winid= win->winid; + win->screen->do_refresh= 1; win->screen->do_draw= 1; @@ -443,14 +447,14 @@ void WM_window_open_temp(bContext *C, rcti *position, int type) ED_area_newspace(C, sa, SPACE_IMAGE); } else { - ED_area_newspace(C, sa, SPACE_INFO); + ED_area_newspace(C, sa, SPACE_USERPREF); } ED_screen_set(C, win->screen); if(sa->spacetype==SPACE_IMAGE) GHOST_SetTitle(win->ghostwin, "Blender Render"); - else if(ELEM(sa->spacetype, SPACE_OUTLINER, SPACE_INFO)) + else if(ELEM(sa->spacetype, SPACE_OUTLINER, SPACE_USERPREF)) GHOST_SetTitle(win->ghostwin, "Blender User Preferences"); else if(sa->spacetype==SPACE_FILE) GHOST_SetTitle(win->ghostwin, "Blender File View"); @@ -585,6 +589,8 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr private) kdata.key= GHOST_kKeyCommand; wm_event_add_ghostevent(win, GHOST_kEventKeyUp, &kdata); } + /* keymodifier zero, it hangs on hotkeys that open windows otherwise */ + win->eventstate->keymodifier= 0; /* entering window, update mouse pos. but no event */ GHOST_GetCursorPosition(g_system, &wx, &wy); @@ -685,12 +691,13 @@ static int wm_window_timer(const bContext *C) wmTimer *wt; for(wt= win->timers.first; wt; wt= wt->next) { if(wt->sleep==0) { - if(wt->timestep < time - wt->ltime) { + if(time > wt->ntime) { wmEvent event= *(win->eventstate); wt->delta= time - wt->ltime; wt->duration += wt->delta; wt->ltime= time; + wt->ntime= wt->stime + wt->timestep*ceil(wt->duration/wt->timestep); event.type= wt->event_type; event.custom= EVT_DATA_TIMER; @@ -785,6 +792,8 @@ wmTimer *WM_event_add_window_timer(wmWindow *win, int event_type, double timeste wt->event_type= event_type; wt->ltime= PIL_check_seconds_timer(); + wt->ntime= wt->ltime + timestep; + wt->stime= wt->ltime; wt->timestep= timestep; BLI_addtail(&win->timers, wt); |