merge with 2.5 at r18948
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 122 KiB After Width: | Height: | Size: 121 KiB |
@@ -49,4 +49,20 @@ int BLF_lang_error(void);
|
||||
/* Return the code string for the specified language code. */
|
||||
char *BLF_lang_find_code(short langid);
|
||||
|
||||
#if 0
|
||||
|
||||
/* Add a path to the font dir paths. */
|
||||
void BLF_dir_add(const char *path);
|
||||
|
||||
/* Remove a path from the font dir paths. */
|
||||
void BLF_dir_rem(const char *path);
|
||||
|
||||
/* Return an array with all the font dir (this can be used for filesel) */
|
||||
char **BLF_dir_get(int *ndir);
|
||||
|
||||
/* Free the data return by BLF_dir_get. */
|
||||
void BLF_dir_free(char **dirs, int count);
|
||||
|
||||
#endif /* zero!! */
|
||||
|
||||
#endif /* BLF_API_H */
|
||||
|
||||
@@ -0,0 +1,208 @@
|
||||
/**
|
||||
* $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): Blender Foundation
|
||||
*
|
||||
* ***** END GPL LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
#if 0
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <ft2build.h>
|
||||
|
||||
#include FT_FREETYPE_H
|
||||
#include FT_GLYPH_H
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "DNA_listBase.h"
|
||||
|
||||
#include "BKE_utildefines.h"
|
||||
|
||||
#include "BLI_blenlib.h"
|
||||
#include "BLI_linklist.h" /* linknode */
|
||||
#include "BLI_string.h"
|
||||
|
||||
#include "blf_internal_types.h"
|
||||
#include "blf_internal.h"
|
||||
|
||||
|
||||
/* Max number of font in memory.
|
||||
* Take care that now every font have a glyph cache per size/dpi,
|
||||
* so we don't need load the same font with different size, just
|
||||
* load one and call BLF_size.
|
||||
*/
|
||||
#define BLF_MAX_FONT 16
|
||||
|
||||
/* Font array. */
|
||||
FontBLF *global_font[BLF_MAX_FONT];
|
||||
|
||||
/* Number of font. */
|
||||
int global_font_num= 0;
|
||||
|
||||
/* Current font. */
|
||||
int global_font_cur= 0;
|
||||
|
||||
int BLF_init(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i= 0; i < BLF_MAX_FONT; i++)
|
||||
global_font[i]= NULL;
|
||||
|
||||
return(blf_font_init());
|
||||
}
|
||||
|
||||
int blf_search(char *name)
|
||||
{
|
||||
FontBLF *font;
|
||||
int i;
|
||||
|
||||
for (i= 0; i < global_font_num; i++) {
|
||||
font= global_font[i];
|
||||
if (font && (!strcmp(font->name, name)))
|
||||
return(i);
|
||||
}
|
||||
return(-1);
|
||||
}
|
||||
|
||||
int BLF_load(char *name)
|
||||
{
|
||||
FontBLF *font;
|
||||
char *filename;
|
||||
int i;
|
||||
|
||||
if (!name)
|
||||
return(-1);
|
||||
|
||||
/* check if we already load this font. */
|
||||
i= blf_search(name);
|
||||
if (i >= 0)
|
||||
return(i);
|
||||
|
||||
if (global_font_num+1 >= BLF_MAX_FONT)
|
||||
return(-1);
|
||||
|
||||
filename= blf_dir_search(name);
|
||||
if (!filename)
|
||||
return(-1);
|
||||
|
||||
font= blf_font_new(name, filename);
|
||||
MEM_freeN(filename);
|
||||
|
||||
if (!font)
|
||||
return(-1);
|
||||
|
||||
global_font[global_font_num]= font;
|
||||
i= global_font_num;
|
||||
global_font_num++;
|
||||
return(i);
|
||||
}
|
||||
|
||||
int BLF_load_mem(char *name, unsigned char *mem, int mem_size)
|
||||
{
|
||||
FontBLF *font;
|
||||
int i;
|
||||
|
||||
if (!name || !mem || !mem_size)
|
||||
return(-1);
|
||||
|
||||
i= blf_search(name);
|
||||
if (i >= 0)
|
||||
return(i);
|
||||
|
||||
if (global_font_num+1 >= BLF_MAX_FONT)
|
||||
return(-1);
|
||||
|
||||
font= blf_font_new_from_mem(name, mem, size);
|
||||
if (!font)
|
||||
return(-1);
|
||||
|
||||
global_font[global_font_num]= font;
|
||||
i= global_font_num;
|
||||
global_font_num++;
|
||||
return(i);
|
||||
}
|
||||
|
||||
void BLF_set(int fontid)
|
||||
{
|
||||
if (fontid >= 0 && fontid < global_font_num)
|
||||
global_font_cur= fontid;
|
||||
}
|
||||
|
||||
void BLF_aspect(float aspect)
|
||||
{
|
||||
FontBLF *font;
|
||||
|
||||
font= global_font[global_font_cur];
|
||||
if (font)
|
||||
font->aspect= aspect;
|
||||
}
|
||||
|
||||
void BLF_position(float x, float y, float z)
|
||||
{
|
||||
FontBLF *font;
|
||||
|
||||
font= global_font[global_font_cur];
|
||||
if (font) {
|
||||
font->pos[0]= x;
|
||||
font->pos[1]= y;
|
||||
font->pos[2]= z;
|
||||
}
|
||||
}
|
||||
|
||||
void BLF_size(int size, int dpi)
|
||||
{
|
||||
FontBLF *font;
|
||||
|
||||
font= global_font[global_font_cur];
|
||||
if (font)
|
||||
blf_font_size(font, size, dpi);
|
||||
}
|
||||
|
||||
void BLF_draw(char *str)
|
||||
{
|
||||
FontBLF *font;
|
||||
|
||||
font= global_font[global_font_cur];
|
||||
if (font) {
|
||||
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]);
|
||||
|
||||
blf_font_draw(font, str);
|
||||
|
||||
glPopMatrix();
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,167 @@
|
||||
/**
|
||||
* $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): Blender Foundation.
|
||||
*
|
||||
* ***** END GPL LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "DNA_listBase.h"
|
||||
|
||||
#include "BKE_utildefines.h"
|
||||
|
||||
#include "BLI_blenlib.h"
|
||||
#include "BLI_linklist.h" /* linknode */
|
||||
#include "BLI_string.h"
|
||||
|
||||
#include "blf_internal_types.h"
|
||||
|
||||
static ListBase global_font_dir= { NULL, NULL };
|
||||
|
||||
DirBLF *blf_dir_find(const char *path)
|
||||
{
|
||||
DirBLF *p;
|
||||
|
||||
p= global_font_dir.first;
|
||||
while (p) {
|
||||
if (!strcmp(p->path, path))
|
||||
return(p);
|
||||
p= p->next;
|
||||
}
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
void BLF_dir_add(const char *path)
|
||||
{
|
||||
DirBLF *dir;
|
||||
|
||||
dir= blf_dir_find(path);
|
||||
if (dir) /* already in the list ? just return. */
|
||||
return;
|
||||
|
||||
dir= (DirBLF *)MEM_mallocN(sizeof(DirBLF), "BLF_dir_add");
|
||||
dir->path= BLI_strdup(path);
|
||||
BLI_addhead(&global_font_dir, dir);
|
||||
}
|
||||
|
||||
void BLF_dir_rem(const char *path)
|
||||
{
|
||||
DirBLF *dir;
|
||||
|
||||
dir= blf_dir_find(path);
|
||||
if (dir) {
|
||||
BLI_remlink(&global_font_dir, dir);
|
||||
MEM_freeN(dir->path);
|
||||
MEM_freeN(dir);
|
||||
}
|
||||
}
|
||||
|
||||
char **BLF_dir_get(int *ndir)
|
||||
{
|
||||
DirBLF *p;
|
||||
char **dirs;
|
||||
char *path;
|
||||
int i, count;
|
||||
|
||||
count= BLI_countlist(&global_font_dir);
|
||||
if (!count)
|
||||
return(NULL);
|
||||
|
||||
dirs= (char **)MEM_mallocN(sizeof(char *) * count, "BLF_dir_get");
|
||||
p= global_font_dir.first;
|
||||
i= 0;
|
||||
while (p) {
|
||||
path= BLI_strdup(p->path);
|
||||
dirs[i]= path;
|
||||
p= p->next;
|
||||
}
|
||||
*ndir= i;
|
||||
return(dirs);
|
||||
}
|
||||
|
||||
void BLF_dir_free(char **dirs, int count)
|
||||
{
|
||||
char *path;
|
||||
int i;
|
||||
|
||||
for (i= 0; i < count; i++) {
|
||||
path= dirs[i];
|
||||
MEM_freeN(path);
|
||||
}
|
||||
MEM_freeN(dirs);
|
||||
}
|
||||
|
||||
char *blf_dir_search(char *file)
|
||||
{
|
||||
DirBLF *dir;
|
||||
char full_path[FILE_MAXDIR+FILE_MAXFILE];
|
||||
char *s;
|
||||
|
||||
dir= global_font_dir.first;
|
||||
s= NULL;
|
||||
while (dir) {
|
||||
BLI_join_dirfile(full_path, dir->path, file);
|
||||
if (BLI_exist(full_path)) {
|
||||
s= (char *)MEM_mallocN(strlen(full_path)+1,"blf_dir_search");
|
||||
strcpy(s, full_path);
|
||||
break;
|
||||
}
|
||||
dir= dir->next;
|
||||
}
|
||||
|
||||
if (!s) {
|
||||
/* check the current directory, why not ? */
|
||||
if (BLI_exist(file))
|
||||
s= BLI_strdup(file);
|
||||
}
|
||||
|
||||
return(s);
|
||||
}
|
||||
|
||||
int blf_dir_split(const char *str, char *file, int *size)
|
||||
{
|
||||
char *s, i, len;
|
||||
|
||||
/* Window, Linux or Mac, this is always / */
|
||||
s= strrchr(str, '/');
|
||||
if (s) {
|
||||
len= s - str;
|
||||
for (i= 0; i < len; i++)
|
||||
file[i]= str[i];
|
||||
|
||||
file[i]= '.';
|
||||
file[i+1]= 't';
|
||||
file[i+2]= 't';
|
||||
file[i+3]= 'f';
|
||||
file[i+4]= '\0';
|
||||
s++;
|
||||
*size= atoi(s);
|
||||
return(1);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
@@ -0,0 +1,212 @@
|
||||
/**
|
||||
* $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): Blender Foundation
|
||||
*
|
||||
* ***** END GPL LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
#if 0
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <ft2build.h>
|
||||
|
||||
#include FT_FREETYPE_H
|
||||
#include FT_GLYPH_H
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "DNA_listBase.h"
|
||||
|
||||
#include "BKE_utildefines.h"
|
||||
|
||||
#include "BLI_blenlib.h"
|
||||
#include "BLI_linklist.h" /* linknode */
|
||||
#include "BLI_string.h"
|
||||
|
||||
#include "blf_internal_types.h"
|
||||
#include "blf_internal.h"
|
||||
|
||||
|
||||
/* freetype2 handle. */
|
||||
FT_Library global_ft_lib;
|
||||
|
||||
int blf_font_init(void)
|
||||
{
|
||||
return(FT_Init_FreeType(&global_ft_lib));
|
||||
}
|
||||
|
||||
void blf_font_exit(void)
|
||||
{
|
||||
FT_Done_Freetype(global_ft_lib);
|
||||
}
|
||||
|
||||
void blf_font_fill(FontBLF *font)
|
||||
{
|
||||
font->ref= 1;
|
||||
font->aspect= 1.0f;
|
||||
font->pos[0]= 0.0f;
|
||||
font->pos[1]= 0.0f;
|
||||
font->angle[0]= 0.0f;
|
||||
font->angle[1]= 0.0f;
|
||||
font->angle[2]= 0.0f;
|
||||
Mat4One(font->mat);
|
||||
font->clip_rec.xmin= 0.0f;
|
||||
font->clip_rec.xmax= 0.0f;
|
||||
font->clip_rec.ymin= 0.0f;
|
||||
font->clip_rec.ymax= 0.0f;
|
||||
font->clip_mode= BLF_CLIP_DISABLE;
|
||||
font->dpi= 0;
|
||||
font->size= 0;
|
||||
font->cache.first= NULL;
|
||||
font->cache.last= NULL;
|
||||
font->glyph_cache= NULL;
|
||||
glGetIntegerv(GL_MAX_TEXTURE_SIZE, (GLint *)&font->max_tex_size);
|
||||
}
|
||||
|
||||
FontBLF *blf_font_new(char *name, char *filename)
|
||||
{
|
||||
FontBLF *font;
|
||||
FT_Error err;
|
||||
|
||||
font= (FontBLF *)MEM_mallocN(sizeof(FontBLF), "blf_font_new");
|
||||
err= FT_New_Face(global_ft_lib, filename, 0, &font->face);
|
||||
if (err) {
|
||||
printf("BLF: Can't load font: %s\n", filename);
|
||||
MEM_freeN(font);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
err= FT_Select_Charmap(font->face, ft_encoding_unicode);
|
||||
if (err) {
|
||||
printf("Warning: FT_Select_Charmap fail!!\n");
|
||||
FT_Done_Face(font->face);
|
||||
MEM_freeN(font);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
font->name= MEM_strdup(name);
|
||||
font->filename= MEM_strdup(filename);
|
||||
blf_font_fill(font);
|
||||
return(font);
|
||||
}
|
||||
|
||||
FontBLF *blf_font_new_from_mem(char *name, unsigned char *mem, int mem_size)
|
||||
{
|
||||
FontBLF *font;
|
||||
FT_Error err;
|
||||
|
||||
font= (FontBLF *)MEM_mallocN(sizeof(FontBLF), "blf_font_new_from_mem");
|
||||
err= FT_New_Memory_Face(global_ft_lib, mem, size, 0, &font->face);
|
||||
if (err) {
|
||||
printf("BLF: Can't load font: %s, from memory!!\n", name);
|
||||
MEM_freeN(font);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
err= FT_Select_Charmap(font->face, ft_encoding_unicode);
|
||||
if (err) {
|
||||
printf("BLF: FT_Select_Charmap fail!!\n");
|
||||
FT_Done_Face(font->face);
|
||||
MEM_freeN(font);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
font->name= MEM_strdup(name);
|
||||
font->filename= NULL;
|
||||
blf_font_fill(font);
|
||||
return(font);
|
||||
}
|
||||
|
||||
void blf_font_size(FontBLF *font, int size, int dpi)
|
||||
{
|
||||
GlyphCacheBLF *gc;
|
||||
FT_Error err;
|
||||
|
||||
err= FT_Set_Char_Size(font->face, 0, (size * 64), dpi, dpi);
|
||||
if (err) {
|
||||
/* FIXME: here we can go through the fixed size and choice a close one */
|
||||
printf("Warning: The current face don't support the size (%d) and dpi (%d)\n", size, dpi);
|
||||
return;
|
||||
}
|
||||
|
||||
font->size= size;
|
||||
font->dpi= dpi;
|
||||
|
||||
gc= blf_glyph_cache_find(font, size, dpi);
|
||||
if (gc)
|
||||
font->glyph_cache= gc;
|
||||
else {
|
||||
gc= blf_glyph_cache_new(font);
|
||||
if (gc)
|
||||
font->glyph_cache= gc;
|
||||
}
|
||||
}
|
||||
|
||||
void blf_font_draw(FontBLF *font, char *str)
|
||||
{
|
||||
unsigned int c;
|
||||
GlyphBLF *g, *g_prev;
|
||||
FT_Vector delta;
|
||||
FT_UInt glyph_index;
|
||||
int pen_x, pen_y;
|
||||
int i, has_kerning;
|
||||
|
||||
i= 0;
|
||||
pen_x= 0;
|
||||
pen_y= 0;
|
||||
has_kerning= FT_HAS_KERNING(font->face);
|
||||
g_prev= NULL;
|
||||
|
||||
while (str[i]) {
|
||||
c= blf_uf8_next((unsigned char *)str, &i);
|
||||
if (c == 0)
|
||||
break;
|
||||
|
||||
glyph_index= FT_Get_Char_Index(face, c);
|
||||
g= blf_glyph_search(font->glyph_cache, glyph_index);
|
||||
if (!g)
|
||||
g= blf_glyph_add(font, glyph_index, c);
|
||||
|
||||
/* if we don't found a glyph, skip it. */
|
||||
if (!g)
|
||||
continue;
|
||||
|
||||
if (use_kering && g_prev) {
|
||||
delta.x= 0;
|
||||
delta.y= 0;
|
||||
|
||||
FT_Get_Kerning(font->face, g_prev->index, glyph_index, FT_KERNING_MODE_UNFITTED, &delta);
|
||||
pen_x += delta.x >> 6;
|
||||
}
|
||||
|
||||
blf_glyph_render(g, (float)pen_x, (float)pen_y);
|
||||
pen_x += g->advance;
|
||||
g_prev= g;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* zero!! */
|
||||
@@ -0,0 +1,283 @@
|
||||
/**
|
||||
* $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): Blender Foundation
|
||||
*
|
||||
* ***** END GPL LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
#if 0
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <ft2build.h>
|
||||
|
||||
#include FT_FREETYPE_H
|
||||
#include FT_GLYPH_H
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "DNA_listBase.h"
|
||||
|
||||
#include "BKE_utildefines.h"
|
||||
|
||||
#include "BLI_blenlib.h"
|
||||
#include "BLI_linklist.h" /* linknode */
|
||||
#include "BLI_string.h"
|
||||
|
||||
#include "blf_internal_types.h"
|
||||
#include "blf_internal.h"
|
||||
|
||||
|
||||
GlyphCacheBLF *blf_glyph_cache_find(FontBLF *font, int size, int dpi)
|
||||
{
|
||||
GlyphCacheBLF *p;
|
||||
|
||||
p= (GlyphCacheBLF *)font->cache.first;
|
||||
while (p) {
|
||||
if (p->size == size && p->dpi == dpi)
|
||||
return(p);
|
||||
p= p->next;
|
||||
}
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
/* Create a new glyph cache for the current size and dpi. */
|
||||
GlyphCacheBLF *blf_glyph_cache_new(FontBLF *font)
|
||||
{
|
||||
GlyphCacheBLF *gc;
|
||||
int i;
|
||||
|
||||
gc= (GlyphCacheBLF *)MEM_mallocN(sizeof(GlyphCacheBLF));
|
||||
gc->next= NULL;
|
||||
gc->prev= NULL;
|
||||
gc->size= font->size;
|
||||
gc->dpi= font->dpi;
|
||||
|
||||
for (i= 0; i < 257; i++) {
|
||||
gc->bucket[i].first= NULL;
|
||||
gc->bucket[i].last= NULL;
|
||||
}
|
||||
|
||||
gc->textures= (GLuint *)malloc(sizeof(GLunit)*256);
|
||||
gc->ntex= 256;
|
||||
gc->cur_tex= -1;
|
||||
gc->x_offs= 0;
|
||||
gc->y_offs= 0;
|
||||
gc->pad= 3;
|
||||
|
||||
gc->num_glyphs= font->face.num_glyphs;
|
||||
gc->rem_glyphs= font->face.num_glyphs;
|
||||
gc->ascender= ((float)font->size.metrics.ascender) / 64.0f;
|
||||
gc->descender= ((float)font->size.metrics.descender) / 64.0f;
|
||||
|
||||
if (FT_IS_SCALABLE(font->face)) {
|
||||
gc->max_glyph_width= (float)((font->face->bbox.xMax - font->face->bbox.xMin) *
|
||||
(((float)font->face->size.metrics.x_ppem) /
|
||||
((float)font->face->units_per_EM)));
|
||||
|
||||
gc->max_glyph_height= (float)((font->face->bbox.yMax - font->face->bbox.yMin) *
|
||||
(((float)font->face->size.metrics.y_ppem) /
|
||||
((float)font->face->units_per_EM)));
|
||||
}
|
||||
else {
|
||||
gc->max_glyph_width= ((float)font->face->metrics.max_advance) / 64.0f;
|
||||
gc->max_glyph_height= ((float)font->face->size.metrics.height) / 64.0f;
|
||||
}
|
||||
|
||||
gc->p2_width= 0;
|
||||
gc->p2_height= 0;
|
||||
|
||||
BLI_addhead(&font->cache, gc);
|
||||
return(gc);
|
||||
}
|
||||
|
||||
void blf_glyph_cache_texture(FontBLF *font, GlyphCacheBLF *gc)
|
||||
{
|
||||
int tot_mem;
|
||||
unsigned char *buf;
|
||||
|
||||
/* move the index. */
|
||||
gc->cur_tex++;
|
||||
|
||||
if (gc->cur_tex > gc->ntex) {
|
||||
gc->ntex *= 2;
|
||||
gc->textures= (GLuint *)realloc((void *)gc->textures, sizeof(GLunit)*gc->ntex);
|
||||
}
|
||||
|
||||
gc->p2_width= blf_next_p2((gc->rem_glyphs * gc->max_glyph_width) + (gc->pad * 2));
|
||||
if (gc->p2_width > font->max_tex_size)
|
||||
gc->p2_width= font->max_tex_size;
|
||||
|
||||
i= (int)((gc->p2_width - (gc->pad * 2)) / gc->p2_width);
|
||||
gc->p2_height= blf_next_p2(((gc->num_glyphs / i) + 1) * gc->max_glyph_height);
|
||||
|
||||
if (gc->p2_height > font->max_tex_size)
|
||||
gc->p2_height= font->max_tex_size;
|
||||
|
||||
tot_mem= gc->p2_width * gc->p2_height;
|
||||
buf= (unsigned char *)malloc(tot_mem);
|
||||
memset((void *)buf, 0, tot_mem);
|
||||
|
||||
glGenTextures(1, (GLuint*)gc->texures[gc->cur_tex]);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, gc->p2_width, gc->p2_height, 0, GL_ALPHA, GL_UNSIGNED_BYTE, buf);
|
||||
free((void *)buf);
|
||||
}
|
||||
|
||||
GlyphBLF *blf_glyph_search(GlyphCacheBLF *gc, FT_UInt idx)
|
||||
{
|
||||
GlyphBLF *p;
|
||||
unsigned int key;
|
||||
|
||||
key= blf_hash(idx);
|
||||
p= gc->bucket[key].first;
|
||||
while (p) {
|
||||
if (p->index == idx)
|
||||
return(p);
|
||||
p= p->next;
|
||||
}
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
GlyphBLF *blf_glyph_add(FontBLF *font, FT_UInt index, unsigned int c)
|
||||
{
|
||||
FT_GlyphSlot slot;
|
||||
GlyphCache *gc;
|
||||
GlyphBLF *g;
|
||||
FT_Error err;
|
||||
FT_Bitmap bitmap;
|
||||
FTBBox bbox;
|
||||
unsigned int key;
|
||||
|
||||
g= blf_glyph_search(font->glyph_cache, index);
|
||||
if (g)
|
||||
return(g);
|
||||
|
||||
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_NORMAL);
|
||||
if (err)
|
||||
return(NULL);
|
||||
|
||||
g= (GlyphBLF *)MEM_mallocN(sizeof(GlyphBLF), "blf_glyph_add");
|
||||
g->next= NULL;
|
||||
g->prev= NULL;
|
||||
g->c= c;
|
||||
g->index= index;
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
bitmap= slot->bitmap;
|
||||
g->tex= gc->textures[gc->cur_tex];
|
||||
g->xoff= gc->x_offs;
|
||||
g->yoff= gc->y_offs;
|
||||
g->width= bitmap.width;
|
||||
g->height= bitmap.rows;
|
||||
|
||||
if (g->width && g->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, g->tex);
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, g->xoff, g->yoff, g->width, g->height, GL_ALPHA, GL_UNSIGNED_BYTE, bitmap.buffer);
|
||||
glPopClientAttrib();
|
||||
}
|
||||
|
||||
g->advance= ((float)slot->advance.x) / 64.0f;
|
||||
g->pos_x= bitmap.left;
|
||||
g->pos_y= 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;
|
||||
|
||||
g->uv[0][0]= ((float)g->xoff) / ((float)g->p2_width);
|
||||
g->uv[0][1]= ((float)g->yoff) / ((float)g->p2_height);
|
||||
g->uv[1][0]= ((float)(g->xoff + g->width)) / ((float)g->p2_width);
|
||||
g->uv[1][1]= ((float)(g->yoff + g->height)) / ((float)g->p2_height);
|
||||
|
||||
/* update the x offset for the next glyph. */
|
||||
gc->x_offs += (int)(g->box.xmax - g->box.xmin + gc->pad);
|
||||
|
||||
key= blf_hash(g->index);
|
||||
BLI_addhead(&gc->bucket[key], g);
|
||||
return(g);
|
||||
}
|
||||
|
||||
void blf_glyph_render(GlyphBLF *g, float x, float y)
|
||||
{
|
||||
GLint cur_tex;
|
||||
float dx;
|
||||
|
||||
glGetIntegerv(GL_TEXTURE_2D_BINDING_EXT, &cur_tex);
|
||||
if (cur_tex != g->tex)
|
||||
glBindTexture(GL_TEXTURE_2D, &g->tex);
|
||||
|
||||
dx= floor(x + g->pos_x);
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(g->uv[0][0], g->uv[0][1]);
|
||||
glVertex2f(dx, y + g->pos_y);
|
||||
|
||||
glTexCoord2f(g->uv[0][0], g->uv[1][1]);
|
||||
glVertex2f(dx, y + g->pos_y - g->height);
|
||||
|
||||
glTexCoord2f(g->uv[1][0], g->uv[1][1]);
|
||||
glVertex2f(dx + g->width, y + g->pos_y - g->height);
|
||||
|
||||
glTexCoord2f(g->uv[1][0], g->uv[0][1]);
|
||||
glVertex2f(dx + g->width, y + g->pos_y);
|
||||
glEnd();
|
||||
}
|
||||
|
||||
#endif /* zero!! */
|
||||
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* $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): Blender Foundation.
|
||||
*
|
||||
* ***** END GPL LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
#ifndef BLF_INTERNAL_H
|
||||
#define BLF_INTERNAL_H
|
||||
|
||||
unsigned int blf_next_p2(unsigned int x);
|
||||
unsigned int blf_hash(unsigned int val);
|
||||
int blf_utf8_next(unsigned char *buf, int *iindex);
|
||||
|
||||
char *blf_dir_search(const char *file);
|
||||
int blf_dir_split(const char *str, char *file, int *size);
|
||||
|
||||
#endif /* BLF_INTERNAL_H */
|
||||
@@ -28,6 +28,153 @@
|
||||
#ifndef BLF_INTERNAL_TYPES_H
|
||||
#define BLF_INTERNAL_TYPES_H
|
||||
|
||||
typedef struct DirBLF {
|
||||
struct DirBLF *next;
|
||||
struct DirBLF *prev;
|
||||
|
||||
/* full path where search fonts. */
|
||||
char *path;
|
||||
} DirBLF;
|
||||
|
||||
#if 0
|
||||
|
||||
typedef struct _GlyphCacheBLF {
|
||||
struct _GlyphCacheBLF *next;
|
||||
struct _GlyphCacheBLF *prev;
|
||||
|
||||
/* font size. */
|
||||
int size;
|
||||
|
||||
/* and dpi. */
|
||||
int dpi;
|
||||
|
||||
/* and the glyphs. */
|
||||
ListBase bucket[257];
|
||||
|
||||
/* texture array, to draw the glyphs. */
|
||||
GLuint *textures;
|
||||
|
||||
/* size of the array. */
|
||||
int ntex;
|
||||
|
||||
/* and the last texture, aka. the current texture. */
|
||||
int cur_tex;
|
||||
|
||||
/* like bftgl, we draw every glyph in a big texture, so this is the
|
||||
* current position inside the texture.
|
||||
*/
|
||||
int x_offs;
|
||||
int y_offs;
|
||||
|
||||
/* and the space from one to other. */
|
||||
unsigned int pad;
|
||||
|
||||
/* and the bigger glyph in the font. */
|
||||
int max_glyph_width;
|
||||
int max_glyph_height;
|
||||
|
||||
/* next two integer power of two, to build the texture. */
|
||||
int p2_width;
|
||||
int p2_height;
|
||||
|
||||
/* number of glyphs in the font. */
|
||||
int num_glyphs;
|
||||
|
||||
/* number of glyphs that we load here. */
|
||||
int rem_glyphs;
|
||||
|
||||
/* ascender and descender value. */
|
||||
float ascender;
|
||||
float descender;
|
||||
} GlyphCacheBLF;
|
||||
|
||||
typedef struct _GlyphBLF {
|
||||
struct _GlyphBLF *next;
|
||||
struct _GlyphBLF *prev;
|
||||
|
||||
/* and the character, as UTF8 */
|
||||
unsigned int c;
|
||||
|
||||
/* Freetype2 index. */
|
||||
FT_UInt index;
|
||||
|
||||
/* texture id where this glyph is store. */
|
||||
GLuint tex;
|
||||
|
||||
/* position inside the texture where this glyph is store. */
|
||||
int xoff;
|
||||
int yoff;
|
||||
|
||||
/* glyph width and height. */
|
||||
int width;
|
||||
int height;
|
||||
|
||||
/* glyph bounding box. */
|
||||
rctf box;
|
||||
|
||||
/* uv coords. */
|
||||
float uv[2][2];
|
||||
|
||||
/* advance value. */
|
||||
float advance;
|
||||
|
||||
/* X and Y bearing of the glyph.
|
||||
* The X bearing is from the origin to the glyph left bbox edge.
|
||||
* The Y bearing is from the baseline to the top of the glyph edge.
|
||||
*/
|
||||
float pos_x;
|
||||
float pos_y;
|
||||
} GlyphBLF;
|
||||
|
||||
typedef struct FontBLF {
|
||||
/* font name. */
|
||||
char *name;
|
||||
|
||||
/* filename or NULL. */
|
||||
char *filename;
|
||||
|
||||
/* reference count. */
|
||||
int ref;
|
||||
|
||||
/* aspect ratio or scale. */
|
||||
float aspect;
|
||||
|
||||
/* initial position for draw the text. */
|
||||
float pos[3];
|
||||
|
||||
/* angle in degrees. */
|
||||
float angle[3];
|
||||
|
||||
/* this is the matrix that we load before rotate/scale/translate. */
|
||||
float mat[4][4];
|
||||
|
||||
/* clipping rectangle. */
|
||||
rctf clip_rec;
|
||||
|
||||
/* and clipping mode. */
|
||||
int clip_mode;
|
||||
|
||||
/* font dpi (default 72). */
|
||||
int dpi;
|
||||
|
||||
/* font size. */
|
||||
int size;
|
||||
|
||||
/* max texture size. */
|
||||
int max_tex_size;
|
||||
|
||||
/* freetype2 face. */
|
||||
FT_Face face;
|
||||
|
||||
/* list of glyph cache for this font. */
|
||||
ListBase cache;
|
||||
|
||||
/* current glyph cache, size and dpi. */
|
||||
GlyphCacheBLF *glyph_cache;
|
||||
} FontBLF;
|
||||
|
||||
#endif /* zero!! */
|
||||
|
||||
typedef struct LangBLF {
|
||||
struct LangBLF *next;
|
||||
struct LangBLF *prev;
|
||||
@@ -42,4 +189,8 @@ typedef struct LangBLF {
|
||||
#define BLF_LANG_FIND_BY_LANGUAGE 1
|
||||
#define BLF_LANG_FIND_BY_CODE 2
|
||||
|
||||
/* font->clip_mode */
|
||||
#define BLF_CLIP_DISABLE 0
|
||||
#define BLF_CLIP_OUT 1
|
||||
|
||||
#endif /* BLF_INTERNAL_TYPES_H */
|
||||
|
||||
@@ -0,0 +1,131 @@
|
||||
/**
|
||||
* $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): Blender Foundation
|
||||
*
|
||||
* ***** END GPL LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
unsigned int blf_next_p2(unsigned int x)
|
||||
{
|
||||
x -= 1;
|
||||
x |= (x >> 16);
|
||||
x |= (x >> 8);
|
||||
x |= (x >> 4);
|
||||
x |= (x >> 2);
|
||||
x |= (x >> 1);
|
||||
x += 1;
|
||||
return(x);
|
||||
}
|
||||
|
||||
unsigned int blf_hash(unsigned int val)
|
||||
{
|
||||
unsigned int key;
|
||||
|
||||
key= val;
|
||||
key += ~(key << 16);
|
||||
key ^= (key >> 5);
|
||||
key += (key << 3);
|
||||
key ^= (key >> 13);
|
||||
key += ~(key << 9);
|
||||
key ^= (key >> 17);
|
||||
return(key % 257);
|
||||
}
|
||||
|
||||
/*
|
||||
* This function is from Imlib2 library (font_main.c), a
|
||||
* library that does image file loading and saving as well
|
||||
* as rendering, manipulation, arbitrary polygon support, etc.
|
||||
*
|
||||
* Copyright (C) 2000 Carsten Haitzler and various contributors
|
||||
* The original name: imlib_font_utf8_get_next
|
||||
* more info here: http://docs.enlightenment.org/api/imlib2/html/
|
||||
*/
|
||||
int blf_utf8_next(unsigned char *buf, int *iindex)
|
||||
{
|
||||
/* Reads UTF8 bytes from 'buf', starting at 'index' and
|
||||
* returns the code point of the next valid code point.
|
||||
* 'index' is updated ready for the next call.
|
||||
*
|
||||
* Returns 0 to indicate an error (e.g. invalid UTF8)
|
||||
*/
|
||||
int index= *iindex, r;
|
||||
unsigned char d= buf[index++], d2, d3, d4;
|
||||
|
||||
if (!d)
|
||||
return(0);
|
||||
|
||||
if (d < 0x80) {
|
||||
*iindex= index;
|
||||
return(d);
|
||||
}
|
||||
|
||||
if ((d & 0xe0) == 0xc0) {
|
||||
/* 2 byte */
|
||||
d2= buf[index++];
|
||||
if ((d2 & 0xc0) != 0x80)
|
||||
return(0);
|
||||
r= d & 0x1f; /* copy lower 5 */
|
||||
r <<= 6;
|
||||
r |= (d2 & 0x3f); /* copy lower 6 */
|
||||
}
|
||||
else if ((d & 0xf0) == 0xe0) {
|
||||
/* 3 byte */
|
||||
d2= buf[index++];
|
||||
d3= buf[index++];
|
||||
|
||||
if ((d2 & 0xc0) != 0x80 || (d3 & 0xc0) != 0x80)
|
||||
return(0);
|
||||
|
||||
r= d & 0x0f; /* copy lower 4 */
|
||||
r <<= 6;
|
||||
r |= (d2 & 0x3f);
|
||||
r <<= 6;
|
||||
r |= (d3 & 0x3f);
|
||||
}
|
||||
else {
|
||||
/* 4 byte */
|
||||
d2= buf[index++];
|
||||
d3= buf[index++];
|
||||
d4= buf[index++];
|
||||
|
||||
if ((d2 & 0xc0) != 0x80 || (d3 & 0xc0) != 0x80 ||
|
||||
(d4 & 0xc0) != 0x80)
|
||||
return(0);
|
||||
|
||||
r= d & 0x0f; /* copy lower 4 */
|
||||
r <<= 6;
|
||||
r |= (d2 & 0x3f);
|
||||
r <<= 6;
|
||||
r |= (d3 & 0x3f);
|
||||
r <<= 6;
|
||||
r |= (d4 & 0x3f);
|
||||
}
|
||||
*iindex= index;
|
||||
return(r);
|
||||
}
|
||||
@@ -36,11 +36,10 @@
|
||||
|
||||
#include "DNA_listBase.h"
|
||||
|
||||
/**
|
||||
* The following structures are defined in DNA_action_types.h, and DNA_anim_types.h
|
||||
*/
|
||||
|
||||
/* The following structures are defined in DNA_action_types.h, and DNA_anim_types.h */
|
||||
struct bAction;
|
||||
struct bActionGroup;
|
||||
struct FCurve;
|
||||
struct bPose;
|
||||
struct bPoseChannel;
|
||||
struct Object;
|
||||
@@ -52,28 +51,40 @@ struct ID;
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct bAction *add_empty_action(const char name[]);
|
||||
|
||||
/**
|
||||
* Allocate a new bAction on the heap and copy
|
||||
* the contents of src into it. If src is NULL NULL is returned.
|
||||
*/
|
||||
/* Action API ----------------- */
|
||||
|
||||
/* Allocate a new bAction with the given name */
|
||||
struct bAction *add_empty_action(const char name[]);
|
||||
|
||||
/* Allocate a copy of the given Action and all its data */
|
||||
struct bAction *copy_action(struct bAction *src);
|
||||
|
||||
/**
|
||||
* Deallocate the action's channels including constraint channels.
|
||||
* does not free the action structure.
|
||||
*/
|
||||
/* Deallocate all of the Action's data, but not the Action itself */
|
||||
void free_action(struct bAction *act);
|
||||
|
||||
// XXX is this needed?
|
||||
void make_local_action(struct bAction *act);
|
||||
|
||||
/**
|
||||
* Some kind of bounding box operation on the action.
|
||||
*/
|
||||
|
||||
/* Some kind of bounding box operation on the action */
|
||||
// XXX depreceated..
|
||||
void calc_action_range(const struct bAction *act, float *start, float *end, int incl_hidden);
|
||||
|
||||
/* Action Groups API ----------------- */
|
||||
|
||||
/* Make the given Action Group the active one */
|
||||
void set_active_action_group(struct bAction *act, struct bActionGroup *agrp, short select);
|
||||
|
||||
/* Add given channel into (active) group */
|
||||
void action_groups_add_channel(struct bAction *act, struct bActionGroup *agrp, struct FCurve *fcurve);
|
||||
|
||||
/* Remove the given channel from all groups */
|
||||
void action_groups_remove_channel(struct bAction *act, struct FCurve *fcu);
|
||||
|
||||
/* Find a group with the given name */
|
||||
struct bActionGroup *action_groups_find_named(struct bAction *act, const char name[]);
|
||||
|
||||
|
||||
/* Pose API ----------------- */
|
||||
|
||||
/**
|
||||
* Removes and deallocates all channels from a pose.
|
||||
|
||||
@@ -9,6 +9,7 @@ struct ID;
|
||||
struct ListBase;
|
||||
struct Main;
|
||||
struct AnimData;
|
||||
struct KeyingSet;
|
||||
|
||||
/* ************************************* */
|
||||
/* AnimData API */
|
||||
@@ -25,6 +26,21 @@ void BKE_free_animdata(struct ID *id);
|
||||
/* Copy AnimData */
|
||||
struct AnimData *BKE_copy_animdata(struct AnimData *adt);
|
||||
|
||||
/* ************************************* */
|
||||
/* KeyingSets API */
|
||||
|
||||
/* Used to create a new 'custom' KeyingSet for the user, that will be automatically added to the stack */
|
||||
struct KeyingSet *BKE_keyingset_add(struct ListBase *list, const char name[], short flag, short keyingflag);
|
||||
|
||||
/* Add a destination to a KeyingSet */
|
||||
void BKE_keyingset_add_destination(struct KeyingSet *ks, struct ID *id, const char group_name[], const char rna_path[], int array_index, int flag);
|
||||
|
||||
/* Free data for KeyingSet but not set itself */
|
||||
void BKE_keyingset_free(struct KeyingSet *ks);
|
||||
|
||||
/* Free all the KeyingSets in the given list */
|
||||
void BKE_keyingsets_free(struct ListBase *list);
|
||||
|
||||
/* ************************************* */
|
||||
// TODO: overrides, remapping, and path-finding api's
|
||||
|
||||
|
||||
@@ -89,6 +89,9 @@ struct FCurve *list_find_fcurve(ListBase *list, const char rna_path[], const int
|
||||
/* get the time extents for F-Curve */
|
||||
void calc_fcurve_range(struct FCurve *fcu, float *min, float *max);
|
||||
|
||||
/* get the bounding-box extents for F-Curve */
|
||||
void calc_fcurve_bounds(struct FCurve *fcu, float *xmin, float *xmax, float *ymin, float *ymax);
|
||||
|
||||
/* -------- Curve Sanity -------- */
|
||||
|
||||
void calchandles_fcurve(struct FCurve *fcu);
|
||||
|
||||
@@ -188,6 +188,196 @@ bAction *copy_action (bAction *src)
|
||||
}
|
||||
|
||||
|
||||
/* Get the active action-group for an Action */
|
||||
bActionGroup *get_active_actiongroup (bAction *act)
|
||||
{
|
||||
bActionGroup *agrp= NULL;
|
||||
|
||||
if (act && act->groups.first) {
|
||||
for (agrp= act->groups.first; agrp; agrp= agrp->next) {
|
||||
if (agrp->flag & AGRP_ACTIVE)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return agrp;
|
||||
}
|
||||
|
||||
/* Make the given Action-Group the active one */
|
||||
void set_active_action_group (bAction *act, bActionGroup *agrp, short select)
|
||||
{
|
||||
bActionGroup *grp;
|
||||
|
||||
/* sanity checks */
|
||||
if (act == NULL)
|
||||
return;
|
||||
|
||||
/* Deactive all others */
|
||||
for (grp= act->groups.first; grp; grp= grp->next) {
|
||||
if ((grp==agrp) && (select))
|
||||
grp->flag |= AGRP_ACTIVE;
|
||||
else
|
||||
grp->flag &= ~AGRP_ACTIVE;
|
||||
}
|
||||
}
|
||||
|
||||
/* Add given channel into (active) group
|
||||
* - assumes that channel is not linked to anything anymore
|
||||
* - always adds at the end of the group
|
||||
*/
|
||||
void action_groups_add_channel (bAction *act, bActionGroup *agrp, FCurve *fcurve)
|
||||
{
|
||||
FCurve *fcu;
|
||||
short done=0;
|
||||
|
||||
/* sanity checks */
|
||||
if (ELEM3(NULL, act, agrp, fcurve))
|
||||
return;
|
||||
|
||||
/* if no channels, just add to two lists at the same time */
|
||||
if (act->curves.first == NULL) {
|
||||
fcurve->next = fcurve->prev = NULL;
|
||||
|
||||
agrp->channels.first = agrp->channels.last = fcurve;
|
||||
act->curves.first = act->curves.last = fcurve;
|
||||
|
||||
fcurve->grp= agrp;
|
||||
return;
|
||||
}
|
||||
|
||||
/* try to find a channel to slot this in before/after */
|
||||
for (fcu= act->curves.first; fcu; fcu= fcu->next) {
|
||||
/* if channel has no group, then we have ungrouped channels, which should always occur after groups */
|
||||
if (fcu->grp == NULL) {
|
||||
BLI_insertlinkbefore(&act->curves, fcu, fcurve);
|
||||
|
||||
if (agrp->channels.first == NULL)
|
||||
agrp->channels.first= fcurve;
|
||||
agrp->channels.last= fcurve;
|
||||
|
||||
done= 1;
|
||||
break;
|
||||
}
|
||||
|
||||
/* if channel has group after current, we can now insert (otherwise we have gone too far) */
|
||||
else if (fcu->grp == agrp->next) {
|
||||
BLI_insertlinkbefore(&act->curves, fcu, fcurve);
|
||||
|
||||
if (agrp->channels.first == NULL)
|
||||
agrp->channels.first= fcurve;
|
||||
agrp->channels.last= fcurve;
|
||||
|
||||
done= 1;
|
||||
break;
|
||||
}
|
||||
|
||||
/* if channel has group we're targeting, check whether it is the last one of these */
|
||||
else if (fcu->grp == agrp) {
|
||||
if ((fcu->next) && (fcu->next->grp != agrp)) {
|
||||
BLI_insertlinkafter(&act->curves, fcu, fcurve);
|
||||
agrp->channels.last= fcurve;
|
||||
done= 1;
|
||||
break;
|
||||
}
|
||||
else if (fcu->next == NULL) {
|
||||
BLI_addtail(&act->curves, fcurve);
|
||||
agrp->channels.last= fcurve;
|
||||
done= 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* if channel has group before target, check whether the next one is something after target */
|
||||
else if (fcu->grp == agrp->prev) {
|
||||
if (fcu->next) {
|
||||
if ((fcu->next->grp != fcu->grp) && (fcu->next->grp != agrp)) {
|
||||
BLI_insertlinkafter(&act->curves, fcu, fcurve);
|
||||
|
||||
agrp->channels.first= fcurve;
|
||||
agrp->channels.last= fcurve;
|
||||
|
||||
done= 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
BLI_insertlinkafter(&act->curves, fcu, fcurve);
|
||||
|
||||
agrp->channels.first= fcurve;
|
||||
agrp->channels.last= fcurve;
|
||||
|
||||
done= 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* only if added, set channel as belonging to this group */
|
||||
if (done) {
|
||||
//printf("FCurve added to group \n");
|
||||
fcurve->grp= agrp;
|
||||
}
|
||||
else {
|
||||
printf("Error: FCurve '%s' couldn't be added to Group '%s' \n", fcurve->rna_path, agrp->name);
|
||||
BLI_addtail(&act->curves, fcurve);
|
||||
}
|
||||
}
|
||||
|
||||
/* Remove the given channel from all groups */
|
||||
void action_groups_remove_channel (bAction *act, FCurve *fcu)
|
||||
{
|
||||
/* sanity checks */
|
||||
if (ELEM(NULL, act, fcu))
|
||||
return;
|
||||
|
||||
/* check if any group used this directly */
|
||||
if (fcu->grp) {
|
||||
bActionGroup *agrp= fcu->grp;
|
||||
|
||||
if (agrp->channels.first == agrp->channels.last) {
|
||||
if (agrp->channels.first == fcu) {
|
||||
agrp->channels.first= NULL;
|
||||
agrp->channels.last= NULL;
|
||||
}
|
||||
}
|
||||
else if (agrp->channels.first == fcu) {
|
||||
if ((fcu->next) && (fcu->next->grp==agrp))
|
||||
agrp->channels.first= fcu->next;
|
||||
else
|
||||
agrp->channels.first= NULL;
|
||||
}
|
||||
else if (agrp->channels.last == fcu) {
|
||||
if ((fcu->prev) && (fcu->prev->grp==agrp))
|
||||
agrp->channels.last= fcu->prev;
|
||||
else
|
||||
agrp->channels.last= NULL;
|
||||
}
|
||||
|
||||
fcu->grp= NULL;
|
||||
}
|
||||
|
||||
/* now just remove from list */
|
||||
BLI_remlink(&act->curves, fcu);
|
||||
}
|
||||
|
||||
/* Find a group with the given name */
|
||||
bActionGroup *action_groups_find_named (bAction *act, const char name[])
|
||||
{
|
||||
bActionGroup *grp;
|
||||
|
||||
/* sanity checks */
|
||||
if (ELEM3(NULL, act, act->groups.first, name) || (name[0] == 0))
|
||||
return NULL;
|
||||
|
||||
/* do string comparisons */
|
||||
for (grp= act->groups.first; grp; grp= grp->next) {
|
||||
if (strcmp(grp->name, name) == 0)
|
||||
return grp;
|
||||
}
|
||||
|
||||
/* not found */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* ************************ Pose channels *************** */
|
||||
|
||||
|
||||
@@ -158,6 +158,124 @@ AnimData *BKE_copy_animdata (AnimData *adt)
|
||||
return dadt;
|
||||
}
|
||||
|
||||
/* *********************************** */
|
||||
/* 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.
|
||||
*/
|
||||
|
||||
/* Defining Tools --------------------------- */
|
||||
|
||||
/* Used to create a new 'custom' KeyingSet for the user, that will be automatically added to the stack */
|
||||
KeyingSet *BKE_keyingset_add (ListBase *list, const char name[], short flag, short keyingflag)
|
||||
{
|
||||
KeyingSet *ks;
|
||||
|
||||
/* allocate new KeyingSet */
|
||||
ks= MEM_callocN(sizeof(KeyingSet), "KeyingSet");
|
||||
|
||||
if (name)
|
||||
BLI_snprintf(ks->name, 64, name);
|
||||
else
|
||||
strcpy(ks->name, "Keying Set");
|
||||
|
||||
ks->flag= flag;
|
||||
ks->keyingflag= keyingflag;
|
||||
|
||||
/* add KeyingSet to list */
|
||||
BLI_addtail(list, ks);
|
||||
|
||||
/* return new KeyingSet for further editing */
|
||||
return ks;
|
||||
}
|
||||
|
||||
/* Add a destination to a KeyingSet. Nothing is returned for now...
|
||||
* Checks are performed to ensure that destination is appropriate for the KeyingSet in question
|
||||
*/
|
||||
void BKE_keyingset_add_destination (KeyingSet *ks, ID *id, const char group_name[], const char rna_path[], int array_index, int flag)
|
||||
{
|
||||
KS_Path *ksp;
|
||||
|
||||
/* sanity checks */
|
||||
if ELEM(NULL, ks, rna_path)
|
||||
return;
|
||||
|
||||
/* ID is optional, and should only be provided for absolute KeyingSets */
|
||||
if (id) {
|
||||
if ((ks->flag & KEYINGSET_ABSOLUTE) == 0)
|
||||
return;
|
||||
}
|
||||
|
||||
/* allocate a new KeyingSet Path */
|
||||
ksp= MEM_callocN(sizeof(KS_Path), "KeyingSet Path");
|
||||
|
||||
/* just store absolute info */
|
||||
if (ks->flag & KEYINGSET_ABSOLUTE) {
|
||||
ksp->id= id;
|
||||
if (group_name)
|
||||
BLI_snprintf(ksp->group, 64, group_name);
|
||||
else
|
||||
strcpy(ksp->group, "");
|
||||
}
|
||||
|
||||
/* just copy path info */
|
||||
// XXX no checks are performed for templates yet
|
||||
// should array index be checked too?
|
||||
ksp->rna_path= BLI_strdupn(rna_path, strlen(rna_path));
|
||||
ksp->array_index= array_index;
|
||||
|
||||
/* store flags */
|
||||
ksp->flag= flag;
|
||||
|
||||
/* add KeyingSet path to KeyingSet */
|
||||
BLI_addtail(&ks->paths, ksp);
|
||||
}
|
||||
|
||||
|
||||
/* Freeing Tools --------------------------- */
|
||||
|
||||
/* Free data for KeyingSet but not set itself */
|
||||
void BKE_keyingset_free (KeyingSet *ks)
|
||||
{
|
||||
KS_Path *ksp, *kspn;
|
||||
|
||||
/* sanity check */
|
||||
if (ks == NULL)
|
||||
return;
|
||||
|
||||
/* free each path as we go to avoid looping twice */
|
||||
for (ksp= ks->paths.first; ksp; ksp= kspn) {
|
||||
kspn= ksp->next;
|
||||
|
||||
/* free RNA-path info */
|
||||
MEM_freeN(ksp->rna_path);
|
||||
|
||||
/* free path itself */
|
||||
BLI_freelinkN(&ks->paths, ksp);
|
||||
}
|
||||
}
|
||||
|
||||
/* Free all the KeyingSets in the given list */
|
||||
void BKE_keyingsets_free (ListBase *list)
|
||||
{
|
||||
KeyingSet *ks, *ksn;
|
||||
|
||||
/* sanity check */
|
||||
if (list == NULL)
|
||||
return;
|
||||
|
||||
/* loop over KeyingSets freeing them
|
||||
* - BKE_keyingset_free() doesn't free the set itself, but it frees its sub-data
|
||||
*/
|
||||
for (ks= list->first; ks; ks= ksn) {
|
||||
ksn= ks->next;
|
||||
BKE_keyingset_free(ks);
|
||||
BLI_freelinkN(list, ks);
|
||||
}
|
||||
}
|
||||
|
||||
/* ***************************************** */
|
||||
/* Evaluation Data-Setting Backend */
|
||||
@@ -587,7 +705,7 @@ void BKE_animsys_evaluate_animdata (ID *id, AnimData *adt, float ctime, short re
|
||||
* - NLA before Active Action, as Active Action behaves as 'tweaking track'
|
||||
* that overrides 'rough' work in NLA
|
||||
*/
|
||||
if ((recalc & ADT_RECALC_ANIM) /*|| (adt->recalc & ADT_RECALC_ANIM)*/) // XXX for now,don't check yet, as depsgraph doesn't know this yet
|
||||
if ((recalc & ADT_RECALC_ANIM) || (adt->recalc & ADT_RECALC_ANIM))
|
||||
{
|
||||
/* evaluate NLA data */
|
||||
if ((adt->nla_tracks.first) && !(adt->flag & ADT_NLA_EVAL_OFF))
|
||||
@@ -599,6 +717,9 @@ void BKE_animsys_evaluate_animdata (ID *id, AnimData *adt, float ctime, short re
|
||||
// FIXME: what if the solo track was not tweaking one, then nla-solo should be checked too?
|
||||
if (adt->action)
|
||||
animsys_evaluate_action(&id_ptr, adt->action, adt->remap, ctime);
|
||||
|
||||
/* reset tag */
|
||||
adt->recalc &= ~ADT_RECALC_ANIM;
|
||||
}
|
||||
|
||||
/* recalculate drivers
|
||||
@@ -639,29 +760,29 @@ void BKE_animsys_evaluate_all_animation (Main *main, float ctime)
|
||||
printf("Evaluate all animation - %f \n", ctime);
|
||||
|
||||
/* macro for less typing */
|
||||
#define EVAL_ANIM_IDS(first) \
|
||||
#define EVAL_ANIM_IDS(first, flag) \
|
||||
for (id= first; id; id= id->next) { \
|
||||
AnimData *adt= BKE_animdata_from_id(id); \
|
||||
BKE_animsys_evaluate_animdata(id, adt, ctime, ADT_RECALC_ANIM); \
|
||||
BKE_animsys_evaluate_animdata(id, adt, ctime, flag); \
|
||||
}
|
||||
|
||||
/* nodes */
|
||||
// TODO...
|
||||
|
||||
/* textures */
|
||||
EVAL_ANIM_IDS(main->tex.first);
|
||||
EVAL_ANIM_IDS(main->tex.first, ADT_RECALC_ANIM);
|
||||
|
||||
/* lamps */
|
||||
EVAL_ANIM_IDS(main->lamp.first);
|
||||
EVAL_ANIM_IDS(main->lamp.first, ADT_RECALC_ANIM);
|
||||
|
||||
/* materials */
|
||||
EVAL_ANIM_IDS(main->mat.first);
|
||||
EVAL_ANIM_IDS(main->mat.first, ADT_RECALC_ANIM);
|
||||
|
||||
/* cameras */
|
||||
EVAL_ANIM_IDS(main->camera.first);
|
||||
EVAL_ANIM_IDS(main->camera.first, ADT_RECALC_ANIM);
|
||||
|
||||
/* shapekeys */
|
||||
EVAL_ANIM_IDS(main->key.first);
|
||||
EVAL_ANIM_IDS(main->key.first, ADT_RECALC_ANIM);
|
||||
|
||||
/* curves */
|
||||
// TODO...
|
||||
@@ -670,13 +791,13 @@ void BKE_animsys_evaluate_all_animation (Main *main, float ctime)
|
||||
// TODO...
|
||||
|
||||
/* objects */
|
||||
EVAL_ANIM_IDS(main->object.first);
|
||||
EVAL_ANIM_IDS(main->object.first, 0);
|
||||
|
||||
/* worlds */
|
||||
EVAL_ANIM_IDS(main->world.first);
|
||||
EVAL_ANIM_IDS(main->world.first, ADT_RECALC_ANIM);
|
||||
|
||||
/* scenes */
|
||||
EVAL_ANIM_IDS(main->scene.first);
|
||||
EVAL_ANIM_IDS(main->scene.first, ADT_RECALC_ANIM);
|
||||
}
|
||||
|
||||
/* ***************************************** */
|
||||
|
||||
@@ -132,6 +132,14 @@ void free_armature(bArmature *arm)
|
||||
if (arm) {
|
||||
/* unlink_armature(arm);*/
|
||||
free_bones(arm);
|
||||
|
||||
/* free editmode data */
|
||||
if (arm->edbo) {
|
||||
BLI_freelistN(arm->edbo);
|
||||
|
||||
MEM_freeN(arm->edbo);
|
||||
arm->edbo= NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -65,6 +65,7 @@
|
||||
#include "IMB_imbuf_types.h"
|
||||
#include "IMB_imbuf.h"
|
||||
|
||||
#include "BKE_animsys.h"
|
||||
#include "BKE_action.h"
|
||||
#include "BKE_blender.h"
|
||||
#include "BKE_context.h"
|
||||
|
||||
@@ -191,6 +191,8 @@ Curve *copy_curve(Curve *cu)
|
||||
cun->bev.first= cun->bev.last= 0;
|
||||
cun->path= 0;
|
||||
|
||||
cun->editnurb= NULL;
|
||||
|
||||
#if 0 // XXX old animation system
|
||||
/* single user ipo too */
|
||||
if(cun->ipo) cun->ipo= copy_ipo(cun->ipo);
|
||||
|
||||
@@ -324,7 +324,7 @@ static void dag_add_driver_relation(AnimData *adt, DagForest *dag, DagNode *node
|
||||
/* now we need refs to all objects mentioned in this
|
||||
* pydriver expression, to call 'dag_add_relation'
|
||||
* for each of them */
|
||||
Object **obarray = BPY_pydriver_get_objects(fcu->driver);
|
||||
Object **obarray = NULL; // XXX BPY_pydriver_get_objects(fcu->driver);
|
||||
if (obarray) {
|
||||
Object *ob, **oba = obarray;
|
||||
|
||||
@@ -2045,7 +2045,12 @@ static void dag_object_time_update_flags(Object *ob)
|
||||
}
|
||||
}
|
||||
#endif // XXX old animation system
|
||||
if(animdata_use_time(ob->adt)) ob->recalc |= OB_RECALC;
|
||||
|
||||
if(animdata_use_time(ob->adt)) {
|
||||
ob->recalc |= OB_RECALC;
|
||||
ob->adt->recalc |= ADT_RECALC_ANIM;
|
||||
}
|
||||
|
||||
if((ob->adt) && (ob->type==OB_ARMATURE)) ob->recalc |= OB_RECALC_DATA;
|
||||
|
||||
if(object_modifiers_use_time(ob)) ob->recalc |= OB_RECALC_DATA;
|
||||
|
||||
@@ -170,6 +170,73 @@ FCurve *list_find_fcurve (ListBase *list, const char rna_path[], const int array
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Calculate the extents of F-Curve's data */
|
||||
void calc_fcurve_bounds (FCurve *fcu, float *xmin, float *xmax, float *ymin, float *ymax)
|
||||
{
|
||||
float xminv=999999999.0f, xmaxv=-999999999.0f;
|
||||
float yminv=999999999.0f, ymaxv=-999999999.0f;
|
||||
short foundvert=0;
|
||||
int i;
|
||||
|
||||
if (fcu->totvert) {
|
||||
if (fcu->bezt) {
|
||||
/* frame range can be directly calculated from end verts */
|
||||
if (xmin || xmax) {
|
||||
xminv= MIN2(xminv, fcu->bezt[0].vec[1][0]);
|
||||
xmaxv= MAX2(xmaxv, fcu->bezt[fcu->totvert-1].vec[1][0]);
|
||||
}
|
||||
|
||||
/* only loop over keyframes to find extents for values if needed */
|
||||
if (ymin || ymax) {
|
||||
BezTriple *bezt;
|
||||
|
||||
for (bezt=fcu->bezt, i=0; i < fcu->totvert; bezt++, i++) {
|
||||
yminv= MIN2(yminv, bezt->vec[1][1]);
|
||||
ymaxv= MAX2(ymaxv, bezt->vec[1][1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (fcu->fpt) {
|
||||
/* frame range can be directly calculated from end verts */
|
||||
if (xmin || xmax) {
|
||||
xminv= MIN2(xminv, fcu->fpt[0].vec[0]);
|
||||
xmaxv= MAX2(xmaxv, fcu->fpt[fcu->totvert-1].vec[0]);
|
||||
}
|
||||
|
||||
/* only loop over keyframes to find extents for values if needed */
|
||||
if (ymin || ymax) {
|
||||
FPoint *fpt;
|
||||
|
||||
for (fpt=fcu->fpt, i=0; i < fcu->totvert; fpt++, i++) {
|
||||
yminv= MIN2(yminv, fpt->vec[1]);
|
||||
ymaxv= MAX2(ymaxv, fpt->vec[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foundvert=1;
|
||||
}
|
||||
|
||||
/* minimum sizes are 1.0f */
|
||||
if (foundvert) {
|
||||
if (xminv == xmaxv) xmaxv += 1.0f;
|
||||
if (yminv == ymaxv) ymaxv += 1.0f;
|
||||
|
||||
if (xmin) *xmin= xminv;
|
||||
if (xmax) *xmax= xmaxv;
|
||||
|
||||
if (ymin) *ymin= yminv;
|
||||
if (ymax) *ymax= ymaxv;
|
||||
}
|
||||
else {
|
||||
if (xmin) *xmin= 0.0f;
|
||||
if (xmax) *xmax= 0.0f;
|
||||
|
||||
if (ymin) *ymin= 1.0f;
|
||||
if (ymax) *ymax= 1.0f;
|
||||
}
|
||||
}
|
||||
|
||||
/* Calculate the extents of F-Curve's keyframes */
|
||||
void calc_fcurve_range (FCurve *fcu, float *start, float *end)
|
||||
{
|
||||
|
||||
@@ -1012,8 +1012,7 @@ bNode *nodeCopyNode(struct bNodeTree *ntree, struct bNode *node, int internal)
|
||||
oldsock->new_sock= sock;
|
||||
}
|
||||
|
||||
if(nnode->id)
|
||||
nnode->id->us++;
|
||||
/* don't increase node->id users, freenode doesn't decrement either */
|
||||
|
||||
if(node->typeinfo->copystoragefunc)
|
||||
node->typeinfo->copystoragefunc(node, nnode);
|
||||
|
||||
@@ -699,7 +699,7 @@ float dof_camera(Object *ob)
|
||||
{
|
||||
Camera *cam = (Camera *)ob->data;
|
||||
if (ob->type != OB_CAMERA)
|
||||
return 0.0;
|
||||
return 0.0f;
|
||||
if (cam->dof_ob) {
|
||||
/* too simple, better to return the distance on the view axis only
|
||||
* return VecLenf(ob->obmat[3], cam->dof_ob->obmat[3]); */
|
||||
@@ -709,7 +709,7 @@ float dof_camera(Object *ob)
|
||||
Mat4Ortho(obmat);
|
||||
Mat4Invert(ob->imat, obmat);
|
||||
Mat4MulMat4(mat, cam->dof_ob->obmat, ob->imat);
|
||||
return fabs(mat[3][2]);
|
||||
return (float)fabs(mat[3][2]);
|
||||
}
|
||||
return cam->YF_dofdist;
|
||||
}
|
||||
@@ -720,26 +720,26 @@ void *add_lamp(char *name)
|
||||
|
||||
la= alloc_libblock(&G.main->lamp, ID_LA, name);
|
||||
|
||||
la->r= la->g= la->b= la->k= 1.0;
|
||||
la->haint= la->energy= 1.0;
|
||||
la->dist= 20.0;
|
||||
la->spotsize= 45.0;
|
||||
la->spotblend= 0.15;
|
||||
la->att2= 1.0;
|
||||
la->r= la->g= la->b= la->k= 1.0f;
|
||||
la->haint= la->energy= 1.0f;
|
||||
la->dist= 20.0f;
|
||||
la->spotsize= 45.0f;
|
||||
la->spotblend= 0.15f;
|
||||
la->att2= 1.0f;
|
||||
la->mode= LA_SHAD_BUF;
|
||||
la->bufsize= 512;
|
||||
la->clipsta= 0.5;
|
||||
la->clipend= 40.0;
|
||||
la->shadspotsize= 45.0;
|
||||
la->clipsta= 0.5f;
|
||||
la->clipend= 40.0f;
|
||||
la->shadspotsize= 45.0f;
|
||||
la->samp= 3;
|
||||
la->bias= 1.0;
|
||||
la->soft= 3.0;
|
||||
la->bias= 1.0f;
|
||||
la->soft= 3.0f;
|
||||
la->ray_samp= la->ray_sampy= la->ray_sampz= 1;
|
||||
la->area_size=la->area_sizey=la->area_sizez= 1.0;
|
||||
la->area_size=la->area_sizey=la->area_sizez= 1.0f;
|
||||
la->buffers= 1;
|
||||
la->buftype= LA_SHADBUF_HALFWAY;
|
||||
la->ray_samp_method = LA_SAMP_HALTON;
|
||||
la->adapt_thresh = 0.001;
|
||||
la->adapt_thresh = 0.001f;
|
||||
la->preview=NULL;
|
||||
la->falloff_type = LA_FALLOFF_INVLINEAR;
|
||||
la->curfalloff = curvemapping_add(1, 0.0f, 1.0f, 1.0f, 0.0f);
|
||||
@@ -748,12 +748,12 @@ void *add_lamp(char *name)
|
||||
la->spread = 1.0;
|
||||
la->sun_brightness = 1.0;
|
||||
la->sun_size = 1.0;
|
||||
la->backscattered_light = 1.0;
|
||||
la->atm_turbidity = 2.0;
|
||||
la->atm_inscattering_factor = 1.0;
|
||||
la->atm_extinction_factor = 1.0;
|
||||
la->atm_distance_factor = 1.0;
|
||||
la->sun_intensity = 1.0;
|
||||
la->backscattered_light = 1.0f;
|
||||
la->atm_turbidity = 2.0f;
|
||||
la->atm_inscattering_factor = 1.0f;
|
||||
la->atm_extinction_factor = 1.0f;
|
||||
la->atm_distance_factor = 1.0f;
|
||||
la->sun_intensity = 1.0f;
|
||||
la->skyblendtype= MA_RAMP_ADD;
|
||||
la->skyblendfac= 1.0f;
|
||||
la->sky_colorspace= BLI_CS_CIE;
|
||||
@@ -1864,7 +1864,6 @@ void where_is_object_time(Scene *scene, Object *ob, float ctime)
|
||||
/* and even worse, it gives bad effects for NLA stride too (try ctime != par->ctime, with MBlur) */
|
||||
pop= 0;
|
||||
if(no_parent_ipo==0 && stime != par->ctime) {
|
||||
|
||||
// only for ipo systems?
|
||||
pushdata(par, sizeof(Object));
|
||||
pop= 1;
|
||||
@@ -1874,16 +1873,15 @@ void where_is_object_time(Scene *scene, Object *ob, float ctime)
|
||||
}
|
||||
|
||||
solve_parenting(scene, ob, par, ob->obmat, slowmat, 0);
|
||||
|
||||
|
||||
if(pop) {
|
||||
poplast(par);
|
||||
}
|
||||
|
||||
if(ob->partype & PARSLOW) {
|
||||
// include framerate
|
||||
|
||||
fac1= (1.0f/(1.0f+ fabs(give_timeoffset(ob))));
|
||||
if(fac1>=1.0) return;
|
||||
fac1= ( 1.0f / (1.0f + (float)fabs(give_timeoffset(ob))) );
|
||||
if(fac1 >= 1.0f) return;
|
||||
fac2= 1.0f-fac1;
|
||||
|
||||
fp1= ob->obmat[0];
|
||||
@@ -1892,7 +1890,6 @@ void where_is_object_time(Scene *scene, Object *ob, float ctime)
|
||||
fp1[0]= fac1*fp1[0] + fac2*fp2[0];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
object_to_mat4(ob, ob->obmat);
|
||||
@@ -1902,7 +1899,6 @@ void where_is_object_time(Scene *scene, Object *ob, float ctime)
|
||||
if(ob->track) {
|
||||
if( ctime != ob->track->ctime) where_is_object_time(scene, ob->track, ctime);
|
||||
solve_tracking (ob, ob->track->obmat);
|
||||
|
||||
}
|
||||
|
||||
/* solve constraints */
|
||||
@@ -2088,7 +2084,7 @@ for a lamp that is the child of another object */
|
||||
bConstraintOb *cob;
|
||||
|
||||
cob= constraints_make_evalob(scene, ob, NULL, CONSTRAINT_OBTYPE_OBJECT);
|
||||
solve_constraints (&ob->constraints, cob, scene->r.cfra);
|
||||
solve_constraints(&ob->constraints, cob, (float)scene->r.cfra);
|
||||
constraints_clear_evalob(cob);
|
||||
}
|
||||
|
||||
@@ -2127,7 +2123,7 @@ void what_does_parent(Scene *scene, Object *ob, Object *workob)
|
||||
BoundBox *unit_boundbox()
|
||||
{
|
||||
BoundBox *bb;
|
||||
float min[3] = {-1,-1,-1}, max[3] = {-1,-1,-1};
|
||||
float min[3] = {-1.0f,-1.0f,-1.0f}, max[3] = {-1.0f,-1.0f,-1.0f};
|
||||
|
||||
bb= MEM_callocN(sizeof(BoundBox), "bb");
|
||||
boundbox_set_from_min_max(bb, min, max);
|
||||
|
||||
@@ -150,6 +150,7 @@ void free_scene(Scene *sce)
|
||||
#endif
|
||||
|
||||
BKE_free_animdata((ID *)sce);
|
||||
BKE_keyingsets_free(&sce->keyingsets);
|
||||
|
||||
if (sce->r.avicodecdata) {
|
||||
free_avicodecdata(sce->r.avicodecdata);
|
||||
@@ -565,33 +566,10 @@ int scene_check_setscene(Scene *sce)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void scene_update(Scene *sce, unsigned int lay)
|
||||
{
|
||||
Base *base;
|
||||
Object *ob;
|
||||
|
||||
if(sce->theDag==NULL)
|
||||
DAG_scene_sort(sce);
|
||||
|
||||
DAG_scene_update_flags(sce, lay); // only stuff that moves or needs display still
|
||||
|
||||
for(base= sce->base.first; base; base= base->next) {
|
||||
ob= base->object;
|
||||
|
||||
object_handle_update(sce, ob); // bke_object.h
|
||||
|
||||
/* only update layer when an ipo */
|
||||
// XXX old animation system
|
||||
//if(ob->ipo && has_ipo_code(ob->ipo, OB_LAY) ) {
|
||||
// base->lay= ob->lay;
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
/* This (evil) function is needed to cope with two legacy Blender rendering features
|
||||
* mblur (motion blur that renders 'subframes' and blurs them together), and fields
|
||||
* rendering. Thus, the use of ugly globals from object.c
|
||||
*/
|
||||
* mblur (motion blur that renders 'subframes' and blurs them together), and fields
|
||||
* rendering. Thus, the use of ugly globals from object.c
|
||||
*/
|
||||
// BAD... EVIL... JUJU...!!!!
|
||||
// XXX moved here temporarily
|
||||
float frame_to_float (Scene *scene, int cfra) /* see also bsystem_time in object.c */
|
||||
@@ -607,24 +585,47 @@ float frame_to_float (Scene *scene, int cfra) /* see also bsystem_time in objec
|
||||
return ctime;
|
||||
}
|
||||
|
||||
static void scene_update(Scene *sce, unsigned int lay)
|
||||
{
|
||||
Base *base;
|
||||
Object *ob;
|
||||
float ctime = frame_to_float(sce, sce->r.cfra);
|
||||
|
||||
if(sce->theDag==NULL)
|
||||
DAG_scene_sort(sce);
|
||||
|
||||
DAG_scene_update_flags(sce, lay); // only stuff that moves or needs display still
|
||||
|
||||
/* All 'standard' (i.e. without any dependencies) animation is handled here,
|
||||
* with an 'local' to 'macro' order of evaluation. This should ensure that
|
||||
* settings stored nestled within a hierarchy (i.e. settings in a Texture block
|
||||
* can be overridden by settings from Scene, which owns the Texture through a hierarchy
|
||||
* such as Scene->World->MTex/Texture) can still get correctly overridden.
|
||||
*/
|
||||
BKE_animsys_evaluate_all_animation(G.main, ctime);
|
||||
|
||||
for(base= sce->base.first; base; base= base->next) {
|
||||
ob= base->object;
|
||||
|
||||
object_handle_update(sce, ob); // bke_object.h
|
||||
|
||||
/* only update layer when an ipo */
|
||||
// XXX old animation system
|
||||
//if(ob->ipo && has_ipo_code(ob->ipo, OB_LAY) ) {
|
||||
// base->lay= ob->lay;
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* applies changes right away, does all sets too */
|
||||
void scene_update_for_newframe(Scene *sce, unsigned int lay)
|
||||
{
|
||||
Scene *scene= sce;
|
||||
float ctime = frame_to_float(sce, sce->r.cfra);
|
||||
|
||||
/* clear animation overrides */
|
||||
// XXX TODO...
|
||||
|
||||
/* All 'standard' (i.e. without any dependencies) animation is handled here,
|
||||
* with an 'local' to 'macro' order of evaluation. This should ensure that
|
||||
* settings stored nestled within a hierarchy (i.e. settings in a Texture block
|
||||
* can be overridden by settings from Scene, which owns the Texture through a hierarchy
|
||||
* such as Scene->World->MTex/Texture) can still get correctly overridden.
|
||||
*/
|
||||
BKE_animsys_evaluate_all_animation(G.main, ctime);
|
||||
|
||||
|
||||
#ifndef DISABLE_PYTHON
|
||||
if (G.f & G_DOSCRIPTLINKS) BPY_do_all_scripts(SCRIPT_FRAMECHANGED, 0);
|
||||
#endif
|
||||
|
||||
@@ -57,6 +57,8 @@ int BLI_in_rctf(struct rctf *rect, float x, float y);
|
||||
int BLI_isect_rctf(struct rctf *src1, struct rctf *src2, struct rctf *dest);
|
||||
int BLI_isect_rcti(struct rcti *src1, struct rcti *src2, struct rcti *dest);
|
||||
void BLI_union_rctf(struct rctf *rcta, struct rctf *rctb);
|
||||
void BLI_union_rcti(struct rcti *rcti1, struct rcti *rcti2);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -188,8 +188,7 @@ void BLI_ghash_free(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreef
|
||||
|
||||
if (keyfreefp) keyfreefp(e->key);
|
||||
if (valfreefp) valfreefp(e->val);
|
||||
BLI_mempool_free(gh->entrypool, e);
|
||||
|
||||
|
||||
e= n;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1599,16 +1599,16 @@ void QuatInterpolW(float *result, float *quat1, float *quat2, float t)
|
||||
cosom = quat1[0]*quat2[0] + quat1[1]*quat2[1] + quat1[2]*quat2[2] + quat1[3]*quat2[3] ;
|
||||
|
||||
/* rotate around shortest angle */
|
||||
if ((1.0 + cosom) > 0.0001) {
|
||||
if ((1.0f + cosom) > 0.0001f) {
|
||||
|
||||
if ((1.0 - cosom) > 0.0001) {
|
||||
omega = acos(cosom);
|
||||
sinom = sin(omega);
|
||||
sc1 = sin((1.0 - t) * omega) / sinom;
|
||||
sc2 = sin(t * omega) / sinom;
|
||||
if ((1.0f - cosom) > 0.0001f) {
|
||||
omega = (float)acos(cosom);
|
||||
sinom = (float)sin(omega);
|
||||
sc1 = (float)sin((1.0 - t) * omega) / sinom;
|
||||
sc2 = (float)sin(t * omega) / sinom;
|
||||
}
|
||||
else {
|
||||
sc1 = 1.0 - t;
|
||||
sc1 = 1.0f - t;
|
||||
sc2 = t;
|
||||
}
|
||||
result[0] = sc1*quat1[0] + sc2*quat2[0];
|
||||
@@ -1622,9 +1622,9 @@ void QuatInterpolW(float *result, float *quat1, float *quat2, float t)
|
||||
result[2] = quat2[1];
|
||||
result[3] = -quat2[0];
|
||||
|
||||
sc1 = sin((1.0 - t)*M_PI_2);
|
||||
sc2 = sin(t*M_PI_2);
|
||||
|
||||
sc1 = (float)sin((1.0 - t)*M_PI_2);
|
||||
sc2 = (float)sin(t*M_PI_2);
|
||||
|
||||
result[0] = sc1*quat1[0] + sc2*result[0];
|
||||
result[1] = sc1*quat1[1] + sc2*result[1];
|
||||
result[2] = sc1*quat1[2] + sc2*result[2];
|
||||
@@ -1639,7 +1639,7 @@ void QuatInterpol(float *result, float *quat1, float *quat2, float t)
|
||||
cosom = quat1[0]*quat2[0] + quat1[1]*quat2[1] + quat1[2]*quat2[2] + quat1[3]*quat2[3] ;
|
||||
|
||||
/* rotate around shortest angle */
|
||||
if (cosom < 0.0) {
|
||||
if (cosom < 0.0f) {
|
||||
cosom = -cosom;
|
||||
quat[0]= -quat1[0];
|
||||
quat[1]= -quat1[1];
|
||||
@@ -1653,13 +1653,13 @@ void QuatInterpol(float *result, float *quat1, float *quat2, float t)
|
||||
quat[3]= quat1[3];
|
||||
}
|
||||
|
||||
if ((1.0 - cosom) > 0.0001) {
|
||||
omega = acos(cosom);
|
||||
sinom = sin(omega);
|
||||
sc1 = sin((1 - t) * omega) / sinom;
|
||||
sc2 = sin(t * omega) / sinom;
|
||||
if ((1.0f - cosom) > 0.0001f) {
|
||||
omega = (float)acos(cosom);
|
||||
sinom = (float)sin(omega);
|
||||
sc1 = (float)sin((1 - t) * omega) / sinom;
|
||||
sc2 = (float)sin(t * omega) / sinom;
|
||||
} else {
|
||||
sc1= 1.0 - t;
|
||||
sc1= 1.0f - t;
|
||||
sc2= t;
|
||||
}
|
||||
|
||||
@@ -1775,7 +1775,7 @@ void DQuatToMat4(DualQuat *dq, float mat[][4])
|
||||
QuatCopy(q0, dq->quat);
|
||||
|
||||
/* normalize */
|
||||
len= sqrt(QuatDot(q0, q0));
|
||||
len= (float)sqrt(QuatDot(q0, q0));
|
||||
if(len != 0.0f)
|
||||
QuatMulf(q0, 1.0f/len);
|
||||
|
||||
@@ -1784,9 +1784,9 @@ void DQuatToMat4(DualQuat *dq, float mat[][4])
|
||||
|
||||
/* translation */
|
||||
t= dq->trans;
|
||||
mat[3][0]= 2.0*(-t[0]*q0[1] + t[1]*q0[0] - t[2]*q0[3] + t[3]*q0[2]);
|
||||
mat[3][1]= 2.0*(-t[0]*q0[2] + t[1]*q0[3] + t[2]*q0[0] - t[3]*q0[1]);
|
||||
mat[3][2]= 2.0*(-t[0]*q0[3] - t[1]*q0[2] + t[2]*q0[1] + t[3]*q0[0]);
|
||||
mat[3][0]= 2.0f*(-t[0]*q0[1] + t[1]*q0[0] - t[2]*q0[3] + t[3]*q0[2]);
|
||||
mat[3][1]= 2.0f*(-t[0]*q0[2] + t[1]*q0[3] + t[2]*q0[0] - t[3]*q0[1]);
|
||||
mat[3][2]= 2.0f*(-t[0]*q0[3] - t[1]*q0[2] + t[2]*q0[1] + t[3]*q0[0]);
|
||||
|
||||
/* note: this does not handle scaling */
|
||||
}
|
||||
@@ -1815,10 +1815,10 @@ void DQuatAddWeighted(DualQuat *dqsum, DualQuat *dq, float weight)
|
||||
/* interpolate scale - but only if needed */
|
||||
if (dq->scale_weight) {
|
||||
float wmat[4][4];
|
||||
|
||||
|
||||
if(flipped) /* we don't want negative weights for scaling */
|
||||
weight= -weight;
|
||||
|
||||
|
||||
Mat4CpyMat4(wmat, dq->scale);
|
||||
Mat4MulFloat((float*)wmat, weight);
|
||||
Mat4AddMat4(dqsum->scale, dqsum->scale, wmat);
|
||||
@@ -1835,7 +1835,7 @@ void DQuatNormalize(DualQuat *dq, float totweight)
|
||||
|
||||
if(dq->scale_weight) {
|
||||
float addweight= totweight - dq->scale_weight;
|
||||
|
||||
|
||||
if(addweight) {
|
||||
dq->scale[0][0] += addweight;
|
||||
dq->scale[1][1] += addweight;
|
||||
@@ -2197,7 +2197,7 @@ void VecNegf(float *v1)
|
||||
|
||||
void VecOrthoBasisf(float *v, float *v1, float *v2)
|
||||
{
|
||||
float f = sqrt(v[0]*v[0] + v[1]*v[1]);
|
||||
float f = (float)sqrt(v[0]*v[0] + v[1]*v[1]);
|
||||
|
||||
if (f < 1e-35f) {
|
||||
// degenerate case
|
||||
@@ -2349,9 +2349,9 @@ double Sqrt3d(double d)
|
||||
|
||||
void NormalShortToFloat(float *out, short *in)
|
||||
{
|
||||
out[0] = in[0] / 32767.0;
|
||||
out[1] = in[1] / 32767.0;
|
||||
out[2] = in[2] / 32767.0;
|
||||
out[0] = in[0] / 32767.0f;
|
||||
out[1] = in[1] / 32767.0f;
|
||||
out[2] = in[2] / 32767.0f;
|
||||
}
|
||||
|
||||
void NormalFloatToShort(short *out, float *in)
|
||||
@@ -2488,15 +2488,15 @@ short IsectLL2Ds(short *v1, short *v2, short *v3, short *v4)
|
||||
*/
|
||||
float div, labda, mu;
|
||||
|
||||
div= (v2[0]-v1[0])*(v4[1]-v3[1])-(v2[1]-v1[1])*(v4[0]-v3[0]);
|
||||
if(div==0.0) return -1;
|
||||
div= (float)((v2[0]-v1[0])*(v4[1]-v3[1])-(v2[1]-v1[1])*(v4[0]-v3[0]));
|
||||
if(div==0.0f) return -1;
|
||||
|
||||
labda= ((float)(v1[1]-v3[1])*(v4[0]-v3[0])-(v1[0]-v3[0])*(v4[1]-v3[1]))/div;
|
||||
|
||||
mu= ((float)(v1[1]-v3[1])*(v2[0]-v1[0])-(v1[0]-v3[0])*(v2[1]-v1[1]))/div;
|
||||
|
||||
if(labda>=0.0 && labda<=1.0 && mu>=0.0 && mu<=1.0) {
|
||||
if(labda==0.0 || labda==1.0 || mu==0.0 || mu==1.0) return 1;
|
||||
if(labda>=0.0f && labda<=1.0f && mu>=0.0f && mu<=1.0f) {
|
||||
if(labda==0.0f || labda==1.0f || mu==0.0f || mu==1.0f) return 1;
|
||||
return 2;
|
||||
}
|
||||
return 0;
|
||||
@@ -2655,9 +2655,9 @@ static int BarycentricWeights(float *v1, float *v2, float *v3, float *co, float
|
||||
|
||||
/* find best projection of face XY, XZ or YZ: barycentric weights of
|
||||
the 2d projected coords are the same and faster to compute */
|
||||
xn= fabs(n[0]);
|
||||
yn= fabs(n[1]);
|
||||
zn= fabs(n[2]);
|
||||
xn= (float)fabs(n[0]);
|
||||
yn= (float)fabs(n[1]);
|
||||
zn= (float)fabs(n[2]);
|
||||
if(zn>=xn && zn>=yn) {i= 0; j= 1;}
|
||||
else if(yn>=xn && yn>=zn) {i= 0; j= 2;}
|
||||
else {i= 1; j= 2;}
|
||||
@@ -2889,12 +2889,12 @@ void Mat4ToEul(float tmat[][4], float *eul)
|
||||
{
|
||||
float tempMat[3][3];
|
||||
|
||||
Mat3CpyMat4 (tempMat, tmat);
|
||||
Mat3CpyMat4(tempMat, tmat);
|
||||
Mat3Ortho(tempMat);
|
||||
Mat3ToEul(tempMat, eul);
|
||||
}
|
||||
|
||||
void QuatToEul( float *quat, float *eul)
|
||||
void QuatToEul(float *quat, float *eul)
|
||||
{
|
||||
float mat[3][3];
|
||||
|
||||
@@ -2903,7 +2903,7 @@ void QuatToEul( float *quat, float *eul)
|
||||
}
|
||||
|
||||
|
||||
void EulToQuat( float *eul, float *quat)
|
||||
void EulToQuat(float *eul, float *quat)
|
||||
{
|
||||
float ti, tj, th, ci, cj, ch, si, sj, sh, cc, cs, sc, ss;
|
||||
|
||||
@@ -2918,7 +2918,7 @@ void EulToQuat( float *eul, float *quat)
|
||||
quat[3] = cj*cs - sj*sc;
|
||||
}
|
||||
|
||||
void VecRotToMat3( float *vec, float phi, float mat[][3])
|
||||
void VecRotToMat3(float *vec, float phi, float mat[][3])
|
||||
{
|
||||
/* rotation of phi radials around vec */
|
||||
float vx, vx2, vy, vy2, vz, vz2, co, si;
|
||||
@@ -2944,7 +2944,7 @@ void VecRotToMat3( float *vec, float phi, float mat[][3])
|
||||
|
||||
}
|
||||
|
||||
void VecRotToMat4( float *vec, float phi, float mat[][4])
|
||||
void VecRotToMat4(float *vec, float phi, float mat[][4])
|
||||
{
|
||||
float tmat[3][3];
|
||||
|
||||
@@ -2953,7 +2953,7 @@ void VecRotToMat4( float *vec, float phi, float mat[][4])
|
||||
Mat4CpyMat3(mat, tmat);
|
||||
}
|
||||
|
||||
void VecRotToQuat( float *vec, float phi, float *quat)
|
||||
void VecRotToQuat(float *vec, float phi, float *quat)
|
||||
{
|
||||
/* rotation of phi radials around vec */
|
||||
float si;
|
||||
@@ -2962,7 +2962,7 @@ void VecRotToQuat( float *vec, float phi, float *quat)
|
||||
quat[2]= vec[1];
|
||||
quat[3]= vec[2];
|
||||
|
||||
if( Normalize(quat+1) == 0.0) {
|
||||
if( Normalize(quat+1) == 0.0f) {
|
||||
QuatOne(quat);
|
||||
}
|
||||
else {
|
||||
@@ -2986,7 +2986,7 @@ float VecAngle3(float *v1, float *v2, float *v3)
|
||||
Normalize(vec1);
|
||||
Normalize(vec2);
|
||||
|
||||
return NormalizedVecAngle2(vec1, vec2) * 180.0/M_PI;
|
||||
return NormalizedVecAngle2(vec1, vec2) * (float)(180.0/M_PI);
|
||||
}
|
||||
|
||||
float VecAngle3_2D(float *v1, float *v2, float *v3)
|
||||
@@ -3002,7 +3002,7 @@ float VecAngle3_2D(float *v1, float *v2, float *v3)
|
||||
Normalize2(vec1);
|
||||
Normalize2(vec2);
|
||||
|
||||
return NormalizedVecAngle2_2D(vec1, vec2) * 180.0/M_PI;
|
||||
return NormalizedVecAngle2_2D(vec1, vec2) * (float)(180.0/M_PI);
|
||||
}
|
||||
|
||||
/* Return the shortest angle in degrees between the 2 vectors */
|
||||
@@ -3015,7 +3015,7 @@ float VecAngle2(float *v1, float *v2)
|
||||
Normalize(vec1);
|
||||
Normalize(vec2);
|
||||
|
||||
return NormalizedVecAngle2(vec1, vec2)* 180.0/M_PI;
|
||||
return NormalizedVecAngle2(vec1, vec2)* (float)(180.0/M_PI);
|
||||
}
|
||||
|
||||
float NormalizedVecAngle2(float *v1, float *v2)
|
||||
@@ -3027,11 +3027,11 @@ float NormalizedVecAngle2(float *v1, float *v2)
|
||||
vec[0]= -v2[0];
|
||||
vec[1]= -v2[1];
|
||||
vec[2]= -v2[2];
|
||||
|
||||
return (float)M_PI - 2.0f*saasin(VecLenf(vec, v1)/2.0f);
|
||||
|
||||
return (float)M_PI - 2.0f*(float)saasin(VecLenf(vec, v1)/2.0f);
|
||||
}
|
||||
else
|
||||
return 2.0f*saasin(VecLenf(v2, v1)/2.0);
|
||||
return 2.0f*(float)saasin(VecLenf(v2, v1)/2.0f);
|
||||
}
|
||||
|
||||
float NormalizedVecAngle2_2D(float *v1, float *v2)
|
||||
@@ -3042,18 +3042,18 @@ float NormalizedVecAngle2_2D(float *v1, float *v2)
|
||||
|
||||
vec[0]= -v2[0];
|
||||
vec[1]= -v2[1];
|
||||
|
||||
|
||||
return (float)M_PI - 2.0f*saasin(Vec2Lenf(vec, v1)/2.0f);
|
||||
}
|
||||
else
|
||||
return 2.0f*saasin(Vec2Lenf(v2, v1)/2.0);
|
||||
return 2.0f*(float)saasin(Vec2Lenf(v2, v1)/2.0f);
|
||||
}
|
||||
|
||||
void euler_rot(float *beul, float ang, char axis)
|
||||
{
|
||||
float eul[3], mat1[3][3], mat2[3][3], totmat[3][3];
|
||||
|
||||
eul[0]= eul[1]= eul[2]= 0.0;
|
||||
eul[0]= eul[1]= eul[2]= 0.0f;
|
||||
if(axis=='x') eul[0]= ang;
|
||||
else if(axis=='y') eul[1]= ang;
|
||||
else eul[2]= ang;
|
||||
@@ -3073,33 +3073,32 @@ void compatible_eul(float *eul, float *oldrot)
|
||||
float dx, dy, dz;
|
||||
|
||||
/* correct differences of about 360 degrees first */
|
||||
|
||||
dx= eul[0] - oldrot[0];
|
||||
dy= eul[1] - oldrot[1];
|
||||
dz= eul[2] - oldrot[2];
|
||||
|
||||
while( fabs(dx) > 5.1) {
|
||||
if(dx > 0.0) eul[0] -= 2.0*M_PI; else eul[0]+= 2.0*M_PI;
|
||||
while(fabs(dx) > 5.1) {
|
||||
if(dx > 0.0f) eul[0] -= 2.0f*(float)M_PI; else eul[0]+= 2.0f*(float)M_PI;
|
||||
dx= eul[0] - oldrot[0];
|
||||
}
|
||||
while( fabs(dy) > 5.1) {
|
||||
if(dy > 0.0) eul[1] -= 2.0*M_PI; else eul[1]+= 2.0*M_PI;
|
||||
while(fabs(dy) > 5.1) {
|
||||
if(dy > 0.0f) eul[1] -= 2.0f*(float)M_PI; else eul[1]+= 2.0f*(float)M_PI;
|
||||
dy= eul[1] - oldrot[1];
|
||||
}
|
||||
while( fabs(dz) > 5.1 ) {
|
||||
if(dz > 0.0) eul[2] -= 2.0*M_PI; else eul[2]+= 2.0*M_PI;
|
||||
while(fabs(dz) > 5.1) {
|
||||
if(dz > 0.0f) eul[2] -= 2.0f*(float)M_PI; else eul[2]+= 2.0f*(float)M_PI;
|
||||
dz= eul[2] - oldrot[2];
|
||||
}
|
||||
|
||||
/* is 1 of the axis rotations larger than 180 degrees and the other small? NO ELSE IF!! */
|
||||
if( fabs(dx) > 3.2 && fabs(dy)<1.6 && fabs(dz)<1.6 ) {
|
||||
if(dx > 0.0) eul[0] -= 2.0*M_PI; else eul[0]+= 2.0*M_PI;
|
||||
if(dx > 0.0) eul[0] -= 2.0f*(float)M_PI; else eul[0]+= 2.0f*(float)M_PI;
|
||||
}
|
||||
if( fabs(dy) > 3.2 && fabs(dz)<1.6 && fabs(dx)<1.6 ) {
|
||||
if(dy > 0.0) eul[1] -= 2.0*M_PI; else eul[1]+= 2.0*M_PI;
|
||||
if(dy > 0.0) eul[1] -= 2.0f*(float)M_PI; else eul[1]+= 2.0f*(float)M_PI;
|
||||
}
|
||||
if( fabs(dz) > 3.2 && fabs(dx)<1.6 && fabs(dy)<1.6 ) {
|
||||
if(dz > 0.0) eul[2] -= 2.0*M_PI; else eul[2]+= 2.0*M_PI;
|
||||
if(dz > 0.0) eul[2] -= 2.0f*(float)M_PI; else eul[2]+= 2.0f*(float)M_PI;
|
||||
}
|
||||
|
||||
/* the method below was there from ancient days... but why! probably because the code sucks :)
|
||||
@@ -3142,8 +3141,8 @@ void Mat3ToCompatibleEul(float mat[][3], float *eul, float *oldrot)
|
||||
compatible_eul(eul1, oldrot);
|
||||
compatible_eul(eul2, oldrot);
|
||||
|
||||
d1= fabs(eul1[0]-oldrot[0]) + fabs(eul1[1]-oldrot[1]) + fabs(eul1[2]-oldrot[2]);
|
||||
d2= fabs(eul2[0]-oldrot[0]) + fabs(eul2[1]-oldrot[1]) + fabs(eul2[2]-oldrot[2]);
|
||||
d1= (float)fabs(eul1[0]-oldrot[0]) + (float)fabs(eul1[1]-oldrot[1]) + (float)fabs(eul1[2]-oldrot[2]);
|
||||
d2= (float)fabs(eul2[0]-oldrot[0]) + (float)fabs(eul2[1]-oldrot[1]) + (float)fabs(eul2[2]-oldrot[2]);
|
||||
|
||||
/* return best, which is just the one with lowest difference */
|
||||
if( d1 > d2) {
|
||||
@@ -3160,14 +3159,14 @@ void Mat3ToCompatibleEul(float mat[][3], float *eul, float *oldrot)
|
||||
void SizeToMat3( float *size, float mat[][3])
|
||||
{
|
||||
mat[0][0]= size[0];
|
||||
mat[0][1]= 0.0;
|
||||
mat[0][2]= 0.0;
|
||||
mat[0][1]= 0.0f;
|
||||
mat[0][2]= 0.0f;
|
||||
mat[1][1]= size[1];
|
||||
mat[1][0]= 0.0;
|
||||
mat[1][2]= 0.0;
|
||||
mat[1][0]= 0.0f;
|
||||
mat[1][2]= 0.0f;
|
||||
mat[2][2]= size[2];
|
||||
mat[2][1]= 0.0;
|
||||
mat[2][0]= 0.0;
|
||||
mat[2][1]= 0.0f;
|
||||
mat[2][0]= 0.0f;
|
||||
}
|
||||
|
||||
void SizeToMat4( float *size, float mat[][4])
|
||||
@@ -3199,7 +3198,7 @@ void Mat4ToSize( float mat[][4], float *size)
|
||||
float Mat3ToScalef(float mat[][3])
|
||||
{
|
||||
/* unit length vector */
|
||||
float unit_vec[3] = {0.577350269189626, 0.577350269189626, 0.577350269189626};
|
||||
float unit_vec[3] = {0.577350269189626f, 0.577350269189626f, 0.577350269189626f};
|
||||
Mat3MulVecfl(mat, unit_vec);
|
||||
return VecLength(unit_vec);
|
||||
}
|
||||
@@ -3224,12 +3223,12 @@ void triatoquat( float *v1, float *v2, float *v3, float *quat)
|
||||
|
||||
n[0]= vec[1];
|
||||
n[1]= -vec[0];
|
||||
n[2]= 0.0;
|
||||
n[2]= 0.0f;
|
||||
Normalize(n);
|
||||
|
||||
if(n[0]==0.0 && n[1]==0.0) n[0]= 1.0;
|
||||
if(n[0]==0.0f && n[1]==0.0f) n[0]= 1.0f;
|
||||
|
||||
angle= -0.5f*saacos(vec[2]);
|
||||
angle= -0.5f*(float)saacos(vec[2]);
|
||||
co= (float)cos(angle);
|
||||
si= (float)sin(angle);
|
||||
q1[0]= co;
|
||||
@@ -3244,7 +3243,7 @@ void triatoquat( float *v1, float *v2, float *v3, float *quat)
|
||||
Mat3MulVecfl(imat, vec);
|
||||
|
||||
/* what angle has this line with x-axis? */
|
||||
vec[2]= 0.0;
|
||||
vec[2]= 0.0f;
|
||||
Normalize(vec);
|
||||
|
||||
angle= (float)(0.5*atan2(vec[1], vec[0]));
|
||||
@@ -3319,12 +3318,11 @@ float Normalize2(float *n)
|
||||
|
||||
if(d>1.0e-35F) {
|
||||
d= (float)sqrt(d);
|
||||
|
||||
n[0]/=d;
|
||||
n[1]/=d;
|
||||
} else {
|
||||
n[0]=n[1]= 0.0;
|
||||
d= 0.0;
|
||||
n[0]=n[1]= 0.0f;
|
||||
d= 0.0f;
|
||||
}
|
||||
return d;
|
||||
}
|
||||
@@ -3389,9 +3387,9 @@ void hsv_to_rgb(float h, float s, float v, float *r, float *g, float *b)
|
||||
void rgb_to_yuv(float r, float g, float b, float *ly, float *lu, float *lv)
|
||||
{
|
||||
float y, u, v;
|
||||
y= 0.299*r + 0.587*g + 0.114*b;
|
||||
u=-0.147*r - 0.289*g + 0.436*b;
|
||||
v= 0.615*r - 0.515*g - 0.100*b;
|
||||
y= 0.299f*r + 0.587f*g + 0.114f*b;
|
||||
u=-0.147f*r - 0.289f*g + 0.436f*b;
|
||||
v= 0.615f*r - 0.515f*g - 0.100f*b;
|
||||
|
||||
*ly=y;
|
||||
*lu=u;
|
||||
@@ -3401,9 +3399,9 @@ void rgb_to_yuv(float r, float g, float b, float *ly, float *lu, float *lv)
|
||||
void yuv_to_rgb(float y, float u, float v, float *lr, float *lg, float *lb)
|
||||
{
|
||||
float r, g, b;
|
||||
r=y+1.140*v;
|
||||
g=y-0.394*u - 0.581*v;
|
||||
b=y+2.032*u;
|
||||
r=y+1.140f*v;
|
||||
g=y-0.394f*u - 0.581f*v;
|
||||
b=y+2.032f*u;
|
||||
|
||||
*lr=r;
|
||||
*lg=g;
|
||||
@@ -3415,14 +3413,14 @@ void rgb_to_ycc(float r, float g, float b, float *ly, float *lcb, float *lcr)
|
||||
float sr,sg, sb;
|
||||
float y, cr, cb;
|
||||
|
||||
sr=255.0*r;
|
||||
sg=255.0*g;
|
||||
sb=255.0*b;
|
||||
sr=255.0f*r;
|
||||
sg=255.0f*g;
|
||||
sb=255.0f*b;
|
||||
|
||||
|
||||
y=(0.257*sr)+(0.504*sg)+(0.098*sb)+16.0;
|
||||
cb=(-0.148*sr)-(0.291*sg)+(0.439*sb)+128.0;
|
||||
cr=(0.439*sr)-(0.368*sg)-(0.071*sb)+128.0;
|
||||
y=(0.257f*sr)+(0.504f*sg)+(0.098f*sb)+16.0f;
|
||||
cb=(-0.148f*sr)-(0.291f*sg)+(0.439f*sb)+128.0f;
|
||||
cr=(0.439f*sr)-(0.368f*sg)-(0.071f*sb)+128.0f;
|
||||
|
||||
*ly=y;
|
||||
*lcb=cb;
|
||||
@@ -3433,13 +3431,13 @@ void ycc_to_rgb(float y, float cb, float cr, float *lr, float *lg, float *lb)
|
||||
{
|
||||
float r,g,b;
|
||||
|
||||
r=1.164*(y-16)+1.596*(cr-128);
|
||||
g=1.164*(y-16)-0.813*(cr-128)-0.392*(cb-128);
|
||||
b=1.164*(y-16)+2.017*(cb-128);
|
||||
r=1.164f*(y-16.0f)+1.596f*(cr-128.0f);
|
||||
g=1.164f*(y-16.0f)-0.813f*(cr-128.0f)-0.392f*(cb-128.0f);
|
||||
b=1.164f*(y-16.0f)+2.017f*(cb-128.0f);
|
||||
|
||||
*lr=r/255.0;
|
||||
*lg=g/255.0;
|
||||
*lb=b/255.0;
|
||||
*lr=r/255.0f;
|
||||
*lg=g/255.0f;
|
||||
*lb=b/255.0f;
|
||||
}
|
||||
|
||||
void hex_to_rgb(char *hexcol, float *r, float *g, float *b)
|
||||
@@ -3449,9 +3447,9 @@ void hex_to_rgb(char *hexcol, float *r, float *g, float *b)
|
||||
if (hexcol[0] == '#') hexcol++;
|
||||
|
||||
if (sscanf(hexcol, "%02x%02x%02x", &ri, &gi, &bi)) {
|
||||
*r = ri / 255.0;
|
||||
*g = gi / 255.0;
|
||||
*b = bi / 255.0;
|
||||
*r = ri / 255.0f;
|
||||
*g = gi / 255.0f;
|
||||
*b = bi / 255.0f;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3469,14 +3467,14 @@ void rgb_to_hsv(float r, float g, float b, float *lh, float *ls, float *lv)
|
||||
cmin = (b<cmin ? b:cmin);
|
||||
|
||||
v = cmax; /* value */
|
||||
if (cmax!=0.0)
|
||||
if (cmax != 0.0f)
|
||||
s = (cmax - cmin)/cmax;
|
||||
else {
|
||||
s = 0.0;
|
||||
h = 0.0;
|
||||
s = 0.0f;
|
||||
h = 0.0f;
|
||||
}
|
||||
if (s == 0.0)
|
||||
h = -1.0;
|
||||
if (s == 0.0f)
|
||||
h = -1.0f;
|
||||
else {
|
||||
cdelta = cmax-cmin;
|
||||
rc = (cmax-r)/cdelta;
|
||||
@@ -3490,13 +3488,13 @@ void rgb_to_hsv(float r, float g, float b, float *lh, float *ls, float *lv)
|
||||
else
|
||||
h = 4.0f+gc-rc;
|
||||
h = h*60.0f;
|
||||
if (h<0.0f)
|
||||
if (h < 0.0f)
|
||||
h += 360.0f;
|
||||
}
|
||||
|
||||
*ls = s;
|
||||
*lh = h/360.0f;
|
||||
if( *lh < 0.0) *lh= 0.0;
|
||||
*lh = h / 360.0f;
|
||||
if(*lh < 0.0f) *lh= 0.0f;
|
||||
*lv = v;
|
||||
}
|
||||
|
||||
@@ -3506,14 +3504,14 @@ void xyz_to_rgb(float xc, float yc, float zc, float *r, float *g, float *b, int
|
||||
{
|
||||
switch (colorspace) {
|
||||
case BLI_CS_SMPTE:
|
||||
*r = (3.50570 * xc) + (-1.73964 * yc) + (-0.544011 * zc);
|
||||
*g = (-1.06906 * xc) + (1.97781 * yc) + (0.0351720 * zc);
|
||||
*b = (0.0563117 * xc) + (-0.196994 * yc) + (1.05005 * zc);
|
||||
*r = (3.50570f * xc) + (-1.73964f * yc) + (-0.544011f * zc);
|
||||
*g = (-1.06906f * xc) + (1.97781f * yc) + (0.0351720f * zc);
|
||||
*b = (0.0563117f * xc) + (-0.196994f * yc) + (1.05005f * zc);
|
||||
break;
|
||||
case BLI_CS_REC709:
|
||||
*r = (3.240476 * xc) + (-1.537150 * yc) + (-0.498535 * zc);
|
||||
*g = (-0.969256 * xc) + (1.875992 * yc) + (0.041556 * zc);
|
||||
*b = (0.055648 * xc) + (-0.204043 * yc) + (1.057311 * zc);
|
||||
*r = (3.240476f * xc) + (-1.537150f * yc) + (-0.498535f * zc);
|
||||
*g = (-0.969256f * xc) + (1.875992f * yc) + (0.041556f * zc);
|
||||
*b = (0.055648f * xc) + (-0.204043f * yc) + (1.057311f * zc);
|
||||
break;
|
||||
case BLI_CS_CIE:
|
||||
*r = (2.28783848734076f * xc) + (-0.833367677835217f * yc) + (-0.454470795871421f * zc);
|
||||
@@ -3558,13 +3556,12 @@ int constrain_rgb(float *r, float *g, float *b)
|
||||
static void gamma_correct(float *c)
|
||||
{
|
||||
/* Rec. 709 gamma correction. */
|
||||
float cc = 0.018;
|
||||
float cc = 0.018f;
|
||||
|
||||
if (*c < cc) {
|
||||
*c *= ((1.099 * pow(cc, 0.45)) - 0.099) / cc;
|
||||
} else {
|
||||
*c = (1.099 * pow(*c, 0.45)) - 0.099;
|
||||
}
|
||||
if (*c < cc)
|
||||
*c *= ((1.099f * (float)pow(cc, 0.45)) - 0.099f) / cc;
|
||||
else
|
||||
*c = (1.099f * (float)pow(*c, 0.45)) - 0.099f;
|
||||
}
|
||||
|
||||
void gamma_correct_rgb(float *r, float *g, float *b)
|
||||
@@ -3630,14 +3627,13 @@ void tubemap(float x, float y, float z, float *u, float *v)
|
||||
{
|
||||
float len;
|
||||
|
||||
*v = (z + 1.0) / 2.0;
|
||||
*v = (z + 1.0f) / 2.0f;
|
||||
|
||||
len= sqrt(x*x+y*y);
|
||||
if(len>0) {
|
||||
*u = (1.0 - (atan2(x/len,y/len) / M_PI)) / 2.0;
|
||||
} else {
|
||||
len= (float)sqrt(x*x+y*y);
|
||||
if(len > 0.0f)
|
||||
*u = (float)((1.0 - (atan2(x/len,y/len) / M_PI)) / 2.0);
|
||||
else
|
||||
*v = *u = 0.0f; /* to avoid un-initialized variables */
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@@ -3646,14 +3642,13 @@ void spheremap(float x, float y, float z, float *u, float *v)
|
||||
{
|
||||
float len;
|
||||
|
||||
len= sqrt(x*x+y*y+z*z);
|
||||
if(len>0.0) {
|
||||
|
||||
if(x==0.0 && y==0.0) *u= 0.0; /* othwise domain error */
|
||||
else *u = (1.0 - atan2(x,y)/M_PI )/2.0;
|
||||
len= (float)sqrt(x*x+y*y+z*z);
|
||||
if(len > 0.0f) {
|
||||
if(x==0.0f && y==0.0f) *u= 0.0f; /* othwise domain error */
|
||||
else *u = (float)((1.0 - (float)atan2(x,y) / M_PI) / 2.0);
|
||||
|
||||
z/=len;
|
||||
*v = 1.0- saacos(z)/M_PI;
|
||||
*v = 1.0f - (float)saacos(z)/(float)M_PI;
|
||||
} else {
|
||||
*v = *u = 0.0f; /* to avoid un-initialized variables */
|
||||
}
|
||||
@@ -3913,7 +3908,7 @@ static int getLowestRoot(float a, float b, float c, float maxR, float* root)
|
||||
{
|
||||
// calculate the two roots: (if determinant == 0 then
|
||||
// x1==x2 but let’s disregard that slight optimization)
|
||||
float sqrtD = sqrt(determinant);
|
||||
float sqrtD = (float)sqrt(determinant);
|
||||
float r1 = (-b - sqrtD) / (2.0f*a);
|
||||
float r2 = (-b + sqrtD) / (2.0f*a);
|
||||
|
||||
@@ -4694,5 +4689,5 @@ void tangent_from_uv(float *uv1, float *uv2, float *uv3, float *co1, float *co2,
|
||||
|
||||
/* used for zoom values*/
|
||||
float power_of_2(float val) {
|
||||
return pow(2, ceil(log(val) / log(2)));
|
||||
return (float)pow(2, ceil(log(val) / log(2)));
|
||||
}
|
||||
|
||||
@@ -70,7 +70,16 @@ int BLI_in_rctf(rctf *rect, float x, float y)
|
||||
|
||||
void BLI_union_rctf(rctf *rct1, rctf *rct2)
|
||||
{
|
||||
|
||||
if(rct1->xmin>rct2->xmin) rct1->xmin= rct2->xmin;
|
||||
if(rct1->xmax<rct2->xmax) rct1->xmax= rct2->xmax;
|
||||
if(rct1->ymin>rct2->ymin) rct1->ymin= rct2->ymin;
|
||||
if(rct1->ymax<rct2->ymax) rct1->ymax= rct2->ymax;
|
||||
}
|
||||
|
||||
void BLI_union_rcti(rcti *rct1, rcti *rct2)
|
||||
{
|
||||
|
||||
if(rct1->xmin>rct2->xmin) rct1->xmin= rct2->xmin;
|
||||
if(rct1->xmax<rct2->xmax) rct1->xmax= rct2->xmax;
|
||||
if(rct1->ymin>rct2->ymin) rct1->ymin= rct2->ymin;
|
||||
|
||||
@@ -163,4 +163,4 @@ void BLI_timestr(double _time, char *str)
|
||||
}
|
||||
|
||||
str[11]=0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1929,6 +1929,39 @@ static void direct_link_action(FileData *fd, bAction *act)
|
||||
|
||||
/* ------- */
|
||||
|
||||
static void lib_link_keyingsets(FileData *fd, ID *id, ListBase *list)
|
||||
{
|
||||
KeyingSet *ks;
|
||||
KS_Path *ksp;
|
||||
|
||||
/* here, we're only interested in the ID pointer stored in some of the paths */
|
||||
for (ks= list->first; ks; ks= ks->next) {
|
||||
for (ksp= ks->paths.first; ksp; ksp= ksp->next) {
|
||||
ksp->id= newlibadr(fd, id->lib, ksp->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* NOTE: this assumes that link_list has already been called on the list */
|
||||
static void direct_link_keyingsets(FileData *fd, ListBase *list)
|
||||
{
|
||||
KeyingSet *ks;
|
||||
KS_Path *ksp;
|
||||
|
||||
/* link KeyingSet data to KeyingSet again (non ID-libs) */
|
||||
for (ks= list->first; ks; ks= ks->next) {
|
||||
/* paths */
|
||||
link_list(fd, &ks->paths);
|
||||
|
||||
for (ksp= ks->paths.first; ksp; ksp= ksp->next) {
|
||||
/* rna path */
|
||||
ksp->rna_path= newdataadr(fd, ksp->rna_path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ------- */
|
||||
|
||||
static void lib_link_animdata(FileData *fd, ID *id, AnimData *adt)
|
||||
{
|
||||
if (adt == NULL)
|
||||
@@ -3698,6 +3731,8 @@ static void lib_link_scene(FileData *fd, Main *main)
|
||||
if (sce->id.properties) IDP_LibLinkProperty(sce->id.properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
|
||||
if (sce->adt) lib_link_animdata(fd, &sce->id, sce->adt);
|
||||
|
||||
lib_link_keyingsets(fd, &sce->id, &sce->keyingsets);
|
||||
|
||||
sce->camera= newlibadr(fd, sce->id.lib, sce->camera);
|
||||
sce->world= newlibadr_us(fd, sce->id.lib, sce->world);
|
||||
sce->set= newlibadr(fd, sce->id.lib, sce->set);
|
||||
@@ -3791,6 +3826,9 @@ static void direct_link_scene(FileData *fd, Scene *sce)
|
||||
sce->adt= newdataadr(fd, sce->adt);
|
||||
direct_link_animdata(fd, sce->adt);
|
||||
|
||||
link_list(fd, &sce->keyingsets);
|
||||
direct_link_keyingsets(fd, &sce->keyingsets);
|
||||
|
||||
sce->basact= newdataadr(fd, sce->basact);
|
||||
|
||||
sce->radio= newdataadr(fd, sce->radio);
|
||||
@@ -5525,7 +5563,7 @@ static void area_add_window_regions(ScrArea *sa, SpaceLink *sl, ListBase *lb)
|
||||
/* we totally reinit the view for the Action Editor, as some old instances had some weird cruft set */
|
||||
ar->v2d.tot.xmin= -20.0f;
|
||||
ar->v2d.tot.ymin= (float)(-sa->winy);
|
||||
ar->v2d.tot.xmax= (float)(sa->winx);
|
||||
ar->v2d.tot.xmax= (float)((sa->winx > 120)? (sa->winx) : 120);
|
||||
ar->v2d.tot.ymax= 0.0f;
|
||||
|
||||
ar->v2d.cur= ar->v2d.tot;
|
||||
@@ -9124,6 +9162,19 @@ static void expand_action(FileData *fd, Main *mainvar, bAction *act)
|
||||
}
|
||||
}
|
||||
|
||||
static void expand_keyingsets(FileData *fd, Main *mainvar, ListBase *list)
|
||||
{
|
||||
KeyingSet *ks;
|
||||
KS_Path *ksp;
|
||||
|
||||
/* expand the ID-pointers in KeyingSets's paths */
|
||||
for (ks= list->first; ks; ks= ks->next) {
|
||||
for (ksp= ks->paths.first; ksp; ksp= ksp->next) {
|
||||
expand_doit(fd, mainvar, ksp->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void expand_animdata(FileData *fd, Main *mainvar, AnimData *adt)
|
||||
{
|
||||
FCurve *fcd;
|
||||
@@ -9655,6 +9706,7 @@ static void expand_scene(FileData *fd, Main *mainvar, Scene *sce)
|
||||
|
||||
if(sce->adt)
|
||||
expand_animdata(fd, mainvar, sce->adt);
|
||||
expand_keyingsets(fd, mainvar, &sce->keyingsets);
|
||||
|
||||
if(sce->nodetree)
|
||||
expand_nodetree(fd, mainvar, sce->nodetree);
|
||||
|
||||
@@ -855,6 +855,26 @@ static void write_actions(WriteData *wd, ListBase *idbase)
|
||||
mywrite(wd, MYWRITE_FLUSH, 0);
|
||||
}
|
||||
|
||||
static void write_keyingsets(WriteData *wd, ListBase *list)
|
||||
{
|
||||
KeyingSet *ks;
|
||||
KS_Path *ksp;
|
||||
|
||||
for (ks= list->first; ks; ks= ks->next) {
|
||||
/* KeyingSet */
|
||||
writestruct(wd, DATA, "KeyingSet", 1, ks);
|
||||
|
||||
/* Paths */
|
||||
for (ksp= ks->paths.first; ksp; ksp= ksp->next) {
|
||||
/* Path */
|
||||
writestruct(wd, DATA, "KS_Path", 1, ksp);
|
||||
|
||||
if (ksp->rna_path)
|
||||
writedata(wd, DATA, strlen(ksp->rna_path)+1, ksp->rna_path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void write_animdata(WriteData *wd, AnimData *adt)
|
||||
{
|
||||
AnimOverride *aor;
|
||||
@@ -1533,6 +1553,7 @@ static void write_scenes(WriteData *wd, ListBase *scebase)
|
||||
if (sce->id.properties) IDP_WriteProperty(sce->id.properties, wd);
|
||||
|
||||
if (sce->adt) write_animdata(wd, sce->adt);
|
||||
write_keyingsets(wd, &sce->keyingsets);
|
||||
|
||||
/* direct data */
|
||||
base= sce->base.first;
|
||||
@@ -1616,9 +1637,9 @@ static void write_scenes(WriteData *wd, ListBase *scebase)
|
||||
writestruct(wd, DATA, "MetaStack", 1, ms);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
write_scriptlink(wd, &sce->scriptlink);
|
||||
|
||||
|
||||
if (sce->r.avicodecdata) {
|
||||
writestruct(wd, DATA, "AviCodecData", 1, sce->r.avicodecdata);
|
||||
if (sce->r.avicodecdata->lpFormat) writedata(wd, DATA, sce->r.avicodecdata->cbFormat, sce->r.avicodecdata->lpFormat);
|
||||
|
||||
@@ -608,12 +608,70 @@ void ANIM_OT_channels_move_bottom (wmOperatorType *ot)
|
||||
|
||||
#endif // XXX old animation system - needs to be updated for new system...
|
||||
|
||||
|
||||
/* ******************** Toggle Channel Visibility Operator *********************** */
|
||||
|
||||
static int animchannels_visibility_toggle_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
bAnimContext ac;
|
||||
ListBase anim_data = {NULL, NULL};
|
||||
bAnimListElem *ale;
|
||||
int filter;
|
||||
short vis= ACHANNEL_SETFLAG_ADD;
|
||||
|
||||
/* get editor data */
|
||||
if (ANIM_animdata_get_context(C, &ac) == 0)
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
/* filter data */
|
||||
filter= (ANIMFILTER_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_CURVESONLY);
|
||||
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
|
||||
|
||||
/* See if we should be making showing all selected or hiding */
|
||||
for (ale= anim_data.first; ale; ale= ale->next) {
|
||||
if (vis == ACHANNEL_SETFLAG_CLEAR)
|
||||
break;
|
||||
|
||||
if (ale->flag & FCURVE_VISIBLE)
|
||||
vis= ACHANNEL_SETFLAG_CLEAR;
|
||||
}
|
||||
|
||||
/* Now set the flags */
|
||||
for (ale= anim_data.first; ale; ale= ale->next) {
|
||||
FCurve *fcu= (FCurve *)ale->data;
|
||||
ACHANNEL_SET_FLAG(fcu, vis, FCURVE_VISIBLE);
|
||||
}
|
||||
|
||||
/* cleanup */
|
||||
BLI_freelistN(&anim_data);
|
||||
|
||||
/* set notifier tha things have changed */
|
||||
ANIM_animdata_send_notifiers(C, &ac, ANIM_CHANGED_CHANNELS);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
void ANIM_OT_channels_visibility_toggle (wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name= "Toggle Visibility";
|
||||
ot->idname= "ANIM_OT_channels_visibility_toggle";
|
||||
|
||||
/* api callbacks */
|
||||
ot->exec= animchannels_visibility_toggle_exec;
|
||||
ot->poll= ED_operator_ipo_active;
|
||||
|
||||
/* flags */
|
||||
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
/* ********************** Set Flags Operator *********************** */
|
||||
|
||||
enum {
|
||||
// ACHANNEL_SETTING_SELECT = 0,
|
||||
ACHANNEL_SETTING_PROTECT = 1,
|
||||
ACHANNEL_SETTING_MUTE,
|
||||
ACHANNEL_SETTING_VISIBLE,
|
||||
} eAnimChannel_Settings;
|
||||
|
||||
/* defines for setting animation-channel flags */
|
||||
@@ -672,6 +730,9 @@ static void setflag_anim_channels (bAnimContext *ac, short setting, short mode)
|
||||
else if (setting == ACHANNEL_SETTING_PROTECT) {
|
||||
ACHANNEL_SET_FLAG(fcu, mode, FCURVE_PROTECTED);
|
||||
}
|
||||
else if (setting == ACHANNEL_SETTING_VISIBLE) {
|
||||
ACHANNEL_SET_FLAG(fcu, mode, FCURVE_VISIBLE);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ANIMTYPE_GPLAYER:
|
||||
@@ -1075,7 +1136,7 @@ static void mouse_anim_channels (bAnimContext *ac, float x, int channel_index, s
|
||||
case ANIMTYPE_GROUP:
|
||||
{
|
||||
bActionGroup *agrp= (bActionGroup *)ale->data;
|
||||
short offset= (ac->datatype == ANIMCONT_DOPESHEET)? 21 : 0;
|
||||
short offset= (ELEM3(ac->datatype, ANIMCONT_DOPESHEET, ANIMCONT_FCURVES, ANIMCONT_DRIVERS))? 18 : 0;
|
||||
|
||||
if ((x < (offset+17)) && (agrp->channels.first)) {
|
||||
/* toggle expand */
|
||||
@@ -1120,6 +1181,7 @@ static void mouse_anim_channels (bAnimContext *ac, float x, int channel_index, s
|
||||
case ANIMTYPE_FCURVE:
|
||||
{
|
||||
FCurve *fcu= (FCurve *)ale->data;
|
||||
short offset= (ac->datatype != ANIMCONT_ACTION)? 18 : 0;
|
||||
|
||||
if (x >= (ACHANNEL_NAMEWIDTH-ACHANNEL_BUTTON_WIDTH)) {
|
||||
/* toggle protection */
|
||||
@@ -1129,6 +1191,11 @@ static void mouse_anim_channels (bAnimContext *ac, float x, int channel_index, s
|
||||
/* toggle mute */
|
||||
fcu->flag ^= FCURVE_MUTED;
|
||||
}
|
||||
else if ((x < (offset+17)) && (ac->spacetype==SPACE_IPO)) {
|
||||
/* toggle visibility */
|
||||
// XXX this is supposed to be button before name, though this sometimes fails
|
||||
fcu->flag ^= FCURVE_VISIBLE;
|
||||
}
|
||||
else {
|
||||
/* select/deselect */
|
||||
fcu->flag ^= FCURVE_SELECTED;
|
||||
@@ -1274,6 +1341,8 @@ void ED_operatortypes_animchannels(void)
|
||||
//WM_operatortype_append(ANIM_OT_channels_move_down);
|
||||
//WM_operatortype_append(ANIM_OT_channels_move_top);
|
||||
//WM_operatortype_append(ANIM_OT_channels_move_bottom);
|
||||
|
||||
WM_operatortype_append(ANIM_OT_channels_visibility_toggle);
|
||||
}
|
||||
|
||||
void ED_keymap_animchannels(wmWindowManager *wm)
|
||||
@@ -1304,6 +1373,9 @@ void ED_keymap_animchannels(wmWindowManager *wm)
|
||||
//WM_keymap_add_item(keymap, "ANIM_OT_channels_move_down", PAGEDOWNKEY, KM_PRESS, KM_SHIFT, 0);
|
||||
//WM_keymap_add_item(keymap, "ANIM_OT_channels_move_to_top", PAGEUPKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0);
|
||||
//WM_keymap_add_item(keymap, "ANIM_OT_channels_move_to_bottom", PAGEDOWNKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0);
|
||||
|
||||
/* Graph Editor only */
|
||||
WM_keymap_add_item(keymap, "ANIM_OT_channels_visibility_toggle", VKEY, KM_PRESS, 0, 0);
|
||||
}
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -484,7 +484,7 @@ static int animdata_filter_fcurves (ListBase *anim_data, FCurve *first, bActionG
|
||||
*/
|
||||
for (fcu= first; ((fcu) && (fcu->grp==grp)); fcu= fcu->next) {
|
||||
/* only include if visible (Graph Editor check, not channels check) */
|
||||
//if (!(filter_mode & ANIMFILTER_CURVEVISIBLE) || (fcu->flag & FCURVE_VISIBLE)) { // XXX don't do this till we have tools to set this
|
||||
if (!(filter_mode & ANIMFILTER_CURVEVISIBLE) || (fcu->flag & FCURVE_VISIBLE)) {
|
||||
/* only work with this channel and its subchannels if it is editable */
|
||||
if (!(filter_mode & ANIMFILTER_FOREDIT) || EDITABLE_FCU(fcu)) {
|
||||
/* only include this curve if selected */
|
||||
@@ -498,7 +498,7 @@ static int animdata_filter_fcurves (ListBase *anim_data, FCurve *first, bActionG
|
||||
}
|
||||
}
|
||||
}
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
/* return the number of items added to the list */
|
||||
|
||||
@@ -172,12 +172,20 @@ static int change_frame_modal(bContext *C, wmOperator *op, wmEvent *event)
|
||||
{
|
||||
/* execute the events */
|
||||
switch (event->type) {
|
||||
case ESCKEY:
|
||||
change_frame_exit(C, op);
|
||||
return OPERATOR_FINISHED;
|
||||
|
||||
case MOUSEMOVE:
|
||||
RNA_int_set(op->ptr, "frame", frame_from_event(C, event));
|
||||
change_frame_apply(C, op);
|
||||
break;
|
||||
|
||||
case LEFTMOUSE:
|
||||
|
||||
case LEFTMOUSE:
|
||||
case RIGHTMOUSE:
|
||||
/* we check for either mouse-button to end, as checking for ACTIONMOUSE (which is used to init
|
||||
* the modal op) doesn't work for some reason
|
||||
*/
|
||||
if (event->val==0) {
|
||||
change_frame_exit(C, op);
|
||||
return OPERATOR_FINISHED;
|
||||
@@ -378,11 +386,12 @@ void ED_keymap_anim(wmWindowManager *wm)
|
||||
{
|
||||
ListBase *keymap= WM_keymap_listbase(wm, "Animation", 0, 0);
|
||||
|
||||
/* frame management */
|
||||
WM_keymap_verify_item(keymap, "ANIM_OT_change_frame", LEFTMOUSE, KM_PRESS, 0, 0);
|
||||
/* frame management */
|
||||
/* NOTE: 'ACTIONMOUSE' not 'LEFTMOUSE', as user may have swapped mouse-buttons */
|
||||
WM_keymap_verify_item(keymap, "ANIM_OT_change_frame", ACTIONMOUSE, KM_PRESS, 0, 0);
|
||||
WM_keymap_verify_item(keymap, "ANIM_OT_time_toggle", TKEY, KM_PRESS, KM_CTRL, 0);
|
||||
|
||||
/* preview range */
|
||||
/* preview range */
|
||||
WM_keymap_verify_item(keymap, "ANIM_OT_previewrange_define", PKEY, KM_PRESS, KM_CTRL, 0);
|
||||
WM_keymap_verify_item(keymap, "ANIM_OT_previewrange_clear", PKEY, KM_PRESS, KM_ALT, 0);
|
||||
}
|
||||
|
||||
@@ -103,6 +103,13 @@ void delete_fcurve_keys(FCurve *fcu)
|
||||
}
|
||||
}
|
||||
|
||||
/* Free the array of BezTriples if there are not keyframes */
|
||||
if (fcu->totvert == 0) {
|
||||
if (fcu->bezt)
|
||||
MEM_freeN(fcu->bezt);
|
||||
fcu->bezt= NULL;
|
||||
}
|
||||
|
||||
#if 0 // XXX for now, we don't get rid of empty curves...
|
||||
/* Only delete if there isn't an ipo-driver still hanging around on an empty curve */
|
||||
if ((icu->totvert==0) && (icu->driver==NULL)) {
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <float.h>
|
||||
@@ -29,6 +30,7 @@
|
||||
#include "BKE_fcurve.h"
|
||||
#include "BKE_utildefines.h"
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_report.h"
|
||||
#include "BKE_key.h"
|
||||
#include "BKE_material.h"
|
||||
|
||||
@@ -38,6 +40,8 @@
|
||||
#include "ED_screen.h"
|
||||
#include "ED_util.h"
|
||||
|
||||
#include "UI_interface.h"
|
||||
|
||||
#include "WM_api.h"
|
||||
#include "WM_types.h"
|
||||
|
||||
@@ -62,46 +66,17 @@ typedef struct bCommonKeySrc {
|
||||
bPoseChannel *pchan; /* only needed when doing recalcs... */
|
||||
} bCommonKeySrc;
|
||||
|
||||
/* -------------- Keying Sets ------------------- */
|
||||
|
||||
#if 0 // XXX I'm not sure how these will work for now...
|
||||
|
||||
/* keying set - a set of channels that will be keyframed together */
|
||||
// TODO: move this to a header to allow custom sets someday?
|
||||
typedef struct bKeyingSet {
|
||||
/* callback func to consider if keyingset should be included
|
||||
* (by default, if this is undefined, item will be shown)
|
||||
*/
|
||||
short (*include_cb)(struct bKeyingSet *, const char *);
|
||||
|
||||
char name[48]; /* name of keyingset */
|
||||
int blocktype; /* nearest ID-blocktype to where data can be found */
|
||||
short flag; /* flags to use when setting keyframes */
|
||||
|
||||
short chan_num; /* number of channels to insert keyframe in */
|
||||
char (*paths)[256]; /* adrcodes for channels to insert keys for (ideally would be variable-len, but limit of 32 will suffice) */
|
||||
} bKeyingSet;
|
||||
|
||||
/* keying set context - an array of keying sets and the number of them */
|
||||
typedef struct bKeyingContext {
|
||||
bKeyingSet *keyingsets; /* array containing the keyingsets of interest */
|
||||
bKeyingSet *lastused; /* item that was chosen last time*/
|
||||
int tot; /* number of keyingsets in */
|
||||
} bKeyingContext;
|
||||
|
||||
#endif
|
||||
|
||||
/* ******************************************* */
|
||||
/* Animation Data Validation */
|
||||
|
||||
/* Get (or add relevant data to be able to do so) F-Curve from the Active Action,
|
||||
* for the given Animation Data block
|
||||
* for the given Animation Data block. This assumes that all the destinations are valid.
|
||||
*/
|
||||
// TODO: should we check if path is valid? For now, assume that it's already set OK by caller...
|
||||
FCurve *verify_fcurve (ID *id, const char rna_path[], const int array_index, short add)
|
||||
FCurve *verify_fcurve (ID *id, const char group[], const char rna_path[], const int array_index, short add)
|
||||
{
|
||||
AnimData *adt;
|
||||
bAction *act;
|
||||
bActionGroup *grp;
|
||||
FCurve *fcu;
|
||||
|
||||
/* sanity checks */
|
||||
@@ -133,10 +108,10 @@ FCurve *verify_fcurve (ID *id, const char rna_path[], const int array_index, sho
|
||||
fcu= NULL;
|
||||
|
||||
if ((fcu == NULL) && (add)) {
|
||||
/* use default settings */
|
||||
/* use default settings to make a F-Curve */
|
||||
fcu= MEM_callocN(sizeof(FCurve), "FCurve");
|
||||
|
||||
fcu->flag |= (FCURVE_VISIBLE|FCURVE_AUTO_HANDLES);
|
||||
fcu->flag = (FCURVE_VISIBLE|FCURVE_AUTO_HANDLES|FCURVE_SELECTED);
|
||||
if (act->curves.first==NULL)
|
||||
fcu->flag |= FCURVE_ACTIVE; /* first one added active */
|
||||
|
||||
@@ -144,8 +119,36 @@ FCurve *verify_fcurve (ID *id, const char rna_path[], const int array_index, sho
|
||||
fcu->rna_path= BLI_strdupn(rna_path, strlen(rna_path));
|
||||
fcu->array_index= array_index;
|
||||
|
||||
/* add curve */
|
||||
BLI_addtail(&act->curves, fcu); // XXX it might be better to add this in order, for easier UI coding...
|
||||
/* set additional flags */
|
||||
// TODO: need to set the FCURVE_INT_VALUES flag must be set if property is not float!
|
||||
|
||||
|
||||
/* if a group name has been provided, try to add or find a group, then add F-Curve to it */
|
||||
if (group) {
|
||||
/* try to find group */
|
||||
grp= action_groups_find_named(act, group);
|
||||
|
||||
/* no matching groups, so add one */
|
||||
if (grp == NULL) {
|
||||
/* Add a new group, and make it active */
|
||||
grp= MEM_callocN(sizeof(bActionGroup), "bActionGroup");
|
||||
|
||||
grp->flag |= (AGRP_ACTIVE|AGRP_SELECTED|AGRP_EXPANDED);
|
||||
BLI_snprintf(grp->name, 64, group);
|
||||
|
||||
BLI_addtail(&act->groups, grp);
|
||||
BLI_uniquename(&act->groups, grp, "Group", offsetof(bActionGroup, name), 64);
|
||||
|
||||
set_active_action_group(act, grp, 1);
|
||||
}
|
||||
|
||||
/* add F-Curve to group */
|
||||
action_groups_add_channel(act, grp, fcu);
|
||||
}
|
||||
else {
|
||||
/* just add F-Curve to end of Action's list */
|
||||
BLI_addtail(&act->curves, fcu);
|
||||
}
|
||||
}
|
||||
|
||||
/* return the F-Curve */
|
||||
@@ -158,7 +161,7 @@ FCurve *verify_fcurve (ID *id, const char rna_path[], const int array_index, sho
|
||||
/* -------------- BezTriple Insertion -------------------- */
|
||||
|
||||
/* threshold for inserting keyframes - threshold here should be good enough for now, but should become userpref */
|
||||
#define BEZT_INSERT_THRESH 0.00001
|
||||
#define BEZT_INSERT_THRESH 0.00001f
|
||||
|
||||
/* Binary search algorithm for finding where to insert BezTriple. (for use by insert_bezt_icu)
|
||||
* Returns the index to insert at (data already at that index will be offset if replace is 0)
|
||||
@@ -711,7 +714,7 @@ static float visualkey_get_value (PointerRNA *ptr, PropertyRNA *prop, int array_
|
||||
* the keyframe insertion. These include the 'visual' keyframing modes, quick refresh,
|
||||
* and extra keyframe filtering.
|
||||
*/
|
||||
short insertkey (ID *id, const char rna_path[], int array_index, float cfra, short flag)
|
||||
short insertkey (ID *id, const char group[], const char rna_path[], int array_index, float cfra, short flag)
|
||||
{
|
||||
PointerRNA id_ptr, ptr;
|
||||
PropertyRNA *prop;
|
||||
@@ -725,7 +728,7 @@ short insertkey (ID *id, const char rna_path[], int array_index, float cfra, sho
|
||||
}
|
||||
|
||||
/* get F-Curve */
|
||||
fcu= verify_fcurve(id, rna_path, array_index, 1);
|
||||
fcu= verify_fcurve(id, group, rna_path, array_index, 1);
|
||||
|
||||
/* only continue if we have an F-Curve to add keyframe to */
|
||||
if (fcu) {
|
||||
@@ -809,7 +812,7 @@ short insertkey (ID *id, const char rna_path[], int array_index, float cfra, sho
|
||||
* The flag argument is used for special settings that alter the behaviour of
|
||||
* the keyframe deletion. These include the quick refresh options.
|
||||
*/
|
||||
short deletekey (ID *id, const char rna_path[], int array_index, float cfra, short flag)
|
||||
short deletekey (ID *id, const char group[], const char rna_path[], int array_index, float cfra, short flag)
|
||||
{
|
||||
AnimData *adt;
|
||||
FCurve *fcu;
|
||||
@@ -819,7 +822,7 @@ short deletekey (ID *id, const char rna_path[], int array_index, float cfra, sho
|
||||
* so 'add' var must be 0
|
||||
*/
|
||||
// XXX we don't check the validity of the path here yet, but it should be ok...
|
||||
fcu= verify_fcurve(id, rna_path, array_index, 0);
|
||||
fcu= verify_fcurve(id, group, rna_path, array_index, 0);
|
||||
adt= BKE_animdata_from_id(id);
|
||||
|
||||
/* only continue if we have an ipo-curve to remove keyframes from */
|
||||
@@ -873,6 +876,46 @@ enum {
|
||||
COMMONKEY_MODE_DELETE,
|
||||
} eCommonModifyKey_Modes;
|
||||
|
||||
|
||||
/* Build menu-string of available keying-sets (allocates memory for string)
|
||||
* NOTE: mode must not be longer than 64 chars
|
||||
*/
|
||||
char *ANIM_build_keyingsets_menu (ListBase *list, short for_edit)
|
||||
{
|
||||
DynStr *pupds= BLI_dynstr_new();
|
||||
KeyingSet *ks;
|
||||
char buf[64];
|
||||
char *str;
|
||||
int i;
|
||||
|
||||
/* add title first */
|
||||
BLI_dynstr_append(pupds, "Keying Sets%t|");
|
||||
|
||||
/* add dummy entries for none-active */
|
||||
if (for_edit) {
|
||||
BLI_dynstr_append(pupds, "Add New%x-1|");
|
||||
BLI_dynstr_append(pupds, " %x0|");
|
||||
}
|
||||
else
|
||||
BLI_dynstr_append(pupds, "<No Keying Set Active>%x0|");
|
||||
|
||||
/* loop through keyingsets, adding them */
|
||||
for (ks=list->first, i=1; ks; ks=ks->next, i++) {
|
||||
if (for_edit == 0)
|
||||
BLI_dynstr_append(pupds, "KS: ");
|
||||
|
||||
BLI_dynstr_append(pupds, ks->name);
|
||||
BLI_snprintf( buf, 64, "%%x%d%s", i, ((ks->next)?"|":"") );
|
||||
BLI_dynstr_append(pupds, buf);
|
||||
}
|
||||
|
||||
/* convert to normal MEM_malloc'd string */
|
||||
str= BLI_dynstr_get_cstring(pupds);
|
||||
BLI_dynstr_free(pupds);
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
#if 0 // XXX old keyingsets code based on adrcodes... to be restored in due course
|
||||
|
||||
/* --------- KeyingSet Adrcode Getters ------------ */
|
||||
@@ -1760,57 +1803,6 @@ static void commonkey_context_refresh (bContext *C)
|
||||
|
||||
/* --- */
|
||||
|
||||
/* Build menu-string of available keying-sets (allocates memory for string)
|
||||
* NOTE: mode must not be longer than 64 chars
|
||||
*/
|
||||
static char *build_keyingsets_menu (bKeyingContext *ksc, const char mode[48])
|
||||
{
|
||||
DynStr *pupds= BLI_dynstr_new();
|
||||
bKeyingSet *ks;
|
||||
char buf[64];
|
||||
char *str;
|
||||
int i, n;
|
||||
|
||||
/* add title first */
|
||||
BLI_snprintf(buf, 64, "%s Key %%t|", mode);
|
||||
BLI_dynstr_append(pupds, buf);
|
||||
|
||||
/* loop through keyingsets, adding them */
|
||||
for (ks=ksc->keyingsets, i=0, n=1; i < ksc->tot; ks++, i++, n++) {
|
||||
/* check if keyingset can be used */
|
||||
if (ks->flag == -1) {
|
||||
/* optional separator? */
|
||||
if (ks->include_cb) {
|
||||
if (ks->include_cb(ks, mode)) {
|
||||
BLI_snprintf( buf, 64, "%s%s", ks->name, ((n < ksc->tot)?"|":"") );
|
||||
BLI_dynstr_append(pupds, buf);
|
||||
}
|
||||
}
|
||||
else {
|
||||
BLI_snprintf( buf, 64, "%%l%s", ((n < ksc->tot)?"|":"") );
|
||||
BLI_dynstr_append(pupds, buf);
|
||||
}
|
||||
}
|
||||
else if ( (ks->include_cb==NULL) || (ks->include_cb(ks, mode)) ) {
|
||||
/* entry can be included */
|
||||
BLI_dynstr_append(pupds, ks->name);
|
||||
|
||||
/* check if special "shapekey" entry */
|
||||
if (ks->flag == -3)
|
||||
BLI_snprintf( buf, 64, "%%x0%s", ((n < ksc->tot)?"|":"") );
|
||||
else
|
||||
BLI_snprintf( buf, 64, "%%x%d%s", n, ((n < ksc->tot)?"|":"") );
|
||||
BLI_dynstr_append(pupds, buf);
|
||||
}
|
||||
}
|
||||
|
||||
/* convert to normal MEM_malloc'd string */
|
||||
str= BLI_dynstr_get_cstring(pupds);
|
||||
BLI_dynstr_free(pupds);
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
/* Get the keying set that was chosen by the user from the menu */
|
||||
static bKeyingSet *get_keyingset_fromcontext (bKeyingContext *ksc, short index)
|
||||
{
|
||||
@@ -2007,6 +1999,92 @@ void common_modifykey (bContext *C, short mode)
|
||||
|
||||
#endif // XXX old keyingsets code based on adrcodes... to be restored in due course
|
||||
|
||||
/* Given a KeyingSet and context info (if required), modify keyframes for the channels specified
|
||||
* by the KeyingSet. This takes into account many of the different combinations of using KeyingSets.
|
||||
* Returns the number of channels that keyframes were added to
|
||||
*/
|
||||
static int commonkey_modifykey (ListBase *dsources, KeyingSet *ks, short mode, float cfra)
|
||||
{
|
||||
KS_Path *ksp;
|
||||
int kflag, success= 0;
|
||||
char *groupname= NULL;
|
||||
|
||||
/* get flags to use */
|
||||
if (mode == COMMONKEY_MODE_INSERT) {
|
||||
/* use KeyingSet's flags as base */
|
||||
kflag= ks->keyingflag;
|
||||
|
||||
/* suppliment with info from the context */
|
||||
if (IS_AUTOKEY_FLAG(AUTOMATKEY)) kflag |= INSERTKEY_MATRIX;
|
||||
if (IS_AUTOKEY_FLAG(INSERTNEEDED)) kflag |= INSERTKEY_NEEDED;
|
||||
// if (IS_AUTOKEY_MODE(EDITKEYS)) flag |= INSERTKEY_REPLACE;
|
||||
}
|
||||
else if (mode == COMMONKEY_MODE_DELETE)
|
||||
kflag= 0;
|
||||
|
||||
/* check if the KeyingSet is absolute or not (i.e. does it requires sources info) */
|
||||
if (ks->flag & KEYINGSET_ABSOLUTE) {
|
||||
/* Absolute KeyingSets are simpler to use, as all the destination info has already been
|
||||
* provided by the user, and is stored, ready to use, in the KeyingSet paths.
|
||||
*/
|
||||
for (ksp= ks->paths.first; ksp; ksp= ksp->next) {
|
||||
int arraylen, i;
|
||||
|
||||
/* get pointer to name of group to add channels to */
|
||||
if (ksp->flag & KSP_FLAG_GROUP_NONE)
|
||||
groupname= NULL;
|
||||
else if (ksp->flag & KSP_FLAG_GROUP_KSNAME)
|
||||
groupname= ks->name;
|
||||
else
|
||||
groupname= ksp->group;
|
||||
|
||||
/* init arraylen and i - arraylen should be greater than i so that
|
||||
* normal non-array entries get keyframed correctly
|
||||
*/
|
||||
i= ksp->array_index;
|
||||
arraylen= i+1;
|
||||
|
||||
/* get length of array if whole array option is enabled */
|
||||
if (ksp->flag & KSP_FLAG_WHOLE_ARRAY) {
|
||||
PointerRNA id_ptr, ptr;
|
||||
PropertyRNA *prop;
|
||||
|
||||
RNA_id_pointer_create(ksp->id, &id_ptr);
|
||||
if (RNA_path_resolve(&id_ptr, ksp->rna_path, &ptr, &prop))
|
||||
arraylen= RNA_property_array_length(&ptr, prop);
|
||||
}
|
||||
|
||||
/* for each possible index, perform operation
|
||||
* - assume that arraylen is greater than index
|
||||
*/
|
||||
for (; i < arraylen; i++) {
|
||||
/* action to take depends on mode */
|
||||
if (mode == COMMONKEY_MODE_INSERT)
|
||||
success+= insertkey(ksp->id, groupname, ksp->rna_path, i, cfra, kflag);
|
||||
else if (mode == COMMONKEY_MODE_DELETE)
|
||||
success+= deletekey(ksp->id, groupname, ksp->rna_path, i, cfra, kflag);
|
||||
}
|
||||
|
||||
// TODO: set recalc tags on the ID?
|
||||
}
|
||||
}
|
||||
#if 0 // XXX still need to figure out how to get such keyingsets working
|
||||
else if (dsources) {
|
||||
/* for each one of the 'sources', resolve the template markers and expand arrays, then insert keyframes */
|
||||
bCommonKeySrc *cks;
|
||||
char *path = NULL;
|
||||
int index=0, tot=0;
|
||||
|
||||
/* for each 'source' for keyframe data, resolve each of the paths from the KeyingSet */
|
||||
for (cks= dsources->first; cks; cks= cks->next) {
|
||||
|
||||
}
|
||||
}
|
||||
#endif // XXX still need to figure out how to get such
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
/* Insert Key Operator ------------------------ */
|
||||
|
||||
/* XXX WARNING:
|
||||
@@ -2020,15 +2098,49 @@ void common_modifykey (bContext *C, short mode)
|
||||
/* defines for basic insert-key testing operator */
|
||||
// XXX this will definitely be replaced
|
||||
EnumPropertyItem prop_insertkey_types[] = {
|
||||
{0, "OBLOC", "Object Location", ""},
|
||||
{1, "OBROT", "Object Rotation", ""},
|
||||
{2, "OBSCALE", "Object Scale", ""},
|
||||
{3, "MAT_COL", "Active Material - Color", ""},
|
||||
{4, "PCHANLOC", "Pose-Channel Location", ""},
|
||||
{5, "PCHANROT", "Pose-Channel Rotation", ""},
|
||||
{6, "PCHANSCALE", "Pose-Channel Scale", ""},
|
||||
{0, "KEYINGSET", "Active KeyingSet", ""},
|
||||
{1, "OBLOC", "Object Location", ""},
|
||||
{2, "OBROT", "Object Rotation", ""},
|
||||
{3, "OBSCALE", "Object Scale", ""},
|
||||
{4, "MAT_COL", "Active Material - Color", ""},
|
||||
{5, "PCHANLOC", "Pose-Channel Location", ""},
|
||||
{6, "PCHANROT", "Pose-Channel Rotation", ""},
|
||||
{7, "PCHANSCALE", "Pose-Channel Scale", ""},
|
||||
{0, NULL, NULL, NULL}
|
||||
};
|
||||
|
||||
static int insert_key_invoke (bContext *C, wmOperator *op, wmEvent *event)
|
||||
{
|
||||
Object *ob= CTX_data_active_object(C);
|
||||
uiMenuItem *head;
|
||||
|
||||
if (ob == NULL)
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
head= uiPupMenuBegin("Insert Keyframe", 0);
|
||||
|
||||
/* active keyingset */
|
||||
uiMenuItemEnumO(head, "", 0, "ANIM_OT_insert_keyframe", "type", 0);
|
||||
|
||||
/* selective inclusion */
|
||||
if ((ob->pose) && (ob->flag & OB_POSEMODE)) {
|
||||
/* bone types */
|
||||
uiMenuItemEnumO(head, "", 0, "ANIM_OT_insert_keyframe", "type", 5);
|
||||
uiMenuItemEnumO(head, "", 0, "ANIM_OT_insert_keyframe", "type", 6);
|
||||
uiMenuItemEnumO(head, "", 0, "ANIM_OT_insert_keyframe", "type", 7);
|
||||
}
|
||||
else {
|
||||
/* object types */
|
||||
uiMenuItemEnumO(head, "", 0, "ANIM_OT_insert_keyframe", "type", 1);
|
||||
uiMenuItemEnumO(head, "", 0, "ANIM_OT_insert_keyframe", "type", 2);
|
||||
uiMenuItemEnumO(head, "", 0, "ANIM_OT_insert_keyframe", "type", 3);
|
||||
uiMenuItemEnumO(head, "", 0, "ANIM_OT_insert_keyframe", "type", 4);
|
||||
}
|
||||
|
||||
uiPupMenuEnd(C, head);
|
||||
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
static int insert_key_exec (bContext *C, wmOperator *op)
|
||||
{
|
||||
@@ -2036,86 +2148,124 @@ static int insert_key_exec (bContext *C, wmOperator *op)
|
||||
short mode= RNA_enum_get(op->ptr, "type");
|
||||
float cfra= (float)CFRA; // XXX for now, don't bother about all the yucky offset crap
|
||||
|
||||
// XXX more comprehensive tests will be needed
|
||||
CTX_DATA_BEGIN(C, Base*, base, selected_bases)
|
||||
{
|
||||
Object *ob= base->object;
|
||||
ID *id= (ID *)ob;
|
||||
short success= 0;
|
||||
/* for now, handle 'active keyingset' one separately */
|
||||
if (mode == 0) {
|
||||
ListBase dsources = {NULL, NULL};
|
||||
KeyingSet *ks= NULL;
|
||||
short success;
|
||||
|
||||
/* check which keyframing mode chosen for this object */
|
||||
if (mode < 4) {
|
||||
/* object-based keyframes */
|
||||
switch (mode) {
|
||||
case 3: /* color of active material (only for geometry...) */
|
||||
// NOTE: this is just a demo... but ideally we'd go through materials instead of active one only so reference stays same
|
||||
success+= insertkey(id, "active_material.diffuse_color", 0, cfra, 0);
|
||||
success+= insertkey(id, "active_material.diffuse_color", 1, cfra, 0);
|
||||
success+= insertkey(id, "active_material.diffuse_color", 2, cfra, 0);
|
||||
break;
|
||||
case 2: /* object scale */
|
||||
success+= insertkey(id, "scale", 0, cfra, 0);
|
||||
success+= insertkey(id, "scale", 1, cfra, 0);
|
||||
success+= insertkey(id, "scale", 2, cfra, 0);
|
||||
break;
|
||||
case 1: /* object rotation */
|
||||
success+= insertkey(id, "rotation", 0, cfra, 0);
|
||||
success+= insertkey(id, "rotation", 1, cfra, 0);
|
||||
success+= insertkey(id, "rotation", 2, cfra, 0);
|
||||
break;
|
||||
default: /* object location */
|
||||
success+= insertkey(id, "location", 0, cfra, 0);
|
||||
success+= insertkey(id, "location", 1, cfra, 0);
|
||||
success+= insertkey(id, "location", 2, cfra, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
ob->recalc |= OB_RECALC_OB;
|
||||
/* try to get KeyingSet */
|
||||
if (scene->active_keyingset > 0)
|
||||
ks= BLI_findlink(&scene->keyingsets, scene->active_keyingset-1);
|
||||
/* report failure */
|
||||
if (ks == NULL) {
|
||||
BKE_report(op->reports, RPT_ERROR, "No active Keying Set");
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
else if ((ob->pose) && (ob->flag & OB_POSEMODE)) {
|
||||
/* PoseChannel based keyframes */
|
||||
bPoseChannel *pchan;
|
||||
|
||||
/* try to insert keyframes for the channels specified by KeyingSet */
|
||||
success= commonkey_modifykey(&dsources, ks, COMMONKEY_MODE_INSERT, cfra);
|
||||
printf("KeyingSet '%s' - Successfully added %d Keyframes \n", ks->name, success);
|
||||
|
||||
/* report failure */
|
||||
if (success == 0) {
|
||||
BKE_report(op->reports, RPT_WARNING, "Keying Set failed to insert any keyframes");
|
||||
return OPERATOR_CANCELLED; // XXX?
|
||||
}
|
||||
else
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
else {
|
||||
// more comprehensive tests will be needed
|
||||
CTX_DATA_BEGIN(C, Base*, base, selected_bases)
|
||||
{
|
||||
Object *ob= base->object;
|
||||
ID *id= (ID *)ob;
|
||||
short success= 0;
|
||||
|
||||
for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
|
||||
/* only if selected */
|
||||
if ((pchan->bone) && (pchan->bone->flag & BONE_SELECTED)) {
|
||||
char buf[512];
|
||||
|
||||
switch (mode) {
|
||||
case 6: /* pchan scale */
|
||||
sprintf(buf, "pose.pose_channels[\"%s\"].scale", pchan->name);
|
||||
success+= insertkey(id, buf, 0, cfra, 0);
|
||||
success+= insertkey(id, buf, 1, cfra, 0);
|
||||
success+= insertkey(id, buf, 2, cfra, 0);
|
||||
break;
|
||||
case 5: /* pchan rotation */
|
||||
sprintf(buf, "pose.pose_channels[\"%s\"].rotation", pchan->name);
|
||||
success+= insertkey(id, buf, 0, cfra, 0);
|
||||
success+= insertkey(id, buf, 1, cfra, 0);
|
||||
success+= insertkey(id, buf, 2, cfra, 0);
|
||||
success+= insertkey(id, buf, 3, cfra, 0);
|
||||
break;
|
||||
default: /* pchan location */
|
||||
sprintf(buf, "pose.pose_channels[\"%s\"].location", pchan->name);
|
||||
success+= insertkey(id, buf, 0, cfra, 0);
|
||||
success+= insertkey(id, buf, 1, cfra, 0);
|
||||
success+= insertkey(id, buf, 2, cfra, 0);
|
||||
break;
|
||||
/* check which keyframing mode chosen for this object */
|
||||
if (mode < 4) {
|
||||
/* object-based keyframes */
|
||||
switch (mode) {
|
||||
case 4: /* color of active material (only for geometry...) */
|
||||
// NOTE: this is just a demo... but ideally we'd go through materials instead of active one only so reference stays same
|
||||
// XXX no group for now
|
||||
success+= insertkey(id, NULL, "active_material.diffuse_color", 0, cfra, 0);
|
||||
success+= insertkey(id, NULL, "active_material.diffuse_color", 1, cfra, 0);
|
||||
success+= insertkey(id, NULL, "active_material.diffuse_color", 2, cfra, 0);
|
||||
break;
|
||||
case 3: /* object scale */
|
||||
success+= insertkey(id, "Object Transforms", "scale", 0, cfra, 0);
|
||||
success+= insertkey(id, "Object Transforms", "scale", 1, cfra, 0);
|
||||
success+= insertkey(id, "Object Transforms", "scale", 2, cfra, 0);
|
||||
break;
|
||||
case 2: /* object rotation */
|
||||
success+= insertkey(id, "Object Transforms", "rotation", 0, cfra, 0);
|
||||
success+= insertkey(id, "Object Transforms", "rotation", 1, cfra, 0);
|
||||
success+= insertkey(id, "Object Transforms", "rotation", 2, cfra, 0);
|
||||
break;
|
||||
case 1: /* object location */
|
||||
success+= insertkey(id, "Object Transforms", "location", 0, cfra, 0);
|
||||
success+= insertkey(id, "Object Transforms", "location", 1, cfra, 0);
|
||||
success+= insertkey(id, "Object Transforms", "location", 2, cfra, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
ob->recalc |= OB_RECALC_OB;
|
||||
}
|
||||
else if ((ob->pose) && (ob->flag & OB_POSEMODE)) {
|
||||
/* PoseChannel based keyframes */
|
||||
bPoseChannel *pchan;
|
||||
|
||||
for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
|
||||
/* only if selected */
|
||||
if ((pchan->bone) && (pchan->bone->flag & BONE_SELECTED)) {
|
||||
char buf[512];
|
||||
|
||||
switch (mode) {
|
||||
case 6: /* pchan scale */
|
||||
sprintf(buf, "pose.pose_channels[\"%s\"].scale", pchan->name);
|
||||
success+= insertkey(id, pchan->name, buf, 0, cfra, 0);
|
||||
success+= insertkey(id, pchan->name, buf, 1, cfra, 0);
|
||||
success+= insertkey(id, pchan->name, buf, 2, cfra, 0);
|
||||
break;
|
||||
case 5: /* pchan rotation */
|
||||
if (pchan->rotmode == PCHAN_ROT_QUAT) {
|
||||
sprintf(buf, "pose.pose_channels[\"%s\"].rotation", pchan->name);
|
||||
success+= insertkey(id, pchan->name, buf, 0, cfra, 0);
|
||||
success+= insertkey(id, pchan->name, buf, 1, cfra, 0);
|
||||
success+= insertkey(id, pchan->name, buf, 2, cfra, 0);
|
||||
success+= insertkey(id, pchan->name, buf, 3, cfra, 0);
|
||||
}
|
||||
else {
|
||||
sprintf(buf, "pose.pose_channels[\"%s\"].euler_rotation", pchan->name);
|
||||
success+= insertkey(id, pchan->name, buf, 0, cfra, 0);
|
||||
success+= insertkey(id, pchan->name, buf, 1, cfra, 0);
|
||||
success+= insertkey(id, pchan->name, buf, 2, cfra, 0);
|
||||
}
|
||||
break;
|
||||
default: /* pchan location */
|
||||
sprintf(buf, "pose.pose_channels[\"%s\"].location", pchan->name);
|
||||
success+= insertkey(id, pchan->name, buf, 0, cfra, 0);
|
||||
success+= insertkey(id, pchan->name, buf, 1, cfra, 0);
|
||||
success+= insertkey(id, pchan->name, buf, 2, cfra, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ob->recalc |= OB_RECALC_OB;
|
||||
}
|
||||
|
||||
ob->recalc |= OB_RECALC_OB;
|
||||
printf("Ob '%s' - Successfully added %d Keyframes \n", id->name+2, success);
|
||||
}
|
||||
|
||||
printf("Ob '%s' - Successfully added %d Keyframes \n", id->name+2, success);
|
||||
CTX_DATA_END;
|
||||
}
|
||||
CTX_DATA_END;
|
||||
|
||||
/* send updates */
|
||||
ED_anim_dag_flush_update(C);
|
||||
|
||||
if (mode == 3) // material color requires different notifiers
|
||||
if (mode == 4) // material color requires different notifiers
|
||||
WM_event_add_notifier(C, NC_MATERIAL|ND_KEYS, NULL);
|
||||
else
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_KEYS, NULL);
|
||||
@@ -2132,7 +2282,7 @@ void ANIM_OT_insert_keyframe (wmOperatorType *ot)
|
||||
ot->idname= "ANIM_OT_insert_keyframe";
|
||||
|
||||
/* callbacks */
|
||||
ot->invoke= WM_menu_invoke; // XXX we will need our own one eventually, to cope with the dynamic menus...
|
||||
ot->invoke= insert_key_invoke;
|
||||
ot->exec= insert_key_exec;
|
||||
ot->poll= ED_operator_areaactive;
|
||||
|
||||
@@ -2172,7 +2322,7 @@ static int delete_key_exec (bContext *C, wmOperator *op)
|
||||
|
||||
for (fcu= act->curves.first; fcu; fcu= fcn) {
|
||||
fcn= fcu->next;
|
||||
success+= deletekey(id, fcu->rna_path, fcu->array_index, cfra, 0);
|
||||
success+= deletekey(id, NULL, fcu->rna_path, fcu->array_index, cfra, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2232,7 +2382,7 @@ short action_frame_has_keyframe (bAction *act, float frame, short filter)
|
||||
*/
|
||||
for (fcu= act->curves.first; fcu; fcu= fcu->next) {
|
||||
/* only check if there are keyframes (currently only of type BezTriple) */
|
||||
if (fcu->bezt) {
|
||||
if (fcu->bezt && fcu->totvert) {
|
||||
/* we either include all regardless of muting, or only non-muted */
|
||||
if ((filter & ANIMFILTER_KEYS_MUTED) || (fcu->flag & FCURVE_MUTED)==0) {
|
||||
short replace = -1;
|
||||
|
||||
@@ -32,16 +32,26 @@
|
||||
struct wmOperatorType;
|
||||
|
||||
/* editarmature.c */
|
||||
void armature_bone_rename(Object *ob, char *oldnamep, char *newnamep);
|
||||
|
||||
void ARMATURE_OT_align_bones(struct wmOperatorType *ot);
|
||||
void ARMATURE_OT_calculate_roll(struct wmOperatorType *ot);
|
||||
void ARMATURE_OT_switch_direction(struct wmOperatorType *ot);
|
||||
void ARMATURE_OT_subdivs(struct wmOperatorType *ot);
|
||||
void ARMATURE_OT_subdivide_simple(struct wmOperatorType *ot);
|
||||
void ARMATURE_OT_subdivide_multi(struct wmOperatorType *ot);
|
||||
void ARMATURE_OT_parent_set(struct wmOperatorType *ot);
|
||||
void ARMATURE_OT_parent_clear(struct wmOperatorType *ot);
|
||||
void ARMATURE_OT_de_select_all(struct wmOperatorType *ot);
|
||||
void ARMATURE_OT_selection_invert(struct wmOperatorType *ot);
|
||||
|
||||
void POSE_OT_hide(struct wmOperatorType *ot);
|
||||
void POSE_OT_reveil(struct wmOperatorType *ot);
|
||||
void POSE_OT_reveal(struct wmOperatorType *ot);
|
||||
void POSE_OT_rot_clear(struct wmOperatorType *ot);
|
||||
void POSE_OT_loc_clear(struct wmOperatorType *ot);
|
||||
void POSE_OT_scale_clear(struct wmOperatorType *ot);
|
||||
void POSE_OT_de_select_all(struct wmOperatorType *ot);
|
||||
void POSE_OT_selection_invert(struct wmOperatorType *ot);
|
||||
void POSE_OT_select_parent(struct wmOperatorType *ot);
|
||||
|
||||
#endif /* ED_ARMATURE_INTERN_H */
|
||||
|
||||
|
||||
@@ -107,15 +107,33 @@ void ARMATURE_OT_test(wmOperatorType *ot)
|
||||
/* Both operators ARMATURE_OT_xxx and POSE_OT_xxx here */
|
||||
void ED_operatortypes_armature(void)
|
||||
{
|
||||
/* EDIT ARMATURE */
|
||||
WM_operatortype_append(ARMATURE_OT_align_bones);
|
||||
WM_operatortype_append(ARMATURE_OT_calculate_roll);
|
||||
WM_operatortype_append(ARMATURE_OT_switch_direction);
|
||||
WM_operatortype_append(ARMATURE_OT_subdivs);
|
||||
WM_operatortype_append(ARMATURE_OT_subdivide_simple);
|
||||
WM_operatortype_append(ARMATURE_OT_subdivide_multi);
|
||||
|
||||
WM_operatortype_append(ARMATURE_OT_parent_set);
|
||||
WM_operatortype_append(ARMATURE_OT_parent_clear);
|
||||
|
||||
WM_operatortype_append(ARMATURE_OT_de_select_all);
|
||||
WM_operatortype_append(ARMATURE_OT_selection_invert);
|
||||
|
||||
/* POSE */
|
||||
WM_operatortype_append(POSE_OT_hide);
|
||||
WM_operatortype_append(POSE_OT_reveil);
|
||||
WM_operatortype_append(POSE_OT_reveal);
|
||||
|
||||
WM_operatortype_append(POSE_OT_rot_clear);
|
||||
WM_operatortype_append(POSE_OT_loc_clear);
|
||||
WM_operatortype_append(POSE_OT_scale_clear);
|
||||
|
||||
WM_operatortype_append(POSE_OT_de_select_all);
|
||||
WM_operatortype_append(POSE_OT_selection_invert);
|
||||
|
||||
WM_operatortype_append(POSE_OT_select_parent);
|
||||
|
||||
WM_operatortype_append(ARMATURE_OT_test); // XXX temp test for context iterators... to be removed
|
||||
}
|
||||
|
||||
@@ -132,6 +150,17 @@ void ED_keymap_armature(wmWindowManager *wm)
|
||||
WM_keymap_add_item(keymap, "ARMATURE_OT_align_bones", AKEY, KM_PRESS, KM_CTRL|KM_ALT, 0);
|
||||
WM_keymap_add_item(keymap, "ARMATURE_OT_calculate_roll", NKEY, KM_PRESS, KM_CTRL, 0);
|
||||
|
||||
WM_keymap_add_item(keymap, "ARMATURE_OT_switch_direction", FKEY, KM_PRESS, KM_ALT, 0);
|
||||
|
||||
/* only menu is registered in keymaps for now */
|
||||
WM_keymap_add_item(keymap, "ARMATURE_OT_subdivs", SKEY, KM_PRESS, KM_ALT, 0);
|
||||
|
||||
WM_keymap_add_item(keymap, "ARMATURE_OT_set_parent", PKEY, KM_PRESS, KM_CTRL, 0);
|
||||
WM_keymap_add_item(keymap, "ARMATURE_OT_clear_parent", PKEY, KM_PRESS, KM_ALT, 0);
|
||||
|
||||
WM_keymap_add_item(keymap, "ARMATURE_OT_de_select_all", AKEY, KM_PRESS, 0, 0);
|
||||
WM_keymap_add_item(keymap, "ARMATURE_OT_selection_invert", IKEY, KM_PRESS, KM_CTRL, 0);
|
||||
|
||||
WM_keymap_add_item(keymap, "ARMATURE_OT_test", TKEY, KM_PRESS, 0, 0); // XXX temp test for context iterators... to be removed
|
||||
|
||||
/* Pose ------------------------ */
|
||||
@@ -141,10 +170,15 @@ void ED_keymap_armature(wmWindowManager *wm)
|
||||
WM_keymap_add_item(keymap, "POSE_OT_hide", HKEY, KM_PRESS, 0, 0);
|
||||
kmi= WM_keymap_add_item(keymap, "POSE_OT_hide", HKEY, KM_PRESS, KM_SHIFT, 0);
|
||||
RNA_boolean_set(kmi->ptr, "invert", 1);
|
||||
WM_keymap_add_item(keymap, "POSE_OT_reveil", HKEY, KM_PRESS, KM_ALT, 0);
|
||||
WM_keymap_add_item(keymap, "POSE_OT_reveal", HKEY, KM_PRESS, KM_ALT, 0);
|
||||
/*clear pose*/
|
||||
WM_keymap_add_item(keymap, "POSE_OT_rot_clear", RKEY, KM_PRESS, KM_ALT, 0);
|
||||
WM_keymap_add_item(keymap, "POSE_OT_loc_clear", GKEY, KM_PRESS, KM_ALT, 0);
|
||||
WM_keymap_add_item(keymap, "POSE_OT_scale_clear", SKEY, KM_PRESS, KM_ALT, 0);
|
||||
|
||||
WM_keymap_add_item(keymap, "POSE_OT_de_select_all", AKEY, KM_PRESS, 0, 0);
|
||||
WM_keymap_add_item(keymap, "POSE_OT_selection_invert", IKEY, KM_PRESS, KM_CTRL, 0);
|
||||
|
||||
WM_keymap_add_item(keymap, "POSE_OT_select_parent", PKEY, KM_PRESS, KM_SHIFT, 0);
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -38,5 +38,45 @@ char *ED_lorem;
|
||||
/* editfont.c */
|
||||
void FONT_OT_textedit(struct wmOperatorType *ot);
|
||||
|
||||
/* editcurve.c */
|
||||
void CURVE_OT_separate(struct wmOperatorType *ot);
|
||||
void CURVE_OT_switch_direction(struct wmOperatorType *ot);
|
||||
void CURVE_OT_set_weight(struct wmOperatorType *ot);
|
||||
void CURVE_OT_set_radius(struct wmOperatorType *ot);
|
||||
void CURVE_OT_smooth(struct wmOperatorType *ot);
|
||||
void CURVE_OT_smooth_radius(struct wmOperatorType *ot);
|
||||
void CURVE_OT_de_select_first(struct wmOperatorType *ot);
|
||||
void CURVE_OT_de_select_last(struct wmOperatorType *ot);
|
||||
void CURVE_OT_de_select_all(struct wmOperatorType *ot);
|
||||
void CURVE_OT_hide(struct wmOperatorType *ot);
|
||||
void CURVE_OT_reveal(struct wmOperatorType *ot);
|
||||
void CURVE_OT_select_inverse(struct wmOperatorType *ot);
|
||||
void CURVE_OT_subdivide(struct wmOperatorType *ot);
|
||||
void CURVE_OT_set_spline_type(struct wmOperatorType *ot);
|
||||
void CURVE_OT_set_handle_type(struct wmOperatorType *ot);
|
||||
void CURVE_OT_make_segment(struct wmOperatorType *ot);
|
||||
void CURVE_OT_spin(struct wmOperatorType *ot);
|
||||
void CURVE_OT_add_vertex(struct wmOperatorType *ot);
|
||||
void CURVE_OT_extrude(struct wmOperatorType *ot);
|
||||
void CURVE_OT_toggle_cyclic(struct wmOperatorType *ot);
|
||||
void CURVE_OT_select_linked(struct wmOperatorType *ot);
|
||||
void CURVE_OT_select_row(struct wmOperatorType *ot);
|
||||
void CURVE_OT_select_next(struct wmOperatorType *ot);
|
||||
void CURVE_OT_select_previous(struct wmOperatorType *ot);
|
||||
void CURVE_OT_select_more(struct wmOperatorType *ot);
|
||||
void CURVE_OT_select_less(struct wmOperatorType *ot);
|
||||
void CURVE_OT_select_random(struct wmOperatorType *ot);
|
||||
void CURVE_OT_select_every_nth(struct wmOperatorType *ot);
|
||||
void CURVE_OT_duplicate(struct wmOperatorType *ot);
|
||||
void CURVE_OT_delete(struct wmOperatorType *ot);
|
||||
void CURVE_OT_set_smooth(struct wmOperatorType *ot);
|
||||
void CURVE_OT_clear_tilt(struct wmOperatorType *ot);
|
||||
void CURVE_OT_add_surface_primitive(struct wmOperatorType *ot);
|
||||
void CURVE_OT_add_curve_primitive(struct wmOperatorType *ot);
|
||||
|
||||
void CURVE_OT_specials_menu(struct wmOperatorType *ot);
|
||||
void CURVE_OT_add_menu(struct wmOperatorType *ot);
|
||||
|
||||
|
||||
#endif /* ED_UTIL_INTERN_H */
|
||||
|
||||
|
||||
@@ -55,15 +55,117 @@
|
||||
#include "ED_screen.h"
|
||||
#include "ED_object.h"
|
||||
|
||||
#include "BIF_transform.h"
|
||||
|
||||
#include "UI_interface.h"
|
||||
|
||||
#include "curve_intern.h"
|
||||
|
||||
|
||||
/* ************************** registration **********************************/
|
||||
/**************************** menus *****************************/
|
||||
|
||||
static int specials_menu_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
||||
{
|
||||
uiMenuItem *head;
|
||||
|
||||
head= uiPupMenuBegin("Specials", 0);
|
||||
uiMenuItemO(head, 0, "CURVE_OT_subdivide");
|
||||
uiMenuItemO(head, 0, "CURVE_OT_switch_direction");
|
||||
uiMenuItemO(head, 0, "CURVE_OT_set_weight");
|
||||
uiMenuItemO(head, 0, "CURVE_OT_set_radius");
|
||||
uiMenuItemO(head, 0, "CURVE_OT_smooth");
|
||||
uiMenuItemO(head, 0, "CURVE_OT_smooth_radius");
|
||||
uiPupMenuEnd(C, head);
|
||||
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
void CURVE_OT_specials_menu(wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name= "Specials Menu";
|
||||
ot->idname= "CURVE_OT_specials_menu";
|
||||
|
||||
/* api clastbacks */
|
||||
ot->invoke= specials_menu_invoke;
|
||||
ot->poll= ED_operator_editsurfcurve;
|
||||
}
|
||||
|
||||
static int add_menu_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
||||
{
|
||||
Object *obedit= CTX_data_edit_object(C);
|
||||
uiMenuItem *head;
|
||||
|
||||
head= uiPupMenuBegin("Add", 0);
|
||||
if(obedit->type == OB_CURVE)
|
||||
uiMenuItemsEnumO(head, "CURVE_OT_add_curve_primitive", "type");
|
||||
else
|
||||
uiMenuItemsEnumO(head, "CURVE_OT_add_surface_primitive", "type");
|
||||
uiPupMenuEnd(C, head);
|
||||
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
void CURVE_OT_add_menu(wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name= "Add Menu";
|
||||
ot->idname= "CURVE_OT_add_menu";
|
||||
|
||||
/* api clastbacks */
|
||||
ot->invoke= add_menu_invoke;
|
||||
ot->poll= ED_operator_editsurfcurve;
|
||||
}
|
||||
|
||||
/************************* registration ****************************/
|
||||
|
||||
void ED_operatortypes_curve(void)
|
||||
{
|
||||
WM_operatortype_append(FONT_OT_textedit);
|
||||
|
||||
WM_operatortype_append(CURVE_OT_hide);
|
||||
WM_operatortype_append(CURVE_OT_reveal);
|
||||
|
||||
WM_operatortype_append(CURVE_OT_separate);
|
||||
WM_operatortype_append(CURVE_OT_duplicate);
|
||||
WM_operatortype_append(CURVE_OT_delete);
|
||||
|
||||
WM_operatortype_append(CURVE_OT_set_weight);
|
||||
WM_operatortype_append(CURVE_OT_set_radius);
|
||||
WM_operatortype_append(CURVE_OT_set_spline_type);
|
||||
WM_operatortype_append(CURVE_OT_set_handle_type);
|
||||
WM_operatortype_append(CURVE_OT_set_smooth);
|
||||
WM_operatortype_append(CURVE_OT_clear_tilt);
|
||||
|
||||
WM_operatortype_append(CURVE_OT_smooth);
|
||||
WM_operatortype_append(CURVE_OT_smooth_radius);
|
||||
|
||||
WM_operatortype_append(CURVE_OT_de_select_first);
|
||||
WM_operatortype_append(CURVE_OT_de_select_last);
|
||||
WM_operatortype_append(CURVE_OT_de_select_all);
|
||||
WM_operatortype_append(CURVE_OT_select_inverse);
|
||||
WM_operatortype_append(CURVE_OT_select_linked);
|
||||
WM_operatortype_append(CURVE_OT_select_row);
|
||||
WM_operatortype_append(CURVE_OT_select_next);
|
||||
WM_operatortype_append(CURVE_OT_select_previous);
|
||||
WM_operatortype_append(CURVE_OT_select_more);
|
||||
WM_operatortype_append(CURVE_OT_select_less);
|
||||
WM_operatortype_append(CURVE_OT_select_random);
|
||||
WM_operatortype_append(CURVE_OT_select_every_nth);
|
||||
|
||||
WM_operatortype_append(CURVE_OT_switch_direction);
|
||||
WM_operatortype_append(CURVE_OT_subdivide);
|
||||
WM_operatortype_append(CURVE_OT_make_segment);
|
||||
WM_operatortype_append(CURVE_OT_spin);
|
||||
WM_operatortype_append(CURVE_OT_add_vertex);
|
||||
WM_operatortype_append(CURVE_OT_extrude);
|
||||
WM_operatortype_append(CURVE_OT_toggle_cyclic);
|
||||
|
||||
WM_operatortype_append(CURVE_OT_add_menu);
|
||||
WM_operatortype_append(CURVE_OT_specials_menu);
|
||||
|
||||
WM_operatortype_append(CURVE_OT_add_surface_primitive);
|
||||
WM_operatortype_append(CURVE_OT_add_curve_primitive);
|
||||
}
|
||||
|
||||
void ED_keymap_curve(wmWindowManager *wm)
|
||||
@@ -77,6 +179,33 @@ void ED_keymap_curve(wmWindowManager *wm)
|
||||
keymap= WM_keymap_listbase(wm, "Curve", 0, 0);
|
||||
|
||||
WM_keymap_add_item(keymap, "OBJECT_OT_curve_add", AKEY, KM_PRESS, KM_SHIFT, 0);
|
||||
WM_keymap_add_item(keymap, "CURVE_OT_add_vertex", ACTIONMOUSE, KM_PRESS, KM_CTRL, 0);
|
||||
|
||||
WM_keymap_add_item(keymap, "CURVE_OT_de_select_all", AKEY, KM_PRESS, 0, 0);
|
||||
WM_keymap_add_item(keymap, "CURVE_OT_select_row", RKEY, KM_PRESS, KM_SHIFT, 0);
|
||||
WM_keymap_add_item(keymap, "CURVE_OT_select_more", PADPLUSKEY, KM_PRESS, KM_CTRL, 0);
|
||||
WM_keymap_add_item(keymap, "CURVE_OT_select_less", PADMINUS, KM_PRESS, KM_CTRL, 0);
|
||||
WM_keymap_add_item(keymap, "CURVE_OT_select_linked", LKEY, KM_PRESS, 0, 0);
|
||||
RNA_boolean_set(WM_keymap_add_item(keymap, "CURVE_OT_select_linked", LKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "deselect", 1);
|
||||
|
||||
WM_keymap_add_item(keymap, "CURVE_OT_separate", PKEY, KM_PRESS, 0, 0);
|
||||
WM_keymap_add_item(keymap, "CURVE_OT_extrude", EKEY, KM_PRESS, 0, 0);
|
||||
WM_keymap_add_item(keymap, "CURVE_OT_duplicate", DKEY, KM_PRESS, KM_SHIFT, 0);
|
||||
WM_keymap_add_item(keymap, "CURVE_OT_make_segment", FKEY, KM_PRESS, 0, 0);
|
||||
WM_keymap_add_item(keymap, "CURVE_OT_toggle_cyclic", CKEY, KM_PRESS, 0, 0);
|
||||
WM_keymap_add_item(keymap, "CURVE_OT_delete", XKEY, KM_PRESS, 0, 0);
|
||||
WM_keymap_add_item(keymap, "CURVE_OT_delete", DELKEY, KM_PRESS, 0, 0);
|
||||
|
||||
WM_keymap_add_item(keymap, "CURVE_OT_clear_tilt", TKEY, KM_PRESS, KM_ALT, 0);
|
||||
RNA_enum_set(WM_keymap_add_item(keymap, "TFM_OT_transform", TKEY, KM_PRESS, 0, 0)->ptr, "mode", TFM_TILT);
|
||||
RNA_enum_set(WM_keymap_add_item(keymap, "CURVE_OT_set_handle_type", HKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "type", 1);
|
||||
RNA_enum_set(WM_keymap_add_item(keymap, "CURVE_OT_set_handle_type", HKEY, KM_PRESS, 0, 0)->ptr, "type", 3);
|
||||
RNA_enum_set(WM_keymap_add_item(keymap, "CURVE_OT_set_handle_type", VKEY, KM_PRESS, 0, 0)->ptr, "type", 2);
|
||||
|
||||
WM_keymap_add_item(keymap, "CURVE_OT_reveal", HKEY, KM_PRESS, KM_ALT, 0);
|
||||
WM_keymap_add_item(keymap, "CURVE_OT_hide", HKEY, KM_PRESS, KM_ALT|KM_CTRL, 0);
|
||||
RNA_enum_set(WM_keymap_add_item(keymap, "CURVE_OT_hide", HKEY, KM_PRESS, KM_ALT|KM_SHIFT, 0)->ptr, "deselected", 1);
|
||||
|
||||
WM_keymap_add_item(keymap, "CURVE_OT_specials_menu", WKEY, KM_PRESS, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -109,6 +109,7 @@ void docenter_armature (struct Scene *scene, struct View3D *v3d, struct Object *
|
||||
|
||||
void auto_align_armature(struct Scene *scene, struct View3D *v3d, short mode);
|
||||
void unique_editbone_name (ListBase *edbo, char *name);
|
||||
void armature_bone_rename(Object *ob, char *oldnamep, char *newnamep);
|
||||
|
||||
void undo_push_armature(struct bContext *C, char *name);
|
||||
|
||||
|
||||
@@ -45,7 +45,6 @@ ListBase *curve_get_editcurve(struct Object *ob);
|
||||
|
||||
void load_editNurb (struct Object *obedit);
|
||||
void make_editNurb (struct Object *obedit);
|
||||
void remake_editNurb (struct Object *obedit);
|
||||
void free_editNurb (struct Object *obedit);
|
||||
|
||||
void mouse_nurb (struct bContext *C, short mval[2], int extend);
|
||||
|
||||
@@ -33,9 +33,23 @@ struct bContext;
|
||||
|
||||
/* space_image.c, exported for transform */
|
||||
struct Image *ED_space_image(struct SpaceImage *sima);
|
||||
void ED_space_image_set(struct bContext *C, struct SpaceImage *sima, struct Scene *scene, struct Object *obedit, struct Image *ima);
|
||||
|
||||
struct ImBuf *ED_space_image_buffer(struct SpaceImage *sima);
|
||||
void ED_space_image_size(struct SpaceImage *sima, int *width, int *height);
|
||||
void ED_space_image_aspect(struct SpaceImage *sima, float *aspx, float *aspy);
|
||||
void ED_space_image_zoom(struct SpaceImage *sima, struct ARegion *ar, float *zoomx, float *zoomy);
|
||||
void ED_space_image_uv_aspect(struct SpaceImage *sima, float *aspx, float *aspy);
|
||||
|
||||
void ED_image_size(struct Image *ima, int *width, int *height);
|
||||
void ED_image_aspect(struct Image *ima, float *aspx, float *aspy);
|
||||
void ED_image_uv_aspect(struct Image *ima, float *aspx, float *aspy);
|
||||
|
||||
int ED_space_image_show_render(struct SpaceImage *sima);
|
||||
int ED_space_image_show_paint(struct SpaceImage *sima);
|
||||
int ED_space_image_show_uvedit(struct SpaceImage *sima, struct Object *obedit);
|
||||
int ED_space_image_show_uvshadow(struct SpaceImage *sima, struct Object *obedit);
|
||||
|
||||
/* image_render.c, export for screen_ops.c, render operator */
|
||||
void ED_space_image_output(struct bContext *C);
|
||||
|
||||
|
||||
@@ -31,6 +31,8 @@
|
||||
struct ListBase;
|
||||
struct ID;
|
||||
|
||||
struct KeyingSet;
|
||||
|
||||
struct FCurve;
|
||||
struct BezTriple;
|
||||
|
||||
@@ -73,14 +75,17 @@ enum {
|
||||
* Use this to create any necessary animation data, and then insert a keyframe
|
||||
* using the current value being keyframed, in the relevant place. Returns success.
|
||||
*/
|
||||
short insertkey(struct ID *id, const char rna_path[], int array_index, float cfra, short flag);
|
||||
short insertkey(struct ID *id, const char group[], const char rna_path[], int array_index, float cfra, short flag);
|
||||
|
||||
/* Main Keyframing API call:
|
||||
* Use this to delete keyframe on current frame for relevant channel. Will perform checks just in case.
|
||||
*/
|
||||
short deletekey(struct ID *id, const char rna_path[], int array_index, float cfra, short flag);
|
||||
short deletekey(struct ID *id, const char group[], const char rna_path[], int array_index, float cfra, short flag);
|
||||
|
||||
|
||||
/* Generate menu of KeyingSets */
|
||||
char *ANIM_build_keyingsets_menu(struct ListBase *list, short for_edit);
|
||||
|
||||
/* Main Keyframe Management operators:
|
||||
* These handle keyframes management from various spaces. They will handle the menus
|
||||
* required for each space.
|
||||
|
||||
@@ -119,6 +119,7 @@ void EM_deselect_flush(struct EditMesh *em);
|
||||
void EM_selectmode_set(struct EditMesh *em);
|
||||
void EM_select_flush(struct EditMesh *em);
|
||||
void EM_convertsel(struct EditMesh *em, short oldmode, short selectmode);
|
||||
void EM_validate_selections(struct EditMesh *em);
|
||||
|
||||
/* exported to transform */
|
||||
int EM_get_actSelection(struct EditMesh *em, struct EditSelection *ese);
|
||||
@@ -139,6 +140,9 @@ void EM_free_backbuf(void);
|
||||
int EM_init_backbuf_border(struct ViewContext *vc, short xmin, short ymin, short xmax, short ymax);
|
||||
int EM_init_backbuf_circle(struct ViewContext *vc, short xs, short ys, short rads);
|
||||
|
||||
void EM_hide_mesh(struct EditMesh *em, int swap);
|
||||
void EM_reveal_mesh(struct EditMesh *em);
|
||||
|
||||
/* editface.c */
|
||||
struct MTFace *EM_get_active_mtface(struct EditMesh *em, struct EditFace **act_efa, struct MCol **mcol, int sloppy);
|
||||
|
||||
|
||||
@@ -117,6 +117,8 @@ int ED_operator_object_active(struct bContext *C);
|
||||
int ED_operator_editmesh(struct bContext *C);
|
||||
int ED_operator_editarmature(struct bContext *C);
|
||||
int ED_operator_editcurve(struct bContext *C);
|
||||
int ED_operator_editsurf(struct bContext *C);
|
||||
int ED_operator_editsurfcurve(struct bContext *C);
|
||||
int ED_operator_uvedit(struct bContext *C);
|
||||
int ED_operator_uvmap(struct bContext *C);
|
||||
int ED_operator_posemode(struct bContext *C);
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#ifndef ED_UVEDIT_H
|
||||
#define ED_UVEDIT_H
|
||||
|
||||
struct bContext;
|
||||
struct Scene;
|
||||
struct Object;
|
||||
struct MTFace;
|
||||
@@ -40,7 +41,7 @@ void ED_operatortypes_uvedit(void);
|
||||
void ED_keymap_uvedit(struct wmWindowManager *wm);
|
||||
|
||||
void ED_uvedit_assign_image(struct Scene *scene, struct Object *obedit, struct Image *ima, struct Image *previma);
|
||||
void ED_uvedit_set_tile(struct Scene *scene, struct Object *obedit, struct Image *ima, int curtile, int dotile);
|
||||
void ED_uvedit_set_tile(struct bContext *C, struct Scene *scene, struct Object *obedit, struct Image *ima, int curtile, int dotile);
|
||||
int ED_uvedit_minmax(struct Scene *scene, struct Image *ima, struct Object *obedit, float *min, float *max);
|
||||
|
||||
int ED_uvedit_test_silent(struct Object *obedit);
|
||||
|
||||
@@ -84,6 +84,7 @@ typedef struct uiPopupBlockHandle uiPopupBlockHandle;
|
||||
#define UI_BLOCK_NO_HILITE 64 /* XXX 2.5 not implemented */
|
||||
#define UI_BLOCK_MOVEMOUSE_QUIT 128
|
||||
#define UI_BLOCK_KEEP_OPEN 256
|
||||
#define UI_BLOCK_POPUP 512
|
||||
|
||||
/* uiPopupBlockHandle->menuretval */
|
||||
#define UI_RETURN_CANCEL 1 /* cancel all menus cascading */
|
||||
@@ -211,7 +212,7 @@ void uiMenuContext(uiMenuItem *head, int opcontext);
|
||||
|
||||
void uiMenuItemVal(uiMenuItem *head, const char *name, int icon, int argval);
|
||||
|
||||
void uiMenuItemEnumO(uiMenuItem *head, int icon, char *opname, char *propname, int value);
|
||||
void uiMenuItemEnumO(uiMenuItem *head, const char *name, int icon, char *opname, char *propname, int value);
|
||||
void uiMenuItemBooleanO(uiMenuItem *head, const char *name, int icon, char *opname, char *propname, int value);
|
||||
void uiMenuItemsEnumO(uiMenuItem *head, char *opname, char *propname);
|
||||
void uiMenuItemIntO(uiMenuItem *head, const char *name, int icon, char *opname, char *propname, int value);
|
||||
@@ -238,9 +239,8 @@ void uiMenuSeparator(uiMenuItem *head);
|
||||
uiMenuItem *uiPupMenuBegin(const char *title, int icon);
|
||||
void uiPupMenuEnd(struct bContext *C, struct uiMenuItem *head);
|
||||
|
||||
void uiPupMenu(struct bContext *C, int maxrow, uiMenuHandleFunc func, void *arg, char *str, ...);
|
||||
void uiPupMenuOkee(struct bContext *C, char *opname, char *str, ...);
|
||||
void uiPupMenuSaveOver(struct bContext *C, char *opname, char *filename, ...);
|
||||
void uiPupMenuSaveOver(struct bContext *C, struct wmOperator *op, char *filename);
|
||||
void uiPupMenuNotice(struct bContext *C, char *str, ...);
|
||||
void uiPupMenuError(struct bContext *C, char *str, ...);
|
||||
void uiPupMenuReports(struct bContext *C, struct ReportList *reports);
|
||||
@@ -513,6 +513,28 @@ void UI_add_region_handlers(struct ListBase *handlers);
|
||||
void UI_add_area_handlers(struct ListBase *handlers);
|
||||
void UI_add_popup_handlers(struct ListBase *handlers, uiPopupBlockHandle *menu);
|
||||
|
||||
/* Legacy code
|
||||
* Callbacks and utils to get 2.48 work */
|
||||
|
||||
void test_idbutton_cb(struct bContext *C, void *namev, void *arg2);
|
||||
void test_scriptpoin_but(struct bContext *C, char *name, ID **idpp);
|
||||
void test_actionpoin_but(struct bContext *C, char *name, ID **idpp);
|
||||
void test_obpoin_but(struct bContext *C, char *name, ID **idpp);
|
||||
void test_meshobpoin_but(struct bContext *C, char *name, ID **idpp);
|
||||
void test_meshpoin_but(struct bContext *C, char *name, ID **idpp);
|
||||
void test_matpoin_but(struct bContext *C, char *name, ID **idpp);
|
||||
void test_scenepoin_but(struct bContext *C, char *name, ID **idpp);
|
||||
void test_grouppoin_but(struct bContext *C, char *name, ID **idpp);
|
||||
void test_texpoin_but(struct bContext *C, char *name, ID **idpp);
|
||||
void test_imapoin_but(struct bContext *C, char *name, ID **idpp);
|
||||
void autocomplete_bone(struct bContext *C, char *str, void *arg_v);
|
||||
void autocomplete_vgroup(struct bContext *C, char *str, void *arg_v);
|
||||
|
||||
struct CurveMapping;
|
||||
struct rctf;
|
||||
void curvemap_buttons(uiBlock *block, struct CurveMapping *cumap, char labeltype, short event, short redraw, struct rctf *rect);
|
||||
|
||||
|
||||
/* Module
|
||||
*
|
||||
* init and exit should be called before using this module. init_userdef must
|
||||
|
||||
@@ -64,6 +64,7 @@ typedef enum {
|
||||
ICON_BLANK006,
|
||||
ICON_BLANK007,
|
||||
ICON_BLANK008,
|
||||
ICON_BLANK008b,
|
||||
|
||||
/* ui */
|
||||
ICON_FULLSCREEN,
|
||||
@@ -91,6 +92,7 @@ typedef enum {
|
||||
ICON_DOTSDOWN,
|
||||
ICON_LINK,
|
||||
ICON_INLINK,
|
||||
ICON_BLANK012b,
|
||||
|
||||
/* available */
|
||||
ICON_BLANK016,
|
||||
@@ -118,6 +120,7 @@ typedef enum {
|
||||
ICON_BLANK038,
|
||||
ICON_BLANK039,
|
||||
ICON_BLANK040,
|
||||
ICON_BLANK040b,
|
||||
|
||||
/* BUTTONS */
|
||||
ICON_LAMP,
|
||||
@@ -145,6 +148,7 @@ typedef enum {
|
||||
ICON_BLANK050,
|
||||
ICON_BLANK051,
|
||||
ICON_BLANK052,
|
||||
ICON_BLANK052b,
|
||||
|
||||
/* EDITORS */
|
||||
ICON_VIEW3D,
|
||||
@@ -172,6 +176,7 @@ typedef enum {
|
||||
ICON_BLANK059,
|
||||
ICON_BLANK060,
|
||||
ICON_BLANK061,
|
||||
ICON_BLANK061b,
|
||||
|
||||
/* MODES */
|
||||
ICON_OBJECTMODE, // XXX fix this up
|
||||
@@ -199,10 +204,11 @@ typedef enum {
|
||||
ICON_BLANK075,
|
||||
ICON_BLANK076,
|
||||
ICON_BLANK077,
|
||||
ICON_BLANK077b,
|
||||
|
||||
/* DATA */
|
||||
ICON_SCENE_DEHLT,
|
||||
ICON_IMAGE_DEHLT,
|
||||
ICON_RENDERLAYERS,
|
||||
ICON_WORLD_DEHLT,
|
||||
ICON_OBJECT,
|
||||
ICON_MESH,
|
||||
@@ -214,7 +220,7 @@ typedef enum {
|
||||
ICON_TEXTURE_DEHLT,
|
||||
ICON_IPO_DEHLT,
|
||||
ICON_CAMERA_DEHLT,
|
||||
ICON_BLANK078,
|
||||
ICON_PARTICLE_DATA,
|
||||
ICON_LIBRARY_DEHLT,
|
||||
ICON_GROUP,
|
||||
ICON_ARMATURE,
|
||||
@@ -226,13 +232,14 @@ typedef enum {
|
||||
ICON_BLANK079,
|
||||
ICON_PACKAGE,
|
||||
ICON_UGLYPACKAGE,
|
||||
ICON_BLANK079b,
|
||||
|
||||
/* DATA */
|
||||
ICON_SCENE_HLT,
|
||||
ICON_IMAGE_HLT,
|
||||
ICON_WORLD_HLT,
|
||||
ICON_OBJECT_HLT,
|
||||
ICON_MESH_HLT,
|
||||
ICON_BRUSH,
|
||||
ICON_IMAGE_DEHLT,
|
||||
ICON_FILE,
|
||||
ICON_FCURVE,
|
||||
ICON_FONT,
|
||||
ICON_CURVE_HLT,
|
||||
ICON_MBALL_HLT,
|
||||
ICON_LATTICE_HLT,
|
||||
@@ -253,6 +260,7 @@ typedef enum {
|
||||
ICON_BLANK089,
|
||||
ICON_BLANK090,
|
||||
ICON_RNA,
|
||||
ICON_BLANK090b,
|
||||
|
||||
/* available */
|
||||
ICON_BLANK092,
|
||||
@@ -280,6 +288,7 @@ typedef enum {
|
||||
ICON_BLANK114,
|
||||
ICON_BLANK115,
|
||||
ICON_BLANK116,
|
||||
ICON_BLANK116b,
|
||||
|
||||
/* OUTLINER */
|
||||
ICON_OUTLINER_OB_EMPTY,
|
||||
@@ -290,8 +299,8 @@ typedef enum {
|
||||
ICON_OUTLINER_OB_LAMP,
|
||||
ICON_OUTLINER_OB_CAMERA,
|
||||
ICON_OUTLINER_OB_ARMATURE,
|
||||
ICON_BLANK117,
|
||||
ICON_BLANK118,
|
||||
ICON_OUTLINER_OB_FONT,
|
||||
ICON_OUTLINER_OB_SURFACE,
|
||||
ICON_BLANK119,
|
||||
ICON_BLANK120,
|
||||
ICON_BLANK121,
|
||||
@@ -307,6 +316,7 @@ typedef enum {
|
||||
ICON_RESTRICT_SELECT_ON,
|
||||
ICON_RESTRICT_RENDER_OFF,
|
||||
ICON_RESTRICT_RENDER_ON,
|
||||
ICON_BLANK127b,
|
||||
|
||||
/* OUTLINER */
|
||||
ICON_BLANK128,
|
||||
@@ -334,6 +344,7 @@ typedef enum {
|
||||
ICON_BLANK140,
|
||||
ICON_BLANK141,
|
||||
ICON_BLANK142,
|
||||
ICON_BLANK142b,
|
||||
|
||||
/* MODIFIERS */
|
||||
ICON_MODIFIER,
|
||||
@@ -351,16 +362,17 @@ typedef enum {
|
||||
ICON_MOD_ARRAY,
|
||||
ICON_MOD_UVPROJECT,
|
||||
ICON_MOD_DISPLACE,
|
||||
ICON_MOD_CURVE,
|
||||
ICON_MOD_LATTICE,
|
||||
ICON_BLANK143,
|
||||
ICON_BLANK144,
|
||||
ICON_BLANK145,
|
||||
ICON_BLANK146,
|
||||
ICON_MOD_ARMATURE,
|
||||
ICON_BLANK147,
|
||||
ICON_BLANK148,
|
||||
ICON_BLANK149,
|
||||
ICON_BLANK150,
|
||||
ICON_BLANK151,
|
||||
ICON_BLANK152,
|
||||
ICON_BLANK152b,
|
||||
|
||||
/* available */
|
||||
ICON_BLANK153,
|
||||
@@ -388,6 +400,7 @@ typedef enum {
|
||||
ICON_BLANK175,
|
||||
ICON_BLANK176,
|
||||
ICON_BLANK177,
|
||||
ICON_BLANK177b,
|
||||
|
||||
/* ANIMATION */
|
||||
ICON_REC,
|
||||
@@ -415,6 +428,7 @@ typedef enum {
|
||||
ICON_MUTE_IPO_ON,
|
||||
ICON_BLANK182,
|
||||
ICON_BLANK183,
|
||||
ICON_BLANK183b,
|
||||
|
||||
/* available */
|
||||
ICON_BLANK184,
|
||||
@@ -442,12 +456,13 @@ typedef enum {
|
||||
ICON_BLANK206,
|
||||
ICON_BLANK207,
|
||||
ICON_BLANK208,
|
||||
ICON_BLANK208b,
|
||||
|
||||
/* EDITING */
|
||||
ICON_VERTEXSEL,
|
||||
ICON_EDGESEL,
|
||||
ICON_FACESEL,
|
||||
ICON_BLANK209,
|
||||
ICON_LINKEDSEL,
|
||||
ICON_BLANK210,
|
||||
ICON_ROTATE,
|
||||
ICON_CURSOR,
|
||||
@@ -469,6 +484,7 @@ typedef enum {
|
||||
ICON_BLANK212,
|
||||
ICON_BLANK213,
|
||||
ICON_BLANK214,
|
||||
ICON_BLANK214b,
|
||||
|
||||
/* EDITING */
|
||||
ICON_MAN_TRANS,
|
||||
@@ -479,15 +495,15 @@ typedef enum {
|
||||
ICON_SNAP_GEAR,
|
||||
ICON_SNAP_GEO,
|
||||
ICON_SNAP_NORMAL,
|
||||
ICON_BLANK216,
|
||||
ICON_BLANK217,
|
||||
ICON_BLANK218,
|
||||
ICON_SNAP_VERTEX,
|
||||
ICON_SNAP_EDGE,
|
||||
ICON_SNAP_FACE,
|
||||
ICON_BLANK218b,
|
||||
ICON_STICKY_UVS_LOC,
|
||||
ICON_STICKY_UVS_DISABLE,
|
||||
ICON_STICKY_UVS_VERT,
|
||||
ICON_CLIPUV_DEHLT,
|
||||
ICON_CLIPUV_HLT,
|
||||
ICON_BLANK218b,
|
||||
ICON_BLANK219,
|
||||
ICON_BLANK220,
|
||||
ICON_BLANK221,
|
||||
@@ -496,6 +512,7 @@ typedef enum {
|
||||
ICON_BLANK224,
|
||||
ICON_BLANK225,
|
||||
ICON_BLANK226,
|
||||
ICON_BLANK226b,
|
||||
|
||||
/* EDITING */
|
||||
ICON_PASTEDOWN,
|
||||
@@ -523,6 +540,7 @@ typedef enum {
|
||||
ICON_BLANK245,
|
||||
ICON_BLANK246,
|
||||
ICON_BLANK247,
|
||||
ICON_BLANK247b,
|
||||
|
||||
/* 3D VIEW */
|
||||
ICON_BBOX,
|
||||
@@ -550,6 +568,7 @@ typedef enum {
|
||||
ICON_BLANK255,
|
||||
ICON_BLANK256,
|
||||
ICON_BLANK257,
|
||||
ICON_BLANK257b,
|
||||
|
||||
/* available */
|
||||
ICON_BLANK258,
|
||||
@@ -577,6 +596,7 @@ typedef enum {
|
||||
ICON_BLANK280,
|
||||
ICON_BLANK281,
|
||||
ICON_BLANK282,
|
||||
ICON_BLANK282b,
|
||||
|
||||
/* FILE SELECT */
|
||||
ICON_SORTALPHA,
|
||||
@@ -604,6 +624,7 @@ typedef enum {
|
||||
ICON_BLANK289,
|
||||
ICON_BLANK290,
|
||||
ICON_BLANK291,
|
||||
ICON_BLANK291b,
|
||||
|
||||
/* available */
|
||||
ICON_BLANK292,
|
||||
@@ -631,6 +652,7 @@ typedef enum {
|
||||
ICON_BLANK314,
|
||||
ICON_BLANK315,
|
||||
ICON_BLANK316,
|
||||
ICON_BLANK316b,
|
||||
|
||||
/* SHADING / TEXT */
|
||||
ICON_MATPLANE,
|
||||
@@ -645,11 +667,11 @@ typedef enum {
|
||||
ICON_BLANK320,
|
||||
ICON_BLANK321,
|
||||
ICON_BLANK322,
|
||||
ICON_BLANK5, // XXX CHANGE TO WORDWRAP
|
||||
ICON_BLANK6, // XXX CHANGE TO WORDWRAP
|
||||
ICON_SYNTAX, // XXX CHANGE OFF -> ON
|
||||
ICON_WORDWRAP_OFF,
|
||||
ICON_WORDWRAP_ON,
|
||||
ICON_SYNTAX_OFF,
|
||||
ICON_LINENUMBERS_OFF, // XXX CREATE NEW
|
||||
ICON_SYNTAX_ON,
|
||||
ICON_LINENUMBERS_OFF,
|
||||
ICON_LINENUMBERS_ON,
|
||||
ICON_SCRIPTPLUGINS, // XXX CREATE NEW
|
||||
ICON_BLANK323,
|
||||
@@ -658,6 +680,7 @@ typedef enum {
|
||||
ICON_BLANK326,
|
||||
ICON_BLANK327,
|
||||
ICON_BLANK328,
|
||||
ICON_BLANK328b,
|
||||
|
||||
/* SEQUENCE / IMAGE EDITOR */
|
||||
ICON_SEQ_SEQUENCER,
|
||||
@@ -685,6 +708,7 @@ typedef enum {
|
||||
ICON_BLANK344,
|
||||
ICON_BLANK345,
|
||||
ICON_BLANK346,
|
||||
ICON_BLANK346b,
|
||||
|
||||
/* vector icons */
|
||||
|
||||
|
||||
@@ -54,6 +54,8 @@ enum {
|
||||
V2D_COMMONVIEW_LIST,
|
||||
/* headers (this is basically the same as listview, but no y-panning) */
|
||||
V2D_COMMONVIEW_HEADER,
|
||||
/* ui listviews, tries to wrap tot inside region width */
|
||||
V2D_COMMONVIEW_LIST_UI,
|
||||
} eView2D_CommonViewTypes;
|
||||
|
||||
/* ---- Defines for Scroller/Grid Arguments ----- */
|
||||
|
||||
@@ -624,6 +624,7 @@ void uiEndBlock(const bContext *C, uiBlock *block)
|
||||
|
||||
void uiDrawBlock(const bContext *C, uiBlock *block)
|
||||
{
|
||||
ARegion *ar= CTX_wm_region(C);
|
||||
uiBut *but;
|
||||
|
||||
if(!block->endblock)
|
||||
@@ -640,7 +641,7 @@ void uiDrawBlock(const bContext *C, uiBlock *block)
|
||||
if(block->drawextra) block->drawextra(C, block);
|
||||
|
||||
for (but= block->buttons.first; but; but= but->next)
|
||||
ui_draw_but(but);
|
||||
ui_draw_but(ar, but);
|
||||
|
||||
ui_draw_links(block);
|
||||
}
|
||||
@@ -863,11 +864,11 @@ static int ui_do_but_LINK(uiBlock *block, uiBut *but)
|
||||
bt= ui_get_valid_link_button(block, but, mval);
|
||||
if(bt) {
|
||||
bt->flag |= UI_ACTIVE;
|
||||
ui_draw_but(bt);
|
||||
ui_draw_but(ar, bt);
|
||||
}
|
||||
if(bto && bto!=bt) {
|
||||
bto->flag &= ~UI_ACTIVE;
|
||||
ui_draw_but(bto);
|
||||
ui_draw_but(ar, bto);
|
||||
}
|
||||
bto= bt;
|
||||
|
||||
@@ -965,7 +966,7 @@ static void edit_but(uiBlock *block, uiBut *but, uiEvent *uevent)
|
||||
but->x2 += dx;
|
||||
but->y2 += dy;
|
||||
|
||||
ui_draw_but(but);
|
||||
ui_draw_but(ar, but);
|
||||
ui_block_flush_back(but->block);
|
||||
didit= 1;
|
||||
|
||||
@@ -2307,6 +2308,10 @@ uiBut *ui_def_but_operator(uiBlock *block, int type, char *opname, int opcontext
|
||||
if(ot) str= ot->name;
|
||||
else str= opname;
|
||||
}
|
||||
|
||||
if ((!tip || tip[0]=='\0') && ot && ot->description) {
|
||||
tip= ot->description;
|
||||
}
|
||||
|
||||
but= ui_def_but(block, type, -1, str, x1, y1, x2, y2, NULL, 0, 0, 0, 0, tip);
|
||||
but->opname= opname;
|
||||
|
||||
@@ -2163,7 +2163,12 @@ void uiDrawMenuBox(float minx, float miny, float maxx, float maxy, short flag, s
|
||||
UI_GetThemeColor4ubv(TH_MENU_BACK, col);
|
||||
|
||||
if (rounded) {
|
||||
if (direction == UI_DOWN) {
|
||||
if (flag & UI_BLOCK_POPUP) {
|
||||
uiSetRoundBox(15);
|
||||
miny -= 4.0;
|
||||
maxy += 4.0;
|
||||
}
|
||||
else if (direction == UI_DOWN) {
|
||||
uiSetRoundBox(12);
|
||||
miny -= 4.0;
|
||||
} else if (direction == UI_TOP) {
|
||||
@@ -2970,7 +2975,7 @@ static void ui_draw_but_curve_grid(uiBut *but, float zoomx, float zoomy, float o
|
||||
|
||||
}
|
||||
|
||||
static void ui_draw_but_CURVE(uiBut *but)
|
||||
static void ui_draw_but_CURVE(ARegion *ar, uiBut *but)
|
||||
{
|
||||
CurveMapping *cumap;
|
||||
CurveMap *cuma;
|
||||
@@ -2985,10 +2990,10 @@ static void ui_draw_but_CURVE(uiBut *but)
|
||||
/* need scissor test, curve can draw outside of boundary */
|
||||
glGetIntegerv(GL_VIEWPORT, scissor);
|
||||
fx= but->x1; fy= but->y1;
|
||||
/* XXX 2.50 need context: ui_graphics_to_window(but->win, &fx, &fy); */
|
||||
ui_block_to_window_fl(ar, but->block, &fx, &fy);
|
||||
dx= but->x2; dy= but->y2;
|
||||
/* XXX 2.50 need context: ui_graphics_to_window(but->win, &dx, &dy); */
|
||||
//glScissor((int)floor(fx), (int)floor(fy), (int)ceil(dx-fx), (int)ceil(dy-fy));
|
||||
ui_block_to_window_fl(ar, but->block, &dx, &dy);
|
||||
glScissor((int)floor(fx), (int)floor(fy), (int)ceil(dx-fx), (int)ceil(dy-fy));
|
||||
|
||||
/* calculate offset and zoom */
|
||||
zoomx= (but->x2-but->x1-2.0*but->aspect)/(cumap->curr.xmax - cumap->curr.xmin);
|
||||
@@ -3249,7 +3254,7 @@ void ui_set_embossfunc(uiBut *but, int drawtype)
|
||||
// note: if you want aligning, adapt the call uiBlockEndAlign in interface.c
|
||||
}
|
||||
|
||||
void ui_draw_but(uiBut *but)
|
||||
void ui_draw_but(ARegion *ar, uiBut *but)
|
||||
{
|
||||
double value;
|
||||
float x1, x2, y1, y2, fac;
|
||||
@@ -3317,7 +3322,7 @@ void ui_draw_but(uiBut *but)
|
||||
ui_draw_but_NORMAL(but);
|
||||
break;
|
||||
case BUT_CURVE:
|
||||
ui_draw_but_CURVE(but);
|
||||
ui_draw_but_CURVE(ar, but);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
@@ -3753,6 +3753,8 @@ static int ui_handler_popup(bContext *C, wmEvent *event, void *userdata)
|
||||
if(temp.opname)
|
||||
WM_operator_name_call(C, temp.opname, temp.opcontext, NULL);
|
||||
}
|
||||
else if(temp.cancel_func)
|
||||
temp.cancel_func(temp.popup_arg);
|
||||
}
|
||||
else {
|
||||
/* re-enable tooltips */
|
||||
|
||||
@@ -67,7 +67,7 @@
|
||||
#define ICON_IMAGE_W 600
|
||||
#define ICON_IMAGE_H 512
|
||||
|
||||
#define ICON_GRID_COLS 25
|
||||
#define ICON_GRID_COLS 26
|
||||
#define ICON_GRID_ROWS 24
|
||||
|
||||
#define ICON_GRID_MARGIN 5
|
||||
|
||||
@@ -279,6 +279,7 @@ struct uiPopupBlockHandle {
|
||||
|
||||
int popup;
|
||||
void (*popup_func)(struct bContext *C, void *arg, int event);
|
||||
void (*cancel_func)(void *arg);
|
||||
void *popup_arg;
|
||||
|
||||
/* for operator popups */
|
||||
@@ -312,13 +313,18 @@ void ui_popup_block_free(struct bContext *C, uiPopupBlockHandle *handle);
|
||||
|
||||
void ui_set_name_menu(uiBut *but, int value);
|
||||
|
||||
struct AutoComplete;
|
||||
struct AutoComplete *autocomplete_begin(char *startname, int maxlen);
|
||||
void autocomplete_do_name(struct AutoComplete *autocpl, const char *name);
|
||||
void autocomplete_end(struct AutoComplete *autocpl, char *autoname);
|
||||
|
||||
/* interface_panel.c */
|
||||
extern int ui_handler_panel_region(struct bContext *C, struct wmEvent *event);
|
||||
extern void ui_draw_panel(struct ARegion *ar, uiBlock *block);
|
||||
|
||||
/* interface_draw.c */
|
||||
extern void ui_set_embossfunc(uiBut *but, int drawtype);
|
||||
extern void ui_draw_but(uiBut *but);
|
||||
extern void ui_draw_but(ARegion *ar, uiBut *but);
|
||||
extern void ui_rasterpos_safe(float x, float y, float aspect);
|
||||
extern void ui_draw_tria_icon(float x, float y, float aspect, char dir);
|
||||
extern void ui_draw_anti_x(float x1, float y1, float x2, float y2);
|
||||
|
||||
@@ -94,6 +94,22 @@ typedef struct uiHandlePanelData {
|
||||
|
||||
static void panel_activate_state(bContext *C, Panel *pa, uiHandlePanelState state);
|
||||
|
||||
/* ******************************** */
|
||||
|
||||
/* temporary code to remove all sbuts stuff from panel code */
|
||||
|
||||
static int panel_aligned(ScrArea *sa, ARegion *ar)
|
||||
{
|
||||
if(sa->spacetype==SPACE_BUTS) {
|
||||
SpaceButs *sbuts= sa->spacedata.first;
|
||||
return sbuts->align;
|
||||
}
|
||||
else if(ar->regiontype==RGN_TYPE_UI)
|
||||
return BUT_VERTICAL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ************** panels ************* */
|
||||
|
||||
static void copy_panel_offset(Panel *pa, Panel *papar)
|
||||
@@ -868,14 +884,11 @@ static int find_highest_panel(const void *a1, const void *a2)
|
||||
/* returns 1 when it did something */
|
||||
int uiAlignPanelStep(ScrArea *sa, ARegion *ar, float fac)
|
||||
{
|
||||
SpaceButs *sbuts= sa->spacedata.first;
|
||||
Panel *pa;
|
||||
PanelSort *ps, *panelsort, *psnext;
|
||||
static int sortcounter= 0;
|
||||
int a, tot=0, done;
|
||||
|
||||
if(sa->spacetype!=SPACE_BUTS)
|
||||
return 0;
|
||||
int align= panel_aligned(sa, ar);
|
||||
|
||||
/* count active, not tabbed Panels */
|
||||
for(pa= ar->panels.first; pa; pa= pa->next) {
|
||||
@@ -887,10 +900,10 @@ int uiAlignPanelStep(ScrArea *sa, ARegion *ar, float fac)
|
||||
/* extra; change close direction? */
|
||||
for(pa= ar->panels.first; pa; pa= pa->next) {
|
||||
if(pa->active && pa->paneltab==NULL) {
|
||||
if( (pa->flag & PNL_CLOSEDX) && (sbuts->align==BUT_VERTICAL) )
|
||||
if( (pa->flag & PNL_CLOSEDX) && (align==BUT_VERTICAL) )
|
||||
pa->flag ^= PNL_CLOSED;
|
||||
|
||||
else if( (pa->flag & PNL_CLOSEDY) && (sbuts->align==BUT_HORIZONTAL) )
|
||||
else if( (pa->flag & PNL_CLOSEDY) && (align==BUT_HORIZONTAL) )
|
||||
pa->flag ^= PNL_CLOSED;
|
||||
|
||||
}
|
||||
@@ -908,20 +921,24 @@ int uiAlignPanelStep(ScrArea *sa, ARegion *ar, float fac)
|
||||
}
|
||||
}
|
||||
|
||||
if(sbuts->align==BUT_VERTICAL)
|
||||
if(align==BUT_VERTICAL)
|
||||
qsort(panelsort, tot, sizeof(PanelSort), find_highest_panel);
|
||||
else
|
||||
qsort(panelsort, tot, sizeof(PanelSort), find_leftmost_panel);
|
||||
|
||||
/* no smart other default start loc! this keeps switching f5/f6/etc compatible */
|
||||
ps= panelsort;
|
||||
ps->pa->ofsx= 0;
|
||||
ps->pa->ofsy= 0;
|
||||
ps->pa->ofsx= PNL_DIST;
|
||||
if(align==BUT_VERTICAL)
|
||||
ps->pa->ofsy= -ps->pa->sizey-PNL_HEADER-PNL_DIST;
|
||||
else
|
||||
ps->pa->ofsy= 0;
|
||||
|
||||
|
||||
for(a=0 ; a<tot-1; a++, ps++) {
|
||||
psnext= ps+1;
|
||||
|
||||
if(sbuts->align==BUT_VERTICAL) {
|
||||
if(align==BUT_VERTICAL) {
|
||||
psnext->pa->ofsx = ps->pa->ofsx;
|
||||
psnext->pa->ofsy = get_panel_real_ofsy(ps->pa) - psnext->pa->sizey-PNL_HEADER-PNL_DIST;
|
||||
}
|
||||
@@ -1031,6 +1048,7 @@ void uiDrawPanels(const bContext *C, int re_align)
|
||||
if(re_align) uiAlignPanelStep(sa, ar, 1.0);
|
||||
|
||||
if(sa->spacetype!=SPACE_BUTS) {
|
||||
#if 0 // XXX make float panel exception
|
||||
SpaceLink *sl= sa->spacedata.first;
|
||||
for(block= ar->uiblocks.first; block; block= block->next) {
|
||||
if(block->active && block->panel && block->panel->active && block->panel->paneltab == NULL) {
|
||||
@@ -1108,6 +1126,7 @@ void uiDrawPanels(const bContext *C, int re_align)
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* draw panels, selected on top */
|
||||
@@ -1217,17 +1236,12 @@ static void ui_do_drag(bContext *C, wmEvent *event, Panel *panel)
|
||||
uiHandlePanelData *data= panel->activedata;
|
||||
ScrArea *sa= CTX_wm_area(C);
|
||||
ARegion *ar= CTX_wm_region(C);
|
||||
short align=0, dx=0, dy=0;
|
||||
short align= panel_aligned(sa, ar), dx=0, dy=0;
|
||||
|
||||
/* first clip for window, no dragging outside */
|
||||
if(!BLI_in_rcti(&ar->winrct, event->x, event->y))
|
||||
return;
|
||||
|
||||
if(sa->spacetype==SPACE_BUTS) {
|
||||
SpaceButs *sbuts= sa->spacedata.first;
|
||||
align= sbuts->align;
|
||||
}
|
||||
|
||||
dx= (event->x-data->startx) & ~(PNL_GRID-1);
|
||||
dy= (event->y-data->starty) & ~(PNL_GRID-1);
|
||||
|
||||
@@ -1334,11 +1348,8 @@ static void panel_clicked_tabs(bContext *C, ScrArea *sa, ARegion *ar, uiBlock *b
|
||||
}
|
||||
|
||||
/* panels now differ size.. */
|
||||
if(sa->spacetype==SPACE_BUTS) {
|
||||
SpaceButs *sbuts= sa->spacedata.first;
|
||||
if(sbuts->align)
|
||||
uiAlignPanelStep(sa, ar, 1.0);
|
||||
}
|
||||
if(panel_aligned(sa, ar))
|
||||
uiAlignPanelStep(sa, ar, 1.0);
|
||||
|
||||
ED_region_tag_redraw(ar);
|
||||
}
|
||||
@@ -1353,12 +1364,7 @@ static void ui_handle_panel_header(bContext *C, uiBlock *block, int mx, int my)
|
||||
ScrArea *sa= CTX_wm_area(C);
|
||||
ARegion *ar= CTX_wm_region(C);
|
||||
Panel *pa;
|
||||
int align= 0, button= 0;
|
||||
|
||||
if(sa->spacetype==SPACE_BUTS) {
|
||||
SpaceButs *sbuts= (SpaceButs*)CTX_wm_space_data(C);
|
||||
align= sbuts->align;
|
||||
}
|
||||
int align= panel_aligned(sa, ar), button= 0;
|
||||
|
||||
/* mouse coordinates in panel space! */
|
||||
|
||||
@@ -1423,7 +1429,6 @@ static void ui_handle_panel_header(bContext *C, uiBlock *block, int mx, int my)
|
||||
|
||||
int ui_handler_panel_region(bContext *C, wmEvent *event)
|
||||
{
|
||||
ScrArea *sa= CTX_wm_area(C);
|
||||
ARegion *ar= CTX_wm_region(C);
|
||||
uiBlock *block;
|
||||
int retval, mx, my, inside_header= 0, inside_scale= 0;
|
||||
@@ -1485,8 +1490,9 @@ int ui_handler_panel_region(bContext *C, wmEvent *event)
|
||||
}
|
||||
else
|
||||
zoom=1;
|
||||
|
||||
#if 0 // XXX make float panel exception?
|
||||
if(zoom) {
|
||||
ScrArea *sa= CTX_wm_area(C);
|
||||
SpaceLink *sl= sa->spacedata.first;
|
||||
|
||||
if(sa->spacetype!=SPACE_BUTS) {
|
||||
@@ -1500,6 +1506,7 @@ int ui_handler_panel_region(bContext *C, wmEvent *event)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
return retval;
|
||||
|
||||
@@ -240,7 +240,9 @@ ARegion *ui_add_temporary_region(bScreen *sc)
|
||||
|
||||
void ui_remove_temporary_region(bContext *C, bScreen *sc, ARegion *ar)
|
||||
{
|
||||
wm_draw_region_clear(CTX_wm_window(C), ar);
|
||||
if(CTX_wm_window(C))
|
||||
wm_draw_region_clear(CTX_wm_window(C), ar);
|
||||
|
||||
ED_region_exit(C, ar);
|
||||
BKE_area_region_free(NULL, ar); /* NULL: no spacetype */
|
||||
BLI_freelinkN(&sc->regionbase, ar);
|
||||
@@ -682,6 +684,7 @@ uiPopupBlockHandle *ui_popup_block_create(bContext *C, ARegion *butregion, uiBut
|
||||
saferct= MEM_callocN(sizeof(uiSafetyRct), "uiSafetyRct");
|
||||
saferct->safety= block->safety;
|
||||
BLI_addhead(&block->saferct, saferct);
|
||||
block->flag |= UI_BLOCK_POPUP;
|
||||
}
|
||||
|
||||
/* the block and buttons were positioned in window space as in 2.4x, now
|
||||
@@ -1832,8 +1835,13 @@ static uiBlock *ui_block_func_MENU_ITEM(bContext *C, uiPopupBlockHandle *handle,
|
||||
else if(item->type==MENU_ITEM_OPNAME_ENUM) {
|
||||
const char *name;
|
||||
char bname[64];
|
||||
|
||||
name= ui_menu_enumpropname(item->opname, item->propname, item->enumval);
|
||||
|
||||
/* If no name is given, use the enum name */
|
||||
if (item->name[0] == '\0')
|
||||
name= ui_menu_enumpropname(item->opname, item->propname, item->enumval);
|
||||
else
|
||||
name= item->name;
|
||||
|
||||
BLI_strncpy(bname, name, sizeof(bname));
|
||||
|
||||
but= uiDefIconTextButO(block, BUTM, item->opname, item->opcontext, item->icon, bname, x1, y1, width+16, MENU_BUTTON_HEIGHT-1, "");
|
||||
@@ -1937,7 +1945,7 @@ uiPopupBlockHandle *ui_popup_menu_create(bContext *C, ARegion *butregion, uiBut
|
||||
uiMenuInfo info;
|
||||
|
||||
head= MEM_callocN(sizeof(uiMenuItem), "menu dummy");
|
||||
head->opcontext= WM_OP_EXEC_REGION_WIN;
|
||||
head->opcontext= WM_OP_INVOKE_REGION_WIN;
|
||||
|
||||
menu_func(C, head, arg);
|
||||
|
||||
@@ -2006,9 +2014,9 @@ void uiMenuItemO(uiMenuItem *head, int icon, char *opname)
|
||||
}
|
||||
|
||||
/* single operator item with property */
|
||||
void uiMenuItemEnumO(uiMenuItem *head, int icon, char *opname, char *propname, int value)
|
||||
void uiMenuItemEnumO(uiMenuItem *head, const char *name, int icon, char *opname, char *propname, int value)
|
||||
{
|
||||
uiMenuItem *item= ui_menu_add_item(head, "", icon, 0);
|
||||
uiMenuItem *item= ui_menu_add_item(head, name, icon, 0);
|
||||
|
||||
item->opname= opname; // static!
|
||||
item->propname= propname; // static!
|
||||
@@ -2069,7 +2077,7 @@ void uiMenuItemsEnumO(uiMenuItem *head, char *opname, char *propname)
|
||||
RNA_property_enum_items(&ptr, prop, &item, &totitem);
|
||||
|
||||
for (i=0; i<totitem; i++)
|
||||
uiMenuItemEnumO(head, 0, opname, propname, item[i].value);
|
||||
uiMenuItemEnumO(head, "", 0, opname, propname, item[i].value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2133,8 +2141,6 @@ void uiMenuLevelEnumO(uiMenuItem *head, char *opname, char *propname)
|
||||
|
||||
item->opname= opname; // static!
|
||||
item->propname= propname; // static!
|
||||
|
||||
BLI_addtail(&head->items, item);
|
||||
}
|
||||
|
||||
/* make a new level from enum properties */
|
||||
@@ -2150,8 +2156,6 @@ void uiMenuLevelEnumR(uiMenuItem *head, PointerRNA *ptr, char *propname)
|
||||
|
||||
item->rnapoin= *ptr;
|
||||
item->propname= propname; // static!
|
||||
|
||||
BLI_addtail(&head->items, item);
|
||||
}
|
||||
|
||||
/* separator */
|
||||
@@ -2203,8 +2207,10 @@ void uiPupMenuEnd(bContext *C, uiMenuItem *head)
|
||||
MEM_freeN(head);
|
||||
}
|
||||
|
||||
/* this one only to be called with operatortype name option */
|
||||
void uiPupMenu(bContext *C, int maxrow, uiMenuHandleFunc func, void *arg, char *str, ...)
|
||||
/* ************** 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;
|
||||
@@ -2224,11 +2230,12 @@ void uiPupMenu(bContext *C, int maxrow, uiMenuHandleFunc func, void *arg, char *
|
||||
|
||||
menu->popup_func= func;
|
||||
menu->popup_arg= arg;
|
||||
|
||||
return menu;
|
||||
}
|
||||
|
||||
/* standard pupmenus */
|
||||
|
||||
static void operator_cb(bContext *C, void *arg, int retval)
|
||||
static void operator_name_cb(bContext *C, void *arg, int retval)
|
||||
{
|
||||
const char *opname= arg;
|
||||
|
||||
@@ -2236,7 +2243,7 @@ static void operator_cb(bContext *C, void *arg, int retval)
|
||||
WM_operator_name_call(C, opname, WM_OP_EXEC_DEFAULT, NULL);
|
||||
}
|
||||
|
||||
static void vconfirm(bContext *C, char *opname, char *title, char *itemfmt, va_list ap)
|
||||
static void vconfirm_opname(bContext *C, char *opname, char *title, char *itemfmt, va_list ap)
|
||||
{
|
||||
char *s, buf[512];
|
||||
|
||||
@@ -2244,18 +2251,37 @@ static void vconfirm(bContext *C, char *opname, char *title, char *itemfmt, va_l
|
||||
if (title) s+= sprintf(s, "%s%%t|", title);
|
||||
vsprintf(s, itemfmt, ap);
|
||||
|
||||
uiPupMenu(C, 0, operator_cb, opname, buf);
|
||||
ui_pup_menu(C, 0, operator_name_cb, opname, buf);
|
||||
}
|
||||
|
||||
static void confirm(bContext *C, char *opname, char *title, char *itemfmt, ...)
|
||||
static void operator_cb(bContext *C, void *arg, int retval)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, itemfmt);
|
||||
vconfirm(C, opname, title, itemfmt, ap);
|
||||
va_end(ap);
|
||||
wmOperator *op= arg;
|
||||
|
||||
if(op && retval > 0)
|
||||
WM_operator_call(C, op);
|
||||
else
|
||||
WM_operator_free(op);
|
||||
}
|
||||
|
||||
static void confirm_cancel_operator(void *opv)
|
||||
{
|
||||
WM_operator_free(opv);
|
||||
}
|
||||
|
||||
static void confirm_operator(bContext *C, wmOperator *op, char *title, char *item)
|
||||
{
|
||||
uiPopupBlockHandle *handle;
|
||||
char *s, buf[512];
|
||||
|
||||
s= buf;
|
||||
if (title) s+= sprintf(s, "%s%%t|%s", title, item);
|
||||
|
||||
handle= ui_pup_menu(C, 0, operator_cb, op, buf);
|
||||
handle->cancel_func= confirm_cancel_operator;
|
||||
}
|
||||
|
||||
|
||||
void uiPupMenuOkee(bContext *C, char *opname, char *str, ...)
|
||||
{
|
||||
va_list ap;
|
||||
@@ -2264,26 +2290,27 @@ void uiPupMenuOkee(bContext *C, char *opname, char *str, ...)
|
||||
sprintf(titlestr, "OK? %%i%d", ICON_HELP);
|
||||
|
||||
va_start(ap, str);
|
||||
vconfirm(C, opname, titlestr, str, ap);
|
||||
vconfirm_opname(C, opname, titlestr, str, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void uiPupMenuSaveOver(bContext *C, char *opname, char *filename, ...)
|
||||
|
||||
void uiPupMenuSaveOver(bContext *C, wmOperator *op, char *filename)
|
||||
{
|
||||
size_t len= strlen(filename);
|
||||
|
||||
if(len==0)
|
||||
return;
|
||||
|
||||
if(BLI_exists(filename)==0)
|
||||
operator_cb(C, opname, 1);
|
||||
|
||||
if(filename[len-1]=='/' || filename[len-1]=='\\') {
|
||||
uiPupMenuError(C, "Cannot overwrite a directory");
|
||||
WM_operator_free(op);
|
||||
return;
|
||||
}
|
||||
|
||||
confirm(C, opname, "Save over", filename);
|
||||
if(BLI_exists(filename)==0)
|
||||
operator_cb(C, op, 1);
|
||||
else
|
||||
confirm_operator(C, op, "Save over", filename);
|
||||
}
|
||||
|
||||
void uiPupMenuNotice(bContext *C, char *str, ...)
|
||||
@@ -2291,7 +2318,7 @@ void uiPupMenuNotice(bContext *C, char *str, ...)
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, str);
|
||||
vconfirm(C, NULL, NULL, str, ap);
|
||||
vconfirm_opname(C, NULL, NULL, str, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
@@ -2306,7 +2333,7 @@ void uiPupMenuError(bContext *C, char *str, ...)
|
||||
sprintf(nfmt, "%s", str);
|
||||
|
||||
va_start(ap, str);
|
||||
vconfirm(C, NULL, titlestr, nfmt, ap);
|
||||
vconfirm_opname(C, NULL, titlestr, nfmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
@@ -2331,7 +2358,7 @@ void uiPupMenuReports(bContext *C, ReportList *reports)
|
||||
}
|
||||
|
||||
str= BLI_dynstr_get_cstring(ds);
|
||||
uiPupMenu(C, 0, NULL, NULL, str);
|
||||
ui_pup_menu(C, 0, NULL, NULL, str);
|
||||
MEM_freeN(str);
|
||||
|
||||
BLI_dynstr_free(ds);
|
||||
|
||||
@@ -29,11 +29,15 @@
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "DNA_action_types.h"
|
||||
#include "DNA_color_types.h"
|
||||
#include "DNA_listBase.h"
|
||||
#include "DNA_material_types.h"
|
||||
#include "DNA_object_types.h"
|
||||
#include "DNA_screen_types.h"
|
||||
#include "DNA_windowmanager_types.h"
|
||||
|
||||
#include "BKE_colortools.h"
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_idprop.h"
|
||||
#include "BKE_library.h"
|
||||
@@ -45,6 +49,7 @@
|
||||
#include "UI_interface.h"
|
||||
#include "UI_resources.h"
|
||||
|
||||
#include "ED_screen.h"
|
||||
#include "ED_util.h"
|
||||
|
||||
#include "WM_api.h"
|
||||
@@ -133,7 +138,9 @@ int UI_GetIconRNA(PointerRNA *ptr)
|
||||
else if(rnatype == &RNA_Sound)
|
||||
return ICON_SOUND;
|
||||
else if(rnatype == &RNA_Brush)
|
||||
return ICON_TPAINT_HLT;
|
||||
return ICON_BRUSH;
|
||||
else if(rnatype == &RNA_VectorFont)
|
||||
return ICON_FONT;
|
||||
else if(rnatype == &RNA_Library)
|
||||
return ICON_LIBRARY_DEHLT;
|
||||
else if(rnatype == &RNA_Action)
|
||||
@@ -670,3 +677,458 @@ int uiDefIDPoinButs(uiBlock *block, Main *bmain, ID *parid, ID **id_p, int id_co
|
||||
return x;
|
||||
}
|
||||
|
||||
/* ****************************** default button callbacks ******************* */
|
||||
/* ************ LEGACY WARNING, only to get things work with 2.48 code! ****** */
|
||||
|
||||
void test_idbutton_cb(struct bContext *C, void *namev, void *arg2)
|
||||
{
|
||||
char *name= namev;
|
||||
|
||||
test_idbutton(name+2);
|
||||
}
|
||||
|
||||
|
||||
void test_scriptpoin_but(struct bContext *C, char *name, ID **idpp)
|
||||
{
|
||||
ID *id;
|
||||
|
||||
id= CTX_data_main(C)->text.first;
|
||||
while(id) {
|
||||
if( strcmp(name, id->name+2)==0 ) {
|
||||
*idpp= id;
|
||||
return;
|
||||
}
|
||||
id= id->next;
|
||||
}
|
||||
*idpp= NULL;
|
||||
}
|
||||
|
||||
void test_actionpoin_but(struct bContext *C, char *name, ID **idpp)
|
||||
{
|
||||
ID *id;
|
||||
|
||||
id= CTX_data_main(C)->action.first;
|
||||
while(id) {
|
||||
if( strcmp(name, id->name+2)==0 ) {
|
||||
id_us_plus(id);
|
||||
*idpp= id;
|
||||
return;
|
||||
}
|
||||
id= id->next;
|
||||
}
|
||||
*idpp= NULL;
|
||||
}
|
||||
|
||||
|
||||
void test_obpoin_but(struct bContext *C, char *name, ID **idpp)
|
||||
{
|
||||
ID *id;
|
||||
|
||||
// XXX if(idpp == (ID **)&(emptytex.object)) {
|
||||
// error("You must add a texture first");
|
||||
// *idpp= 0;
|
||||
// return;
|
||||
// }
|
||||
|
||||
id= CTX_data_main(C)->object.first;
|
||||
while(id) {
|
||||
if( strcmp(name, id->name+2)==0 ) {
|
||||
*idpp= id;
|
||||
id_lib_extern(id); /* checks lib data, sets correct flag for saving then */
|
||||
return;
|
||||
}
|
||||
id= id->next;
|
||||
}
|
||||
*idpp= NULL;
|
||||
}
|
||||
|
||||
/* tests for an object of type OB_MESH */
|
||||
void test_meshobpoin_but(struct bContext *C, char *name, ID **idpp)
|
||||
{
|
||||
ID *id;
|
||||
|
||||
id = CTX_data_main(C)->object.first;
|
||||
while(id) {
|
||||
Object *ob = (Object *)id;
|
||||
if(ob->type == OB_MESH && strcmp(name, id->name + 2) == 0) {
|
||||
*idpp = id;
|
||||
/* checks lib data, sets correct flag for saving then */
|
||||
id_lib_extern(id);
|
||||
return;
|
||||
}
|
||||
id = id->next;
|
||||
}
|
||||
*idpp = NULL;
|
||||
}
|
||||
|
||||
void test_meshpoin_but(struct bContext *C, char *name, ID **idpp)
|
||||
{
|
||||
ID *id;
|
||||
|
||||
if( *idpp ) (*idpp)->us--;
|
||||
|
||||
id= CTX_data_main(C)->mesh.first;
|
||||
while(id) {
|
||||
if( strcmp(name, id->name+2)==0 ) {
|
||||
*idpp= id;
|
||||
id_us_plus(id);
|
||||
return;
|
||||
}
|
||||
id= id->next;
|
||||
}
|
||||
*idpp= NULL;
|
||||
}
|
||||
|
||||
void test_matpoin_but(struct bContext *C, char *name, ID **idpp)
|
||||
{
|
||||
ID *id;
|
||||
|
||||
if( *idpp ) (*idpp)->us--;
|
||||
|
||||
id= CTX_data_main(C)->mat.first;
|
||||
while(id) {
|
||||
if( strcmp(name, id->name+2)==0 ) {
|
||||
*idpp= id;
|
||||
id_us_plus(id);
|
||||
return;
|
||||
}
|
||||
id= id->next;
|
||||
}
|
||||
*idpp= NULL;
|
||||
}
|
||||
|
||||
void test_scenepoin_but(struct bContext *C, char *name, ID **idpp)
|
||||
{
|
||||
ID *id;
|
||||
|
||||
if( *idpp ) (*idpp)->us--;
|
||||
|
||||
id= CTX_data_main(C)->scene.first;
|
||||
while(id) {
|
||||
if( strcmp(name, id->name+2)==0 ) {
|
||||
*idpp= id;
|
||||
id_us_plus(id);
|
||||
return;
|
||||
}
|
||||
id= id->next;
|
||||
}
|
||||
*idpp= NULL;
|
||||
}
|
||||
|
||||
void test_grouppoin_but(struct bContext *C, char *name, ID **idpp)
|
||||
{
|
||||
ID *id;
|
||||
|
||||
if( *idpp ) (*idpp)->us--;
|
||||
|
||||
id= CTX_data_main(C)->group.first;
|
||||
while(id) {
|
||||
if( strcmp(name, id->name+2)==0 ) {
|
||||
*idpp= id;
|
||||
id_us_plus(id);
|
||||
return;
|
||||
}
|
||||
id= id->next;
|
||||
}
|
||||
*idpp= NULL;
|
||||
}
|
||||
|
||||
void test_texpoin_but(struct bContext *C, char *name, ID **idpp)
|
||||
{
|
||||
ID *id;
|
||||
|
||||
if( *idpp ) (*idpp)->us--;
|
||||
|
||||
id= CTX_data_main(C)->tex.first;
|
||||
while(id) {
|
||||
if( strcmp(name, id->name+2)==0 ) {
|
||||
*idpp= id;
|
||||
id_us_plus(id);
|
||||
return;
|
||||
}
|
||||
id= id->next;
|
||||
}
|
||||
*idpp= NULL;
|
||||
}
|
||||
|
||||
void test_imapoin_but(struct bContext *C, char *name, ID **idpp)
|
||||
{
|
||||
ID *id;
|
||||
|
||||
if( *idpp ) (*idpp)->us--;
|
||||
|
||||
id= CTX_data_main(C)->image.first;
|
||||
while(id) {
|
||||
if( strcmp(name, id->name+2)==0 ) {
|
||||
*idpp= id;
|
||||
id_us_plus(id);
|
||||
return;
|
||||
}
|
||||
id= id->next;
|
||||
}
|
||||
*idpp= NULL;
|
||||
}
|
||||
|
||||
/* autocomplete callback for buttons */
|
||||
void autocomplete_bone(struct bContext *C, char *str, void *arg_v)
|
||||
{
|
||||
Object *ob= (Object *)arg_v;
|
||||
|
||||
if(ob==NULL || ob->pose==NULL) return;
|
||||
|
||||
/* search if str matches the beginning of name */
|
||||
if(str[0]) {
|
||||
AutoComplete *autocpl= autocomplete_begin(str, 32);
|
||||
bPoseChannel *pchan;
|
||||
|
||||
for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next)
|
||||
autocomplete_do_name(autocpl, pchan->name);
|
||||
|
||||
autocomplete_end(autocpl, str);
|
||||
}
|
||||
}
|
||||
|
||||
/* autocomplete callback for buttons */
|
||||
void autocomplete_vgroup(struct bContext *C, char *str, void *arg_v)
|
||||
{
|
||||
Object *ob= (Object *)arg_v;
|
||||
|
||||
if(ob==NULL) return;
|
||||
|
||||
/* search if str matches the beginning of a name */
|
||||
if(str[0]) {
|
||||
AutoComplete *autocpl= autocomplete_begin(str, 32);
|
||||
bDeformGroup *dg;
|
||||
|
||||
for(dg= ob->defbase.first; dg; dg= dg->next)
|
||||
if(dg->name!=str)
|
||||
autocomplete_do_name(autocpl, dg->name);
|
||||
|
||||
autocomplete_end(autocpl, str);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* ----------- custom button group ---------------------- */
|
||||
|
||||
static void curvemap_buttons_zoom_in(bContext *C, void *cumap_v, void *unused)
|
||||
{
|
||||
CurveMapping *cumap = cumap_v;
|
||||
float d;
|
||||
|
||||
/* we allow 20 times zoom */
|
||||
if( (cumap->curr.xmax - cumap->curr.xmin) > 0.04f*(cumap->clipr.xmax - cumap->clipr.xmin) ) {
|
||||
d= 0.1154f*(cumap->curr.xmax - cumap->curr.xmin);
|
||||
cumap->curr.xmin+= d;
|
||||
cumap->curr.xmax-= d;
|
||||
d= 0.1154f*(cumap->curr.ymax - cumap->curr.ymin);
|
||||
cumap->curr.ymin+= d;
|
||||
cumap->curr.ymax-= d;
|
||||
}
|
||||
}
|
||||
|
||||
static void curvemap_buttons_zoom_out(bContext *C, void *cumap_v, void *unused)
|
||||
{
|
||||
CurveMapping *cumap = cumap_v;
|
||||
float d, d1;
|
||||
|
||||
/* we allow 20 times zoom, but dont view outside clip */
|
||||
if( (cumap->curr.xmax - cumap->curr.xmin) < 20.0f*(cumap->clipr.xmax - cumap->clipr.xmin) ) {
|
||||
d= d1= 0.15f*(cumap->curr.xmax - cumap->curr.xmin);
|
||||
|
||||
if(cumap->flag & CUMA_DO_CLIP)
|
||||
if(cumap->curr.xmin-d < cumap->clipr.xmin)
|
||||
d1= cumap->curr.xmin - cumap->clipr.xmin;
|
||||
cumap->curr.xmin-= d1;
|
||||
|
||||
d1= d;
|
||||
if(cumap->flag & CUMA_DO_CLIP)
|
||||
if(cumap->curr.xmax+d > cumap->clipr.xmax)
|
||||
d1= -cumap->curr.xmax + cumap->clipr.xmax;
|
||||
cumap->curr.xmax+= d1;
|
||||
|
||||
d= d1= 0.15f*(cumap->curr.ymax - cumap->curr.ymin);
|
||||
|
||||
if(cumap->flag & CUMA_DO_CLIP)
|
||||
if(cumap->curr.ymin-d < cumap->clipr.ymin)
|
||||
d1= cumap->curr.ymin - cumap->clipr.ymin;
|
||||
cumap->curr.ymin-= d1;
|
||||
|
||||
d1= d;
|
||||
if(cumap->flag & CUMA_DO_CLIP)
|
||||
if(cumap->curr.ymax+d > cumap->clipr.ymax)
|
||||
d1= -cumap->curr.ymax + cumap->clipr.ymax;
|
||||
cumap->curr.ymax+= d1;
|
||||
}
|
||||
}
|
||||
|
||||
static void curvemap_buttons_setclip(bContext *C, void *cumap_v, void *unused)
|
||||
{
|
||||
CurveMapping *cumap = cumap_v;
|
||||
|
||||
curvemapping_changed(cumap, 0);
|
||||
}
|
||||
|
||||
static void curvemap_buttons_delete(bContext *C, void *cumap_v, void *unused)
|
||||
{
|
||||
CurveMapping *cumap = cumap_v;
|
||||
|
||||
curvemap_remove(cumap->cm+cumap->cur, SELECT);
|
||||
curvemapping_changed(cumap, 0);
|
||||
}
|
||||
|
||||
/* NOTE: this is a block-menu, needs 0 events, otherwise the menu closes */
|
||||
static uiBlock *curvemap_clipping_func(struct bContext *C, struct ARegion *ar, void *cumap_v)
|
||||
{
|
||||
CurveMapping *cumap = cumap_v;
|
||||
uiBlock *block;
|
||||
uiBut *bt;
|
||||
|
||||
block= uiBeginBlock(C, ar, "curvemap_clipping_func", UI_EMBOSS, UI_HELV);
|
||||
|
||||
/* use this for a fake extra empy space around the buttons */
|
||||
uiDefBut(block, LABEL, 0, "", -4, 16, 128, 106, NULL, 0, 0, 0, 0, "");
|
||||
|
||||
bt= uiDefButBitI(block, TOG, CUMA_DO_CLIP, 1, "Use Clipping",
|
||||
0,100,120,18, &cumap->flag, 0.0, 0.0, 10, 0, "");
|
||||
uiButSetFunc(bt, curvemap_buttons_setclip, cumap, NULL);
|
||||
|
||||
uiBlockBeginAlign(block);
|
||||
uiDefButF(block, NUM, 0, "Min X ", 0,74,120,18, &cumap->clipr.xmin, -100.0, cumap->clipr.xmax, 10, 0, "");
|
||||
uiDefButF(block, NUM, 0, "Min Y ", 0,56,120,18, &cumap->clipr.ymin, -100.0, cumap->clipr.ymax, 10, 0, "");
|
||||
uiDefButF(block, NUM, 0, "Max X ", 0,38,120,18, &cumap->clipr.xmax, cumap->clipr.xmin, 100.0, 10, 0, "");
|
||||
uiDefButF(block, NUM, 0, "Max Y ", 0,20,120,18, &cumap->clipr.ymax, cumap->clipr.ymin, 100.0, 10, 0, "");
|
||||
|
||||
uiBlockSetDirection(block, UI_RIGHT);
|
||||
|
||||
uiEndBlock(C, block);
|
||||
return block;
|
||||
}
|
||||
|
||||
|
||||
static void curvemap_tools_dofunc(bContext *C, void *cumap_v, int event)
|
||||
{
|
||||
CurveMapping *cumap = cumap_v;
|
||||
CurveMap *cuma= cumap->cm+cumap->cur;
|
||||
|
||||
switch(event) {
|
||||
case 0:
|
||||
curvemap_reset(cuma, &cumap->clipr);
|
||||
curvemapping_changed(cumap, 0);
|
||||
break;
|
||||
case 1:
|
||||
cumap->curr= cumap->clipr;
|
||||
break;
|
||||
case 2: /* set vector */
|
||||
curvemap_sethandle(cuma, 1);
|
||||
curvemapping_changed(cumap, 0);
|
||||
break;
|
||||
case 3: /* set auto */
|
||||
curvemap_sethandle(cuma, 0);
|
||||
curvemapping_changed(cumap, 0);
|
||||
break;
|
||||
case 4: /* extend horiz */
|
||||
cuma->flag &= ~CUMA_EXTEND_EXTRAPOLATE;
|
||||
curvemapping_changed(cumap, 0);
|
||||
break;
|
||||
case 5: /* extend extrapolate */
|
||||
cuma->flag |= CUMA_EXTEND_EXTRAPOLATE;
|
||||
curvemapping_changed(cumap, 0);
|
||||
break;
|
||||
}
|
||||
ED_region_tag_redraw(CTX_wm_region(C));
|
||||
}
|
||||
|
||||
static uiBlock *curvemap_tools_func(struct bContext *C, struct ARegion *ar, void *cumap_v)
|
||||
{
|
||||
uiBlock *block;
|
||||
short yco= 0, menuwidth=120;
|
||||
|
||||
block= uiBeginBlock(C, ar, "curvemap_tools_func", UI_EMBOSSP, UI_HELV);
|
||||
uiBlockSetButmFunc(block, curvemap_tools_dofunc, cumap_v);
|
||||
|
||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Reset View", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 1, "");
|
||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Vector Handle", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 2, "");
|
||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Auto Handle", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 3, "");
|
||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Extend Horizontal", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 4, "");
|
||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Extend Extrapolated", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 5, "");
|
||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Reset Curve", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 0, "");
|
||||
|
||||
uiBlockSetDirection(block, UI_RIGHT);
|
||||
uiTextBoundsBlock(block, 50);
|
||||
|
||||
uiEndBlock(C, block);
|
||||
return block;
|
||||
}
|
||||
|
||||
/* still unsure how this call evolves... we use labeltype for defining what curve-channels to show */
|
||||
void curvemap_buttons(uiBlock *block, CurveMapping *cumap, char labeltype, short event, short redraw, rctf *rect)
|
||||
{
|
||||
uiBut *bt;
|
||||
float dx, fy= rect->ymax-18.0f;
|
||||
int icon;
|
||||
short xco, yco;
|
||||
|
||||
yco= (short)(rect->ymax-18.0f);
|
||||
|
||||
/* curve choice options + tools/settings, 8 icons + spacer */
|
||||
dx= (rect->xmax-rect->xmin)/(9.0f);
|
||||
|
||||
uiBlockBeginAlign(block);
|
||||
if(labeltype=='v') { /* vector */
|
||||
xco= (short)rect->xmin;
|
||||
if(cumap->cm[0].curve)
|
||||
uiDefButI(block, ROW, redraw, "X", xco, yco+2, dx, 16, &cumap->cur, 0.0, 0.0, 0.0, 0.0, "");
|
||||
xco= (short)(rect->xmin+1.0f*dx);
|
||||
if(cumap->cm[1].curve)
|
||||
uiDefButI(block, ROW, redraw, "Y", xco, yco+2, dx, 16, &cumap->cur, 0.0, 1.0, 0.0, 0.0, "");
|
||||
xco= (short)(rect->xmin+2.0f*dx);
|
||||
if(cumap->cm[2].curve)
|
||||
uiDefButI(block, ROW, redraw, "Z", xco, yco+2, dx, 16, &cumap->cur, 0.0, 2.0, 0.0, 0.0, "");
|
||||
}
|
||||
else if(labeltype=='c') { /* color */
|
||||
xco= (short)rect->xmin;
|
||||
if(cumap->cm[3].curve)
|
||||
uiDefButI(block, ROW, redraw, "C", xco, yco+2, dx, 16, &cumap->cur, 0.0, 3.0, 0.0, 0.0, "");
|
||||
xco= (short)(rect->xmin+1.0f*dx);
|
||||
if(cumap->cm[0].curve)
|
||||
uiDefButI(block, ROW, redraw, "R", xco, yco+2, dx, 16, &cumap->cur, 0.0, 0.0, 0.0, 0.0, "");
|
||||
xco= (short)(rect->xmin+2.0f*dx);
|
||||
if(cumap->cm[1].curve)
|
||||
uiDefButI(block, ROW, redraw, "G", xco, yco+2, dx, 16, &cumap->cur, 0.0, 1.0, 0.0, 0.0, "");
|
||||
xco= (short)(rect->xmin+3.0f*dx);
|
||||
if(cumap->cm[2].curve)
|
||||
uiDefButI(block, ROW, redraw, "B", xco, yco+2, dx, 16, &cumap->cur, 0.0, 2.0, 0.0, 0.0, "");
|
||||
}
|
||||
/* else no channels ! */
|
||||
uiBlockEndAlign(block);
|
||||
|
||||
xco= (short)(rect->xmin+4.5f*dx);
|
||||
uiBlockSetEmboss(block, UI_EMBOSSN);
|
||||
bt= uiDefIconBut(block, BUT, redraw, ICON_ZOOMIN, xco, yco, dx, 14, NULL, 0.0, 0.0, 0.0, 0.0, "Zoom in");
|
||||
uiButSetFunc(bt, curvemap_buttons_zoom_in, cumap, NULL);
|
||||
|
||||
xco= (short)(rect->xmin+5.25f*dx);
|
||||
bt= uiDefIconBut(block, BUT, redraw, ICON_ZOOMOUT, xco, yco, dx, 14, NULL, 0.0, 0.0, 0.0, 0.0, "Zoom out");
|
||||
uiButSetFunc(bt, curvemap_buttons_zoom_out, cumap, NULL);
|
||||
|
||||
xco= (short)(rect->xmin+6.0f*dx);
|
||||
bt= uiDefIconBlockBut(block, curvemap_tools_func, cumap, event, ICON_MODIFIER, xco, yco, dx, 18, "Tools");
|
||||
|
||||
xco= (short)(rect->xmin+7.0f*dx);
|
||||
if(cumap->flag & CUMA_DO_CLIP) icon= ICON_CLIPUV_HLT; else icon= ICON_CLIPUV_DEHLT;
|
||||
bt= uiDefIconBlockBut(block, curvemap_clipping_func, cumap, event, icon, xco, yco, dx, 18, "Clipping Options");
|
||||
|
||||
xco= (short)(rect->xmin+8.0f*dx);
|
||||
bt= uiDefIconBut(block, BUT, event, ICON_X, xco, yco, dx, 18, NULL, 0.0, 0.0, 0.0, 0.0, "Delete points");
|
||||
uiButSetFunc(bt, curvemap_buttons_delete, cumap, NULL);
|
||||
|
||||
uiBlockSetEmboss(block, UI_EMBOSS);
|
||||
|
||||
uiDefBut(block, BUT_CURVE, event, "",
|
||||
rect->xmin, rect->ymin, rect->xmax-rect->xmin, fy-rect->ymin,
|
||||
cumap, 0.0f, 1.0f, 0, 0, "");
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -439,19 +439,21 @@ void ui_theme_init_userdef(void)
|
||||
SETCOL(btheme->tipo.back, 120, 120, 120, 255);
|
||||
SETCOL(btheme->tipo.header, 195, 195, 195, 255);
|
||||
SETCOL(btheme->tipo.panel, 255, 255, 255, 150);
|
||||
SETCOL(btheme->tipo.shade1, 172, 172, 172, 100);
|
||||
SETCOL(btheme->tipo.shade2, 0x70, 0x70, 0x70, 100);
|
||||
SETCOL(btheme->tipo.vertex, 0xff, 0x70, 0xff, 255);
|
||||
SETCOL(btheme->tipo.vertex_select, 0xff, 0xff, 0x70, 255);
|
||||
SETCOL(btheme->tipo.shade1, 172, 172, 172, 100);
|
||||
SETCOL(btheme->tipo.shade2, 0x70, 0x70, 0x70, 100);
|
||||
SETCOL(btheme->tipo.vertex, 0, 0, 0, 255);
|
||||
SETCOL(btheme->tipo.vertex_select, 255, 133, 0, 255);
|
||||
SETCOL(btheme->tipo.hilite, 0x60, 0xc0, 0x40, 255);
|
||||
btheme->tipo.vertex_size= 3;
|
||||
|
||||
SETCOL(btheme->tipo.handle_vertex, 0xff, 0x70, 0xff, 255);
|
||||
SETCOL(btheme->tipo.handle_vertex_select, 0xff, 0xff, 0x70, 255);
|
||||
SETCOL(btheme->tipo.handle_vertex, 0, 0, 0, 255);
|
||||
SETCOL(btheme->tipo.handle_vertex_select, 255, 133, 0, 255);
|
||||
btheme->tipo.handle_vertex_size= 3;
|
||||
|
||||
SETCOL(btheme->tipo.ds_channel, 0x36, 0x13, 0xca, 255);
|
||||
SETCOL(btheme->tipo.ds_subchannel, 0x60, 0x43, 0xd2, 255);
|
||||
SETCOL(btheme->tipo.ds_channel, 82, 96, 110, 255);
|
||||
SETCOL(btheme->tipo.ds_subchannel, 124, 137, 150, 255);
|
||||
SETCOL(btheme->tipo.group, 79, 101, 73, 255);
|
||||
SETCOL(btheme->tipo.group_active, 135, 177, 125, 255);
|
||||
|
||||
/* space file */
|
||||
/* to have something initialized */
|
||||
@@ -476,10 +478,10 @@ void ui_theme_init_userdef(void)
|
||||
SETCOL(btheme->tact.hilite, 255, 160, 0, 100); // bar
|
||||
SETCOL(btheme->tact.strip_select, 255, 160, 0, 255);
|
||||
SETCOL(btheme->tact.strip, 78, 78, 78, 255);
|
||||
SETCOL(btheme->tact.group, 22, 112, 0, 255);
|
||||
SETCOL(btheme->tact.group_active, 125, 233, 96, 255);
|
||||
SETCOL(btheme->tact.ds_channel, 0x36, 0x13, 0xca, 255);
|
||||
SETCOL(btheme->tact.ds_subchannel, 0x60, 0x43, 0xd2, 255);
|
||||
SETCOL(btheme->tact.group, 79, 101, 73, 255);
|
||||
SETCOL(btheme->tact.group_active, 135, 177, 125, 255)
|
||||
SETCOL(btheme->tact.ds_channel, 82, 96, 110, 255);
|
||||
SETCOL(btheme->tact.ds_subchannel, 124, 137, 150, 255);
|
||||
|
||||
|
||||
/* space nla */
|
||||
@@ -511,12 +513,12 @@ void ui_theme_init_userdef(void)
|
||||
/* space image */
|
||||
btheme->tima= btheme->tv3d;
|
||||
SETCOL(btheme->tima.back, 53, 53, 53, 255);
|
||||
SETCOL(btheme->tima.vertex, 0xff, 0x70, 0xff, 255);
|
||||
SETCOL(btheme->tima.vertex_select, 0xff, 0xff, 0x70, 255);
|
||||
btheme->tima.vertex_size= 2;
|
||||
btheme->tima.facedot_size= 2;
|
||||
SETCOL(btheme->tima.face, 0, 50, 150, 40);
|
||||
SETCOL(btheme->tima.face_select, 200, 100, 200, 80);
|
||||
SETCOL(btheme->tima.vertex, 0, 0, 0, 255);
|
||||
SETCOL(btheme->tima.vertex_select, 255, 133, 0, 255);
|
||||
btheme->tima.vertex_size= 3;
|
||||
btheme->tima.facedot_size= 3;
|
||||
SETCOL(btheme->tima.face, 255, 255, 255, 10);
|
||||
SETCOL(btheme->tima.face_select, 255, 133, 0, 60);
|
||||
SETCOL(btheme->tima.editmesh_active, 255, 255, 255, 128);
|
||||
|
||||
/* space imageselect */
|
||||
|
||||
@@ -69,7 +69,7 @@ static int view2d_scroll_mapped(int scroll)
|
||||
}
|
||||
|
||||
/* called each time cur changes, to dynamically update masks */
|
||||
static void view2_masks(View2D *v2d)
|
||||
static void view2d_masks(View2D *v2d)
|
||||
{
|
||||
int scroll;
|
||||
|
||||
@@ -93,9 +93,9 @@ static void view2_masks(View2D *v2d)
|
||||
scroll= view2d_scroll_mapped(v2d->scroll);
|
||||
|
||||
/* scrollers shrink mask area, but should be based off regionsize
|
||||
* - they can only be on one to two edges of the region they define
|
||||
* - if they overlap, they must not occupy the corners (which are reserved for other widgets)
|
||||
*/
|
||||
* - they can only be on one to two edges of the region they define
|
||||
* - if they overlap, they must not occupy the corners (which are reserved for other widgets)
|
||||
*/
|
||||
if (scroll) {
|
||||
/* vertical scroller */
|
||||
if (scroll & V2D_SCROLL_LEFT) {
|
||||
@@ -107,7 +107,7 @@ static void view2_masks(View2D *v2d)
|
||||
else if (scroll & V2D_SCROLL_RIGHT) {
|
||||
/* on right-hand edge of region */
|
||||
v2d->vert= v2d->mask;
|
||||
v2d->vert.xmax++; /* one pixel extra... was having leaving a minor gap... */
|
||||
v2d->vert.xmax++; /* one pixel extra... was leaving a minor gap... */
|
||||
v2d->vert.xmin= v2d->vert.xmax - V2D_SCROLL_WIDTH;
|
||||
v2d->mask.xmax= v2d->vert.xmin - 1;
|
||||
}
|
||||
@@ -231,7 +231,28 @@ void UI_view2d_region_reinit(View2D *v2d, short type, int winx, int winy)
|
||||
}
|
||||
break;
|
||||
|
||||
/* other view types are completely defined using their own settings already */
|
||||
/* ui listviews, tries to wrap 'tot' inside region width */
|
||||
case V2D_COMMONVIEW_LIST_UI:
|
||||
{
|
||||
/* for now, aspect ratio should be maintained, and zoom is clamped within sane default limits */
|
||||
v2d->keepzoom= (V2D_KEEPASPECT|V2D_KEEPZOOM);
|
||||
v2d->minzoom= 0.5f;
|
||||
v2d->maxzoom= 2.0f;
|
||||
|
||||
v2d->align= (V2D_ALIGN_NO_NEG_X|V2D_ALIGN_NO_POS_Y);
|
||||
v2d->keeptot= V2D_KEEPTOT_BOUNDS;
|
||||
|
||||
v2d->tot.xmin= 0.0f;
|
||||
v2d->tot.xmax= 336.f; // XXX 320 width + 2 x PNL_DIST
|
||||
|
||||
v2d->tot.ymax= 0.0f;
|
||||
v2d->tot.ymin= -336.0f*((float)winy)/(float)winx;
|
||||
|
||||
v2d->cur= v2d->tot;
|
||||
|
||||
}
|
||||
break;
|
||||
/* other view types are completely defined using their own settings already */
|
||||
default:
|
||||
/* we don't do anything here, as settings should be fine, but just make sure that rect */
|
||||
break;
|
||||
@@ -243,7 +264,7 @@ void UI_view2d_region_reinit(View2D *v2d, short type, int winx, int winy)
|
||||
v2d->winy= winy;
|
||||
|
||||
/* set masks */
|
||||
view2_masks(v2d);
|
||||
view2d_masks(v2d);
|
||||
|
||||
/* set 'tot' rect before setting cur? */
|
||||
if (tot_changed)
|
||||
@@ -586,7 +607,7 @@ void UI_view2d_curRect_validate(View2D *v2d)
|
||||
}
|
||||
|
||||
/* set masks */
|
||||
view2_masks(v2d);
|
||||
view2d_masks(v2d);
|
||||
}
|
||||
|
||||
/* ------------------ */
|
||||
|
||||
@@ -1295,9 +1295,16 @@ void UI_view2d_keymap(wmWindowManager *wm)
|
||||
WM_keymap_add_item(keymap, "View2D_OT_view_zoom", MIDDLEMOUSE, KM_PRESS, KM_CTRL, 0);
|
||||
|
||||
/* borderzoom - drag */
|
||||
WM_keymap_add_item(keymap, "View2D_OT_view_borderzoom", ZKEY, KM_PRESS, KM_SHIFT, 0);
|
||||
WM_keymap_add_item(keymap, "View2D_OT_view_borderzoom", BKEY, KM_PRESS, KM_SHIFT, 0);
|
||||
|
||||
/* scrollers */
|
||||
WM_keymap_add_item(keymap, "View2D_OT_scroller_activate", LEFTMOUSE, KM_PRESS, 0, 0);
|
||||
|
||||
/* Alternative keymap for buttons listview */
|
||||
keymap= WM_keymap_listbase(wm, "View2D Buttons List", 0, 0);
|
||||
WM_keymap_add_item(keymap, "View2D_OT_view_pan", MIDDLEMOUSE, KM_PRESS, 0, 0);
|
||||
WM_keymap_add_item(keymap, "View2D_OT_view_downscroll", WHEELDOWNMOUSE, KM_PRESS, 0, 0);
|
||||
WM_keymap_add_item(keymap, "View2D_OT_view_upscroll", WHEELUPMOUSE, KM_PRESS, 0, 0);
|
||||
WM_keymap_add_item(keymap, "View2D_OT_view_zoom", MIDDLEMOUSE, KM_PRESS, KM_CTRL, 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -81,27 +81,6 @@
|
||||
/* own include */
|
||||
#include "mesh_intern.h"
|
||||
|
||||
|
||||
/* Pupmenu codes: */
|
||||
#define UV_CUBE_MAPPING 2
|
||||
#define UV_CYL_MAPPING 3
|
||||
#define UV_SPHERE_MAPPING 4
|
||||
#define UV_BOUNDS_MAPPING 5
|
||||
#define UV_RESET_MAPPING 6
|
||||
#define UV_WINDOW_MAPPING 7
|
||||
#define UV_UNWRAP_MAPPING 8
|
||||
#define UV_CYL_EX 32
|
||||
#define UV_SPHERE_EX 34
|
||||
|
||||
/* Some macro tricks to make pupmenu construction look nicer :-)
|
||||
Sorry, just did it for fun. */
|
||||
|
||||
#define _STR(x) " " #x
|
||||
#define STRING(x) _STR(x)
|
||||
|
||||
#define MENUSTRING(string, code) string " %x" STRING(code)
|
||||
#define MENUTITLE(string) string " %t|"
|
||||
|
||||
/* ***************** XXX **************** */
|
||||
static int sample_backbuf_rect() {return 0;}
|
||||
static int sample_backbuf() {return 0;}
|
||||
@@ -139,462 +118,6 @@ int facesel_face_pick(View3D *v3d, Mesh *me, short *mval, unsigned int *index, s
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* only operates on the edit object - this is all thats needed at the moment */
|
||||
static void uv_calc_center_vector(Scene *scene, View3D *v3d, float *result, Object *ob, EditMesh *em)
|
||||
{
|
||||
float min[3], max[3], *cursx;
|
||||
|
||||
EditFace *efa;
|
||||
switch (v3d->around)
|
||||
{
|
||||
case V3D_CENTER: /* bounding box center */
|
||||
min[0]= min[1]= min[2]= 1e20f;
|
||||
max[0]= max[1]= max[2]= -1e20f;
|
||||
|
||||
for (efa= em->faces.first; efa; efa= efa->next) {
|
||||
if (efa->f & SELECT) {
|
||||
DO_MINMAX(efa->v1->co, min, max);
|
||||
DO_MINMAX(efa->v2->co, min, max);
|
||||
DO_MINMAX(efa->v3->co, min, max);
|
||||
if(efa->v4) DO_MINMAX(efa->v4->co, min, max);
|
||||
}
|
||||
}
|
||||
VecMidf(result, min, max);
|
||||
break;
|
||||
case V3D_CURSOR: /*cursor center*/
|
||||
cursx= give_cursor(scene, v3d);
|
||||
/* shift to objects world */
|
||||
result[0]= cursx[0]-ob->obmat[3][0];
|
||||
result[1]= cursx[1]-ob->obmat[3][1];
|
||||
result[2]= cursx[2]-ob->obmat[3][2];
|
||||
break;
|
||||
case V3D_LOCAL: /*object center*/
|
||||
case V3D_CENTROID: /* multiple objects centers, only one object here*/
|
||||
default:
|
||||
result[0]= result[1]= result[2]= 0.0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void uv_calc_map_matrix(float result[][4], RegionView3D *rv3d, Object *ob, float upangledeg, float sideangledeg, float radius)
|
||||
{
|
||||
float rotup[4][4], rotside[4][4], viewmatrix[4][4], rotobj[4][4];
|
||||
float sideangle= 0.0, upangle= 0.0;
|
||||
int k;
|
||||
|
||||
/* get rotation of the current view matrix */
|
||||
Mat4CpyMat4(viewmatrix, rv3d->viewmat);
|
||||
/* but shifting */
|
||||
for( k= 0; k< 4; k++) viewmatrix[3][k] =0.0;
|
||||
|
||||
/* get rotation of the current object matrix */
|
||||
Mat4CpyMat4(rotobj,ob->obmat);
|
||||
/* but shifting */
|
||||
for( k= 0; k< 4; k++) rotobj[3][k] =0.0;
|
||||
|
||||
Mat4Clr(*rotup);
|
||||
Mat4Clr(*rotside);
|
||||
|
||||
/* compensate front/side.. against opengl x,y,z world definition */
|
||||
/* this is "kanonen gegen spatzen", a few plus minus 1 will do here */
|
||||
/* i wanted to keep the reason here, so we're rotating*/
|
||||
sideangle= M_PI * (sideangledeg + 180.0) /180.0;
|
||||
rotside[0][0]= (float)cos(sideangle);
|
||||
rotside[0][1]= -(float)sin(sideangle);
|
||||
rotside[1][0]= (float)sin(sideangle);
|
||||
rotside[1][1]= (float)cos(sideangle);
|
||||
rotside[2][2]= 1.0f;
|
||||
|
||||
upangle= M_PI * upangledeg /180.0;
|
||||
rotup[1][1]= (float)cos(upangle)/radius;
|
||||
rotup[1][2]= -(float)sin(upangle)/radius;
|
||||
rotup[2][1]= (float)sin(upangle)/radius;
|
||||
rotup[2][2]= (float)cos(upangle)/radius;
|
||||
rotup[0][0]= (float)1.0/radius;
|
||||
|
||||
/* calculate transforms*/
|
||||
Mat4MulSerie(result,rotup,rotside,viewmatrix,rotobj,NULL,NULL,NULL,NULL);
|
||||
}
|
||||
|
||||
static void uv_calc_shift_project(ARegion *ar, View3D *v3d, float *target, float *shift, float rotmat[][4], int projectionmode, float *source, float *min, float *max)
|
||||
{
|
||||
RegionView3D *rv3d= ar->regiondata;
|
||||
float pv[3];
|
||||
|
||||
VecSubf(pv, source, shift);
|
||||
Mat4MulVecfl(rotmat, pv);
|
||||
|
||||
switch(projectionmode) {
|
||||
case B_UVAUTO_CYLINDER:
|
||||
tubemap(pv[0], pv[1], pv[2], &target[0],&target[1]);
|
||||
/* split line is always zero */
|
||||
if (target[0] >= 1.0f) target[0] -= 1.0f;
|
||||
break;
|
||||
|
||||
case B_UVAUTO_SPHERE:
|
||||
spheremap(pv[0], pv[1], pv[2], &target[0],&target[1]);
|
||||
/* split line is always zero */
|
||||
if (target[0] >= 1.0f) target[0] -= 1.0f;
|
||||
break;
|
||||
|
||||
case 3: /* ortho special case for BOUNDS */
|
||||
target[0] = -pv[0];
|
||||
target[1] = pv[2];
|
||||
break;
|
||||
|
||||
case 4:
|
||||
{
|
||||
/* very special case for FROM WINDOW */
|
||||
float pv4[4], dx, dy, x= 0.0, y= 0.0;
|
||||
|
||||
dx= ar->winx;
|
||||
dy= ar->winy;
|
||||
|
||||
VecCopyf(pv4, source);
|
||||
pv4[3] = 1.0;
|
||||
|
||||
/* rotmat is the object matrix in this case */
|
||||
Mat4MulVec4fl(rotmat, pv4);
|
||||
|
||||
/* almost project_short */
|
||||
Mat4MulVec4fl(rv3d->persmat, pv4);
|
||||
if (fabs(pv4[3]) > 0.00001) { /* avoid division by zero */
|
||||
target[0] = dx/2.0 + (dx/2.0)*pv4[0]/pv4[3];
|
||||
target[1] = dy/2.0 + (dy/2.0)*pv4[1]/pv4[3];
|
||||
}
|
||||
else {
|
||||
/* scaling is lost but give a valid result */
|
||||
target[0] = dx/2.0 + (dx/2.0)*pv4[0];
|
||||
target[1] = dy/2.0 + (dy/2.0)*pv4[1];
|
||||
}
|
||||
|
||||
/* v3d->persmat seems to do this funky scaling */
|
||||
if(dx > dy) {
|
||||
y= (dx-dy)/2.0;
|
||||
dy = dx;
|
||||
}
|
||||
else {
|
||||
x= (dy-dx)/2.0;
|
||||
dx = dy;
|
||||
}
|
||||
target[0]= (x + target[0])/dx;
|
||||
target[1]= (y + target[1])/dy;
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
target[0] = 0.0;
|
||||
target[1] = 1.0;
|
||||
}
|
||||
|
||||
/* we know the values here and may need min_max later */
|
||||
/* max requests independand from min; not fastest but safest */
|
||||
if(min) {
|
||||
min[0] = MIN2(target[0], min[0]);
|
||||
min[1] = MIN2(target[1], min[1]);
|
||||
}
|
||||
if(max) {
|
||||
max[0] = MAX2(target[0], max[0]);
|
||||
max[1] = MAX2(target[1], max[1]);
|
||||
}
|
||||
}
|
||||
|
||||
static void correct_uv_aspect( EditMesh *em )
|
||||
{
|
||||
float aspx=1, aspy=1;
|
||||
EditFace *efa = EM_get_actFace(em, 1);
|
||||
MTFace *tface;
|
||||
|
||||
if (efa) {
|
||||
tface = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
|
||||
// XXX image_final_aspect(tface->tpage, &aspx, &aspy);
|
||||
}
|
||||
|
||||
if (aspx != aspy) {
|
||||
|
||||
float scale;
|
||||
|
||||
if (aspx > aspy) {
|
||||
scale = aspy/aspx;
|
||||
for (efa= em->faces.first; efa; efa= efa->next) {
|
||||
if (efa->f & SELECT) {
|
||||
tface = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
|
||||
tface->uv[0][0] = ((tface->uv[0][0]-0.5)*scale)+0.5;
|
||||
tface->uv[1][0] = ((tface->uv[1][0]-0.5)*scale)+0.5;
|
||||
tface->uv[2][0] = ((tface->uv[2][0]-0.5)*scale)+0.5;
|
||||
if(efa->v4) {
|
||||
tface->uv[3][0] = ((tface->uv[3][0]-0.5)*scale)+0.5;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
scale = aspx/aspy;
|
||||
for (efa= em->faces.first; efa; efa= efa->next) {
|
||||
if (efa->f & SELECT) {
|
||||
tface = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
|
||||
tface->uv[0][1] = ((tface->uv[0][1]-0.5)*scale)+0.5;
|
||||
tface->uv[1][1] = ((tface->uv[1][1]-0.5)*scale)+0.5;
|
||||
tface->uv[2][1] = ((tface->uv[2][1]-0.5)*scale)+0.5;
|
||||
if(efa->v4) {
|
||||
tface->uv[3][1] = ((tface->uv[3][1]-0.5)*scale)+0.5;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void default_uv(float uv[][2], float size)
|
||||
{
|
||||
int dy;
|
||||
|
||||
if(size>1.0) size= 1.0;
|
||||
|
||||
dy= 1.0-size;
|
||||
|
||||
uv[0][0]= 0;
|
||||
uv[0][1]= size+dy;
|
||||
|
||||
uv[1][0]= 0;
|
||||
uv[1][1]= dy;
|
||||
|
||||
uv[2][0]= size;
|
||||
uv[2][1]= dy;
|
||||
|
||||
uv[3][0]= size;
|
||||
uv[3][1]= size+dy;
|
||||
}
|
||||
|
||||
static void calculate_uv_map(Scene *scene, ARegion *ar, View3D *v3d, EditMesh *em, unsigned short mapmode)
|
||||
{
|
||||
RegionView3D *rv3d= ar->regiondata;
|
||||
MTFace *tface;
|
||||
Object *ob;
|
||||
EditFace *efa;
|
||||
float dx, dy, rotatematrix[4][4], radius= 1.0, min[3], cent[3], max[3];
|
||||
float fac= 1.0, upangledeg= 0.0, sideangledeg= 90.0;
|
||||
int i, b, mi, n;
|
||||
|
||||
if(scene->toolsettings->uvcalc_mapdir==1) {
|
||||
upangledeg= 90.0;
|
||||
sideangledeg= 0.0;
|
||||
} else {
|
||||
upangledeg= 0.0;
|
||||
if(scene->toolsettings->uvcalc_mapalign==1) sideangledeg= 0.0;
|
||||
else sideangledeg= 90.0;
|
||||
}
|
||||
|
||||
/* add uvs if there not here */
|
||||
if (!EM_texFaceCheck(em)) {
|
||||
if (em && em->faces.first)
|
||||
EM_add_data_layer(em, &em->fdata, CD_MTFACE);
|
||||
|
||||
// XXX if (G.sima && G.sima->image) /* this is a bit of a kludge, but assume they want the image on their mesh when UVs are added */
|
||||
// image_changed(G.sima, G.sima->image);
|
||||
|
||||
if (!EM_texFaceCheck(em))
|
||||
return;
|
||||
|
||||
/* select new UV's */
|
||||
// XX if ((G.sima && G.sima->flag & SI_SYNC_UVSEL)==0) {
|
||||
// for(efa=em->faces.first; efa; efa=efa->next) {
|
||||
// MTFace *tf= (MTFace *)CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
|
||||
// simaFaceSel_Set(efa, tf);
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
ob=OBACT;
|
||||
|
||||
switch(mapmode) {
|
||||
case B_UVAUTO_BOUNDS:
|
||||
min[0]= min[1]= 10000000.0;
|
||||
max[0]= max[1]= -10000000.0;
|
||||
|
||||
cent[0] = cent[1] = cent[2] = 0.0;
|
||||
uv_calc_map_matrix(rotatematrix, rv3d, ob, upangledeg, sideangledeg, 1.0f);
|
||||
|
||||
for (efa= em->faces.first; efa; efa= efa->next) {
|
||||
if (efa->f & SELECT) {
|
||||
tface = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
|
||||
uv_calc_shift_project(ar, v3d, tface->uv[0],cent,rotatematrix,3, efa->v1->co, min,max);
|
||||
uv_calc_shift_project(ar, v3d, tface->uv[1],cent,rotatematrix,3, efa->v2->co, min,max);
|
||||
uv_calc_shift_project(ar, v3d, tface->uv[2],cent,rotatematrix,3, efa->v3->co,min,max);
|
||||
if(efa->v4)
|
||||
uv_calc_shift_project(ar, v3d, tface->uv[3],cent,rotatematrix,3, efa->v4->co,min,max);
|
||||
}
|
||||
}
|
||||
|
||||
/* rescale UV to be in 1/1 */
|
||||
dx= (max[0]-min[0]);
|
||||
dy= (max[1]-min[1]);
|
||||
|
||||
for (efa= em->faces.first; efa; efa= efa->next) {
|
||||
if (efa->f & SELECT) {
|
||||
tface = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
|
||||
if(efa->v4) b= 3; else b= 2;
|
||||
for(; b>=0; b--) {
|
||||
tface->uv[b][0]= ((tface->uv[b][0]-min[0])*fac)/dx;
|
||||
tface->uv[b][1]= 1.0-fac+((tface->uv[b][1]-min[1])/* *fac */)/dy;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case B_UVAUTO_WINDOW:
|
||||
cent[0] = cent[1] = cent[2] = 0.0;
|
||||
Mat4CpyMat4(rotatematrix,ob->obmat);
|
||||
for (efa= em->faces.first; efa; efa= efa->next) {
|
||||
if (efa->f & SELECT) {
|
||||
tface = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
|
||||
uv_calc_shift_project(ar, v3d, tface->uv[0],cent,rotatematrix,4, efa->v1->co, NULL,NULL);
|
||||
uv_calc_shift_project(ar, v3d, tface->uv[1],cent,rotatematrix,4, efa->v2->co, NULL,NULL);
|
||||
uv_calc_shift_project(ar, v3d, tface->uv[2],cent,rotatematrix,4, efa->v3->co, NULL,NULL);
|
||||
if(efa->v4)
|
||||
uv_calc_shift_project(ar, v3d, tface->uv[3],cent,rotatematrix,4, efa->v4->co, NULL,NULL);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case B_UVAUTO_RESET:
|
||||
for (efa= em->faces.first; efa; efa= efa->next) {
|
||||
if (efa->f & SELECT) {
|
||||
tface = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
|
||||
default_uv(tface->uv, 1.0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case B_UVAUTO_CYLINDER:
|
||||
case B_UVAUTO_SPHERE:
|
||||
uv_calc_center_vector(scene, v3d, cent, ob, em);
|
||||
|
||||
if(mapmode==B_UVAUTO_CYLINDER) radius = scene->toolsettings->uvcalc_radius;
|
||||
|
||||
/* be compatible to the "old" sphere/cylinder mode */
|
||||
if (scene->toolsettings->uvcalc_mapdir== 2)
|
||||
Mat4One(rotatematrix);
|
||||
else
|
||||
uv_calc_map_matrix(rotatematrix, rv3d, ob, upangledeg,sideangledeg,radius);
|
||||
for (efa= em->faces.first; efa; efa= efa->next) {
|
||||
if (efa->f & SELECT) {
|
||||
tface = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
|
||||
uv_calc_shift_project(ar, v3d, tface->uv[0],cent,rotatematrix,mapmode, efa->v1->co, NULL,NULL);
|
||||
uv_calc_shift_project(ar, v3d, tface->uv[1],cent,rotatematrix,mapmode, efa->v2->co, NULL,NULL);
|
||||
uv_calc_shift_project(ar, v3d, tface->uv[2],cent,rotatematrix,mapmode, efa->v3->co, NULL,NULL);
|
||||
n = 3;
|
||||
if(efa->v4) {
|
||||
uv_calc_shift_project(ar, v3d, tface->uv[3],cent,rotatematrix,mapmode, efa->v4->co, NULL,NULL);
|
||||
n=4;
|
||||
}
|
||||
|
||||
mi = 0;
|
||||
for (i = 1; i < n; i++)
|
||||
if (tface->uv[i][0] > tface->uv[mi][0]) mi = i;
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
if (i != mi) {
|
||||
dx = tface->uv[mi][0] - tface->uv[i][0];
|
||||
if (dx > 0.5) tface->uv[i][0] += 1.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case B_UVAUTO_CUBE:
|
||||
{
|
||||
/* choose x,y,z axis for projetion depending on the largest normal */
|
||||
/* component, but clusters all together around the center of map */
|
||||
float no[3];
|
||||
short cox, coy;
|
||||
float *loc= ob->obmat[3];
|
||||
/*MVert *mv= me->mvert;*/
|
||||
float cubesize = scene->toolsettings->uvcalc_cubesize;
|
||||
|
||||
for (efa= em->faces.first; efa; efa= efa->next) {
|
||||
if (efa->f & SELECT) {
|
||||
tface = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
|
||||
CalcNormFloat(efa->v1->co, efa->v2->co, efa->v3->co, no);
|
||||
|
||||
no[0]= fabs(no[0]);
|
||||
no[1]= fabs(no[1]);
|
||||
no[2]= fabs(no[2]);
|
||||
|
||||
cox=0; coy= 1;
|
||||
if(no[2]>=no[0] && no[2]>=no[1]);
|
||||
else if(no[1]>=no[0] && no[1]>=no[2]) coy= 2;
|
||||
else { cox= 1; coy= 2; }
|
||||
|
||||
tface->uv[0][0]= 0.5+0.5*cubesize*(loc[cox] + efa->v1->co[cox]);
|
||||
tface->uv[0][1]= 0.5+0.5*cubesize*(loc[coy] + efa->v1->co[coy]);
|
||||
dx = floor(tface->uv[0][0]);
|
||||
dy = floor(tface->uv[0][1]);
|
||||
tface->uv[0][0] -= dx;
|
||||
tface->uv[0][1] -= dy;
|
||||
tface->uv[1][0]= 0.5+0.5*cubesize*(loc[cox] + efa->v2->co[cox]);
|
||||
tface->uv[1][1]= 0.5+0.5*cubesize*(loc[coy] + efa->v2->co[coy]);
|
||||
tface->uv[1][0] -= dx;
|
||||
tface->uv[1][1] -= dy;
|
||||
tface->uv[2][0]= 0.5+0.5*cubesize*(loc[cox] + efa->v3->co[cox]);
|
||||
tface->uv[2][1]= 0.5+0.5*cubesize*(loc[coy] + efa->v3->co[coy]);
|
||||
tface->uv[2][0] -= dx;
|
||||
tface->uv[2][1] -= dy;
|
||||
if(efa->v4) {
|
||||
tface->uv[3][0]= 0.5+0.5*cubesize*(loc[cox] + efa->v4->co[cox]);
|
||||
tface->uv[3][1]= 0.5+0.5*cubesize*(loc[coy] + efa->v4->co[coy]);
|
||||
tface->uv[3][0] -= dx;
|
||||
tface->uv[3][1] -= dy;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
if ((scene->toolsettings->uvcalc_flag & UVCALC_NO_ASPECT_CORRECT)==0)
|
||||
correct_uv_aspect(em);
|
||||
return;
|
||||
} /* end switch mapmode */
|
||||
|
||||
/* clipping and wrapping */
|
||||
if(0) { // XXX (make it uv layer property!) G.sima && G.sima->flag & SI_CLIP_UV) {
|
||||
for (efa= em->faces.first; efa; efa= efa->next) {
|
||||
if (!(efa->f & SELECT)) continue;
|
||||
tface = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
|
||||
|
||||
dx= dy= 0;
|
||||
if(efa->v4) b= 3; else b= 2;
|
||||
for(; b>=0; b--) {
|
||||
while(tface->uv[b][0] + dx < 0.0) dx+= 0.5;
|
||||
while(tface->uv[b][0] + dx > 1.0) dx-= 0.5;
|
||||
while(tface->uv[b][1] + dy < 0.0) dy+= 0.5;
|
||||
while(tface->uv[b][1] + dy > 1.0) dy-= 0.5;
|
||||
}
|
||||
|
||||
if(efa->v4) b= 3; else b= 2;
|
||||
for(; b>=0; b--) {
|
||||
tface->uv[b][0]+= dx;
|
||||
CLAMP(tface->uv[b][0], 0.0, 1.0);
|
||||
|
||||
tface->uv[b][1]+= dy;
|
||||
CLAMP(tface->uv[b][1], 0.0, 1.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( (mapmode!=B_UVAUTO_BOUNDS) &&
|
||||
(mapmode!=B_UVAUTO_RESET) &&
|
||||
(scene->toolsettings->uvcalc_flag & UVCALC_NO_ASPECT_CORRECT)==0
|
||||
) {
|
||||
correct_uv_aspect(em);
|
||||
}
|
||||
|
||||
// XXX notifier object_uvs_changed(OBACT);
|
||||
|
||||
}
|
||||
|
||||
/* last_sel, use em->act_face otherwise get the last selected face in the editselections
|
||||
* at the moment, last_sel is mainly useful for gaking sure the space image dosnt flicker */
|
||||
MTFace *EM_get_active_mtface(EditMesh *em, EditFace **act_efa, MCol **mcol, int sloppy)
|
||||
@@ -1211,73 +734,6 @@ void face_borderselect(Scene *scene, ARegion *ar)
|
||||
#endif
|
||||
}
|
||||
|
||||
void uv_autocalc_tface(Scene *scene, ARegion *ar, View3D *v3d, EditMesh *em)
|
||||
{
|
||||
short mode;
|
||||
#ifndef DISABLE_PYTHON
|
||||
// short i=0, has_pymenu=0; /* pymenu must be bigger then UV_*_MAPPING */
|
||||
// XXX BPyMenu *pym;
|
||||
// char menu_number[3];
|
||||
#endif
|
||||
|
||||
/* uvmenu, will add python items */
|
||||
char uvmenu[4096]=MENUTITLE("UV Calculation")
|
||||
MENUSTRING("Unwrap", UV_UNWRAP_MAPPING) "|%l|"
|
||||
|
||||
MENUSTRING("Cube Projection", UV_CUBE_MAPPING) "|"
|
||||
MENUSTRING("Cylinder from View", UV_CYL_MAPPING) "|"
|
||||
MENUSTRING("Sphere from View", UV_SPHERE_MAPPING) "|%l|"
|
||||
|
||||
MENUSTRING("Project From View", UV_WINDOW_MAPPING) "|"
|
||||
MENUSTRING("Project from View (Bounds)",UV_BOUNDS_MAPPING) "|%l|"
|
||||
|
||||
MENUSTRING("Reset", UV_RESET_MAPPING);
|
||||
#ifndef DISABLE_PYTHON
|
||||
#if 0
|
||||
XXX
|
||||
/* note that we account for the 10 previous entries with i+10: */
|
||||
for (pym = BPyMenuTable[PYMENU_UVCALCULATION]; pym; pym = pym->next, i++) {
|
||||
|
||||
if (!has_pymenu) {
|
||||
strcat(uvmenu, "|%l");
|
||||
has_pymenu = 1;
|
||||
}
|
||||
|
||||
strcat(uvmenu, "|");
|
||||
strcat(uvmenu, pym->name);
|
||||
strcat(uvmenu, " %x");
|
||||
sprintf(menu_number, "%d", i+10);
|
||||
strcat(uvmenu, menu_number);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
mode= pupmenu(uvmenu);
|
||||
#ifndef DISABLE_PYTHON
|
||||
// if (mode >= 10) {
|
||||
// BPY_menu_do_python(PYMENU_UVCALCULATION, mode - 10);
|
||||
// return;
|
||||
// }
|
||||
#endif
|
||||
switch(mode) {
|
||||
case UV_CUBE_MAPPING:
|
||||
calculate_uv_map(scene, ar, v3d, em, B_UVAUTO_CUBE); break;
|
||||
case UV_CYL_MAPPING:
|
||||
calculate_uv_map(scene, ar, v3d, em, B_UVAUTO_CYLINDER); break;
|
||||
case UV_SPHERE_MAPPING:
|
||||
calculate_uv_map(scene, ar, v3d, em, B_UVAUTO_SPHERE); break;
|
||||
case UV_BOUNDS_MAPPING:
|
||||
calculate_uv_map(scene, ar, v3d, em, B_UVAUTO_BOUNDS); break;
|
||||
case UV_RESET_MAPPING:
|
||||
calculate_uv_map(scene, ar, v3d, em, B_UVAUTO_RESET); break;
|
||||
case UV_WINDOW_MAPPING:
|
||||
calculate_uv_map(scene, ar, v3d, em, B_UVAUTO_WINDOW); break;
|
||||
case UV_UNWRAP_MAPPING:
|
||||
// XXX unwrap_lscm(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Texture Paint */
|
||||
|
||||
void set_texturepaint(Scene *scene) /* toggle */
|
||||
|
||||
@@ -220,6 +220,7 @@ void EM_validate_selections(EditMesh *em)
|
||||
EditSelection *ese, *nextese;
|
||||
|
||||
ese = em->selected.first;
|
||||
|
||||
while(ese){
|
||||
nextese = ese->next;
|
||||
if(ese->type == EDITVERT && !(((EditVert*)ese->data)->f & SELECT)) BLI_freelinkN(&(em->selected), ese);
|
||||
|
||||
@@ -2534,9 +2534,8 @@ void MESH_OT_select_linked(wmOperatorType *ot)
|
||||
|
||||
/* ************************* */
|
||||
|
||||
|
||||
/* swap is 0 or 1, if 1 it hides not selected */
|
||||
static void hide_mesh(EditMesh *em, int swap)
|
||||
void EM_hide_mesh(EditMesh *em, int swap)
|
||||
{
|
||||
EditVert *eve;
|
||||
EditEdge *eed;
|
||||
@@ -2643,7 +2642,7 @@ static int hide_mesh_exec(bContext *C, wmOperator *op)
|
||||
Object *obedit= CTX_data_edit_object(C);
|
||||
EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
|
||||
|
||||
hide_mesh(em, RNA_boolean_get(op->ptr, "invert"));
|
||||
EM_hide_mesh(em, RNA_boolean_get(op->ptr, "invert"));
|
||||
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
|
||||
return OPERATOR_FINISHED;
|
||||
@@ -2663,10 +2662,10 @@ void MESH_OT_hide(wmOperatorType *ot)
|
||||
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
|
||||
/* props */
|
||||
RNA_def_boolean(ot->srna, "invert", 0, "Invert", "");
|
||||
RNA_def_boolean(ot->srna, "invert", 0, "Invert", "Hide unselected rather than selected.");
|
||||
}
|
||||
|
||||
void reveal_mesh(EditMesh *em)
|
||||
void EM_reveal_mesh(EditMesh *em)
|
||||
{
|
||||
EditVert *eve;
|
||||
EditEdge *eed;
|
||||
@@ -2707,8 +2706,8 @@ static int reveal_mesh_exec(bContext *C, wmOperator *op)
|
||||
Object *obedit= CTX_data_edit_object(C);
|
||||
EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
|
||||
|
||||
reveal_mesh(em);
|
||||
|
||||
EM_reveal_mesh(em);
|
||||
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -2727,228 +2726,6 @@ void MESH_OT_reveal(wmOperatorType *ot)
|
||||
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
void hide_tface_uv(EditMesh *em, int swap)
|
||||
{
|
||||
#if 0
|
||||
/* no space image here */
|
||||
EditFace *efa;
|
||||
MTFace *tface;
|
||||
|
||||
if( is_uv_tface_editing_allowed()==0 ) return;
|
||||
|
||||
/* call the mesh function if we are in mesh sync sel */
|
||||
if (G.sima->flag & SI_SYNC_UVSEL) {
|
||||
hide_mesh(swap);
|
||||
return;
|
||||
}
|
||||
|
||||
if(swap) {
|
||||
for (efa= em->faces.first; efa; efa= efa->next) {
|
||||
if(efa->f & SELECT) {
|
||||
tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
|
||||
if (G.sima->flag & SI_SELACTFACE) {
|
||||
/* Pretend face mode */
|
||||
if (( (efa->v4==NULL &&
|
||||
( tface->flag & (TF_SEL1|TF_SEL2|TF_SEL3)) == (TF_SEL1|TF_SEL2|TF_SEL3) ) ||
|
||||
( tface->flag & (TF_SEL1|TF_SEL2|TF_SEL3|TF_SEL4)) == (TF_SEL1|TF_SEL2|TF_SEL3|TF_SEL4) ) == 0) {
|
||||
|
||||
if (em->selectmode == SCE_SELECT_FACE) {
|
||||
efa->f &= ~SELECT;
|
||||
/* must re-select after */
|
||||
efa->e1->f &= ~SELECT;
|
||||
efa->e2->f &= ~SELECT;
|
||||
efa->e3->f &= ~SELECT;
|
||||
if(efa->e4) efa->e4->f &= ~SELECT;
|
||||
} else {
|
||||
EM_select_face(efa, 0);
|
||||
}
|
||||
}
|
||||
tface->flag &= ~(TF_SEL1|TF_SEL2|TF_SEL3|TF_SEL4);
|
||||
} else if (em->selectmode == SCE_SELECT_FACE) {
|
||||
if((tface->flag & (TF_SEL1|TF_SEL2|TF_SEL3))==0) {
|
||||
if(!efa->v4)
|
||||
EM_select_face(efa, 0);
|
||||
else if(!(tface->flag & TF_SEL4))
|
||||
EM_select_face(efa, 0);
|
||||
tface->flag &= ~(TF_SEL1|TF_SEL2|TF_SEL3|TF_SEL4);
|
||||
}
|
||||
} else {
|
||||
/* EM_deselect_flush will deselect the face */
|
||||
if((tface->flag & TF_SEL1)==0) efa->v1->f &= ~SELECT;
|
||||
if((tface->flag & TF_SEL2)==0) efa->v2->f &= ~SELECT;
|
||||
if((tface->flag & TF_SEL3)==0) efa->v3->f &= ~SELECT;
|
||||
if((efa->v4) && (tface->flag & TF_SEL4)==0) efa->v4->f &= ~SELECT;
|
||||
tface->flag &= ~(TF_SEL1|TF_SEL2|TF_SEL3|TF_SEL4);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (efa= em->faces.first; efa; efa= efa->next) {
|
||||
if(efa->f & SELECT) {
|
||||
tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
|
||||
if (G.sima->flag & SI_SELACTFACE) {
|
||||
if ( (efa->v4==NULL &&
|
||||
( tface->flag & (TF_SEL1|TF_SEL2|TF_SEL3)) == (TF_SEL1|TF_SEL2|TF_SEL3) ) ||
|
||||
( tface->flag & (TF_SEL1|TF_SEL2|TF_SEL3|TF_SEL4)) == (TF_SEL1|TF_SEL2|TF_SEL3|TF_SEL4) ) {
|
||||
|
||||
if (em->selectmode == SCE_SELECT_FACE) {
|
||||
efa->f &= ~SELECT;
|
||||
/* must re-select after */
|
||||
efa->e1->f &= ~SELECT;
|
||||
efa->e2->f &= ~SELECT;
|
||||
efa->e3->f &= ~SELECT;
|
||||
if(efa->e4) efa->e4->f &= ~SELECT;
|
||||
} else {
|
||||
EM_select_face(efa, 0);
|
||||
}
|
||||
}
|
||||
tface->flag &= ~(TF_SEL1|TF_SEL2|TF_SEL3|TF_SEL4);
|
||||
} else if (em->selectmode == SCE_SELECT_FACE) {
|
||||
if(tface->flag & (TF_SEL1|TF_SEL2|TF_SEL3))
|
||||
EM_select_face(efa, 0);
|
||||
else if(efa->v4 && tface->flag & TF_SEL4)
|
||||
EM_select_face(efa, 0);
|
||||
tface->flag &= ~(TF_SEL1|TF_SEL2|TF_SEL3|TF_SEL4);
|
||||
} else {
|
||||
/* EM_deselect_flush will deselect the face */
|
||||
if(tface->flag & TF_SEL1) efa->v1->f &= ~SELECT;
|
||||
if(tface->flag & TF_SEL2) efa->v2->f &= ~SELECT;
|
||||
if(tface->flag & TF_SEL3) efa->v3->f &= ~SELECT;
|
||||
if((efa->v4) && tface->flag & TF_SEL4) efa->v4->f &= ~SELECT;
|
||||
tface->flag &= ~(TF_SEL1|TF_SEL2|TF_SEL3|TF_SEL4);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*deselects too many but ok for now*/
|
||||
if(em->selectmode & (SCE_SELECT_EDGE|SCE_SELECT_VERTEX)) {
|
||||
EM_deselect_flush(em);
|
||||
}
|
||||
|
||||
if (em->selectmode==SCE_SELECT_FACE) {
|
||||
/* de-selected all edges from faces that were de-selected.
|
||||
* now make sure all faces that are selected also have selected edges */
|
||||
for (efa= em->faces.first; efa; efa= efa->next) {
|
||||
if (efa->f & SELECT) {
|
||||
EM_select_face(efa, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
EM_validate_selections();
|
||||
|
||||
// XXX object_tface_flags_changed(OBACT, 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
void reveal_tface_uv(EditMesh *em)
|
||||
{
|
||||
#if 0
|
||||
/* function should move away? */
|
||||
EditFace *efa;
|
||||
MTFace *tface;
|
||||
|
||||
if( is_uv_tface_editing_allowed()==0 ) return;
|
||||
|
||||
/* call the mesh function if we are in mesh sync sel */
|
||||
if (G.sima->flag & SI_SYNC_UVSEL) {
|
||||
reveal_mesh();
|
||||
return;
|
||||
}
|
||||
|
||||
if (G.sima->flag & SI_SELACTFACE) {
|
||||
if (em->selectmode == SCE_SELECT_FACE) {
|
||||
for (efa= em->faces.first; efa; efa= efa->next) {
|
||||
if (!(efa->h) && !(efa->f & SELECT)) {
|
||||
tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
|
||||
EM_select_face(efa, 1);
|
||||
tface->flag |= TF_SEL1|TF_SEL2|TF_SEL3|TF_SEL4;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* enable adjacent faces to have disconnected UV selections if sticky is disabled */
|
||||
if (G.sima->sticky == SI_STICKY_DISABLE) {
|
||||
for (efa= em->faces.first; efa; efa= efa->next) {
|
||||
if (!(efa->h) && !(efa->f & SELECT)) {
|
||||
/* All verts must be unselected for the face to be selected in the UV view */
|
||||
if ((efa->v1->f&SELECT)==0 && (efa->v2->f&SELECT)==0 && (efa->v3->f&SELECT)==0 && (efa->v4==0 || (efa->v4->f&SELECT)==0)) {
|
||||
tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
|
||||
tface->flag |= TF_SEL1|TF_SEL2|TF_SEL3|TF_SEL4;
|
||||
/* Cant use EM_select_face here because it unselects the verts
|
||||
* and we cant tell if the face was totally unselected or not */
|
||||
/*EM_select_face(efa, 1);
|
||||
*
|
||||
* See Loop with EM_select_face() below... */
|
||||
efa->f |= SELECT;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (efa= em->faces.first; efa; efa= efa->next) {
|
||||
if (!(efa->h) && !(efa->f & SELECT)) {
|
||||
tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
|
||||
if ((efa->v1->f & SELECT)==0) {tface->flag |= TF_SEL1;}
|
||||
if ((efa->v2->f & SELECT)==0) {tface->flag |= TF_SEL2;}
|
||||
if ((efa->v3->f & SELECT)==0) {tface->flag |= TF_SEL3;}
|
||||
if ((efa->v4 && (efa->v4->f & SELECT)==0)) {tface->flag |= TF_SEL4;}
|
||||
efa->f |= SELECT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Select all edges and verts now */
|
||||
for (efa= em->faces.first; efa; efa= efa->next) {
|
||||
/* we only selected the face flags, and didnt changes edges or verts, fix this now */
|
||||
if (!(efa->h) && (efa->f & SELECT)) {
|
||||
EM_select_face(efa, 1);
|
||||
}
|
||||
}
|
||||
EM_select_flush(em);
|
||||
}
|
||||
} else if (em->selectmode == SCE_SELECT_FACE) {
|
||||
for (efa= em->faces.first; efa; efa= efa->next) {
|
||||
if (!(efa->h) && !(efa->f & SELECT)) {
|
||||
tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
|
||||
efa->f |= SELECT;
|
||||
tface->flag |= TF_SEL1|TF_SEL2|TF_SEL3|TF_SEL4;
|
||||
}
|
||||
}
|
||||
|
||||
/* Select all edges and verts now */
|
||||
for (efa= em->faces.first; efa; efa= efa->next) {
|
||||
/* we only selected the face flags, and didnt changes edges or verts, fix this now */
|
||||
if (!(efa->h) && (efa->f & SELECT)) {
|
||||
EM_select_face(efa, 1);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
for (efa= em->faces.first; efa; efa= efa->next) {
|
||||
if (!(efa->h) && !(efa->f & SELECT)) {
|
||||
tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
|
||||
if ((efa->v1->f & SELECT)==0) {tface->flag |= TF_SEL1;}
|
||||
if ((efa->v2->f & SELECT)==0) {tface->flag |= TF_SEL2;}
|
||||
if ((efa->v3->f & SELECT)==0) {tface->flag |= TF_SEL3;}
|
||||
if ((efa->v4 && (efa->v4->f & SELECT)==0)) {tface->flag |= TF_SEL4;}
|
||||
efa->f |= SELECT;
|
||||
}
|
||||
}
|
||||
|
||||
/* Select all edges and verts now */
|
||||
for (efa= em->faces.first; efa; efa= efa->next) {
|
||||
/* we only selected the face flags, and didnt changes edges or verts, fix this now */
|
||||
if (!(efa->h) && (efa->f & SELECT)) {
|
||||
EM_select_face(efa, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// XXX object_tface_flags_changed(OBACT, 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
void select_faces_by_numverts(EditMesh *em, int numverts)
|
||||
{
|
||||
EditFace *efa;
|
||||
@@ -3391,7 +3168,7 @@ void EM_select_swap(EditMesh *em) /* exported for UV */
|
||||
|
||||
}
|
||||
|
||||
static int selectswap_mesh_exec(bContext *C, wmOperator *op)
|
||||
static int select_invert_mesh_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Object *obedit= CTX_data_edit_object(C);
|
||||
EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
|
||||
@@ -3405,11 +3182,11 @@ static int selectswap_mesh_exec(bContext *C, wmOperator *op)
|
||||
void MESH_OT_select_invert(wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name= "Select Swap";
|
||||
ot->name= "Select Invert";
|
||||
ot->idname= "MESH_OT_select_invert";
|
||||
|
||||
/* api callbacks */
|
||||
ot->exec= selectswap_mesh_exec;
|
||||
ot->exec= select_invert_mesh_exec;
|
||||
ot->poll= ED_operator_editmesh;
|
||||
|
||||
/* flags */
|
||||
@@ -3696,7 +3473,7 @@ static void selectrandom_mesh(EditMesh *em, float perc) /* randomly selects a us
|
||||
EditVert *eve;
|
||||
EditEdge *eed;
|
||||
EditFace *efa;
|
||||
float randfac= perc/100.0f;
|
||||
float randfac= perc;
|
||||
/* Get the percentage of vertices to randomly select as 'randfac' */
|
||||
// XXX if(button(&randfac,0, 100,"Percentage:")==0) return;
|
||||
|
||||
@@ -3759,7 +3536,7 @@ void MESH_OT_select_random(wmOperatorType *ot)
|
||||
ot->flag= OPTYPE_REGISTER/*|OPTYPE_UNDO*/;
|
||||
|
||||
/* props */
|
||||
RNA_def_float(ot->srna, "percent", 50.0f, 0.0f, 100.0f, "Percent", "percentage of mesh data to randomly select", 0.01f, 100.0f);
|
||||
RNA_def_float(ot->srna, "percent", 0.5f, 0.0f, 1.0f, "Percent", "Percentage of vertices to select randomly.", 0.0001f, 1.0f);
|
||||
}
|
||||
|
||||
void editmesh_select_by_material(EditMesh *em, int index)
|
||||
|
||||
@@ -1173,7 +1173,7 @@ static int delete_mesh_exec(bContext *C, wmOperator *op)
|
||||
void MESH_OT_delete(wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name= "Delete Mesh";
|
||||
ot->name= "Delete";
|
||||
ot->idname= "MESH_OT_delete";
|
||||
|
||||
/* api callbacks */
|
||||
@@ -6614,7 +6614,7 @@ void MESH_OT_subdivide_multi(wmOperatorType *ot)
|
||||
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
|
||||
/* props */
|
||||
RNA_def_int(ot->srna, "number_cuts", 4, 0, 100, "Number of Cuts", "", 0, INT_MAX);
|
||||
RNA_def_int(ot->srna, "number_cuts", 4, 1, 100, "Number of Cuts", "", 1, INT_MAX);
|
||||
}
|
||||
|
||||
static int subdivide_multi_fractal_exec(bContext *C, wmOperator *op)
|
||||
@@ -6644,7 +6644,7 @@ void MESH_OT_subdivide_multi_fractal(wmOperatorType *ot)
|
||||
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
|
||||
/* properties */
|
||||
RNA_def_int(ot->srna, "number_cuts", 4, 0, 100, "Number of Cuts", "", 0, INT_MAX);
|
||||
RNA_def_int(ot->srna, "number_cuts", 4, 1, 100, "Number of Cuts", "", 1, INT_MAX);
|
||||
RNA_def_float(ot->srna, "random_factor", 5.0, 0.0f, FLT_MAX, "Random Factor", "", 0.0f, 1000.0f);
|
||||
}
|
||||
|
||||
@@ -6675,7 +6675,7 @@ void MESH_OT_subdivide_smooth(wmOperatorType *ot)
|
||||
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
|
||||
/* props */
|
||||
RNA_def_float(ot->srna, "smoothness", 5.0f, 0.0f, 1000.0f, "Smoothness", "", 0.0f, FLT_MAX);
|
||||
RNA_def_float(ot->srna, "smoothness", 1.0f, 0.0f, 1000.0f, "Smoothness", "", 0.0f, FLT_MAX);
|
||||
}
|
||||
|
||||
static int subdivs_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
||||
@@ -6736,9 +6736,9 @@ void MESH_OT_subdivs(wmOperatorType *ot)
|
||||
RNA_def_enum(ot->srna, "type", type_items, 0, "Type", "");
|
||||
|
||||
/* this is temp, the ops are different, but they are called from subdivs, so all the possible props should be here as well*/
|
||||
RNA_def_int(ot->srna, "number_cuts", 4, 0, 100, "Number of Cuts", "", 0, INT_MAX);
|
||||
RNA_def_int(ot->srna, "number_cuts", 4, 1, 10, "Number of Cuts", "", 1, INT_MAX);
|
||||
RNA_def_float(ot->srna, "random_factor", 5.0, 0.0f, FLT_MAX, "Random Factor", "", 0.0f, 1000.0f);
|
||||
RNA_def_float(ot->srna, "smoothness", 5.0f, 0.0f, 1000.0f, "Smoothness", "", 0.0f, FLT_MAX);
|
||||
RNA_def_float(ot->srna, "smoothness", 1.0f, 0.0f, 1000.0f, "Smoothness", "", 0.0f, FLT_MAX);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -49,30 +49,6 @@ int edgetag_context_check(Scene *scene, EditEdge *eed);
|
||||
void edgetag_context_set(Scene *scene, EditEdge *eed, int val);
|
||||
int edgetag_shortest_path(Scene *scene, EditMesh *em, EditEdge *source, EditEdge *target);
|
||||
|
||||
/* ******************* meshtools.c */
|
||||
|
||||
|
||||
/* XXX move to uv editor? */
|
||||
enum {
|
||||
B_UVAUTO_REDRAW = 3301,
|
||||
B_UVAUTO_SPHERE,
|
||||
B_UVAUTO_CYLINDER,
|
||||
B_UVAUTO_CYLRADIUS,
|
||||
B_UVAUTO_WINDOW,
|
||||
B_UVAUTO_CUBE,
|
||||
B_UVAUTO_CUBESIZE,
|
||||
B_UVAUTO_RESET,
|
||||
B_UVAUTO_BOUNDS,
|
||||
B_UVAUTO_TOP,
|
||||
B_UVAUTO_FACE,
|
||||
B_UVAUTO_OBJECT,
|
||||
B_UVAUTO_ALIGNX,
|
||||
B_UVAUTO_ALIGNY,
|
||||
B_UVAUTO_UNWRAP,
|
||||
B_UVAUTO_DRAWFACES
|
||||
};
|
||||
|
||||
|
||||
/* ******************* editmesh.c */
|
||||
|
||||
extern void free_editvert(EditMesh *em, EditVert *eve);
|
||||
|
||||
@@ -287,7 +287,8 @@ void ED_keymap_mesh(wmWindowManager *wm)
|
||||
|
||||
WM_keymap_add_item(keymap, "MESH_OT_knife_cut", LEFTMOUSE, KM_PRESS, KM_ALT|KM_CTRL, 0);
|
||||
|
||||
|
||||
WM_keymap_add_item(keymap, "MESH_OT_bmesh_test", JKEY, KM_PRESS, 0, 0);
|
||||
/* UV's */
|
||||
WM_keymap_add_item(keymap, "UV_OT_mapping_menu", UKEY, KM_PRESS, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -422,10 +422,10 @@ void OBJECT_OT_mesh_add(wmOperatorType *ot)
|
||||
}
|
||||
|
||||
static EnumPropertyItem prop_curve_types[] = {
|
||||
{CU_BEZIER|CU_2D|CU_PRIM_CURVE, "BEZCURVE", "Bezier Curve", ""},
|
||||
{CU_BEZIER|CU_2D|CU_PRIM_CIRCLE, "BEZCIRCLE", "Bezier Circle", ""},
|
||||
{CU_NURBS|CU_2D|CU_PRIM_CURVE, "NURBSCUVE", "NURBS Curve", ""},
|
||||
{CU_NURBS|CU_2D|CU_PRIM_CIRCLE, "NURBSCIRCLE", "NURBS Circle", ""},
|
||||
{CU_BEZIER|CU_2D|CU_PRIM_CURVE, "BEZIER_CURVE", "Bezier Curve", ""},
|
||||
{CU_BEZIER|CU_2D|CU_PRIM_CIRCLE, "BEZIER_CIRCLE", "Bezier Circle", ""},
|
||||
{CU_NURBS|CU_2D|CU_PRIM_CURVE, "NURBS_CURVE", "NURBS Curve", ""},
|
||||
{CU_NURBS|CU_2D|CU_PRIM_CIRCLE, "NURBS_CIRCLE", "NURBS Circle", ""},
|
||||
{CU_NURBS|CU_2D|CU_PRIM_PATH, "PATH", "Path", ""},
|
||||
{0, NULL, NULL, NULL}
|
||||
};
|
||||
@@ -477,19 +477,60 @@ void OBJECT_OT_curve_add(wmOperatorType *ot)
|
||||
}
|
||||
|
||||
|
||||
static int object_add_armature_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Object *obedit= CTX_data_edit_object(C);
|
||||
int newob= 0;
|
||||
|
||||
if ((obedit==NULL) || (obedit->type != OB_ARMATURE)) {
|
||||
object_add_type(C, OB_ARMATURE);
|
||||
ED_object_enter_editmode(C, 0);
|
||||
newob = 1;
|
||||
}
|
||||
else DAG_object_flush_update(CTX_data_scene(C), obedit, OB_RECALC_DATA);
|
||||
|
||||
//nu= addNurbprim(C, RNA_enum_get(op->ptr, "type"), newob);
|
||||
//editnurb= curve_get_editcurve(CTX_data_edit_object(C));
|
||||
//BLI_addtail(editnurb, nu);
|
||||
|
||||
/* userdef */
|
||||
if (newob && (U.flag & USER_ADD_EDITMODE)==0) {
|
||||
ED_object_exit_editmode(C, EM_FREEDATA);
|
||||
}
|
||||
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
void OBJECT_OT_armature_add(wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name= "Add Armature";
|
||||
ot->idname= "OBJECT_OT_armature_add";
|
||||
|
||||
/* api callbacks */
|
||||
ot->exec= object_add_armature_exec;
|
||||
ot->poll= ED_operator_scene_editable;
|
||||
|
||||
/* flags */
|
||||
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
|
||||
static int object_add_primitive_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
||||
{
|
||||
uiMenuItem *head= uiPupMenuBegin("Add Object", 0);
|
||||
|
||||
uiMenuLevelEnumO(head, "OBJECT_OT_mesh_add", "type");
|
||||
uiMenuLevelEnumO(head, "OBJECT_OT_curve_add", "type");
|
||||
uiMenuItemEnumO(head, 0, "OBJECT_OT_object_add", "type", OB_SURF);
|
||||
uiMenuItemEnumO(head, 0, "OBJECT_OT_object_add", "type", OB_MBALL);
|
||||
uiMenuItemEnumO(head, 0, "OBJECT_OT_object_add", "type", OB_CAMERA);
|
||||
uiMenuItemEnumO(head, 0, "OBJECT_OT_object_add", "type", OB_LAMP);
|
||||
uiMenuItemEnumO(head, 0, "OBJECT_OT_object_add", "type", OB_EMPTY);
|
||||
uiMenuItemEnumO(head, 0, "OBJECT_OT_object_add", "type", OB_ARMATURE);
|
||||
uiMenuItemEnumO(head, 0, "OBJECT_OT_object_add", "type", OB_LATTICE);
|
||||
uiMenuItemEnumO(head, "", 0, "OBJECT_OT_object_add", "type", OB_SURF);
|
||||
uiMenuItemEnumO(head, "", 0, "OBJECT_OT_object_add", "type", OB_MBALL);
|
||||
uiMenuItemEnumO(head, "", 0, "OBJECT_OT_object_add", "type", OB_CAMERA);
|
||||
uiMenuItemEnumO(head, "", 0, "OBJECT_OT_object_add", "type", OB_LAMP);
|
||||
uiMenuItemEnumO(head, "", 0, "OBJECT_OT_object_add", "type", OB_EMPTY);
|
||||
uiMenuItemEnumO(head, "", 0, "OBJECT_OT_armature_add", "type", OB_ARMATURE);
|
||||
uiMenuItemEnumO(head, "", 0, "OBJECT_OT_object_add", "type", OB_LATTICE);
|
||||
|
||||
uiPupMenuEnd(C, head);
|
||||
|
||||
@@ -1665,7 +1706,6 @@ void OBJECT_OT_select_random(wmOperatorType *ot)
|
||||
|
||||
static int object_clear_location_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
int armature_clear= 0;
|
||||
|
||||
CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) {
|
||||
@@ -1708,7 +1748,6 @@ void OBJECT_OT_clear_location(wmOperatorType *ot)
|
||||
|
||||
static int object_clear_rotation_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
int armature_clear= 0;
|
||||
|
||||
CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) {
|
||||
@@ -1752,7 +1791,6 @@ void OBJECT_OT_clear_rotation(wmOperatorType *ot)
|
||||
|
||||
static int object_clear_scale_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
int armature_clear= 0;
|
||||
|
||||
CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) {
|
||||
@@ -1777,7 +1815,7 @@ static int object_clear_scale_exec(bContext *C, wmOperator *op)
|
||||
if(armature_clear==0) /* in this case flush was done */
|
||||
ED_anim_dag_flush_update(C);
|
||||
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, CTX_data_scene(C));
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -2408,20 +2446,20 @@ static int make_parent_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
||||
uiMenuItem *head= uiPupMenuBegin("Make Parent To", 0);
|
||||
|
||||
uiMenuContext(head, WM_OP_EXEC_DEFAULT);
|
||||
uiMenuItemEnumO(head, 0, "OBJECT_OT_make_parent", "type", PAR_OBJECT);
|
||||
uiMenuItemEnumO(head, "", 0, "OBJECT_OT_make_parent", "type", PAR_OBJECT);
|
||||
|
||||
/* ob becomes parent, make the associated menus */
|
||||
if(ob->type==OB_ARMATURE) {
|
||||
uiMenuItemEnumO(head, 0, "OBJECT_OT_make_parent", "type", PAR_ARMATURE);
|
||||
uiMenuItemEnumO(head, 0, "OBJECT_OT_make_parent", "type", PAR_BONE);
|
||||
uiMenuItemEnumO(head, "", 0, "OBJECT_OT_make_parent", "type", PAR_ARMATURE);
|
||||
uiMenuItemEnumO(head, "", 0, "OBJECT_OT_make_parent", "type", PAR_BONE);
|
||||
}
|
||||
else if(ob->type==OB_CURVE) {
|
||||
uiMenuItemEnumO(head, 0, "OBJECT_OT_make_parent", "type", PAR_CURVE);
|
||||
uiMenuItemEnumO(head, 0, "OBJECT_OT_make_parent", "type", PAR_FOLLOW);
|
||||
uiMenuItemEnumO(head, 0, "OBJECT_OT_make_parent", "type", PAR_PATH_CONST);
|
||||
uiMenuItemEnumO(head, "", 0, "OBJECT_OT_make_parent", "type", PAR_CURVE);
|
||||
uiMenuItemEnumO(head, "", 0, "OBJECT_OT_make_parent", "type", PAR_FOLLOW);
|
||||
uiMenuItemEnumO(head, "", 0, "OBJECT_OT_make_parent", "type", PAR_PATH_CONST);
|
||||
}
|
||||
else if(ob->type == OB_LATTICE) {
|
||||
uiMenuItemEnumO(head, 0, "OBJECT_OT_make_parent", "type", PAR_LATTICE);
|
||||
uiMenuItemEnumO(head, "", 0, "OBJECT_OT_make_parent", "type", PAR_LATTICE);
|
||||
}
|
||||
|
||||
uiPupMenuEnd(C, head);
|
||||
@@ -3041,7 +3079,7 @@ void ED_object_exit_editmode(bContext *C, int flag)
|
||||
|
||||
if(flag & EM_WAITCURSOR) waitcursor(0);
|
||||
|
||||
WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_MODE_OBJECT, ob);
|
||||
WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_MODE_OBJECT, scene);
|
||||
|
||||
}
|
||||
|
||||
@@ -3083,7 +3121,7 @@ void ED_object_enter_editmode(bContext *C, int flag)
|
||||
|
||||
make_editMesh(scene, ob);
|
||||
|
||||
WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_EDITMODE_MESH, ob);
|
||||
WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_EDITMODE_MESH, scene);
|
||||
}
|
||||
else if (ob->type==OB_ARMATURE){
|
||||
bArmature *arm= base->object->data;
|
||||
@@ -5953,7 +5991,6 @@ static int add_duplicate_exec(bContext *C, wmOperator *op)
|
||||
|
||||
static int add_duplicate_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
||||
{
|
||||
|
||||
add_duplicate_exec(C, op);
|
||||
|
||||
RNA_int_set(op->ptr, "mode", TFM_TRANSLATION);
|
||||
@@ -5982,7 +6019,6 @@ void OBJECT_OT_add_duplicate(wmOperatorType *ot)
|
||||
RNA_def_int(ot->srna, "mode", TFM_TRANSLATION, 0, INT_MAX, "Mode", "", 0, INT_MAX);
|
||||
}
|
||||
|
||||
|
||||
/* ********************** */
|
||||
|
||||
void image_aspect(Scene *scene, View3D *v3d)
|
||||
|
||||
@@ -86,8 +86,8 @@
|
||||
|
||||
#include "BIF_gl.h"
|
||||
|
||||
#include "ED_anim_api.h"
|
||||
#include "ED_fluidsim.h"
|
||||
#include "ED_screen.h"
|
||||
|
||||
/* XXX */
|
||||
/* from header info.c */
|
||||
@@ -262,7 +262,7 @@ static void fluidsimInitMeshChannel(bContext *C, float **setchannel, int size, O
|
||||
float *verts=NULL;
|
||||
int *tris=NULL;
|
||||
scene->r.cfra = frame;
|
||||
ED_update_for_newframe(C, 0);
|
||||
ED_update_for_newframe(C, 1);
|
||||
|
||||
initElbeemMesh(scene, obm, &numVerts, &verts, &numTris, &tris, 1, modifierIndex);
|
||||
//fprintf(stderr,"\nfluidsimInitMeshChannel frame%d verts%d/%d \n\n",frame,vertices,numVerts);
|
||||
@@ -596,7 +596,7 @@ void fluidsimBake(bContext *C, struct Object *ob)
|
||||
// CHECK more reasonable to number frames according to blender?
|
||||
// dump data for frame 0
|
||||
scene->r.cfra = startFrame;
|
||||
ED_update_for_newframe(C, 0);
|
||||
ED_update_for_newframe(C, 1);
|
||||
|
||||
// init common export vars for both file export and run
|
||||
for(i=0; i<256; i++) {
|
||||
@@ -985,7 +985,7 @@ void fluidsimBake(bContext *C, struct Object *ob)
|
||||
fsmesh.channelSizeVertices = allchannelSize;
|
||||
fluidsimInitMeshChannel(C, &fsmesh.channelVertices, allchannelSize, obit, numVerts, timeAtFrame, modifierIndex);
|
||||
scene->r.cfra = startFrame;
|
||||
ED_update_for_newframe(C, 0);
|
||||
ED_update_for_newframe(C, 1);
|
||||
// remove channels
|
||||
fsmesh.channelTranslation =
|
||||
fsmesh.channelRotation =
|
||||
@@ -1063,7 +1063,7 @@ void fluidsimBake(bContext *C, struct Object *ob)
|
||||
ScrArea *sa;
|
||||
scene->r.cfra = startFrame+globalBakeFrame;
|
||||
lastRedraw = globalBakeFrame;
|
||||
ED_update_for_newframe(C, 0);
|
||||
ED_update_for_newframe(C, 1);
|
||||
sa= G.curscreen->areabase.first;
|
||||
while(sa) {
|
||||
if(sa->spacetype == SPACE_VIEW3D) { scrarea_do_windraw(sa); }
|
||||
@@ -1096,7 +1096,7 @@ void fluidsimBake(bContext *C, struct Object *ob)
|
||||
}
|
||||
|
||||
scene->r.cfra = origFrame;
|
||||
ED_update_for_newframe(C, 0);
|
||||
ED_update_for_newframe(C, 1);
|
||||
|
||||
if(!simAborted) {
|
||||
char fsmessage[512];
|
||||
|
||||
@@ -375,7 +375,7 @@ static void region_rect_recursive(ARegion *ar, rcti *remainder, int quad)
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(ar->alignment==RGN_ALIGN_LEFT || ar->alignment==RGN_ALIGN_RIGHT) {
|
||||
else if( ELEM4(ar->alignment, RGN_ALIGN_LEFT, RGN_ALIGN_RIGHT, RGN_OVERLAP_LEFT, RGN_OVERLAP_RIGHT)) {
|
||||
|
||||
if( rct_fits(remainder, 'h', prefsizex) < 0 ) {
|
||||
ar->flag |= RGN_FLAG_TOO_SMALL;
|
||||
@@ -388,13 +388,15 @@ static void region_rect_recursive(ARegion *ar, rcti *remainder, int quad)
|
||||
|
||||
ar->winrct= *remainder;
|
||||
|
||||
if(ar->alignment==RGN_ALIGN_RIGHT) {
|
||||
if(ELEM(ar->alignment, RGN_ALIGN_RIGHT, RGN_OVERLAP_RIGHT)) {
|
||||
ar->winrct.xmin= ar->winrct.xmax - prefsizex + 1;
|
||||
remainder->xmax= ar->winrct.xmin - 1;
|
||||
if(ar->alignment==RGN_ALIGN_RIGHT)
|
||||
remainder->xmax= ar->winrct.xmin - 1;
|
||||
}
|
||||
else {
|
||||
ar->winrct.xmax= ar->winrct.xmin + prefsizex - 1;
|
||||
remainder->xmin= ar->winrct.xmax + 1;
|
||||
if(ar->alignment==RGN_ALIGN_LEFT)
|
||||
remainder->xmin= ar->winrct.xmax + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -771,7 +773,7 @@ static char *windowtype_pup(void)
|
||||
"|%l" // 33
|
||||
|
||||
"|Graph Editor %x2" //54
|
||||
"|DopeSheet Editor %x12" //73
|
||||
"|DopeSheet %x12" //73
|
||||
"|NLA Editor %x13" //94
|
||||
|
||||
"|%l" //97
|
||||
|
||||
@@ -148,7 +148,12 @@ int ED_operator_buttons_active(bContext *C)
|
||||
|
||||
int ED_operator_node_active(bContext *C)
|
||||
{
|
||||
return ed_spacetype_test(C, SPACE_NODE);
|
||||
if(ed_spacetype_test(C, SPACE_NODE)) {
|
||||
SpaceNode *snode= (SpaceNode *)CTX_wm_space_data(C);
|
||||
if(snode->edittree)
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ED_operator_ipo_active(bContext *C)
|
||||
@@ -190,8 +195,11 @@ int ED_operator_editarmature(bContext *C)
|
||||
int ED_operator_posemode(bContext *C)
|
||||
{
|
||||
Object *obact= CTX_data_active_object(C);
|
||||
if(obact && obact->type==OB_ARMATURE)
|
||||
Object *obedit= CTX_data_edit_object(C);
|
||||
|
||||
if ((obact != obedit) && (obact) && (obact->type==OB_ARMATURE))
|
||||
return (obact->flag & OB_POSEMODE)!=0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -224,14 +232,33 @@ int ED_operator_uvmap(bContext *C)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ED_operator_editsurfcurve(bContext *C)
|
||||
{
|
||||
Object *obedit= CTX_data_edit_object(C);
|
||||
if(obedit && ELEM(obedit->type, OB_CURVE, OB_SURF))
|
||||
return NULL != ((Curve *)obedit->data)->editnurb;
|
||||
return 0;
|
||||
|
||||
// XXX this test was in many tools, still needed?
|
||||
// if(v3d==0 || (v3d->lay & obedit->lay)==0 ) return 0;
|
||||
}
|
||||
|
||||
|
||||
int ED_operator_editcurve(bContext *C)
|
||||
{
|
||||
Object *obedit= CTX_data_edit_object(C);
|
||||
if(obedit && obedit->type==OB_CURVE)
|
||||
return NULL != ((Mesh *)obedit->data)->edit_mesh;
|
||||
return NULL != ((Curve *)obedit->data)->editnurb;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ED_operator_editsurf(bContext *C)
|
||||
{
|
||||
Object *obedit= CTX_data_edit_object(C);
|
||||
if(obedit && obedit->type==OB_SURF)
|
||||
return NULL != ((Curve *)obedit->data)->editnurb;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* *************************** action zone operator ************************** */
|
||||
|
||||
@@ -999,6 +1026,7 @@ static int frame_offset_exec(bContext *C, wmOperator *op)
|
||||
delta = RNA_int_get(op->ptr, "delta");
|
||||
|
||||
CTX_data_scene(C)->r.cfra += delta;
|
||||
|
||||
WM_event_add_notifier(C, NC_SCENE|ND_FRAME, CTX_data_scene(C));
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
@@ -1757,7 +1785,7 @@ static int screen_animation_play(bContext *C, wmOperator *op, wmEvent *event)
|
||||
scene->r.cfra= scene->r.sfra;
|
||||
}
|
||||
|
||||
WM_event_add_notifier(C, NC_SCENE|ND_FRAME, CTX_data_scene(C));
|
||||
WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
@@ -594,7 +594,7 @@ void draw_channel_names(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
|
||||
indent= 0;
|
||||
special= -1;
|
||||
|
||||
offset= (ale->id) ? 21 : 0;
|
||||
offset= (ac->datatype == ANIMCONT_DOPESHEET) ? 16 : 0;
|
||||
|
||||
/* only show expand if there are any channels */
|
||||
if (agrp->channels.first) {
|
||||
@@ -619,8 +619,8 @@ void draw_channel_names(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
|
||||
|
||||
indent = 0;
|
||||
|
||||
//group= (ale->grp) ? 1 : 0;
|
||||
//grp= ale->grp;
|
||||
group= (fcu->grp) ? 1 : 0;
|
||||
grp= fcu->grp;
|
||||
|
||||
switch (ale->ownertype) {
|
||||
case ANIMTYPE_NONE: /* no owner */
|
||||
@@ -650,9 +650,7 @@ void draw_channel_names(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
|
||||
|
||||
sel = SEL_FCU(fcu);
|
||||
|
||||
// for now, we just print the full path... this needs more work!
|
||||
getname_anim_fcurve(name, ale->id, fcu);
|
||||
//sprintf(name, "%s[%d]", fcu->rna_path, fcu->array_index);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -869,7 +867,7 @@ void draw_channel_names(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
|
||||
offset += 17;
|
||||
}
|
||||
else {
|
||||
/* for ipo/constraint channels */
|
||||
/* for normal channels */
|
||||
UI_icon_draw(x+offset, yminc, special);
|
||||
offset += 17;
|
||||
}
|
||||
|
||||
@@ -114,7 +114,6 @@ static void get_keyframe_extents (bAnimContext *ac, float *min, float *max)
|
||||
|
||||
/* get range and apply necessary scaling before */
|
||||
calc_fcurve_range(fcu, &tmin, &tmax);
|
||||
tmin= tmax= 0.0f; // xxx
|
||||
|
||||
if (nob) {
|
||||
tmin= get_action_frame_inv(nob, tmin);
|
||||
@@ -200,7 +199,7 @@ static int actkeys_viewall_exec(bContext *C, wmOperator *op)
|
||||
/* set the horizontal range, with an extra offset so that the extreme keys will be in view */
|
||||
get_keyframe_extents(&ac, &v2d->cur.xmin, &v2d->cur.xmax);
|
||||
|
||||
extra= 0.05f * (v2d->cur.xmax - v2d->cur.xmin);
|
||||
extra= 0.1f * (v2d->cur.xmax - v2d->cur.xmin);
|
||||
v2d->cur.xmin -= extra;
|
||||
v2d->cur.xmax += extra;
|
||||
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
|
||||
#include "BLI_blenlib.h"
|
||||
|
||||
#include "BKE_animsys.h"
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_screen.h"
|
||||
|
||||
@@ -1557,7 +1558,7 @@ static void saction_idpoin_handle(bContext *C, ID *id, int event)
|
||||
{
|
||||
SpaceAction *saction= (SpaceAction*)CTX_wm_space_data(C);
|
||||
Object *obact= CTX_data_active_object(C);
|
||||
AnimData *adt= BKE_id_add_animdata((ID *)obact);
|
||||
// AnimData *adt= BKE_id_add_animdata((ID *)obact);
|
||||
|
||||
switch (event) {
|
||||
case UI_ID_BROWSE:
|
||||
|
||||
@@ -74,8 +74,9 @@ static SpaceLink *action_new(const bContext *C)
|
||||
|
||||
saction= MEM_callocN(sizeof(SpaceAction), "initaction");
|
||||
saction->spacetype= SPACE_ACTION;
|
||||
saction->autosnap = SACTSNAP_FRAME;
|
||||
|
||||
saction->autosnap = SACTSNAP_FRAME;
|
||||
saction->mode= SACTCONT_DOPESHEET;
|
||||
|
||||
/* header */
|
||||
ar= MEM_callocN(sizeof(ARegion), "header for action");
|
||||
@@ -298,6 +299,7 @@ static void action_channel_area_listener(ARegion *ar, wmNotifier *wmn)
|
||||
switch(wmn->data) {
|
||||
case ND_BONE_ACTIVE:
|
||||
case ND_BONE_SELECT:
|
||||
case ND_KEYS:
|
||||
ED_region_tag_redraw(ar);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@ CPPFLAGS += -I../../blenloader
|
||||
CPPFLAGS += -I../../blenkernel
|
||||
CPPFLAGS += -I../../blenlib
|
||||
CPPFLAGS += -I../../makesdna
|
||||
CPPFLAGS += -I../../makesrna
|
||||
CPPFLAGS += -I../../imbuf
|
||||
CPPFLAGS += -I../../python
|
||||
CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include
|
||||
|
||||
@@ -5,6 +5,6 @@ sources = env.Glob('*.c')
|
||||
|
||||
incs = '../include ../../blenlib ../../blenkernel ../../makesdna ../../imbuf'
|
||||
incs += ' ../../windowmanager #/intern/guardedalloc #/extern/glew/include'
|
||||
incs += ' ../../render/extern/include'
|
||||
incs += ' ../../makesrna ../../render/extern/include'
|
||||
|
||||
env.BlenderLib ( 'bf_editors_space_buttons', sources, Split(incs), [], libtype=['core'], priority=[120] )
|
||||
|
||||
@@ -40,9 +40,14 @@
|
||||
|
||||
#include "RE_pipeline.h"
|
||||
|
||||
#include "RNA_access.h"
|
||||
#include "RNA_define.h"
|
||||
|
||||
#include "UI_interface.h"
|
||||
#include "UI_resources.h"
|
||||
|
||||
#include "WM_types.h"
|
||||
|
||||
#include "buttons_intern.h"
|
||||
|
||||
#define R_DISPLAYIMAGE 0
|
||||
@@ -212,7 +217,8 @@ static void render_panel_render(const bContext *C, ARegion *ar)
|
||||
if(uiNewPanel(C, ar, block, "Render", "Render", 320, 0, 318, 204)==0) return;
|
||||
|
||||
uiBlockBeginAlign(block);
|
||||
uiDefBut(block, BUT,0,"RENDER", 369, 164, 191,37, 0, 0, 0, 0, 0, "Render the current frame (F12)");
|
||||
uiDefButO(block, BUT, "SCREEN_OT_render", WM_OP_INVOKE_DEFAULT, "RENDER", 369, 164, 191,37, "Render the current frame (F12)");
|
||||
|
||||
#ifndef DISABLE_YAFRAY
|
||||
/* yafray: on request, render engine menu is back again, and moved to Render panel */
|
||||
uiDefButS(block, MENU, 0, "Rendering Engine %t|Blender Internal %x0|YafRay %x1",
|
||||
@@ -287,12 +293,14 @@ void render_panel_anim(const bContext *C, ARegion *ar)
|
||||
{
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
uiBlock *block;
|
||||
|
||||
uiBut *but;
|
||||
|
||||
block= uiBeginBlock(C, ar, "render_panel_anim", UI_EMBOSS, UI_HELV);
|
||||
if(uiNewPanel(C, ar, block, "Anim", "Render", 640, 0, 318, 204) == 0) return;
|
||||
|
||||
uiDefBut(block, BUT, 0, "ANIM", 692,142,192,47, 0, 0, 0, 0, 0, "Render the animation to disk from start to end frame, (Ctrl+F12)");
|
||||
|
||||
but= uiDefButO(block, BUT, "SCREEN_OT_render", WM_OP_INVOKE_DEFAULT, "ANIM", 692,142,192,47, "Render the animation to disk from start to end frame, (Ctrl+F12)");
|
||||
RNA_boolean_set(uiButGetOperatorPtrRNA(but), "anim", 1);
|
||||
|
||||
uiBlockSetCol(block, TH_BUT_SETTING1);
|
||||
uiBlockBeginAlign(block);
|
||||
uiDefButBitI(block, TOG, R_DOSEQ, 0, "Do Sequence",692,114,192,20, &scene->r.scemode, 0, 0, 0, 0, "Enables sequence output rendering (Default: 3D rendering)");
|
||||
|
||||
@@ -85,6 +85,7 @@ enum {
|
||||
B_REDR = 0,
|
||||
B_FS_LOAD,
|
||||
B_FS_CANCEL,
|
||||
B_FS_PARENT,
|
||||
} eFile_ButEvents;
|
||||
|
||||
static void do_file_buttons(bContext *C, void *arg, int event)
|
||||
@@ -96,6 +97,9 @@ static void do_file_buttons(bContext *C, void *arg, int event)
|
||||
case B_FS_CANCEL:
|
||||
file_cancel_exec(C, NULL); /* file_ops.c */
|
||||
break;
|
||||
case B_FS_PARENT:
|
||||
file_parent_exec(C, NULL); /* file_ops.c */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,7 +172,7 @@ void file_draw_buttons(const bContext *C, ARegion *ar)
|
||||
|
||||
MEM_freeN(menu);
|
||||
|
||||
uiDefBut(block, BUT, 0 /* XXX B_FS_PARDIR */, "P", xmin, filebuty2, parentbut_width, 21, 0, 0, 0, 0, 0, "Move to the parent directory (PKEY)");
|
||||
uiDefBut(block, BUT, B_FS_PARENT, "P", xmin, filebuty2, parentbut_width, 21, 0, 0, 0, 0, 0, "Move to the parent directory (PKEY)");
|
||||
uiEndBlock(C, block);
|
||||
uiDrawBlock(C, block);
|
||||
}
|
||||
@@ -502,27 +506,10 @@ void file_draw_list(const bContext *C, ARegion *ar)
|
||||
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
}
|
||||
else {
|
||||
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);
|
||||
}
|
||||
}
|
||||
if (S_ISDIR(file->type))
|
||||
UI_ThemeColor4(TH_TEXT_HI);
|
||||
else
|
||||
UI_ThemeColor4(TH_TEXT);
|
||||
}
|
||||
|
||||
sw = UI_GetStringWidth(G.font, file->size, 0);
|
||||
|
||||
@@ -57,9 +57,11 @@ void ED_FILE_OT_select_bookmark(struct wmOperatorType *ot);
|
||||
void ED_FILE_OT_loadimages(struct wmOperatorType *ot);
|
||||
void ED_FILE_OT_load(struct wmOperatorType *ot);
|
||||
void ED_FILE_OT_cancel(struct wmOperatorType *ot);
|
||||
void ED_FILE_OT_parent(struct wmOperatorType *ot);
|
||||
|
||||
int file_load_exec(bContext *C, struct wmOperator *unused);
|
||||
int file_cancel_exec(bContext *C, struct wmOperator *unused);
|
||||
int file_parent_exec(bContext *C, struct wmOperator *unused);
|
||||
int file_hilight_set(SpaceFile *sfile, ARegion *ar, int mx, int my);
|
||||
|
||||
#endif /* ED_FILE_INTERN_H */
|
||||
|
||||
@@ -514,5 +514,32 @@ void ED_FILE_OT_load(struct wmOperatorType *ot)
|
||||
ot->poll= ED_operator_file_active; /* <- important, handler is on window level */
|
||||
}
|
||||
|
||||
int file_parent_exec(bContext *C, wmOperator *unused)
|
||||
{
|
||||
SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C);
|
||||
|
||||
if(sfile->params) {
|
||||
BLI_parent_dir(sfile->params->dir);
|
||||
filelist_setdir(sfile->files, sfile->params->dir);
|
||||
filelist_free(sfile->files);
|
||||
sfile->params->active_file = -1;
|
||||
}
|
||||
ED_area_tag_redraw(CTX_wm_area(C));
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
|
||||
}
|
||||
|
||||
void ED_FILE_OT_parent(struct wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name= "Parent File";
|
||||
ot->idname= "ED_FILE_OT_parent";
|
||||
|
||||
/* api callbacks */
|
||||
ot->exec= file_parent_exec;
|
||||
ot->poll= ED_operator_file_active; /* <- important, handler is on window level */
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -259,6 +259,7 @@ void file_operatortypes(void)
|
||||
WM_operatortype_append(ED_FILE_OT_highlight);
|
||||
WM_operatortype_append(ED_FILE_OT_load);
|
||||
WM_operatortype_append(ED_FILE_OT_cancel);
|
||||
WM_operatortype_append(ED_FILE_OT_parent);
|
||||
}
|
||||
|
||||
/* NOTE: do not add .blend file reading on this level */
|
||||
@@ -269,6 +270,7 @@ void file_keymap(struct wmWindowManager *wm)
|
||||
WM_keymap_add_item(keymap, "ED_FILE_OT_select_all", AKEY, KM_PRESS, 0, 0);
|
||||
WM_keymap_add_item(keymap, "ED_FILE_OT_border_select", BKEY, KM_PRESS, 0, 0);
|
||||
WM_keymap_add_item(keymap, "ED_FILE_OT_highlight", MOUSEMOVE, KM_ANY, 0, 0);
|
||||
WM_keymap_add_item(keymap, "ED_FILE_OT_parent", PKEY, KM_PRESS, 0, 0);
|
||||
|
||||
WM_keymap_add_item(keymap, "ED_FILE_OT_loadimages", TIMER1, KM_ANY, KM_ANY, 0);
|
||||
|
||||
|
||||
@@ -154,9 +154,16 @@ static void draw_fcurve_handle_control (float x, float y, float xscale, float ys
|
||||
glTranslatef(x, y, 0.0f);
|
||||
glScalef(1.0f/xscale*hsize, 1.0f/yscale*hsize, 1.0f);
|
||||
|
||||
/* anti-aliased lines for more consistent appearance */
|
||||
glEnable(GL_LINE_SMOOTH);
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
/* draw! */
|
||||
glCallList(displist);
|
||||
|
||||
glDisable(GL_LINE_SMOOTH);
|
||||
glDisable(GL_BLEND);
|
||||
|
||||
/* restore view transform */
|
||||
glScalef(xscale/hsize, yscale/hsize, 1.0);
|
||||
glTranslatef(-x, -y, 0.0f);
|
||||
@@ -323,6 +330,74 @@ static void draw_fcurve_handles (SpaceIpo *sipo, ARegion *ar, FCurve *fcu)
|
||||
}
|
||||
}
|
||||
|
||||
/* Samples ---------------- */
|
||||
|
||||
/* helper func - draw sample-range marker for an F-Curve as a cross */
|
||||
static void draw_fcurve_sample_control (float x, float y, float xscale, float yscale, float hsize)
|
||||
{
|
||||
static GLuint displist=0;
|
||||
|
||||
/* initialise X shape */
|
||||
if (displist == 0) {
|
||||
displist= glGenLists(1);
|
||||
glNewList(displist, GL_COMPILE);
|
||||
|
||||
glBegin(GL_LINES);
|
||||
glVertex2f(-0.7f, -0.7f);
|
||||
glVertex2f(+0.7f, +0.7f);
|
||||
|
||||
glVertex2f(-0.7f, +0.7f);
|
||||
glVertex2f(+0.7f, -0.7f);
|
||||
glEnd(); // GL_LINES
|
||||
|
||||
glEndList();
|
||||
}
|
||||
|
||||
/* adjust view transform before starting */
|
||||
glTranslatef(x, y, 0.0f);
|
||||
glScalef(1.0f/xscale*hsize, 1.0f/yscale*hsize, 1.0f);
|
||||
|
||||
/* anti-aliased lines for more consistent appearance */
|
||||
// XXX needed here?
|
||||
glEnable(GL_LINE_SMOOTH);
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
/* draw! */
|
||||
glCallList(displist);
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
glDisable(GL_LINE_SMOOTH);
|
||||
|
||||
/* restore view transform */
|
||||
glScalef(xscale/hsize, yscale/hsize, 1.0);
|
||||
glTranslatef(-x, -y, 0.0f);
|
||||
}
|
||||
|
||||
/* helper func - draw keyframe vertices only for an F-Curve */
|
||||
static void draw_fcurve_samples (SpaceIpo *sipo, ARegion *ar, FCurve *fcu)
|
||||
{
|
||||
FPoint *first, *last;
|
||||
float hsize, xscale, yscale;
|
||||
|
||||
/* get view settings */
|
||||
hsize= UI_GetThemeValuef(TH_VERTEX_SIZE);
|
||||
UI_view2d_getscale(&ar->v2d, &xscale, &yscale);
|
||||
|
||||
/* set vertex color */
|
||||
if (fcu->flag & (FCURVE_ACTIVE|FCURVE_SELECTED)) UI_ThemeColor(TH_TEXT_HI);
|
||||
else UI_ThemeColor(TH_TEXT);
|
||||
|
||||
/* get verts */
|
||||
first= fcu->fpt;
|
||||
last= (first) ? (first + fcu->totvert) : (NULL);
|
||||
|
||||
/* draw */
|
||||
if (first && last) {
|
||||
draw_fcurve_sample_control(first->vec[0], first->vec[1], xscale, yscale, hsize);
|
||||
draw_fcurve_sample_control(last->vec[0], last->vec[1], xscale, yscale, hsize);
|
||||
}
|
||||
}
|
||||
|
||||
/* Curve ---------------- */
|
||||
|
||||
/* helper func - draw one repeat of an F-Curve */
|
||||
@@ -614,7 +689,6 @@ void graph_draw_curves (bAnimContext *ac, SpaceIpo *sipo, ARegion *ar)
|
||||
int items, i;
|
||||
|
||||
/* build list of curves to draw */
|
||||
// XXX enable ANIMFILTER_CURVEVISIBLE when we have a method to set them
|
||||
filter= (ANIMFILTER_VISIBLE|ANIMFILTER_CURVESONLY|ANIMFILTER_CURVEVISIBLE);
|
||||
items= ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
|
||||
|
||||
@@ -627,19 +701,46 @@ void graph_draw_curves (bAnimContext *ac, SpaceIpo *sipo, ARegion *ar)
|
||||
Object *nob= ANIM_nla_mapping_get(ac, ale);
|
||||
float fac=0.0f; // dummy var
|
||||
|
||||
/* map ipo-points for drawing if scaled F-Curve */
|
||||
/* map keyframes for drawing if scaled F-Curve */
|
||||
if (nob)
|
||||
ANIM_nla_mapping_apply_fcurve(nob, ale->key_data, 0, 0);
|
||||
|
||||
/* draw curve - we currently calculate colour on the fly, but that should probably be done in advance instead */
|
||||
col= ipo_rainbow(i, items);
|
||||
cpack(col);
|
||||
|
||||
draw_fcurve_repeat(fcu, &ar->v2d, 0, 0, &fac); // XXX this call still needs a lot more work
|
||||
|
||||
/* draw handles and vertices as appropriate */
|
||||
draw_fcurve_handles(sipo, ar, fcu);
|
||||
draw_fcurve_vertices(sipo, ar, fcu);
|
||||
if ( ((fcu->bezt) || (fcu->fpt)) && (fcu->totvert) ) {
|
||||
/* set color/drawing style for curve itself */
|
||||
if ( ((fcu->grp) && (fcu->grp->flag & AGRP_PROTECTED)) || (fcu->flag & FCURVE_PROTECTED) ) {
|
||||
/* protected curves (non editable) are drawn with dotted lines */
|
||||
setlinestyle(2);
|
||||
}
|
||||
if (fcu->flag & FCURVE_MUTED) {
|
||||
/* muted curves are drawn in a greyish hue */
|
||||
// XXX should we have some variations?
|
||||
UI_ThemeColorShade(TH_HEADER, 50);
|
||||
}
|
||||
else {
|
||||
// XXX color calculation here really needs to be done in advance instead
|
||||
col= ipo_rainbow(i, items);
|
||||
cpack(col);
|
||||
}
|
||||
|
||||
/* draw F-Curve */
|
||||
draw_fcurve_repeat(fcu, &ar->v2d, 0, 0, &fac); // XXX this call still needs a lot more work
|
||||
|
||||
/* restore settings */
|
||||
setlinestyle(0);
|
||||
|
||||
|
||||
/* draw handles and vertices as appropriate */
|
||||
if (fcu->bezt) {
|
||||
/* only draw handles/vertices on keyframes */
|
||||
draw_fcurve_handles(sipo, ar, fcu);
|
||||
draw_fcurve_vertices(sipo, ar, fcu);
|
||||
}
|
||||
else {
|
||||
/* samples: should we only draw two indicators at either end as indicators? */
|
||||
draw_fcurve_samples(sipo, ar, fcu);
|
||||
}
|
||||
}
|
||||
|
||||
/* undo mapping of keyframes for drawing if scaled F-Curve */
|
||||
if (nob)
|
||||
@@ -875,7 +976,7 @@ void graph_draw_channel_names(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar)
|
||||
indent= 0;
|
||||
special= -1;
|
||||
|
||||
offset= (ale->id) ? 21 : 0;
|
||||
offset= (ale->id) ? 16 : 0;
|
||||
|
||||
/* only show expand if there are any channels */
|
||||
if (agrp->channels.first) {
|
||||
@@ -900,11 +1001,9 @@ void graph_draw_channel_names(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar)
|
||||
|
||||
indent = 0;
|
||||
|
||||
//group= (ale->grp) ? 1 : 0;
|
||||
//grp= ale->grp;
|
||||
|
||||
// XXX include some UI element to allow toggling of visibility
|
||||
|
||||
group= (fcu->grp) ? 1 : 0;
|
||||
grp= fcu->grp;
|
||||
|
||||
switch (ale->ownertype) {
|
||||
case ANIMTYPE_NONE: /* no owner */
|
||||
case ANIMTYPE_FCURVE:
|
||||
@@ -921,6 +1020,13 @@ void graph_draw_channel_names(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar)
|
||||
break;
|
||||
}
|
||||
|
||||
/* for now, 'special' (i.e. in front of name) is used to show visibility status */
|
||||
// XXX these 'blank' icons are currently checkboxes
|
||||
if (fcu->flag & FCURVE_VISIBLE)
|
||||
special= ICON_BLANK012;
|
||||
else
|
||||
special= ICON_BLANK011;
|
||||
|
||||
if (fcu->flag & FCURVE_MUTED)
|
||||
mute = ICON_MUTE_IPO_ON;
|
||||
else
|
||||
@@ -933,9 +1039,7 @@ void graph_draw_channel_names(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar)
|
||||
|
||||
sel = SEL_FCU(fcu);
|
||||
|
||||
// for now, we just print the full path... this needs more work!
|
||||
getname_anim_fcurve(name, ale->id, fcu);
|
||||
//sprintf(name, "%s[%d]", fcu->rna_path, fcu->array_index);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1048,7 +1152,7 @@ void graph_draw_channel_names(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar)
|
||||
offset += 17;
|
||||
}
|
||||
else {
|
||||
/* for ipo/constraint channels */
|
||||
/* for normal channels */
|
||||
UI_icon_draw(x+offset, yminc, special);
|
||||
offset += 17;
|
||||
}
|
||||
|
||||
@@ -84,15 +84,13 @@
|
||||
|
||||
#include "graph_intern.h"
|
||||
|
||||
#if 0 // XXX code to be sanitied for new system
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* KEYFRAME-RANGE STUFF */
|
||||
|
||||
/* *************************** Calculate Range ************************** */
|
||||
|
||||
/* Get the min/max keyframes*/
|
||||
static void get_keyframe_extents (bAnimContext *ac, float *xmin, float *xmax, float *ymin, float *ymax)
|
||||
static void get_graph_keyframe_extents (bAnimContext *ac, float *xmin, float *xmax, float *ymin, float *ymax)
|
||||
{
|
||||
ListBase anim_data = {NULL, NULL};
|
||||
bAnimListElem *ale;
|
||||
@@ -105,24 +103,19 @@ static void get_keyframe_extents (bAnimContext *ac, float *xmin, float *xmax, fl
|
||||
/* set large values to try to override */
|
||||
if (xmin) *xmin= 999999999.0f;
|
||||
if (xmax) *xmax= -999999999.0f;
|
||||
//if (ymin) *ymin= 999999999.0f;
|
||||
//if (ymax) *ymax= -999999999.0f;
|
||||
|
||||
// XXX
|
||||
if (ymin) *ymin= -10;
|
||||
if (ymax) *ymax= 10;
|
||||
if (ymin) *ymin= 999999999.0f;
|
||||
if (ymax) *ymax= -999999999.0f;
|
||||
|
||||
/* check if any channels to set range with */
|
||||
if (anim_data.first) {
|
||||
/* go through channels, finding max extents */
|
||||
for (ale= anim_data.first; ale; ale= ale->next) {
|
||||
Object *nob= ANIM_nla_mapping_get(ac, ale);
|
||||
Object *nob= NULL; //ANIM_nla_mapping_get(ac, ale);
|
||||
FCurve *fcu= (FCurve *)ale->key_data;
|
||||
float tmin, tmax;
|
||||
|
||||
/* get range and apply necessary scaling before */
|
||||
calc_fcurve_range(fcu, &tmin, &tmax);
|
||||
tmin= tmax= 0.0f; // xxx
|
||||
calc_fcurve_bounds(fcu, &tmin, &tmax, ymin, ymax);
|
||||
|
||||
if (nob) {
|
||||
tmin= get_action_frame_inv(nob, tmin);
|
||||
@@ -147,6 +140,9 @@ static void get_keyframe_extents (bAnimContext *ac, float *xmin, float *xmax, fl
|
||||
if (xmin) *xmin= -5;
|
||||
if (xmax) *xmax= 100;
|
||||
}
|
||||
|
||||
if (ymin) *ymin= -5;
|
||||
if (ymax) *ymax= 5;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -167,7 +163,7 @@ static int graphkeys_previewrange_exec(bContext *C, wmOperator *op)
|
||||
scene= ac.scene;
|
||||
|
||||
/* set the range directly */
|
||||
get_keyframe_extents(&ac, &min, &max);
|
||||
get_graph_keyframe_extents(&ac, &min, &max, NULL, NULL);
|
||||
scene->r.psfra= (int)floor(min + 0.5f);
|
||||
scene->r.pefra= (int)floor(max + 0.5f);
|
||||
|
||||
@@ -206,13 +202,13 @@ static int graphkeys_viewall_exec(bContext *C, wmOperator *op)
|
||||
v2d= &ac.ar->v2d;
|
||||
|
||||
/* set the horizontal range, with an extra offset so that the extreme keys will be in view */
|
||||
get_keyframe_extents(&ac, &v2d->cur.xmin, &v2d->cur.xmax, &v2d->cur.ymin, &v2d->cur.ymax);
|
||||
get_graph_keyframe_extents(&ac, &v2d->cur.xmin, &v2d->cur.xmax, &v2d->cur.ymin, &v2d->cur.ymax);
|
||||
|
||||
extra= 0.05f * (v2d->cur.xmax - v2d->cur.xmin);
|
||||
extra= 0.1f * (v2d->cur.xmax - v2d->cur.xmin);
|
||||
v2d->cur.xmin -= extra;
|
||||
v2d->cur.xmax += extra;
|
||||
|
||||
extra= 0.05f * (v2d->cur.ymax - v2d->cur.ymin);
|
||||
extra= 0.1f * (v2d->cur.ymax - v2d->cur.ymin);
|
||||
v2d->cur.ymin -= extra;
|
||||
v2d->cur.ymax += extra;
|
||||
|
||||
@@ -239,17 +235,17 @@ void GRAPHEDIT_OT_view_all (wmOperatorType *ot)
|
||||
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* GENERAL STUFF */
|
||||
|
||||
#if 0 // XXX stuff to be sanitised for the new anim system
|
||||
|
||||
// TODO:
|
||||
// - insert key
|
||||
|
||||
/* ******************** Copy/Paste Keyframes Operator ************************* */
|
||||
/* - The copy/paste buffer currently stores a set of Action Channels, with temporary
|
||||
* IPO-blocks, and also temporary IpoCurves which only contain the selected keyframes.
|
||||
* - Only pastes between compatable data is possible (i.e. same achan->name, ipo-curve type, etc.)
|
||||
* Unless there is only one element in the buffer, names are also tested to check for compatability.
|
||||
/* - xxx...
|
||||
* - All pasted frames are offset by the same amount. This is calculated as the difference in the times of
|
||||
* the current frame and the 'first keyframe' (i.e. the earliest one in all channels).
|
||||
* - The earliest frame is calculated per copy operation.
|
||||
|
||||
@@ -97,8 +97,8 @@ void graphedit_operatortypes(void)
|
||||
{
|
||||
/* view */
|
||||
WM_operatortype_append(GRAPHEDIT_OT_view_togglehandles);
|
||||
//WM_operatortype_append(GRAPHEDIT_OT_set_previewrange);
|
||||
//WM_operatortype_append(GRAPHEDIT_OT_view_all);
|
||||
WM_operatortype_append(GRAPHEDIT_OT_set_previewrange);
|
||||
WM_operatortype_append(GRAPHEDIT_OT_view_all);
|
||||
|
||||
/* keyframes */
|
||||
/* selection */
|
||||
@@ -183,8 +183,8 @@ static void graphedit_keymap_keyframes (wmWindowManager *wm, ListBase *keymap)
|
||||
#endif // XXX code to be sanitied for new system
|
||||
|
||||
/* auto-set range */
|
||||
//WM_keymap_add_item(keymap, "GRAPHEDIT_OT_set_previewrange", PKEY, KM_PRESS, KM_CTRL|KM_ALT, 0);
|
||||
//WM_keymap_add_item(keymap, "GRAPHEDIT_OT_view_all", HOMEKEY, KM_PRESS, 0, 0);
|
||||
WM_keymap_add_item(keymap, "GRAPHEDIT_OT_set_previewrange", PKEY, KM_PRESS, KM_CTRL|KM_ALT, 0);
|
||||
WM_keymap_add_item(keymap, "GRAPHEDIT_OT_view_all", HOMEKEY, KM_PRESS, 0, 0);
|
||||
|
||||
/* transform system */
|
||||
transform_keymap_for_space(wm, keymap, SPACE_IPO);
|
||||
|
||||
@@ -121,7 +121,6 @@ static void deselect_graph_keys (bAnimContext *ac, short test, short sel)
|
||||
test_cb= ANIM_editkeyframes_ok(BEZT_OK_SELECTED);
|
||||
|
||||
/* See if we should be selecting or deselecting */
|
||||
// xxx check for curves too
|
||||
if (test) {
|
||||
for (ale= anim_data.first; ale; ale= ale->next) {
|
||||
if (ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, NULL, test_cb, NULL)) {
|
||||
@@ -135,9 +134,21 @@ static void deselect_graph_keys (bAnimContext *ac, short test, short sel)
|
||||
sel_cb= ANIM_editkeyframes_select(sel);
|
||||
|
||||
/* Now set the flags */
|
||||
// xxx check for curves too
|
||||
for (ale= anim_data.first; ale; ale= ale->next)
|
||||
for (ale= anim_data.first; ale; ale= ale->next) {
|
||||
FCurve *fcu= (FCurve *)ale->key_data;
|
||||
|
||||
/* Keyframes First */
|
||||
ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, NULL, sel_cb, NULL);
|
||||
|
||||
/* Curve Selection too */
|
||||
if (sel == SELECT_ADD)
|
||||
fcu->flag |= FCURVE_SELECTED;
|
||||
else if (sel == SELECT_SUBTRACT)
|
||||
fcu->flag &= ~FCURVE_SELECTED;
|
||||
else
|
||||
fcu->flag ^= FCURVE_SELECTED;
|
||||
fcu->flag &= ~FCURVE_ACTIVE;
|
||||
}
|
||||
|
||||
/* Cleanup */
|
||||
BLI_freelistN(&anim_data);
|
||||
@@ -664,12 +675,6 @@ static void mouse_graph_keys (bAnimContext *ac, int mval[], short selectmode)
|
||||
selectmode= SELECT_ADD;
|
||||
}
|
||||
|
||||
/* select or deselect? */
|
||||
if (selectmode == SELECT_ADD)
|
||||
fcu->flag |= (FCURVE_ACTIVE|FCURVE_SELECTED);
|
||||
else if (selectmode == SELECT_INVERT)
|
||||
fcu->flag ^= (FCURVE_ACTIVE|FCURVE_SELECTED);
|
||||
|
||||
/* if we're selecting points too */
|
||||
if ( ((fcu->flag & FCURVE_PROTECTED)==0) /*|| (curvesonly == 0) */) {
|
||||
/* only if there's keyframe */
|
||||
@@ -712,6 +717,18 @@ static void mouse_graph_keys (bAnimContext *ac, int mval[], short selectmode)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* select or deselect curve? */
|
||||
if (selectmode == SELECT_INVERT) {
|
||||
fcu->flag ^= FCURVE_SELECTED;
|
||||
|
||||
if (fcu->flag & FCURVE_SELECTED)
|
||||
fcu->flag |= FCURVE_ACTIVE;
|
||||
else
|
||||
fcu->flag &= ~FCURVE_ACTIVE;
|
||||
}
|
||||
else if (selectmode == SELECT_ADD)
|
||||
fcu->flag |= (FCURVE_ACTIVE|FCURVE_SELECTED);
|
||||
}
|
||||
|
||||
/* Option 2) Selects all the keyframes on either side of the current frame (depends on which side the mouse is on) */
|
||||
|
||||
@@ -68,9 +68,12 @@ static SpaceLink *graph_new(const bContext *C)
|
||||
ARegion *ar;
|
||||
SpaceIpo *sipo;
|
||||
|
||||
/* Graph Editor - general stuff */
|
||||
sipo= MEM_callocN(sizeof(SpaceIpo), "init graphedit");
|
||||
sipo->spacetype= SPACE_IPO;
|
||||
|
||||
sipo->autosnap= SACTSNAP_FRAME;
|
||||
|
||||
/* allocate DopeSheet data for Graph Editor */
|
||||
sipo->ads= MEM_callocN(sizeof(bDopeSheet), "GraphEdit DopeSheet");
|
||||
|
||||
@@ -97,7 +100,7 @@ static SpaceLink *graph_new(const bContext *C)
|
||||
ar->regiontype= RGN_TYPE_WINDOW;
|
||||
|
||||
ar->v2d.tot.xmin= 0.0f;
|
||||
ar->v2d.tot.ymin= -10.0f;
|
||||
ar->v2d.tot.ymin= (float)scene->r.sfra - 10.0f;
|
||||
ar->v2d.tot.xmax= (float)scene->r.efra;
|
||||
ar->v2d.tot.ymax= 10.0f;
|
||||
|
||||
@@ -404,7 +407,7 @@ void ED_spacetype_ipo(void)
|
||||
/* regions: channels */
|
||||
art= MEM_callocN(sizeof(ARegionType), "spacetype graphedit region");
|
||||
art->regionid = RGN_TYPE_CHANNELS;
|
||||
art->minsizex= 200;
|
||||
art->minsizex= 214; /* 200 is the 'standard', but due to scrollers, we want a bit more to fit the lock icons in */
|
||||
art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D|ED_KEYMAP_FRAMES;
|
||||
art->listener= graph_region_listener;
|
||||
art->init= graph_channel_area_init;
|
||||
|
||||
@@ -52,6 +52,7 @@
|
||||
#include "BIF_gl.h"
|
||||
#include "BIF_glutil.h"
|
||||
|
||||
#include "ED_image.h"
|
||||
#include "ED_screen.h"
|
||||
|
||||
#include "UI_resources.h"
|
||||
@@ -124,7 +125,7 @@ static void image_verify_buffer_float(SpaceImage *sima, ImBuf *ibuf)
|
||||
}
|
||||
}
|
||||
|
||||
static void sima_draw_render_info(SpaceImage *sima, ARegion *ar)
|
||||
static void draw_render_info(SpaceImage *sima, ARegion *ar)
|
||||
{
|
||||
rcti rect;
|
||||
float colf[3];
|
||||
@@ -135,32 +136,35 @@ static void sima_draw_render_info(SpaceImage *sima, ARegion *ar)
|
||||
return;
|
||||
|
||||
rect= ar->winrct;
|
||||
rect.ymin= rect.ymax - HEADER_HEIGHT;
|
||||
|
||||
glaDefine2DArea(&rect);
|
||||
rect.xmin= 0;
|
||||
rect.ymin= ar->winrct.ymax - ar->winrct.ymin - HEADER_HEIGHT;
|
||||
rect.xmax= ar->winrct.xmax - ar->winrct.xmin;
|
||||
rect.ymax= ar->winrct.ymax - ar->winrct.ymin;
|
||||
|
||||
/* clear header rect */
|
||||
UI_GetThemeColor3fv(TH_BACK, colf);
|
||||
glClearColor(colf[0]+0.1f, colf[1]+0.1f, colf[2]+0.1f, 1.0);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
glColor3f(colf[0]+0.1f, colf[1]+0.1f, colf[2]+0.1f);
|
||||
glRecti(rect.xmin, rect.ymin, rect.xmax, rect.ymax);
|
||||
|
||||
UI_ThemeColor(TH_TEXT_HI);
|
||||
glRasterPos2i(12, 5);
|
||||
UI_RasterPos(12, 5);
|
||||
glRasterPos2i(12, rect.ymin + 5);
|
||||
UI_RasterPos(12, rect.ymin + 5);
|
||||
|
||||
if(showspare) {
|
||||
UI_DrawString(G.fonts, "(Previous)", 0);
|
||||
glRasterPos2i(72, 5);
|
||||
UI_RasterPos(72, 5);
|
||||
glRasterPos2i(72, rect.ymin + 5);
|
||||
UI_RasterPos(72, rect.ymin + 5);
|
||||
}
|
||||
|
||||
UI_DrawString(G.fonts, str, 0);
|
||||
}
|
||||
|
||||
/*static void sima_draw_image_info(ARegion *ar, int channels, int x, int y, char *cp, float *fp, int *zp, float *zpf)
|
||||
void draw_image_info(ARegion *ar, int channels, int x, int y, char *cp, float *fp, int *zp, float *zpf)
|
||||
{
|
||||
char str[256];
|
||||
int ofs;
|
||||
|
||||
ED_region_pixelspace(ar);
|
||||
|
||||
ofs= sprintf(str, "X: %d Y: %d ", x, y);
|
||||
if(cp)
|
||||
@@ -192,7 +196,7 @@ static void sima_draw_render_info(SpaceImage *sima, ARegion *ar)
|
||||
UI_RasterPos(10, 10);
|
||||
|
||||
UI_DrawString(G.fonts, str, 0);
|
||||
}*/
|
||||
}
|
||||
|
||||
/* image drawing */
|
||||
|
||||
@@ -492,36 +496,6 @@ static void draw_image_buffer_repeated(SpaceImage *sima, ARegion *ar, Scene *sce
|
||||
|
||||
/* draw uv edit */
|
||||
|
||||
/* XXX this becomes draw extra? */
|
||||
#if 0
|
||||
glPixelZoom(zoomx, zoomy);
|
||||
|
||||
if(sima->flag & SI_EDITTILE) {
|
||||
/* create char buffer from float if needed */
|
||||
image_verify_buffer_float(sima, ibuf);
|
||||
|
||||
glaDrawPixelsSafe(x1, y1, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect);
|
||||
|
||||
glPixelZoom(1.0, 1.0);
|
||||
|
||||
dx= ibuf->x/sima->image->xrep;
|
||||
dy= ibuf->y/sima->image->yrep;
|
||||
sy= (sima->curtile / sima->image->xrep);
|
||||
sx= sima->curtile - sy*sima->image->xrep;
|
||||
|
||||
sx*= dx;
|
||||
sy*= dy;
|
||||
|
||||
calc_image_view(sima, 'p'); /* pixel */
|
||||
myortho2(G.v2d->cur.xmin, G.v2d->cur.xmax, G.v2d->cur.ymin, G.v2d->cur.ymax);
|
||||
|
||||
cpack(0x0);
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); glRects(sx, sy, sx+dx-1, sy+dy-1); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||
cpack(0xFFFFFF);
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); glRects(sx+1, sy+1, sx+dx, sy+dy); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* draw grease pencil */
|
||||
|
||||
static void draw_image_grease_pencil(SpaceImage *sima, ImBuf *ibuf)
|
||||
@@ -652,7 +626,7 @@ void draw_image_main(SpaceImage *sima, ARegion *ar, Scene *scene)
|
||||
what_image(sima);
|
||||
|
||||
if(sima->image) {
|
||||
image_pixel_aspect(sima->image, &xuser_asp, &yuser_asp);
|
||||
ED_image_aspect(sima->image, &xuser_asp, &yuser_asp);
|
||||
|
||||
/* UGLY hack? until now iusers worked fine... but for flipbook viewer we need this */
|
||||
if(sima->image->type==IMA_TYPE_COMPOSITE) {
|
||||
@@ -663,16 +637,16 @@ void draw_image_main(SpaceImage *sima, ARegion *ar, Scene *scene)
|
||||
}
|
||||
}
|
||||
/* and we check for spare */
|
||||
ibuf= get_space_image_buffer(sima);
|
||||
ibuf= ED_space_image_buffer(sima);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* put scene context variable in iuser */
|
||||
sima->iuser.scene= scene;
|
||||
/* retrieve the image and information about it */
|
||||
ima= get_space_image(sima);
|
||||
ibuf= get_space_image_buffer(sima);
|
||||
get_space_image_zoom(sima, ar, &zoomx, &zoomy);
|
||||
ima= ED_space_image(sima);
|
||||
ibuf= ED_space_image_buffer(sima);
|
||||
ED_space_image_zoom(sima, ar, &zoomx, &zoomy);
|
||||
|
||||
show_viewer= (ima && ima->source == IMA_SRC_VIEWER);
|
||||
show_render= (show_viewer && ima->type == IMA_TYPE_R_RESULT);
|
||||
@@ -695,7 +669,7 @@ void draw_image_main(SpaceImage *sima, ARegion *ar, Scene *scene)
|
||||
|
||||
/* render info */
|
||||
if(ibuf && show_render)
|
||||
sima_draw_render_info(sima, ar);
|
||||
draw_render_info(sima, ar);
|
||||
|
||||
/* XXX integrate this code */
|
||||
#if 0
|
||||
|
||||
@@ -51,6 +51,7 @@
|
||||
#include "IMB_imbuf.h"
|
||||
#include "IMB_imbuf_types.h"
|
||||
|
||||
#include "ED_image.h"
|
||||
#include "ED_mesh.h"
|
||||
#include "ED_screen.h"
|
||||
#include "ED_types.h"
|
||||
@@ -61,6 +62,7 @@
|
||||
|
||||
#include "BIF_gl.h"
|
||||
#include "BIF_glutil.h"
|
||||
#include "BIF_transform.h"
|
||||
|
||||
#include "UI_interface.h"
|
||||
#include "UI_resources.h"
|
||||
@@ -132,9 +134,9 @@ static void image_viewmenu(bContext *C, uiMenuItem *head, void *arg_unused)
|
||||
RNA_pointer_create(&sc->id, &RNA_SpaceImageEditor, sima, &spaceptr);
|
||||
RNA_pointer_create(&sc->id, &RNA_SpaceUVEditor, sima, &uvptr);
|
||||
|
||||
show_render= get_space_image_show_render(sima);
|
||||
show_paint= get_space_image_show_paint(sima);
|
||||
show_uvedit= get_space_image_show_uvedit(sima, CTX_data_edit_object(C));
|
||||
show_render= ED_space_image_show_render(sima);
|
||||
show_paint= ED_space_image_show_paint(sima);
|
||||
show_uvedit= ED_space_image_show_uvedit(sima, CTX_data_edit_object(C));
|
||||
|
||||
/* create menu */
|
||||
uiMenuItemO(head, ICON_MENU_PANEL, "IMAGE_OT_toggle_view_properties_panel"); // View Properties...
|
||||
@@ -184,60 +186,6 @@ static void do_image_imagemenu(void *arg, int event)
|
||||
#ifndef DISABLE_PYTHON
|
||||
if (event >= 20) BPY_menu_do_python(PYMENU_IMAGE, event - 20);
|
||||
#endif
|
||||
switch(event)
|
||||
{
|
||||
case 0:
|
||||
open_image_sima((G.qual==LR_CTRLKEY));
|
||||
break;
|
||||
case 1:
|
||||
replace_image_sima((G.qual==LR_CTRLKEY));
|
||||
break;
|
||||
case 2:
|
||||
pack_image_sima();
|
||||
break;
|
||||
case 4: /* Texture Painting */
|
||||
brush_check_exists(&G.scene->toolsettings->imapaint.brush);
|
||||
if(sima->flag & SI_DRAWTOOL) sima->flag &= ~SI_DRAWTOOL;
|
||||
else sima->flag |= SI_DRAWTOOL;
|
||||
allqueue(REDRAWBUTSSHADING, 0);
|
||||
break;
|
||||
case 5:
|
||||
save_as_image_sima();
|
||||
break;
|
||||
case 6:
|
||||
reload_image_sima();
|
||||
break;
|
||||
case 7:
|
||||
new_image_sima();
|
||||
break;
|
||||
case 8:
|
||||
save_image_sima();
|
||||
break;
|
||||
case 9:
|
||||
save_image_sequence_sima();
|
||||
break;
|
||||
case 10:
|
||||
BKE_image_memorypack(sima->image);
|
||||
allqueue(REDRAWIMAGE, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* move to realtime properties panel */
|
||||
#if 0
|
||||
static void do_image_image_rtmappingmenu(void *arg, int event)
|
||||
{
|
||||
switch(event) {
|
||||
case 0: /* UV Co-ordinates */
|
||||
sima->image->flag &= ~IMA_REFLECT;
|
||||
break;
|
||||
case 1: /* Reflection */
|
||||
sima->image->flag |= IMA_REFLECT;
|
||||
break;
|
||||
}
|
||||
|
||||
allqueue(REDRAWVIEW3D, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -245,30 +193,32 @@ static void image_imagemenu(bContext *C, uiMenuItem *head, void *arg_unused)
|
||||
{
|
||||
bScreen *sc= CTX_wm_screen(C);
|
||||
SpaceImage *sima= (SpaceImage*)CTX_wm_space_data(C);
|
||||
PointerRNA spaceptr;
|
||||
PointerRNA spaceptr, imaptr;
|
||||
Image *ima;
|
||||
ImBuf *ibuf;
|
||||
int show_render;
|
||||
|
||||
/* retrieve state */
|
||||
ima= get_space_image(sima);
|
||||
ibuf= get_space_image_buffer(sima);
|
||||
ima= ED_space_image(sima);
|
||||
ibuf= ED_space_image_buffer(sima);
|
||||
|
||||
show_render= get_space_image_show_render(sima);
|
||||
show_render= ED_space_image_show_render(sima);
|
||||
|
||||
RNA_pointer_create(&sc->id, &RNA_SpaceImageEditor, sima, &spaceptr);
|
||||
|
||||
/* create menu */
|
||||
uiMenuItemO(head, 0, "IMAGE_OT_new"); // New...|Alt N
|
||||
uiMenuItemO(head, 0, "IMAGE_OT_open"); // Open...|Alt O
|
||||
uiMenuItemO(head, 0, "IMAGE_OT_new"); // New...
|
||||
uiMenuItemO(head, 0, "IMAGE_OT_open"); // Open...
|
||||
|
||||
if(ima) {
|
||||
uiMenuItemO(head, 0, "IMAGE_OT_replace"); // Replace...
|
||||
uiMenuItemO(head, 0, "IMAGE_OT_reload"); // Reload...|Alt R
|
||||
uiMenuItemO(head, 0, "IMAGE_OT_save"); // Save|Alt S
|
||||
if(!show_render) {
|
||||
uiMenuItemO(head, 0, "IMAGE_OT_replace"); // Replace...
|
||||
uiMenuItemO(head, 0, "IMAGE_OT_reload"); // Reload...
|
||||
}
|
||||
uiMenuItemO(head, 0, "IMAGE_OT_save"); // Save
|
||||
uiMenuItemO(head, 0, "IMAGE_OT_save_as"); // Save As...
|
||||
if(ima->source == IMA_SRC_SEQUENCE)
|
||||
uiMenuItemO(head, 0, "IMAGE_OT_save_changed"); // Save Changed Images
|
||||
uiMenuItemO(head, 0, "IMAGE_OT_save_sequence"); // Save Changed Sequence Images
|
||||
|
||||
if(!show_render) {
|
||||
uiMenuSeparator(head);
|
||||
@@ -279,12 +229,15 @@ static void image_imagemenu(bContext *C, uiMenuItem *head, void *arg_unused)
|
||||
/* only for dirty && specific image types : XXX poll? */
|
||||
if(ibuf && (ibuf->userflags & IB_BITMAPDIRTY))
|
||||
if(ELEM(ima->source, IMA_SRC_FILE, IMA_SRC_GENERATED) && ima->type != IMA_TYPE_MULTILAYER)
|
||||
uiMenuItemO(head, 0, "IMAGE_OT_pack_as_png"); // Pack Image As PNG
|
||||
uiMenuItemBooleanO(head, "Pack As PNG", 0, "IMAGE_OT_pack", "as_png", 1); // Pack Image As PNG
|
||||
|
||||
uiMenuSeparator(head);
|
||||
|
||||
/* XXX check state better */
|
||||
uiMenuItemBooleanR(head, &spaceptr, "image_painting");
|
||||
|
||||
/* move to realtime properties panel */
|
||||
RNA_id_pointer_create(&ima->id, &imaptr);
|
||||
uiMenuLevelEnumR(head, &imaptr, "mapping");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -306,62 +259,24 @@ static void image_imagemenu(bContext *C, uiMenuItem *head, void *arg_unused)
|
||||
#endif
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void do_image_uvs_showhidemenu(void *arg, int event)
|
||||
{
|
||||
switch(event) {
|
||||
case 4: /* show hidden faces */
|
||||
reveal_tface_uv();
|
||||
break;
|
||||
case 5: /* hide selected faces */
|
||||
hide_tface_uv(0);
|
||||
break;
|
||||
case 6: /* hide deselected faces */
|
||||
hide_tface_uv(1);
|
||||
break;
|
||||
}
|
||||
allqueue(REDRAWVIEW3D, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void image_uvs_showhidemenu(bContext *C, uiMenuItem *head, void *arg_unused)
|
||||
{
|
||||
uiMenuItemO(head, 0, "UV_OT_show_hidden_faces"); // Show Hidden Faces|Alt H
|
||||
uiMenuItemO(head, 0, "UV_OT_hide_selected_faces"); // Hide Selected Faces|H
|
||||
uiMenuItemO(head, 0, "UV_OT_hide_deselected_faces"); // Hide Deselected Faces|Shift H
|
||||
uiMenuItemO(head, 0, "UV_OT_show_hidden");
|
||||
uiMenuItemO(head, 0, "UV_OT_hide_selected");
|
||||
uiMenuItemO(head, 0, "UV_OT_hide_deselected");
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void do_image_uvs_transformmenu(void *arg, int event)
|
||||
{
|
||||
switch(event) {
|
||||
case 0: /* Grab */
|
||||
initTransform(TFM_TRANSLATION, CTX_NONE);
|
||||
Transform();
|
||||
break;
|
||||
case 1: /* Rotate */
|
||||
initTransform(TFM_ROTATION, CTX_NONE);
|
||||
Transform();
|
||||
break;
|
||||
case 2: /* Scale */
|
||||
initTransform(TFM_RESIZE, CTX_NONE);
|
||||
Transform();
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static void image_uvs_transformmenu(bContext *C, uiMenuItem *head, void *arg_unused)
|
||||
{
|
||||
uiMenuItemO(head, 0, "UV_OT_grab"); // Grab/Move|G
|
||||
uiMenuItemO(head, 0, "UV_OT_rotate"); // Rotate|R
|
||||
uiMenuItemO(head, 0, "UV_OT_scale"); // Scale|S
|
||||
uiMenuItemEnumO(head, "", 0, "TFM_OT_transform", "mode", TFM_TRANSLATION);
|
||||
uiMenuItemEnumO(head, "", 0, "TFM_OT_transform", "mode", TFM_ROTATION);
|
||||
uiMenuItemEnumO(head, "", 0, "TFM_OT_transform", "mode", TFM_RESIZE);
|
||||
}
|
||||
|
||||
static void image_uvs_mirrormenu(bContext *C, uiMenuItem *head, void *arg_unused)
|
||||
{
|
||||
uiMenuItemEnumO(head, 0, "UV_OT_mirror", "axis", 'x'); // "X Axis", M, 1
|
||||
uiMenuItemEnumO(head, 0, "UV_OT_mirror", "axis", 'y'); // "Y Axis", M, 2
|
||||
uiMenuItemEnumO(head, "", 0, "UV_OT_mirror", "axis", 'x'); // "X Axis", M, 1
|
||||
uiMenuItemEnumO(head, "", 0, "UV_OT_mirror", "axis", 'y'); // "Y Axis", M, 2
|
||||
}
|
||||
|
||||
static void image_uvs_weldalignmenu(bContext *C, uiMenuItem *head, void *arg_unused)
|
||||
@@ -405,26 +320,6 @@ static void image_uvs_scriptsmenu (void *args_unused)
|
||||
#endif /* DISABLE_PYTHON */
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
static void do_uvsmenu(bContext *C, void *arg, int event)
|
||||
{
|
||||
switch(event) {
|
||||
case 10:
|
||||
unwrap_lscm(0);
|
||||
break;
|
||||
case 12:
|
||||
minimize_stretch_tface_uv();
|
||||
break;
|
||||
case 13:
|
||||
pack_charts_tface_uv();
|
||||
break;
|
||||
case 14:
|
||||
average_charts_tface_uv();
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static void image_uvsmenu(bContext *C, uiMenuItem *head, void *arg_unused)
|
||||
{
|
||||
bScreen *sc= CTX_wm_screen(C);
|
||||
@@ -435,8 +330,8 @@ static void image_uvsmenu(bContext *C, uiMenuItem *head, void *arg_unused)
|
||||
ImBuf *ibuf;
|
||||
|
||||
/* retrieve state */
|
||||
ima= get_space_image(sima);
|
||||
ibuf= get_space_image_buffer(sima);
|
||||
ima= ED_space_image(sima);
|
||||
ibuf= ED_space_image_buffer(sima);
|
||||
|
||||
RNA_pointer_create(&sc->id, &RNA_SpaceUVEditor, sima, &uvptr);
|
||||
RNA_id_pointer_create(&scene->id, &sceneptr);
|
||||
@@ -526,13 +421,6 @@ static void do_image_buttons(bContext *C, void *arg, int event)
|
||||
}
|
||||
|
||||
switch(event) {
|
||||
case B_SIMAPIN:
|
||||
allqueue (REDRAWIMAGE, 0);
|
||||
break;
|
||||
case B_SIMAGEHOME:
|
||||
image_home();
|
||||
break;
|
||||
|
||||
case B_SIMABROWSE:
|
||||
if(sima->imanr== -2) {
|
||||
if(G.qual & LR_CTRLKEY) {
|
||||
@@ -577,14 +465,6 @@ static void do_image_buttons(bContext *C, void *arg, int event)
|
||||
allqueue(REDRAWVIEW3D, 0);
|
||||
allqueue(REDRAWIMAGE, 0);
|
||||
break;
|
||||
case B_SIMAGEPAINTTOOL:
|
||||
if(sima->flag & SI_DRAWTOOL)
|
||||
/* add new brush if none exists */
|
||||
brush_check_exists(&G.scene->toolsettings->imapaint.brush);
|
||||
allqueue(REDRAWBUTSSHADING, 0);
|
||||
allqueue(REDRAWIMAGE, 0);
|
||||
allqueue(REDRAWVIEW3D, 0);
|
||||
break;
|
||||
|
||||
case B_SIMAPACKIMA:
|
||||
pack_image_sima();
|
||||
@@ -806,26 +686,19 @@ static void sima_idpoin_handle(bContext *C, ID *id, int event)
|
||||
switch(event) {
|
||||
case UI_ID_BROWSE:
|
||||
case UI_ID_DELETE:
|
||||
set_space_image(sima, scene, obedit, sima->image);
|
||||
|
||||
if(sima->image && sima->image->id.us==0)
|
||||
sima->image->id.us= 1;
|
||||
|
||||
ED_area_tag_redraw(CTX_wm_area(C));
|
||||
ED_space_image_set(C, sima, scene, obedit, sima->image);
|
||||
ED_undo_push(C, "Assign Image UV");
|
||||
break;
|
||||
case UI_ID_RENAME:
|
||||
break;
|
||||
case UI_ID_ADD_NEW:
|
||||
/* XXX not implemented */
|
||||
WM_operator_name_call(C, "IMAGE_OT_new", WM_OP_INVOKE_REGION_WIN, NULL);
|
||||
break;
|
||||
case UI_ID_OPEN:
|
||||
/* XXX not implemented */
|
||||
break;
|
||||
case UI_ID_ALONE:
|
||||
/* XXX not implemented */
|
||||
WM_operator_name_call(C, "IMAGE_OT_open", WM_OP_INVOKE_REGION_WIN, NULL);
|
||||
break;
|
||||
case UI_ID_PIN:
|
||||
ED_area_tag_refresh(CTX_wm_area(C));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -841,15 +714,15 @@ void image_header_buttons(const bContext *C, ARegion *ar)
|
||||
uiBlock *block;
|
||||
uiBut *but;
|
||||
PointerRNA spaceptr, uvptr, sceneptr;
|
||||
int xco, yco= 3, show_uvedit, show_render, show_paint;
|
||||
int xco, yco= 3, show_uvedit, show_render, show_paint, pinflag;
|
||||
|
||||
/* retrieve state */
|
||||
ima= get_space_image(sima);
|
||||
ibuf= get_space_image_buffer(sima);
|
||||
ima= ED_space_image(sima);
|
||||
ibuf= ED_space_image_buffer(sima);
|
||||
|
||||
show_render= get_space_image_show_render(sima);
|
||||
show_paint= get_space_image_show_paint(sima);
|
||||
show_uvedit= get_space_image_show_uvedit(sima, CTX_data_edit_object(C));
|
||||
show_render= ED_space_image_show_render(sima);
|
||||
show_paint= ED_space_image_show_paint(sima);
|
||||
show_uvedit= ED_space_image_show_uvedit(sima, CTX_data_edit_object(C));
|
||||
|
||||
RNA_pointer_create(&sc->id, &RNA_SpaceImageEditor, sima, &spaceptr);
|
||||
RNA_pointer_create(&sc->id, &RNA_SpaceUVEditor, sima, &uvptr);
|
||||
@@ -894,35 +767,27 @@ void image_header_buttons(const bContext *C, ARegion *ar)
|
||||
|
||||
/* image select */
|
||||
|
||||
pinflag= (show_render)? 0: UI_ID_PIN;
|
||||
xco= uiDefIDPoinButs(block, CTX_data_main(C), NULL, (ID**)&sima->image, ID_IM, &sima->pin, xco, yco,
|
||||
sima_idpoin_handle, UI_ID_BROWSE|UI_ID_BROWSE_RENDER|UI_ID_RENAME|UI_ID_ADD_NEW|UI_ID_OPEN|UI_ID_DELETE|UI_ID_ALONE|UI_ID_PIN);
|
||||
sima_idpoin_handle, UI_ID_BROWSE|UI_ID_BROWSE_RENDER|UI_ID_RENAME|UI_ID_ADD_NEW|UI_ID_OPEN|UI_ID_DELETE|pinflag);
|
||||
xco += 8;
|
||||
|
||||
#if 0
|
||||
char naam[256];
|
||||
|
||||
/* This should not be a static var */
|
||||
static int headerbuttons_packdummy;
|
||||
|
||||
headerbuttons_packdummy = 0;
|
||||
|
||||
int allow_pin= (show_render)? 0: B_SIMAPIN;
|
||||
|
||||
xco= 8 + std_libbuttons(block, xco, yco, allow_pin, &sima->pin, B_SIMABROWSE, ID_IM, 0, (ID *)ima, 0, &(sima->imanr), 0, 0, B_IMAGEDELETE, 0, 0);
|
||||
|
||||
if(ima && !ELEM3(ima->source, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE, IMA_SRC_VIEWER) && ima->ok) {
|
||||
/* XXX this should not be a static var */
|
||||
static int headerbuttons_packdummy;
|
||||
|
||||
headerbuttons_packdummy = 0;
|
||||
|
||||
if (ima->packedfile) {
|
||||
headerbuttons_packdummy = 1;
|
||||
}
|
||||
if (ima->packedfile && ibuf && (ibuf->userflags & IB_BITMAPDIRTY))
|
||||
uiDefIconButBitI(block, TOG, 1, B_SIMA_REPACK, ICON_UGLYPACKAGE, xco,yco,XIC,YIC, &headerbuttons_packdummy, 0, 0, 0, 0, "Re-Pack this image as PNG");
|
||||
uiDefIconButBitI(block, TOG, 1, 0 /* XXX B_SIMA_REPACK */, ICON_UGLYPACKAGE, xco,yco,XIC,YIC, &headerbuttons_packdummy, 0, 0, 0, 0, "Re-Pack this image as PNG");
|
||||
else
|
||||
uiDefIconButBitI(block, TOG, 1, B_SIMAPACKIMA, ICON_PACKAGE, xco,yco,XIC,YIC, &headerbuttons_packdummy, 0, 0, 0, 0, "Pack/Unpack this image");
|
||||
uiDefIconButBitI(block, TOG, 1, 0 /* XXX B_SIMAPACKIMA */, ICON_PACKAGE, xco,yco,XIC,YIC, &headerbuttons_packdummy, 0, 0, 0, 0, "Pack/Unpack this image");
|
||||
|
||||
xco+= XIC+8;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* uv editing */
|
||||
if(show_uvedit) {
|
||||
@@ -958,7 +823,7 @@ void image_header_buttons(const bContext *C, ARegion *ar)
|
||||
xco+=XIC,yco,XIC,YIC, &scene->toolsettings->uv_selectmode, 1.0, UV_SELECT_EDGE, 0, 0, "Edge select mode");
|
||||
uiDefIconButS(block, ROW, B_REDR, ICON_FACESEL,
|
||||
xco+=XIC,yco,XIC,YIC, &scene->toolsettings->uv_selectmode, 1.0, UV_SELECT_FACE, 0, 0, "Face select mode");
|
||||
uiDefIconButS(block, ROW, B_REDR, ICON_MESH,
|
||||
uiDefIconButS(block, ROW, B_REDR, ICON_LINKEDSEL,
|
||||
xco+=XIC,yco,XIC,YIC, &scene->toolsettings->uv_selectmode, 1.0, UV_SELECT_ISLAND, 0, 0, "Island select mode");
|
||||
|
||||
uiBlockEndAlign(block);
|
||||
@@ -988,7 +853,7 @@ void image_header_buttons(const bContext *C, ARegion *ar)
|
||||
}
|
||||
|
||||
uiBlockEndAlign(block);
|
||||
xco+= 10;
|
||||
xco+= 8;
|
||||
|
||||
/* uv layers */
|
||||
{
|
||||
@@ -1001,14 +866,14 @@ void image_header_buttons(const bContext *C, ARegion *ar)
|
||||
but = uiDefButI(block, MENU, B_NOP, menustr ,xco,yco,85,YIC, &act, 0, 0, 0, 0, "Active UV Layer for editing.");
|
||||
// uiButSetFunc(but, do_image_buttons_set_uvlayer_callback, &act, NULL);
|
||||
|
||||
xco+= 90;
|
||||
xco+= 85;
|
||||
}
|
||||
|
||||
xco+= 8;
|
||||
}
|
||||
|
||||
if(ima) {
|
||||
RenderResult *rr;
|
||||
|
||||
xco+= 8;
|
||||
|
||||
/* render layers and passes */
|
||||
rr= BKE_image_get_renderresult(scene, ima);
|
||||
@@ -1046,7 +911,7 @@ void image_header_buttons(const bContext *C, ARegion *ar)
|
||||
/* record & play */
|
||||
uiBlockBeginAlign(block);
|
||||
if(ima->type==IMA_TYPE_COMPOSITE) {
|
||||
//XXX uiDefIconButO(block, BUT, "IMAGE_OT_record_composite", WM_OP_INVOKE_REGION_WIN, ICON_REC, xco, yco, XIC, YIC, NULL); // Record Composite
|
||||
uiDefIconButO(block, BUT, "IMAGE_OT_record_composite", WM_OP_INVOKE_REGION_WIN, ICON_REC, xco, yco, XIC, YIC, NULL); // Record Composite
|
||||
xco+= XIC;
|
||||
}
|
||||
if((ima->type==IMA_TYPE_COMPOSITE) || ELEM(ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) {
|
||||
@@ -1076,7 +941,7 @@ static int toolbox_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
||||
uiMenuItem *head;
|
||||
int show_uvedit;
|
||||
|
||||
show_uvedit= get_space_image_show_uvedit(sima, obedit);
|
||||
show_uvedit= ED_space_image_show_uvedit(sima, obedit);
|
||||
|
||||
head= uiPupMenuBegin("Toolbox", 0);
|
||||
|
||||
@@ -1101,4 +966,3 @@ void IMAGE_OT_toolbox(wmOperatorType *ot)
|
||||
ot->poll= space_image_main_area_poll;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -39,21 +39,6 @@ struct ImBuf;
|
||||
struct wmOperatorType;
|
||||
struct Scene;
|
||||
|
||||
/* space_image.c */
|
||||
struct Image *get_space_image(struct SpaceImage *sima);
|
||||
void set_space_image(struct SpaceImage *sima, struct Scene *scene, struct Object *obedit, struct Image *ima);
|
||||
|
||||
struct ImBuf *get_space_image_buffer(struct SpaceImage *sima);
|
||||
void get_space_image_size(struct SpaceImage *sima, int *width, int *height);
|
||||
void get_space_image_aspect(struct SpaceImage *sima, float *aspx, float *aspy);
|
||||
void get_space_image_zoom(struct SpaceImage *sima, struct ARegion *ar, float *zoomx, float *zoomy);
|
||||
void get_space_image_uv_aspect(struct SpaceImage *sima, float *aspx, float *aspy);
|
||||
|
||||
int get_space_image_show_render(struct SpaceImage *sima);
|
||||
int get_space_image_show_paint(struct SpaceImage *sima);
|
||||
int get_space_image_show_uvedit(struct SpaceImage *sima, struct Object *obedit);
|
||||
int get_space_image_show_uvshadow(struct SpaceImage *sima, struct Object *obedit);
|
||||
|
||||
/* image_header.c */
|
||||
void image_header_buttons(const struct bContext *C, struct ARegion *ar);
|
||||
|
||||
@@ -61,6 +46,7 @@ void IMAGE_OT_toolbox(struct wmOperatorType *ot);
|
||||
|
||||
/* image_draw.c */
|
||||
void draw_image_main(struct SpaceImage *sima, struct ARegion *ar, struct Scene *scene);
|
||||
void draw_image_info(struct ARegion *ar, int channels, int x, int y, char *cp, float *fp, int *zp, float *zpf);
|
||||
|
||||
/* image_ops.c */
|
||||
int space_image_main_area_poll(struct bContext *C);
|
||||
@@ -73,6 +59,21 @@ void IMAGE_OT_view_zoom_in(struct wmOperatorType *ot);
|
||||
void IMAGE_OT_view_zoom_out(struct wmOperatorType *ot);
|
||||
void IMAGE_OT_view_zoom_ratio(struct wmOperatorType *ot);
|
||||
|
||||
void IMAGE_OT_new(struct wmOperatorType *ot);
|
||||
void IMAGE_OT_open(struct wmOperatorType *ot);
|
||||
void IMAGE_OT_replace(struct wmOperatorType *ot);
|
||||
void IMAGE_OT_reload(struct wmOperatorType *ot);
|
||||
void IMAGE_OT_save(struct wmOperatorType *ot);
|
||||
void IMAGE_OT_save_as(struct wmOperatorType *ot);
|
||||
void IMAGE_OT_save_sequence(struct wmOperatorType *ot);
|
||||
void IMAGE_OT_pack(struct wmOperatorType *ot);
|
||||
void IMAGE_OT_unpack(struct wmOperatorType *ot);
|
||||
|
||||
void IMAGE_OT_sample(struct wmOperatorType *ot);
|
||||
void IMAGE_OT_set_curves_point(struct wmOperatorType *ot);
|
||||
|
||||
void IMAGE_OT_record_composite(struct wmOperatorType *ot);
|
||||
|
||||
/* uvedit_draw.c */
|
||||
void draw_uvedit_main(struct SpaceImage *sima, struct ARegion *ar, struct Scene *scene, struct Object *obedit);
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -101,9 +101,6 @@ static SpaceLink *image_new(const bContext *C)
|
||||
BLI_addtail(&simage->regionbase, ar);
|
||||
ar->regiontype= RGN_TYPE_WINDOW;
|
||||
|
||||
/* channel list region XXX */
|
||||
|
||||
|
||||
return (SpaceLink *)simage;
|
||||
}
|
||||
|
||||
@@ -147,6 +144,21 @@ void image_operatortypes(void)
|
||||
WM_operatortype_append(IMAGE_OT_view_zoom_out);
|
||||
WM_operatortype_append(IMAGE_OT_view_zoom_ratio);
|
||||
|
||||
WM_operatortype_append(IMAGE_OT_new);
|
||||
WM_operatortype_append(IMAGE_OT_open);
|
||||
WM_operatortype_append(IMAGE_OT_replace);
|
||||
WM_operatortype_append(IMAGE_OT_reload);
|
||||
WM_operatortype_append(IMAGE_OT_save);
|
||||
WM_operatortype_append(IMAGE_OT_save_as);
|
||||
WM_operatortype_append(IMAGE_OT_save_sequence);
|
||||
WM_operatortype_append(IMAGE_OT_pack);
|
||||
WM_operatortype_append(IMAGE_OT_unpack);
|
||||
|
||||
WM_operatortype_append(IMAGE_OT_sample);
|
||||
WM_operatortype_append(IMAGE_OT_set_curves_point);
|
||||
|
||||
WM_operatortype_append(IMAGE_OT_record_composite);
|
||||
|
||||
WM_operatortype_append(IMAGE_OT_toolbox);
|
||||
}
|
||||
|
||||
@@ -172,6 +184,15 @@ void image_keymap(struct wmWindowManager *wm)
|
||||
RNA_float_set(WM_keymap_add_item(keymap, "IMAGE_OT_view_zoom_ratio", PAD4, KM_PRESS, 0, 0)->ptr, "ratio", 0.25f);
|
||||
RNA_float_set(WM_keymap_add_item(keymap, "IMAGE_OT_view_zoom_ratio", PAD8, KM_PRESS, 0, 0)->ptr, "ratio", 0.125f);
|
||||
|
||||
WM_keymap_add_item(keymap, "IMAGE_OT_new", NKEY, KM_PRESS, KM_ALT, 0);
|
||||
WM_keymap_add_item(keymap, "IMAGE_OT_open", OKEY, KM_PRESS, KM_ALT, 0);
|
||||
WM_keymap_add_item(keymap, "IMAGE_OT_reload", RKEY, KM_PRESS, KM_ALT, 0);
|
||||
WM_keymap_add_item(keymap, "IMAGE_OT_save", SKEY, KM_PRESS, KM_ALT, 0);
|
||||
|
||||
WM_keymap_add_item(keymap, "IMAGE_OT_sample", ACTIONMOUSE, KM_PRESS, 0, 0);
|
||||
RNA_enum_set(WM_keymap_add_item(keymap, "IMAGE_OT_set_curves_point", ACTIONMOUSE, KM_PRESS, KM_CTRL, 0)->ptr, "point", 0);
|
||||
RNA_enum_set(WM_keymap_add_item(keymap, "IMAGE_OT_set_curves_point", ACTIONMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "point", 1);
|
||||
|
||||
WM_keymap_add_item(keymap, "IMAGE_OT_toolbox", SPACEKEY, KM_PRESS, 0, 0);
|
||||
}
|
||||
|
||||
@@ -181,7 +202,7 @@ static void image_refresh(const bContext *C, ScrArea *sa)
|
||||
Object *obedit= CTX_data_edit_object(C);
|
||||
Image *ima;
|
||||
|
||||
ima= get_space_image(sima);
|
||||
ima= ED_space_image(sima);
|
||||
|
||||
/* check if we have to set the image from the editmesh */
|
||||
if(ima && (ima->source==IMA_SRC_VIEWER || sima->pin));
|
||||
@@ -190,7 +211,7 @@ static void image_refresh(const bContext *C, ScrArea *sa)
|
||||
EditMesh *em= me->edit_mesh;
|
||||
MTFace *tf;
|
||||
|
||||
if(EM_texFaceCheck(em)) {
|
||||
if(em && EM_texFaceCheck(em)) {
|
||||
sima->image= ima= NULL;
|
||||
|
||||
tf = EM_get_active_mtface(em, NULL, NULL, 1); /* partially selected face is ok */
|
||||
@@ -215,6 +236,8 @@ static void image_refresh(const bContext *C, ScrArea *sa)
|
||||
|
||||
static void image_listener(ScrArea *sa, wmNotifier *wmn)
|
||||
{
|
||||
SpaceImage *sima= sa->spacedata.first;
|
||||
|
||||
/* context changes */
|
||||
switch(wmn->category) {
|
||||
case NC_SCENE:
|
||||
@@ -227,6 +250,10 @@ static void image_listener(ScrArea *sa, wmNotifier *wmn)
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case NC_IMAGE:
|
||||
if(!wmn->reference || wmn->reference == sima->image)
|
||||
ED_area_tag_redraw(sa);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -235,11 +262,11 @@ static int image_context(const bContext *C, bContextDataMember member, bContextD
|
||||
SpaceImage *sima= (SpaceImage*)CTX_wm_space_data(C);
|
||||
|
||||
if(member == CTX_DATA_EDIT_IMAGE) {
|
||||
CTX_data_pointer_set(result, get_space_image(sima));
|
||||
CTX_data_pointer_set(result, ED_space_image(sima));
|
||||
return 1;
|
||||
}
|
||||
else if(member == CTX_DATA_EDIT_IMAGE_BUFFER) {
|
||||
CTX_data_pointer_set(result, get_space_image_buffer(sima));
|
||||
CTX_data_pointer_set(result, ED_space_image_buffer(sima));
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -251,17 +278,17 @@ static int image_context(const bContext *C, bContextDataMember member, bContextD
|
||||
/* sets up the fields of the View2D from zoom and offset */
|
||||
static void image_main_area_set_view2d(SpaceImage *sima, ARegion *ar)
|
||||
{
|
||||
Image *ima= get_space_image(sima);
|
||||
Image *ima= ED_space_image(sima);
|
||||
float x1, y1, w, h;
|
||||
int width, height, winx, winy;
|
||||
|
||||
#if 0
|
||||
if(image_preview_active(curarea, &xim, &yim));
|
||||
else if(sima->image) {
|
||||
ImBuf *ibuf= imagewindow_get_ibuf(sima);
|
||||
ImBuf *ibuf= ED_space_image_buffer(sima);
|
||||
float xuser_asp, yuser_asp;
|
||||
|
||||
image_pixel_aspect(sima->image, &xuser_asp, &yuser_asp);
|
||||
ED_image_aspect(sima->image, &xuser_asp, &yuser_asp);
|
||||
if(ibuf) {
|
||||
xim= ibuf->x * xuser_asp;
|
||||
yim= ibuf->y * yuser_asp;
|
||||
@@ -274,7 +301,7 @@ static void image_main_area_set_view2d(SpaceImage *sima, ARegion *ar)
|
||||
}
|
||||
#endif
|
||||
|
||||
get_space_image_size(sima, &width, &height);
|
||||
ED_space_image_size(sima, &width, &height);
|
||||
|
||||
w= width;
|
||||
h= height;
|
||||
@@ -354,6 +381,7 @@ static void image_main_area_draw(const bContext *C, ARegion *ar)
|
||||
/* and uvs in 0.0-1.0 space */
|
||||
UI_view2d_view_ortho(C, v2d);
|
||||
draw_uvedit_main(sima, ar, scene, obedit);
|
||||
ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST);
|
||||
UI_view2d_view_restore(C);
|
||||
|
||||
/* scrollers? */
|
||||
@@ -367,6 +395,7 @@ static void image_modal_keymaps(wmWindowManager *wm, ARegion *ar, int stype)
|
||||
ListBase *keymap;
|
||||
|
||||
keymap= WM_keymap_listbase(wm, "UVEdit", 0, 0);
|
||||
|
||||
if(stype==NS_EDITMODE_MESH)
|
||||
WM_event_add_keymap_handler(&ar->handlers, keymap);
|
||||
else
|
||||
@@ -472,13 +501,13 @@ void ED_spacetype_image(void)
|
||||
|
||||
/**************************** common state *****************************/
|
||||
|
||||
Image *get_space_image(SpaceImage *sima)
|
||||
Image *ED_space_image(SpaceImage *sima)
|
||||
{
|
||||
return sima->image;
|
||||
}
|
||||
|
||||
/* called to assign images to UV faces */
|
||||
void set_space_image(SpaceImage *sima, Scene *scene, Object *obedit, Image *ima)
|
||||
void ED_space_image_set(bContext *C, SpaceImage *sima, Scene *scene, Object *obedit, Image *ima)
|
||||
{
|
||||
ED_uvedit_assign_image(scene, obedit, ima, sima->image);
|
||||
|
||||
@@ -491,9 +520,17 @@ void set_space_image(SpaceImage *sima, Scene *scene, Object *obedit, Image *ima)
|
||||
|
||||
if(sima->image)
|
||||
BKE_image_signal(sima->image, &sima->iuser, IMA_SIGNAL_USER_NEW_IMAGE);
|
||||
|
||||
if(sima->image && sima->image->id.us==0)
|
||||
sima->image->id.us= 1;
|
||||
|
||||
if(obedit)
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, obedit);
|
||||
|
||||
ED_area_tag_redraw(CTX_wm_area(C));
|
||||
}
|
||||
|
||||
ImBuf *get_space_image_buffer(SpaceImage *sima)
|
||||
ImBuf *ED_space_image_buffer(SpaceImage *sima)
|
||||
{
|
||||
ImBuf *ibuf;
|
||||
|
||||
@@ -512,11 +549,27 @@ ImBuf *get_space_image_buffer(SpaceImage *sima)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void get_space_image_size(SpaceImage *sima, int *width, int *height)
|
||||
void ED_image_size(Image *ima, int *width, int *height)
|
||||
{
|
||||
ImBuf *ibuf;
|
||||
|
||||
ibuf= get_space_image_buffer(sima);
|
||||
ibuf= (ima)? BKE_image_get_ibuf(ima, NULL): NULL;
|
||||
|
||||
if(ibuf && ibuf->x > 0 && ibuf->y > 0) {
|
||||
*width= ibuf->x;
|
||||
*height= ibuf->y;
|
||||
}
|
||||
else {
|
||||
*width= 256;
|
||||
*height= 256;
|
||||
}
|
||||
}
|
||||
|
||||
void ED_space_image_size(SpaceImage *sima, int *width, int *height)
|
||||
{
|
||||
ImBuf *ibuf;
|
||||
|
||||
ibuf= ED_space_image_buffer(sima);
|
||||
|
||||
if(ibuf && ibuf->x > 0 && ibuf->y > 0) {
|
||||
*width= ibuf->x;
|
||||
@@ -530,12 +583,8 @@ void get_space_image_size(SpaceImage *sima, int *width, int *height)
|
||||
}
|
||||
}
|
||||
|
||||
void get_space_image_aspect(SpaceImage *sima, float *aspx, float *aspy)
|
||||
void ED_image_aspect(Image *ima, float *aspx, float *aspy)
|
||||
{
|
||||
Image *ima;
|
||||
|
||||
ima= get_space_image(sima);
|
||||
|
||||
*aspx= *aspy= 1.0;
|
||||
|
||||
if((ima == NULL) || (ima->type == IMA_TYPE_R_RESULT) || (ima->type == IMA_TYPE_COMPOSITE) ||
|
||||
@@ -546,45 +595,61 @@ void get_space_image_aspect(SpaceImage *sima, float *aspx, float *aspy)
|
||||
*aspy = ima->aspy/ima->aspx;
|
||||
}
|
||||
|
||||
void get_space_image_zoom(SpaceImage *sima, ARegion *ar, float *zoomx, float *zoomy)
|
||||
void ED_space_image_aspect(SpaceImage *sima, float *aspx, float *aspy)
|
||||
{
|
||||
ED_image_aspect(ED_space_image(sima), aspx, aspy);
|
||||
}
|
||||
|
||||
void ED_space_image_zoom(SpaceImage *sima, ARegion *ar, float *zoomx, float *zoomy)
|
||||
{
|
||||
int width, height;
|
||||
|
||||
get_space_image_size(sima, &width, &height);
|
||||
ED_space_image_size(sima, &width, &height);
|
||||
|
||||
*zoomx= (float)(ar->winrct.xmax - ar->winrct.xmin)/(float)((ar->v2d.cur.xmax - ar->v2d.cur.xmin)*width);
|
||||
*zoomy= (float)(ar->winrct.ymax - ar->winrct.ymin)/(float)((ar->v2d.cur.ymax - ar->v2d.cur.ymin)*height);
|
||||
}
|
||||
|
||||
void get_space_image_uv_aspect(SpaceImage *sima, float *aspx, float *aspy)
|
||||
void ED_space_image_uv_aspect(SpaceImage *sima, float *aspx, float *aspy)
|
||||
{
|
||||
int w, h;
|
||||
|
||||
get_space_image_aspect(sima, aspx, aspy);
|
||||
get_space_image_size(sima, &w, &h);
|
||||
ED_space_image_aspect(sima, aspx, aspy);
|
||||
ED_space_image_size(sima, &w, &h);
|
||||
|
||||
*aspx *= (float)w/256.0f;
|
||||
*aspy *= (float)h/256.0f;
|
||||
}
|
||||
|
||||
void ED_image_uv_aspect(Image *ima, float *aspx, float *aspy)
|
||||
{
|
||||
int w, h;
|
||||
|
||||
ED_image_aspect(ima, aspx, aspy);
|
||||
ED_image_size(ima, &w, &h);
|
||||
|
||||
*aspx *= (float)w;
|
||||
*aspy *= (float)h;
|
||||
}
|
||||
|
||||
int get_space_image_show_render(SpaceImage *sima)
|
||||
int ED_space_image_show_render(SpaceImage *sima)
|
||||
{
|
||||
return (sima->image && ELEM(sima->image->type, IMA_TYPE_R_RESULT, IMA_TYPE_COMPOSITE));
|
||||
}
|
||||
|
||||
int get_space_image_show_paint(SpaceImage *sima)
|
||||
int ED_space_image_show_paint(SpaceImage *sima)
|
||||
{
|
||||
if(get_space_image_show_render(sima))
|
||||
if(ED_space_image_show_render(sima))
|
||||
return 0;
|
||||
|
||||
return (sima->flag & SI_DRAWTOOL);
|
||||
}
|
||||
|
||||
int get_space_image_show_uvedit(SpaceImage *sima, Object *obedit)
|
||||
int ED_space_image_show_uvedit(SpaceImage *sima, Object *obedit)
|
||||
{
|
||||
if(get_space_image_show_render(sima))
|
||||
if(ED_space_image_show_render(sima))
|
||||
return 0;
|
||||
if(get_space_image_show_paint(sima))
|
||||
if(ED_space_image_show_paint(sima))
|
||||
return 0;
|
||||
|
||||
if(obedit && obedit->type == OB_MESH)
|
||||
@@ -593,33 +658,15 @@ int get_space_image_show_uvedit(SpaceImage *sima, Object *obedit)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int get_space_image_show_uvshadow(SpaceImage *sima, Object *obedit)
|
||||
int ED_space_image_show_uvshadow(SpaceImage *sima, Object *obedit)
|
||||
{
|
||||
if(get_space_image_show_render(sima))
|
||||
if(ED_space_image_show_render(sima))
|
||||
return 0;
|
||||
|
||||
if(get_space_image_show_paint(sima))
|
||||
if(ED_space_image_show_paint(sima))
|
||||
if(obedit && obedit->type == OB_MESH)
|
||||
return EM_texFaceCheck(((Mesh*)obedit->data)->edit_mesh);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Exported Functions */
|
||||
|
||||
Image *ED_space_image(SpaceImage *sima)
|
||||
{
|
||||
return get_space_image(sima);
|
||||
}
|
||||
|
||||
void ED_space_image_size(SpaceImage *sima, int *width, int *height)
|
||||
{
|
||||
get_space_image_size(sima, width, height);
|
||||
}
|
||||
|
||||
void ED_space_image_uv_aspect(SpaceImage *sima, float *aspx, float *aspy)
|
||||
{
|
||||
get_space_image_uv_aspect(sima, aspx, aspy);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -272,12 +272,12 @@ static int node_buts_time(uiBlock *block, bNodeTree *ntree, bNode *node, rctf *b
|
||||
short dx= (short)((butr->xmax-butr->xmin)/2);
|
||||
butr->ymin += 26;
|
||||
|
||||
// XXX curvemap_buttons(block, node->storage, 's', B_NODE_EXEC, B_REDR, butr);
|
||||
curvemap_buttons(block, node->storage, 's', B_NODE_EXEC, B_REDR, butr);
|
||||
|
||||
if(cumap) {
|
||||
cumap->flag |= CUMA_DRAW_CFRA;
|
||||
if(node->custom1<node->custom2)
|
||||
;// XXX cumap->sample[0]= (float)(CFRA - node->custom1)/(float)(node->custom2-node->custom1);
|
||||
//cumap->flag |= CUMA_DRAW_CFRA;
|
||||
//if(node->custom1<node->custom2)
|
||||
// cumap->sample[0]= (float)(CFRA - node->custom1)/(float)(node->custom2-node->custom1);
|
||||
}
|
||||
|
||||
uiBlockBeginAlign(block);
|
||||
@@ -305,7 +305,7 @@ static int node_buts_valtorgb(uiBlock *block, bNodeTree *ntree, bNode *node, rct
|
||||
static int node_buts_curvevec(uiBlock *block, bNodeTree *ntree, bNode *node, rctf *butr)
|
||||
{
|
||||
if(block) {
|
||||
; // XXX curvemap_buttons(block, node->storage, 'v', B_NODE_EXEC, B_REDR, butr);
|
||||
curvemap_buttons(block, node->storage, 'v', B_NODE_EXEC, B_REDR, butr);
|
||||
}
|
||||
return (int)(node->width-NODE_DY);
|
||||
}
|
||||
@@ -327,7 +327,7 @@ static int node_buts_curvecol(uiBlock *block, bNodeTree *ntree, bNode *node, rct
|
||||
else
|
||||
cumap->flag &= ~CUMA_DRAW_SAMPLE;
|
||||
|
||||
// XXX curvemap_buttons(block, node->storage, 'c', B_NODE_EXEC, B_REDR, butr);
|
||||
curvemap_buttons(block, node->storage, 'c', B_NODE_EXEC, B_REDR, butr);
|
||||
}
|
||||
return (int)(node->width-NODE_DY);
|
||||
}
|
||||
@@ -2583,7 +2583,7 @@ void node_draw_link_bezier(View2D *v2d, SpaceNode *snode, bNodeLink *link, int t
|
||||
dist = 1.0f/(float)LINK_RESOL;
|
||||
|
||||
glBegin(GL_LINE_STRIP);
|
||||
for(i=0; i<LINK_RESOL; i++) {
|
||||
for(i=0; i<=LINK_RESOL; i++) {
|
||||
if(do_shaded) {
|
||||
UI_ThemeColorBlend(th_col1, th_col2, spline_step);
|
||||
spline_step += dist;
|
||||
|
||||
@@ -702,7 +702,7 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN
|
||||
UI_icon_draw_aspect_blended(iconofs, rct->ymax-NODE_DY+2, ICON_BUTS, snode->aspect, -60);
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
{ /* always hide/reveil unused sockets */
|
||||
{ /* always hide/reveal unused sockets */
|
||||
int shade;
|
||||
|
||||
iconofs-= 18.0f;
|
||||
@@ -823,11 +823,9 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* XXX fix
|
||||
UI_ThemeColor(TH_TEXT);
|
||||
ui_rasterpos_safe(sock->locx+8.0f, sock->locy-5.0f, snode->aspect);
|
||||
UI_DrawString(snode->curfont, sock->name, 0);
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -835,11 +833,12 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN
|
||||
/* socket outputs */
|
||||
for(sock= node->outputs.first; sock; sock= sock->next) {
|
||||
if(!(sock->flag & (SOCK_HIDDEN|SOCK_UNAVAIL))) {
|
||||
float slen;
|
||||
int ofs= 0;
|
||||
|
||||
socket_circle_draw(sock, NODE_SOCKSIZE);
|
||||
|
||||
/* XXX fix
|
||||
UI_ThemeColor(TH_TEXT);
|
||||
ofs= 0;
|
||||
slen= snode->aspect*UI_GetStringWidth(snode->curfont, sock->name, 0);
|
||||
while(slen > node->width) {
|
||||
ofs++;
|
||||
@@ -847,7 +846,6 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN
|
||||
}
|
||||
ui_rasterpos_safe(sock->locx-8.0f-slen, sock->locy-5.0f, snode->aspect);
|
||||
UI_DrawString(snode->curfont, sock->name+ofs, 0);
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1110,7 +1108,7 @@ void drawnodespace(const bContext *C, ARegion *ar, View2D *v2d)
|
||||
|
||||
/* aspect+font, set each time */
|
||||
snode->aspect= (v2d->cur.xmax - v2d->cur.xmin)/((float)ar->winx);
|
||||
//snode->curfont= uiSetCurFont_ext(snode->aspect);
|
||||
snode->curfont= uiSetCurFont_ext(snode->aspect);
|
||||
|
||||
UI_view2d_constant_grid_draw(C, v2d);
|
||||
/* backdrop */
|
||||
|
||||
@@ -164,10 +164,14 @@ static void node_area_refresh(const struct bContext *C, struct ScrArea *sa)
|
||||
|
||||
if(snode->nodetree) {
|
||||
if(snode->treetype==NTREE_SHADER) {
|
||||
ED_preview_shader_job(C, sa, snode->id, 100, 100);
|
||||
Material *ma= (Material *)snode->id;
|
||||
if(ma->use_nodes)
|
||||
ED_preview_shader_job(C, sa, snode->id, 100, 100);
|
||||
}
|
||||
else if(snode->treetype==NTREE_COMPOSIT) {
|
||||
snode_composite_job(C, sa);
|
||||
Scene *scene= (Scene *)snode->id;
|
||||
if(scene->use_nodes)
|
||||
snode_composite_job(C, sa);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,6 +64,7 @@
|
||||
|
||||
#include "IMB_imbuf_types.h"
|
||||
|
||||
#include "BKE_animsys.h"
|
||||
#include "BKE_constraint.h"
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_deform.h"
|
||||
@@ -75,6 +76,7 @@
|
||||
#include "BKE_material.h"
|
||||
#include "BKE_modifier.h"
|
||||
#include "BKE_object.h"
|
||||
#include "BKE_report.h"
|
||||
#include "BKE_screen.h"
|
||||
#include "BKE_scene.h"
|
||||
#include "BKE_sequence.h"
|
||||
@@ -2477,7 +2479,7 @@ void outliner_find_panel(Scene *scene, ARegion *ar, SpaceOops *soops, int again,
|
||||
// else return; /* XXX RETURN! XXX */
|
||||
}
|
||||
|
||||
/* do selection and reveil */
|
||||
/* do selection and reveal */
|
||||
if (te) {
|
||||
tselem= TREESTORE(te);
|
||||
if (tselem) {
|
||||
@@ -3086,6 +3088,235 @@ void outliner_operation_menu(Scene *scene, ARegion *ar, SpaceOops *soops)
|
||||
}
|
||||
}
|
||||
|
||||
/* ***************** KEYINGSET OPERATIONS *************** */
|
||||
|
||||
/* These operators are only available in databrowser mode for now, as
|
||||
* they depend on having RNA paths and/or hierarchies available.
|
||||
*/
|
||||
enum {
|
||||
KEYINGSET_EDITMODE_ADD = 0,
|
||||
KEYINGSET_EDITMODE_REMOVE,
|
||||
} eKeyingSet_EditModes;
|
||||
|
||||
/* typedef'd function-prototype style for KeyingSet operation callbacks */
|
||||
typedef void (*ksEditOp)(SpaceOops *soops, KeyingSet *ks, TreeElement *te, TreeStoreElem *tselem);
|
||||
|
||||
/* Utilities ---------------------------------- */
|
||||
|
||||
/* specialised poll callback for these operators to work in Datablocks view only */
|
||||
static int ed_operator_outliner_datablocks_active(bContext *C)
|
||||
{
|
||||
ScrArea *sa= CTX_wm_area(C);
|
||||
if ((sa) && (sa->spacetype==SPACE_OOPS)) {
|
||||
SpaceOops *so= (SpaceOops *)CTX_wm_space_data(C);
|
||||
return ((so->type == SO_OUTLINER) && (so->outlinevis == SO_DATABLOCKS));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* find the 'active' KeyingSet, and add if not found (if adding is allowed) */
|
||||
// TODO: should this be an API func?
|
||||
static KeyingSet *verify_active_keyingset(Scene *scene, short add)
|
||||
{
|
||||
KeyingSet *ks= NULL;
|
||||
|
||||
/* sanity check */
|
||||
if (scene == NULL)
|
||||
return NULL;
|
||||
|
||||
/* try to find one from scene */
|
||||
if (scene->active_keyingset > 0)
|
||||
ks= BLI_findlink(&scene->keyingsets, scene->active_keyingset-1);
|
||||
|
||||
/* add if none found */
|
||||
// XXX the default settings have yet to evolve
|
||||
if ((add) && (ks==NULL)) {
|
||||
ks= BKE_keyingset_add(&scene->keyingsets, "KeyingSet", KEYINGSET_ABSOLUTE, 0);
|
||||
scene->active_keyingset= BLI_countlist(&scene->keyingsets);
|
||||
}
|
||||
|
||||
return ks;
|
||||
}
|
||||
|
||||
/* helper func to add a new KeyingSet Path */
|
||||
static void ks_editop_add_cb(SpaceOops *soops, KeyingSet *ks, TreeElement *te, TreeStoreElem *tselem)
|
||||
{
|
||||
ListBase hierarchy = {NULL, NULL};
|
||||
LinkData *ld;
|
||||
TreeElement *tem;
|
||||
TreeStoreElem *tse;
|
||||
PointerRNA *ptr;
|
||||
PropertyRNA *prop;
|
||||
ID *id = NULL;
|
||||
char *path=NULL, *newpath=NULL;
|
||||
int array_index= 0;
|
||||
int flag= KSP_FLAG_GROUP_KSNAME;
|
||||
|
||||
/* optimise tricks:
|
||||
* - Don't do anything if the selected item is a 'struct', but arrays are allowed
|
||||
*/
|
||||
if (tselem->type == TSE_RNA_STRUCT)
|
||||
return;
|
||||
|
||||
//printf("ks_editop_add_cb() \n");
|
||||
|
||||
/* Overview of Algorithm:
|
||||
* 1. Go up the chain of parents until we find the 'root', taking note of the
|
||||
* levels encountered in reverse-order (i.e. items are added to the start of the list
|
||||
* for more convenient looping later)
|
||||
* 2. Walk down the chain, adding from the first ID encountered
|
||||
* (which will become the 'ID' for the KeyingSet Path), and build a
|
||||
* path as we step through the chain
|
||||
*/
|
||||
// XXX do we want to separate this part out to a helper func for the other editing op at some point?
|
||||
|
||||
/* step 1: flatten out hierarchy of parents into a flat chain */
|
||||
for (tem= te->parent; tem; tem= tem->parent) {
|
||||
ld= MEM_callocN(sizeof(LinkData), "LinkData for ks_editop_add_cb()");
|
||||
ld->data= tem;
|
||||
BLI_addhead(&hierarchy, ld);
|
||||
}
|
||||
|
||||
/* step 2: step down hierarchy building the path (NOTE: addhead in previous loop was needed so that we can loop like this) */
|
||||
for (ld= hierarchy.first; ld; ld= ld->next) {
|
||||
/* get data */
|
||||
tem= (TreeElement *)ld->data;
|
||||
tse= TREESTORE(tem);
|
||||
ptr= &tem->rnaptr;
|
||||
prop= tem->directdata;
|
||||
|
||||
/* check if we're looking for first ID, or appending to path */
|
||||
if (id) {
|
||||
/* just 'append' property to path
|
||||
* - to prevent memory leaks, we must write to newpath not path, then free old path + swap them
|
||||
*/
|
||||
// TODO: how to do this? we must use 'string' identifiers for collections so that these don't break if data is added/removed
|
||||
//newpath= RNA_path_append(path, NULL, prop, index, NULL);
|
||||
|
||||
if (path) MEM_freeN(path);
|
||||
path= newpath;
|
||||
}
|
||||
else {
|
||||
/* no ID, so check if entry is RNA-struct, and if that RNA-struct is an ID datablock to extract info from */
|
||||
if (tse->type == TSE_RNA_STRUCT) {
|
||||
/* ptr->data not ptr->id.data seems to be the one we want, since ptr->data is sometimes the owner of this ID? */
|
||||
if (RNA_struct_is_ID(ptr))
|
||||
id= (ID *)ptr->data;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* step 3: if we've got an ID, add the current item to the path */
|
||||
if (id) {
|
||||
/* add the active property to the path */
|
||||
// if array base, add KSP_FLAG_WHOLE_ARRAY
|
||||
ptr= &te->rnaptr;
|
||||
prop= te->directdata;
|
||||
|
||||
/* array checks */
|
||||
if (tselem->type == TSE_RNA_ARRAY_ELEM) {
|
||||
/* item is part of an array, so must set the array_index */
|
||||
array_index= te->index;
|
||||
}
|
||||
else if (RNA_property_array_length(ptr, prop)) {
|
||||
/* entire array was selected, so keyframe all */
|
||||
flag |= KSP_FLAG_WHOLE_ARRAY;
|
||||
}
|
||||
|
||||
/* path */
|
||||
newpath= RNA_path_append(path, NULL, prop, 0, NULL);
|
||||
if (path) MEM_freeN(path);
|
||||
path= newpath;
|
||||
|
||||
printf("Adding KeyingSet '%s': Path %s %d \n", ks->name, path, array_index);
|
||||
|
||||
/* add a new path with the information obtained (only if valid) */
|
||||
// TODO: what do we do with group name? for now, we don't supply one, and just let this use the KeyingSet name
|
||||
if (path)
|
||||
BKE_keyingset_add_destination(ks, id, NULL, path, array_index, flag);
|
||||
}
|
||||
|
||||
/* free temp data */
|
||||
if (path) MEM_freeN(path);
|
||||
BLI_freelistN(&hierarchy);
|
||||
}
|
||||
|
||||
/* Recursively iterate over tree, finding and working on selected items */
|
||||
static void do_outliner_keyingset_editop(SpaceOops *soops, KeyingSet *ks, ListBase *tree, ksEditOp edit_cb)
|
||||
{
|
||||
TreeElement *te;
|
||||
TreeStoreElem *tselem;
|
||||
|
||||
for (te= tree->first; te; te=te->next) {
|
||||
tselem= TREESTORE(te);
|
||||
|
||||
/* if item is selected, perform operation */
|
||||
if (tselem->flag & TSE_SELECTED) {
|
||||
if (edit_cb) edit_cb(soops, ks, te, tselem);
|
||||
}
|
||||
|
||||
/* go over sub-tree */
|
||||
if ((tselem->flag & TSE_CLOSED)==0)
|
||||
do_outliner_keyingset_editop(soops, ks, &te->subtree, edit_cb);
|
||||
}
|
||||
}
|
||||
|
||||
/* Add Operator ---------------------------------- */
|
||||
|
||||
static int outliner_keyingset_additems_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
SpaceOops *soutliner= (SpaceOops*)CTX_wm_space_data(C);
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
KeyingSet *ks= verify_active_keyingset(scene, 1);
|
||||
|
||||
/* check for invalid states */
|
||||
if (ks == NULL) {
|
||||
BKE_report(op->reports, RPT_ERROR, "Operation requires an Active Keying Set");
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
if (soutliner == NULL)
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
/* recursively go into tree, adding selected items */
|
||||
// TODO: make the last arg a callback func instead...
|
||||
do_outliner_keyingset_editop(soutliner, ks, &soutliner->tree, ks_editop_add_cb);
|
||||
|
||||
/* send notifiers */
|
||||
WM_event_add_notifier(C, NC_SCENE|ND_KEYINGSET, NULL);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
void OUTLINER_OT_keyingset_add_selected(wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->idname= "OUTLINER_OT_keyingset_add_selected";
|
||||
ot->name= "Keyingset Add Selected";
|
||||
|
||||
/* api callbacks */
|
||||
ot->exec= outliner_keyingset_additems_exec;
|
||||
ot->poll= ed_operator_outliner_datablocks_active;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
|
||||
/* Remove Operator ---------------------------------- */
|
||||
|
||||
void OUTLINER_OT_keyingset_remove_selected(wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->idname= "OUTLINER_OT_keyingset_remove_selected";
|
||||
ot->name= "Keyingset Remove Selected";
|
||||
|
||||
/* api callbacks */
|
||||
ot->poll= ed_operator_outliner_datablocks_active;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
/* ***************** DRAW *************** */
|
||||
|
||||
@@ -3120,11 +3351,11 @@ static void tselem_draw_icon(float x, float y, TreeStoreElem *tselem, TreeElemen
|
||||
case eModifierType_Subsurf:
|
||||
UI_icon_draw(x, y, ICON_MOD_SUBSURF); break;
|
||||
case eModifierType_Armature:
|
||||
UI_icon_draw(x, y, ICON_ARMATURE); break;
|
||||
UI_icon_draw(x, y, ICON_MOD_ARMATURE); break;
|
||||
case eModifierType_Lattice:
|
||||
UI_icon_draw(x, y, ICON_LATTICE); break;
|
||||
UI_icon_draw(x, y, ICON_MOD_LATTICE); break;
|
||||
case eModifierType_Curve:
|
||||
UI_icon_draw(x, y, ICON_CURVE); break;
|
||||
UI_icon_draw(x, y, ICON_MOD_CURVE); break;
|
||||
case eModifierType_Build:
|
||||
UI_icon_draw(x, y, ICON_MOD_BUILD); break;
|
||||
case eModifierType_Mirror:
|
||||
@@ -3165,7 +3396,7 @@ static void tselem_draw_icon(float x, float y, TreeStoreElem *tselem, TreeElemen
|
||||
case TSE_PROXY:
|
||||
UI_icon_draw(x, y, ICON_GHOST); break;
|
||||
case TSE_R_LAYER_BASE:
|
||||
UI_icon_draw(x, y, ICON_RESTRICT_RENDER_OFF); break;
|
||||
UI_icon_draw(x, y, ICON_RENDERLAYERS); break;
|
||||
case TSE_R_LAYER:
|
||||
UI_icon_draw(x, y, ICON_IMAGE_DEHLT); break;
|
||||
case TSE_LINKED_LAMP:
|
||||
@@ -3218,6 +3449,10 @@ static void tselem_draw_icon(float x, float y, TreeStoreElem *tselem, TreeElemen
|
||||
UI_icon_draw(x, y, ICON_OUTLINER_OB_LATTICE); break;
|
||||
case OB_ARMATURE:
|
||||
UI_icon_draw(x, y, ICON_OUTLINER_OB_ARMATURE); break;
|
||||
case OB_FONT:
|
||||
UI_icon_draw(x, y, ICON_OUTLINER_OB_FONT); break;
|
||||
case OB_SURF:
|
||||
UI_icon_draw(x, y, ICON_OUTLINER_OB_SURFACE); break;
|
||||
case OB_EMPTY:
|
||||
UI_icon_draw(x, y, ICON_OUTLINER_OB_EMPTY); break;
|
||||
|
||||
@@ -3506,7 +3741,7 @@ static void outliner_draw_struct_marks(ARegion *ar, SpaceOops *soops, ListBase *
|
||||
if((tselem->flag & TSE_CLOSED)==0) {
|
||||
outliner_draw_struct_marks(ar, soops, &te->subtree, starty);
|
||||
if(tselem->type == TSE_RNA_STRUCT)
|
||||
fdrawline(0, *starty+OL_H-1, (int)ar->v2d.cur.xmax, *starty+OL_H-1);
|
||||
fdrawline(0, (float)*starty+OL_H-1, ar->v2d.cur.xmax, (float)*starty+OL_H-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3915,14 +4150,14 @@ static void outliner_draw_rnacols(ARegion *ar, SpaceOops *soops, int sizex)
|
||||
UI_ThemeColorShadeAlpha(TH_BACK, -15, -200);
|
||||
|
||||
/* draw column separator lines */
|
||||
fdrawline(sizex,
|
||||
fdrawline((float)sizex,
|
||||
v2d->cur.ymax,
|
||||
sizex,
|
||||
(float)sizex,
|
||||
v2d->cur.ymin);
|
||||
|
||||
fdrawline(sizex+OL_RNA_COL_SIZEX,
|
||||
fdrawline((float)sizex+OL_RNA_COL_SIZEX,
|
||||
v2d->cur.ymax,
|
||||
sizex+OL_RNA_COL_SIZEX,
|
||||
(float)sizex+OL_RNA_COL_SIZEX,
|
||||
v2d->cur.ymin);
|
||||
}
|
||||
|
||||
@@ -3941,15 +4176,15 @@ static void outliner_draw_rnabuts(uiBlock *block, Scene *scene, ARegion *ar, Spa
|
||||
if(tselem->type == TSE_RNA_PROPERTY) {
|
||||
ptr= &te->rnaptr;
|
||||
prop= te->directdata;
|
||||
|
||||
|
||||
if(!(RNA_property_type(ptr, prop) == PROP_POINTER && (tselem->flag & TSE_CLOSED)==0))
|
||||
uiDefAutoButR(block, ptr, prop, -1, "", sizex, te->ys, OL_RNA_COL_SIZEX, OL_H-1);
|
||||
uiDefAutoButR(block, ptr, prop, -1, "", sizex, (int)te->ys, OL_RNA_COL_SIZEX, OL_H-1);
|
||||
}
|
||||
else if(tselem->type == TSE_RNA_ARRAY_ELEM) {
|
||||
ptr= &te->rnaptr;
|
||||
prop= te->directdata;
|
||||
|
||||
uiDefAutoButR(block, ptr, prop, te->index, "", sizex, te->ys, OL_RNA_COL_SIZEX, OL_H-1);
|
||||
|
||||
uiDefAutoButR(block, ptr, prop, te->index, "", sizex, (int)te->ys, OL_RNA_COL_SIZEX, OL_H-1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include "DNA_ID.h"
|
||||
#include "DNA_anim_types.h"
|
||||
#include "DNA_space_types.h"
|
||||
#include "DNA_scene_types.h"
|
||||
#include "DNA_screen_types.h"
|
||||
@@ -39,11 +40,13 @@
|
||||
|
||||
#include "BLI_blenlib.h"
|
||||
|
||||
#include "BKE_animsys.h"
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_global.h"
|
||||
#include "BKE_main.h"
|
||||
#include "BKE_screen.h"
|
||||
|
||||
#include "ED_keyframing.h"
|
||||
#include "ED_screen.h"
|
||||
#include "ED_util.h"
|
||||
#include "ED_types.h"
|
||||
@@ -158,15 +161,51 @@ static uiBlock *outliner_viewmenu(bContext *C, ARegion *ar, void *arg_unused)
|
||||
return block;
|
||||
}
|
||||
|
||||
#define B_REDR 1
|
||||
enum {
|
||||
B_REDR = 1,
|
||||
|
||||
B_KEYINGSET_CHANGE,
|
||||
B_KEYINGSET_REMOVE,
|
||||
} eOutlinerHeader_Events;
|
||||
|
||||
static void do_outliner_buttons(bContext *C, void *arg, int event)
|
||||
{
|
||||
ScrArea *sa= CTX_wm_area(C);
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
|
||||
switch(event) {
|
||||
case B_REDR:
|
||||
ED_area_tag_redraw(sa);
|
||||
break;
|
||||
|
||||
case B_KEYINGSET_CHANGE:
|
||||
/* 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);
|
||||
scene->active_keyingset= BLI_countlist(&scene->keyingsets);
|
||||
}
|
||||
|
||||
/* redraw regions with KeyingSet info */
|
||||
WM_event_add_notifier(C, NC_SCENE|ND_KEYINGSET, scene);
|
||||
break;
|
||||
|
||||
case B_KEYINGSET_REMOVE:
|
||||
/* remove the active KeyingSet */
|
||||
if (scene->active_keyingset) {
|
||||
KeyingSet *ks= BLI_findlink(&scene->keyingsets, scene->active_keyingset-1);
|
||||
|
||||
/* firstly free KeyingSet's data, then free the KeyingSet itself */
|
||||
if (ks) {
|
||||
BKE_keyingset_free(ks);
|
||||
BLI_freelinkN(&scene->keyingsets, ks);
|
||||
scene->active_keyingset= 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* redraw regions with KeyingSet info */
|
||||
WM_event_add_notifier(C, NC_SCENE|ND_KEYINGSET, scene);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,6 +213,7 @@ static void do_outliner_buttons(bContext *C, void *arg, int event)
|
||||
void outliner_header_buttons(const bContext *C, ARegion *ar)
|
||||
{
|
||||
ScrArea *sa= CTX_wm_area(C);
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
SpaceOops *soutliner= (SpaceOops*)CTX_wm_space_data(C);
|
||||
uiBlock *block;
|
||||
int xco, yco= 3, xmax;
|
||||
@@ -199,16 +239,66 @@ void outliner_header_buttons(const bContext *C, ARegion *ar)
|
||||
uiBlockSetEmboss(block, UI_EMBOSS);
|
||||
}
|
||||
|
||||
if(1) { // XXX soutliner->type==SO_OUTLINER) {
|
||||
//if (outliner->type==SO_OUTLINER) {
|
||||
/* data selector*/
|
||||
if(G.main->library.first)
|
||||
uiDefButS(block, MENU, B_REDR, "Outliner Display%t|Libraries %x7|All Scenes %x0|Current Scene %x1|Visible Layers %x2|Groups %x6|Same Types %x5|Selected %x3|Active %x4|Sequence %x10|Datablocks %x11|User Preferences %x12", xco, yco, 120, 20, &soutliner->outlinevis, 0, 0, 0, 0, "");
|
||||
else
|
||||
uiDefButS(block, MENU, B_REDR, "Outliner Display%t|All Scenes %x0|Current Scene %x1|Visible Layers %x2|Groups %x6|Same Types %x5|Selected %x3|Active %x4|Sequence %x10|Datablocks %x11|User Preferences %x12", xco, yco, 120, 20, &soutliner->outlinevis, 0, 0, 0, 0, "");
|
||||
}
|
||||
|
||||
uiDefButS(block, MENU, B_REDR, "Outliner Display%t|All Scenes %x0|Current Scene %x1|Visible Layers %x2|Groups %x6|Same Types %x5|Selected %x3|Active %x4|Sequence %x10|Datablocks %x11|User Preferences %x12", xco, yco, 120, 20, &soutliner->outlinevis, 0, 0, 0, 0, "");
|
||||
xco += 120;
|
||||
|
||||
/* KeyingSet editing buttons */
|
||||
if ((soutliner->flag & SO_HIDE_KEYINGSETINFO)==0 && (soutliner->outlinevis==SO_DATABLOCKS)) {
|
||||
KeyingSet *ks= NULL;
|
||||
char *menustr= NULL;
|
||||
|
||||
xco+= (int)(XIC*1.5);
|
||||
|
||||
if (scene->active_keyingset)
|
||||
ks= (KeyingSet *)BLI_findlink(&scene->keyingsets, scene->active_keyingset-1);
|
||||
|
||||
uiBlockBeginAlign(block);
|
||||
/* currently 'active' KeyingSet */
|
||||
menustr= ANIM_build_keyingsets_menu(&scene->keyingsets, 1);
|
||||
uiDefButI(block, MENU, B_KEYINGSET_CHANGE, menustr, xco,yco, 18,20, &scene->active_keyingset, 0, 0, 0, 0, "Browse Keying Sets");
|
||||
MEM_freeN(menustr);
|
||||
xco += 18;
|
||||
|
||||
/* currently 'active' KeyingSet - change name */
|
||||
if (ks) {
|
||||
/* active KeyingSet */
|
||||
uiDefBut(block, TEX, B_KEYINGSET_CHANGE,"", xco,yco,120,20, ks->name, 0, 63, 0, 0, "Name of Active Keying Set");
|
||||
xco += 120;
|
||||
uiDefIconBut(block, BUT, B_KEYINGSET_REMOVE, VICON_X, xco, yco, 20, 20, NULL, 0.0, 0.0, 0.0, 0.0, "Remove this Keying Set");
|
||||
xco += 20;
|
||||
}
|
||||
else {
|
||||
/* no active KeyingSet... so placeholder instead */
|
||||
uiDefBut(block, LABEL, 0,"<No Keying Set Active>", xco,yco,140,20, NULL, 0, 63, 0, 0, "Name of Active Keying Set");
|
||||
xco += 140;
|
||||
}
|
||||
uiBlockEndAlign(block);
|
||||
|
||||
/* current 'active' KeyingSet */
|
||||
if (ks) {
|
||||
xco += 5;
|
||||
|
||||
/* operator buttons to add/remove selected items from set */
|
||||
uiBlockBeginAlign(block);
|
||||
// XXX the icons here are temporary
|
||||
uiDefIconButO(block, BUT, "OUTLINER_OT_keyingset_remove_selected", WM_OP_INVOKE_REGION_WIN, ICON_ZOOMOUT, xco,yco,XIC,YIC, "Remove selected properties from active Keying Set (Alt-K)");
|
||||
xco += XIC;
|
||||
uiDefIconButO(block, BUT, "OUTLINER_OT_keyingset_add_selected", WM_OP_INVOKE_REGION_WIN, ICON_ZOOMIN, xco,yco,XIC,YIC, "Add selected properties to active Keying Set (K)");
|
||||
xco += XIC;
|
||||
uiBlockEndAlign(block);
|
||||
}
|
||||
|
||||
xco += XIC*2;
|
||||
}
|
||||
//}
|
||||
|
||||
/* always as last */
|
||||
UI_view2d_totRect_set(&ar->v2d, xco+XIC+100, ar->v2d.tot.ymax-ar->v2d.tot.ymin);
|
||||
UI_view2d_totRect_set(&ar->v2d, xco+XIC+100, (int)(ar->v2d.tot.ymax-ar->v2d.tot.ymin));
|
||||
|
||||
uiEndBlock(C, block);
|
||||
uiDrawBlock(C, block);
|
||||
|
||||
@@ -119,6 +119,8 @@ void outliner_select(struct SpaceOops *soops, struct ListBase *lb, int *index, s
|
||||
void draw_outliner(const struct bContext *C);
|
||||
|
||||
void OUTLINER_OT_activate_click(struct wmOperatorType *ot);
|
||||
void OUTLINER_OT_keyingset_add_selected(struct wmOperatorType *ot);
|
||||
void OUTLINER_OT_keyingset_remove_selected(struct wmOperatorType *ot);
|
||||
|
||||
#if 0
|
||||
extern void outliner_mouse_event(Scene *scene, ARegion *ar, SpaceOops *soops, short event);
|
||||
|
||||
@@ -44,6 +44,9 @@
|
||||
void outliner_operatortypes(void)
|
||||
{
|
||||
WM_operatortype_append(OUTLINER_OT_activate_click);
|
||||
|
||||
WM_operatortype_append(OUTLINER_OT_keyingset_add_selected);
|
||||
WM_operatortype_append(OUTLINER_OT_keyingset_remove_selected);
|
||||
}
|
||||
|
||||
void outliner_keymap(wmWindowManager *wm)
|
||||
@@ -51,6 +54,10 @@ void outliner_keymap(wmWindowManager *wm)
|
||||
ListBase *keymap= WM_keymap_listbase(wm, "Outliner", SPACE_OOPS, 0);
|
||||
|
||||
WM_keymap_verify_item(keymap, "OUTLINER_OT_activate_click", LEFTMOUSE, KM_PRESS, 0, 0);
|
||||
|
||||
/* keying sets - only for databrowse */
|
||||
WM_keymap_verify_item(keymap, "OUTLINER_OT_keyingset_add_selected", KKEY, KM_PRESS, 0, 0);
|
||||
WM_keymap_verify_item(keymap, "OUTLINER_OT_keyingset_remove_selected", KKEY, KM_PRESS, KM_ALT, 0);
|
||||
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user