merge with 2.5 at r18751
This commit is contained in:
@@ -205,10 +205,18 @@
|
||||
RelativePath="..\..\..\source\blender\editors\include\ED_datafiles.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\source\blender\editors\include\ED_editparticle.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\source\blender\editors\include\ED_fileselect.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\source\blender\editors\include\ED_fluidsim.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\source\blender\editors\include\ED_gpencil.h"
|
||||
>
|
||||
@@ -237,6 +245,10 @@
|
||||
RelativePath="..\..\..\source\blender\editors\include\ED_mesh.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\source\blender\editors\include\ED_node.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\source\blender\editors\include\ED_object.h"
|
||||
>
|
||||
@@ -558,6 +570,10 @@
|
||||
RelativePath="..\..\..\source\blender\editors\space_ipo\ipo_draw.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\source\blender\editors\space_ipo\ipo_edit.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\source\blender\editors\space_ipo\ipo_header.c"
|
||||
>
|
||||
@@ -566,6 +582,14 @@
|
||||
RelativePath="..\..\..\source\blender\editors\space_ipo\ipo_intern.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\source\blender\editors\space_ipo\ipo_ops.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\source\blender\editors\space_ipo\ipo_select.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\source\blender\editors\space_ipo\space_ipo.c"
|
||||
>
|
||||
@@ -706,6 +730,10 @@
|
||||
RelativePath="..\..\..\source\blender\editors\space_file\space_file.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\source\blender\editors\space_file\writeimage.c"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="space_info"
|
||||
@@ -1146,10 +1174,26 @@
|
||||
<Filter
|
||||
Name="curve"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\..\..\source\blender\editors\curve\curve_intern.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\source\blender\editors\curve\curve_ops.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\source\blender\editors\curve\editcurve.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\source\blender\editors\curve\editfont.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\source\blender\editors\curve\lorem.c"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="preview"
|
||||
@@ -1163,6 +1207,22 @@
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="physics"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\..\..\source\blender\editors\physics\ed_fluidsim.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\source\blender\editors\physics\editparticle.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\source\blender\editors\physics\physics_intern.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
|
||||
@@ -234,6 +234,10 @@
|
||||
RelativePath="..\..\..\source\blender\windowmanager\wm_cursors.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\source\blender\windowmanager\wm_draw.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\source\blender\windowmanager\wm_event_system.h"
|
||||
>
|
||||
|
||||
@@ -107,6 +107,7 @@ COMLIB += $(NAN_JPEG)/lib/libjpeg.a
|
||||
COMLIB += $(OCGDIR)/blender/gpu/$(DEBUG_DIR)libgpu.a
|
||||
COMLIB += $(NAN_GLEW)/lib/libglew.a
|
||||
COMLIB += $(NAN_ELBEEM)/lib/$(DEBUG_DIR)libelbeem.a
|
||||
COMLIB += $(OCGDIR)/blender/blenfont/$(DEBUG_DIR)libblenfont.a
|
||||
|
||||
ifneq ($(NAN_NO_KETSJI),true)
|
||||
COMLIB += $(OCGDIR)/gameengine/bloutines/$(DEBUG_DIR)libbloutines.a
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#
|
||||
# ***** END GPL LICENSE BLOCK *****
|
||||
|
||||
SUBDIRS(windowmanager editors avi nodes blenkernel blenlib blenloader blenpluginapi imbuf imbuf/intern/cineon gpu makesdna makesrna radiosity readblenfile render)
|
||||
SUBDIRS(windowmanager editors avi nodes blenkernel blenlib blenloader blenpluginapi imbuf imbuf/intern/cineon gpu makesdna makesrna radiosity readblenfile render blenfont)
|
||||
|
||||
IF(WITH_INTERNATIONAL)
|
||||
SUBDIRS(ftfont)
|
||||
|
||||
@@ -34,6 +34,7 @@ DIRS = windowmanager editors blenloader readblenfile
|
||||
DIRS += avi imbuf render radiosity blenlib blenkernel blenpluginapi
|
||||
DIRS += makesdna makesrna yafray
|
||||
DIRS += python nodes gpu
|
||||
DIRS += blenfont
|
||||
|
||||
ifeq ($(WITH_FREETYPE2), true)
|
||||
DIRS += ftfont
|
||||
|
||||
@@ -18,7 +18,8 @@ SConscript(['avi/SConscript',
|
||||
'readblenfile/SConscript',
|
||||
'render/SConscript',
|
||||
'nodes/SConscript',
|
||||
'windowmanager/SConscript'])
|
||||
'windowmanager/SConscript',
|
||||
'blenfont/SConscript'])
|
||||
|
||||
|
||||
|
||||
|
||||
52
source/blender/blenfont/BLF_api.h
Normal file
52
source/blender/blenfont/BLF_api.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* $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_API_H
|
||||
#define BLF_API_H
|
||||
|
||||
/* Read the .Blanguages file, return 1 on success or 0 if fails. */
|
||||
int BLF_lang_init(void);
|
||||
|
||||
/* Free the memory allocate for the .Blanguages. */
|
||||
void BLF_lang_exit(void);
|
||||
|
||||
/* Set the current Language. */
|
||||
void BLF_lang_set(int id);
|
||||
|
||||
/* Return a string with all the Language available. */
|
||||
char *BLF_lang_pup(void);
|
||||
|
||||
/* Return the number of invalid lines in the .Blanguages file,
|
||||
* zero means no error found.
|
||||
*/
|
||||
int BLF_lang_error(void);
|
||||
|
||||
/* Return the code string for the specified language code. */
|
||||
char *BLF_lang_find_code(short langid);
|
||||
|
||||
#endif /* BLF_API_H */
|
||||
38
source/blender/blenfont/CMakeLists.txt
Normal file
38
source/blender/blenfont/CMakeLists.txt
Normal file
@@ -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) 2008, Blender Foundation
|
||||
# All rights reserved.
|
||||
#
|
||||
# The Original Code is: all of this file.
|
||||
#
|
||||
# ***** END GPL LICENSE BLOCK *****
|
||||
|
||||
FILE(GLOB SRC intern/*.c)
|
||||
|
||||
#SET(INC . intern ../../../intern/guardedalloc ../blenlib ../blenkernel ../makedna
|
||||
|
||||
SET(INC
|
||||
../../../intern/guardedalloc ../blenlib ../makesdna
|
||||
../blenkernel ../ftfont
|
||||
)
|
||||
|
||||
IF(WITH_INTERNATIONAL)
|
||||
ADD_DEFINITIONS(-DWITH_FREETYPE2)
|
||||
ENDIF(WITH_INTERNATIONAL)
|
||||
|
||||
BLENDERLIB(bf_blenfont "${SRC}" "${INC}")
|
||||
30
source/blender/blenfont/Makefile
Normal file
30
source/blender/blenfont/Makefile
Normal file
@@ -0,0 +1,30 @@
|
||||
#
|
||||
# $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): none yet.
|
||||
#
|
||||
# ***** END GPL LICENSE BLOCK *****
|
||||
|
||||
SOURCEDIR = source/blender/blenfont
|
||||
DIRS = intern
|
||||
|
||||
include nan_subdirs.mk
|
||||
14
source/blender/blenfont/SConscript
Normal file
14
source/blender/blenfont/SConscript
Normal file
@@ -0,0 +1,14 @@
|
||||
#!/usr/bin/python
|
||||
import sys
|
||||
Import ('env')
|
||||
|
||||
sources = env.Glob('intern/*.c')
|
||||
|
||||
incs = '. intern #/intern/guardedalloc ../blenkernel ../blenlib ../makesdna ../ftfont'
|
||||
|
||||
defs = ''
|
||||
|
||||
if env['WITH_BF_INTERNATIONAL']:
|
||||
defs += ' WITH_FREETYPE2'
|
||||
|
||||
env.BlenderLib ( 'bf_blenfont', sources, Split(incs), Split(defs), libtype=['core'], priority=[210] )
|
||||
42
source/blender/blenfont/intern/Makefile
Normal file
42
source/blender/blenfont/intern/Makefile
Normal file
@@ -0,0 +1,42 @@
|
||||
#
|
||||
# $Id:
|
||||
#
|
||||
# ***** BEGIN GPL LICENSE BLOCK *****
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software Foundation,
|
||||
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
# The Original Code is Copyright (C) 2008 Blender Foundation.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Contributor(s): none yet.
|
||||
#
|
||||
# ***** END GPL LICENSE BLOCK *****
|
||||
#
|
||||
#
|
||||
|
||||
LIBNAME = blenfont
|
||||
DIR = $(OCGDIR)/blender/blenfont
|
||||
|
||||
include nan_compile.mk
|
||||
|
||||
CFLAGS += $(LEVEL_1_C_WARNINGS)
|
||||
|
||||
CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include
|
||||
CPPFLAGS += -I../../makesdna
|
||||
CPPFLAGS += -I../../blenlib
|
||||
CPPFLAGS += -I../../blenkernel
|
||||
CPPFLAGS += -I../../ftfont
|
||||
|
||||
CPPFLAGS += -I..
|
||||
45
source/blender/blenfont/intern/blf_internal_types.h
Normal file
45
source/blender/blenfont/intern/blf_internal_types.h
Normal file
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* $Id$
|
||||
*
|
||||
* ***** BEGIN GPL LICENSE BLOCK *****
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* The Original Code is Copyright (C) 2008 Blender Foundation.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Contributor(s): Blender Foundation.
|
||||
*
|
||||
* ***** END GPL LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
#ifndef BLF_INTERNAL_TYPES_H
|
||||
#define BLF_INTERNAL_TYPES_H
|
||||
|
||||
typedef struct LangBLF {
|
||||
struct LangBLF *next;
|
||||
struct LangBLF *prev;
|
||||
|
||||
char *line;
|
||||
char *language;
|
||||
char *code;
|
||||
int id;
|
||||
} LangBLF;
|
||||
|
||||
#define BLF_LANG_FIND_BY_LINE 0
|
||||
#define BLF_LANG_FIND_BY_LANGUAGE 1
|
||||
#define BLF_LANG_FIND_BY_CODE 2
|
||||
|
||||
#endif /* BLF_INTERNAL_TYPES_H */
|
||||
246
source/blender/blenfont/intern/blf_lang.c
Normal file
246
source/blender/blenfont/intern/blf_lang.c
Normal file
@@ -0,0 +1,246 @@
|
||||
/**
|
||||
* $Id$
|
||||
*
|
||||
* ***** BEGIN GPL LICENSE BLOCK *****
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* The Original Code is Copyright (C) 2008 Blender Foundation.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Contributor(s): Blender Foundation.
|
||||
*
|
||||
* ***** END GPL LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
#include <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"
|
||||
|
||||
// XXX 2.50 Remove this later.
|
||||
#ifdef WITH_FREETYPE2
|
||||
#include "FTF_Api.h"
|
||||
#endif
|
||||
|
||||
static ListBase global_lang= { NULL, NULL };
|
||||
static int global_tot_lang= 0;
|
||||
static int global_err_lang= 0;
|
||||
|
||||
int BLF_lang_error(void)
|
||||
{
|
||||
return(global_err_lang);
|
||||
}
|
||||
|
||||
char *BLF_lang_pup(void)
|
||||
{
|
||||
LangBLF *lme;
|
||||
static char string[1024];
|
||||
static char tmp[1024];
|
||||
|
||||
if(global_tot_lang == 0)
|
||||
sprintf(string, "Choose Language: %%t|Language: English %%x0");
|
||||
else {
|
||||
lme= global_lang.first;
|
||||
sprintf(string, "Choose Language: %%t");
|
||||
while (lme) {
|
||||
sprintf(tmp, "|Language: %s %%x%d", lme->language, lme->id);
|
||||
strcat(string, tmp);
|
||||
lme= lme->next;
|
||||
}
|
||||
}
|
||||
|
||||
return(string);
|
||||
}
|
||||
|
||||
LangBLF *blf_lang_find_by_id(short langid)
|
||||
{
|
||||
LangBLF *p;
|
||||
|
||||
p= global_lang.first;
|
||||
while (p) {
|
||||
if (p->id == langid)
|
||||
return(p);
|
||||
p= p->next;
|
||||
}
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
char *BLF_lang_find_code(short langid)
|
||||
{
|
||||
LangBLF *p;
|
||||
|
||||
p= blf_lang_find_by_id(langid);
|
||||
if (p)
|
||||
return(p->code);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
void BLF_lang_set(int id)
|
||||
{
|
||||
#ifdef WITH_FREETYPE2
|
||||
LangBLF *lme;
|
||||
|
||||
// XXX 2.50 Remove this later, with ftfont
|
||||
lme= blf_lang_find_by_id(id);
|
||||
if(lme) FTF_SetLanguage(lme->code);
|
||||
else FTF_SetLanguage("en_US");
|
||||
#endif
|
||||
}
|
||||
|
||||
static void blf_lang_split(char *line, LangBLF* lme)
|
||||
{
|
||||
char *dpointchar= strchr(line, ':');
|
||||
|
||||
if (dpointchar) {
|
||||
lme->code= BLI_strdup(dpointchar+1);
|
||||
*(dpointchar)=0;
|
||||
lme->language= BLI_strdup(line);
|
||||
} else {
|
||||
lme->code= NULL;
|
||||
lme->language= NULL;
|
||||
/* XXX 2.50 bad call error("Invalid language file");
|
||||
* If we set this to NULL, the function blf_lang_new
|
||||
* drop the line and increment the error lang value
|
||||
* so the init code can call BLF_lang_error to get
|
||||
* the number of invalid lines and show the error.
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
LangBLF *blf_lang_find(char *s, int find_by)
|
||||
{
|
||||
LangBLF *p;
|
||||
|
||||
p= global_lang.first;
|
||||
while (p) {
|
||||
if (find_by == BLF_LANG_FIND_BY_LINE) {
|
||||
if (BLI_streq(s, p->line))
|
||||
return(p);
|
||||
}
|
||||
else if (find_by == BLF_LANG_FIND_BY_CODE) {
|
||||
if (BLI_streq(s, p->code))
|
||||
return(p);
|
||||
}
|
||||
else if (find_by == BLF_LANG_FIND_BY_LANGUAGE) {
|
||||
if (BLI_streq(s, p->language))
|
||||
return(p);
|
||||
}
|
||||
p= p->next;
|
||||
}
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
static void blf_lang_new(char *line)
|
||||
{
|
||||
LangBLF *lme;
|
||||
|
||||
lme= blf_lang_find(line, BLF_LANG_FIND_BY_LINE);
|
||||
if (!lme) {
|
||||
lme= MEM_mallocN(sizeof(LangBLF), "blf_lang_new");
|
||||
lme->next= NULL;
|
||||
lme->prev= NULL;
|
||||
lme->line = BLI_strdup(line);
|
||||
blf_lang_split(line, lme);
|
||||
|
||||
if (lme->code && lme->language) {
|
||||
lme->id = global_tot_lang;
|
||||
global_tot_lang++;
|
||||
BLI_addhead(&global_lang, lme);
|
||||
}
|
||||
else {
|
||||
global_err_lang++;
|
||||
MEM_freeN(lme->line);
|
||||
MEM_freeN(lme);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int BLF_lang_init(void)
|
||||
{
|
||||
char name[FILE_MAXDIR+FILE_MAXFILE];
|
||||
LinkNode *l, *lines;
|
||||
|
||||
/* .Blanguages, http://www.blender3d.org/cms/Installation_Policy.352.0.html*/
|
||||
#if defined (__APPLE__) || (WIN32)
|
||||
BLI_make_file_string("/", name, BLI_gethome(), ".Blanguages");
|
||||
#else
|
||||
BLI_make_file_string("/", name, BLI_gethome(), ".blender/.Blanguages");
|
||||
#endif
|
||||
|
||||
lines= BLI_read_file_as_lines(name);
|
||||
|
||||
if(lines == NULL) {
|
||||
/* If not found in home, try current dir
|
||||
* (Resources folder of app bundle on OS X) */
|
||||
#if defined (__APPLE__)
|
||||
char *bundlePath = BLI_getbundle();
|
||||
strcpy(name, bundlePath);
|
||||
strcat(name, "/Contents/Resources/.Blanguages");
|
||||
#else
|
||||
/* Check the CWD. Takes care of the case where users
|
||||
* unpack blender tarball; cd blender-dir; ./blender */
|
||||
strcpy(name, ".blender/.Blanguages");
|
||||
#endif
|
||||
lines= BLI_read_file_as_lines(name);
|
||||
|
||||
if(lines == NULL) {
|
||||
/* If not found in .blender, try current dir */
|
||||
strcpy(name, ".Blanguages");
|
||||
lines= BLI_read_file_as_lines(name);
|
||||
if(lines == NULL) {
|
||||
// XXX 2.50 if(G.f & G_DEBUG)
|
||||
printf("File .Blanguages not found\n");
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (l= lines; l; l= l->next) {
|
||||
char *line= l->link;
|
||||
|
||||
if (!BLI_streq(line, "")) {
|
||||
blf_lang_new(line);
|
||||
}
|
||||
}
|
||||
|
||||
BLI_free_file_lines(lines);
|
||||
return(1);
|
||||
}
|
||||
|
||||
void BLF_lang_exit(void)
|
||||
{
|
||||
LangBLF *p;
|
||||
|
||||
while (global_lang.first) {
|
||||
p= global_lang.first;
|
||||
BLI_remlink(&global_lang, p);
|
||||
MEM_freeN(p->line);
|
||||
MEM_freeN(p->language);
|
||||
MEM_freeN(p->code);
|
||||
MEM_freeN(p);
|
||||
}
|
||||
}
|
||||
@@ -123,17 +123,8 @@ void update_pose_constraint_flags(struct bPose *pose);
|
||||
// XXX to be depreceated for a more general solution in animsys...
|
||||
void framechange_poses_clear_unkeyed(void);
|
||||
|
||||
/**
|
||||
* Set the pose channels from the given action.
|
||||
*/
|
||||
// XXX old crap
|
||||
void extract_pose_from_action(struct bPose *pose, struct bAction *act, float ctime);
|
||||
|
||||
/**
|
||||
* Get the effects of the given action using a workob
|
||||
*/
|
||||
// XXX old crap, used for action constraint though!
|
||||
void what_does_obaction(struct Scene *scene, struct Object *ob, struct Object *workob, struct bAction *act, float cframe);
|
||||
/* Used for the Action Constraint */
|
||||
void what_does_obaction(struct Scene *scene, struct Object *ob, struct Object *workob, struct bPose *pose, struct bAction *act, float cframe);
|
||||
|
||||
/* exported for game engine */
|
||||
void blend_poses(struct bPose *dst, struct bPose *src, float srcweight, short mode);
|
||||
|
||||
@@ -25,6 +25,7 @@ void bezt_add_to_cfra_elem(ListBase *lb, struct BezTriple *bezt);
|
||||
/* ************** F-Curve Drivers ***************** */
|
||||
|
||||
void fcurve_free_driver(struct FCurve *fcu);
|
||||
struct ChannelDriver *fcurve_copy_driver(struct ChannelDriver *driver);
|
||||
|
||||
/* ************** F-Curve Modifiers *************** */
|
||||
|
||||
|
||||
@@ -142,6 +142,8 @@ void IDP_FreeIterBeforeEnd(void *vself);
|
||||
struct IDProperty *IDP_GetProperties(struct ID *id, int create_if_needed);
|
||||
struct IDProperty *IDP_CopyProperty(struct IDProperty *prop);
|
||||
|
||||
int IDP_EqualsProperties(struct IDProperty *prop1, struct IDProperty *prop2);
|
||||
|
||||
/*
|
||||
Allocate a new ID.
|
||||
|
||||
|
||||
@@ -148,6 +148,12 @@ void BKE_image_memorypack(struct Image *ima);
|
||||
/* prints memory statistics for images */
|
||||
void BKE_image_print_memlist(void);
|
||||
|
||||
/* empty image block, of similar type and filename */
|
||||
struct Image *BKE_image_copy(struct Image *ima);
|
||||
|
||||
/* merge source into dest, and free source */
|
||||
void BKE_image_merge(struct Image *dest, struct Image *source);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -106,6 +106,7 @@ typedef struct bNodeType {
|
||||
#define NODE_BREAK 2
|
||||
#define NODE_FINISHED 4
|
||||
#define NODE_FREEBUFS 8
|
||||
#define NODE_SKIPPED 16
|
||||
|
||||
/* nodetype->nclass, for add-menu and themes */
|
||||
#define NODE_CLASS_INPUT 0
|
||||
@@ -148,6 +149,11 @@ void ntreeInitPreview(struct bNodeTree *, int xsize, int ysize);
|
||||
void ntreeClearPreview(struct bNodeTree *ntree);
|
||||
|
||||
void ntreeFreeCache(struct bNodeTree *ntree);
|
||||
|
||||
/* calls allowing threaded composite */
|
||||
struct bNodeTree *ntreeLocalize(struct bNodeTree *ntree);
|
||||
void ntreeLocalSync(struct bNodeTree *localtree, struct bNodeTree *ntree);
|
||||
void ntreeLocalMerge(struct bNodeTree *localtree, struct bNodeTree *ntree);
|
||||
|
||||
/* ************** GENERIC API, NODES *************** */
|
||||
|
||||
|
||||
@@ -30,16 +30,22 @@
|
||||
#ifndef BKE_SCULPT_H
|
||||
#define BKE_SCULPT_H
|
||||
|
||||
struct NumInput;
|
||||
struct RadialControl;
|
||||
struct Scene;
|
||||
struct MFace;
|
||||
struct MultireModifierData;
|
||||
struct MVert;
|
||||
struct Sculpt;
|
||||
struct SculptSession;
|
||||
struct StrokeCache;
|
||||
|
||||
typedef struct SculptSession {
|
||||
struct ProjVert *projverts;
|
||||
|
||||
/* Mesh data (not copied) can come either directly from a Mesh, or from a MultiresDM */
|
||||
struct MultiresModifierData *multires; /* Special handling for multires meshes */
|
||||
struct MVert *mvert;
|
||||
struct MFace *mface;
|
||||
int totvert, totface;
|
||||
float *face_normals;
|
||||
|
||||
/* Mesh connectivity */
|
||||
struct ListBase *fmap;
|
||||
struct IndexNode *fmap_mem;
|
||||
@@ -55,8 +61,6 @@ typedef struct SculptSession {
|
||||
|
||||
void *cursor; /* wm handle */
|
||||
|
||||
struct RadialControl *radialcontrol;
|
||||
|
||||
struct SculptStroke *stroke;
|
||||
|
||||
struct StrokeCache *cache;
|
||||
|
||||
@@ -140,6 +140,7 @@ struct SeqEffectHandle {
|
||||
void seq_free_sequence(struct Editing *ed, struct Sequence *seq);
|
||||
void seq_free_strip(struct Strip *strip);
|
||||
void seq_free_editing(struct Editing *ed);
|
||||
struct Editing *seq_give_editing(struct Scene *scene, int alloc);
|
||||
char *give_seqname(struct Sequence *seq);
|
||||
struct ImBuf *give_ibuf_seq(struct Scene *scene, int rectx, int recty, int cfra, int chanshown);
|
||||
struct ImBuf *give_ibuf_seq_threaded(struct Scene *scene, int rectx, int recty, int cfra, int chanshown);
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
#include "DNA_object_types.h"
|
||||
#include "DNA_scene_types.h"
|
||||
|
||||
#include "BKE_animsys.h"
|
||||
#include "BKE_action.h"
|
||||
#include "BKE_anim.h"
|
||||
#include "BKE_armature.h"
|
||||
@@ -610,46 +611,6 @@ void extract_pose_from_pose(bPose *pose, const bPose *src)
|
||||
}
|
||||
}
|
||||
|
||||
/* Pose should exist, can have any number of channels too (used for constraint) */
|
||||
void extract_pose_from_action(bPose *pose, bAction *act, float ctime)
|
||||
{
|
||||
#if 0 // XXX old animation system
|
||||
bActionChannel *achan;
|
||||
bPoseChannel *pchan;
|
||||
Ipo *ipo;
|
||||
|
||||
if (!act)
|
||||
return;
|
||||
if (!pose)
|
||||
return;
|
||||
|
||||
/* Copy the data from the action into the pose */
|
||||
for (pchan= pose->chanbase.first; pchan; pchan=pchan->next) {
|
||||
/* skip this pose channel if it has been tagged as having unkeyed poses */
|
||||
if ((pchan->bone) && (pchan->bone->flag & BONE_UNKEYED))
|
||||
continue;
|
||||
|
||||
/* get action channel and clear pchan-transform flags */
|
||||
achan= get_action_channel(act, pchan->name);
|
||||
pchan->flag &= ~(POSE_LOC|POSE_ROT|POSE_SIZE);
|
||||
|
||||
if (achan) {
|
||||
ipo = achan->ipo;
|
||||
if (ipo) {
|
||||
/* Evaluates and sets the internal ipo value */
|
||||
calc_ipo(ipo, ctime);
|
||||
/* This call also sets the pchan flags */
|
||||
execute_action_ipo(achan, pchan);
|
||||
}
|
||||
/* 0 = do all ipos, not only drivers */
|
||||
do_constraint_channels(&pchan->constraints, &achan->constraintChannels, ctime, 0);
|
||||
}
|
||||
}
|
||||
#endif // XXX old animation system
|
||||
|
||||
pose->ctime= ctime; /* used for cyclic offset matching */
|
||||
}
|
||||
|
||||
/* for do_all_pose_actions, clears the pose. Now also exported for proxy and tools */
|
||||
void rest_pose(bPose *pose)
|
||||
{
|
||||
@@ -708,6 +669,50 @@ void copy_pose_result(bPose *to, bPose *from)
|
||||
}
|
||||
}
|
||||
|
||||
/* For the calculation of the effects of an Action at the given frame on an object
|
||||
* This is currently only used for the Action Constraint
|
||||
*/
|
||||
void what_does_obaction (Scene *scene, Object *ob, Object *workob, bPose *pose, bAction *act, float cframe)
|
||||
{
|
||||
AnimData adt;
|
||||
|
||||
/* clear workob and animdata */
|
||||
clear_workob(workob);
|
||||
memset(&adt, 0, sizeof(AnimData));
|
||||
|
||||
/* init workob */
|
||||
Mat4CpyMat4(workob->obmat, ob->obmat);
|
||||
Mat4CpyMat4(workob->parentinv, ob->parentinv);
|
||||
Mat4CpyMat4(workob->constinv, ob->constinv);
|
||||
workob->parent= ob->parent;
|
||||
workob->track= ob->track;
|
||||
|
||||
workob->trackflag= ob->trackflag;
|
||||
workob->upflag= ob->upflag;
|
||||
|
||||
workob->partype= ob->partype;
|
||||
workob->par1= ob->par1;
|
||||
workob->par2= ob->par2;
|
||||
workob->par3= ob->par3;
|
||||
|
||||
workob->constraints.first = ob->constraints.first;
|
||||
workob->constraints.last = ob->constraints.last;
|
||||
|
||||
workob->pose= pose; /* need to set pose too, since this is used for both types of Action Constraint */
|
||||
|
||||
strcpy(workob->parsubstr, ob->parsubstr);
|
||||
strcpy(workob->id.name, "OB<ConstrWorkOb>"); /* we don't use real object name, otherwise RNA screws with the real thing */
|
||||
|
||||
/* init animdata, and attach to workob */
|
||||
workob->adt= &adt;
|
||||
|
||||
adt.recalc= ADT_RECALC_ANIM;
|
||||
adt.action= act;
|
||||
|
||||
/* execute effects of Action on to workob (or it's PoseChannels) */
|
||||
BKE_animsys_evaluate_animdata(workob, &adt, cframe, ADT_RECALC_ANIM);
|
||||
}
|
||||
|
||||
/* ********** NLA with non-poses works with ipo channels ********** */
|
||||
|
||||
#if 0 // XXX OLD ANIMATION SYSTEM (TO BE REMOVED)
|
||||
@@ -1162,45 +1167,6 @@ static Object *get_parent_path(Object *ob)
|
||||
|
||||
/* ************** do the action ************ */
|
||||
|
||||
/* For the calculation of the effects of an action at the given frame on an object
|
||||
* This is currently only used for the action constraint
|
||||
*/
|
||||
void what_does_obaction (Scene *scene, Object *ob, Object *workob, bAction *act, float cframe)
|
||||
{
|
||||
ListBase tchanbase= {NULL, NULL};
|
||||
|
||||
clear_workob(workob);
|
||||
Mat4CpyMat4(workob->obmat, ob->obmat);
|
||||
Mat4CpyMat4(workob->parentinv, ob->parentinv);
|
||||
Mat4CpyMat4(workob->constinv, ob->constinv);
|
||||
workob->parent= ob->parent;
|
||||
workob->track= ob->track;
|
||||
|
||||
workob->trackflag= ob->trackflag;
|
||||
workob->upflag= ob->upflag;
|
||||
|
||||
workob->partype= ob->partype;
|
||||
workob->par1= ob->par1;
|
||||
workob->par2= ob->par2;
|
||||
workob->par3= ob->par3;
|
||||
|
||||
workob->constraints.first = ob->constraints.first;
|
||||
workob->constraints.last = ob->constraints.last;
|
||||
|
||||
strcpy(workob->parsubstr, ob->parsubstr);
|
||||
strcpy(workob->id.name, ob->id.name);
|
||||
|
||||
/* extract_ipochannels_from_action needs id's! */
|
||||
workob->action= act;
|
||||
|
||||
extract_ipochannels_from_action(&tchanbase, &workob->id, act, "Object", bsystem_time(scene, workob, cframe, 0.0));
|
||||
|
||||
if (tchanbase.first) {
|
||||
execute_ipochannels(&tchanbase);
|
||||
BLI_freelistN(&tchanbase);
|
||||
}
|
||||
}
|
||||
|
||||
/* ----- nla, etc. --------- */
|
||||
|
||||
static void do_nla(Scene *scene, Object *ob, int blocktype)
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "BKE_animsys.h"
|
||||
#include "BKE_action.h"
|
||||
#include "BKE_fcurve.h"
|
||||
#include "BKE_global.h"
|
||||
#include "BKE_main.h"
|
||||
#include "BKE_utildefines.h"
|
||||
|
||||
@@ -183,8 +184,8 @@ short animsys_remap_path (AnimMapper *remap, char *path, char **dst)
|
||||
}
|
||||
|
||||
|
||||
/* Write the given value to a setting using RNA */
|
||||
static void animsys_write_rna_setting (PointerRNA *ptr, char *path, int array_index, float value)
|
||||
/* Write the given value to a setting using RNA, and return success */
|
||||
static short animsys_write_rna_setting (PointerRNA *ptr, char *path, int array_index, float value)
|
||||
{
|
||||
PropertyRNA *prop;
|
||||
PointerRNA new_ptr;
|
||||
@@ -222,6 +223,21 @@ static void animsys_write_rna_setting (PointerRNA *ptr, char *path, int array_in
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* successful */
|
||||
// XXX should the unhandled case also be successful?
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
/* failed to get path */
|
||||
// XXX don't tag as failed yet though, as there are some legit situations (Action Constraint)
|
||||
// where some channels will not exist, but shouldn't lock up Action
|
||||
if (G.f & G_DEBUG) {
|
||||
printf("Animato: Invalid path. ID = '%s', '%s [%d]' \n",
|
||||
(ptr && ptr->id.data) ? (((ID *)ptr->id.data)->name+2) : "<No ID>",
|
||||
path, array_index);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -282,7 +298,7 @@ static void animsys_evaluate_drivers (PointerRNA *ptr, AnimData *adt, float ctim
|
||||
if ((fcu->flag & (FCURVE_MUTED|FCURVE_DISABLED)) == 0)
|
||||
{
|
||||
/* check if driver itself is tagged for recalculation */
|
||||
if ((driver) && (driver->flag & DRIVER_FLAG_RECALC)) {
|
||||
if ((driver) /*&& (driver->flag & DRIVER_FLAG_RECALC)*/) { // XXX driver recalc flag is not set yet by depsgraph!
|
||||
/* evaluate this using values set already in other places */
|
||||
// NOTE: for 'layering' option later on, we should check if we should remove old value before adding new to only be done when drivers only changed
|
||||
calculate_fcurve(fcu, ctime);
|
||||
@@ -619,7 +635,8 @@ void BKE_animsys_evaluate_all_animation (Main *main, float ctime)
|
||||
{
|
||||
ID *id;
|
||||
|
||||
printf("Evaluate all animation - %f \n", ctime);
|
||||
if (G.f & G_DEBUG)
|
||||
printf("Evaluate all animation - %f \n", ctime);
|
||||
|
||||
/* macro for less typing */
|
||||
#define EVAL_ANIM_IDS(first) \
|
||||
|
||||
@@ -363,7 +363,7 @@ void bone_flip_name (char *name, int strip_number)
|
||||
*/
|
||||
void bone_autoside_name (char *name, int strip_number, short axis, float head, float tail)
|
||||
{
|
||||
int len;
|
||||
unsigned int len;
|
||||
char basename[32]={""};
|
||||
char extension[5]={""};
|
||||
|
||||
@@ -606,7 +606,7 @@ Mat4 *b_bone_spline_setup(bPoseChannel *pchan, int rest)
|
||||
Mat3Inv(imat3, mat3);
|
||||
Mat3MulMat3(mat3, result, imat3); // the matrix transforming vec_roll to desired roll
|
||||
|
||||
roll1= atan2(mat3[2][0], mat3[2][2]);
|
||||
roll1= (float)atan2(mat3[2][0], mat3[2][2]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -639,7 +639,7 @@ Mat4 *b_bone_spline_setup(bPoseChannel *pchan, int rest)
|
||||
Mat3Inv(imat3, mat3);
|
||||
Mat3MulMat3(mat3, imat3, result); // the matrix transforming vec_roll to desired roll
|
||||
|
||||
roll2= atan2(mat3[2][0], mat3[2][2]);
|
||||
roll2= (float)atan2(mat3[2][0], mat3[2][2]);
|
||||
|
||||
/* and only now negate handle */
|
||||
VecMulf(h2, -hlength2);
|
||||
@@ -784,7 +784,7 @@ float distfactor_to_bone (float vec[3], float b1[3], float b2[3], float rad1, fl
|
||||
|
||||
if(l!=0.0f) {
|
||||
rad= a/l;
|
||||
rad= rad*rad2 + (1.0-rad)*rad1;
|
||||
rad= rad*rad2 + (1.0f-rad)*rad1;
|
||||
}
|
||||
else rad= rad1;
|
||||
}
|
||||
@@ -798,8 +798,8 @@ float distfactor_to_bone (float vec[3], float b1[3], float b2[3], float rad1, fl
|
||||
if(rdist==0.0f || dist >= l)
|
||||
return 0.0f;
|
||||
else {
|
||||
a= sqrt(dist)-rad;
|
||||
return 1.0-( a*a )/( rdist*rdist );
|
||||
a= (float)sqrt(dist)-rad;
|
||||
return 1.0f-( a*a )/( rdist*rdist );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1301,7 +1301,7 @@ void mat3_to_vec_roll(float mat[][3], float *vec, float *roll)
|
||||
Mat3Inv(vecmatinv, vecmat);
|
||||
Mat3MulMat3(rollmat, vecmatinv, mat);
|
||||
|
||||
*roll= atan2(rollmat[2][0], rollmat[2][2]);
|
||||
*roll= (float)atan2(rollmat[2][0], rollmat[2][2]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1333,7 +1333,7 @@ void vec_roll_to_mat3(float *vec, float roll, float mat[][3])
|
||||
float updown;
|
||||
|
||||
/* point same direction, or opposite? */
|
||||
updown = ( Inpf (target,nor) > 0 ) ? 1.0 : -1.0;
|
||||
updown = ( Inpf (target,nor) > 0 ) ? 1.0f : -1.0f;
|
||||
|
||||
/* I think this should work ... */
|
||||
bMatrix[0][0]=updown; bMatrix[0][1]=0.0; bMatrix[0][2]=0.0;
|
||||
@@ -1789,10 +1789,10 @@ static void execute_posetree(Object *ob, PoseTree *tree)
|
||||
IK_SetStiffness(seg, IK_Y, pchan->stiffness[1]);
|
||||
IK_SetStiffness(seg, IK_Z, pchan->stiffness[2]);
|
||||
|
||||
if(tree->stretch && (pchan->ikstretch > 0.0)) {
|
||||
if(tree->stretch && (pchan->ikstretch > 0.0f)) {
|
||||
float ikstretch = pchan->ikstretch*pchan->ikstretch;
|
||||
IK_SetStiffness(seg, IK_TRANS_Y, MIN2(1.0-ikstretch, 0.99));
|
||||
IK_SetLimit(seg, IK_TRANS_Y, 0.001, 1e10);
|
||||
IK_SetStiffness(seg, IK_TRANS_Y, MIN2(1.0f-ikstretch, 0.99f));
|
||||
IK_SetLimit(seg, IK_TRANS_Y, 0.001f, 1e10);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1858,10 +1858,10 @@ static void execute_posetree(Object *ob, PoseTree *tree)
|
||||
}
|
||||
|
||||
/* do we need blending? */
|
||||
if (!resultblend && target->con->enforce!=1.0) {
|
||||
if (!resultblend && target->con->enforce!=1.0f) {
|
||||
float q1[4], q2[4], q[4];
|
||||
float fac= target->con->enforce;
|
||||
float mfac= 1.0-fac;
|
||||
float mfac= 1.0f-fac;
|
||||
|
||||
pchan= tree->pchan[target->tip];
|
||||
|
||||
@@ -1884,13 +1884,13 @@ static void execute_posetree(Object *ob, PoseTree *tree)
|
||||
|
||||
iktarget= iktree[target->tip];
|
||||
|
||||
if(data->weight != 0.0) {
|
||||
if(data->weight != 0.0f) {
|
||||
if(poleconstrain)
|
||||
IK_SolverSetPoleVectorConstraint(solver, iktarget, goalpos,
|
||||
polepos, data->poleangle*M_PI/180, (poleangledata == data));
|
||||
polepos, data->poleangle*(float)M_PI/180.0f, (poleangledata == data));
|
||||
IK_SolverAddGoal(solver, iktarget, goalpos, data->weight);
|
||||
}
|
||||
if((data->flag & CONSTRAINT_IK_ROT) && (data->orientweight != 0.0))
|
||||
if((data->flag & CONSTRAINT_IK_ROT) && (data->orientweight != 0.0f))
|
||||
if((data->flag & CONSTRAINT_IK_AUTO)==0)
|
||||
IK_SolverAddGoalOrientation(solver, iktarget, goalrot,
|
||||
data->orientweight);
|
||||
@@ -1900,7 +1900,7 @@ static void execute_posetree(Object *ob, PoseTree *tree)
|
||||
IK_Solve(solver, 0.0f, tree->iterations);
|
||||
|
||||
if(poleangledata)
|
||||
poleangledata->poleangle= IK_SolverGetPoleAngle(solver)*180/M_PI;
|
||||
poleangledata->poleangle= IK_SolverGetPoleAngle(solver)*180.0f/(float)M_PI;
|
||||
|
||||
IK_FreeSolver(solver);
|
||||
|
||||
@@ -1917,20 +1917,20 @@ static void execute_posetree(Object *ob, PoseTree *tree)
|
||||
float parentstretch, stretch;
|
||||
|
||||
pchan= tree->pchan[a];
|
||||
parentstretch= (tree->parent[a] >= 0)? ikstretch[tree->parent[a]]: 1.0;
|
||||
parentstretch= (tree->parent[a] >= 0)? ikstretch[tree->parent[a]]: 1.0f;
|
||||
|
||||
if(tree->stretch && (pchan->ikstretch > 0.0)) {
|
||||
if(tree->stretch && (pchan->ikstretch > 0.0f)) {
|
||||
float trans[3], length;
|
||||
|
||||
IK_GetTranslationChange(iktree[a], trans);
|
||||
length= pchan->bone->length*VecLength(pchan->pose_mat[1]);
|
||||
|
||||
ikstretch[a]= (length == 0.0)? 1.0: (trans[1]+length)/length;
|
||||
ikstretch[a]= (length == 0.0f)? 1.0f: (trans[1]+length)/length;
|
||||
}
|
||||
else
|
||||
ikstretch[a] = 1.0;
|
||||
ikstretch[a] = 1.0f;
|
||||
|
||||
stretch= (parentstretch == 0.0)? 1.0: ikstretch[a]/parentstretch;
|
||||
stretch= (parentstretch == 0.0f)? 1.0f: ikstretch[a]/parentstretch;
|
||||
|
||||
VecMulf(tree->basis_change[a][0], stretch);
|
||||
VecMulf(tree->basis_change[a][1], stretch);
|
||||
@@ -2035,7 +2035,7 @@ static void do_strip_modifiers(Scene *scene, Object *armob, Bone *bone, bPoseCha
|
||||
{
|
||||
bActionModifier *amod;
|
||||
bActionStrip *strip, *strip2;
|
||||
float scene_cfra= scene->r.cfra;
|
||||
float scene_cfra= (float)scene->r.cfra;
|
||||
int do_modif;
|
||||
|
||||
for (strip=armob->nlastrips.first; strip; strip=strip->next) {
|
||||
|
||||
@@ -251,7 +251,7 @@ static void clean_paths(Main *main)
|
||||
}
|
||||
|
||||
while(scene) {
|
||||
ed= scene->ed;
|
||||
ed= seq_give_editing(scene, 0);
|
||||
if(ed) {
|
||||
seq= ed->seqbasep->first;
|
||||
while(seq) {
|
||||
|
||||
@@ -1018,14 +1018,15 @@ static struct ImBuf *brush_gen_radial_control_imbuf(Brush *br)
|
||||
|
||||
/* Modulate curve with texture */
|
||||
if(texcache) {
|
||||
for(i=0; i<side; ++i)
|
||||
for(i=0; i<side; ++i) {
|
||||
for(j=0; j<side; ++j) {
|
||||
const int col= texcache[i*side+j];
|
||||
im->rect_float[i*side+j]*= (((char*)&col)[0]+((char*)&col)[1]+((char*)&col)[2])/3.0f/255.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MEM_freeN(texcache);
|
||||
MEM_freeN(texcache);
|
||||
}
|
||||
|
||||
return im;
|
||||
}
|
||||
|
||||
@@ -1882,20 +1882,29 @@ static void actcon_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraint
|
||||
CLAMP(s, 0, 1);
|
||||
t = ( s * (data->end-data->start)) + data->start;
|
||||
|
||||
if (G.f & G_DEBUG)
|
||||
printf("do Action Constraint %s - Ob %s Pchan %s \n", con->name, cob->ob->id.name+2, (cob->pchan)?cob->pchan->name:NULL);
|
||||
|
||||
/* Get the appropriate information from the action */
|
||||
// XXX probably we might need some special filtering methods to make this more efficient
|
||||
if (cob->type == CONSTRAINT_OBTYPE_BONE) {
|
||||
Object workob;
|
||||
bPose *pose;
|
||||
bPoseChannel *pchan, *tchan;
|
||||
|
||||
/* make a temporary pose and evaluate using that */
|
||||
pose = MEM_callocN(sizeof(bPose), "pose");
|
||||
|
||||
/* make a copy of the bone of interest in the temp pose before evaluating action, so that it can get set */
|
||||
pchan = cob->pchan;
|
||||
tchan= verify_pose_channel(pose, pchan->name);
|
||||
extract_pose_from_action(pose, data->act, t);
|
||||
|
||||
/* evaluate action using workob (it will only set the PoseChannel in question) */
|
||||
// XXX we need some flags to prevent evaluation from setting disabled flags on all other settings
|
||||
what_does_obaction(cob->scene, cob->ob, &workob, pose, data->act, t);
|
||||
|
||||
/* convert animation to matrices for use here */
|
||||
chan_calc_mat(tchan);
|
||||
|
||||
Mat4CpyMat4(ct->matrix, tchan->chan_mat);
|
||||
|
||||
/* Clean up */
|
||||
@@ -1903,8 +1912,9 @@ static void actcon_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraint
|
||||
}
|
||||
else if (cob->type == CONSTRAINT_OBTYPE_OBJECT) {
|
||||
Object workob;
|
||||
|
||||
/* evaluate using workob */
|
||||
//what_does_obaction(cob->scene, cob->ob, &workob, data->act, t); // FIXME: missing func...
|
||||
what_does_obaction(cob->scene, cob->ob, &workob, NULL, data->act, t);
|
||||
object_to_mat4(&workob, ct->matrix);
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -347,11 +347,16 @@ static void dag_add_driver_relation(AnimData *adt, DagForest *dag, DagNode *node
|
||||
// XXX rotational difference
|
||||
}
|
||||
else if (driver->id) {
|
||||
/* normal channel-drives-channel */
|
||||
node1 = dag_get_node(dag, driver->id); // XXX we assume that id is an object...
|
||||
if(GS(driver->id->name)==ID_OB) {
|
||||
/* normal channel-drives-channel */
|
||||
node1 = dag_get_node(dag, driver->id);
|
||||
|
||||
// XXX what happens for bone drivers?
|
||||
dag_add_relation(dag, node1, node, isdata?DAG_RL_OB_DATA:DAG_RL_OB_OB, "Ipo Driver");
|
||||
// XXX how to find out rnapath is bone?
|
||||
if( ((Object *)driver->id)->type==OB_ARMATURE )
|
||||
dag_add_relation(dag, node1, node, isdata?DAG_RL_DATA_DATA:DAG_RL_DATA_OB, "Ipo Driver");
|
||||
else
|
||||
dag_add_relation(dag, node1, node, isdata?DAG_RL_OB_DATA:DAG_RL_OB_OB, "Ipo Driver");
|
||||
}
|
||||
}
|
||||
#if 0 // XXX old 'normal' type
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
#include "BKE_fcurve.h"
|
||||
#include "BKE_curve.h"
|
||||
#include "BKE_global.h"
|
||||
#include "BKE_idprop.h"
|
||||
#include "BKE_utildefines.h"
|
||||
|
||||
@@ -106,7 +107,7 @@ FCurve *copy_fcurve (FCurve *fcu)
|
||||
fcu_d->rna_path= MEM_dupallocN(fcu_d->rna_path);
|
||||
|
||||
/* copy driver */
|
||||
//fcurve_copy_driver();
|
||||
fcu_d->driver= fcurve_copy_driver(fcu_d->driver);
|
||||
|
||||
/* copy modifiers */
|
||||
fcurve_copy_modifiers(&fcu_d->modifiers, &fcu->modifiers);
|
||||
@@ -438,6 +439,24 @@ void fcurve_free_driver(FCurve *fcu)
|
||||
fcu->driver= NULL;
|
||||
}
|
||||
|
||||
/* This makes a copy of the given driver */
|
||||
ChannelDriver *fcurve_copy_driver (ChannelDriver *driver)
|
||||
{
|
||||
ChannelDriver *ndriver;
|
||||
|
||||
/* sanity checks */
|
||||
if (driver == NULL)
|
||||
return NULL;
|
||||
|
||||
/* copy all data */
|
||||
ndriver= MEM_dupallocN(driver);
|
||||
ndriver->rna_path= MEM_dupallocN(ndriver->rna_path);
|
||||
ndriver->rna_path2= MEM_dupallocN(ndriver->rna_path2);
|
||||
|
||||
/* return the new driver */
|
||||
return ndriver;
|
||||
}
|
||||
|
||||
/* Driver Evaluation -------------------------- */
|
||||
|
||||
/* Helper function to obtain a value using RNA from the specified source (for evaluating drivers)
|
||||
@@ -447,24 +466,35 @@ static float driver_get_driver_value (ChannelDriver *driver, short target)
|
||||
{
|
||||
PointerRNA id_ptr, ptr;
|
||||
PropertyRNA *prop;
|
||||
ID *id;
|
||||
char *path;
|
||||
int index;
|
||||
float value= 0.0f;
|
||||
|
||||
/* get RNA-pointer for the ID-block given in driver */
|
||||
if (target == 2) {
|
||||
if (target == 1) {
|
||||
/* second target */
|
||||
RNA_id_pointer_create(driver->id2, &id_ptr);
|
||||
id= driver->id2;
|
||||
path= driver->rna_path2;
|
||||
index= driver->array_index2;
|
||||
}
|
||||
else {
|
||||
/* first/main target */
|
||||
RNA_id_pointer_create(driver->id, &id_ptr);
|
||||
id= driver->id;
|
||||
path= driver->rna_path;
|
||||
index= driver->array_index;
|
||||
}
|
||||
|
||||
/* error check for missing pointer... */
|
||||
if (id == NULL) {
|
||||
printf("Error: driver doesn't have any valid target to use \n");
|
||||
if (G.f & G_DEBUG) printf("\tpath = %s [%d] \n", path, index);
|
||||
driver->flag |= DRIVER_FLAG_INVALID;
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
/* get property to read from, and get value as appropriate */
|
||||
if (RNA_path_resolve(&id_ptr, path, &ptr, &prop)) {
|
||||
switch (RNA_property_type(&ptr, prop)) {
|
||||
@@ -511,9 +541,10 @@ static float evaluate_driver (ChannelDriver *driver, float evaltime)
|
||||
case DRIVER_TYPE_CHANNEL: /* channel/setting drivers channel/setting */
|
||||
return driver_get_driver_value(driver, 0);
|
||||
|
||||
#ifndef DISABLE_PYTHON
|
||||
|
||||
case DRIVER_TYPE_PYTHON: /* expression */
|
||||
{
|
||||
#ifndef DISABLE_PYTHON
|
||||
/* check for empty or invalid expression */
|
||||
if ( (driver->expression[0] == '\0') ||
|
||||
(driver->flag & DRIVER_FLAG_INVALID) )
|
||||
@@ -526,8 +557,10 @@ static float evaluate_driver (ChannelDriver *driver, float evaltime)
|
||||
*/
|
||||
//return BPY_pydriver_eval(driver); // XXX old func
|
||||
return 1.0f;
|
||||
}
|
||||
#endif /* DISABLE_PYTHON*/
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case DRIVER_TYPE_ROTDIFF: /* difference of rotations of 2 bones (should be in same armature) */
|
||||
{
|
||||
@@ -1011,7 +1044,7 @@ static void fcm_generator_evaluate (FCurve *fcu, FModifier *fcm, float *cvalue,
|
||||
// TODO: could this be more efficient (i.e. without need to recalc pow() everytime)
|
||||
cp= data->poly_coefficients;
|
||||
for (i=0; (i <= data->poly_order) && (cp); i++, cp++)
|
||||
value += (*cp) * pow(evaltime, i);
|
||||
value += (*cp) * (float)pow(evaltime, i);
|
||||
|
||||
/* only if something changed */
|
||||
if (data->poly_order)
|
||||
|
||||
@@ -527,6 +527,60 @@ IDProperty *IDP_GetProperties(ID *id, int create_if_needed)
|
||||
}
|
||||
}
|
||||
|
||||
int IDP_EqualsProperties(IDProperty *prop1, IDProperty *prop2)
|
||||
{
|
||||
if(prop1 == NULL && prop2 == NULL)
|
||||
return 1;
|
||||
else if(prop1 == NULL || prop2 == NULL)
|
||||
return 0;
|
||||
else if(prop1->type != prop2->type)
|
||||
return 0;
|
||||
|
||||
if(prop1->type == IDP_INT)
|
||||
return (IDP_Int(prop1) == IDP_Int(prop2));
|
||||
else if(prop1->type == IDP_FLOAT)
|
||||
return (IDP_Float(prop1) == IDP_Float(prop2));
|
||||
else if(prop1->type == IDP_DOUBLE)
|
||||
return (IDP_Double(prop1) == IDP_Double(prop2));
|
||||
else if(prop1->type == IDP_STRING)
|
||||
return BSTR_EQ(IDP_String(prop1), IDP_String(prop2));
|
||||
else if(prop1->type == IDP_ARRAY) {
|
||||
if(prop1->len == prop2->len && prop1->subtype == prop2->subtype)
|
||||
return memcmp(IDP_Array(prop1), IDP_Array(prop2), idp_size_table[prop1->subtype]*prop1->len);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
else if(prop1->type == IDP_GROUP) {
|
||||
IDProperty *link1, *link2;
|
||||
|
||||
if(BLI_countlist(&prop1->data.group) != BLI_countlist(&prop2->data.group))
|
||||
return 0;
|
||||
|
||||
for(link1=prop1->data.group.first; link1; link1=link1->next) {
|
||||
link2= IDP_GetPropertyFromGroup(prop2, link1->name);
|
||||
|
||||
if(!IDP_EqualsProperties(link1, link2))
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
else if(prop1->type == IDP_IDPARRAY) {
|
||||
IDProperty *array1= IDP_IDPArray(prop1);
|
||||
IDProperty *array2= IDP_IDPArray(prop2);
|
||||
int i;
|
||||
|
||||
if(prop1->len != prop2->len)
|
||||
return 0;
|
||||
|
||||
for(i=0; i<prop1->len; i++)
|
||||
if(!IDP_EqualsProperties(&array1[i], &array2[i]))
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
IDProperty *IDP_New(int type, IDPropertyTemplate val, const char *name)
|
||||
{
|
||||
IDProperty *prop=NULL;
|
||||
|
||||
@@ -91,6 +91,7 @@
|
||||
/* quick lookup: supports 1 million frames, thousand passes */
|
||||
#define IMA_MAKE_INDEX(frame, index) ((frame)<<10)+index
|
||||
#define IMA_INDEX_FRAME(index) (index>>10)
|
||||
#define IMA_INDEX_PASS(index) (index & ~1023)
|
||||
|
||||
/* ******** IMAGE PROCESSING ************* */
|
||||
|
||||
@@ -332,6 +333,33 @@ static void image_assign_ibuf(Image *ima, ImBuf *ibuf, int index, int frame)
|
||||
}
|
||||
}
|
||||
|
||||
/* empty image block, of similar type and filename */
|
||||
Image *BKE_image_copy(Image *ima)
|
||||
{
|
||||
Image *new= image_alloc(ima->id.name+2, ima->source, ima->type);
|
||||
|
||||
BLI_strncpy(new->name, ima->name, sizeof(ima->name));
|
||||
|
||||
new->gen_x= ima->gen_x;
|
||||
new->gen_y= ima->gen_y;
|
||||
new->gen_type= ima->gen_type;
|
||||
|
||||
return new;
|
||||
}
|
||||
|
||||
void BKE_image_merge(Image *dest, Image *source)
|
||||
{
|
||||
ImBuf *ibuf;
|
||||
|
||||
while((ibuf= source->ibufs.first)) {
|
||||
BLI_remlink(&source->ibufs, ibuf);
|
||||
image_assign_ibuf(dest, ibuf, IMA_INDEX_PASS(ibuf->index), IMA_INDEX_FRAME(ibuf->index));
|
||||
}
|
||||
|
||||
free_libblock(&G.main->image, source);
|
||||
}
|
||||
|
||||
|
||||
/* checks if image was already loaded, then returns same image */
|
||||
/* otherwise creates new. */
|
||||
/* does not load ibuf itself */
|
||||
|
||||
@@ -109,11 +109,83 @@ void free_ipo (Ipo *ipo)
|
||||
BLI_freelinkN(&ipo->curve, icu);
|
||||
}
|
||||
|
||||
printf("Freed %d (Unconverted) Ipo-Curves from IPO '%s' \n", n, ipo->id.name+2);
|
||||
if (G.f & G_DEBUG)
|
||||
printf("Freed %d (Unconverted) Ipo-Curves from IPO '%s' \n", n, ipo->id.name+2);
|
||||
}
|
||||
|
||||
/* *************************************************** */
|
||||
/* ADRCODE to RNA-Path Conversion Code */
|
||||
/* ADRCODE to RNA-Path Conversion Code - Special (Bitflags) */
|
||||
|
||||
/* Mapping Table for bitflag <-> RNA path */
|
||||
typedef struct AdrBit2Path {
|
||||
int bit;
|
||||
char *path;
|
||||
int array_index;
|
||||
} AdrBit2Path;
|
||||
|
||||
/* ----------------- */
|
||||
/* Mapping Tables to use bits <-> RNA paths */
|
||||
|
||||
/* Object layers */
|
||||
static AdrBit2Path ob_layer_bits[]= {
|
||||
{(1<<0), "layer", 0},
|
||||
{(1<<1), "layer", 1},
|
||||
{(1<<2), "layer", 2},
|
||||
{(1<<3), "layer", 3},
|
||||
{(1<<4), "layer", 4},
|
||||
{(1<<5), "layer", 5},
|
||||
{(1<<6), "layer", 6},
|
||||
{(1<<7), "layer", 7},
|
||||
{(1<<8), "layer", 8},
|
||||
{(1<<9), "layer", 9},
|
||||
{(1<<10), "layer", 10},
|
||||
{(1<<11), "layer", 11},
|
||||
{(1<<12), "layer", 12},
|
||||
{(1<<13), "layer", 13},
|
||||
{(1<<14), "layer", 14},
|
||||
{(1<<15), "layer", 15},
|
||||
{(1<<16), "layer", 16},
|
||||
{(1<<17), "layer", 17},
|
||||
{(1<<18), "layer", 18},
|
||||
{(1<<19), "layer", 19},
|
||||
{(1<<20), "layer", 20}
|
||||
};
|
||||
|
||||
/* ----------------- */
|
||||
|
||||
/* This function checks if a Blocktype+Adrcode combo, returning a mapping table */
|
||||
static AdrBit2Path *adrcode_bitmaps_to_paths (int blocktype, int adrcode, int *tot)
|
||||
{
|
||||
/* Object layers */
|
||||
if ((blocktype == ID_OB) && (adrcode == OB_LAY)) {
|
||||
*tot= sizeof(ob_layer_bits)/sizeof(AdrBit2Path);
|
||||
return ob_layer_bits;
|
||||
}
|
||||
else if ((blocktype == ID_MA) && (adrcode == MA_MODE)) {
|
||||
// XXX to be added...
|
||||
}
|
||||
// XXX TODO: add other types...
|
||||
|
||||
/* Normal curve */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* This function makes a copy of a path stored in AdrBit2Path entry, and makes a guardedalloc copy */
|
||||
static char *adrcode_bitmap_path_copy (const char *abp_path)
|
||||
{
|
||||
char *path;
|
||||
int len;
|
||||
|
||||
/* copy the path */
|
||||
len= strlen(abp_path) + 1; // XXX is this safe?
|
||||
path= MEM_callocN(len, "Bitflag IPO-Curve RNA-Path");
|
||||
memcpy(path, abp_path, len);
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
/* *************************************************** */
|
||||
/* ADRCODE to RNA-Path Conversion Code - Standard */
|
||||
|
||||
/* Object types */
|
||||
static char *ob_adrcodes_to_paths (int adrcode, int *array_index)
|
||||
@@ -163,10 +235,6 @@ static char *ob_adrcodes_to_paths (int adrcode, int *array_index)
|
||||
*array_index= 2; return "delta_scale";
|
||||
|
||||
#if 0
|
||||
case OB_LAY: // XXX EVIL BITFLAG ALERT! this one will need special attention...
|
||||
// poin= &(ob->lay); *type= IPO_INT_BIT; break;
|
||||
return NULL;
|
||||
|
||||
case OB_COL_R:
|
||||
poin= &(ob->col[0]); break;
|
||||
case OB_COL_G:
|
||||
@@ -250,6 +318,23 @@ static char *pchan_adrcodes_to_paths (int adrcode, int *array_index)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Constraint types */
|
||||
static char *constraint_adrcodes_to_paths (int adrcode, int *array_index)
|
||||
{
|
||||
/* set array index like this in-case nothing sets it correctly */
|
||||
*array_index= 0;
|
||||
|
||||
/* result depends on adrcode */
|
||||
switch (adrcode) {
|
||||
case CO_ENFORCE:
|
||||
return "influence";
|
||||
case CO_HEADTAIL: // XXX this needs to be wrapped in RNA.. probably then this path will be invalid
|
||||
return "data.head_tail";
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* ShapeKey types
|
||||
* NOTE: as we don't have access to the keyblock where the data comes from (for now),
|
||||
* we'll just use numerical indicies for now...
|
||||
@@ -260,7 +345,10 @@ static char *shapekey_adrcodes_to_paths (int adrcode, int *array_index)
|
||||
|
||||
/* block will be attached to ID_KE block, and setting that we alter is the 'value' (which sets keyblock.curval) */
|
||||
// XXX adrcode 0 was dummy 'speed' curve
|
||||
sprintf(buf, "keys[%d].value", adrcode-1); // XXX this doesn't seem too safe...
|
||||
if (adrcode == 0)
|
||||
sprintf(buf, "speed");
|
||||
else
|
||||
sprintf(buf, "keys[%d].value", adrcode);
|
||||
return buf;
|
||||
}
|
||||
|
||||
@@ -397,8 +485,6 @@ static char *material_adrcodes_to_paths (int adrcode, int *array_index)
|
||||
poin= &(ma->spectra); break;
|
||||
case MA_IOR:
|
||||
poin= &(ma->ang); break;
|
||||
case MA_MODE:
|
||||
poin= &(ma->mode); *type= IPO_INT_BIT; break; // evil... dumping bitflags directly to user!
|
||||
case MA_HASIZE:
|
||||
poin= &(ma->hasize); break;
|
||||
case MA_TRANSLU:
|
||||
@@ -482,6 +568,71 @@ static char *camera_adrcodes_to_paths (int adrcode, int *array_index)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Lamp Types */
|
||||
static char *lamp_adrcodes_to_paths (int adrcode, int *array_index)
|
||||
{
|
||||
/* set array index like this in-case nothing sets it correctly */
|
||||
*array_index= 0;
|
||||
|
||||
/* result depends on adrcode */
|
||||
switch (adrcode) {
|
||||
case LA_ENERGY:
|
||||
return "energy";
|
||||
|
||||
case LA_COL_R:
|
||||
*array_index= 0; return "color";
|
||||
case LA_COL_G:
|
||||
*array_index= 1; return "color";
|
||||
case LA_COL_B:
|
||||
*array_index= 2; return "color";
|
||||
|
||||
case LA_DIST:
|
||||
return "distance";
|
||||
|
||||
case LA_SPOTSI:
|
||||
return "spot_size";
|
||||
case LA_SPOTBL:
|
||||
return "spot_blend";
|
||||
|
||||
case LA_QUAD1:
|
||||
return "linear_attenuation";
|
||||
case LA_QUAD2:
|
||||
return "quadratic_attenuation";
|
||||
|
||||
case LA_HALOINT:
|
||||
return "halo_intensity";
|
||||
}
|
||||
|
||||
#if 0 // XXX to be converted
|
||||
if (poin == NULL) {
|
||||
if (icu->adrcode & MA_MAP1) mtex= la->mtex[0];
|
||||
else if (icu->adrcode & MA_MAP2) mtex= la->mtex[1];
|
||||
else if (icu->adrcode & MA_MAP3) mtex= la->mtex[2];
|
||||
else if (icu->adrcode & MA_MAP4) mtex= la->mtex[3];
|
||||
else if (icu->adrcode & MA_MAP5) mtex= la->mtex[4];
|
||||
else if (icu->adrcode & MA_MAP6) mtex= la->mtex[5];
|
||||
else if (icu->adrcode & MA_MAP7) mtex= la->mtex[6];
|
||||
else if (icu->adrcode & MA_MAP8) mtex= la->mtex[7];
|
||||
else if (icu->adrcode & MA_MAP9) mtex= la->mtex[8];
|
||||
else if (icu->adrcode & MA_MAP10) mtex= la->mtex[9];
|
||||
else if (icu->adrcode & MA_MAP11) mtex= la->mtex[10];
|
||||
else if (icu->adrcode & MA_MAP12) mtex= la->mtex[11];
|
||||
else if (icu->adrcode & MA_MAP13) mtex= la->mtex[12];
|
||||
else if (icu->adrcode & MA_MAP14) mtex= la->mtex[13];
|
||||
else if (icu->adrcode & MA_MAP15) mtex= la->mtex[14];
|
||||
else if (icu->adrcode & MA_MAP16) mtex= la->mtex[15];
|
||||
else if (icu->adrcode & MA_MAP17) mtex= la->mtex[16];
|
||||
else if (icu->adrcode & MA_MAP18) mtex= la->mtex[17];
|
||||
|
||||
if (mtex)
|
||||
poin= give_mtex_poin(mtex, (icu->adrcode & (MA_MAP1-1)));
|
||||
}
|
||||
#endif // XXX to be converted
|
||||
|
||||
/* unrecognised adrcode, or not-yet-handled ones! */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* ------- */
|
||||
|
||||
/* Allocate memory for RNA-path for some property given a blocktype, adrcode, and 'root' parts of path
|
||||
@@ -513,6 +664,10 @@ char *get_rna_access (int blocktype, int adrcode, char actname[], char constname
|
||||
propname= shapekey_adrcodes_to_paths(adrcode, &dummy_index);
|
||||
break;
|
||||
|
||||
case ID_CO: /* constraint */
|
||||
propname= constraint_adrcodes_to_paths(adrcode, &dummy_index);
|
||||
break;
|
||||
|
||||
case ID_TE: /* texture */
|
||||
propname= texture_adrcodes_to_paths(adrcode, &dummy_index);
|
||||
break;
|
||||
@@ -525,6 +680,10 @@ char *get_rna_access (int blocktype, int adrcode, char actname[], char constname
|
||||
propname= camera_adrcodes_to_paths(adrcode, &dummy_index);
|
||||
break;
|
||||
|
||||
case ID_LA: /* lamp */
|
||||
propname= lamp_adrcodes_to_paths(adrcode, &dummy_index);
|
||||
break;
|
||||
|
||||
/* XXX problematic blocktypes */
|
||||
case ID_CU: /* curve */
|
||||
propname= "speed"; // XXX this was a 'dummy curve' that didn't really correspond to any real var...
|
||||
@@ -620,6 +779,7 @@ static ChannelDriver *idriver_to_cdriver (IpoDriver *idriver)
|
||||
if (idriver->blocktype == ID_AR) {
|
||||
/* ID_PO */
|
||||
if (idriver->adrcode == OB_ROT_DIFF) {
|
||||
if (G.f & G_DEBUG) printf("idriver_to_cdriver - rotdiff %p \n", idriver->ob);
|
||||
/* Rotational Difference is a special type of driver now... */
|
||||
cdriver->type= DRIVER_TYPE_ROTDIFF;
|
||||
|
||||
@@ -637,6 +797,7 @@ static ChannelDriver *idriver_to_cdriver (IpoDriver *idriver)
|
||||
cdriver->rna_path2= get_rna_access(-1, -1, idriver->name+DRIVER_NAME_OFFS, NULL, NULL);
|
||||
}
|
||||
else {
|
||||
if (G.f & G_DEBUG) printf("idriver_to_cdriver - arm %p \n", idriver->ob);
|
||||
/* 'standard' driver */
|
||||
cdriver->type= DRIVER_TYPE_CHANNEL;
|
||||
cdriver->id= (ID *)idriver->ob;
|
||||
@@ -677,12 +838,15 @@ static ChannelDriver *idriver_to_cdriver (IpoDriver *idriver)
|
||||
}
|
||||
else {
|
||||
/* ID_OB */
|
||||
if (G.f & G_DEBUG) printf("idriver_to_cdriver - ob %p \n", idriver->ob);
|
||||
cdriver->type= DRIVER_TYPE_CHANNEL;
|
||||
cdriver->id= (ID *)idriver->ob;
|
||||
cdriver->rna_path= get_rna_access(ID_OB, idriver->adrcode, idriver->name, NULL, &cdriver->array_index);
|
||||
cdriver->rna_path= get_rna_access(ID_OB, idriver->adrcode, NULL, NULL, &cdriver->array_index);
|
||||
}
|
||||
}
|
||||
|
||||
if (G.f & G_DEBUG) printf("\tcdriver -> id = %p \n", cdriver->id);
|
||||
|
||||
/* free old driver */
|
||||
MEM_freeN(idriver);
|
||||
|
||||
@@ -695,10 +859,11 @@ static ChannelDriver *idriver_to_cdriver (IpoDriver *idriver)
|
||||
* actname: name of Action-Channel (if applicable) that IPO-Curve's IPO-block belonged to
|
||||
* constname: name of Constraint-Channel (if applicable) that IPO-Curve's IPO-block belonged to
|
||||
*/
|
||||
static FCurve *icu_to_fcu (IpoCurve *icu, char *actname, char *constname)
|
||||
static void icu_to_fcurves (ListBase *list, IpoCurve *icu, char *actname, char *constname)
|
||||
{
|
||||
AdrBit2Path *abp;
|
||||
FCurve *fcu;
|
||||
int i= 0;
|
||||
int i=0, totbits;
|
||||
|
||||
/* allocate memory for a new F-Curve */
|
||||
fcu= MEM_callocN(sizeof(FCurve), "FCurve");
|
||||
@@ -709,56 +874,6 @@ static FCurve *icu_to_fcu (IpoCurve *icu, char *actname, char *constname)
|
||||
icu->driver= NULL;
|
||||
}
|
||||
|
||||
/* convert keyframes
|
||||
* - beztriples and bpoints are mutually exclusive, so we won't have both at the same time
|
||||
* - beztriples are more likely to be encountered as they are keyframes (the other type wasn't used yet)
|
||||
*/
|
||||
// XXX we need to cope with the nasty old 'bitflag' curves... that will be a task for later
|
||||
// XXX we also need to correct values for object-rotation curves
|
||||
fcu->totvert= icu->totvert;
|
||||
|
||||
if (icu->bezt) {
|
||||
BezTriple *dst, *src;
|
||||
|
||||
/* allocate new array for keyframes/beztriples */
|
||||
fcu->bezt= MEM_callocN(sizeof(BezTriple)*fcu->totvert, "BezTriples");
|
||||
|
||||
/* loop through copying all BezTriples individually, as we need to modify a few things */
|
||||
for (dst=fcu->bezt, src=icu->bezt; i < fcu->totvert; i++, dst++, src++) {
|
||||
/* firstly, copy BezTriple data */
|
||||
*dst= *src;
|
||||
|
||||
/* now copy interpolation from curve (if not already set) */
|
||||
if (icu->ipo != IPO_MIXED)
|
||||
dst->ipo= icu->ipo;
|
||||
|
||||
/* correct values for object rotation curves - they were degrees/10 */
|
||||
// XXX for now, just make them into radians as RNA sets/reads directly in that form
|
||||
if ((icu->blocktype == ID_OB) && ELEM3(icu->adrcode, OB_ROT_X, OB_ROT_Y, OB_ROT_Z)) {
|
||||
const float fac= M_PI / 18.0f; //10.0f * M_PI/180.0f;
|
||||
|
||||
dst->vec[0][1] *= fac;
|
||||
dst->vec[1][1] *= fac;
|
||||
dst->vec[2][1] *= fac;
|
||||
}
|
||||
}
|
||||
|
||||
/* free this data now */
|
||||
MEM_freeN(icu->bezt);
|
||||
}
|
||||
else if (icu->bp) {
|
||||
/* TODO: need to convert from BPoint type to the more compact FPoint type... but not priority, since no data used this */
|
||||
//BPoint *bp;
|
||||
//FPoint *fpt;
|
||||
}
|
||||
|
||||
/* get rna-path
|
||||
* - we will need to set the 'disabled' flag if no path is able to be made (for now)
|
||||
*/
|
||||
fcu->rna_path= get_rna_access(icu->blocktype, icu->adrcode, actname, constname, &fcu->array_index);
|
||||
if (fcu->rna_path == NULL)
|
||||
fcu->flag |= FCURVE_DISABLED;
|
||||
|
||||
/* copy flags */
|
||||
if (icu->flag & IPO_VISIBLE) fcu->flag |= FCURVE_VISIBLE;
|
||||
if (icu->flag & IPO_SELECT) fcu->flag |= FCURVE_SELECTED;
|
||||
@@ -795,33 +910,147 @@ static FCurve *icu_to_fcu (IpoCurve *icu, char *actname, char *constname)
|
||||
break;
|
||||
}
|
||||
|
||||
/* return new F-Curve */
|
||||
return fcu;
|
||||
/* -------- */
|
||||
|
||||
/* get adrcode <-> bitflags mapping to handle nasty bitflag curves? */
|
||||
abp= adrcode_bitmaps_to_paths(icu->blocktype, icu->adrcode, &totbits);
|
||||
if (abp && totbits) {
|
||||
FCurve *fcurve;
|
||||
int b;
|
||||
|
||||
if (G.f & G_DEBUG) printf("\tconvert bitflag ipocurve, totbits = %d \n", totbits);
|
||||
|
||||
/* add the 'only int values' flag */
|
||||
fcu->flag |= FCURVE_INT_VALUES;
|
||||
|
||||
/* for each bit we have to remap + check for:
|
||||
* 1) we need to make copy the existing F-Curve data (fcu -> fcurve),
|
||||
* except for the last one which will use the original
|
||||
* 2) copy the relevant path info across
|
||||
* 3) filter the keyframes for the flag of interest
|
||||
*/
|
||||
for (b=0; b < totbits; b++, abp++) {
|
||||
/* make a copy of existing base-data if not the last curve */
|
||||
if (b < (totbits-1))
|
||||
fcurve= copy_fcurve(fcu);
|
||||
else
|
||||
fcurve= fcu;
|
||||
|
||||
/* set path */
|
||||
fcurve->rna_path= MEM_dupallocN(abp->path);
|
||||
fcurve->array_index= abp->array_index;
|
||||
|
||||
/* convert keyframes
|
||||
* - beztriples and bpoints are mutually exclusive, so we won't have both at the same time
|
||||
* - beztriples are more likely to be encountered as they are keyframes (the other type wasn't used yet)
|
||||
*/
|
||||
fcurve->totvert= icu->totvert;
|
||||
|
||||
if (icu->bezt) {
|
||||
BezTriple *dst, *src;
|
||||
|
||||
/* allocate new array for keyframes/beztriples */
|
||||
fcurve->bezt= MEM_callocN(sizeof(BezTriple)*fcurve->totvert, "BezTriples");
|
||||
|
||||
/* loop through copying all BezTriples individually, as we need to modify a few things */
|
||||
for (dst=fcurve->bezt, src=icu->bezt; i < fcurve->totvert; i++, dst++, src++) {
|
||||
/* firstly, copy BezTriple data */
|
||||
*dst= *src;
|
||||
|
||||
/* interpolation can only be constant... */
|
||||
dst->ipo= BEZT_IPO_CONST;
|
||||
|
||||
/* correct values, by checking if the flag of interest is set */
|
||||
if ( ((int)(dst->vec[1][1])) & (abp->bit) )
|
||||
dst->vec[0][1]= dst->vec[1][1]= dst->vec[2][1] = 1.0f;
|
||||
else
|
||||
dst->vec[0][1]= dst->vec[1][1]= dst->vec[2][1] = 0.0f;
|
||||
}
|
||||
}
|
||||
else if (icu->bp) {
|
||||
/* TODO: need to convert from BPoint type to the more compact FPoint type... but not priority, since no data used this */
|
||||
//BPoint *bp;
|
||||
//FPoint *fpt;
|
||||
}
|
||||
|
||||
/* add new F-Curve to list */
|
||||
BLI_addtail(list, fcurve);
|
||||
}
|
||||
|
||||
/* free old data of curve now that it's no longer needed for converting any more curves */
|
||||
if (icu->bezt) MEM_freeN(icu->bezt);
|
||||
if (icu->bp) MEM_freeN(icu->bezt);
|
||||
}
|
||||
else {
|
||||
/* get rna-path
|
||||
* - we will need to set the 'disabled' flag if no path is able to be made (for now)
|
||||
*/
|
||||
fcu->rna_path= get_rna_access(icu->blocktype, icu->adrcode, actname, constname, &fcu->array_index);
|
||||
if (fcu->rna_path == NULL)
|
||||
fcu->flag |= FCURVE_DISABLED;
|
||||
|
||||
/* convert keyframes
|
||||
* - beztriples and bpoints are mutually exclusive, so we won't have both at the same time
|
||||
* - beztriples are more likely to be encountered as they are keyframes (the other type wasn't used yet)
|
||||
*/
|
||||
fcu->totvert= icu->totvert;
|
||||
|
||||
if (icu->bezt) {
|
||||
BezTriple *dst, *src;
|
||||
|
||||
/* allocate new array for keyframes/beztriples */
|
||||
fcu->bezt= MEM_callocN(sizeof(BezTriple)*fcu->totvert, "BezTriples");
|
||||
|
||||
/* loop through copying all BezTriples individually, as we need to modify a few things */
|
||||
for (dst=fcu->bezt, src=icu->bezt; i < fcu->totvert; i++, dst++, src++) {
|
||||
/* firstly, copy BezTriple data */
|
||||
*dst= *src;
|
||||
|
||||
/* now copy interpolation from curve (if not already set) */
|
||||
if (icu->ipo != IPO_MIXED)
|
||||
dst->ipo= icu->ipo;
|
||||
|
||||
/* correct values for object rotation curves - they were degrees/10 */
|
||||
// XXX for now, just make them into radians as RNA sets/reads directly in that form
|
||||
if ((icu->blocktype == ID_OB) && ELEM3(icu->adrcode, OB_ROT_X, OB_ROT_Y, OB_ROT_Z)) {
|
||||
const float fac= (float)M_PI / 18.0f; //10.0f * M_PI/180.0f;
|
||||
|
||||
dst->vec[0][1] *= fac;
|
||||
dst->vec[1][1] *= fac;
|
||||
dst->vec[2][1] *= fac;
|
||||
}
|
||||
}
|
||||
|
||||
/* free this data now */
|
||||
MEM_freeN(icu->bezt);
|
||||
}
|
||||
else if (icu->bp) {
|
||||
/* TODO: need to convert from BPoint type to the more compact FPoint type... but not priority, since no data used this */
|
||||
//BPoint *bp;
|
||||
//FPoint *fpt;
|
||||
}
|
||||
|
||||
/* add new F-Curve to list */
|
||||
BLI_addtail(list, fcu);
|
||||
}
|
||||
}
|
||||
|
||||
/* Convert IPO-block (i.e. all its IpoCurves) for some ID to the new system
|
||||
* This assumes that AnimData has been added already. Separation of drivers
|
||||
* from animation data is accomplished here too...
|
||||
/* ------------------------- */
|
||||
|
||||
/* Convert IPO-block (i.e. all its IpoCurves) to the new system.
|
||||
* This does not assume that any ID or AnimData uses it, but does assume that
|
||||
* it is given two lists, which it will perform driver/animation-data separation.
|
||||
*/
|
||||
static void ipo_to_animdata (ID *id, Ipo *ipo, char *actname, char *constname)
|
||||
static void ipo_to_animato (Ipo *ipo, char actname[], char constname[], ListBase *anim, ListBase *drivers)
|
||||
{
|
||||
AnimData *adt= BKE_animdata_from_id(id);
|
||||
//bActionGroup *grp;
|
||||
IpoCurve *icu, *icn;
|
||||
FCurve *fcu;
|
||||
|
||||
/* sanity check */
|
||||
if ELEM(NULL, id, ipo)
|
||||
if (ELEM3(NULL, ipo, anim, drivers))
|
||||
return;
|
||||
if (adt == NULL) {
|
||||
printf("ERROR ipo_to_animdata(): adt invalid \n");
|
||||
return;
|
||||
}
|
||||
|
||||
printf("ipo to animdata - ID:%s, IPO:%s, actname:%s constname:%s curves:%d \n",
|
||||
id->name+2, ipo->id.name+2, (actname)?actname:"<None>", (constname)?constname:"<None>",
|
||||
BLI_countlist(&ipo->curve));
|
||||
|
||||
|
||||
if (G.f & G_DEBUG) printf("ipo_to_animato \n");
|
||||
|
||||
/* validate actname and constname
|
||||
* - clear actname if it was one of the generic <builtin> ones (i.e. 'Object', or 'Shapes')
|
||||
* - actname can then be used to assign F-Curves in Action to Action Groups
|
||||
@@ -829,10 +1058,9 @@ static void ipo_to_animdata (ID *id, Ipo *ipo, char *actname, char *constname)
|
||||
* F-Curves for bones). This may be added later... for now let's just dump without them...
|
||||
*/
|
||||
if (actname) {
|
||||
printf("actname != 0 \n");
|
||||
if ((GS(id->name) == ID_OB) && (strcmp(actname, "Object") == 0))
|
||||
if ((ipo->blocktype == ID_OB) && (strcmp(actname, "Object") == 0))
|
||||
actname= NULL;
|
||||
else if ((GS(id->name) == ID_OB) && (strcmp(actname, "Shape") == 0))
|
||||
else if ((ipo->blocktype == ID_OB) && (strcmp(actname, "Shape") == 0))
|
||||
actname= NULL;
|
||||
}
|
||||
|
||||
@@ -841,59 +1069,38 @@ static void ipo_to_animdata (ID *id, Ipo *ipo, char *actname, char *constname)
|
||||
/* get link to next (for later) */
|
||||
icn= icu->next;
|
||||
|
||||
/* convert IPO-Curve to F-Curve
|
||||
* NOTE: this frees any of the old data stored in the IPO-Curve that isn't needed anymore...
|
||||
/* Since an IPO-Curve may end up being made into many F-Curves (i.e. bitflag curves),
|
||||
* we figure out the best place to put the channel, then tell the curve-converter to just dump there
|
||||
*/
|
||||
// XXX we need to cope with the nasty old 'bitflag' curves... that will be a task for later
|
||||
// we will need to create a few new curves when doing so, and will need to sift through the keyframes to add relevant data
|
||||
fcu= icu_to_fcu(icu, actname, constname);
|
||||
|
||||
/* conversion path depends on whether it's a driver or not */
|
||||
if (fcu->driver == NULL) {
|
||||
/* try to get action */
|
||||
if (adt->action == NULL) {
|
||||
adt->action= add_empty_action("ConvertedAction"); // XXX we need a better name for this...
|
||||
printf("added new action \n");
|
||||
}
|
||||
|
||||
/* add F-Curve to action */
|
||||
BLI_addtail(&adt->action->curves, fcu);
|
||||
}
|
||||
else {
|
||||
/* add F-Curve to AnimData's drivers */
|
||||
BLI_addtail(&adt->drivers, fcu);
|
||||
}
|
||||
if (icu->driver)
|
||||
icu_to_fcurves(drivers, icu, actname, constname);
|
||||
else
|
||||
icu_to_fcurves(anim, icu, actname, constname);
|
||||
|
||||
/* free this IpoCurve now that it's been converted */
|
||||
BLI_freelinkN(&ipo->curve, icu);
|
||||
}
|
||||
}
|
||||
|
||||
/* Convert Action-block to new system
|
||||
/* Convert Action-block to new system, separating animation and drivers
|
||||
* New curves may not be converted directly into the given Action (i.e. for Actions linked
|
||||
* to Objects, where ob->ipo and ob->action need to be combined).
|
||||
* NOTE: we need to be careful here, as same data-structs are used for new system too!
|
||||
*/
|
||||
static void action_to_animdata (ID *id, bAction *act)
|
||||
static void action_to_animato (bAction *act, ListBase *curves, ListBase *drivers)
|
||||
{
|
||||
AnimData *adt= BKE_animdata_from_id(id);
|
||||
bActionChannel *achan, *achann;
|
||||
bConstraintChannel *conchan, *conchann;
|
||||
|
||||
/* only continue if there are Action Channels (indicating unconverted data) */
|
||||
if (ELEM(NULL, adt, act->chanbase.first))
|
||||
if (act->chanbase.first == NULL)
|
||||
return;
|
||||
|
||||
/* get rid of all Action Groups */
|
||||
// XXX this is risky if there's some old, some new data in the Action...
|
||||
// XXX this is risky if there's some old + some new data in the Action...
|
||||
if (act->groups.first)
|
||||
BLI_freelistN(&act->groups);
|
||||
|
||||
/* check if we need to set this Action as the AnimData's action */
|
||||
if (adt->action == NULL) {
|
||||
/* set this Action as AnimData's Action */
|
||||
printf("act_to_adt - set adt action to act \n");
|
||||
adt->action= act;
|
||||
}
|
||||
|
||||
|
||||
/* loop through Action-Channels, converting data, freeing as we go */
|
||||
for (achan= act->chanbase.first; achan; achan= achann) {
|
||||
/* get pointer to next Action Channel */
|
||||
@@ -901,7 +1108,7 @@ static void action_to_animdata (ID *id, bAction *act)
|
||||
|
||||
/* convert Action Channel's IPO data */
|
||||
if (achan->ipo) {
|
||||
ipo_to_animdata(id, achan->ipo, achan->name, NULL);
|
||||
ipo_to_animato(achan->ipo, achan->name, NULL, curves, drivers);
|
||||
achan->ipo->id.us--;
|
||||
achan->ipo= NULL;
|
||||
}
|
||||
@@ -913,7 +1120,7 @@ static void action_to_animdata (ID *id, bAction *act)
|
||||
|
||||
/* convert Constraint Channel's IPO data */
|
||||
if (conchan->ipo) {
|
||||
ipo_to_animdata(id, conchan->ipo, achan->name, conchan->name);
|
||||
ipo_to_animato(conchan->ipo, achan->name, conchan->name, curves, drivers);
|
||||
conchan->ipo->id.us--;
|
||||
conchan->ipo= NULL;
|
||||
}
|
||||
@@ -927,6 +1134,81 @@ static void action_to_animdata (ID *id, bAction *act)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------- */
|
||||
|
||||
/* Convert IPO-block (i.e. all its IpoCurves) for some ID to the new system
|
||||
* This assumes that AnimData has been added already. Separation of drivers
|
||||
* from animation data is accomplished here too...
|
||||
*/
|
||||
static void ipo_to_animdata (ID *id, Ipo *ipo, char actname[], char constname[])
|
||||
{
|
||||
AnimData *adt= BKE_animdata_from_id(id);
|
||||
ListBase anim = {NULL, NULL};
|
||||
ListBase drivers = {NULL, NULL};
|
||||
|
||||
/* sanity check */
|
||||
if ELEM(NULL, id, ipo)
|
||||
return;
|
||||
if (adt == NULL) {
|
||||
printf("ERROR ipo_to_animdata(): adt invalid \n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (G.f & G_DEBUG) {
|
||||
printf("ipo to animdata - ID:%s, IPO:%s, actname:%s constname:%s curves:%d \n",
|
||||
id->name+2, ipo->id.name+2, (actname)?actname:"<None>", (constname)?constname:"<None>",
|
||||
BLI_countlist(&ipo->curve));
|
||||
}
|
||||
|
||||
/* Convert curves to animato system (separated into separate lists of F-Curves for animation and drivers),
|
||||
* and the try to put these lists in the right places, but do not free the lists here
|
||||
*/
|
||||
ipo_to_animato(ipo, actname, constname, &anim, &drivers);
|
||||
|
||||
/* deal with animation first */
|
||||
if (anim.first) {
|
||||
if (G.f & G_DEBUG) printf("\thas anim \n");
|
||||
/* try to get action */
|
||||
if (adt->action == NULL) {
|
||||
adt->action= add_empty_action("ConvData_Action"); // XXX we need a better name for this
|
||||
if (G.f & G_DEBUG) printf("\t\tadded new action \n");
|
||||
}
|
||||
|
||||
/* add F-Curves to action */
|
||||
addlisttolist(&adt->action->curves, &anim);
|
||||
}
|
||||
|
||||
/* deal with drivers */
|
||||
if (drivers.first) {
|
||||
if (G.f & G_DEBUG) printf("\thas drivers \n");
|
||||
/* add drivers to end of driver stack */
|
||||
addlisttolist(&adt->drivers, &drivers);
|
||||
}
|
||||
}
|
||||
|
||||
/* Convert Action-block to new system
|
||||
* NOTE: we need to be careful here, as same data-structs are used for new system too!
|
||||
*/
|
||||
static void action_to_animdata (ID *id, bAction *act)
|
||||
{
|
||||
AnimData *adt= BKE_animdata_from_id(id);
|
||||
|
||||
/* only continue if there are Action Channels (indicating unconverted data) */
|
||||
if (ELEM(NULL, adt, act->chanbase.first))
|
||||
return;
|
||||
|
||||
/* check if we need to set this Action as the AnimData's action */
|
||||
if (adt->action == NULL) {
|
||||
/* set this Action as AnimData's Action */
|
||||
if (G.f & G_DEBUG) printf("act_to_adt - set adt action to act \n");
|
||||
adt->action= act;
|
||||
}
|
||||
|
||||
/* convert Action data */
|
||||
action_to_animato(act, &adt->action->curves, &adt->drivers);
|
||||
}
|
||||
|
||||
/* *************************************************** */
|
||||
/* External API - Only Called from do_versions() */
|
||||
|
||||
@@ -943,6 +1225,7 @@ static void action_to_animdata (ID *id, bAction *act)
|
||||
// XXX currently done after all file reading...
|
||||
void do_versions_ipos_to_animato(Main *main)
|
||||
{
|
||||
ListBase drivers = {NULL, NULL};
|
||||
ID *id;
|
||||
AnimData *adt;
|
||||
|
||||
@@ -960,6 +1243,7 @@ void do_versions_ipos_to_animato(Main *main)
|
||||
else
|
||||
printf("INFO: Converting to Animato... \n"); // xxx debug
|
||||
|
||||
/* ----------- Animation Attached to Data -------------- */
|
||||
|
||||
/* objects */
|
||||
for (id= main->object.first; id; id= id->next) {
|
||||
@@ -968,7 +1252,7 @@ void do_versions_ipos_to_animato(Main *main)
|
||||
bConstraint *con;
|
||||
bConstraintChannel *conchan, *conchann;
|
||||
|
||||
printf("\tconverting ob %s \n", id->name+2);
|
||||
if (G.f & G_DEBUG) printf("\tconverting ob %s \n", id->name+2);
|
||||
|
||||
/* check if object has any animation data */
|
||||
if ((ob->ipo) || (ob->action) || (ob->nlastrips.first)) {
|
||||
@@ -1012,9 +1296,6 @@ void do_versions_ipos_to_animato(Main *main)
|
||||
con->ipo->id.us--;
|
||||
con->ipo= NULL;
|
||||
}
|
||||
|
||||
/* check for Action Constraint */
|
||||
// XXX do we really want to do this here?
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1058,7 +1339,7 @@ void do_versions_ipos_to_animato(Main *main)
|
||||
for (id= main->key.first; id; id= id->next) {
|
||||
Key *key= (Key *)id;
|
||||
|
||||
printf("\tconverting key %s \n", id->name+2);
|
||||
if (G.f & G_DEBUG) printf("\tconverting key %s \n", id->name+2);
|
||||
|
||||
/* we're only interested in the IPO
|
||||
* NOTE: for later, it might be good to port these over to Object instead, as many of these
|
||||
@@ -1079,7 +1360,7 @@ void do_versions_ipos_to_animato(Main *main)
|
||||
for (id= main->mat.first; id; id= id->next) {
|
||||
Material *ma= (Material *)id;
|
||||
|
||||
printf("\tconverting material %s \n", id->name+2);
|
||||
if (G.f & G_DEBUG) printf("\tconverting material %s \n", id->name+2);
|
||||
|
||||
/* we're only interested in the IPO */
|
||||
if (ma->ipo) {
|
||||
@@ -1097,7 +1378,7 @@ void do_versions_ipos_to_animato(Main *main)
|
||||
for (id= main->tex.first; id; id= id->next) {
|
||||
Tex *te= (Tex *)id;
|
||||
|
||||
printf("\tconverting texture %s \n", id->name+2);
|
||||
if (G.f & G_DEBUG) printf("\tconverting texture %s \n", id->name+2);
|
||||
|
||||
/* we're only interested in the IPO */
|
||||
if (te->ipo) {
|
||||
@@ -1115,7 +1396,7 @@ void do_versions_ipos_to_animato(Main *main)
|
||||
for (id= main->camera.first; id; id= id->next) {
|
||||
Camera *ca= (Camera *)id;
|
||||
|
||||
printf("\tconverting camera %s \n", id->name+2);
|
||||
if (G.f & G_DEBUG) printf("\tconverting camera %s \n", id->name+2);
|
||||
|
||||
/* we're only interested in the IPO */
|
||||
if (ca->ipo) {
|
||||
@@ -1129,7 +1410,67 @@ void do_versions_ipos_to_animato(Main *main)
|
||||
}
|
||||
}
|
||||
|
||||
// XXX add other types too...
|
||||
/* lamps */
|
||||
for (id= main->lamp.first; id; id= id->next) {
|
||||
Lamp *la= (Lamp *)id;
|
||||
|
||||
if (G.f & G_DEBUG) printf("\tconverting lamp %s \n", id->name+2);
|
||||
|
||||
/* we're only interested in the IPO */
|
||||
if (la->ipo) {
|
||||
/* Add AnimData block */
|
||||
adt= BKE_id_add_animdata(id);
|
||||
|
||||
/* Convert Lamp data... */
|
||||
ipo_to_animdata(id, la->ipo, NULL, NULL);
|
||||
la->ipo->id.us--;
|
||||
la->ipo= NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* --------- Unconverted Animation Data ------------------ */
|
||||
/* For Animation data which may not be directly connected (i.e. not linked) to any other
|
||||
* data, we need to perform a separate pass to make sure that they are converted to standalone
|
||||
* Actions which may then be able to be reused. This does mean that we will be going over data that's
|
||||
* already been converted, but there are no problems with that.
|
||||
*
|
||||
* The most common case for this will be Action Constraints, or IPO's with Fake-Users.
|
||||
* We collect all drivers that were found into a temporary collection, and free them in one go, as they're
|
||||
* impossible to resolve.
|
||||
*/
|
||||
|
||||
/* actions */
|
||||
for (id= main->action.first; id; id= id->next) {
|
||||
bAction *act= (bAction *)id;
|
||||
|
||||
if (G.f & G_DEBUG) printf("\tconverting action %s \n", id->name+2);
|
||||
|
||||
/* be careful! some of the actions we encounter will be converted ones... */
|
||||
action_to_animato(act, &act->curves, &drivers);
|
||||
}
|
||||
|
||||
/* ipo's */
|
||||
for (id= main->ipo.first; id; id= id->next) {
|
||||
Ipo *ipo= (Ipo *)id;
|
||||
|
||||
if (G.f & G_DEBUG) printf("\tconverting ipo %s \n", id->name+2);
|
||||
|
||||
/* most likely this IPO has already been processed, so check if any curves left to convert */
|
||||
if (ipo->curve.first) {
|
||||
bAction *new_act;
|
||||
|
||||
/* add a new action for this, and convert all data into that action */
|
||||
new_act= add_empty_action("ConvIPO_Action"); // XXX need a better name...
|
||||
ipo_to_animato(ipo, NULL, NULL, &new_act->curves, &drivers);
|
||||
}
|
||||
|
||||
/* clear fake-users, and set user-count to zero to make sure it is cleared on file-save */
|
||||
ipo->id.us= 0;
|
||||
ipo->id.flag &= ~LIB_FAKEUSER;
|
||||
}
|
||||
|
||||
/* free unused drivers from actions + ipos */
|
||||
free_fcurves(&drivers);
|
||||
|
||||
printf("INFO: animato convert done \n"); // xxx debug
|
||||
}
|
||||
@@ -1281,58 +1622,6 @@ void *get_ipo_poin (ID *id, IpoCurve *icu, int *type)
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ID_LA: /* lamp channels ----------------------------- */
|
||||
{
|
||||
Lamp *la= (Lamp *)id;
|
||||
|
||||
switch (icu->adrcode) {
|
||||
case LA_ENERGY:
|
||||
poin= &(la->energy); break;
|
||||
case LA_COL_R:
|
||||
poin= &(la->r); break;
|
||||
case LA_COL_G:
|
||||
poin= &(la->g); break;
|
||||
case LA_COL_B:
|
||||
poin= &(la->b); break;
|
||||
case LA_DIST:
|
||||
poin= &(la->dist); break;
|
||||
case LA_SPOTSI:
|
||||
poin= &(la->spotsize); break;
|
||||
case LA_SPOTBL:
|
||||
poin= &(la->spotblend); break;
|
||||
case LA_QUAD1:
|
||||
poin= &(la->att1); break;
|
||||
case LA_QUAD2:
|
||||
poin= &(la->att2); break;
|
||||
case LA_HALOINT:
|
||||
poin= &(la->haint); break;
|
||||
}
|
||||
|
||||
if (poin == NULL) {
|
||||
if (icu->adrcode & MA_MAP1) mtex= la->mtex[0];
|
||||
else if (icu->adrcode & MA_MAP2) mtex= la->mtex[1];
|
||||
else if (icu->adrcode & MA_MAP3) mtex= la->mtex[2];
|
||||
else if (icu->adrcode & MA_MAP4) mtex= la->mtex[3];
|
||||
else if (icu->adrcode & MA_MAP5) mtex= la->mtex[4];
|
||||
else if (icu->adrcode & MA_MAP6) mtex= la->mtex[5];
|
||||
else if (icu->adrcode & MA_MAP7) mtex= la->mtex[6];
|
||||
else if (icu->adrcode & MA_MAP8) mtex= la->mtex[7];
|
||||
else if (icu->adrcode & MA_MAP9) mtex= la->mtex[8];
|
||||
else if (icu->adrcode & MA_MAP10) mtex= la->mtex[9];
|
||||
else if (icu->adrcode & MA_MAP11) mtex= la->mtex[10];
|
||||
else if (icu->adrcode & MA_MAP12) mtex= la->mtex[11];
|
||||
else if (icu->adrcode & MA_MAP13) mtex= la->mtex[12];
|
||||
else if (icu->adrcode & MA_MAP14) mtex= la->mtex[13];
|
||||
else if (icu->adrcode & MA_MAP15) mtex= la->mtex[14];
|
||||
else if (icu->adrcode & MA_MAP16) mtex= la->mtex[15];
|
||||
else if (icu->adrcode & MA_MAP17) mtex= la->mtex[16];
|
||||
else if (icu->adrcode & MA_MAP18) mtex= la->mtex[17];
|
||||
|
||||
if (mtex)
|
||||
poin= give_mtex_poin(mtex, (icu->adrcode & (MA_MAP1-1)));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ID_SO: /* sound channels ----------------------------- */
|
||||
{
|
||||
bSound *snd= (bSound *)id;
|
||||
|
||||
@@ -646,7 +646,7 @@ void do_rel_key(int start, int end, int tot, char *basispoin, Key *key, int mode
|
||||
|
||||
if(key->from==NULL) return;
|
||||
|
||||
printf("do_rel_key() \n");
|
||||
if (G.f & G_DEBUG) printf("do_rel_key() \n");
|
||||
|
||||
if( GS(key->from->name)==ID_ME ) {
|
||||
ofs[0]= sizeof(MVert);
|
||||
@@ -683,14 +683,14 @@ void do_rel_key(int start, int end, int tot, char *basispoin, Key *key, int mode
|
||||
if(kb!=key->refkey) {
|
||||
float icuval= kb->curval;
|
||||
|
||||
printf("\tdo rel key %s : %s = %f \n", key->id.name+2, kb->name, icuval);
|
||||
if (G.f & G_DEBUG) printf("\tdo rel key %s : %s = %f \n", key->id.name+2, kb->name, icuval);
|
||||
|
||||
/* only with value, and no difference allowed */
|
||||
if(!(kb->flag & KEYBLOCK_MUTE) && icuval!=0.0f && kb->totelem==tot) {
|
||||
KeyBlock *refb;
|
||||
float weight, *weights= kb->weights;
|
||||
|
||||
printf("\t\tnot skipped \n");
|
||||
if (G.f & G_DEBUG) printf("\t\tnot skipped \n");
|
||||
|
||||
poin= basispoin;
|
||||
from= kb->data;
|
||||
@@ -762,7 +762,7 @@ static void do_key(int start, int end, int tot, char *poin, Key *key, KeyBlock *
|
||||
|
||||
if(key->from==0) return;
|
||||
|
||||
printf("do_key() \n");
|
||||
if (G.f & G_DEBUG) printf("do_key() \n");
|
||||
|
||||
if( GS(key->from->name)==ID_ME ) {
|
||||
ofs[0]= sizeof(MVert);
|
||||
@@ -1024,10 +1024,10 @@ static int do_mesh_key(Scene *scene, Object *ob, Mesh *me)
|
||||
/* prevent python from screwing this up? anyhoo, the from pointer could be dropped */
|
||||
me->key->from= (ID *)me;
|
||||
|
||||
printf("do mesh key ob:%s me:%s ke:%s \n", ob->id.name+2, me->id.name+2, me->key->id.name+2);
|
||||
if (G.f & G_DEBUG) printf("do mesh key ob:%s me:%s ke:%s \n", ob->id.name+2, me->id.name+2, me->key->id.name+2);
|
||||
|
||||
if(me->key->slurph && me->key->type!=KEY_RELATIVE ) {
|
||||
printf("\tslurph key\n");
|
||||
if (G.f & G_DEBUG) printf("\tslurph key\n");
|
||||
|
||||
delta= me->key->slurph;
|
||||
delta/= me->totvert;
|
||||
@@ -1039,7 +1039,7 @@ static int do_mesh_key(Scene *scene, Object *ob, Mesh *me)
|
||||
/* in do_key and cp_key the case a>tot is handled */
|
||||
}
|
||||
|
||||
cfra= scene->r.cfra;
|
||||
cfra= (float)scene->r.cfra;
|
||||
|
||||
for(a=0; a<me->totvert; a+=step, cfra+= delta) {
|
||||
|
||||
@@ -1071,7 +1071,7 @@ static int do_mesh_key(Scene *scene, Object *ob, Mesh *me)
|
||||
if(me->key->type==KEY_RELATIVE) {
|
||||
KeyBlock *kb;
|
||||
|
||||
printf("\tdo relative \n");
|
||||
if (G.f & G_DEBUG) printf("\tdo relative \n");
|
||||
|
||||
for(kb= me->key->block.first; kb; kb= kb->next)
|
||||
kb->weights= get_weights_array(ob, kb->vgroup);
|
||||
@@ -1084,9 +1084,9 @@ static int do_mesh_key(Scene *scene, Object *ob, Mesh *me)
|
||||
}
|
||||
}
|
||||
else {
|
||||
printf("\tdo absolute \n");
|
||||
if (G.f & G_DEBUG) printf("\tdo absolute \n");
|
||||
|
||||
ctime= bsystem_time(scene, ob, scene->r.cfra, 0.0); // xxx old cruft
|
||||
ctime= bsystem_time(scene, ob, (float)scene->r.cfra, 0.0f); // xxx old cruft
|
||||
|
||||
#if 0 // XXX old animation system
|
||||
if(calc_ipo_spec(me->key->ipo, KEY_SPEED, &ctime)==0) {
|
||||
@@ -1207,10 +1207,10 @@ static int do_curve_key(Scene *scene, Curve *cu)
|
||||
/* in do_key and cp_key the case a>tot has been handled */
|
||||
}
|
||||
|
||||
cfra= scene->r.cfra;
|
||||
cfra= (float)scene->r.cfra;
|
||||
|
||||
for(a=0; a<tot; a+=step, cfra+= delta) {
|
||||
ctime= bsystem_time(scene, 0, cfra, 0.0); // XXX old cruft
|
||||
ctime= bsystem_time(scene, 0, cfra, 0.0f); // XXX old cruft
|
||||
#if 0 // XXX old animation system
|
||||
if(calc_ipo_spec(cu->key->ipo, KEY_SPEED, &ctime)==0) {
|
||||
ctime /= 100.0;
|
||||
@@ -1274,7 +1274,7 @@ static int do_latt_key(Scene *scene, Object *ob, Lattice *lt)
|
||||
delta= lt->key->slurph;
|
||||
delta/= (float)tot;
|
||||
|
||||
cfra= scene->r.cfra;
|
||||
cfra= (float)scene->r.cfra;
|
||||
|
||||
for(a=0; a<tot; a++, cfra+= delta) {
|
||||
|
||||
@@ -1346,7 +1346,7 @@ int do_ob_key(Scene *scene, Object *ob)
|
||||
if(ob->shapeflag & (OB_SHAPE_LOCK|OB_SHAPE_TEMPLOCK)) {
|
||||
KeyBlock *kb= BLI_findlink(&key->block, ob->shapenr-1);
|
||||
|
||||
printf("ob %s, key %s locked \n", ob->id.name+2, key->id.name+2);
|
||||
if (G.f & G_DEBUG) printf("ob %s, key %s locked \n", ob->id.name+2, key->id.name+2);
|
||||
|
||||
if(kb && (kb->flag & KEYBLOCK_MUTE))
|
||||
kb= key->refkey;
|
||||
@@ -1393,7 +1393,7 @@ int do_ob_key(Scene *scene, Object *ob)
|
||||
#endif // XXX old animation system
|
||||
/* do shapekey local drivers */
|
||||
float ctime= (float)scene->r.cfra; // XXX this needs to be checked
|
||||
printf("ob %s - do shapekey (%s) drivers \n", ob->id.name+2, key->id.name+2);
|
||||
if (G.f & G_DEBUG) printf("ob %s - do shapekey (%s) drivers \n", ob->id.name+2, key->id.name+2);
|
||||
BKE_animsys_evaluate_animdata(&key->id, key->adt, ctime, ADT_RECALC_DRIVERS);
|
||||
|
||||
if(ob->type==OB_MESH) return do_mesh_key(scene, ob, ob->data);
|
||||
|
||||
@@ -83,8 +83,9 @@
|
||||
#include "BLI_blenlib.h"
|
||||
#include "BLI_dynstr.h"
|
||||
|
||||
#include "BKE_library.h"
|
||||
#include "BKE_animsys.h"
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_library.h"
|
||||
#include "BKE_main.h"
|
||||
#include "BKE_global.h"
|
||||
#include "BKE_sound.h"
|
||||
@@ -401,6 +402,45 @@ void *alloc_libblock(ListBase *lb, short type, const char *name)
|
||||
/* from blendef: */
|
||||
#define GS(a) (*((short *)(a)))
|
||||
|
||||
/* by spec, animdata is first item after ID */
|
||||
/* we still read ->adt itself, to ensure compiler warns when it doesnt exist */
|
||||
static void id_copy_animdata(ID *id)
|
||||
{
|
||||
switch(GS(id->name)) {
|
||||
case ID_OB:
|
||||
((Object *)id)->adt= BKE_copy_animdata(((Object *)id)->adt);
|
||||
break;
|
||||
case ID_CU:
|
||||
((Curve *)id)->adt= BKE_copy_animdata(((Curve *)id)->adt);
|
||||
break;
|
||||
case ID_CA:
|
||||
((Camera *)id)->adt= BKE_copy_animdata(((Camera *)id)->adt);
|
||||
break;
|
||||
case ID_KE:
|
||||
((Key *)id)->adt= BKE_copy_animdata(((Key *)id)->adt);
|
||||
break;
|
||||
case ID_LA:
|
||||
((Lamp *)id)->adt= BKE_copy_animdata(((Lamp *)id)->adt);
|
||||
break;
|
||||
case ID_MA:
|
||||
((Material *)id)->adt= BKE_copy_animdata(((Material *)id)->adt);
|
||||
break;
|
||||
case ID_NT:
|
||||
((bNodeTree *)id)->adt= BKE_copy_animdata(((bNodeTree *)id)->adt);
|
||||
break;
|
||||
case ID_SCE:
|
||||
((Scene *)id)->adt= BKE_copy_animdata(((Scene *)id)->adt);
|
||||
break;
|
||||
case ID_TE:
|
||||
((Tex *)id)->adt= BKE_copy_animdata(((Tex *)id)->adt);
|
||||
break;
|
||||
case ID_WO:
|
||||
((World *)id)->adt= BKE_copy_animdata(((World *)id)->adt);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* used everywhere in blenkernel and text.c */
|
||||
void *copy_libblock(void *rt)
|
||||
{
|
||||
@@ -429,6 +469,8 @@ void *copy_libblock(void *rt)
|
||||
idn->flag |= LIB_NEW;
|
||||
if (id->properties) idn->properties = IDP_CopyProperty(id->properties);
|
||||
|
||||
id_copy_animdata(id);
|
||||
|
||||
return idn;
|
||||
}
|
||||
|
||||
|
||||
@@ -1158,6 +1158,104 @@ bNodeTree *ntreeCopyTree(bNodeTree *ntree, int internal_select)
|
||||
return newtree;
|
||||
}
|
||||
|
||||
/* *************** preview *********** */
|
||||
/* if node->preview, then we assume the rect to exist */
|
||||
|
||||
static void node_free_preview(bNode *node)
|
||||
{
|
||||
if(node->preview) {
|
||||
if(node->preview->rect)
|
||||
MEM_freeN(node->preview->rect);
|
||||
MEM_freeN(node->preview);
|
||||
node->preview= NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void node_init_preview(bNode *node, int xsize, int ysize)
|
||||
{
|
||||
|
||||
if(node->preview==NULL) {
|
||||
node->preview= MEM_callocN(sizeof(bNodePreview), "node preview");
|
||||
// printf("added preview %s\n", node->name);
|
||||
}
|
||||
|
||||
/* node previews can get added with variable size this way */
|
||||
if(xsize==0 || ysize==0)
|
||||
return;
|
||||
|
||||
/* sanity checks & initialize */
|
||||
if(node->preview->rect) {
|
||||
if(node->preview->xsize!=xsize && node->preview->ysize!=ysize) {
|
||||
MEM_freeN(node->preview->rect);
|
||||
node->preview->rect= NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if(node->preview->rect==NULL) {
|
||||
node->preview->rect= MEM_callocN(4*xsize + xsize*ysize*sizeof(float)*4, "node preview rect");
|
||||
node->preview->xsize= xsize;
|
||||
node->preview->ysize= ysize;
|
||||
}
|
||||
}
|
||||
|
||||
void ntreeInitPreview(bNodeTree *ntree, int xsize, int ysize)
|
||||
{
|
||||
bNode *node;
|
||||
|
||||
if(ntree==NULL)
|
||||
return;
|
||||
|
||||
for(node= ntree->nodes.first; node; node= node->next) {
|
||||
if(node->typeinfo->flag & NODE_PREVIEW) /* hrms, check for closed nodes? */
|
||||
node_init_preview(node, xsize, ysize);
|
||||
if(node->type==NODE_GROUP && (node->flag & NODE_GROUP_EDIT))
|
||||
ntreeInitPreview((bNodeTree *)node->id, xsize, ysize);
|
||||
}
|
||||
}
|
||||
|
||||
static void nodeClearPreview(bNode *node)
|
||||
{
|
||||
if(node->preview && node->preview->rect)
|
||||
memset(node->preview->rect, 0, MEM_allocN_len(node->preview->rect));
|
||||
}
|
||||
|
||||
/* use it to enforce clear */
|
||||
void ntreeClearPreview(bNodeTree *ntree)
|
||||
{
|
||||
bNode *node;
|
||||
|
||||
if(ntree==NULL)
|
||||
return;
|
||||
|
||||
for(node= ntree->nodes.first; node; node= node->next) {
|
||||
if(node->typeinfo->flag & NODE_PREVIEW)
|
||||
nodeClearPreview(node);
|
||||
if(node->type==NODE_GROUP && (node->flag & NODE_GROUP_EDIT))
|
||||
ntreeClearPreview((bNodeTree *)node->id);
|
||||
}
|
||||
}
|
||||
|
||||
/* hack warning! this function is only used for shader previews, and
|
||||
since it gets called multiple times per pixel for Ztransp we only
|
||||
add the color once. Preview gets cleared before it starts render though */
|
||||
void nodeAddToPreview(bNode *node, float *col, int x, int y)
|
||||
{
|
||||
bNodePreview *preview= node->preview;
|
||||
if(preview) {
|
||||
if(x>=0 && y>=0) {
|
||||
if(x<preview->xsize && y<preview->ysize) {
|
||||
float *tar= preview->rect+ 4*((preview->xsize*y) + x);
|
||||
//if(tar[0]==0.0f) {
|
||||
QUATCOPY(tar, col);
|
||||
//}
|
||||
}
|
||||
//else printf("prv out bound x y %d %d\n", x, y);
|
||||
}
|
||||
//else printf("prv out bound x y %d %d\n", x, y);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* ************** Free stuff ********** */
|
||||
|
||||
/* goes over entire tree */
|
||||
@@ -1215,11 +1313,8 @@ void nodeFreeNode(bNodeTree *ntree, bNode *node)
|
||||
BLI_freelistN(&node->inputs);
|
||||
BLI_freelistN(&node->outputs);
|
||||
|
||||
if(node->preview) {
|
||||
if(node->preview->rect)
|
||||
MEM_freeN(node->preview->rect);
|
||||
MEM_freeN(node->preview);
|
||||
}
|
||||
node_free_preview(node);
|
||||
|
||||
if(node->typeinfo && node->typeinfo->freestoragefunc) {
|
||||
node->typeinfo->freestoragefunc(node);
|
||||
}
|
||||
@@ -1652,14 +1747,8 @@ void NodeTagChanged(bNodeTree *ntree, bNode *node)
|
||||
|
||||
for(sock= node->outputs.first; sock; sock= sock->next) {
|
||||
if(sock->ns.data) {
|
||||
free_compbuf(sock->ns.data);
|
||||
sock->ns.data= NULL;
|
||||
|
||||
//if(node->preview && node->preview->rect) {
|
||||
// MEM_freeN(node->preview->rect);
|
||||
// node->preview->rect= NULL;
|
||||
//}
|
||||
|
||||
//free_compbuf(sock->ns.data);
|
||||
//sock->ns.data= NULL;
|
||||
}
|
||||
}
|
||||
node->need_exec= 1;
|
||||
@@ -1683,95 +1772,6 @@ void NodeTagIDChanged(bNodeTree *ntree, ID *id)
|
||||
}
|
||||
|
||||
|
||||
/* *************** preview *********** */
|
||||
|
||||
/* if node->preview, then we assume the rect to exist */
|
||||
|
||||
static void nodeInitPreview(bNode *node, int xsize, int ysize)
|
||||
{
|
||||
|
||||
if(node->preview==NULL) {
|
||||
node->preview= MEM_callocN(sizeof(bNodePreview), "node preview");
|
||||
// printf("added preview %s\n", node->name);
|
||||
}
|
||||
|
||||
/* node previews can get added with variable size this way */
|
||||
if(xsize==0 || ysize==0)
|
||||
return;
|
||||
|
||||
/* sanity checks & initialize */
|
||||
if(node->preview->rect) {
|
||||
if(node->preview->xsize!=xsize && node->preview->ysize!=ysize) {
|
||||
MEM_freeN(node->preview->rect);
|
||||
node->preview->rect= NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if(node->preview->rect==NULL) {
|
||||
node->preview->rect= MEM_callocN(4*xsize + xsize*ysize*sizeof(float)*4, "node preview rect");
|
||||
node->preview->xsize= xsize;
|
||||
node->preview->ysize= ysize;
|
||||
}
|
||||
}
|
||||
|
||||
void ntreeInitPreview(bNodeTree *ntree, int xsize, int ysize)
|
||||
{
|
||||
bNode *node;
|
||||
|
||||
if(ntree==NULL)
|
||||
return;
|
||||
|
||||
for(node= ntree->nodes.first; node; node= node->next) {
|
||||
if(node->typeinfo->flag & NODE_PREVIEW) /* hrms, check for closed nodes? */
|
||||
nodeInitPreview(node, xsize, ysize);
|
||||
if(node->type==NODE_GROUP && (node->flag & NODE_GROUP_EDIT))
|
||||
ntreeInitPreview((bNodeTree *)node->id, xsize, ysize);
|
||||
}
|
||||
}
|
||||
|
||||
static void nodeClearPreview(bNode *node)
|
||||
{
|
||||
if(node->preview && node->preview->rect)
|
||||
memset(node->preview->rect, 0, MEM_allocN_len(node->preview->rect));
|
||||
}
|
||||
|
||||
/* use it to enforce clear */
|
||||
void ntreeClearPreview(bNodeTree *ntree)
|
||||
{
|
||||
bNode *node;
|
||||
|
||||
if(ntree==NULL)
|
||||
return;
|
||||
|
||||
for(node= ntree->nodes.first; node; node= node->next) {
|
||||
if(node->typeinfo->flag & NODE_PREVIEW)
|
||||
nodeClearPreview(node);
|
||||
if(node->type==NODE_GROUP && (node->flag & NODE_GROUP_EDIT))
|
||||
ntreeClearPreview((bNodeTree *)node->id);
|
||||
}
|
||||
}
|
||||
|
||||
/* hack warning! this function is only used for shader previews, and
|
||||
since it gets called multiple times per pixel for Ztransp we only
|
||||
add the color once. Preview gets cleared before it starts render though */
|
||||
void nodeAddToPreview(bNode *node, float *col, int x, int y)
|
||||
{
|
||||
bNodePreview *preview= node->preview;
|
||||
if(preview) {
|
||||
if(x>=0 && y>=0) {
|
||||
if(x<preview->xsize && y<preview->ysize) {
|
||||
float *tar= preview->rect+ 4*((preview->xsize*y) + x);
|
||||
//if(tar[0]==0.0f) {
|
||||
QUATCOPY(tar, col);
|
||||
//}
|
||||
}
|
||||
//else printf("prv out bound x y %d %d\n", x, y);
|
||||
}
|
||||
//else printf("prv out bound x y %d %d\n", x, y);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* ******************* executing ************* */
|
||||
|
||||
@@ -2205,7 +2205,7 @@ static void *exec_composite_node(void *node_v)
|
||||
bNodeStack *nsin[MAX_SOCKET]; /* arbitrary... watch this */
|
||||
bNodeStack *nsout[MAX_SOCKET]; /* arbitrary... watch this */
|
||||
bNode *node= node_v;
|
||||
ThreadData *thd= (ThreadData *)node->new_node; /* abuse */
|
||||
ThreadData *thd= (ThreadData *)node->threaddata;
|
||||
|
||||
node_get_stack(node, thd->stack, nsin, nsout);
|
||||
|
||||
@@ -2300,7 +2300,7 @@ static int setExecutableNodes(bNodeTree *ntree, ThreadData *thd)
|
||||
}
|
||||
else {
|
||||
/* tag for getExecutableNode() */
|
||||
node->exec= NODE_READY|NODE_FINISHED;
|
||||
node->exec= NODE_READY|NODE_FINISHED|NODE_SKIPPED;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -2410,7 +2410,7 @@ void ntreeCompositExecTree(bNodeTree *ntree, RenderData *rd, int do_preview)
|
||||
|
||||
/* sets need_exec tags in nodes */
|
||||
totnode= setExecutableNodes(ntree, &thdata);
|
||||
|
||||
|
||||
BLI_init_threads(&threads, exec_composite_node, rd->threads);
|
||||
|
||||
while(rendering) {
|
||||
@@ -2418,7 +2418,7 @@ void ntreeCompositExecTree(bNodeTree *ntree, RenderData *rd, int do_preview)
|
||||
if(BLI_available_threads(&threads)) {
|
||||
node= getExecutableNode(ntree);
|
||||
if(node) {
|
||||
|
||||
|
||||
if(ntree->timecursor)
|
||||
ntree->timecursor(ntree->tch, totnode);
|
||||
if(ntree->stats_draw) {
|
||||
@@ -2428,7 +2428,7 @@ void ntreeCompositExecTree(bNodeTree *ntree, RenderData *rd, int do_preview)
|
||||
}
|
||||
totnode--;
|
||||
|
||||
node->new_node = (bNode *)&thdata;
|
||||
node->threaddata = &thdata;
|
||||
node->exec= NODE_PROCESSING;
|
||||
BLI_insert_thread(&threads, node);
|
||||
}
|
||||
@@ -2461,12 +2461,127 @@ void ntreeCompositExecTree(bNodeTree *ntree, RenderData *rd, int do_preview)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
BLI_end_threads(&threads);
|
||||
|
||||
ntreeEndExecTree(ntree);
|
||||
}
|
||||
|
||||
|
||||
/* ********** copy composite tree entirely, to allow threaded exec ******************* */
|
||||
/* ***************** do NOT execute this in a thread! ****************** */
|
||||
|
||||
/* returns localized composite tree for execution in threads */
|
||||
/* local tree then owns all compbufs */
|
||||
bNodeTree *ntreeLocalize(bNodeTree *ntree)
|
||||
{
|
||||
bNodeTree *ltree= ntreeCopyTree(ntree, 0);
|
||||
bNode *node;
|
||||
bNodeSocket *sock;
|
||||
|
||||
/* move over the compbufs */
|
||||
/* right after ntreeCopyTree() oldsock pointers are valid */
|
||||
for(node= ntree->nodes.first; node; node= node->next) {
|
||||
|
||||
/* store new_node pointer to original */
|
||||
node->new_node->new_node= node;
|
||||
/* ensure new user input gets handled ok */
|
||||
node->need_exec= 0;
|
||||
|
||||
if(ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) {
|
||||
if(node->id && (node->flag & NODE_DO_OUTPUT)) {
|
||||
node->new_node->id= (ID *)BKE_image_copy((Image *)node->id);
|
||||
}
|
||||
}
|
||||
|
||||
for(sock= node->outputs.first; sock; sock= sock->next) {
|
||||
|
||||
sock->new_sock->ns.data= sock->ns.data;
|
||||
sock->ns.data= NULL;
|
||||
sock->new_sock->new_sock= sock;
|
||||
}
|
||||
}
|
||||
|
||||
return ltree;
|
||||
}
|
||||
|
||||
static int node_exists(bNodeTree *ntree, bNode *testnode)
|
||||
{
|
||||
bNode *node= ntree->nodes.first;
|
||||
for(; node; node= node->next)
|
||||
if(node==testnode)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int outsocket_exists(bNode *node, bNodeSocket *testsock)
|
||||
{
|
||||
bNodeSocket *sock= node->outputs.first;
|
||||
for(; sock; sock= sock->next)
|
||||
if(sock==testsock)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* sync local composite with real tree */
|
||||
/* local composite is supposed to be running, be careful moving previews! */
|
||||
void ntreeLocalSync(bNodeTree *localtree, bNodeTree *ntree)
|
||||
{
|
||||
bNode *lnode;
|
||||
|
||||
/* move over the compbufs and previews */
|
||||
for(lnode= localtree->nodes.first; lnode; lnode= lnode->next) {
|
||||
if( (lnode->exec & NODE_READY) && !(lnode->exec & NODE_SKIPPED) ) {
|
||||
if(node_exists(ntree, lnode->new_node)) {
|
||||
|
||||
if(lnode->preview && lnode->preview->rect) {
|
||||
node_free_preview(lnode->new_node);
|
||||
lnode->new_node->preview= lnode->preview;
|
||||
lnode->preview= NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* merge local tree results back, and free local tree */
|
||||
/* we have to assume the editor already changed completely */
|
||||
void ntreeLocalMerge(bNodeTree *localtree, bNodeTree *ntree)
|
||||
{
|
||||
bNode *lnode;
|
||||
bNodeSocket *lsock;
|
||||
|
||||
/* move over the compbufs and previews */
|
||||
for(lnode= localtree->nodes.first; lnode; lnode= lnode->next) {
|
||||
if(node_exists(ntree, lnode->new_node)) {
|
||||
|
||||
if(lnode->preview && lnode->preview->rect) {
|
||||
node_free_preview(lnode->new_node);
|
||||
lnode->new_node->preview= lnode->preview;
|
||||
lnode->preview= NULL;
|
||||
}
|
||||
|
||||
if(ELEM(lnode->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) {
|
||||
if(lnode->id && (lnode->flag & NODE_DO_OUTPUT)) {
|
||||
BKE_image_merge((Image *)lnode->new_node->id, (Image *)lnode->id);
|
||||
}
|
||||
}
|
||||
|
||||
for(lsock= lnode->outputs.first; lsock; lsock= lsock->next) {
|
||||
if(outsocket_exists(lnode->new_node, lsock->new_sock)) {
|
||||
lsock->new_sock->ns.data= lsock->ns.data;
|
||||
lsock->ns.data= NULL;
|
||||
lsock->new_sock= NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ntreeFreeTree(localtree);
|
||||
MEM_freeN(localtree);
|
||||
}
|
||||
|
||||
/* *********************************************** */
|
||||
|
||||
/* GPU material from shader nodes */
|
||||
|
||||
static void gpu_from_node_stack(ListBase *sockets, bNodeStack **ns, GPUNodeStack *gs)
|
||||
|
||||
@@ -1617,7 +1617,7 @@ static void ob_parbone(Object *ob, Object *par, float mat[][4])
|
||||
bPoseChannel *pchan;
|
||||
float vec[3];
|
||||
|
||||
if (ob->type!=OB_ARMATURE) {
|
||||
if (par->type!=OB_ARMATURE) {
|
||||
Mat4One(mat);
|
||||
return;
|
||||
}
|
||||
@@ -2273,8 +2273,9 @@ void object_handle_update(Scene *scene, Object *ob)
|
||||
if(ob->recalc & OB_RECALC) {
|
||||
|
||||
if(ob->recalc & OB_RECALC_OB) {
|
||||
|
||||
printf("recalcob %s\n", ob->id.name+2);
|
||||
|
||||
if (G.f & G_DEBUG)
|
||||
printf("recalcob %s\n", ob->id.name+2);
|
||||
|
||||
/* handle proxy copy for target */
|
||||
if(ob->id.lib && ob->proxy_from) {
|
||||
@@ -2296,7 +2297,8 @@ void object_handle_update(Scene *scene, Object *ob)
|
||||
|
||||
if(ob->recalc & OB_RECALC_DATA) {
|
||||
|
||||
printf("recalcdata %s\n", ob->id.name+2);
|
||||
if (G.f & G_DEBUG)
|
||||
printf("recalcdata %s\n", ob->id.name+2);
|
||||
|
||||
/* includes all keys and modifiers */
|
||||
if(ob->type==OB_MESH) {
|
||||
|
||||
@@ -658,9 +658,6 @@ void sculptsession_free(Sculpt *sculpt)
|
||||
if(ss->projverts)
|
||||
MEM_freeN(ss->projverts);
|
||||
|
||||
if(ss->radialcontrol)
|
||||
MEM_freeN(ss->radialcontrol);
|
||||
|
||||
if(ss->fmap)
|
||||
MEM_freeN(ss->fmap);
|
||||
|
||||
|
||||
@@ -184,6 +184,17 @@ void seq_free_sequence(Editing *ed, Sequence *seq)
|
||||
MEM_freeN(seq);
|
||||
}
|
||||
|
||||
Editing *seq_give_editing(Scene *scene, int alloc)
|
||||
{
|
||||
if (scene->ed == NULL && alloc) {
|
||||
Editing *ed;
|
||||
|
||||
ed= scene->ed= MEM_callocN( sizeof(Editing), "addseq");
|
||||
ed->seqbasep= &ed->seqbase;
|
||||
}
|
||||
return scene->ed;
|
||||
}
|
||||
|
||||
void seq_free_editing(Editing *ed)
|
||||
{
|
||||
MetaStack *ms;
|
||||
@@ -594,10 +605,10 @@ void sort_seq(Scene *scene)
|
||||
{
|
||||
/* all strips together per kind, and in order of y location ("machine") */
|
||||
ListBase seqbase, effbase;
|
||||
Editing *ed;
|
||||
Editing *ed= seq_give_editing(scene, FALSE);
|
||||
Sequence *seq, *seqt;
|
||||
|
||||
ed= scene->ed;
|
||||
|
||||
if(ed==NULL) return;
|
||||
|
||||
seqbase.first= seqbase.last= 0;
|
||||
@@ -1036,14 +1047,11 @@ static int evaluate_seq_frame_gen(Sequence ** seq_arr, ListBase *seqbase, int cf
|
||||
|
||||
int evaluate_seq_frame(Scene *scene, int cfra)
|
||||
{
|
||||
Editing *ed;
|
||||
Sequence *seq_arr[MAXSEQ+1];
|
||||
|
||||
ed= scene->ed;
|
||||
if(ed==NULL) return 0;
|
||||
|
||||
return evaluate_seq_frame_gen(seq_arr, ed->seqbasep, cfra);
|
||||
Editing *ed= seq_give_editing(scene, FALSE);
|
||||
Sequence *seq_arr[MAXSEQ+1];
|
||||
|
||||
if(ed==NULL) return 0;
|
||||
return evaluate_seq_frame_gen(seq_arr, ed->seqbasep, cfra);
|
||||
}
|
||||
|
||||
static int video_seq_is_rendered(Sequence * seq)
|
||||
@@ -2403,12 +2411,12 @@ static TStripElem* do_build_seq_array_recursively(Scene *scene,
|
||||
|
||||
static ImBuf *give_ibuf_seq_impl(Scene *scene, int rectx, int recty, int cfra, int chanshown)
|
||||
{
|
||||
Editing *ed;
|
||||
Editing *ed= seq_give_editing(scene, FALSE);
|
||||
int count;
|
||||
ListBase *seqbasep;
|
||||
TStripElem *se;
|
||||
|
||||
ed= scene->ed;
|
||||
|
||||
if(ed==NULL) return NULL;
|
||||
|
||||
count = BLI_countlist(&ed->metastack);
|
||||
@@ -2818,7 +2826,7 @@ static void free_anim_seq(Sequence *seq)
|
||||
|
||||
void free_imbuf_seq_except(Scene *scene, int cfra)
|
||||
{
|
||||
Editing *ed= scene->ed;
|
||||
Editing *ed= seq_give_editing(scene, FALSE);
|
||||
Sequence *seq;
|
||||
TStripElem *se;
|
||||
int a;
|
||||
@@ -2960,10 +2968,10 @@ static int update_changed_seq_recurs(Scene *scene, Sequence *seq, Sequence *chan
|
||||
|
||||
void update_changed_seq_and_deps(Scene *scene, Sequence *changed_seq, int len_change, int ibuf_change)
|
||||
{
|
||||
Editing *ed= scene->ed;
|
||||
Editing *ed= seq_give_editing(scene, FALSE);
|
||||
Sequence *seq;
|
||||
|
||||
if (!ed) return;
|
||||
if (ed==NULL) return;
|
||||
|
||||
for (seq=ed->seqbase.first; seq; seq=seq->next)
|
||||
update_changed_seq_recurs(scene, seq, changed_seq, len_change, ibuf_change);
|
||||
@@ -2972,7 +2980,7 @@ void update_changed_seq_and_deps(Scene *scene, Sequence *changed_seq, int len_ch
|
||||
void free_imbuf_seq_with_ipo(Scene *scene, struct Ipo *ipo)
|
||||
{
|
||||
/* force update of all sequences with this ipo, on ipo changes */
|
||||
Editing *ed= scene->ed;
|
||||
Editing *ed= seq_give_editing(scene, FALSE);
|
||||
Sequence *seq;
|
||||
|
||||
if(ed==NULL) return;
|
||||
|
||||
@@ -201,7 +201,9 @@ static struct bSound *snd_stepdata__internal(struct bSound *snd, int step_next)
|
||||
return snd;
|
||||
}
|
||||
|
||||
static struct Sequence *seq_stepdata__internal(struct BPathIterator *bpi, int step_next) {
|
||||
static struct Sequence *seq_stepdata__internal(struct BPathIterator *bpi, int step_next)
|
||||
{
|
||||
Editing *ed;
|
||||
Sequence *seq;
|
||||
|
||||
/* Initializing */
|
||||
@@ -214,11 +216,11 @@ static struct Sequence *seq_stepdata__internal(struct BPathIterator *bpi, int st
|
||||
}
|
||||
|
||||
while (bpi->seqdata.scene) {
|
||||
|
||||
if (bpi->seqdata.scene->ed) {
|
||||
ed= seq_give_editing(bpi->seqdata.scene, 0);
|
||||
if (ed) {
|
||||
if (bpi->seqdata.seqar == NULL) {
|
||||
/* allocate the sequencer array */
|
||||
seq_array(bpi->seqdata.scene->ed, &bpi->seqdata.seqar, &bpi->seqdata.totseq, 0);
|
||||
seq_array(ed, &bpi->seqdata.seqar, &bpi->seqdata.totseq, 0);
|
||||
bpi->seqdata.seq = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -4152,6 +4152,22 @@ static void lib_link_screen(FileData *fd, Main *main)
|
||||
|
||||
ssound->sound= newlibadr_us(fd, sc->id.lib, ssound->sound);
|
||||
}
|
||||
else if(sl->spacetype==SPACE_NODE) {
|
||||
SpaceNode *snode= (SpaceNode *)sl;
|
||||
|
||||
snode->id= newlibadr(fd, sc->id.lib, snode->id);
|
||||
|
||||
/* internal data, a bit patchy */
|
||||
if(snode->id) {
|
||||
if(GS(snode->id->name)==ID_MA)
|
||||
snode->nodetree= ((Material *)snode->id)->nodetree;
|
||||
else if(GS(snode->id->name)==ID_SCE)
|
||||
snode->nodetree= ((Scene *)snode->id)->nodetree;
|
||||
else if(GS(snode->id->name)==ID_TE)
|
||||
snode->nodetree= ((Tex *)snode->id)->nodetree;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
sa= sa->next;
|
||||
}
|
||||
@@ -4345,8 +4361,19 @@ void lib_link_screen_restore(Main *newmain, bScreen *curscreen, Scene *curscene)
|
||||
else if(sl->spacetype==SPACE_NODE) {
|
||||
SpaceNode *snode= (SpaceNode *)sl;
|
||||
|
||||
snode->nodetree= snode->edittree= NULL;
|
||||
snode->flag |= SNODE_DO_PREVIEW;
|
||||
snode->id= restore_pointer_by_name(newmain, snode->id, 1);
|
||||
snode->edittree= NULL;
|
||||
|
||||
if(snode->id==NULL)
|
||||
snode->nodetree= NULL;
|
||||
else {
|
||||
if(GS(snode->id->name)==ID_MA)
|
||||
snode->nodetree= ((Material *)snode->id)->nodetree;
|
||||
else if(GS(snode->id->name)==ID_SCE)
|
||||
snode->nodetree= ((Scene *)snode->id)->nodetree;
|
||||
else if(GS(snode->id->name)==ID_TE)
|
||||
snode->nodetree= ((Tex *)snode->id)->nodetree;
|
||||
}
|
||||
}
|
||||
}
|
||||
sa= sa->next;
|
||||
@@ -4544,7 +4571,6 @@ static void direct_link_screen(FileData *fd, bScreen *sc)
|
||||
link_gpencil(fd, snode->gpd);
|
||||
}
|
||||
snode->nodetree= snode->edittree= NULL;
|
||||
snode->flag |= SNODE_DO_PREVIEW;
|
||||
}
|
||||
else if(sl->spacetype==SPACE_SEQ) {
|
||||
SpaceSeq *sseq= (SpaceSeq *)sl;
|
||||
@@ -5454,11 +5480,7 @@ static void area_add_window_regions(ScrArea *sa, SpaceLink *sl, ListBase *lb)
|
||||
/* init mainarea view2d */
|
||||
ar->v2d.scroll |= (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL);
|
||||
ar->v2d.scroll |= (V2D_SCROLL_LEFT|V2D_SCROLL_SCALE_VERTICAL);
|
||||
|
||||
/* init dopesheet */
|
||||
// XXX move this elsewhere instead?
|
||||
sipo->ads= MEM_callocN(sizeof(bDopeSheet), "GraphEdit DopeSheet");
|
||||
|
||||
|
||||
//ar->v2d.flag |= V2D_IS_INITIALISED;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ SET(INC ../windowmanager
|
||||
../../../intern/ghost ../../../intern/opennl/extern ../../../extern/glew/include
|
||||
../nodes
|
||||
../gpu
|
||||
../blenfont
|
||||
${SDL_INC}
|
||||
)
|
||||
|
||||
|
||||
@@ -1025,7 +1025,13 @@ static void mouse_anim_channels (bAnimContext *ac, float x, int channel_index, s
|
||||
case ANIMTYPE_FILLACTD:
|
||||
{
|
||||
bAction *act= (bAction *)ale->data;
|
||||
act->flag ^= ACT_EXPANDED;
|
||||
act->flag ^= ACT_COLLAPSED;
|
||||
}
|
||||
break;
|
||||
case ANIMTYPE_FILLDRIVERS:
|
||||
{
|
||||
AnimData *adt= (AnimData* )ale->data;
|
||||
adt->flag ^= ADT_DRIVERS_COLLAPSED;
|
||||
}
|
||||
break;
|
||||
case ANIMTYPE_FILLMATD:
|
||||
@@ -1126,6 +1132,11 @@ static void mouse_anim_channels (bAnimContext *ac, float x, int channel_index, s
|
||||
else {
|
||||
/* select/deselect */
|
||||
fcu->flag ^= FCURVE_SELECTED;
|
||||
|
||||
if (fcu->flag & FCURVE_SELECTED)
|
||||
fcu->flag |= FCURVE_ACTIVE;
|
||||
else
|
||||
fcu->flag &= ~FCURVE_ACTIVE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -145,6 +145,8 @@ void ANIM_animdata_send_notifiers (bContext *C, bAnimContext *ac, short data_cha
|
||||
/* types of notifiers to send, depends on the editor context */
|
||||
switch (ac->datatype) {
|
||||
case ANIMCONT_DOPESHEET: /* dopesheet */
|
||||
case ANIMCONT_FCURVES: /* fcurve editor */
|
||||
case ANIMCONT_DRIVERS: /* drivers editor */ // XXX probably this will need separate handling, since these are part of dependency system
|
||||
{
|
||||
/* what action was taken */
|
||||
switch (data_changed) {
|
||||
@@ -153,8 +155,9 @@ void ANIM_animdata_send_notifiers (bContext *C, bAnimContext *ac, short data_cha
|
||||
// XXX what about other cases? maybe we need general ND_KEYFRAMES or ND_ANIMATION?
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL);
|
||||
break;
|
||||
//case ANIM_CHANGED_KEYFRAMES_SELECT: // XXX what to do here?
|
||||
// break;
|
||||
case ANIM_CHANGED_KEYFRAMES_SELECT: // XXX what to do here?
|
||||
WM_event_add_notifier(C, NC_SCENE, NULL);
|
||||
break;
|
||||
case ANIM_CHANGED_CHANNELS:
|
||||
// XXX err... check available datatypes in dopesheet first?
|
||||
// FIXME: this currently doesn't work (to update own view)
|
||||
|
||||
@@ -199,6 +199,10 @@ static short actedit_get_context (bAnimContext *ac, SpaceAction *saction)
|
||||
/* Get data being edited in Graph Editor (depending on current 'mode') */
|
||||
static short graphedit_get_context (bAnimContext *ac, SpaceIpo *sipo)
|
||||
{
|
||||
/* init dopesheet data if non-existant (i.e. for old files) */
|
||||
if (sipo->ads == NULL)
|
||||
sipo->ads= MEM_callocN(sizeof(bDopeSheet), "GraphEdit DopeSheet");
|
||||
|
||||
/* sync settings with current view status, then return appropriate data */
|
||||
switch (sipo->mode) {
|
||||
case SIPO_MODE_ANIMATION: /* Animation F-Curve Editor */
|
||||
@@ -217,7 +221,7 @@ static short graphedit_get_context (bAnimContext *ac, SpaceIpo *sipo)
|
||||
sipo->ads->source= (ID *)ac->scene;
|
||||
sipo->ads->filterflag |= ADS_FILTER_ONLYDRIVERS;
|
||||
|
||||
ac->datatype= ANIMCONT_FCURVES;
|
||||
ac->datatype= ANIMCONT_DRIVERS;
|
||||
ac->data= sipo->ads;
|
||||
|
||||
ac->mode= sipo->mode;
|
||||
@@ -302,6 +306,9 @@ short ANIM_animdata_get_context (const bContext *C, bAnimContext *ac)
|
||||
/* quick macro to test if AnimData is usable */
|
||||
#define ANIMDATA_HAS_KEYS(id) ((id)->adt && (id)->adt->action)
|
||||
|
||||
/* quick macro to test if AnimData is usable for drivers */
|
||||
#define ANIMDATA_HAS_DRIVERS(id) ((id)->adt && (id)->adt->drivers.first)
|
||||
|
||||
/* ----------- 'Private' Stuff --------------- */
|
||||
|
||||
/* this function allocates memory for a new bAnimListElem struct for the
|
||||
@@ -347,6 +354,17 @@ bAnimListElem *make_new_animlistelem (void *data, short datatype, void *owner, s
|
||||
ale->datatype= ALE_ACT;
|
||||
}
|
||||
break;
|
||||
case ANIMTYPE_FILLDRIVERS:
|
||||
{
|
||||
AnimData *adt= (AnimData *)data;
|
||||
|
||||
ale->flag= adt->flag;
|
||||
|
||||
// XXX... drivers don't show summary for now
|
||||
ale->key_data= NULL;
|
||||
ale->datatype= ALE_NONE;
|
||||
}
|
||||
break;
|
||||
case ANIMTYPE_FILLMATD:
|
||||
{
|
||||
Object *ob= (Object *)data;
|
||||
@@ -466,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)) {
|
||||
//if (!(filter_mode & ANIMFILTER_CURVEVISIBLE) || (fcu->flag & FCURVE_VISIBLE)) { // XXX don't do this till we have tools to set this
|
||||
/* 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 */
|
||||
@@ -480,7 +498,7 @@ static int animdata_filter_fcurves (ListBase *anim_data, FCurve *first, bActionG
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//}
|
||||
}
|
||||
|
||||
/* return the number of items added to the list */
|
||||
@@ -690,9 +708,29 @@ static int animdata_filter_gpencil (ListBase *anim_data, bScreen *sc, int filter
|
||||
|
||||
static int animdata_filter_dopesheet_mats (ListBase *anim_data, bDopeSheet *ads, Base *base, int filter_mode)
|
||||
{
|
||||
ListBase mats = {NULL, NULL};
|
||||
LinkData *ld;
|
||||
|
||||
bAnimListElem *ale=NULL;
|
||||
Object *ob= base->object;
|
||||
int items = 0;
|
||||
int items=0, a=0;
|
||||
|
||||
/* firstly check that we actuallly have some materials, by gathering all materials in a temp list */
|
||||
for (a=0; a < ob->totcol; a++) {
|
||||
Material *ma= give_current_material(ob, a);
|
||||
|
||||
/* for now, if no material returned, skip (this shouldn't confuse the user I hope) */
|
||||
if (ELEM3(NULL, ma, ma->adt, ma->adt->action)) continue;
|
||||
|
||||
/* make a temp list elem for this */
|
||||
ld= MEM_callocN(sizeof(LinkData), "DopeSheet-MaterialCache");
|
||||
ld->data= ma;
|
||||
BLI_addtail(&mats, ld);
|
||||
}
|
||||
|
||||
/* if there were no channels found, no need to carry on */
|
||||
if (mats.first == NULL)
|
||||
return 0;
|
||||
|
||||
/* include materials-expand widget? */
|
||||
if ((filter_mode & ANIMFILTER_CHANNELS) && !(filter_mode & ANIMFILTER_CURVESONLY)) {
|
||||
@@ -705,14 +743,9 @@ static int animdata_filter_dopesheet_mats (ListBase *anim_data, bDopeSheet *ads,
|
||||
|
||||
/* add materials? */
|
||||
if (FILTER_MAT_OBJC(ob) || (filter_mode & ANIMFILTER_CURVESONLY)) {
|
||||
short a;
|
||||
|
||||
/* for each material, either add channels separately, or as ipo-block */
|
||||
for (a=0; a<ob->totcol; a++) {
|
||||
Material *ma= give_current_material(ob, a);
|
||||
|
||||
/* for now, if no material returned, skip (this shouldn't confuse the user I hope) */
|
||||
if (ELEM(NULL, ma, ma->adt)) continue;
|
||||
/* for each material in cache, add channels */
|
||||
for (ld= mats.first; ld; ld= ld->next) {
|
||||
Material *ma= (Material *)ld->data;
|
||||
|
||||
/* include material-expand widget? */
|
||||
// hmm... do we need to store the index of this material in the array anywhere?
|
||||
@@ -724,7 +757,7 @@ static int animdata_filter_dopesheet_mats (ListBase *anim_data, bDopeSheet *ads,
|
||||
}
|
||||
}
|
||||
|
||||
/* add material's ipo-curve channels? */
|
||||
/* add material's F-Curve channels? */
|
||||
if (FILTER_MAT_OBJD(ma) || (filter_mode & ANIMFILTER_CURVESONLY)) {
|
||||
//items += animdata_filter_ipocurves(anim_data, ma->ipo, filter_mode, base, ANIMTYPE_OBJECT, (ID *)ma);
|
||||
// XXX the 'owner' info here is still subject to improvement
|
||||
@@ -733,6 +766,9 @@ static int animdata_filter_dopesheet_mats (ListBase *anim_data, bDopeSheet *ads,
|
||||
}
|
||||
}
|
||||
|
||||
/* free cache */
|
||||
BLI_freelistN(&mats);
|
||||
|
||||
/* return the number of items added to the list */
|
||||
return items;
|
||||
}
|
||||
@@ -742,6 +778,7 @@ static int animdata_filter_dopesheet_obdata (ListBase *anim_data, bDopeSheet *ad
|
||||
bAnimListElem *ale=NULL;
|
||||
Object *ob= base->object;
|
||||
IdAdtTemplate *iat= ob->data;
|
||||
AnimData *adt= iat->adt;
|
||||
short type=0, expanded=0;
|
||||
int items= 0;
|
||||
|
||||
@@ -773,6 +810,10 @@ static int animdata_filter_dopesheet_obdata (ListBase *anim_data, bDopeSheet *ad
|
||||
break;
|
||||
}
|
||||
|
||||
/* special exception for drivers instead of action */
|
||||
if (ads->filterflag & ADS_FILTER_ONLYDRIVERS)
|
||||
expanded= EXPANDED_DRVD(adt);
|
||||
|
||||
/* include data-expand widget? */
|
||||
if ((filter_mode & ANIMFILTER_CURVESONLY) == 0) {
|
||||
ale= make_new_animlistelem(iat, type, base, ANIMTYPE_OBJECT, (ID *)iat);
|
||||
@@ -781,8 +822,15 @@ static int animdata_filter_dopesheet_obdata (ListBase *anim_data, bDopeSheet *ad
|
||||
|
||||
/* add object-data animation channels? */
|
||||
if ((expanded) || (filter_mode & ANIMFILTER_CURVESONLY)) {
|
||||
// XXX the 'owner' info here is still subject to improvement
|
||||
items += animdata_filter_action(anim_data, iat->adt->action, filter_mode, iat, type, (ID *)iat);
|
||||
/* Action or Drivers? */
|
||||
if ((ads->filterflag & ADS_FILTER_ONLYDRIVERS) == 0) {
|
||||
// XXX the 'owner' info here is still subject to improvement
|
||||
items += animdata_filter_action(anim_data, iat->adt->action, filter_mode, iat, type, (ID *)iat);
|
||||
}
|
||||
else {
|
||||
// need to make the ownertype normal object here... (maybe type should be a separate one for clarity?)
|
||||
items += animdata_filter_fcurves(anim_data, adt->drivers.first, NULL, iat, type, filter_mode, (ID *)iat);
|
||||
}
|
||||
}
|
||||
|
||||
/* return the number of items added to the list */
|
||||
@@ -813,40 +861,88 @@ static int animdata_filter_dopesheet_ob (ListBase *anim_data, bDopeSheet *ads, B
|
||||
if ( (EXPANDED_OBJC(ob) == 0) && !(filter_mode & ANIMFILTER_CURVESONLY) )
|
||||
return items;
|
||||
|
||||
/* Action? */
|
||||
if (ANIMDATA_HAS_KEYS(ob) /*&& !(ads->filterflag & ADS_FILTER_NOACTS)*/) {
|
||||
AnimData *adt= ob->adt;
|
||||
|
||||
/* include action-expand widget? */
|
||||
if ((filter_mode & ANIMFILTER_CHANNELS) && !(filter_mode & ANIMFILTER_CURVESONLY)) {
|
||||
ale= make_new_animlistelem(adt->action, ANIMTYPE_FILLACTD, base, ANIMTYPE_OBJECT, (ID *)ob);
|
||||
if (ale) {
|
||||
BLI_addtail(anim_data, ale);
|
||||
items++;
|
||||
/* Action or Drivers */
|
||||
if ((ads->filterflag & ADS_FILTER_ONLYDRIVERS) == 0) {
|
||||
/* Action? */
|
||||
if (ANIMDATA_HAS_KEYS(ob) /*&& !(ads->filterflag & ADS_FILTER_NOACTS)*/) {
|
||||
AnimData *adt= ob->adt;
|
||||
|
||||
/* include action-expand widget? */
|
||||
if ((filter_mode & ANIMFILTER_CHANNELS) && !(filter_mode & ANIMFILTER_CURVESONLY)) {
|
||||
ale= make_new_animlistelem(adt->action, ANIMTYPE_FILLACTD, base, ANIMTYPE_OBJECT, (ID *)ob);
|
||||
if (ale) {
|
||||
BLI_addtail(anim_data, ale);
|
||||
items++;
|
||||
}
|
||||
}
|
||||
|
||||
/* add F-Curve channels? */
|
||||
if (EXPANDED_ACTC(adt->action) || !(filter_mode & ANIMFILTER_CHANNELS)) {
|
||||
// need to make the ownertype normal object here... (maybe type should be a separate one for clarity?)
|
||||
items += animdata_filter_action(anim_data, adt->action, filter_mode, ob, ANIMTYPE_OBJECT, (ID *)ob);
|
||||
}
|
||||
}
|
||||
|
||||
/* add F-Curve channels? */
|
||||
if (EXPANDED_ACTC(adt->action) || !(filter_mode & ANIMFILTER_CHANNELS)) {
|
||||
// need to make the ownertype normal object here... (maybe type should be a separate one for clarity?)
|
||||
items += animdata_filter_action(anim_data, adt->action, filter_mode, ob, ANIMTYPE_OBJECT, (ID *)ob);
|
||||
}
|
||||
else {
|
||||
/* Drivers */
|
||||
if (ANIMDATA_HAS_DRIVERS(ob)) {
|
||||
AnimData *adt= ob->adt;
|
||||
|
||||
/* include drivers-expand widget? */
|
||||
if ((filter_mode & ANIMFILTER_CHANNELS) && !(filter_mode & ANIMFILTER_CURVESONLY)) {
|
||||
ale= make_new_animlistelem(adt->action, ANIMTYPE_FILLDRIVERS, base, ANIMTYPE_OBJECT, (ID *)ob);
|
||||
if (ale) {
|
||||
BLI_addtail(anim_data, ale);
|
||||
items++;
|
||||
}
|
||||
}
|
||||
|
||||
/* add F-Curve channels (drivers are F-Curves) */
|
||||
if (EXPANDED_DRVD(adt) || !(filter_mode & ANIMFILTER_CHANNELS)) {
|
||||
// need to make the ownertype normal object here... (maybe type should be a separate one for clarity?)
|
||||
items += animdata_filter_fcurves(anim_data, adt->drivers.first, NULL, ob, ANIMTYPE_OBJECT, filter_mode, (ID *)ob);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ShapeKeys? */
|
||||
if ((key) && !(ads->filterflag & ADS_FILTER_NOSHAPEKEYS)) {
|
||||
/* include shapekey-expand widget? */
|
||||
if ((filter_mode & ANIMFILTER_CHANNELS) && !(filter_mode & ANIMFILTER_CURVESONLY)) {
|
||||
ale= make_new_animlistelem(key, ANIMTYPE_DSSKEY, base, ANIMTYPE_OBJECT, (ID *)ob);
|
||||
if (ale) {
|
||||
BLI_addtail(anim_data, ale);
|
||||
items++;
|
||||
/* Animation or Drivers */
|
||||
if ((ads->filterflag & ADS_FILTER_ONLYDRIVERS) == 0) {
|
||||
/* include shapekey-expand widget? */
|
||||
if ((filter_mode & ANIMFILTER_CHANNELS) && !(filter_mode & ANIMFILTER_CURVESONLY)) {
|
||||
ale= make_new_animlistelem(key, ANIMTYPE_DSSKEY, base, ANIMTYPE_OBJECT, (ID *)ob);
|
||||
if (ale) {
|
||||
BLI_addtail(anim_data, ale);
|
||||
items++;
|
||||
}
|
||||
}
|
||||
|
||||
/* add channels */
|
||||
if (FILTER_SKE_OBJD(key) || (filter_mode & ANIMFILTER_CURVESONLY)) {
|
||||
items += animdata_filter_shapekey(anim_data, key, filter_mode, ob, ANIMTYPE_OBJECT, (ID *)ob);
|
||||
}
|
||||
}
|
||||
|
||||
/* add channels */
|
||||
if (FILTER_SKE_OBJD(key) || (filter_mode & ANIMFILTER_CURVESONLY)) {
|
||||
items += animdata_filter_shapekey(anim_data, key, filter_mode, ob, ANIMTYPE_OBJECT, (ID *)ob);
|
||||
else {
|
||||
/* Drivers */
|
||||
if (ANIMDATA_HAS_DRIVERS(key)) {
|
||||
AnimData *adt= key->adt;
|
||||
|
||||
/* include shapekey-expand widget? */
|
||||
if ((filter_mode & ANIMFILTER_CHANNELS) && !(filter_mode & ANIMFILTER_CURVESONLY)) {
|
||||
ale= make_new_animlistelem(key, ANIMTYPE_DSSKEY, base, ANIMTYPE_OBJECT, (ID *)ob);
|
||||
if (ale) {
|
||||
BLI_addtail(anim_data, ale);
|
||||
items++;
|
||||
}
|
||||
}
|
||||
|
||||
/* add F-Curve channels (drivers are F-Curves) */
|
||||
if (FILTER_SKE_OBJD(key)/*EXPANDED_DRVD(adt)*/ || !(filter_mode & ANIMFILTER_CHANNELS)) {
|
||||
// XXX owner info is messed up now...
|
||||
items += animdata_filter_fcurves(anim_data, adt->drivers.first, NULL, ob, ANIMTYPE_OBJECT, filter_mode, (ID *)key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -860,22 +956,49 @@ static int animdata_filter_dopesheet_ob (ListBase *anim_data, bDopeSheet *ads, B
|
||||
case OB_CAMERA: /* ------- Camera ------------ */
|
||||
{
|
||||
Camera *ca= (Camera *)ob->data;
|
||||
if (ANIMDATA_HAS_KEYS(ca) && !(ads->filterflag & ADS_FILTER_NOCAM))
|
||||
items += animdata_filter_dopesheet_obdata(anim_data, ads, base, filter_mode);
|
||||
|
||||
if ((ads->filterflag & ADS_FILTER_NOCAM) == 0) {
|
||||
if ((ads->filterflag & ADS_FILTER_ONLYDRIVERS)==0) {
|
||||
if (ANIMDATA_HAS_KEYS(ca))
|
||||
items += animdata_filter_dopesheet_obdata(anim_data, ads, base, filter_mode);
|
||||
}
|
||||
else {
|
||||
if (ANIMDATA_HAS_DRIVERS(ca))
|
||||
items += animdata_filter_dopesheet_obdata(anim_data, ads, base, filter_mode);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case OB_LAMP: /* ---------- Lamp ----------- */
|
||||
{
|
||||
Lamp *la= (Lamp *)ob->data;
|
||||
if (ANIMDATA_HAS_KEYS(la) && !(ads->filterflag & ADS_FILTER_NOLAM))
|
||||
items += animdata_filter_dopesheet_obdata(anim_data, ads, base, filter_mode);
|
||||
|
||||
if ((ads->filterflag & ADS_FILTER_NOLAM) == 0) {
|
||||
if ((ads->filterflag & ADS_FILTER_ONLYDRIVERS)==0) {
|
||||
if (ANIMDATA_HAS_KEYS(la))
|
||||
items += animdata_filter_dopesheet_obdata(anim_data, ads, base, filter_mode);
|
||||
}
|
||||
else {
|
||||
if (ANIMDATA_HAS_DRIVERS(la))
|
||||
items += animdata_filter_dopesheet_obdata(anim_data, ads, base, filter_mode);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case OB_CURVE: /* ------- Curve ---------- */
|
||||
{
|
||||
Curve *cu= (Curve *)ob->data;
|
||||
if (ANIMDATA_HAS_KEYS(cu) && !(ads->filterflag & ADS_FILTER_NOCUR))
|
||||
items += animdata_filter_dopesheet_obdata(anim_data, ads, base, filter_mode);
|
||||
|
||||
if ((ads->filterflag & ADS_FILTER_NOCUR) == 0) {
|
||||
if ((ads->filterflag & ADS_FILTER_ONLYDRIVERS)==0) {
|
||||
if (ANIMDATA_HAS_KEYS(cu))
|
||||
items += animdata_filter_dopesheet_obdata(anim_data, ads, base, filter_mode);
|
||||
}
|
||||
else {
|
||||
if (ANIMDATA_HAS_DRIVERS(cu))
|
||||
items += animdata_filter_dopesheet_obdata(anim_data, ads, base, filter_mode);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -938,26 +1061,41 @@ static int animdata_filter_dopesheet (ListBase *anim_data, bDopeSheet *ads, int
|
||||
#endif
|
||||
|
||||
/* check filters for datatypes */
|
||||
actOk= (ANIMDATA_HAS_KEYS(ob) /*&& !(ads->filterflag & ADS_FILTER_NOACTS)*/);
|
||||
keyOk= ((key) && !(ads->filterflag & ADS_FILTER_NOSHAPEKEYS));
|
||||
if (ads->filterflag & ADS_FILTER_ONLYDRIVERS) {
|
||||
actOk= (ANIMDATA_HAS_DRIVERS(ob));
|
||||
keyOk= ((key) && ANIMDATA_HAS_DRIVERS(key) && !(ads->filterflag & ADS_FILTER_NOSHAPEKEYS));
|
||||
}
|
||||
else {
|
||||
actOk= (ANIMDATA_HAS_KEYS(ob) /*&& !(ads->filterflag & ADS_FILTER_NOACTS)*/);
|
||||
keyOk= ((key) && ANIMDATA_HAS_KEYS(key) && !(ads->filterflag & ADS_FILTER_NOSHAPEKEYS));
|
||||
}
|
||||
|
||||
switch (ob->type) {
|
||||
case OB_CAMERA: /* ------- Camera ------------ */
|
||||
{
|
||||
Camera *ca= (Camera *)ob->data;
|
||||
dataOk= (ANIMDATA_HAS_KEYS(ca) && !(ads->filterflag & ADS_FILTER_NOCAM));
|
||||
if (ads->filterflag & ADS_FILTER_ONLYDRIVERS)
|
||||
dataOk= (ANIMDATA_HAS_DRIVERS(ca) && !(ads->filterflag & ADS_FILTER_NOCAM));
|
||||
else
|
||||
dataOk= (ANIMDATA_HAS_KEYS(ca) && !(ads->filterflag & ADS_FILTER_NOCAM));
|
||||
}
|
||||
break;
|
||||
case OB_LAMP: /* ---------- Lamp ----------- */
|
||||
{
|
||||
Lamp *la= (Lamp *)ob->data;
|
||||
dataOk= (ANIMDATA_HAS_KEYS(la) && !(ads->filterflag & ADS_FILTER_NOLAM));
|
||||
if (ads->filterflag & ADS_FILTER_ONLYDRIVERS)
|
||||
dataOk= (ANIMDATA_HAS_DRIVERS(la) && !(ads->filterflag & ADS_FILTER_NOLAM));
|
||||
else
|
||||
dataOk= (ANIMDATA_HAS_KEYS(la) && !(ads->filterflag & ADS_FILTER_NOLAM));
|
||||
}
|
||||
break;
|
||||
case OB_CURVE: /* -------- Curve ---------- */
|
||||
{
|
||||
Curve *cu= (Curve *)ob->data;
|
||||
dataOk= (ANIMDATA_HAS_KEYS(cu) && !(ads->filterflag & ADS_FILTER_NOCUR));
|
||||
if (ads->filterflag & ADS_FILTER_ONLYDRIVERS)
|
||||
dataOk= (ANIMDATA_HAS_DRIVERS(cu) && !(ads->filterflag & ADS_FILTER_NOCUR));
|
||||
else
|
||||
dataOk= (ANIMDATA_HAS_KEYS(cu) && !(ads->filterflag & ADS_FILTER_NOCUR));
|
||||
}
|
||||
break;
|
||||
default: /* --- other --- */
|
||||
@@ -984,13 +1122,13 @@ static int animdata_filter_dopesheet (ListBase *anim_data, bDopeSheet *ads, int
|
||||
case OB_LAMP: /* ---------- Lamp ----------- */
|
||||
{
|
||||
Lamp *la= (Lamp *)ob->data;
|
||||
dataOk= ANIMDATA_HAS_KEYS(la);
|
||||
dataOk= ANIMDATA_HAS_KEYS(la);
|
||||
}
|
||||
break;
|
||||
case OB_CURVE: /* -------- Curve ---------- */
|
||||
{
|
||||
Curve *cu= (Curve *)ob->data;
|
||||
dataOk= ANIMDATA_HAS_KEYS(cu);
|
||||
dataOk= ANIMDATA_HAS_KEYS(cu);
|
||||
}
|
||||
break;
|
||||
default: /* --- other --- */
|
||||
|
||||
@@ -138,6 +138,7 @@ void getname_anim_fcurve(char *name, ID *id, FCurve *fcu)
|
||||
/* Property Name is straightforward */
|
||||
propname= (char *)RNA_property_ui_name(&ptr, prop);
|
||||
|
||||
/* Array Index - only if applicable */
|
||||
if (RNA_property_array_length(&ptr, prop)) {
|
||||
// XXX the format of these is not final... we don't know how this will go yet
|
||||
static char *vectoritem[4]= {".X", ".Y", ".Z", ".W"};
|
||||
@@ -160,6 +161,10 @@ void getname_anim_fcurve(char *name, ID *id, FCurve *fcu)
|
||||
arrayname= &arrayindbuf[0];
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* no array index */
|
||||
arrayname= "";
|
||||
}
|
||||
|
||||
/* putting this all together into the buffer */
|
||||
// XXX we need to check for invalid names...
|
||||
@@ -190,8 +195,8 @@ unsigned int ipo_rainbow(int cur, int tot)
|
||||
if(tot > 32) fac= fac*1.95f;
|
||||
if(fac>1.0f) fac-= 1.0f;
|
||||
|
||||
if(fac>0.5f && fac<0.8f) sat= 0.4f;
|
||||
else sat= 0.5f;
|
||||
if(fac>0.5f && fac<0.8f) sat= 0.5f;
|
||||
else sat= 0.6f;
|
||||
|
||||
return hsv_to_cpack(fac, sat, 1.0f);
|
||||
}
|
||||
|
||||
@@ -867,7 +867,7 @@ void ED_marker_keymap(wmWindowManager *wm)
|
||||
|
||||
WM_keymap_add_item(keymap, "MARKER_OT_move", GKEY, KM_PRESS, 0, 0);
|
||||
|
||||
/* generates event, in end to make select work */
|
||||
/* generates event, needs to be after select to work */
|
||||
WM_keymap_verify_item(keymap, "WM_OT_tweak_gesture", RIGHTMOUSE, KM_PRESS, 0, 0);
|
||||
|
||||
}
|
||||
|
||||
@@ -38,7 +38,6 @@
|
||||
#include "DNA_action_types.h"
|
||||
#include "DNA_constraint_types.h"
|
||||
#include "DNA_curve_types.h"
|
||||
#include "DNA_ipo_types.h" // XXX to be phased out
|
||||
#include "DNA_key_types.h"
|
||||
#include "DNA_object_types.h"
|
||||
#include "DNA_space_types.h"
|
||||
@@ -56,7 +55,7 @@
|
||||
/* This file defines an API and set of callback-operators for non-destructive editing of keyframe data.
|
||||
*
|
||||
* Two API functions are defined for actually performing the operations on the data:
|
||||
* ipo_keys_bezier_loop() and icu_keys_bezier_loop()
|
||||
* ANIM_fcurve_keys_bezier_loop()
|
||||
* which take the data they operate on, a few callbacks defining what operations to perform.
|
||||
*
|
||||
* As operators which work on keyframes usually apply the same operation on all BezTriples in
|
||||
@@ -84,6 +83,10 @@ short ANIM_fcurve_keys_bezier_loop(BeztEditData *bed, FCurve *fcu, BeztEditFunc
|
||||
BezTriple *bezt;
|
||||
int b;
|
||||
|
||||
/* sanity check */
|
||||
if (fcu == NULL)
|
||||
return 0;
|
||||
|
||||
/* if function to apply to bezier curves is set, then loop through executing it on beztriples */
|
||||
if (bezt_cb) {
|
||||
/* if there's a validation func, include that check in the loop
|
||||
@@ -194,7 +197,7 @@ void ANIM_editkeyframes_refresh(bAnimContext *ac)
|
||||
for (ale= anim_data.first; ale; ale= ale->next) {
|
||||
FCurve *fcu= ale->key_data;
|
||||
|
||||
/* make sure keyframes in IPO-curve are all in order, and handles are in valid positions */
|
||||
/* make sure keyframes in F-curve are all in order, and handles are in valid positions */
|
||||
sort_time_fcurve(fcu);
|
||||
testhandles_fcurve(fcu);
|
||||
}
|
||||
@@ -233,6 +236,21 @@ static short ok_bezier_value(BeztEditData *bed, BezTriple *bezt)
|
||||
return IS_EQ(bezt->vec[1][1], bed->f1);
|
||||
}
|
||||
|
||||
static short ok_bezier_valuerange(BeztEditData *bed, BezTriple *bezt)
|
||||
{
|
||||
/* value range is stored in float properties */
|
||||
return ((bezt->vec[1][1] > bed->f1) && (bezt->vec[1][1] < bed->f2));
|
||||
}
|
||||
|
||||
static short ok_bezier_region(BeztEditData *bed, BezTriple *bezt)
|
||||
{
|
||||
/* rect is stored in data property (it's of type rectf, but may not be set) */
|
||||
if (bed->data)
|
||||
return BLI_in_rctf(bed->data, bezt->vec[1][0], bezt->vec[1][1]);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
BeztEditFunc ANIM_editkeyframes_ok(short mode)
|
||||
{
|
||||
@@ -242,10 +260,14 @@ BeztEditFunc ANIM_editkeyframes_ok(short mode)
|
||||
return ok_bezier_frame;
|
||||
case BEZT_OK_FRAMERANGE: /* only if bezt falls within the specified frame range (floats) */
|
||||
return ok_bezier_framerange;
|
||||
case BEZT_OK_SELECTED: /* only if bezt is selected */
|
||||
case BEZT_OK_SELECTED: /* only if bezt is selected (self) */
|
||||
return ok_bezier_selected;
|
||||
case BEZT_OK_VALUE: /* only if bezt value matches (float) */
|
||||
return ok_bezier_value;
|
||||
case BEZT_OK_VALUERANGE: /* only if bezier falls within the specified value range (floats) */
|
||||
return ok_bezier_valuerange;
|
||||
case BEZT_OK_REGION: /* only if bezier falls within the specified rect (data -> rectf) */
|
||||
return ok_bezier_region;
|
||||
default: /* nothing was ok */
|
||||
return NULL;
|
||||
}
|
||||
@@ -286,6 +308,16 @@ static short snap_bezier_nearmarker(BeztEditData *bed, BezTriple *bezt)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static short snap_bezier_horizontal(BeztEditData *bed, BezTriple *bezt)
|
||||
{
|
||||
if (bezt->f2 & SELECT) {
|
||||
bezt->vec[0][1]= bezt->vec[2][1]= bezt->vec[1][1];
|
||||
if ((bezt->h1==HD_AUTO) || (bezt->h1==HD_VECT)) bezt->h1= HD_ALIGN;
|
||||
if ((bezt->h2==HD_AUTO) || (bezt->h2==HD_VECT)) bezt->h2= HD_ALIGN;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// calchandles_ipocurve
|
||||
BeztEditFunc ANIM_editkeyframes_snap(short type)
|
||||
{
|
||||
@@ -299,6 +331,8 @@ BeztEditFunc ANIM_editkeyframes_snap(short type)
|
||||
return snap_bezier_nearmarker;
|
||||
case SNAP_KEYS_NEARSEC: /* snap to nearest second */
|
||||
return snap_bezier_nearestsec;
|
||||
case SNAP_KEYS_HORIZONTAL: /* snap handles to same value */
|
||||
return snap_bezier_horizontal;
|
||||
default: /* just in case */
|
||||
return snap_bezier_nearest;
|
||||
}
|
||||
@@ -355,7 +389,7 @@ static short mirror_bezier_marker(BeztEditData *bed, BezTriple *bezt)
|
||||
}
|
||||
|
||||
/* Note: for markers case, need to set global vars (eww...) */
|
||||
// calchandles_ipocurve
|
||||
// calchandles_fcurve
|
||||
BeztEditFunc ANIM_editkeyframes_mirror(short type)
|
||||
{
|
||||
switch (type) {
|
||||
@@ -437,7 +471,7 @@ static short set_bezier_free(BeztEditData *bed, BezTriple *bezt)
|
||||
}
|
||||
|
||||
/* Set all Bezier Handles to a single type */
|
||||
// calchandles_ipocurve
|
||||
// calchandles_fcurve
|
||||
BeztEditFunc ANIM_editkeyframes_handles(short code)
|
||||
{
|
||||
switch (code) {
|
||||
@@ -460,21 +494,21 @@ BeztEditFunc ANIM_editkeyframes_handles(short code)
|
||||
static short set_bezt_constant(BeztEditData *bed, BezTriple *bezt)
|
||||
{
|
||||
if (bezt->f2 & SELECT)
|
||||
bezt->ipo= IPO_CONST;
|
||||
bezt->ipo= BEZT_IPO_CONST;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static short set_bezt_linear(BeztEditData *bed, BezTriple *bezt)
|
||||
{
|
||||
if (bezt->f2 & SELECT)
|
||||
bezt->ipo= IPO_LIN;
|
||||
bezt->ipo= BEZT_IPO_LIN;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static short set_bezt_bezier(BeztEditData *bed, BezTriple *bezt)
|
||||
{
|
||||
if (bezt->f2 & SELECT)
|
||||
bezt->ipo= IPO_BEZ;
|
||||
bezt->ipo= BEZT_IPO_BEZ;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -483,9 +517,9 @@ static short set_bezt_bezier(BeztEditData *bed, BezTriple *bezt)
|
||||
BeztEditFunc ANIM_editkeyframes_ipo(short code)
|
||||
{
|
||||
switch (code) {
|
||||
case IPO_CONST: /* constant */
|
||||
case BEZT_IPO_CONST: /* constant */
|
||||
return set_bezt_constant;
|
||||
case IPO_LIN: /* linear */
|
||||
case BEZT_IPO_LIN: /* linear */
|
||||
return set_bezt_linear;
|
||||
default: /* bezier */
|
||||
return set_bezt_bezier;
|
||||
|
||||
@@ -152,11 +152,6 @@ void duplicate_fcurve_keys(FCurve *fcu)
|
||||
/* **************************************************** */
|
||||
/* Various Tools */
|
||||
|
||||
// XXX - stub... until keyframing code is fixed...
|
||||
static void insert_vert_fcu(FCurve *fcu, float x, float y, short flag)
|
||||
{
|
||||
}
|
||||
|
||||
/* Basic IPO-Curve 'cleanup' function that removes 'double points' and unnecessary keyframes on linear-segments only */
|
||||
void clean_fcurve(FCurve *fcu, float thresh)
|
||||
{
|
||||
@@ -176,7 +171,7 @@ void clean_fcurve(FCurve *fcu, float thresh)
|
||||
|
||||
/* now insert first keyframe, as it should be ok */
|
||||
bezt = old_bezts;
|
||||
insert_vert_fcu(fcu, bezt->vec[1][0], bezt->vec[1][1], 0);
|
||||
insert_vert_fcurve(fcu, bezt->vec[1][0], bezt->vec[1][1], 0);
|
||||
|
||||
/* Loop through BezTriples, comparing them. Skip any that do
|
||||
* not fit the criteria for "ok" points.
|
||||
@@ -213,7 +208,7 @@ void clean_fcurve(FCurve *fcu, float thresh)
|
||||
if (cur[1] > next[1]) {
|
||||
if (IS_EQT(cur[1], prev[1], thresh) == 0) {
|
||||
/* add new keyframe */
|
||||
insert_vert_fcu(fcu, cur[0], cur[1], 0);
|
||||
insert_vert_fcurve(fcu, cur[0], cur[1], 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -221,7 +216,7 @@ void clean_fcurve(FCurve *fcu, float thresh)
|
||||
/* only add if values are a considerable distance apart */
|
||||
if (IS_EQT(cur[1], prev[1], thresh) == 0) {
|
||||
/* add new keyframe */
|
||||
insert_vert_fcu(fcu, cur[0], cur[1], 0);
|
||||
insert_vert_fcurve(fcu, cur[0], cur[1], 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -231,18 +226,18 @@ void clean_fcurve(FCurve *fcu, float thresh)
|
||||
/* does current have same value as previous and next? */
|
||||
if (IS_EQT(cur[1], prev[1], thresh) == 0) {
|
||||
/* add new keyframe*/
|
||||
insert_vert_fcu(fcu, cur[0], cur[1], 0);
|
||||
insert_vert_fcurve(fcu, cur[0], cur[1], 0);
|
||||
}
|
||||
else if (IS_EQT(cur[1], next[1], thresh) == 0) {
|
||||
/* add new keyframe */
|
||||
insert_vert_fcu(fcu, cur[0], cur[1], 0);
|
||||
insert_vert_fcurve(fcu, cur[0], cur[1], 0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* add if value doesn't equal that of previous */
|
||||
if (IS_EQT(cur[1], prev[1], thresh) == 0) {
|
||||
/* add new keyframe */
|
||||
insert_vert_fcu(fcu, cur[0], cur[1], 0);
|
||||
insert_vert_fcurve(fcu, cur[0], cur[1], 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -261,8 +256,7 @@ typedef struct tSmooth_Bezt {
|
||||
} tSmooth_Bezt;
|
||||
|
||||
/* Use a weighted moving-means method to reduce intensity of fluctuations */
|
||||
//mode= pupmenu("Smooth F-Curve%t|Tweak Points%x1|Flatten Handles%x2");
|
||||
void smooth_fcurve(FCurve *fcu, short mode)
|
||||
void smooth_fcurve (FCurve *fcu)
|
||||
{
|
||||
BezTriple *bezt;
|
||||
int i, x, totSel = 0;
|
||||
@@ -283,8 +277,6 @@ void smooth_fcurve(FCurve *fcu, short mode)
|
||||
}
|
||||
}
|
||||
|
||||
/* check if adjust values too... */
|
||||
if (mode == 2) {
|
||||
/* if any points were selected, allocate tSmooth_Bezt points to work on */
|
||||
if (totSel >= 3) {
|
||||
tSmooth_Bezt *tarray, *tsb;
|
||||
@@ -309,51 +301,50 @@ void smooth_fcurve(FCurve *fcu, short mode)
|
||||
}
|
||||
}
|
||||
|
||||
/* calculate the new smoothed ipo's with weighted averages:
|
||||
* - this is done with two passes
|
||||
* - uses 5 points for each operation (which stores in the relevant handles)
|
||||
* - previous: w/a ratio = 3:5:2:1:1
|
||||
* - next: w/a ratio = 1:1:2:5:3
|
||||
*/
|
||||
/* calculate the new smoothed F-Curve's with weighted averages:
|
||||
* - this is done with two passes
|
||||
* - uses 5 points for each operation (which stores in the relevant handles)
|
||||
* - previous: w/a ratio = 3:5:2:1:1
|
||||
* - next: w/a ratio = 1:1:2:5:3
|
||||
*/
|
||||
|
||||
/* round 1: calculate previous and next */
|
||||
tsb= tarray;
|
||||
for (i=0; i < totSel; i++, tsb++) {
|
||||
/* don't touch end points (otherwise, curves slowly explode) */
|
||||
if (ELEM(i, 0, (totSel-1)) == 0) {
|
||||
const tSmooth_Bezt *tP1 = tsb - 1;
|
||||
const tSmooth_Bezt *tP2 = (i-2 > 0) ? (tsb - 2) : (NULL);
|
||||
const tSmooth_Bezt *tN1 = tsb + 1;
|
||||
const tSmooth_Bezt *tN2 = (i+2 < totSel) ? (tsb + 2) : (NULL);
|
||||
|
||||
/* round 1: calculate previous and next */
|
||||
tsb= tarray;
|
||||
for (i=0; i < totSel; i++, tsb++) {
|
||||
/* don't touch end points (otherwise, curves slowly explode) */
|
||||
if (ELEM(i, 0, (totSel-1)) == 0) {
|
||||
const tSmooth_Bezt *tP1 = tsb - 1;
|
||||
const tSmooth_Bezt *tP2 = (i-2 > 0) ? (tsb - 2) : (NULL);
|
||||
const tSmooth_Bezt *tN1 = tsb + 1;
|
||||
const tSmooth_Bezt *tN2 = (i+2 < totSel) ? (tsb + 2) : (NULL);
|
||||
|
||||
const float p1 = *tP1->h2;
|
||||
const float p2 = (tP2) ? (*tP2->h2) : (*tP1->h2);
|
||||
const float c1 = *tsb->h2;
|
||||
const float n1 = *tN1->h2;
|
||||
const float n2 = (tN2) ? (*tN2->h2) : (*tN1->h2);
|
||||
|
||||
/* calculate previous and next */
|
||||
*tsb->h1= (3*p2 + 5*p1 + 2*c1 + n1 + n2) / 12;
|
||||
*tsb->h3= (p2 + p1 + 2*c1 + 5*n1 + 3*n2) / 12;
|
||||
}
|
||||
}
|
||||
const float p1 = *tP1->h2;
|
||||
const float p2 = (tP2) ? (*tP2->h2) : (*tP1->h2);
|
||||
const float c1 = *tsb->h2;
|
||||
const float n1 = *tN1->h2;
|
||||
const float n2 = (tN2) ? (*tN2->h2) : (*tN1->h2);
|
||||
|
||||
/* round 2: calculate new values and reset handles */
|
||||
tsb= tarray;
|
||||
for (i=0; i < totSel; i++, tsb++) {
|
||||
/* calculate new position by averaging handles */
|
||||
*tsb->h2 = (*tsb->h1 + *tsb->h3) / 2;
|
||||
|
||||
/* reset handles now */
|
||||
*tsb->h1 = *tsb->h2;
|
||||
*tsb->h3 = *tsb->h2;
|
||||
}
|
||||
|
||||
/* free memory required for tarray */
|
||||
MEM_freeN(tarray);
|
||||
/* calculate previous and next */
|
||||
*tsb->h1= (3*p2 + 5*p1 + 2*c1 + n1 + n2) / 12;
|
||||
*tsb->h3= (p2 + p1 + 2*c1 + 5*n1 + 3*n2) / 12;
|
||||
}
|
||||
}
|
||||
|
||||
/* round 2: calculate new values and reset handles */
|
||||
tsb= tarray;
|
||||
for (i=0; i < totSel; i++, tsb++) {
|
||||
/* calculate new position by averaging handles */
|
||||
*tsb->h2 = (*tsb->h1 + *tsb->h3) / 2;
|
||||
|
||||
/* reset handles now */
|
||||
*tsb->h1 = *tsb->h2;
|
||||
*tsb->h3 = *tsb->h2;
|
||||
}
|
||||
|
||||
/* free memory required for tarray */
|
||||
MEM_freeN(tarray);
|
||||
}
|
||||
|
||||
/* recalculate handles */
|
||||
calchandles_fcurve(fcu);
|
||||
}
|
||||
|
||||
@@ -334,7 +334,7 @@ void insert_vert_fcurve (FCurve *fcu, float x, float y, short fast)
|
||||
/* set handletype and interpolation */
|
||||
if (fcu->totvert > 2) {
|
||||
BezTriple *bezt= (fcu->bezt + a);
|
||||
short h1, h2;
|
||||
char h1, h2;
|
||||
|
||||
/* set handles (autohandles by default) */
|
||||
h1= h2= HD_AUTO;
|
||||
@@ -2117,9 +2117,9 @@ static int insert_key_exec (bContext *C, wmOperator *op)
|
||||
ED_undo_push(C, "Insert Keyframe");
|
||||
|
||||
if (mode == 3) // material color requires different notifiers
|
||||
WM_event_add_notifier(C, NC_MATERIAL|ND_SHADING_DRAW, NULL);
|
||||
WM_event_add_notifier(C, NC_MATERIAL|ND_KEYS, NULL);
|
||||
else
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL);
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_KEYS, NULL);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -2184,7 +2184,7 @@ static int delete_key_exec (bContext *C, wmOperator *op)
|
||||
ED_undo_push(C, "Delete Keyframe");
|
||||
|
||||
// XXX what if it was a material keyframe?
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL);
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_KEYS, NULL);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
@@ -74,9 +74,9 @@ void ED_keymap_curve(wmWindowManager *wm)
|
||||
WM_keymap_add_item(keymap, "FONT_OT_textedit", KM_TEXTINPUT, KM_ANY, KM_ANY, 0);
|
||||
|
||||
/* only set in editmode curve, by space_view3d listener */
|
||||
// keymap= WM_keymap_listbase(wm, "Curve", 0, 0);
|
||||
keymap= WM_keymap_listbase(wm, "Curve", 0, 0);
|
||||
|
||||
// WM_keymap_add_item(keymap, "OBJECT_OT_de_select_all", AKEY, KM_PRESS, 0, 0);
|
||||
WM_keymap_add_item(keymap, "OBJECT_OT_curve_add", AKEY, KM_PRESS, KM_SHIFT, 0);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -4049,28 +4049,23 @@ int join_curve(Scene *scene, int type)
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Nurb *addNurbprim(Scene *scene, int type, int stype, int newname)
|
||||
/* type: &8= 2D; 0=poly,1 bez, 4 nurb
|
||||
* stype: 0: 2/4 points curve
|
||||
* 1: 8 points circle
|
||||
* 2: 4x4 patch Nurb
|
||||
* 3: tube 4:sphere 5:donut
|
||||
* 6: 5 points, 5th order straight line (for anim path)
|
||||
*/
|
||||
Nurb *addNurbprim(bContext *C, int type, int newname)
|
||||
{
|
||||
Object *obedit= scene->obedit; // XXX
|
||||
static int xzproj= 0; /* this function calls itself... */
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
Object *obedit= CTX_data_edit_object(C);
|
||||
ListBase *editnurb= curve_get_editcurve(obedit);
|
||||
View3D *v3d= NULL; // XXX
|
||||
RegionView3D *rv3d= NULL; // XXX
|
||||
static int xzproj= 0;
|
||||
View3D *v3d= CTX_wm_view3d(C);
|
||||
RegionView3D *rv3d= CTX_wm_region_view3d(C);
|
||||
Nurb *nu = NULL;
|
||||
BezTriple *bezt;
|
||||
BPoint *bp;
|
||||
float *curs, cent[3],vec[3],imat[3][3],mat[3][3];
|
||||
float fac,cmat[3][3], grid;
|
||||
int a, b;
|
||||
int a, b, cutype, stype;
|
||||
|
||||
cutype= type & CU_TYPE; // poly, bezier, nurbs, etc
|
||||
stype= type & CU_PRIMITIVE;
|
||||
|
||||
if (v3d) grid = v3d->grid;
|
||||
else grid = 1.0;
|
||||
@@ -4085,7 +4080,7 @@ Nurb *addNurbprim(Scene *scene, int type, int stype, int newname)
|
||||
cent[1]-= obedit->obmat[3][1];
|
||||
cent[2]-= obedit->obmat[3][2];
|
||||
|
||||
if (v3d) {
|
||||
if (rv3d) {
|
||||
if ( !(newname) || U.flag & USER_ADD_VIEWALIGNED)
|
||||
Mat3CpyMat4(imat, rv3d->viewmat);
|
||||
else Mat3One(imat);
|
||||
@@ -4096,11 +4091,11 @@ Nurb *addNurbprim(Scene *scene, int type, int stype, int newname)
|
||||
setflagsNurb(editnurb, 0);
|
||||
}
|
||||
else {
|
||||
Mat3One(imat);
|
||||
cent[0]= cent[1]= cent[2]= 0.0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (ELEM5(stype, 0, 1, 2, 4, 6)) {
|
||||
/* these types call this function to return a Nurb */
|
||||
if (stype!=CU_PRIM_TUBE && stype!=CU_PRIM_DONUT) {
|
||||
nu = (Nurb*)MEM_callocN(sizeof(Nurb), "addNurbprim");
|
||||
nu->type= type;
|
||||
nu->resolu= 4;
|
||||
@@ -4108,13 +4103,13 @@ Nurb *addNurbprim(Scene *scene, int type, int stype, int newname)
|
||||
}
|
||||
|
||||
switch(stype) {
|
||||
case 0: /* curve */
|
||||
case CU_PRIM_CURVE: /* curve */
|
||||
nu->resolu= 12; /* set as 4 above */
|
||||
if(newname) {
|
||||
rename_id((ID *)obedit, "Curve");
|
||||
rename_id((ID *)obedit->data, "Curve");
|
||||
}
|
||||
if((type & 7)==CU_BEZIER) {
|
||||
if(cutype==CU_BEZIER) {
|
||||
nu->pntsu= 2;
|
||||
nu->bezt =
|
||||
(BezTriple*)MEM_callocN(2 * sizeof(BezTriple), "addNurbprim1");
|
||||
@@ -4175,14 +4170,14 @@ Nurb *addNurbprim(Scene *scene, int type, int stype, int newname)
|
||||
bp= nu->bp;
|
||||
for(a=0;a<4;a++, bp++) Mat3MulVecfl(imat,bp->vec);
|
||||
|
||||
if((type & 7)==4) {
|
||||
if(cutype==CU_NURBS) {
|
||||
nu->knotsu= 0; /* makeknots allocates */
|
||||
makeknots(nu, 1, nu->flagu>>1);
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
case 6: /* 5 point path */
|
||||
case CU_PRIM_PATH: /* 5 point path */
|
||||
nu->pntsu= 5;
|
||||
nu->pntsv= 1;
|
||||
nu->orderu= 5;
|
||||
@@ -4210,19 +4205,19 @@ Nurb *addNurbprim(Scene *scene, int type, int stype, int newname)
|
||||
bp= nu->bp;
|
||||
for(a=0;a<5;a++, bp++) Mat3MulVecfl(imat,bp->vec);
|
||||
|
||||
if((type & 7)==4) {
|
||||
if(cutype==CU_NURBS) {
|
||||
nu->knotsu= 0; /* makeknots allocates */
|
||||
makeknots(nu, 1, nu->flagu>>1);
|
||||
}
|
||||
|
||||
break;
|
||||
case 1: /* circle */
|
||||
case CU_PRIM_CIRCLE: /* circle */
|
||||
nu->resolu= 12; /* set as 4 above */
|
||||
if(newname) {
|
||||
rename_id((ID *)obedit, "CurveCircle");
|
||||
rename_id((ID *)obedit->data, "CurveCircle");
|
||||
}
|
||||
if((type & 7)==CU_BEZIER) {
|
||||
if(cutype==CU_BEZIER) {
|
||||
nu->pntsu= 4;
|
||||
nu->bezt= callocstructN(BezTriple, 4, "addNurbprim1");
|
||||
nu->flagu= CU_CYCLIC;
|
||||
@@ -4269,7 +4264,7 @@ Nurb *addNurbprim(Scene *scene, int type, int stype, int newname)
|
||||
|
||||
calchandlesNurb(nu);
|
||||
}
|
||||
else if( (type & 7)==CU_NURBS ) { /* nurb */
|
||||
else if( cutype==CU_NURBS ) { /* nurb */
|
||||
nu->pntsu= 8;
|
||||
nu->pntsv= 1;
|
||||
nu->orderu= 4;
|
||||
@@ -4300,8 +4295,8 @@ Nurb *addNurbprim(Scene *scene, int type, int stype, int newname)
|
||||
makeknots(nu, 1, nu->flagu>>1);
|
||||
}
|
||||
break;
|
||||
case 2: /* 4x4 patch */
|
||||
if( (type & 7)==CU_NURBS ) { /* nurb */
|
||||
case CU_PRIM_PATCH: /* 4x4 patch */
|
||||
if( cutype==CU_NURBS ) { /* nurb */
|
||||
if(newname) {
|
||||
rename_id((ID *)obedit, "Surf");
|
||||
rename_id((ID *)obedit->data, "Surf");
|
||||
@@ -4338,14 +4333,14 @@ Nurb *addNurbprim(Scene *scene, int type, int stype, int newname)
|
||||
makeknots(nu, 2, nu->flagv>>1);
|
||||
}
|
||||
break;
|
||||
case 3: /* tube */
|
||||
if( (type & 7)==CU_NURBS ) {
|
||||
case CU_PRIM_TUBE: /* tube */
|
||||
if( cutype==CU_NURBS ) {
|
||||
if(newname) {
|
||||
rename_id((ID *)obedit, "SurfTube");
|
||||
rename_id((ID *)obedit->data, "SurfTube");
|
||||
}
|
||||
|
||||
nu= addNurbprim(scene, 4, 1, newname); /* circle */
|
||||
nu= addNurbprim(C, CU_NURBS|CU_2D|CU_PRIM_CIRCLE, 0); /* circle */
|
||||
nu->resolu= 4;
|
||||
nu->flag= CU_SMOOTH;
|
||||
BLI_addtail(editnurb, nu); /* temporal for extrude and translate */
|
||||
@@ -4369,8 +4364,8 @@ Nurb *addNurbprim(Scene *scene, int type, int stype, int newname)
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 4: /* sphere */
|
||||
if( (type & 7)==CU_NURBS ) {
|
||||
case CU_PRIM_SPHERE: /* sphere */
|
||||
if( cutype==CU_NURBS ) {
|
||||
if(newname) {
|
||||
rename_id((ID *)obedit, "SurfSphere");
|
||||
rename_id((ID *)obedit->data, "SurfSphere");
|
||||
@@ -4416,15 +4411,15 @@ Nurb *addNurbprim(Scene *scene, int type, int stype, int newname)
|
||||
BLI_remlink(editnurb, nu);
|
||||
}
|
||||
break;
|
||||
case 5: /* donut */
|
||||
if( (type & 7)==CU_NURBS ) {
|
||||
case CU_PRIM_DONUT: /* donut */
|
||||
if( cutype==CU_NURBS ) {
|
||||
if(newname) {
|
||||
rename_id((ID *)obedit, "SurfDonut");
|
||||
rename_id((ID *)obedit->data, "SurfDonut");
|
||||
}
|
||||
|
||||
xzproj= 1;
|
||||
nu= addNurbprim(scene, 4, 1, newname); /* circle */
|
||||
nu= addNurbprim(C, CU_NURBS|CU_2D|CU_PRIM_CIRCLE, 0); /* circle */
|
||||
xzproj= 0;
|
||||
nu->resolu= 4;
|
||||
nu->resolv= 4;
|
||||
@@ -4492,110 +4487,6 @@ void default_curve_ipo(Scene *scene, Curve *cu)
|
||||
#endif // XXX old animation system
|
||||
}
|
||||
|
||||
void add_primitiveCurve(Scene *scene, int stype)
|
||||
{
|
||||
Object *obedit= scene->obedit; // XXX
|
||||
ListBase *editnurb= curve_get_editcurve(obedit);
|
||||
View3D *v3d= NULL; // XXX
|
||||
Nurb *nu;
|
||||
Curve *cu;
|
||||
int type, newname= 0;
|
||||
|
||||
if(v3d==0) return;
|
||||
if(scene->id.lib) return;
|
||||
|
||||
if(stype>=10 && stype<20) type= CU_2D+1;
|
||||
else if(stype>=20 && stype<30) type= CU_2D+2;
|
||||
else if(stype>=30 && stype<40) type= CU_2D+3;
|
||||
else if(stype>=40 && stype<50) {
|
||||
if(stype==46) type= 4;
|
||||
else type= CU_2D+4;
|
||||
}
|
||||
else type= CU_2D;
|
||||
|
||||
// XXX check_editmode(OB_CURVE);
|
||||
|
||||
/* if no obedit: new object and enter editmode */
|
||||
if(obedit==NULL) {
|
||||
// XXX add_object_draw(OB_CURVE);
|
||||
ED_object_base_init_from_view(NULL, BASACT); // NULL is C
|
||||
obedit= BASACT->object;
|
||||
|
||||
where_is_object(scene, obedit);
|
||||
|
||||
make_editNurb(obedit);
|
||||
newname= 1;
|
||||
|
||||
cu= obedit->data;
|
||||
if(stype==46) {
|
||||
cu->flag |= (CU_3D+CU_PATH);
|
||||
|
||||
default_curve_ipo(scene, cu);
|
||||
}
|
||||
}
|
||||
else {
|
||||
cu= obedit->data;
|
||||
}
|
||||
|
||||
if(cu->flag & CU_3D) type &= ~CU_2D;
|
||||
|
||||
stype= (stype % 10);
|
||||
|
||||
nu= addNurbprim(scene, type, stype, newname); /* 2D */
|
||||
|
||||
BLI_addtail(editnurb, nu);
|
||||
DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
|
||||
|
||||
/* if a new object was created, it stores it in Curve, for reload original data and undo */
|
||||
if ( !(newname) || U.flag & USER_ADD_EDITMODE) {
|
||||
if(newname) load_editNurb(obedit);
|
||||
} else {
|
||||
// XXX
|
||||
ED_object_exit_editmode(NULL, EM_FREEDATA|EM_WAITCURSOR);
|
||||
}
|
||||
|
||||
BIF_undo_push("Add Curve");
|
||||
}
|
||||
|
||||
void add_primitiveNurb(Scene *scene, int type)
|
||||
{
|
||||
Object *obedit= scene->obedit; // XXX
|
||||
ListBase *editnurb= curve_get_editcurve(obedit);
|
||||
Nurb *nu;
|
||||
int newname= 0;
|
||||
|
||||
if(scene->id.lib) return;
|
||||
|
||||
// XXX check_editmode(OB_SURF);
|
||||
|
||||
/* if no obedit: new object and enter editmode */
|
||||
if(obedit==0) {
|
||||
// XXX add_object_draw(OB_SURF);
|
||||
ED_object_base_init_from_view(NULL, BASACT); // NULL is C
|
||||
obedit= BASACT->object;
|
||||
|
||||
where_is_object(scene, obedit);
|
||||
|
||||
make_editNurb(obedit);
|
||||
newname= 1;
|
||||
}
|
||||
|
||||
nu= addNurbprim(scene, 4, type, newname);
|
||||
BLI_addtail(editnurb,nu);
|
||||
DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
|
||||
|
||||
/* if a new object was created, it stores it in Curve, for reload original data and undo */
|
||||
if ( !(newname) || U.flag & USER_ADD_EDITMODE) {
|
||||
if(newname) load_editNurb(obedit);
|
||||
} else {
|
||||
// XXX
|
||||
ED_object_exit_editmode(NULL, EM_FREEDATA|EM_WAITCURSOR);
|
||||
}
|
||||
|
||||
BIF_undo_push("Add Surface");
|
||||
}
|
||||
|
||||
|
||||
|
||||
void clear_tilt(Scene *scene)
|
||||
{
|
||||
|
||||
@@ -112,6 +112,7 @@ typedef enum eAnim_ChannelType {
|
||||
ANIMTYPE_FCURVE,
|
||||
|
||||
ANIMTYPE_FILLACTD,
|
||||
ANIMTYPE_FILLDRIVERS,
|
||||
ANIMTYPE_FILLMATD,
|
||||
|
||||
ANIMTYPE_DSMAT,
|
||||
@@ -170,7 +171,9 @@ typedef enum eAnimFilter_Flags {
|
||||
#define FILTER_CUR_OBJD(cu) ((cu->flag & CU_DS_EXPAND))
|
||||
/* 'Sub-object/Action' channels (flags stored in Action) */
|
||||
#define SEL_ACTC(actc) ((actc->flag & ACT_SELECTED))
|
||||
#define EXPANDED_ACTC(actc) ((actc->flag & ACT_EXPANDED))
|
||||
#define EXPANDED_ACTC(actc) ((actc->flag & ACT_COLLAPSED)==0)
|
||||
/* 'Sub-AnimData' chanenls */
|
||||
#define EXPANDED_DRVD(adt) ((adt->flag & ADT_DRIVERS_COLLAPSED)==0)
|
||||
|
||||
/* Actions (also used for Dopesheet) */
|
||||
/* Action Channel Group */
|
||||
|
||||
@@ -50,6 +50,8 @@ void free_editNurb (struct Object *obedit);
|
||||
|
||||
void mouse_nurb (struct bContext *C, short mval[2], int extend);
|
||||
|
||||
struct Nurb *addNurbprim(struct bContext *C, int type, int newname);
|
||||
|
||||
/* editfont.h */
|
||||
void undo_push_font (struct bContext *C, char *name);
|
||||
void make_editText (struct Object *obedit);
|
||||
|
||||
39
source/blender/editors/include/ED_image.h
Normal file
39
source/blender/editors/include/ED_image.h
Normal file
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* $Id:
|
||||
*
|
||||
* ***** BEGIN GPL LICENSE BLOCK *****
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* The Original Code is Copyright (C) 2008 Blender Foundation.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Contributor(s): Blender Foundation
|
||||
*
|
||||
* ***** END GPL LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
#ifndef ED_IMAGE_H
|
||||
#define ED_IMAGE_H
|
||||
|
||||
struct SpaceImage;
|
||||
|
||||
/* space_image.c, exported for transform */
|
||||
struct Image *ED_space_image(struct SpaceImage *sima);
|
||||
void ED_space_image_size(struct SpaceImage *sima, int *width, int *height);
|
||||
void ED_space_image_uv_aspect(struct SpaceImage *sima, float *aspx, float *aspy);
|
||||
|
||||
#endif /* ED_IMAGE_H */
|
||||
|
||||
@@ -53,6 +53,8 @@ typedef enum eEditKeyframes_Validate {
|
||||
BEZT_OK_FRAMERANGE,
|
||||
BEZT_OK_SELECTED,
|
||||
BEZT_OK_VALUE,
|
||||
BEZT_OK_VALUERANGE,
|
||||
BEZT_OK_REGION,
|
||||
} eEditKeyframes_Validate;
|
||||
|
||||
/* ------------ */
|
||||
@@ -71,6 +73,7 @@ typedef enum eEditKeyframes_Snap {
|
||||
SNAP_KEYS_NEARFRAME,
|
||||
SNAP_KEYS_NEARSEC,
|
||||
SNAP_KEYS_NEARMARKER,
|
||||
SNAP_KEYS_HORIZONTAL,
|
||||
} eEditKeyframes_Snap;
|
||||
|
||||
/* mirroring tools */
|
||||
@@ -89,7 +92,7 @@ typedef enum eEditKeyframes_Mirror {
|
||||
typedef struct BeztEditData {
|
||||
ListBase list; /* temp list for storing custom list of data to check */
|
||||
struct Scene *scene; /* pointer to current scene - many tools need access to cfra/etc. */
|
||||
void *data; /* pointer to custom data - usually 'Object', but could be other types too */
|
||||
void *data; /* pointer to custom data - usually 'Object' but also 'rectf', but could be other types too */
|
||||
float f1, f2; /* storage of times/values as 'decimals' */
|
||||
int i1, i2; /* storage of times/values/flags as 'whole' numbers */
|
||||
} BeztEditData;
|
||||
@@ -126,10 +129,10 @@ BeztEditFunc ANIM_editkeyframes_ipo(short mode);
|
||||
|
||||
void delete_fcurve_key(struct FCurve *fcu, int index, short do_recalc);
|
||||
void delete_fcurve_keys(struct FCurve *fcu);
|
||||
void duplicate_fcurve_keys(struct FCurve *fcu); // XXX fixme...
|
||||
void duplicate_fcurve_keys(struct FCurve *fcu);
|
||||
|
||||
void clean_fcurve(struct FCurve *fcu, float thresh);
|
||||
void smooth_fcurve(struct FCurve *fcu, short mode);
|
||||
void smooth_fcurve(struct FCurve *fcu);
|
||||
|
||||
/* ************************************************ */
|
||||
|
||||
|
||||
35
source/blender/editors/include/ED_node.h
Normal file
35
source/blender/editors/include/ED_node.h
Normal file
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* $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 ED_NODE_H
|
||||
#define ED_NODE_H
|
||||
|
||||
/* drawnode.c */
|
||||
void ED_init_node_butfuncs(void);
|
||||
|
||||
#endif /* ED_NODE_H */
|
||||
|
||||
@@ -40,6 +40,7 @@ struct Lattice;
|
||||
struct Mesh;
|
||||
struct Curve;
|
||||
|
||||
/* object_edit.c */
|
||||
void ED_operatortypes_object(void);
|
||||
void ED_keymap_object(struct wmWindowManager *wm);
|
||||
|
||||
@@ -51,6 +52,8 @@ void ED_base_object_activate(struct bContext *C, struct Base *base);
|
||||
void ED_base_object_free_and_unlink(struct Scene *scene, struct Base *base);
|
||||
|
||||
void ED_object_apply_obmat(struct Object *ob);
|
||||
/* single object duplicate, if dupflag==0, fully linked, else it uses U.dupflag */
|
||||
Base *ED_object_add_duplicate(struct Scene *scene, struct Base *base, int usedupflag);
|
||||
|
||||
|
||||
/* bitflags for enter/exit editmode */
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
|
||||
struct Object;
|
||||
struct bContext;
|
||||
struct uiMenuBlockHandle;
|
||||
struct ARegion;
|
||||
struct uiBlock;
|
||||
struct wmOperatorType;
|
||||
|
||||
@@ -55,7 +55,7 @@ void undo_editmode_push(struct bContext *C, char *name,
|
||||
|
||||
|
||||
void *undo_editmode_get_prev (struct Object *ob);
|
||||
struct uiBlock *editmode_undohistorymenu(struct bContext *C, struct uiMenuBlockHandle *handle, void *arg_unused);
|
||||
struct uiBlock *editmode_undohistorymenu(struct bContext *C, struct ARegion *ar, void *arg_unused);
|
||||
void undo_editmode_menu (struct bContext *C);
|
||||
void undo_editmode_clear (void);
|
||||
void undo_editmode_step (struct bContext *C, int step);
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
|
||||
struct Scene;
|
||||
struct Object;
|
||||
struct MTFace;
|
||||
struct EditFace;
|
||||
struct Image;
|
||||
struct wmWindowManager;
|
||||
|
||||
@@ -41,5 +43,20 @@ void ED_uvedit_assign_image(struct Scene *scene, struct Object *obedit, struct I
|
||||
void ED_uvedit_set_tile(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);
|
||||
int ED_uvedit_test(struct Object *obedit);
|
||||
|
||||
int uvedit_face_visible(struct Scene *scene, struct Image *ima, struct EditFace *efa, struct MTFace *tf);
|
||||
int uvedit_face_selected(struct Scene *scene, struct EditFace *efa, struct MTFace *tf);
|
||||
int uvedit_edge_selected(struct Scene *scene, struct EditFace *efa, struct MTFace *tf, int i);
|
||||
int uvedit_uv_selected(struct Scene *scene, struct EditFace *efa, struct MTFace *tf, int i);
|
||||
|
||||
int ED_uvedit_nearest_uv(struct Scene *scene, struct Object *obedit, struct Image *ima, float co[2], float uv[2]);
|
||||
|
||||
/* uvedit_unwrap.c */
|
||||
void ED_uvedit_live_unwrap_begin(struct Scene *scene, struct Object *obedit);
|
||||
void ED_uvedit_live_unwrap_re_solve(void);
|
||||
void ED_uvedit_live_unwrap_end(short cancel);
|
||||
|
||||
#endif /* ED_UVEDIT_H */
|
||||
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
#ifndef UI_INTERFACE_H
|
||||
#define UI_INTERFACE_H
|
||||
|
||||
/* Struct Declarations */
|
||||
|
||||
struct ID;
|
||||
struct ListBase;
|
||||
struct ARegion;
|
||||
@@ -42,6 +44,12 @@ struct PointerRNA;
|
||||
struct PropertyRNA;
|
||||
struct ReportList;
|
||||
|
||||
typedef struct uiBut uiBut;
|
||||
typedef struct uiBlock uiBlock;
|
||||
typedef struct uiPopupBlockHandle uiPopupBlockHandle;
|
||||
|
||||
/* Defines */
|
||||
|
||||
/* uiBlock->dt */
|
||||
#define UI_EMBOSS 0 /* use one of the themes for drawing */
|
||||
#define UI_EMBOSSN 1 /* Nothing */
|
||||
@@ -76,7 +84,7 @@ struct ReportList;
|
||||
#define UI_BLOCK_MOVEMOUSE_QUIT 128
|
||||
#define UI_BLOCK_KEEP_OPEN 256
|
||||
|
||||
/* uiMenuBlockHandle->menuretval */
|
||||
/* uiPopupBlockHandle->menuretval */
|
||||
#define UI_RETURN_CANCEL 1 /* cancel all menus cascading */
|
||||
#define UI_RETURN_OK 2 /* choice made */
|
||||
#define UI_RETURN_OUT 4 /* left the menu */
|
||||
@@ -169,12 +177,13 @@ struct ReportList;
|
||||
#define ICONTOGN (34<<9)
|
||||
#define FTPREVIEW (35<<9)
|
||||
#define NUMABS (36<<9)
|
||||
#define HMENU (37<<9)
|
||||
#define BUTTYPE (63<<9)
|
||||
|
||||
typedef struct uiBut uiBut;
|
||||
typedef struct uiBlock uiBlock;
|
||||
|
||||
/* Common Drawing Functions */
|
||||
/* Drawing
|
||||
*
|
||||
* Functions to draw various shapes, taking theme settings into account.
|
||||
* Used for code that draws its own UI style elements. */
|
||||
|
||||
void uiEmboss(float x1, float y1, float x2, float y2, int sel);
|
||||
void uiRoundBox(float minx, float miny, float maxx, float maxy, float rad);
|
||||
@@ -183,91 +192,137 @@ void uiRoundRect(float minx, float miny, float maxx, float maxy, float rad);
|
||||
void uiDrawMenuBox(float minx, float miny, float maxx, float maxy, short flag, short direction);
|
||||
void uiDrawBoxShadow(unsigned char alpha, float minx, float miny, float maxx, float maxy);
|
||||
|
||||
/* Popup Menu's */
|
||||
/* Menus
|
||||
*
|
||||
* These functions are used by popup menus, toolbox and header menus. They
|
||||
* assume uiMenuItem head is already created, which is done by uiMenuButton
|
||||
* for header menus, or can be done with uiPupMenuBegin for popups. These
|
||||
* functions do not use uiDefBut functions in order to simplify creating
|
||||
* them, and to permit other types of menus (radial, ..) in the future. */
|
||||
|
||||
typedef struct uiMenuBlockHandle {
|
||||
/* internal */
|
||||
struct ARegion *region;
|
||||
int towardsx, towardsy;
|
||||
double towardstime;
|
||||
int dotowards;
|
||||
|
||||
int popup;
|
||||
void (*popup_func)(struct bContext *C, void *arg, int event);
|
||||
void *popup_arg;
|
||||
/* for operator menus */
|
||||
struct wmOperator *op_arg;
|
||||
const char *propname;
|
||||
|
||||
/* return values */
|
||||
int butretval;
|
||||
int menuretval;
|
||||
float retvalue;
|
||||
float retvec[3];
|
||||
} uiMenuBlockHandle;
|
||||
|
||||
typedef uiBlock* (*uiBlockFuncFP)(struct bContext *C, struct uiMenuBlockHandle *handle, void *arg1);
|
||||
typedef void (*uiPupmenuFunc)(struct bContext *C, void *arg, int event);
|
||||
|
||||
void uiPupmenuSetActive(int val);
|
||||
|
||||
void uiPupmenuOperator(struct bContext *C, int maxrow, struct wmOperator *op, const char *propname, char *str);
|
||||
void uiPupmenu(struct bContext *C, int maxrow, uiPupmenuFunc func, void *arg, char *str, ...);
|
||||
void uiPupmenuOkee(struct bContext *C, char *opname, char *str, ...);
|
||||
void uiPupmenuSaveOver(struct bContext *C, char *opname, char *filename, ...);
|
||||
void uiPupmenuNotice(struct bContext *C, char *str, ...);
|
||||
void uiPupmenuError(struct bContext *C, char *str, ...);
|
||||
void uiPupmenuReports(struct bContext *C, struct ReportList *reports);
|
||||
|
||||
/* Custom popup menus and toolbox */
|
||||
typedef struct uiMenuItem uiMenuItem;
|
||||
|
||||
uiMenuItem *uiMenuBegin(const char *title);
|
||||
typedef void (*uiMenuCreateFunc)(struct bContext *C, uiMenuItem *head, void *arg1);
|
||||
typedef void (*uiMenuHandleFunc)(struct bContext *C, void *arg, int event);
|
||||
|
||||
void uiMenuFunc(uiMenuItem *head, void (*eventfunc)(struct bContext *, void *, int), void *argv);
|
||||
void uiMenuFunc(uiMenuItem *head, uiMenuHandleFunc handlefunc, void *argv);
|
||||
void uiMenuContext(uiMenuItem *head, int opcontext);
|
||||
|
||||
void uiMenuItemVal(uiMenuItem *head, const char *name, int icon, int argval);
|
||||
|
||||
void uiMenuItemEnumO(uiMenuItem *head, char *opname, char *propname, int value);
|
||||
void uiMenuItemBooleanO(uiMenuItem *head, char *opname, char *propname, int value);
|
||||
void uiMenuItemsEnumO(uiMenuItem *head, char *opname, char *propname);
|
||||
void uiMenuItemFloatO(uiMenuItem *head, const char *name, char *opname, char *propname, float value);
|
||||
void uiMenuItemO(uiMenuItem *head, char *name, int icon);
|
||||
void uiMenuLevel(uiMenuItem *head, const char *name, void (*newlevel)(uiMenuItem *));
|
||||
|
||||
void uiMenuItemBooleanR(uiMenuItem *head, struct PointerRNA *ptr, char *propname);
|
||||
void uiMenuItemEnumR(uiMenuItem *head, struct PointerRNA *ptr, char *propname, int value);
|
||||
void uiMenuItemsEnumR(uiMenuItem *head, struct PointerRNA *ptr, char *propname);
|
||||
|
||||
void uiMenuLevel(uiMenuItem *head, const char *name, uiMenuCreateFunc newlevel);
|
||||
void uiMenuLevelEnumO(uiMenuItem *head, char *opname, char *propname);
|
||||
void uiMenuLevelEnumR(uiMenuItem *head, struct PointerRNA *ptr, char *propname);
|
||||
|
||||
void uiMenuEnd(struct bContext *C, struct uiMenuItem *head);
|
||||
void uiMenuSeparator(uiMenuItem *head);
|
||||
|
||||
/* Block */
|
||||
/* Popup Menus
|
||||
*
|
||||
* Functions used to create popup menus. For more extended menus the
|
||||
* uiPupMenuBegin/End functions can be used to define own items with
|
||||
* the uiMenu functions inbetween. If it is a simple confirmation menu
|
||||
* or similar, popups can be created with a single function call. */
|
||||
|
||||
uiMenuItem *uiPupMenuBegin(const char *title);
|
||||
void uiPupMenuEnd(struct bContext *C, struct uiMenuItem *head);
|
||||
|
||||
void uiPupMenu(struct bContext *C, int maxrow, uiMenuHandleFunc func, void *arg, char *str, ...);
|
||||
void uiPupMenuOperator(struct bContext *C, int maxrow, struct wmOperator *op, const char *propname, char *str);
|
||||
void uiPupMenuOkee(struct bContext *C, char *opname, char *str, ...);
|
||||
void uiPupMenuSaveOver(struct bContext *C, char *opname, char *filename, ...);
|
||||
void uiPupMenuNotice(struct bContext *C, char *str, ...);
|
||||
void uiPupMenuError(struct bContext *C, char *str, ...);
|
||||
void uiPupMenuReports(struct bContext *C, struct ReportList *reports);
|
||||
|
||||
void uiPupMenuSetActive(int val);
|
||||
|
||||
/* Popup Blocks
|
||||
*
|
||||
* Functions used to create popup blocks. These are like popup menus
|
||||
* but allow using all button types and creating an own layout. */
|
||||
|
||||
uiBlock *uiPupBlockBegin(struct bContext *C, const char *title);
|
||||
void uiPupBlockEnd(struct bContext *C, uiBlock *block);
|
||||
|
||||
/* Blocks
|
||||
*
|
||||
* Functions for creating, drawing and freeing blocks. A Block is a
|
||||
* container of buttons and used for various purposes.
|
||||
*
|
||||
* Begin/Define Buttons/End/Draw is the typical order in which these
|
||||
* function should be called, though for popup blocks Draw is left out.
|
||||
* Freeing blocks is done by the screen/ module automatically.
|
||||
*
|
||||
* */
|
||||
|
||||
uiBlock *uiBeginBlock(const struct bContext *C, struct ARegion *region, char *name, short dt, short font);
|
||||
void uiEndBlock(const struct bContext *C, uiBlock *block);
|
||||
void uiDrawBlock(const struct bContext *C, struct uiBlock *block);
|
||||
|
||||
uiBlock *uiGetBlock(char *name, struct ARegion *ar);
|
||||
|
||||
void uiFreeBlock(const struct bContext *C, uiBlock *block);
|
||||
void uiFreeBlocks(const struct bContext *C, struct ListBase *lb);
|
||||
void uiFreeInactiveBlocks(const struct bContext *C, struct ListBase *lb);
|
||||
|
||||
void uiBoundsBlock(struct uiBlock *block, int addval);
|
||||
void uiTextBoundsBlock(uiBlock *block, int addval);
|
||||
|
||||
void uiBlockSetButLock(uiBlock *block, int val, char *lockstr);
|
||||
void uiBlockClearButLock(uiBlock *block);
|
||||
|
||||
/* Appearance/Cruft
|
||||
*
|
||||
* These functions should mostly dissappear ideally, or become internal.
|
||||
* Font handling could move to blenfont/, and appearance could be dictated
|
||||
* better by high level information instead of spread out all over. */
|
||||
|
||||
void uiSetCurFont(uiBlock *block, int index);
|
||||
void *uiSetCurFont_ext(float aspect);
|
||||
void uiDefFont(unsigned int index, void *xl, void *large, void *medium, void *small);
|
||||
void *uiBlockGetCurFont (uiBlock *block);
|
||||
|
||||
/* automatic aligning, horiz or verical */
|
||||
void uiBlockBeginAlign(uiBlock *block);
|
||||
void uiBlockEndAlign(uiBlock *block);
|
||||
|
||||
/* Misc */
|
||||
void uiBoundsBlock(struct uiBlock *block, int addval);
|
||||
void uiTextBoundsBlock(uiBlock *block, int addval);
|
||||
void uiPopupBoundsBlock(uiBlock *block, int addval);
|
||||
|
||||
void uiSetCurFont(uiBlock *block, int index);
|
||||
void *uiSetCurFont_ext(float aspect);
|
||||
void uiDefFont(unsigned int index, void *xl, void *large, void *medium, void *small);
|
||||
int uiBlocksGetYMin (ListBase *lb);
|
||||
int uiBlockGetCol (uiBlock *block);
|
||||
|
||||
void uiComposeLinks(uiBlock *block);
|
||||
uiBut *uiFindInlink(uiBlock *block, void *poin);
|
||||
void uiBlockSetCol (uiBlock *block, int col);
|
||||
void uiBlockSetEmboss (uiBlock *block, int emboss);
|
||||
void uiBlockSetDirection (uiBlock *block, int direction);
|
||||
void uiBlockFlipOrder (uiBlock *block);
|
||||
void uiBlockSetFlag (uiBlock *block, int flag);
|
||||
void uiBlockSetXOfs (uiBlock *block, int xofs);
|
||||
|
||||
void uiBlockPickerButtons(struct uiBlock *block, float *col, float *hsv, float *old, char *hexcol, char mode, short retval);
|
||||
int uiButGetRetVal (uiBut *but);
|
||||
|
||||
/* Defining Buttons */
|
||||
void uiButSetFlag (uiBut *but, int flag);
|
||||
void uiButClearFlag (uiBut *but, int flag);
|
||||
|
||||
void uiAutoBlock(uiBlock *block, float minx, float miny, float sizex, float sizey, int flag);
|
||||
|
||||
/* Buttons
|
||||
*
|
||||
* Functions to define various types of buttons in a block. Postfixes:
|
||||
* - F: float
|
||||
* - I: int
|
||||
* - S: short
|
||||
* - C: char
|
||||
* - R: RNA
|
||||
* - O: operator */
|
||||
|
||||
uiBut *uiDefBut(uiBlock *block,
|
||||
int type, int retval, char *str,
|
||||
@@ -323,65 +378,93 @@ uiBut *uiDefIconTextButBitC(uiBlock *block, int type, int bit, int retval, int i
|
||||
uiBut *uiDefIconTextButR(uiBlock *block, int type, int retval, int icon, char *str, short x1, short y1, short x2, short y2, struct PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2, char *tip);
|
||||
uiBut *uiDefIconTextButO(uiBlock *block, int type, char *opname, int opcontext, int icon, char *str, short x1, short y1, short x2, short y2, char *tip);
|
||||
|
||||
typedef void (*uiIDPoinFuncFP) (struct bContext *C, char *str, struct ID **idpp);
|
||||
/* for passing inputs to ButO buttons */
|
||||
struct PointerRNA *uiButGetOperatorPtrRNA(uiBut *but);
|
||||
|
||||
/* Special Buttons
|
||||
*
|
||||
* Butons with a more specific purpose:
|
||||
* - IDPoinBut: for creating buttons that work on a pointer to an ID block.
|
||||
* - MenuBut: buttons that popup a menu (in headers usually).
|
||||
* - PulldownBut: like MenuBut, but creating a uiBlock (for compatibility).
|
||||
* - BlockBut: buttons that popup a block with more buttons.
|
||||
* - KeyevtBut: buttons that can be used to turn key events into values.
|
||||
* - PickerButtons: buttons like the color picker (for code sharing). */
|
||||
|
||||
typedef uiBlock* (*uiBlockCreateFunc)(struct bContext *C, struct ARegion *ar, void *arg1);
|
||||
typedef void (*uiIDPoinFuncFP)(struct bContext *C, char *str, struct ID **idpp);
|
||||
|
||||
uiBut *uiDefIDPoinBut(struct uiBlock *block, uiIDPoinFuncFP func, short blocktype, int retval, char *str,
|
||||
short x1, short y1, short x2, short y2, void *idpp, char *tip);
|
||||
|
||||
uiBut *uiDefBlockBut(uiBlock *block, uiBlockFuncFP func, void *func_arg1, char *str, short x1, short y1, short x2, short y2, char *tip);
|
||||
uiBut *uiDefPulldownBut(uiBlock *block, uiBlockFuncFP func, void *func_arg1, char *str, short x1, short y1, short x2, short y2, char *tip);
|
||||
uiBut *uiDefPulldownBut(uiBlock *block, uiBlockCreateFunc func, void *arg, char *str, short x1, short y1, short x2, short y2, char *tip);
|
||||
uiBut *uiDefMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, char *str, short x1, short y1, short x2, short y2, char *tip);
|
||||
uiBut *uiDefIconTextMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, int icon, char *str, short x1, short y1, short x2, short y2, char *tip);
|
||||
|
||||
uiBut *uiDefIconTextBlockBut(uiBlock *block, uiBlockFuncFP func, void *arg, int icon, char *str, short x1, short y1, short x2, short y2, char *tip);
|
||||
uiBut *uiDefIconBlockBut(uiBlock *block, uiBlockFuncFP func, void *arg, int retval, int icon, short x1, short y1, short x2, short y2, char *tip);
|
||||
uiBut *uiDefBlockBut(uiBlock *block, uiBlockCreateFunc func, void *func_arg1, char *str, short x1, short y1, short x2, short y2, char *tip);
|
||||
uiBut *uiDefIconBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg, int retval, int icon, short x1, short y1, short x2, short y2, char *tip);
|
||||
uiBut *uiDefIconTextBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg, int icon, char *str, short x1, short y1, short x2, short y2, char *tip);
|
||||
|
||||
void uiDefKeyevtButS(uiBlock *block, int retval, char *str, short x1, short y1, short x2, short y2, short *spoin, char *tip);
|
||||
|
||||
uiBut *uiDefMenuButO(uiBlock *block, char *opname, char *name);
|
||||
uiBut *uiDefMenuSep(uiBlock *block);
|
||||
uiBut *uiDefMenuSub(uiBlock *block, uiBlockFuncFP func, char *name);
|
||||
uiBut *uiDefMenuTogR(uiBlock *block, struct PointerRNA *ptr, char *propname, char *propvalue, char *name);
|
||||
void uiBlockPickerButtons(struct uiBlock *block, float *col, float *hsv, float *old, char *hexcol, char mode, short retval);
|
||||
|
||||
void uiAutoBlock(struct uiBlock *block,
|
||||
float minx, float miny,
|
||||
float sizex, float sizey, int flag);
|
||||
void uiSetButLink(struct uiBut *but,
|
||||
void **poin,
|
||||
void ***ppoin,
|
||||
short *tot,
|
||||
int from, int to);
|
||||
/* Links
|
||||
*
|
||||
* Game engine logic brick links. Non-functional currently in 2.5,
|
||||
* code to handle and draw these is disabled internally. */
|
||||
|
||||
int uiBlocksGetYMin (ListBase *lb);
|
||||
int uiBlockGetCol (uiBlock *block);
|
||||
void* uiBlockGetCurFont (uiBlock *block);
|
||||
void uiSetButLink(struct uiBut *but, void **poin, void ***ppoin, short *tot, int from, int to);
|
||||
|
||||
void uiBlockSetCol (uiBlock *block, int col);
|
||||
void uiBlockSetEmboss (uiBlock *block, int emboss);
|
||||
void uiBlockSetDirection (uiBlock *block, int direction);
|
||||
void uiBlockFlipOrder (uiBlock *block);
|
||||
void uiBlockSetFlag (uiBlock *block, int flag);
|
||||
void uiBlockSetXOfs (uiBlock *block, int xofs);
|
||||
void uiComposeLinks(uiBlock *block);
|
||||
uiBut *uiFindInlink(uiBlock *block, void *poin);
|
||||
|
||||
int uiButGetRetVal (uiBut *but);
|
||||
/* Callbacks
|
||||
*
|
||||
* uiBlockSetHandleFunc/ButmFunc are for handling events through a callback.
|
||||
* HandleFunc gets the retval passed on, and ButmFunc gets a2. The latter is
|
||||
* mostly for compatibility with older code.
|
||||
*
|
||||
* uiButSetCompleteFunc is for tab completion.
|
||||
*
|
||||
* uiBlockSetFunc and uiButSetFunc are callbacks run when a button is used,
|
||||
* in case events, operators or RNA are not sufficient to handle the button. */
|
||||
|
||||
void uiButSetFlag (uiBut *but, int flag);
|
||||
void uiButClearFlag (uiBut *but, int flag);
|
||||
typedef void (*uiButHandleFunc)(struct bContext *C, void *arg1, void *arg2);
|
||||
typedef void (*uiButCompleteFunc)(struct bContext *C, char *str, void *arg);
|
||||
typedef void (*uiBlockHandleFunc)(struct bContext *C, void *arg, int event);
|
||||
|
||||
struct PointerRNA *uiButGetOperatorPtrRNA(uiBut *but);
|
||||
void uiBlockSetHandleFunc(uiBlock *block, uiBlockHandleFunc func, void *arg);
|
||||
void uiBlockSetButmFunc (uiBlock *block, uiMenuHandleFunc func, void *arg);
|
||||
|
||||
void uiBlockSetHandleFunc(uiBlock *block, void (*func)(struct bContext *C, void *arg, int event), void *arg);
|
||||
void uiBlockSetButmFunc (uiBlock *block, void (*func)(struct bContext *C, void *arg, int but_a2), void *arg);
|
||||
void uiBlockSetFunc (uiBlock *block, uiButHandleFunc func, void *arg1, void *arg2);
|
||||
void uiButSetFunc (uiBut *but, uiButHandleFunc func, void *arg1, void *arg2);
|
||||
|
||||
void uiBlockSetFunc (uiBlock *block, void (*func)(struct bContext *C, void *arg1, void *arg2), void *arg1, void *arg2);
|
||||
void uiButSetFunc (uiBut *but, void (*func)(struct bContext *C, void *arg1, void *arg2), void *arg1, void *arg2);
|
||||
|
||||
void uiButSetCompleteFunc(uiBut *but, void (*func)(struct bContext *C, char *str, void *arg), void *arg);
|
||||
void uiButSetCompleteFunc(uiBut *but, uiButCompleteFunc func, void *arg);
|
||||
|
||||
void uiBlockSetDrawExtraFunc(uiBlock *block, void (*func)(struct bContext *C, uiBlock *block));
|
||||
|
||||
/* Panels */
|
||||
/* Autocomplete
|
||||
*
|
||||
* Tab complete helper functions, for use in uiButCompleteFunc callbacks.
|
||||
* Call begin once, then multiple times do_name with all possibilities,
|
||||
* and finally end to finish and get the completed name. */
|
||||
|
||||
typedef struct AutoComplete AutoComplete;
|
||||
|
||||
AutoComplete *autocomplete_begin(char *startname, int maxlen);
|
||||
void autocomplete_do_name(AutoComplete *autocpl, const char *name);
|
||||
void autocomplete_end(AutoComplete *autocpl, char *autoname);
|
||||
|
||||
/* Panels
|
||||
*
|
||||
* Functions for creating, freeing and drawing panels. The API here
|
||||
* could use a good cleanup, though how they will function in 2.5 is
|
||||
* not clear yet so we postpone that. */
|
||||
|
||||
extern void uiFreePanels(struct ListBase *lb);
|
||||
extern void uiNewPanelTabbed(char *, char *);
|
||||
extern int uiNewPanel(const struct bContext *C, struct ARegion *ar, uiBlock *block, char *panelname, char *tabname, int ofsx, int ofsy, int sizex, int sizey);
|
||||
extern void uiFreePanels(struct ListBase *lb);
|
||||
extern void uiDrawPanels(const struct bContext *C, int re_align);
|
||||
|
||||
extern void uiSetPanelsView2d(struct ARegion *ar);
|
||||
@@ -394,25 +477,31 @@ extern int uiAlignPanelStep(struct ScrArea *sa, struct ARegion *ar, float fac);
|
||||
extern void uiPanelControl(int);
|
||||
extern void uiSetPanelHandler(int);
|
||||
|
||||
/* Autocomplete */
|
||||
|
||||
typedef struct AutoComplete AutoComplete;
|
||||
|
||||
AutoComplete *autocomplete_begin(char *startname, int maxlen);
|
||||
void autocomplete_do_name(AutoComplete *autocpl, const char *name);
|
||||
void autocomplete_end(AutoComplete *autocpl, char *autoname);
|
||||
|
||||
/* Handlers for regions with UI blocks */
|
||||
/* Handlers
|
||||
*
|
||||
* Handlers that can be registered in regions, areas and windows for
|
||||
* handling WM events. Mostly this is done automatic by modules such
|
||||
* as screen/ if ED_KEYMAP_UI is set, or internally in popup functions. */
|
||||
|
||||
void UI_add_region_handlers(struct ListBase *handlers);
|
||||
void UI_add_area_handlers(struct ListBase *handlers);
|
||||
void UI_add_popup_handlers(struct ListBase *handlers, uiMenuBlockHandle *menu);
|
||||
void UI_add_popup_handlers(struct ListBase *handlers, uiPopupBlockHandle *menu);
|
||||
|
||||
/* Module initialization and exit */
|
||||
/* Module
|
||||
*
|
||||
* init and exit should be called before using this module. init_userdef must
|
||||
* be used to reinitialize some internal state if user preferences change. */
|
||||
|
||||
void UI_init(void);
|
||||
void UI_init_userdef(void);
|
||||
void UI_exit(void);
|
||||
|
||||
/* XXX hide this */
|
||||
|
||||
uiBut *uiDefMenuButO(uiBlock *block, char *opname, char *name);
|
||||
uiBut *uiDefMenuSep(uiBlock *block);
|
||||
uiBut *uiDefMenuSub(uiBlock *block, uiBlockCreateFunc func, char *name);
|
||||
uiBut *uiDefMenuTogR(uiBlock *block, struct PointerRNA *ptr, char *propname, char *propvalue, char *name);
|
||||
|
||||
#endif /* UI_INTERFACE_H */
|
||||
|
||||
|
||||
@@ -32,14 +32,9 @@
|
||||
|
||||
struct BMF_Font;
|
||||
|
||||
int read_languagefile(void); /* usiblender.c */
|
||||
void free_languagemenu(void); /* usiblender.c */
|
||||
|
||||
void set_interface_font(char *str); /* headerbuttons.c */
|
||||
void start_interface_font(void); /* headerbuttons.c */
|
||||
void lang_setlanguage(void); /* usiblender.c */
|
||||
|
||||
char *language_pup(void);
|
||||
char *fontsize_pup(void);
|
||||
|
||||
int UI_DrawString(struct BMF_Font* font, char *str, int translate);
|
||||
@@ -53,15 +48,6 @@ void UI_RasterPos(float x, float y);
|
||||
void UI_SetScale(float aspect);
|
||||
void ui_text_init_userdef(void);
|
||||
|
||||
struct LANGMenuEntry {
|
||||
struct LANGMenuEntry *next;
|
||||
char *line;
|
||||
char *language;
|
||||
char *code;
|
||||
int id;
|
||||
};
|
||||
|
||||
struct LANGMenuEntry *find_language(short langid);
|
||||
|
||||
#endif /* UI_TEXT_H */
|
||||
|
||||
|
||||
@@ -49,6 +49,7 @@ CPPFLAGS += -I../../makesdna
|
||||
CPPFLAGS += -I../../makesrna
|
||||
CPPFLAGS += -I../../imbuf
|
||||
CPPFLAGS += -I../../ftfont
|
||||
CPPFLAGS += -I../../blenfont
|
||||
|
||||
# own include
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ Import ('env')
|
||||
|
||||
sources = env.Glob('*.c')
|
||||
|
||||
incs = '../include ../../blenlib ../../blenkernel ../../makesdna ../../imbuf'
|
||||
incs = '../include ../../blenlib ../../blenfont ../../blenkernel ../../makesdna ../../imbuf'
|
||||
incs += ' ../../makesrna ../../windowmanager #/intern/guardedalloc #intern/bmfont'
|
||||
incs += ' #/extern/glew/include'
|
||||
|
||||
|
||||
@@ -207,11 +207,27 @@ void ui_window_to_region(const ARegion *ar, int *x, int *y)
|
||||
|
||||
/* ******************* block calc ************************* */
|
||||
|
||||
/* only for pulldowns */
|
||||
void uiTextBoundsBlock(uiBlock *block, int addval)
|
||||
static void ui_block_translate(uiBlock *block, int x, int y)
|
||||
{
|
||||
uiBut *bt;
|
||||
int i = 0, j, x1addval= 0, nextcol;
|
||||
|
||||
for(bt= block->buttons.first; bt; bt=bt->next) {
|
||||
bt->x1 += x;
|
||||
bt->y1 += y;
|
||||
bt->x2 += x;
|
||||
bt->y2 += y;
|
||||
}
|
||||
|
||||
block->minx += x;
|
||||
block->miny += y;
|
||||
block->maxx += x;
|
||||
block->maxy += y;
|
||||
}
|
||||
|
||||
static void ui_text_bounds_block(uiBlock *block, float offset)
|
||||
{
|
||||
uiBut *bt;
|
||||
int i = 0, j, x1addval= offset, nextcol;
|
||||
|
||||
bt= block->buttons.first;
|
||||
while(bt) {
|
||||
@@ -233,25 +249,22 @@ void uiTextBoundsBlock(uiBlock *block, int addval)
|
||||
else nextcol= 0;
|
||||
|
||||
bt->x1 = x1addval;
|
||||
bt->x2 = bt->x1 + i + addval;
|
||||
bt->x2 = bt->x1 + i + block->bounds;
|
||||
|
||||
ui_check_but(bt); // clips text again
|
||||
|
||||
if(nextcol)
|
||||
x1addval+= i + addval;
|
||||
x1addval+= i + block->bounds;
|
||||
|
||||
bt= bt->next;
|
||||
}
|
||||
}
|
||||
|
||||
void uiBoundsBlock(uiBlock *block, int addval)
|
||||
void ui_bounds_block(uiBlock *block)
|
||||
{
|
||||
uiBut *bt;
|
||||
int xof;
|
||||
|
||||
if(block==NULL)
|
||||
return;
|
||||
|
||||
if(block->buttons.first==NULL) {
|
||||
if(block->panel) {
|
||||
block->minx= 0.0; block->maxx= block->panel->sizex;
|
||||
@@ -274,10 +287,10 @@ void uiBoundsBlock(uiBlock *block, int addval)
|
||||
bt= bt->next;
|
||||
}
|
||||
|
||||
block->minx -= addval;
|
||||
block->miny -= addval;
|
||||
block->maxx += addval;
|
||||
block->maxy += addval;
|
||||
block->minx -= block->bounds;
|
||||
block->miny -= block->bounds;
|
||||
block->maxx += block->bounds;
|
||||
block->maxy += block->bounds;
|
||||
}
|
||||
|
||||
/* hardcoded exception... but that one is annoying with larger safety */
|
||||
@@ -291,34 +304,80 @@ void uiBoundsBlock(uiBlock *block, int addval)
|
||||
block->safety.ymax= block->maxy+xof;
|
||||
}
|
||||
|
||||
void uiBlockTranslate(uiBlock *block, int x, int y)
|
||||
static void ui_popup_bounds_block(const bContext *C, uiBlock *block)
|
||||
{
|
||||
uiBut *bt;
|
||||
int startx, starty, endx, endy, width, height;
|
||||
int oldbounds, mx, my, xmax, ymax;
|
||||
|
||||
for(bt= block->buttons.first; bt; bt=bt->next) {
|
||||
bt->x1 += x;
|
||||
bt->y1 += y;
|
||||
bt->x2 += x;
|
||||
bt->y2 += y;
|
||||
oldbounds= block->bounds;
|
||||
|
||||
/* compute bounds */
|
||||
ui_bounds_block(block);
|
||||
mx= block->minx;
|
||||
my= block->miny;
|
||||
|
||||
wm_window_get_size(CTX_wm_window(C), &xmax, &ymax);
|
||||
|
||||
/* first we ensure wide enough text bounds */
|
||||
block->bounds= 50;
|
||||
ui_text_bounds_block(block, block->minx);
|
||||
|
||||
/* next we recompute bounds */
|
||||
block->bounds= oldbounds;
|
||||
ui_bounds_block(block);
|
||||
|
||||
/* and we adjust the position to fit within window */
|
||||
width= block->maxx - block->minx;
|
||||
height= block->maxy - block->miny;
|
||||
|
||||
startx= mx-(0.8*(width));
|
||||
starty= my;
|
||||
|
||||
if(startx<10)
|
||||
startx= 10;
|
||||
if(starty<10)
|
||||
starty= 10;
|
||||
|
||||
endx= startx+width;
|
||||
endy= starty+height;
|
||||
|
||||
if(endx>xmax) {
|
||||
endx= xmax-10;
|
||||
startx= endx-width;
|
||||
}
|
||||
if(endy>ymax-20) {
|
||||
endy= ymax-20;
|
||||
starty= endy-height;
|
||||
}
|
||||
|
||||
block->minx += x;
|
||||
block->miny += y;
|
||||
block->maxx += x;
|
||||
block->maxy += y;
|
||||
ui_block_translate(block, startx - block->minx, starty - block->miny);
|
||||
|
||||
/* now recompute bounds and safety */
|
||||
ui_bounds_block(block);
|
||||
}
|
||||
|
||||
void uiBlockOrigin(uiBlock *block)
|
||||
/* used for various cases */
|
||||
void uiBoundsBlock(uiBlock *block, int addval)
|
||||
{
|
||||
uiBut *bt;
|
||||
int minx= 10000, miny= 10000;
|
||||
if(block==NULL)
|
||||
return;
|
||||
|
||||
block->bounds= addval;
|
||||
block->dobounds= 1;
|
||||
}
|
||||
|
||||
for(bt= block->buttons.first; bt; bt=bt->next) {
|
||||
if(bt->x1 < minx) minx= bt->x1;
|
||||
if(bt->y1 < miny) miny= bt->y1;
|
||||
}
|
||||
/* used for pulldowns */
|
||||
void uiTextBoundsBlock(uiBlock *block, int addval)
|
||||
{
|
||||
block->bounds= addval;
|
||||
block->dobounds= 2;
|
||||
}
|
||||
|
||||
uiBlockTranslate(block, -minx, -miny);
|
||||
/* used for menu popups */
|
||||
void uiPopupBoundsBlock(uiBlock *block, int addval)
|
||||
{
|
||||
block->bounds= addval;
|
||||
block->dobounds= 3;
|
||||
}
|
||||
|
||||
void ui_autofill(uiBlock *block)
|
||||
@@ -433,8 +492,8 @@ static int ui_but_equals_old(uiBut *but, uiBut *oldbut)
|
||||
if(but->rnaprop != oldbut->rnaprop)
|
||||
if(but->rnaindex != oldbut->rnaindex) return 0;
|
||||
if(but->func != oldbut->func) return 0;
|
||||
if(but->func_arg1 != oldbut->func_arg1) return 0;
|
||||
if(but->func_arg2 != oldbut->func_arg2) return 0;
|
||||
if(oldbut->func_arg1 != oldbut && but->func_arg1 != oldbut->func_arg1) return 0;
|
||||
if(oldbut->func_arg2 != oldbut && but->func_arg2 != oldbut->func_arg2) return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -479,16 +538,21 @@ static int ui_but_update_from_old_block(const bContext *C, uiBlock *block, uiBut
|
||||
return found;
|
||||
}
|
||||
|
||||
static void ui_menu_block_set_keymaps(const bContext *C, uiBlock *block)
|
||||
void ui_menu_block_set_keymaps(const bContext *C, uiBlock *block)
|
||||
{
|
||||
uiBut *but;
|
||||
IDProperty *prop;
|
||||
char buf[512], *butstr;
|
||||
|
||||
/* XXX bounds? */
|
||||
/* only do it before bounding */
|
||||
if(block->minx != block->maxx)
|
||||
return;
|
||||
|
||||
for(but=block->buttons.first; but; but=but->next) {
|
||||
/* only hotkey for menus without properties */
|
||||
if(but->opname && but->opptr==NULL) {
|
||||
if(WM_key_event_operator_string(C, but->opname, but->opcontext, buf, sizeof(buf))) {
|
||||
if(but->opname) {
|
||||
prop= (but->opptr)? but->opptr->data: NULL;
|
||||
|
||||
if(WM_key_event_operator_string(C, but->opname, but->opcontext, prop, buf, sizeof(buf))) {
|
||||
butstr= MEM_mallocN(strlen(but->str)+strlen(buf)+2, "menu_block_set_keymaps");
|
||||
strcpy(butstr, but->str);
|
||||
strcat(butstr, "|");
|
||||
@@ -526,9 +590,17 @@ void uiEndBlock(const bContext *C, uiBlock *block)
|
||||
|
||||
/* handle pending stuff */
|
||||
if(block->flag & UI_BLOCK_LOOP) ui_menu_block_set_keymaps(C, block);
|
||||
|
||||
/* after keymaps! */
|
||||
if(block->dobounds == 1) ui_bounds_block(block);
|
||||
else if(block->dobounds == 2) ui_text_bounds_block(block, 0.0f);
|
||||
else if(block->dobounds == 3) ui_popup_bounds_block(C, block);
|
||||
|
||||
if(block->autofill) ui_autofill(block);
|
||||
if(block->minx==0.0 && block->maxx==0.0) uiBoundsBlock(block, 0);
|
||||
if(block->flag & UI_BUT_ALIGN) uiBlockEndAlign(block);
|
||||
|
||||
block->endblock= 1;
|
||||
}
|
||||
|
||||
/* ************** BLOCK DRAWING FUNCTION ************* */
|
||||
@@ -537,6 +609,9 @@ void uiDrawBlock(const bContext *C, uiBlock *block)
|
||||
{
|
||||
uiBut *but;
|
||||
|
||||
if(!block->endblock)
|
||||
uiEndBlock(C, block);
|
||||
|
||||
/* we set this only once */
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
@@ -1767,6 +1842,7 @@ static int ui_auto_themecol(uiBut *but)
|
||||
case TEX:
|
||||
return TH_BUT_TEXTFIELD;
|
||||
case PULLDOWN:
|
||||
case HMENU:
|
||||
case BLOCK:
|
||||
case MENU:
|
||||
case BUTM:
|
||||
@@ -2103,6 +2179,18 @@ uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, char *str, short x1,
|
||||
|
||||
freestr= 1;
|
||||
}
|
||||
else if(type == ROW && proptype == PROP_ENUM) {
|
||||
const EnumPropertyItem *item;
|
||||
int i, totitem;
|
||||
|
||||
RNA_property_enum_items(ptr, prop, &item, &totitem);
|
||||
for(i=0; i<totitem; i++)
|
||||
if(item[i].value == (int)max)
|
||||
str= (char*)item[i].name;
|
||||
|
||||
if(!str)
|
||||
str= (char*)RNA_property_ui_name(ptr, prop);
|
||||
}
|
||||
else
|
||||
str= (char*)RNA_property_ui_name(ptr, prop);
|
||||
}
|
||||
@@ -2564,7 +2652,7 @@ uiBut *uiDefMenuSep(uiBlock *block)
|
||||
return uiDefBut(block, SEPR, 0, "", 0, y, MENU_WIDTH, MENU_SEP_HEIGHT, NULL, 0.0, 0.0, 0, 0, "");
|
||||
}
|
||||
|
||||
uiBut *uiDefMenuSub(uiBlock *block, uiBlockFuncFP func, char *name)
|
||||
uiBut *uiDefMenuSub(uiBlock *block, uiBlockCreateFunc func, char *name)
|
||||
{
|
||||
int y= ui_menu_y(block) - MENU_ITEM_HEIGHT;
|
||||
return uiDefIconTextBlockBut(block, func, NULL, ICON_RIGHTARROW_THIN, name, 0, y, MENU_WIDTH, MENU_ITEM_HEIGHT-1, "");
|
||||
@@ -2798,24 +2886,48 @@ uiBut *uiDefIDPoinBut(uiBlock *block, uiIDPoinFuncFP func, short blocktype, int
|
||||
return but;
|
||||
}
|
||||
|
||||
uiBut *uiDefBlockBut(uiBlock *block, uiBlockFuncFP func, void *arg, char *str, short x1, short y1, short x2, short y2, char *tip)
|
||||
uiBut *uiDefBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg, char *str, short x1, short y1, short x2, short y2, char *tip)
|
||||
{
|
||||
uiBut *but= ui_def_but(block, BLOCK, 0, str, x1, y1, x2, y2, arg, 0.0, 0.0, 0.0, 0.0, tip);
|
||||
but->block_func= func;
|
||||
but->block_create_func= func;
|
||||
ui_check_but(but);
|
||||
return but;
|
||||
}
|
||||
|
||||
uiBut *uiDefPulldownBut(uiBlock *block, uiBlockFuncFP func, void *arg, char *str, short x1, short y1, short x2, short y2, char *tip)
|
||||
uiBut *uiDefPulldownBut(uiBlock *block, uiBlockCreateFunc func, void *arg, char *str, short x1, short y1, short x2, short y2, char *tip)
|
||||
{
|
||||
uiBut *but= ui_def_but(block, PULLDOWN, 0, str, x1, y1, x2, y2, arg, 0.0, 0.0, 0.0, 0.0, tip);
|
||||
but->block_func= func;
|
||||
but->block_create_func= func;
|
||||
ui_check_but(but);
|
||||
return but;
|
||||
}
|
||||
|
||||
uiBut *uiDefMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, char *str, short x1, short y1, short x2, short y2, char *tip)
|
||||
{
|
||||
uiBut *but= ui_def_but(block, HMENU, 0, str, x1, y1, x2, y2, arg, 0.0, 0.0, 0.0, 0.0, tip);
|
||||
but->menu_create_func= func;
|
||||
ui_check_but(but);
|
||||
return but;
|
||||
}
|
||||
|
||||
uiBut *uiDefIconTextMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, int icon, char *str, short x1, short y1, short x2, short y2, char *tip)
|
||||
{
|
||||
uiBut *but= ui_def_but(block, HMENU, 0, str, x1, y1, x2, y2, arg, 0.0, 0.0, 0.0, 0.0, tip);
|
||||
|
||||
but->icon= (BIFIconID) icon;
|
||||
but->flag|= UI_HAS_ICON;
|
||||
|
||||
but->flag|= UI_ICON_LEFT;
|
||||
but->flag|= UI_ICON_RIGHT;
|
||||
|
||||
but->menu_create_func= func;
|
||||
ui_check_but(but);
|
||||
|
||||
return but;
|
||||
}
|
||||
|
||||
/* Block button containing both string label and icon */
|
||||
uiBut *uiDefIconTextBlockBut(uiBlock *block, uiBlockFuncFP func, void *arg, int icon, char *str, short x1, short y1, short x2, short y2, char *tip)
|
||||
uiBut *uiDefIconTextBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg, int icon, char *str, short x1, short y1, short x2, short y2, char *tip)
|
||||
{
|
||||
uiBut *but= ui_def_but(block, BLOCK, 0, str, x1, y1, x2, y2, arg, 0.0, 0.0, 0.0, 0.0, tip);
|
||||
|
||||
@@ -2825,14 +2937,14 @@ uiBut *uiDefIconTextBlockBut(uiBlock *block, uiBlockFuncFP func, void *arg, int
|
||||
but->flag|= UI_ICON_LEFT;
|
||||
but->flag|= UI_ICON_RIGHT;
|
||||
|
||||
but->block_func= func;
|
||||
but->block_create_func= func;
|
||||
ui_check_but(but);
|
||||
|
||||
return but;
|
||||
}
|
||||
|
||||
/* Block button containing icon */
|
||||
uiBut *uiDefIconBlockBut(uiBlock *block, uiBlockFuncFP func, void *arg, int retval, int icon, short x1, short y1, short x2, short y2, char *tip)
|
||||
uiBut *uiDefIconBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg, int retval, int icon, short x1, short y1, short x2, short y2, char *tip)
|
||||
{
|
||||
uiBut *but= ui_def_but(block, BLOCK, retval, "", x1, y1, x2, y2, arg, 0.0, 0.0, 0.0, 0.0, tip);
|
||||
|
||||
@@ -2842,7 +2954,7 @@ uiBut *uiDefIconBlockBut(uiBlock *block, uiBlockFuncFP func, void *arg, int retv
|
||||
but->flag|= UI_ICON_LEFT;
|
||||
but->flag|= UI_ICON_RIGHT;
|
||||
|
||||
but->block_func= func;
|
||||
but->block_create_func= func;
|
||||
ui_check_but(but);
|
||||
|
||||
return but;
|
||||
|
||||
@@ -3214,7 +3214,8 @@ void ui_set_embossfunc(uiBut *but, int drawtype)
|
||||
|
||||
// standard builtin first:
|
||||
if(but->type==LABEL || but->type==ROUNDBOX) but->embossfunc= ui_draw_nothing;
|
||||
else if(but->type==PULLDOWN) but->embossfunc= ui_draw_pulldown_round;
|
||||
else if(ELEM(but->type, PULLDOWN, HMENU) && !(but->block->flag & UI_BLOCK_LOOP))
|
||||
but->embossfunc= ui_draw_pulldown_round;
|
||||
else if(drawtype==UI_EMBOSSM) but->embossfunc= ui_draw_minimal;
|
||||
else if(drawtype==UI_EMBOSSN) but->embossfunc= ui_draw_nothing;
|
||||
else if(drawtype==UI_EMBOSSP) but->embossfunc= ui_draw_pulldown_item;
|
||||
|
||||
@@ -122,7 +122,7 @@ typedef struct uiHandleButtonData {
|
||||
CBData *dragcbd;
|
||||
|
||||
/* menu open */
|
||||
uiMenuBlockHandle *menu;
|
||||
uiPopupBlockHandle *menu;
|
||||
int menuretval;
|
||||
|
||||
/* post activate */
|
||||
@@ -157,6 +157,51 @@ static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState s
|
||||
static int ui_handler_region_menu(bContext *C, wmEvent *event, void *userdata);
|
||||
static int ui_handler_popup(bContext *C, wmEvent *event, void *userdata);
|
||||
static void ui_handler_remove_popup(bContext *C, void *userdata);
|
||||
static void ui_handle_button_activate(bContext *C, ARegion *ar, uiBut *but, uiButtonActivateType type);
|
||||
|
||||
/* ******************** menu navigation helpers ************** */
|
||||
|
||||
static uiBut *ui_but_prev(uiBut *but)
|
||||
{
|
||||
while(but->prev) {
|
||||
but= but->prev;
|
||||
if(but->type!=LABEL && but->type!=SEPR && but->type!=ROUNDBOX) return but;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static uiBut *ui_but_next(uiBut *but)
|
||||
{
|
||||
while(but->next) {
|
||||
but= but->next;
|
||||
if(but->type!=LABEL && but->type!=SEPR && but->type!=ROUNDBOX) return but;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static uiBut *ui_but_first(uiBlock *block)
|
||||
{
|
||||
uiBut *but;
|
||||
|
||||
but= block->buttons.first;
|
||||
while(but) {
|
||||
if(but->type!=LABEL && but->type!=SEPR && but->type!=ROUNDBOX) return but;
|
||||
but= but->next;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static uiBut *ui_but_last(uiBlock *block)
|
||||
{
|
||||
uiBut *but;
|
||||
|
||||
but= block->buttons.last;
|
||||
while(but) {
|
||||
if(but->type!=LABEL && but->type!=SEPR && but->type!=ROUNDBOX) return but;
|
||||
but= but->prev;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* ********************** button apply/revert ************************/
|
||||
|
||||
@@ -553,6 +598,7 @@ static void ui_apply_button(bContext *C, uiBlock *block, uiBut *but, uiHandleBut
|
||||
case ICONTEXTROW:
|
||||
case BLOCK:
|
||||
case PULLDOWN:
|
||||
case HMENU:
|
||||
case COL:
|
||||
ui_apply_but_BLOCK(C, but, data);
|
||||
break;
|
||||
@@ -1384,13 +1430,19 @@ static void ui_numedit_apply(bContext *C, uiBlock *block, uiBut *but, uiHandleBu
|
||||
|
||||
static void ui_blockopen_begin(bContext *C, uiBut *but, uiHandleButtonData *data)
|
||||
{
|
||||
uiBlockFuncFP func= NULL;
|
||||
uiBlockCreateFunc func= NULL;
|
||||
uiBlockHandleCreateFunc handlefunc= NULL;
|
||||
uiMenuCreateFunc menufunc= NULL;
|
||||
void *arg= NULL;
|
||||
|
||||
switch(but->type) {
|
||||
case BLOCK:
|
||||
case PULLDOWN:
|
||||
func= but->block_func;
|
||||
func= but->block_create_func;
|
||||
arg= but->poin;
|
||||
break;
|
||||
case HMENU:
|
||||
menufunc= but->menu_create_func;
|
||||
arg= but->poin;
|
||||
break;
|
||||
case MENU:
|
||||
@@ -1398,15 +1450,15 @@ static void ui_blockopen_begin(bContext *C, uiBut *but, uiHandleButtonData *data
|
||||
data->value= data->origvalue;
|
||||
but->editval= &data->value;
|
||||
|
||||
func= ui_block_func_MENU;
|
||||
handlefunc= ui_block_func_MENU;
|
||||
arg= but;
|
||||
break;
|
||||
case ICONROW:
|
||||
func= ui_block_func_ICONROW;
|
||||
handlefunc= ui_block_func_ICONROW;
|
||||
arg= but;
|
||||
break;
|
||||
case ICONTEXTROW:
|
||||
func= ui_block_func_ICONTEXTROW;
|
||||
handlefunc= ui_block_func_ICONTEXTROW;
|
||||
arg= but;
|
||||
break;
|
||||
case COL:
|
||||
@@ -1414,13 +1466,18 @@ static void ui_blockopen_begin(bContext *C, uiBut *but, uiHandleButtonData *data
|
||||
VECCOPY(data->vec, data->origvec);
|
||||
but->editvec= data->vec;
|
||||
|
||||
func= ui_block_func_COL;
|
||||
handlefunc= ui_block_func_COL;
|
||||
arg= but;
|
||||
break;
|
||||
}
|
||||
|
||||
if(func) {
|
||||
data->menu= ui_menu_block_create(C, data->region, but, func, arg);
|
||||
if(func || handlefunc) {
|
||||
data->menu= ui_popup_block_create(C, data->region, but, func, handlefunc, arg);
|
||||
if(but->block->handle)
|
||||
data->menu->popup= but->block->handle->popup;
|
||||
}
|
||||
else if(menufunc) {
|
||||
data->menu= ui_popup_menu_create(C, data->region, but, menufunc, arg);
|
||||
if(but->block->handle)
|
||||
data->menu->popup= but->block->handle->popup;
|
||||
}
|
||||
@@ -1439,7 +1496,7 @@ static void ui_blockopen_end(bContext *C, uiBut *but, uiHandleButtonData *data)
|
||||
}
|
||||
|
||||
if(data->menu) {
|
||||
ui_menu_block_free(C, data->menu);
|
||||
ui_popup_block_free(C, data->menu);
|
||||
data->menu= NULL;
|
||||
}
|
||||
}
|
||||
@@ -2613,6 +2670,7 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, wmEvent *event)
|
||||
break;
|
||||
case BLOCK:
|
||||
case PULLDOWN:
|
||||
case HMENU:
|
||||
retval= ui_do_but_BLOCK(C, but, data, event);
|
||||
break;
|
||||
case BUTM:
|
||||
@@ -2790,7 +2848,7 @@ static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState s
|
||||
button_tooltip_timer_reset(but);
|
||||
|
||||
/* automatic open pulldown block timer */
|
||||
if(but->type==BLOCK || but->type==MENU || but->type==PULLDOWN || but->type==ICONTEXTROW) {
|
||||
if(ELEM5(but->type, BLOCK, MENU, PULLDOWN, HMENU, ICONTEXTROW)) {
|
||||
if(!data->autoopentimer) {
|
||||
int time;
|
||||
|
||||
@@ -2892,8 +2950,23 @@ static void button_activate_init(bContext *C, ARegion *ar, uiBut *but, uiButtonA
|
||||
|
||||
button_activate_state(C, but, BUTTON_STATE_HIGHLIGHT);
|
||||
|
||||
if(type == BUTTON_ACTIVATE_OPEN)
|
||||
if(type == BUTTON_ACTIVATE_OPEN) {
|
||||
button_activate_state(C, but, BUTTON_STATE_MENU_OPEN);
|
||||
|
||||
/* activate first button in submenu */
|
||||
if(data->menu && data->menu->region) {
|
||||
ARegion *subar= data->menu->region;
|
||||
uiBlock *subblock= subar->uiblocks.first;
|
||||
uiBut *subbut;
|
||||
|
||||
if(subblock) {
|
||||
subbut= ui_but_first(subblock);
|
||||
|
||||
if(subbut)
|
||||
ui_handle_button_activate(C, subar, subbut, BUTTON_ACTIVATE);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(type == BUTTON_ACTIVATE_TEXT_EDITING)
|
||||
button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING);
|
||||
else if(type == BUTTON_ACTIVATE_APPLY)
|
||||
@@ -2915,7 +2988,7 @@ static void button_activate_exit(bContext *C, uiHandleButtonData *data, uiBut *b
|
||||
* value to the button value and the menu return value to ok, the
|
||||
* menu return value will be picked up and the menu will close */
|
||||
if(block->handle && !(block->flag & UI_BLOCK_KEEP_OPEN) && !data->cancel) {
|
||||
uiMenuBlockHandle *menu;
|
||||
uiPopupBlockHandle *menu;
|
||||
|
||||
menu= block->handle;
|
||||
menu->butretval= data->retval;
|
||||
@@ -3124,7 +3197,7 @@ static int ui_handle_button_event(bContext *C, wmEvent *event, uiBut *but)
|
||||
static void ui_handle_button_closed_submenu(bContext *C, wmEvent *event, uiBut *but)
|
||||
{
|
||||
uiHandleButtonData *data;
|
||||
uiMenuBlockHandle *menu;
|
||||
uiPopupBlockHandle *menu;
|
||||
|
||||
data= but->active;
|
||||
menu= data->menu;
|
||||
@@ -3155,50 +3228,6 @@ static void ui_handle_button_closed_submenu(bContext *C, wmEvent *event, uiBut *
|
||||
}
|
||||
}
|
||||
|
||||
/* ******************** menu navigation helpers ************** */
|
||||
|
||||
static uiBut *ui_but_prev(uiBut *but)
|
||||
{
|
||||
while(but->prev) {
|
||||
but= but->prev;
|
||||
if(but->type!=LABEL && but->type!=SEPR && but->type!=ROUNDBOX) return but;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static uiBut *ui_but_next(uiBut *but)
|
||||
{
|
||||
while(but->next) {
|
||||
but= but->next;
|
||||
if(but->type!=LABEL && but->type!=SEPR && but->type!=ROUNDBOX) return but;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static uiBut *ui_but_first(uiBlock *block)
|
||||
{
|
||||
uiBut *but;
|
||||
|
||||
but= block->buttons.first;
|
||||
while(but) {
|
||||
if(but->type!=LABEL && but->type!=SEPR && but->type!=ROUNDBOX) return but;
|
||||
but= but->next;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static uiBut *ui_but_last(uiBlock *block)
|
||||
{
|
||||
uiBut *but;
|
||||
|
||||
but= block->buttons.last;
|
||||
while(but) {
|
||||
if(but->type!=LABEL && but->type!=SEPR && but->type!=ROUNDBOX) return but;
|
||||
but= but->prev;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* ************************* menu handling *******************************/
|
||||
|
||||
/* function used to prevent loosing the open menu when using nested pulldowns,
|
||||
@@ -3210,7 +3239,7 @@ static uiBut *ui_but_last(uiBlock *block)
|
||||
* - only for 1 second
|
||||
*/
|
||||
|
||||
static void ui_mouse_motion_towards_init(uiMenuBlockHandle *menu, int mx, int my)
|
||||
static void ui_mouse_motion_towards_init(uiPopupBlockHandle *menu, int mx, int my)
|
||||
{
|
||||
if(!menu->dotowards) {
|
||||
menu->dotowards= 1;
|
||||
@@ -3220,7 +3249,7 @@ static void ui_mouse_motion_towards_init(uiMenuBlockHandle *menu, int mx, int my
|
||||
}
|
||||
}
|
||||
|
||||
static int ui_mouse_motion_towards_check(uiBlock *block, uiMenuBlockHandle *menu, int mx, int my)
|
||||
static int ui_mouse_motion_towards_check(uiBlock *block, uiPopupBlockHandle *menu, int mx, int my)
|
||||
{
|
||||
int fac, dx, dy, domx, domy;
|
||||
|
||||
@@ -3274,7 +3303,7 @@ static int ui_mouse_motion_towards_check(uiBlock *block, uiMenuBlockHandle *menu
|
||||
return menu->dotowards;
|
||||
}
|
||||
|
||||
int ui_handle_menu_event(bContext *C, wmEvent *event, uiMenuBlockHandle *menu, int topmenu)
|
||||
int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle *menu, int topmenu)
|
||||
{
|
||||
ARegion *ar;
|
||||
uiBlock *block;
|
||||
@@ -3474,9 +3503,11 @@ int ui_handle_menu_event(bContext *C, wmEvent *event, uiMenuBlockHandle *menu, i
|
||||
}
|
||||
}
|
||||
|
||||
/* if we are inside the region and didn't handle the event yet, lets
|
||||
* pass it on to buttons inside this region */
|
||||
if((inside && !menu->menuretval && retval == WM_UI_HANDLER_CONTINUE) || event->type == TIMER) {
|
||||
/* if we are didn't handle the event yet, lets pass it on to
|
||||
* buttons inside this region. disabled inside check .. not sure
|
||||
* anymore why it was there? but i meant enter enter didn't work
|
||||
* for example when mouse was not over submenu */
|
||||
if((/*inside &&*/ !menu->menuretval && retval == WM_UI_HANDLER_CONTINUE) || event->type == TIMER) {
|
||||
but= ui_but_find_activated(ar);
|
||||
|
||||
if(but)
|
||||
@@ -3496,13 +3527,13 @@ int ui_handle_menu_event(bContext *C, wmEvent *event, uiMenuBlockHandle *menu, i
|
||||
return retval;
|
||||
}
|
||||
|
||||
static int ui_handle_menu_closed_submenu(bContext *C, wmEvent *event, uiMenuBlockHandle *menu)
|
||||
static int ui_handle_menu_closed_submenu(bContext *C, wmEvent *event, uiPopupBlockHandle *menu)
|
||||
{
|
||||
ARegion *ar;
|
||||
uiBut *but;
|
||||
uiBlock *block;
|
||||
uiHandleButtonData *data;
|
||||
uiMenuBlockHandle *submenu;
|
||||
uiPopupBlockHandle *submenu;
|
||||
|
||||
ar= menu->region;
|
||||
block= ar->uiblocks.first;
|
||||
@@ -3532,11 +3563,11 @@ static int ui_handle_menu_closed_submenu(bContext *C, wmEvent *event, uiMenuBloc
|
||||
return WM_UI_HANDLER_BREAK;
|
||||
}
|
||||
|
||||
static int ui_handle_menus_recursive(bContext *C, wmEvent *event, uiMenuBlockHandle *menu)
|
||||
static int ui_handle_menus_recursive(bContext *C, wmEvent *event, uiPopupBlockHandle *menu)
|
||||
{
|
||||
uiBut *but;
|
||||
uiHandleButtonData *data;
|
||||
uiMenuBlockHandle *submenu;
|
||||
uiPopupBlockHandle *submenu;
|
||||
int retval= WM_UI_HANDLER_CONTINUE;
|
||||
|
||||
/* check if we have a submenu, and handle events for it first */
|
||||
@@ -3665,16 +3696,16 @@ static int ui_handler_region_menu(bContext *C, wmEvent *event, void *userdata)
|
||||
/* two types of popups, one with operator + enum, other with regular callbacks */
|
||||
static int ui_handler_popup(bContext *C, wmEvent *event, void *userdata)
|
||||
{
|
||||
uiMenuBlockHandle *menu= userdata;
|
||||
uiPopupBlockHandle *menu= userdata;
|
||||
|
||||
ui_handle_menus_recursive(C, event, menu);
|
||||
|
||||
/* free if done, does not free handle itself */
|
||||
if(menu->menuretval) {
|
||||
/* copy values, we have to free first (closes region) */
|
||||
uiMenuBlockHandle temp= *menu;
|
||||
uiPopupBlockHandle temp= *menu;
|
||||
|
||||
ui_menu_block_free(C, menu);
|
||||
ui_popup_block_free(C, menu);
|
||||
WM_event_remove_ui_handler(&CTX_wm_window(C)->handlers, ui_handler_popup, ui_handler_remove_popup, menu);
|
||||
|
||||
if(temp.menuretval == UI_RETURN_OK) {
|
||||
@@ -3707,10 +3738,10 @@ static int ui_handler_popup(bContext *C, wmEvent *event, void *userdata)
|
||||
|
||||
static void ui_handler_remove_popup(bContext *C, void *userdata)
|
||||
{
|
||||
uiMenuBlockHandle *menu= userdata;
|
||||
uiPopupBlockHandle *menu= userdata;
|
||||
|
||||
/* free menu block if window is closed for some reason */
|
||||
ui_menu_block_free(C, menu);
|
||||
ui_popup_block_free(C, menu);
|
||||
|
||||
/* delayed apply callbacks */
|
||||
ui_apply_but_funcs_after(C);
|
||||
@@ -3722,7 +3753,7 @@ void UI_add_region_handlers(ListBase *handlers)
|
||||
WM_event_add_ui_handler(NULL, handlers, ui_handler_region, ui_handler_remove_region, NULL);
|
||||
}
|
||||
|
||||
void UI_add_popup_handlers(ListBase *handlers, uiMenuBlockHandle *menu)
|
||||
void UI_add_popup_handlers(ListBase *handlers, uiPopupBlockHandle *menu)
|
||||
{
|
||||
WM_event_add_ui_handler(NULL, handlers, ui_handler_popup, ui_handler_remove_popup, menu);
|
||||
}
|
||||
|
||||
@@ -121,14 +121,14 @@ struct uiBut {
|
||||
float a1, a2, hsv[3]; // hsv is temp memory for hsv buttons
|
||||
float aspect;
|
||||
|
||||
void (*func)(struct bContext*, void *, void *);
|
||||
uiButHandleFunc func;
|
||||
void *func_arg1;
|
||||
void *func_arg2;
|
||||
|
||||
void (*embossfunc)(int , int , float, float, float, float, float, int);
|
||||
void (*sliderfunc)(int , float, float, float, float, float, float, int);
|
||||
|
||||
void (*autocomplete_func)(struct bContext*, char *, void *);
|
||||
uiButCompleteFunc autocomplete_func;
|
||||
void *autofunc_arg;
|
||||
|
||||
uiLink *link;
|
||||
@@ -143,19 +143,22 @@ struct uiBut {
|
||||
short lock, win;
|
||||
short iconadd, dt;
|
||||
|
||||
/* IDPOIN data */
|
||||
/* IDPOIN data */
|
||||
uiIDPoinFuncFP idpoin_func;
|
||||
ID **idpoin_idpp;
|
||||
|
||||
/* BLOCK data */
|
||||
uiBlockFuncFP block_func;
|
||||
/* BLOCK data */
|
||||
uiBlockCreateFunc block_create_func;
|
||||
|
||||
/* RNA */
|
||||
/* HMENU data */
|
||||
uiMenuCreateFunc menu_create_func;
|
||||
|
||||
/* RNA data */
|
||||
struct PointerRNA rnapoin;
|
||||
struct PropertyRNA *rnaprop;
|
||||
int rnaindex;
|
||||
|
||||
/* Operator */
|
||||
/* Operator data */
|
||||
const char *opname;
|
||||
int opcontext;
|
||||
struct IDProperty *opproperties;
|
||||
@@ -188,14 +191,14 @@ struct uiBlock {
|
||||
float minx, miny, maxx, maxy;
|
||||
float aspect;
|
||||
|
||||
void (*func)(struct bContext*, void *arg1, void *arg2);
|
||||
uiButHandleFunc func;
|
||||
void *func_arg1;
|
||||
void *func_arg2;
|
||||
|
||||
void (*butm_func)(struct bContext*, void *arg, int but_a2);
|
||||
uiMenuHandleFunc butm_func;
|
||||
void *butm_func_arg;
|
||||
|
||||
void (*handle_func)(struct bContext*, void *arg, int event);
|
||||
uiBlockHandleFunc handle_func;
|
||||
void *handle_func_arg;
|
||||
|
||||
/* extra draw function for custom blocks */
|
||||
@@ -214,12 +217,14 @@ struct uiBlock {
|
||||
int lock;
|
||||
char *lockstr;
|
||||
|
||||
float xofs, yofs; // offset to parent button
|
||||
float xofs, yofs; // offset to parent button
|
||||
int bounds, dobounds; // for doing delayed
|
||||
int endblock; // uiEndBlock done?
|
||||
|
||||
rctf safety; // pulldowns, to detect outside, can differ per case how it is created
|
||||
ListBase saferct; // uiSafetyRct list
|
||||
|
||||
uiMenuBlockHandle *handle; // handle
|
||||
uiPopupBlockHandle *handle; // handle
|
||||
int tooltipdisabled; // to avoid tooltip after click
|
||||
|
||||
int handler; // for panels in other windows than buttonswin... just event code
|
||||
@@ -258,18 +263,46 @@ extern void ui_autofill(uiBlock *block);
|
||||
extern int ui_is_but_float(uiBut *but);
|
||||
extern void ui_update_block_buts_hsv(uiBlock *block, float *hsv);
|
||||
|
||||
extern void ui_bounds_block(uiBlock *block);
|
||||
|
||||
/* interface_regions.c */
|
||||
uiBlock *ui_block_func_MENU(struct bContext *C, uiMenuBlockHandle *handle, void *arg_but);
|
||||
uiBlock *ui_block_func_ICONROW(struct bContext *C, uiMenuBlockHandle *handle, void *arg_but);
|
||||
uiBlock *ui_block_func_ICONTEXTROW(struct bContext *C, uiMenuBlockHandle *handle, void *arg_but);
|
||||
uiBlock *ui_block_func_COL(struct bContext *C, uiMenuBlockHandle *handle, void *arg_but);
|
||||
|
||||
struct uiPopupBlockHandle {
|
||||
/* internal */
|
||||
struct ARegion *region;
|
||||
int towardsx, towardsy;
|
||||
double towardstime;
|
||||
int dotowards;
|
||||
|
||||
int popup;
|
||||
void (*popup_func)(struct bContext *C, void *arg, int event);
|
||||
void *popup_arg;
|
||||
/* for operator menus */
|
||||
struct wmOperator *op_arg;
|
||||
const char *propname;
|
||||
|
||||
/* return values */
|
||||
int butretval;
|
||||
int menuretval;
|
||||
float retvalue;
|
||||
float retvec[3];
|
||||
};
|
||||
|
||||
uiBlock *ui_block_func_MENU(struct bContext *C, uiPopupBlockHandle *handle, void *arg_but);
|
||||
uiBlock *ui_block_func_ICONROW(struct bContext *C, uiPopupBlockHandle *handle, void *arg_but);
|
||||
uiBlock *ui_block_func_ICONTEXTROW(struct bContext *C, uiPopupBlockHandle *handle, void *arg_but);
|
||||
uiBlock *ui_block_func_COL(struct bContext *C, uiPopupBlockHandle *handle, void *arg_but);
|
||||
|
||||
struct ARegion *ui_tooltip_create(struct bContext *C, struct ARegion *butregion, uiBut *but);
|
||||
void ui_tooltip_free(struct bContext *C, struct ARegion *ar);
|
||||
|
||||
uiMenuBlockHandle *ui_menu_block_create(struct bContext *C, struct ARegion *butregion, uiBut *but,
|
||||
uiBlockFuncFP block_func, void *arg);
|
||||
void ui_menu_block_free(struct bContext *C, uiMenuBlockHandle *handle);
|
||||
typedef uiBlock* (*uiBlockHandleCreateFunc)(struct bContext *C, struct uiPopupBlockHandle *handle, void *arg1);
|
||||
|
||||
uiPopupBlockHandle *ui_popup_block_create(struct bContext *C, struct ARegion *butregion, uiBut *but,
|
||||
uiBlockCreateFunc create_func, uiBlockHandleCreateFunc handle_create_func, void *arg);
|
||||
uiPopupBlockHandle *ui_popup_menu_create(struct bContext *C, struct ARegion *butregion, uiBut *but,
|
||||
uiMenuCreateFunc create_func, void *arg);
|
||||
void ui_popup_block_free(struct bContext *C, uiPopupBlockHandle *handle);
|
||||
|
||||
void ui_set_name_menu(uiBut *but, int value);
|
||||
|
||||
|
||||
@@ -266,7 +266,7 @@ static void ui_scale_panel_block(uiBlock *block)
|
||||
|
||||
if(block->autofill) ui_autofill(block);
|
||||
/* buttons min/max centered, offset calculated */
|
||||
uiBoundsBlock(block, 0);
|
||||
ui_bounds_block(block);
|
||||
|
||||
if( block->maxx-block->minx > block->panel->sizex - 2*PNL_SAFETY ) {
|
||||
facx= (block->panel->sizex - (2*PNL_SAFETY))/( block->maxx-block->minx );
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -43,6 +43,7 @@
|
||||
|
||||
#include "BIF_gl.h"
|
||||
#include "UI_text.h"
|
||||
#include "BLF_api.h"
|
||||
|
||||
#include "ED_datafiles.h"
|
||||
|
||||
@@ -77,11 +78,7 @@ void string_to_utf8(char *original, char *utf_8, char *code)
|
||||
|
||||
#ifdef INTERNATIONAL
|
||||
#include "FTF_Api.h"
|
||||
|
||||
static struct LANGMenuEntry *langmenu= 0;
|
||||
static int tot_lang = 0;
|
||||
|
||||
#endif // INTERNATIONAL
|
||||
#endif
|
||||
|
||||
void UI_RasterPos(float x, float y)
|
||||
{
|
||||
@@ -118,14 +115,13 @@ int UI_DrawString(BMF_Font* font, char *str, int translate)
|
||||
#ifdef WITH_ICONV
|
||||
if(translate & CONVERT_TO_UTF8) {
|
||||
char utf_8[512];
|
||||
char *code;
|
||||
|
||||
struct LANGMenuEntry *lme;
|
||||
lme = find_language(U.language);
|
||||
|
||||
if (lme !=NULL) {
|
||||
if (!strcmp(lme->code, "ja_JP"))
|
||||
code= BLF_lang_find_code(U.language);
|
||||
if (lme) {
|
||||
if (!strcmp(code, "ja_JP"))
|
||||
string_to_utf8(str, utf_8, "Shift_JIS"); /* Japanese */
|
||||
else if (!strcmp(lme->code, "zh_CN"))
|
||||
else if (!strcmp(code, "zh_CN"))
|
||||
string_to_utf8(str, utf_8, "GB2312"); /* Chinese */
|
||||
}
|
||||
|
||||
@@ -204,50 +200,6 @@ char *fontsize_pup(void)
|
||||
return (string);
|
||||
}
|
||||
|
||||
|
||||
char *language_pup(void)
|
||||
{
|
||||
struct LANGMenuEntry *lme = langmenu;
|
||||
static char string[1024];
|
||||
static char tmp[1024];
|
||||
|
||||
if(tot_lang == 0)
|
||||
sprintf(string, "Choose Language: %%t|Language: English %%x0");
|
||||
else {
|
||||
sprintf(string, "Choose Language: %%t");
|
||||
while(lme) {
|
||||
sprintf(tmp, "|Language: %s %%x%d", lme->language, lme->id);
|
||||
strcat(string, tmp);
|
||||
lme= lme->next;
|
||||
}
|
||||
}
|
||||
|
||||
return string;
|
||||
}
|
||||
|
||||
struct LANGMenuEntry *find_language(short langid)
|
||||
{
|
||||
struct LANGMenuEntry *lme = langmenu;
|
||||
|
||||
while(lme) {
|
||||
if(lme->id == langid)
|
||||
return lme;
|
||||
|
||||
lme=lme->next;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
void lang_setlanguage(void)
|
||||
{
|
||||
struct LANGMenuEntry *lme;
|
||||
|
||||
lme = find_language(U.language);
|
||||
if(lme) FTF_SetLanguage(lme->code);
|
||||
else FTF_SetLanguage("en_US");
|
||||
}
|
||||
|
||||
/* called from fileselector */
|
||||
void set_interface_font(char *str)
|
||||
{
|
||||
@@ -255,7 +207,7 @@ void set_interface_font(char *str)
|
||||
/* this test needed because fileselect callback can happen after disable AA fonts */
|
||||
if(U.transopts & USER_DOTRANSLATE) {
|
||||
if(FTF_SetFont((unsigned char*)str, 0, U.fontsize)) {
|
||||
lang_setlanguage();
|
||||
BLF_lang_set(U.language);
|
||||
|
||||
if(strlen(str) < FILE_MAXDIR) strcpy(U.fontname, str);
|
||||
G.ui_international = TRUE;
|
||||
@@ -297,8 +249,7 @@ void start_interface_font(void)
|
||||
}
|
||||
|
||||
if(result) {
|
||||
lang_setlanguage();
|
||||
|
||||
BLF_lang_set(U.language);
|
||||
G.ui_international = TRUE;
|
||||
}
|
||||
else {
|
||||
@@ -311,132 +262,5 @@ void start_interface_font(void)
|
||||
/* XXX 2.50 bad call allqueue(REDRAWALL, 0); */
|
||||
}
|
||||
|
||||
static char *first_dpointchar(char *string)
|
||||
{
|
||||
char *dpointchar;
|
||||
|
||||
dpointchar= strchr(string, ':');
|
||||
|
||||
return dpointchar;
|
||||
}
|
||||
|
||||
|
||||
static void splitlangline(char *line, struct LANGMenuEntry *lme)
|
||||
{
|
||||
char *dpointchar= first_dpointchar(line);
|
||||
|
||||
if (dpointchar) {
|
||||
lme->code= BLI_strdup(dpointchar+1);
|
||||
*(dpointchar)=0;
|
||||
lme->language= BLI_strdup(line);
|
||||
} else {
|
||||
/* XXX 2.50 bad call error("Invalid language file"); */
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void puplang_insert_entry(char *line)
|
||||
{
|
||||
struct LANGMenuEntry *lme, *prev;
|
||||
int sorted = 0;
|
||||
|
||||
prev= NULL;
|
||||
lme= langmenu;
|
||||
|
||||
for (; lme; prev= lme, lme= lme->next) {
|
||||
if (lme->line) {
|
||||
if (BLI_streq(line, lme->line)) {
|
||||
return;
|
||||
} else if (sorted && strcmp(line, lme->line)<0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lme= MEM_mallocN(sizeof(*lme), "lme");
|
||||
lme->line = BLI_strdup(line);
|
||||
splitlangline(line, lme);
|
||||
lme->id = tot_lang;
|
||||
tot_lang++;
|
||||
|
||||
if (prev) {
|
||||
lme->next= prev->next;
|
||||
prev->next= lme;
|
||||
} else {
|
||||
lme->next= langmenu;
|
||||
langmenu= lme;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int read_languagefile(void)
|
||||
{
|
||||
char name[FILE_MAXDIR+FILE_MAXFILE];
|
||||
LinkNode *l, *lines;
|
||||
|
||||
/* .Blanguages, http://www.blender3d.org/cms/Installation_Policy.352.0.html*/
|
||||
#if defined (__APPLE__) || (WIN32)
|
||||
BLI_make_file_string("/", name, BLI_gethome(), ".Blanguages");
|
||||
#else
|
||||
BLI_make_file_string("/", name, BLI_gethome(), ".blender/.Blanguages");
|
||||
#endif
|
||||
|
||||
lines= BLI_read_file_as_lines(name);
|
||||
|
||||
if(lines == NULL) {
|
||||
/* If not found in home, try current dir
|
||||
* (Resources folder of app bundle on OS X) */
|
||||
#if defined (__APPLE__)
|
||||
char *bundlePath = BLI_getbundle();
|
||||
strcpy(name, bundlePath);
|
||||
strcat(name, "/Contents/Resources/.Blanguages");
|
||||
#else
|
||||
/* Check the CWD. Takes care of the case where users
|
||||
* unpack blender tarball; cd blender-dir; ./blender */
|
||||
strcpy(name, ".blender/.Blanguages");
|
||||
#endif
|
||||
lines= BLI_read_file_as_lines(name);
|
||||
|
||||
if(lines == NULL) {
|
||||
/* If not found in .blender, try current dir */
|
||||
strcpy(name, ".Blanguages");
|
||||
lines= BLI_read_file_as_lines(name);
|
||||
if(lines == NULL) {
|
||||
if(G.f & G_DEBUG) printf("File .Blanguages not found\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (l= lines; l; l= l->next) {
|
||||
char *line= l->link;
|
||||
|
||||
if (!BLI_streq(line, "")) {
|
||||
puplang_insert_entry(line);
|
||||
}
|
||||
}
|
||||
|
||||
BLI_free_file_lines(lines);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
void free_languagemenu(void)
|
||||
{
|
||||
struct LANGMenuEntry *lme= langmenu;
|
||||
|
||||
while (lme) {
|
||||
struct LANGMenuEntry *n= lme->next;
|
||||
|
||||
if (lme->line) MEM_freeN(lme->line);
|
||||
if (lme->language) MEM_freeN(lme->language);
|
||||
if (lme->code) MEM_freeN(lme->code);
|
||||
MEM_freeN(lme);
|
||||
|
||||
lme= n;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* INTERNATIONAL */
|
||||
|
||||
|
||||
@@ -57,6 +57,91 @@
|
||||
#include "interface_intern.h"
|
||||
|
||||
/* *********************************************************************** */
|
||||
|
||||
/* helper to allow scrollbars to dynamically hide */
|
||||
static int view2d_scroll_mapped(int scroll)
|
||||
{
|
||||
if(scroll & V2D_SCROLL_HORIZONTAL_HIDE)
|
||||
scroll &= ~(V2D_SCROLL_HORIZONTAL);
|
||||
if(scroll & V2D_SCROLL_VERTICAL_HIDE)
|
||||
scroll &= ~(V2D_SCROLL_VERTICAL);
|
||||
return scroll;
|
||||
}
|
||||
|
||||
/* called each time cur changes, to dynamically update masks */
|
||||
static void view2_masks(View2D *v2d)
|
||||
{
|
||||
int scroll;
|
||||
|
||||
/* mask - view frame */
|
||||
v2d->mask.xmin= v2d->mask.ymin= 0;
|
||||
v2d->mask.xmax= v2d->winx - 1; /* -1 yes! masks are pixels */
|
||||
v2d->mask.ymax= v2d->winy - 1;
|
||||
|
||||
#if 0
|
||||
v2d->scroll &= ~(V2D_SCROLL_HORIZONTAL_HIDE|V2D_SCROLL_VERTICAL_HIDE);
|
||||
/* check size if: */
|
||||
if (v2d->scroll & V2D_SCROLL_HORIZONTAL)
|
||||
if(!(v2d->scroll & V2D_SCROLL_SCALE_HORIZONTAL))
|
||||
if (v2d->tot.xmax-v2d->tot.xmin <= v2d->cur.xmax-v2d->cur.xmin)
|
||||
v2d->scroll |= V2D_SCROLL_HORIZONTAL_HIDE;
|
||||
if (v2d->scroll & V2D_SCROLL_VERTICAL)
|
||||
if(!(v2d->scroll & V2D_SCROLL_SCALE_VERTICAL))
|
||||
if (v2d->tot.ymax-v2d->tot.ymin <= v2d->cur.ymax-v2d->cur.ymin)
|
||||
v2d->scroll |= V2D_SCROLL_VERTICAL_HIDE;
|
||||
#endif
|
||||
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)
|
||||
*/
|
||||
if (scroll) {
|
||||
/* vertical scroller */
|
||||
if (scroll & V2D_SCROLL_LEFT) {
|
||||
/* on left-hand edge of region */
|
||||
v2d->vert= v2d->mask;
|
||||
v2d->vert.xmax= V2D_SCROLL_WIDTH;
|
||||
v2d->mask.xmin= v2d->vert.xmax + 1;
|
||||
}
|
||||
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.xmin= v2d->vert.xmax - V2D_SCROLL_WIDTH;
|
||||
v2d->mask.xmax= v2d->vert.xmin - 1;
|
||||
}
|
||||
|
||||
/* horizontal scroller */
|
||||
if (scroll & (V2D_SCROLL_BOTTOM|V2D_SCROLL_BOTTOM_O)) {
|
||||
/* on bottom edge of region (V2D_SCROLL_BOTTOM_O is outliner, the other is for standard) */
|
||||
v2d->hor= v2d->mask;
|
||||
v2d->hor.ymax= V2D_SCROLL_HEIGHT;
|
||||
v2d->mask.ymin= v2d->hor.ymax + 1;
|
||||
}
|
||||
else if (scroll & V2D_SCROLL_TOP) {
|
||||
/* on upper edge of region */
|
||||
v2d->hor= v2d->mask;
|
||||
v2d->hor.ymin= v2d->hor.ymax - V2D_SCROLL_HEIGHT;
|
||||
v2d->mask.ymax= v2d->hor.ymin - 1;
|
||||
}
|
||||
|
||||
/* adjust vertical scroller if there's a horizontal scroller, to leave corner free */
|
||||
if (scroll & V2D_SCROLL_VERTICAL) {
|
||||
/* just set y min/max for vertical scroller to y min/max of mask as appropriate */
|
||||
if (scroll & (V2D_SCROLL_BOTTOM|V2D_SCROLL_BOTTOM_O)) {
|
||||
/* on bottom edge of region (V2D_SCROLL_BOTTOM_O is outliner, the other is for standard) */
|
||||
v2d->vert.ymin= v2d->mask.ymin;
|
||||
}
|
||||
else if (scroll & V2D_SCROLL_TOP) {
|
||||
/* on upper edge of region */
|
||||
v2d->vert.ymax= v2d->mask.ymax;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* Refresh and Validation */
|
||||
|
||||
/* Initialise all relevant View2D data (including view rects if first time) and/or refresh mask sizes after view resize
|
||||
@@ -153,69 +238,19 @@ void UI_view2d_region_reinit(View2D *v2d, short type, int winx, int winy)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* store view size */
|
||||
v2d->winx= winx;
|
||||
v2d->winy= winy;
|
||||
|
||||
/* mask - view frame */
|
||||
v2d->mask.xmin= v2d->mask.ymin= 0;
|
||||
v2d->mask.xmax= winx - 1; /* -1 yes! masks are pixels */
|
||||
v2d->mask.ymax= winy - 1;
|
||||
|
||||
/* 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)
|
||||
*/
|
||||
if (v2d->scroll) {
|
||||
/* vertical scroller */
|
||||
if (v2d->scroll & V2D_SCROLL_LEFT) {
|
||||
/* on left-hand edge of region */
|
||||
v2d->vert= v2d->mask;
|
||||
v2d->vert.xmax= V2D_SCROLL_WIDTH;
|
||||
v2d->mask.xmin= v2d->vert.xmax + 1;
|
||||
}
|
||||
else if (v2d->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.xmin= v2d->vert.xmax - V2D_SCROLL_WIDTH;
|
||||
v2d->mask.xmax= v2d->vert.xmin - 1;
|
||||
}
|
||||
|
||||
/* horizontal scroller */
|
||||
if (v2d->scroll & (V2D_SCROLL_BOTTOM|V2D_SCROLL_BOTTOM_O)) {
|
||||
/* on bottom edge of region (V2D_SCROLL_BOTTOM_O is outliner, the other is for standard) */
|
||||
v2d->hor= v2d->mask;
|
||||
v2d->hor.ymax= V2D_SCROLL_HEIGHT;
|
||||
v2d->mask.ymin= v2d->hor.ymax + 1;
|
||||
}
|
||||
else if (v2d->scroll & V2D_SCROLL_TOP) {
|
||||
/* on upper edge of region */
|
||||
v2d->hor= v2d->mask;
|
||||
v2d->hor.ymin= v2d->hor.ymax - V2D_SCROLL_HEIGHT;
|
||||
v2d->mask.ymax= v2d->hor.ymin - 1;
|
||||
}
|
||||
|
||||
/* adjust vertical scroller if there's a horizontal scroller, to leave corner free */
|
||||
if (v2d->scroll & V2D_SCROLL_VERTICAL) {
|
||||
/* just set y min/max for vertical scroller to y min/max of mask as appropriate */
|
||||
if (v2d->scroll & (V2D_SCROLL_BOTTOM|V2D_SCROLL_BOTTOM_O)) {
|
||||
/* on bottom edge of region (V2D_SCROLL_BOTTOM_O is outliner, the other is for standard) */
|
||||
v2d->vert.ymin= v2d->mask.ymin;
|
||||
}
|
||||
else if (v2d->scroll & V2D_SCROLL_TOP) {
|
||||
/* on upper edge of region */
|
||||
v2d->vert.ymax= v2d->mask.ymax;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* set masks */
|
||||
view2_masks(v2d);
|
||||
|
||||
/* set 'tot' rect before setting cur? */
|
||||
if (tot_changed)
|
||||
UI_view2d_totRect_set(v2d, winx, winy);
|
||||
else
|
||||
UI_view2d_curRect_validate(v2d);
|
||||
|
||||
}
|
||||
|
||||
/* Ensure View2D rects remain in a viable configuration
|
||||
@@ -549,6 +584,9 @@ void UI_view2d_curRect_validate(View2D *v2d)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* set masks */
|
||||
view2_masks(v2d);
|
||||
}
|
||||
|
||||
/* ------------------ */
|
||||
@@ -731,7 +769,7 @@ static void view2d_map_cur_using_mask(View2D *v2d, rctf *curmasked)
|
||||
{
|
||||
*curmasked= v2d->cur;
|
||||
|
||||
if ((v2d->scroll)) {
|
||||
if (view2d_scroll_mapped(v2d->scroll)) {
|
||||
float dx= (v2d->cur.xmax-v2d->cur.xmin)/((float)(v2d->mask.xmax-v2d->mask.xmin+1));
|
||||
float dy= (v2d->cur.ymax-v2d->cur.ymin)/((float)(v2d->mask.ymax-v2d->mask.ymin+1));
|
||||
|
||||
@@ -1116,6 +1154,7 @@ View2DScrollers *UI_view2d_scrollers_calc(const bContext *C, View2D *v2d, short
|
||||
View2DScrollers *scrollers;
|
||||
rcti vert, hor;
|
||||
float fac, totsize, scrollsize;
|
||||
int scroll= view2d_scroll_mapped(v2d->scroll);
|
||||
|
||||
vert= v2d->vert;
|
||||
hor= v2d->hor;
|
||||
@@ -1129,7 +1168,7 @@ View2DScrollers *UI_view2d_scrollers_calc(const bContext *C, View2D *v2d, short
|
||||
*/
|
||||
|
||||
/* horizontal scrollers */
|
||||
if (v2d->scroll & V2D_SCROLL_HORIZONTAL) {
|
||||
if (scroll & V2D_SCROLL_HORIZONTAL) {
|
||||
/* scroller 'button' extents */
|
||||
totsize= v2d->tot.xmax - v2d->tot.xmin;
|
||||
scrollsize= (float)(hor.xmax - hor.xmin);
|
||||
@@ -1145,7 +1184,7 @@ View2DScrollers *UI_view2d_scrollers_calc(const bContext *C, View2D *v2d, short
|
||||
}
|
||||
|
||||
/* vertical scrollers */
|
||||
if (v2d->scroll & V2D_SCROLL_VERTICAL) {
|
||||
if (scroll & V2D_SCROLL_VERTICAL) {
|
||||
/* scroller 'button' extents */
|
||||
totsize= v2d->tot.ymax - v2d->tot.ymin;
|
||||
scrollsize= (float)(vert.ymax - vert.ymin);
|
||||
@@ -1161,7 +1200,7 @@ View2DScrollers *UI_view2d_scrollers_calc(const bContext *C, View2D *v2d, short
|
||||
}
|
||||
|
||||
/* grid markings on scrollbars */
|
||||
if (v2d->scroll & (V2D_SCROLL_SCALE_HORIZONTAL|V2D_SCROLL_SCALE_VERTICAL)) {
|
||||
if (scroll & (V2D_SCROLL_SCALE_HORIZONTAL|V2D_SCROLL_SCALE_VERTICAL)) {
|
||||
/* store clamping */
|
||||
scrollers->xclamp= xclamp;
|
||||
scrollers->xunits= xunits;
|
||||
@@ -1292,13 +1331,14 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
const short darker= -50, dark= -10, light= 20, lighter= 50;
|
||||
rcti vert, hor, corner;
|
||||
int scroll= view2d_scroll_mapped(v2d->scroll);
|
||||
|
||||
/* make copies of rects for less typing */
|
||||
vert= v2d->vert;
|
||||
hor= v2d->hor;
|
||||
|
||||
/* horizontal scrollbar */
|
||||
if (v2d->scroll & V2D_SCROLL_HORIZONTAL) {
|
||||
if (scroll & V2D_SCROLL_HORIZONTAL) {
|
||||
/* scroller backdrop */
|
||||
UI_ThemeColorShade(TH_SHADE1, light);
|
||||
glRecti(hor.xmin, hor.ymin, hor.xmax, hor.ymax);
|
||||
@@ -1306,8 +1346,10 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
|
||||
/* scroller 'button'
|
||||
* - if view is zoomable in x, draw handles too
|
||||
* - handles are drawn darker
|
||||
* - no slider when view is > total
|
||||
*/
|
||||
if (v2d->keepzoom & V2D_LOCKZOOM_X) {
|
||||
if (v2d->tot.xmax-v2d->tot.xmin <= v2d->cur.xmax-v2d->cur.xmin);
|
||||
else if (v2d->keepzoom & V2D_LOCKZOOM_X) {
|
||||
/* draw base bar as rounded shape */
|
||||
UI_ThemeColorShade(TH_SHADE1, dark);
|
||||
uiSetRoundBox(15);
|
||||
@@ -1362,7 +1404,7 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
|
||||
|
||||
/* scale indicators */
|
||||
// XXX will need to update the font drawing when the new stuff comes in
|
||||
if ((v2d->scroll & V2D_SCROLL_SCALE_HORIZONTAL) && (vs->grid)) {
|
||||
if ((scroll & V2D_SCROLL_SCALE_HORIZONTAL) && (vs->grid)) {
|
||||
View2DGrid *grid= vs->grid;
|
||||
float fac, dfac, fac2, val;
|
||||
|
||||
@@ -1426,14 +1468,14 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
|
||||
|
||||
/* decoration outer bevel line */
|
||||
UI_ThemeColorShade(TH_SHADE1, lighter);
|
||||
if (v2d->scroll & (V2D_SCROLL_BOTTOM|V2D_SCROLL_BOTTOM_O))
|
||||
if (scroll & (V2D_SCROLL_BOTTOM|V2D_SCROLL_BOTTOM_O))
|
||||
sdrawline(hor.xmin, hor.ymax, hor.xmax, hor.ymax);
|
||||
else if (v2d->scroll & V2D_SCROLL_TOP)
|
||||
else if (scroll & V2D_SCROLL_TOP)
|
||||
sdrawline(hor.xmin, hor.ymin, hor.xmax, hor.ymin);
|
||||
}
|
||||
|
||||
/* vertical scrollbar */
|
||||
if (v2d->scroll & V2D_SCROLL_VERTICAL) {
|
||||
if (scroll & V2D_SCROLL_VERTICAL) {
|
||||
/* scroller backdrop */
|
||||
UI_ThemeColorShade(TH_SHADE1, light);
|
||||
glRecti(vert.xmin, vert.ymin, vert.xmax, vert.ymax);
|
||||
@@ -1442,7 +1484,8 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
|
||||
* - if view is zoomable in y, draw handles too
|
||||
* - handles are drawn darker
|
||||
*/
|
||||
if (v2d->keepzoom & V2D_LOCKZOOM_Y) {
|
||||
if (v2d->tot.ymax-v2d->tot.ymin <= v2d->cur.ymax-v2d->cur.ymin);
|
||||
else if (v2d->keepzoom & V2D_LOCKZOOM_Y) {
|
||||
/* draw base bar as rounded shape */
|
||||
UI_ThemeColorShade(TH_SHADE1, dark);
|
||||
uiSetRoundBox(15);
|
||||
@@ -1497,7 +1540,7 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
|
||||
|
||||
/* scale indiators */
|
||||
// XXX will need to update the font drawing when the new stuff comes in
|
||||
if ((v2d->scroll & V2D_SCROLL_SCALE_VERTICAL) && (vs->grid)) {
|
||||
if ((scroll & V2D_SCROLL_SCALE_VERTICAL) && (vs->grid)) {
|
||||
View2DGrid *grid= vs->grid;
|
||||
float fac, dfac, val;
|
||||
|
||||
@@ -1532,14 +1575,14 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
|
||||
|
||||
/* decoration outer bevel line */
|
||||
UI_ThemeColorShade(TH_SHADE1, lighter);
|
||||
if (v2d->scroll & V2D_SCROLL_RIGHT)
|
||||
if (scroll & V2D_SCROLL_RIGHT)
|
||||
sdrawline(vert.xmin, vert.ymin, vert.xmin, vert.ymax);
|
||||
else if (v2d->scroll & V2D_SCROLL_LEFT)
|
||||
else if (scroll & V2D_SCROLL_LEFT)
|
||||
sdrawline(vert.xmax, vert.ymin, vert.xmax, vert.ymax);
|
||||
}
|
||||
|
||||
/* draw a 'sunken square' to cover up any overlapping corners resulting from intersection of overflowing scroller data */
|
||||
if ((v2d->scroll & V2D_SCROLL_VERTICAL) && (v2d->scroll & V2D_SCROLL_HORIZONTAL)) {
|
||||
if ((scroll & V2D_SCROLL_VERTICAL) && (scroll & V2D_SCROLL_HORIZONTAL)) {
|
||||
/* set bounds (these should be right) */
|
||||
corner.xmin= vert.xmin;
|
||||
corner.xmax= vert.xmax;
|
||||
@@ -1811,16 +1854,17 @@ short UI_view2d_mouse_in_scrollers (const bContext *C, View2D *v2d, int x, int y
|
||||
{
|
||||
ARegion *ar= CTX_wm_region(C);
|
||||
int co[2];
|
||||
int scroll= view2d_scroll_mapped(v2d->scroll);
|
||||
|
||||
/* clamp x,y to region-coordinates first */
|
||||
co[0]= x - ar->winrct.xmin;
|
||||
co[1]= y - ar->winrct.ymin;
|
||||
|
||||
/* check if within scrollbars */
|
||||
if (v2d->scroll & V2D_SCROLL_HORIZONTAL) {
|
||||
if (scroll & V2D_SCROLL_HORIZONTAL) {
|
||||
if (IN_2D_HORIZ_SCROLL(v2d, co)) return 'h';
|
||||
}
|
||||
if (v2d->scroll & V2D_SCROLL_VERTICAL) {
|
||||
if (scroll & V2D_SCROLL_VERTICAL) {
|
||||
if (IN_2D_VERT_SCROLL(v2d, co)) return 'v';
|
||||
}
|
||||
|
||||
|
||||
@@ -77,9 +77,17 @@
|
||||
#include "BIF_retopo.h"
|
||||
|
||||
#include "ED_mesh.h"
|
||||
#include "ED_object.h"
|
||||
#include "ED_util.h"
|
||||
#include "ED_screen.h"
|
||||
#include "ED_view3d.h"
|
||||
|
||||
#include "RNA_access.h"
|
||||
#include "RNA_define.h"
|
||||
|
||||
#include "WM_api.h"
|
||||
#include "WM_types.h"
|
||||
|
||||
/* own include */
|
||||
#include "mesh_intern.h"
|
||||
|
||||
@@ -92,11 +100,7 @@ editmesh.c:
|
||||
|
||||
/* XXX */
|
||||
static void BIF_undo_push() {}
|
||||
static void waitcursor() {}
|
||||
static void error() {}
|
||||
static int pupmenu() {return 0;}
|
||||
static void key_to_mesh() {}
|
||||
static void adduplicate() {}
|
||||
|
||||
|
||||
/* ***************** HASH ********************* */
|
||||
@@ -583,6 +587,7 @@ static void editMesh_set_hash(EditMesh *em)
|
||||
{
|
||||
EditEdge *eed;
|
||||
|
||||
if(em->hashedgetab) MEM_freeN(em->hashedgetab);
|
||||
em->hashedgetab= NULL;
|
||||
|
||||
for(eed=em->edges.first; eed; eed= eed->next) {
|
||||
@@ -851,8 +856,6 @@ void make_editMesh(Scene *scene, Object *ob)
|
||||
|
||||
actkey = ob_get_keyblock(ob);
|
||||
if(actkey) {
|
||||
// XXX strcpy(G.editModeTitleExtra, "(Key) ");
|
||||
key_to_mesh(actkey, me);
|
||||
tot= actkey->totelem;
|
||||
/* undo-ing in past for previous editmode sessions gives corrupt 'keyindex' values */
|
||||
undo_editmode_clear();
|
||||
@@ -1424,371 +1427,203 @@ void load_editMesh(Scene *scene, Object *ob)
|
||||
void remake_editMesh(Scene *scene, Object *ob)
|
||||
{
|
||||
make_editMesh(scene, ob);
|
||||
// allqueue(REDRAWVIEW3D, 0);
|
||||
// allqueue(REDRAWBUTSOBJECT, 0); /* needed to have nice cloth panels */
|
||||
DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
|
||||
BIF_undo_push("Undo all changes");
|
||||
}
|
||||
|
||||
/* *************** (partial exit editmode) *************/
|
||||
/* *************** Operator: separate parts *************/
|
||||
|
||||
static EnumPropertyItem prop_separate_types[] = {
|
||||
{0, "SELECTED", "Selection", ""},
|
||||
{1, "MATERIAL", "By Material", ""},
|
||||
{2, "LOOSE", "By loose parts", ""},
|
||||
{0, NULL, NULL, NULL}
|
||||
};
|
||||
|
||||
|
||||
|
||||
void separate_mesh(Scene *scene, Object *obedit)
|
||||
/* return 1: success */
|
||||
static int mesh_separate_selected(Scene *scene, Base *editbase)
|
||||
{
|
||||
EditMesh *em, emcopy;
|
||||
EditMesh *em, *emnew;
|
||||
EditVert *eve, *v1;
|
||||
EditEdge *eed, *e1;
|
||||
EditFace *efa, *vl1;
|
||||
Object *oldob;
|
||||
Mesh *me, *men;
|
||||
Base *base, *oldbase;
|
||||
ListBase edve, eded, edvl;
|
||||
EditFace *efa, *f1;
|
||||
Object *obedit;
|
||||
Mesh *me, *menew;
|
||||
Base *basenew;
|
||||
|
||||
if(obedit==NULL) return;
|
||||
|
||||
waitcursor(1);
|
||||
if(editbase==NULL) return 0;
|
||||
|
||||
obedit= editbase->object;
|
||||
me= obedit->data;
|
||||
em= me->edit_mesh;
|
||||
if(me->key) {
|
||||
error("Can't separate with vertex keys");
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(em->selected.first) BLI_freelistN(&(em->selected)); /* clear the selection order */
|
||||
if(em->selected.first)
|
||||
BLI_freelistN(&(em->selected)); /* clear the selection order */
|
||||
|
||||
EM_selectmode_set(em); // enforce full consistant selection flags
|
||||
|
||||
/* we are going to abuse the system as follows:
|
||||
* 1. add a duplicate object: this will be the new one, we remember old pointer
|
||||
* 2: then do a split if needed.
|
||||
* 3. put apart: all NOT selected verts, edges, faces
|
||||
* 4. call load_editMesh(): this will be the new object
|
||||
* 5. freelist and get back old verts, edges, facs
|
||||
EM_stats_update(em);
|
||||
|
||||
if(em->totvertsel==0) return 0;
|
||||
|
||||
/* we are going to work as follows:
|
||||
* 1. add a linked duplicate object: this will be the new one, we remember old pointer
|
||||
* 2. give new object empty mesh and put in editmode
|
||||
* 3: do a split if needed on current editmesh.
|
||||
* 4. copy over: all NOT selected verts, edges, faces
|
||||
* 5. call load_editMesh() on the new object
|
||||
*/
|
||||
|
||||
/* make only obedit selected */
|
||||
base= FIRSTBASE;
|
||||
while(base) {
|
||||
// XXX if(base->lay & G.vd->lay) {
|
||||
if(base->object==obedit) base->flag |= SELECT;
|
||||
else base->flag &= ~SELECT;
|
||||
// }
|
||||
base= base->next;
|
||||
}
|
||||
/* 1 */
|
||||
basenew= ED_object_add_duplicate(scene, editbase, 0); /* 0 = fully linked */
|
||||
ED_base_object_select(basenew, BA_DESELECT);
|
||||
|
||||
/* no test for split, split doesn't split when a loose part is selected */
|
||||
/* 2 */
|
||||
basenew->object->data= menew= add_mesh(me->id.name); /* empty */
|
||||
me->id.us--;
|
||||
make_editMesh(scene, basenew->object);
|
||||
emnew= menew->edit_mesh;
|
||||
|
||||
/* 3 */
|
||||
/* SPLIT: first make duplicate */
|
||||
adduplicateflag(em, SELECT);
|
||||
|
||||
/* SPLIT: old faces have 3x flag 128 set, delete these ones */
|
||||
delfaceflag(em, 128);
|
||||
|
||||
/* since we do tricky things with verts/edges/faces, this makes sure all is selected coherent */
|
||||
EM_selectmode_set(em);
|
||||
|
||||
/* set apart: everything that is not selected */
|
||||
edve.first= edve.last= eded.first= eded.last= edvl.first= edvl.last= 0;
|
||||
eve= em->verts.first;
|
||||
while(eve) {
|
||||
/* 4 */
|
||||
/* move over: everything that is selected */
|
||||
for(eve= em->verts.first; eve; eve= v1) {
|
||||
v1= eve->next;
|
||||
if((eve->f & SELECT)==0) {
|
||||
if(eve->f & SELECT) {
|
||||
BLI_remlink(&em->verts, eve);
|
||||
BLI_addtail(&edve, eve);
|
||||
BLI_addtail(&emnew->verts, eve);
|
||||
}
|
||||
|
||||
eve= v1;
|
||||
}
|
||||
eed= em->edges.first;
|
||||
while(eed) {
|
||||
|
||||
for(eed= em->edges.first; eed; eed= e1) {
|
||||
e1= eed->next;
|
||||
if((eed->f & SELECT)==0) {
|
||||
if(eed->f & SELECT) {
|
||||
BLI_remlink(&em->edges, eed);
|
||||
BLI_addtail(&eded, eed);
|
||||
BLI_addtail(&emnew->edges, eed);
|
||||
}
|
||||
eed= e1;
|
||||
}
|
||||
efa= em->faces.first;
|
||||
while(efa) {
|
||||
vl1= efa->next;
|
||||
|
||||
for(efa= em->faces.first; efa; efa= f1) {
|
||||
f1= efa->next;
|
||||
if (efa == em->act_face && (efa->f & SELECT)) {
|
||||
EM_set_actFace(em, NULL);
|
||||
}
|
||||
|
||||
if((efa->f & SELECT)==0) {
|
||||
if(efa->f & SELECT) {
|
||||
BLI_remlink(&em->faces, efa);
|
||||
BLI_addtail(&edvl, efa);
|
||||
BLI_addtail(&emnew->faces, efa);
|
||||
}
|
||||
efa= vl1;
|
||||
}
|
||||
|
||||
/* 5 */
|
||||
load_editMesh(scene, basenew->object);
|
||||
free_editMesh(emnew);
|
||||
|
||||
oldob= obedit;
|
||||
oldbase= BASACT;
|
||||
|
||||
adduplicate(1, 0); /* notrans and a linked duplicate */
|
||||
|
||||
obedit= BASACT->object; /* basact was set in adduplicate() */
|
||||
|
||||
men= copy_mesh(me);
|
||||
set_mesh(obedit, men);
|
||||
/* because new mesh is a copy: reduce user count */
|
||||
men->id.us--;
|
||||
|
||||
load_editMesh(scene, obedit);
|
||||
|
||||
BASACT->flag &= ~SELECT;
|
||||
|
||||
/* we cannot free the original buffer... */
|
||||
emcopy= *em;
|
||||
emcopy.allverts= NULL;
|
||||
emcopy.alledges= NULL;
|
||||
emcopy.allfaces= NULL;
|
||||
emcopy.derivedFinal= emcopy.derivedCage= NULL;
|
||||
memset(&emcopy.vdata, 0, sizeof(emcopy.vdata));
|
||||
memset(&emcopy.fdata, 0, sizeof(emcopy.fdata));
|
||||
free_editMesh(&emcopy);
|
||||
|
||||
em->verts= edve;
|
||||
em->edges= eded;
|
||||
em->faces= edvl;
|
||||
|
||||
/* hashedges are freed now, make new! */
|
||||
/* hashedges are invalid now, make new! */
|
||||
editMesh_set_hash(em);
|
||||
|
||||
DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
|
||||
obedit= oldob;
|
||||
BASACT= oldbase;
|
||||
BASACT->flag |= SELECT;
|
||||
|
||||
waitcursor(0);
|
||||
|
||||
// allqueue(REDRAWVIEW3D, 0);
|
||||
DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
|
||||
DAG_object_flush_update(scene, basenew->object, OB_RECALC_DATA);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void separate_material(Scene *scene, Object *obedit)
|
||||
/* return 1: success */
|
||||
static int mesh_separate_material(Scene *scene, Base *editbase)
|
||||
{
|
||||
Mesh *me= editbase->object->data;
|
||||
EditMesh *em= me->edit_mesh;
|
||||
unsigned char curr_mat;
|
||||
|
||||
for (curr_mat = 1; curr_mat < editbase->object->totcol; ++curr_mat) {
|
||||
/* clear selection, we're going to use that to select material group */
|
||||
EM_clear_flag_all(em, SELECT);
|
||||
/* select the material */
|
||||
editmesh_select_by_material(em, curr_mat);
|
||||
/* and now separate */
|
||||
if(0==mesh_separate_selected(scene, editbase))
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* return 1: success */
|
||||
static int mesh_separate_loose(Scene *scene, Base *editbase)
|
||||
{
|
||||
Mesh *me;
|
||||
EditMesh *em;
|
||||
unsigned char curr_mat;
|
||||
int doit= 1;
|
||||
|
||||
me= obedit->data;
|
||||
me= editbase->object->data;
|
||||
em= me->edit_mesh;
|
||||
|
||||
if(me->key) {
|
||||
error("Can't separate with vertex keys");
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(obedit && em) {
|
||||
if(obedit->type == OB_MESH) {
|
||||
for (curr_mat = 1; curr_mat < obedit->totcol; ++curr_mat) {
|
||||
/* clear selection, we're going to use that to select material group */
|
||||
EM_clear_flag_all(em, SELECT);
|
||||
/* select the material */
|
||||
editmesh_select_by_material(em, curr_mat);
|
||||
/* and now separate */
|
||||
separate_mesh(scene, obedit);
|
||||
}
|
||||
}
|
||||
}
|
||||
EM_clear_flag_all(em, SELECT);
|
||||
|
||||
// allqueue(REDRAWVIEW3D, 0);
|
||||
DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void separate_mesh_loose(Scene *scene, Object *obedit)
|
||||
{
|
||||
EditMesh *em, emcopy;
|
||||
EditVert *eve, *v1;
|
||||
EditEdge *eed, *e1;
|
||||
EditFace *efa, *vl1;
|
||||
Object *oldob=NULL;
|
||||
Mesh *me, *men;
|
||||
Base *base, *oldbase;
|
||||
ListBase edve, eded, edvl;
|
||||
int vertsep=0;
|
||||
short done=0, check=1;
|
||||
|
||||
me= obedit->data;
|
||||
em= me->edit_mesh;
|
||||
if(me->key) {
|
||||
error("Can't separate a mesh with vertex keys");
|
||||
return;
|
||||
}
|
||||
|
||||
waitcursor(1);
|
||||
|
||||
/* we are going to abuse the system as follows:
|
||||
* 1. add a duplicate object: this will be the new one, we remember old pointer
|
||||
* 2: then do a split if needed.
|
||||
* 3. put apart: all NOT selected verts, edges, faces
|
||||
* 4. call load_editMesh(): this will be the new object
|
||||
* 5. freelist and get back old verts, edges, facs
|
||||
*/
|
||||
|
||||
while(!done){
|
||||
vertsep=check=1;
|
||||
|
||||
/* make only obedit selected */
|
||||
base= FIRSTBASE;
|
||||
while(base) {
|
||||
// XXX if(base->lay & G.vd->lay) {
|
||||
if(base->object==obedit) base->flag |= SELECT;
|
||||
else base->flag &= ~SELECT;
|
||||
// }
|
||||
base= base->next;
|
||||
}
|
||||
|
||||
/*--------- Select connected-----------*/
|
||||
|
||||
EM_clear_flag_all(em, SELECT);
|
||||
|
||||
while(doit && em->verts.first) {
|
||||
/* Select a random vert to start with */
|
||||
eve= em->verts.first;
|
||||
EditVert *eve= em->verts.first;
|
||||
eve->f |= SELECT;
|
||||
|
||||
while(check==1) {
|
||||
check= 0;
|
||||
eed= em->edges.first;
|
||||
while(eed) {
|
||||
if(eed->h==0) {
|
||||
if(eed->v1->f & SELECT) {
|
||||
if( (eed->v2->f & SELECT)==0 ) {
|
||||
eed->v2->f |= SELECT;
|
||||
vertsep++;
|
||||
check= 1;
|
||||
}
|
||||
}
|
||||
else if(eed->v2->f & SELECT) {
|
||||
if( (eed->v1->f & SELECT)==0 ) {
|
||||
eed->v1->f |= SELECT;
|
||||
vertsep++;
|
||||
check= SELECT;
|
||||
}
|
||||
}
|
||||
}
|
||||
eed= eed->next;
|
||||
}
|
||||
}
|
||||
/*----------End of select connected--------*/
|
||||
selectconnected_mesh_all(em);
|
||||
|
||||
|
||||
/* If the amount of vertices that is about to be split == the total amount
|
||||
of verts in the mesh, it means that there is only 1 unconnected object, so we don't have to separate
|
||||
*/
|
||||
if(em->totvert==vertsep) done=1;
|
||||
else{
|
||||
/* No splitting: select connected goes fine */
|
||||
|
||||
EM_select_flush(em); // from verts->edges->faces
|
||||
|
||||
/* set apart: everything that is not selected */
|
||||
edve.first= edve.last= eded.first= eded.last= edvl.first= edvl.last= 0;
|
||||
eve= em->verts.first;
|
||||
while(eve) {
|
||||
v1= eve->next;
|
||||
if((eve->f & SELECT)==0) {
|
||||
BLI_remlink(&em->verts, eve);
|
||||
BLI_addtail(&edve, eve);
|
||||
}
|
||||
eve= v1;
|
||||
}
|
||||
eed= em->edges.first;
|
||||
while(eed) {
|
||||
e1= eed->next;
|
||||
if( (eed->f & SELECT)==0 ) {
|
||||
BLI_remlink(&em->edges, eed);
|
||||
BLI_addtail(&eded, eed);
|
||||
}
|
||||
eed= e1;
|
||||
}
|
||||
efa= em->faces.first;
|
||||
while(efa) {
|
||||
vl1= efa->next;
|
||||
if( (efa->f & SELECT)==0 ) {
|
||||
BLI_remlink(&em->faces, efa);
|
||||
BLI_addtail(&edvl, efa);
|
||||
}
|
||||
efa= vl1;
|
||||
}
|
||||
|
||||
oldob= obedit;
|
||||
oldbase= BASACT;
|
||||
|
||||
adduplicate(1, 0); /* notrans and a linked duplicate*/
|
||||
|
||||
obedit= BASACT->object; /* basact was set in adduplicate() */
|
||||
|
||||
men= copy_mesh(me);
|
||||
set_mesh(obedit, men);
|
||||
/* because new mesh is a copy: reduce user count */
|
||||
men->id.us--;
|
||||
|
||||
load_editMesh(scene, obedit);
|
||||
|
||||
BASACT->flag &= ~SELECT;
|
||||
|
||||
/* we cannot free the original buffer... */
|
||||
emcopy= *em;
|
||||
emcopy.allverts= NULL;
|
||||
emcopy.alledges= NULL;
|
||||
emcopy.allfaces= NULL;
|
||||
emcopy.derivedFinal= emcopy.derivedCage= NULL;
|
||||
memset(&emcopy.vdata, 0, sizeof(emcopy.vdata));
|
||||
memset(&emcopy.fdata, 0, sizeof(emcopy.fdata));
|
||||
free_editMesh(&emcopy);
|
||||
|
||||
em->verts= edve;
|
||||
em->edges= eded;
|
||||
em->faces= edvl;
|
||||
|
||||
/* hashedges are freed now, make new! */
|
||||
editMesh_set_hash(em);
|
||||
|
||||
obedit= oldob;
|
||||
BASACT= oldbase;
|
||||
BASACT->flag |= SELECT;
|
||||
|
||||
}
|
||||
/* and now separate */
|
||||
doit= mesh_separate_selected(scene, editbase);
|
||||
}
|
||||
|
||||
/* unselect the vertices that we (ab)used for the separation*/
|
||||
EM_clear_flag_all(em, SELECT);
|
||||
|
||||
waitcursor(0);
|
||||
// allqueue(REDRAWVIEW3D, 0);
|
||||
DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
|
||||
return 1;
|
||||
}
|
||||
|
||||
void separatemenu(Scene *scene, Object *obedit)
|
||||
|
||||
static int mesh_separate_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Mesh *me= obedit->data;
|
||||
short event;
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
Base *base= CTX_data_active_base(C);
|
||||
int retval= 0;
|
||||
|
||||
if(me->edit_mesh->verts.first==NULL) return;
|
||||
if(RNA_enum_is_equal(op->ptr, "type", "SELECTED"))
|
||||
retval= mesh_separate_selected(scene, base);
|
||||
else if(RNA_enum_is_equal(op->ptr, "type", "MATERIAL"))
|
||||
retval= mesh_separate_material (scene, base);
|
||||
else if(RNA_enum_is_equal(op->ptr, "type", "LOOSE"))
|
||||
retval= mesh_separate_loose(scene, base);
|
||||
|
||||
event = pupmenu("Separate %t|Selected%x1|All Loose Parts%x2|By Material%x3");
|
||||
|
||||
if (event==0) return;
|
||||
waitcursor(1);
|
||||
|
||||
switch (event) {
|
||||
case 1:
|
||||
separate_mesh(scene, obedit);
|
||||
break;
|
||||
case 2:
|
||||
separate_mesh_loose(scene, obedit);
|
||||
break;
|
||||
case 3:
|
||||
separate_material(scene, obedit);
|
||||
break;
|
||||
if(retval) {
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, base->object);
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
waitcursor(0);
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
void MESH_OT_separate(wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name= "Mesh Separate";
|
||||
ot->idname= "MESH_OT_separate";
|
||||
|
||||
/* api callbacks */
|
||||
ot->invoke= WM_menu_invoke;
|
||||
ot->exec= mesh_separate_exec;
|
||||
ot->poll= ED_operator_editmesh;
|
||||
|
||||
/* flags */
|
||||
ot->flag= OPTYPE_REGISTER/*|OPTYPE_UNDO*/;
|
||||
|
||||
RNA_def_enum(ot->srna, "type", prop_separate_types, 0, "Type", "");
|
||||
}
|
||||
|
||||
|
||||
@@ -1848,9 +1683,6 @@ static void free_undoMesh(void *umv)
|
||||
{
|
||||
UndoMesh *um= umv;
|
||||
|
||||
if (um == NULL)
|
||||
return; /* XXX FIX ME, THIS SHOULD NEVER BE TRUE YET IT HAPPENS DURING TRANSFORM */
|
||||
|
||||
if(um->verts) MEM_freeN(um->verts);
|
||||
if(um->edges) MEM_freeN(um->edges);
|
||||
if(um->faces) MEM_freeN(um->faces);
|
||||
@@ -1865,7 +1697,6 @@ static void free_undoMesh(void *umv)
|
||||
static void *editMesh_to_undoMesh(void *emv)
|
||||
{
|
||||
EditMesh *em= (EditMesh *)emv;
|
||||
// Scene *scene= NULL;
|
||||
UndoMesh *um;
|
||||
EditVert *eve;
|
||||
EditEdge *eed;
|
||||
|
||||
@@ -76,7 +76,6 @@
|
||||
|
||||
/* XXX */
|
||||
static void BIF_undo_push() {}
|
||||
static void waitcursor() {}
|
||||
static void error() {}
|
||||
static int pupmenu() {return 0;}
|
||||
#define add_numbut(a, b, c, d, e, f, g) {}
|
||||
@@ -119,34 +118,36 @@ static short icoface[20][3] = {
|
||||
{10,9,11}
|
||||
};
|
||||
|
||||
static void get_view_aligned_coordinate(float *fp, short mval[2])
|
||||
static void get_view_aligned_coordinate(ViewContext *vc, float *fp, short mval[2])
|
||||
{
|
||||
// float dvec[3];
|
||||
// short mx, my;
|
||||
float dvec[3];
|
||||
short mx, my;
|
||||
|
||||
// mx= mval[0];
|
||||
// my= mval[1];
|
||||
mx= mval[0];
|
||||
my= mval[1];
|
||||
|
||||
// XXX project_short_noclip(ar, v3d, fp, mval);
|
||||
project_short_noclip(vc->ar, fp, mval);
|
||||
|
||||
// XXX initgrabz(fp[0], fp[1], fp[2]);
|
||||
initgrabz(vc->rv3d, fp[0], fp[1], fp[2]);
|
||||
|
||||
// if(mval[0]!=IS_CLIPPED) {
|
||||
// window_to_3d_delta(dvec, mval[0]-mx, mval[1]-my);
|
||||
// VecSubf(fp, fp, dvec);
|
||||
// }
|
||||
if(mval[0]!=IS_CLIPPED) {
|
||||
window_to_3d_delta(vc->ar, dvec, mval[0]-mx, mval[1]-my);
|
||||
VecSubf(fp, fp, dvec);
|
||||
}
|
||||
}
|
||||
|
||||
void add_click_mesh(Scene *scene, Object *obedit, EditMesh *em)
|
||||
void add_click_mesh(bContext *C)
|
||||
{
|
||||
View3D *v3d= NULL; // XXX
|
||||
ViewContext vc;
|
||||
EditVert *eve, *v1;
|
||||
float min[3], max[3];
|
||||
int done= 0;
|
||||
|
||||
em_setup_viewcontext(C, &vc);
|
||||
|
||||
INIT_MINMAX(min, max);
|
||||
|
||||
for(v1= em->verts.first;v1; v1=v1->next) {
|
||||
for(v1= vc.em->verts.first;v1; v1=v1->next) {
|
||||
if(v1->f & SELECT) {
|
||||
DO_MINMAX(v1->co, min, max);
|
||||
done= 1;
|
||||
@@ -162,7 +163,7 @@ void add_click_mesh(Scene *scene, Object *obedit, EditMesh *em)
|
||||
|
||||
/* check for edges that are half selected, use for rotation */
|
||||
done= 0;
|
||||
for(eed= em->edges.first; eed; eed= eed->next) {
|
||||
for(eed= vc.em->edges.first; eed; eed= eed->next) {
|
||||
if( (eed->v1->f & SELECT)+(eed->v2->f & SELECT) == SELECT ) {
|
||||
if(eed->v1->f & SELECT) VecSubf(vec, eed->v1->co, eed->v2->co);
|
||||
else VecSubf(vec, eed->v2->co, eed->v1->co);
|
||||
@@ -177,10 +178,10 @@ void add_click_mesh(Scene *scene, Object *obedit, EditMesh *em)
|
||||
VecMulf(cent, 0.5f);
|
||||
VECCOPY(min, cent);
|
||||
|
||||
Mat4MulVecfl(obedit->obmat, min); // view space
|
||||
get_view_aligned_coordinate(min, mval);
|
||||
Mat4Invert(obedit->imat, obedit->obmat);
|
||||
Mat4MulVecfl(obedit->imat, min); // back in object space
|
||||
Mat4MulVecfl(vc.obedit->obmat, min); // view space
|
||||
get_view_aligned_coordinate(&vc, min, mval);
|
||||
Mat4Invert(vc.obedit->imat, vc.obedit->obmat);
|
||||
Mat4MulVecfl(vc.obedit->imat, min); // back in object space
|
||||
|
||||
VecSubf(min, min, cent);
|
||||
|
||||
@@ -209,23 +210,23 @@ void add_click_mesh(Scene *scene, Object *obedit, EditMesh *em)
|
||||
}
|
||||
}
|
||||
|
||||
extrudeflag(obedit, em, SELECT, nor);
|
||||
rotateflag(em, SELECT, cent, mat);
|
||||
translateflag(em, SELECT, min);
|
||||
extrudeflag(vc.obedit, vc.em, SELECT, nor);
|
||||
rotateflag(vc.em, SELECT, cent, mat);
|
||||
translateflag(vc.em, SELECT, min);
|
||||
|
||||
recalc_editnormals(em);
|
||||
recalc_editnormals(vc.em);
|
||||
}
|
||||
else {
|
||||
float mat[3][3],imat[3][3];
|
||||
float *curs= give_cursor(scene, v3d);
|
||||
float *curs= give_cursor(vc.scene, vc.v3d);
|
||||
|
||||
eve= addvertlist(em, 0, NULL);
|
||||
eve= addvertlist(vc.em, 0, NULL);
|
||||
|
||||
Mat3CpyMat4(mat, obedit->obmat);
|
||||
Mat3CpyMat4(mat, vc.obedit->obmat);
|
||||
Mat3Inv(imat, mat);
|
||||
|
||||
VECCOPY(eve->co, curs);
|
||||
VecSubf(eve->co, eve->co, obedit->obmat[3]);
|
||||
VecSubf(eve->co, eve->co, vc.obedit->obmat[3]);
|
||||
|
||||
Mat3MulVecfl(imat, eve->co);
|
||||
|
||||
@@ -235,9 +236,8 @@ void add_click_mesh(Scene *scene, Object *obedit, EditMesh *em)
|
||||
//retopo_do_all();
|
||||
|
||||
BIF_undo_push("Add vertex/edge/face");
|
||||
// XXX DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
|
||||
DAG_object_flush_update(vc.scene, vc.obedit, OB_RECALC_DATA);
|
||||
|
||||
while(0); // XXX get_mbut()&R_MOUSE);
|
||||
|
||||
}
|
||||
|
||||
@@ -560,6 +560,7 @@ static void fix_new_face(EditMesh *em, EditFace *eface)
|
||||
}
|
||||
}
|
||||
|
||||
/* only adds quads or trias when there's edges already */
|
||||
void addfaces_from_edgenet(EditMesh *em)
|
||||
{
|
||||
EditVert *eve1, *eve2, *eve3, *eve4;
|
||||
@@ -740,30 +741,6 @@ void addedgeface_mesh(EditMesh *em)
|
||||
}
|
||||
|
||||
|
||||
void adduplicate_mesh(Scene *scene, Object *obedit, EditMesh *em)
|
||||
{
|
||||
|
||||
waitcursor(1);
|
||||
|
||||
adduplicateflag(em, SELECT);
|
||||
|
||||
waitcursor(0);
|
||||
|
||||
/* We need to force immediate calculation here because
|
||||
* transform may use derived objects (which are now stale).
|
||||
*
|
||||
* This shouldn't be necessary, derived queries should be
|
||||
* automatically building this data if invalid. Or something.
|
||||
*/
|
||||
DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
|
||||
object_handle_update(scene, obedit);
|
||||
|
||||
// XXX BIF_TransformSetUndo("Add Duplicate");
|
||||
// initTransform(TFM_TRANSLATION, CTX_NO_PET);
|
||||
// Transform();
|
||||
}
|
||||
|
||||
|
||||
// HACK: these can also be found in cmoview.tga.c, but are here so that they can be found by linker
|
||||
// this hack is only used so that scons+mingw + split-sources hack works
|
||||
// ------------------------------- start copied code
|
||||
@@ -1214,181 +1191,6 @@ static void make_prim(Object *obedit, int type, float mat[4][4], int tot, int se
|
||||
righthandfaces(em, 1); /* otherwise monkey has eyes in wrong direction */
|
||||
}
|
||||
|
||||
#if 0
|
||||
void add_primitiveMesh(Scene *scene, View3D *v3d, Object *obedit, EditMesh *em, int type)
|
||||
{
|
||||
Mesh *me;
|
||||
float *curs, d, dia, phi, phid, cent[3], imat[3][3], mat[3][3];
|
||||
float cmat[3][3];
|
||||
static int tot=32, seg=32, subdiv=2,
|
||||
/* so each type remembers its fill setting */
|
||||
fill_circle=0, fill_cone=1, fill_cylinder=1;
|
||||
|
||||
int ext=0, fill=0, totoud, newob=0;
|
||||
char *undostr="Add Primitive";
|
||||
char *name=NULL;
|
||||
|
||||
// if(scene->id.lib) return;
|
||||
|
||||
/* this function also comes from an info window */
|
||||
// XXX if ELEM(curarea->spacetype, SPACE_VIEW3D, SPACE_INFO); else return;
|
||||
|
||||
/* if editmode exists for other type, it exits */
|
||||
check_editmode(OB_MESH);
|
||||
|
||||
if(G.f & (G_VERTEXPAINT+G_TEXTUREPAINT)) {
|
||||
G.f &= ~(G_VERTEXPAINT+G_TEXTUREPAINT);
|
||||
}
|
||||
|
||||
totoud= tot; /* store, and restore when cube/plane */
|
||||
|
||||
dia= v3d->grid;
|
||||
d= v3d->grid;
|
||||
|
||||
/* ext==extrudeflag, tot==amount of vertices in basis */
|
||||
switch(type) {
|
||||
case 0: /* plane */
|
||||
tot= 4;
|
||||
ext= 0;
|
||||
fill= 1;
|
||||
newob = confirm_objectExists(scene, obedit, &me, mat );
|
||||
if(newob) name = "Plane";
|
||||
undostr="Add Plane";
|
||||
break;
|
||||
case 1: /* cube */
|
||||
tot= 4;
|
||||
ext= 1;
|
||||
fill= 1;
|
||||
newob = confirm_objectExists(scene, obedit, &me, mat );
|
||||
if(newob) name = "Cube";
|
||||
undostr="Add Cube";
|
||||
break;
|
||||
case 4: /* circle */
|
||||
add_numbut(0, NUM|INT, "Vertices:", 3, 500, &tot, NULL);
|
||||
add_numbut(1, NUM|FLO, "Radius:", 0.001*v3d->grid, 100*v3d->grid, &dia, NULL);
|
||||
add_numbut(2, TOG|INT, "Fill", 0, 0, &(fill_circle), NULL);
|
||||
if (!(do_clever_numbuts("Add Circle", 3, 0))) return;
|
||||
ext= 0;
|
||||
fill = fill_circle;
|
||||
newob = confirm_objectExists(scene, obedit, &me, mat );
|
||||
if(newob) name = "Circle";
|
||||
undostr="Add Circle";
|
||||
break;
|
||||
case 5: /* cylinder */
|
||||
d*=2;
|
||||
add_numbut(0, NUM|INT, "Vertices:", 2, 500, &tot, NULL);
|
||||
add_numbut(1, NUM|FLO, "Radius:", 0.001*v3d->grid, 100*v3d->grid, &dia, NULL);
|
||||
add_numbut(2, NUM|FLO, "Depth:", 0.001*v3d->grid, 100*v3d->grid, &d, NULL);
|
||||
add_numbut(3, TOG|INT, "Cap Ends", 0, 0, &(fill_cylinder), NULL);
|
||||
if (!(do_clever_numbuts("Add Cylinder", 4, 0))) return;
|
||||
ext= 1;
|
||||
fill = fill_cylinder;
|
||||
d/=2;
|
||||
newob = confirm_objectExists(scene, obedit, &me, mat );
|
||||
if(newob) {
|
||||
if (fill) name = "Cylinder";
|
||||
else name = "Tube";
|
||||
}
|
||||
undostr="Add Cylinder";
|
||||
break;
|
||||
case 7: /* cone */
|
||||
d*=2;
|
||||
add_numbut(0, NUM|INT, "Vertices:", 2, 500, &tot, NULL);
|
||||
add_numbut(1, NUM|FLO, "Radius:", 0.001*v3d->grid, 100*v3d->grid, &dia, NULL);
|
||||
add_numbut(2, NUM|FLO, "Depth:", 0.001*v3d->grid, 100*v3d->grid, &d, NULL);
|
||||
add_numbut(3, TOG|INT, "Cap End", 0, 0, &(fill_cone), NULL);
|
||||
if (!(do_clever_numbuts("Add Cone", 4, 0))) return;
|
||||
d/=2;
|
||||
ext= 0;
|
||||
fill = fill_cone;
|
||||
newob = confirm_objectExists(scene, obedit, &me, mat );
|
||||
if(newob) name = "Cone";
|
||||
undostr="Add Cone";
|
||||
break;
|
||||
case 10: /* grid */
|
||||
add_numbut(0, NUM|INT, "X res:", 3, 1000, &tot, NULL);
|
||||
add_numbut(1, NUM|INT, "Y res:", 3, 1000, &seg, NULL);
|
||||
if (!(do_clever_numbuts("Add Grid", 2, 0))) return;
|
||||
newob = confirm_objectExists(scene, obedit, &me, mat );
|
||||
if(newob) name = "Grid";
|
||||
undostr="Add Grid";
|
||||
break;
|
||||
case 11: /* UVsphere */
|
||||
add_numbut(0, NUM|INT, "Segments:", 3, 500, &seg, NULL);
|
||||
add_numbut(1, NUM|INT, "Rings:", 3, 500, &tot, NULL);
|
||||
add_numbut(2, NUM|FLO, "Radius:", 0.001*v3d->grid, 100*v3d->grid, &dia, NULL);
|
||||
|
||||
if (!(do_clever_numbuts("Add UV Sphere", 3, 0))) return;
|
||||
|
||||
newob = confirm_objectExists(scene, obedit, &me, mat );
|
||||
if(newob) name = "Sphere";
|
||||
undostr="Add UV Sphere";
|
||||
break;
|
||||
case 12: /* Icosphere */
|
||||
add_numbut(0, NUM|INT, "Subdivision:", 1, 8, &subdiv, NULL);
|
||||
add_numbut(1, NUM|FLO, "Radius:", 0.001*v3d->grid, 100*v3d->grid, &dia, NULL);
|
||||
if (!(do_clever_numbuts("Add Ico Sphere", 2, 0))) return;
|
||||
|
||||
newob = confirm_objectExists(scene, obedit, &me, mat );
|
||||
if(newob) name = "Sphere";
|
||||
undostr="Add Ico Sphere";
|
||||
break;
|
||||
case 13: /* Monkey */
|
||||
newob = confirm_objectExists(scene, obedit, &me, mat );
|
||||
if(newob) name = "Suzanne";
|
||||
undostr="Add Monkey";
|
||||
break;
|
||||
default:
|
||||
newob = confirm_objectExists(scene, obedit, &me, mat );
|
||||
break;
|
||||
}
|
||||
|
||||
if( name!=NULL ) {
|
||||
rename_id((ID *)obedit, name );
|
||||
rename_id((ID *)me, name );
|
||||
}
|
||||
|
||||
d = -d;
|
||||
curs= give_cursor(scene, v3d);
|
||||
VECCOPY(cent, curs);
|
||||
cent[0]-= obedit->obmat[3][0];
|
||||
cent[1]-= obedit->obmat[3][1];
|
||||
cent[2]-= obedit->obmat[3][2];
|
||||
|
||||
if ( !(newob) || U.flag & USER_ADD_VIEWALIGNED) Mat3CpyMat4(imat, v3d->viewmat);
|
||||
else Mat3One(imat);
|
||||
Mat3MulVecfl(imat, cent);
|
||||
Mat3MulMat3(cmat, imat, mat);
|
||||
Mat3Inv(imat,cmat);
|
||||
|
||||
|
||||
if(type == 0 || type == 1) /* plane, cube (diameter of 1.41 makes it unit size) */
|
||||
dia *= sqrt(2.0);
|
||||
|
||||
phid= 2*M_PI/tot;
|
||||
phi= .25*M_PI;
|
||||
|
||||
make_prim(obedit, type, imat, tot, seg, subdiv, dia, d, ext, fill, cent);
|
||||
|
||||
if(type<2) tot = totoud;
|
||||
|
||||
/* simple selection flush OK, based on fact it's a single model */
|
||||
EM_select_flush(em); // flushes vertex -> edge -> face selection
|
||||
|
||||
if(type!=0 && type!=13) righthandfaces(em, 1); /* otherwise monkey has eyes in wrong direction... */
|
||||
|
||||
// XXX DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
|
||||
|
||||
/* if a new object was created, it stores it in Mesh, for reload original data and undo */
|
||||
if ( !(newob) || U.flag & USER_ADD_EDITMODE) {
|
||||
if(newob) load_editMesh(scene, obedit);
|
||||
} else {
|
||||
exit_editmode(2);
|
||||
}
|
||||
|
||||
BIF_undo_push(undostr);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* uses context to figure out transform for primitive */
|
||||
/* returns standard diameter */
|
||||
|
||||
@@ -256,12 +256,8 @@ int EM_mask_init_backbuf_border(ViewContext *vc, short mcords[][2], short tot, s
|
||||
dr = buf->rect;
|
||||
|
||||
/* draw the mask */
|
||||
#ifdef __APPLE__
|
||||
glDrawBuffer(GL_AUX0);
|
||||
#endif
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
|
||||
// XXX persp(PERSP_WIN);
|
||||
glColor3ub(0, 0, 0);
|
||||
|
||||
/* yah, opengl doesn't do concave... tsk! */
|
||||
@@ -271,11 +267,8 @@ int EM_mask_init_backbuf_border(ViewContext *vc, short mcords[][2], short tot, s
|
||||
for(a=0; a<tot; a++) glVertex2s(mcords[a][0], mcords[a][1]);
|
||||
glEnd();
|
||||
|
||||
// XXX persp(PERSP_VIEW);
|
||||
glFinish(); /* to be sure readpixels sees mask */
|
||||
|
||||
glDrawBuffer(GL_BACK);
|
||||
|
||||
/* grab mask */
|
||||
bufmask= view3d_read_backbuf(vc, xmin, ymin, xmax, ymax);
|
||||
drm = bufmask->rect;
|
||||
@@ -1476,9 +1469,6 @@ void EM_mesh_copy_face(EditMesh *em, short type)
|
||||
|
||||
if (change) {
|
||||
// DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
|
||||
if (type==3) {
|
||||
// XXX allqueue(REDRAWIMAGE, 0);
|
||||
}
|
||||
|
||||
BIF_undo_push("Copy Face Attribute");
|
||||
}
|
||||
@@ -2832,31 +2822,31 @@ void select_faces_by_numverts(EditMesh *em, int numverts)
|
||||
BIF_undo_push("Select non-Triangles/Quads");
|
||||
}
|
||||
|
||||
void select_sharp_edges(EditMesh *em, float fsharpness)
|
||||
static int select_sharp_edges_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
/* Find edges that have exactly two neighboring faces,
|
||||
* check the angle between those faces, and if angle is
|
||||
* small enough, select the edge
|
||||
*/
|
||||
* check the angle between those faces, and if angle is
|
||||
* small enough, select the edge
|
||||
*/
|
||||
Object *obedit= CTX_data_edit_object(C);
|
||||
EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
|
||||
EditEdge *eed;
|
||||
EditFace *efa;
|
||||
EditFace **efa1;
|
||||
EditFace **efa2;
|
||||
intptr_t edgecount = 0, i;
|
||||
static short sharpness = 135;
|
||||
|
||||
intptr_t edgecount = 0, i = 0;
|
||||
float sharpness, fsharpness;
|
||||
|
||||
/* 'standard' behaviour - check if selected, then apply relevant selection */
|
||||
|
||||
if(em->selectmode==SCE_SELECT_FACE) {
|
||||
error("Doesn't work in face selection mode");
|
||||
return;
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
// XXX if(button(&sharpness,0, 180,"Max Angle:")==0) return;
|
||||
/* if faces are at angle 'sharpness', then the face normals
|
||||
* are at angle 180.0 - 'sharpness' (convert to radians too)
|
||||
*/
|
||||
sharpness= RNA_float_get(op->ptr, "sharpness");
|
||||
fsharpness = ((180.0 - sharpness) * M_PI) / 180.0;
|
||||
|
||||
i=0;
|
||||
/* count edges, use tmp.l */
|
||||
eed= em->edges.first;
|
||||
while(eed) {
|
||||
@@ -2929,18 +2919,6 @@ void select_sharp_edges(EditMesh *em, float fsharpness)
|
||||
// if (EM_texFaceCheck())
|
||||
|
||||
BIF_undo_push("Select Sharp Edges");
|
||||
}
|
||||
|
||||
static int select_sharp_edges_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Object *obedit= CTX_data_edit_object(C);
|
||||
EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
|
||||
|
||||
/* 'standard' behaviour - check if selected, then apply relevant selection */
|
||||
|
||||
// XXX we need a message here - for 1 its recalculate normals inside, for 2 its outside
|
||||
righthandfaces(em, RNA_float_get(op->ptr, "sharpness"));
|
||||
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit); //TODO is this needed ?
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -2958,13 +2936,12 @@ void MESH_OT_select_sharp_edges(wmOperatorType *ot)
|
||||
/* flags */
|
||||
ot->flag= OPTYPE_REGISTER/*|OPTYPE_UNDO*/;
|
||||
|
||||
/* props XXX figure out? */
|
||||
/* props */
|
||||
RNA_def_float(ot->srna, "sharpness", 0.01f, 0.0f, FLT_MAX, "sharpness", "", 0.0f, 180.0f);
|
||||
}
|
||||
|
||||
|
||||
// XXX looks like more work is needed in order for this to work (see in function)
|
||||
void select_linked_flat_faces(EditMesh *em, float fsharpness)
|
||||
static void select_linked_flat_faces(EditMesh *em, float sharpness)
|
||||
{
|
||||
/* Find faces that are linked to selected faces that are
|
||||
* relatively flat (angle between faces is higher than
|
||||
@@ -2975,18 +2952,13 @@ void select_linked_flat_faces(EditMesh *em, float fsharpness)
|
||||
EditFace **efa1;
|
||||
EditFace **efa2;
|
||||
intptr_t edgecount = 0, i, faceselcount=0, faceselcountold=0;
|
||||
static short sharpness = 135;
|
||||
float fsharpness;
|
||||
|
||||
|
||||
if(em->selectmode!=SCE_SELECT_FACE) {
|
||||
error("Only works in face selection mode");
|
||||
return;
|
||||
}
|
||||
|
||||
// XXX if(button(&sharpness,0, 180,"Min Angle:")==0) return;
|
||||
/* if faces are at angle 'sharpness', then the face normals
|
||||
* are at angle 180.0 - 'sharpness' (convert to radians too)
|
||||
*/
|
||||
fsharpness = ((180.0 - sharpness) * M_PI) / 180.0;
|
||||
|
||||
i=0;
|
||||
@@ -3890,6 +3862,7 @@ void Face_Menu(EditMesh *em)
|
||||
|
||||
/* **************** NORMALS ************** */
|
||||
|
||||
/* XXX value of select is messed up, it means two things */
|
||||
void righthandfaces(EditMesh *em, int select) /* makes faces righthand turning */
|
||||
{
|
||||
EditEdge *eed, *ed1, *ed2, *ed3, *ed4;
|
||||
@@ -4108,7 +4081,7 @@ static int righthandfaces_exec(bContext *C, wmOperator *op)
|
||||
|
||||
/* 'standard' behaviour - check if selected, then apply relevant selection */
|
||||
|
||||
// XXX we need a message here - for 1 its recalculate normals inside, for 2 its outside
|
||||
// XXX need other args
|
||||
righthandfaces(em, RNA_int_get(op->ptr, "select"));
|
||||
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit); //TODO is this needed ?
|
||||
@@ -4128,7 +4101,7 @@ void MESH_OT_righthandfaces(wmOperatorType *ot)
|
||||
/* flags */
|
||||
ot->flag= OPTYPE_REGISTER/*|OPTYPE_UNDO*/;
|
||||
|
||||
/* props */
|
||||
/* XXX make it enum or so */
|
||||
RNA_def_int(ot->srna, "select", 0, INT_MIN, INT_MAX, "Select", "", INT_MIN, INT_MAX);
|
||||
}
|
||||
|
||||
@@ -4310,6 +4283,7 @@ void editmesh_align_view_to_selected(Object *obedit, EditMesh *em, View3D *v3d,
|
||||
|
||||
void vertexsmooth(Object *obedit, EditMesh *em)
|
||||
{
|
||||
Scene *scene= NULL; // XXX
|
||||
EditVert *eve, *eve_mir = NULL;
|
||||
EditEdge *eed;
|
||||
float *adror, *adr, fac;
|
||||
@@ -4394,9 +4368,9 @@ void vertexsmooth(Object *obedit, EditMesh *em)
|
||||
if(eve->f & SELECT) {
|
||||
if(eve->f1) {
|
||||
|
||||
// XXX if (scene->toolsettings->editbutflag & B_MESH_X_MIRROR) {
|
||||
// eve_mir= editmesh_get_x_mirror_vert(obedit, em, eve->co);
|
||||
// }
|
||||
if (scene->toolsettings->editbutflag & B_MESH_X_MIRROR) {
|
||||
eve_mir= editmesh_get_x_mirror_vert(obedit, em, eve->co);
|
||||
}
|
||||
|
||||
adr = eve->tmp.p;
|
||||
fac= 0.5/(float)eve->f1;
|
||||
|
||||
@@ -99,7 +99,6 @@ static int extern_qread() {return 0;}
|
||||
static void waitcursor() {}
|
||||
static void error() {}
|
||||
static int pupmenu() {return 0;}
|
||||
static int okee() {return 0;}
|
||||
static int qtest() {return 0;}
|
||||
#define add_numbut(a, b, c, d, e, f, g) {}
|
||||
static int do_clever_numbuts() {return 0;}
|
||||
@@ -724,8 +723,6 @@ void MESH_OT_extrude_mesh(wmOperatorType *ot)
|
||||
void split_mesh(EditMesh *em)
|
||||
{
|
||||
|
||||
if(okee(" Split ")==0) return;
|
||||
|
||||
waitcursor(1);
|
||||
|
||||
/* make duplicate first */
|
||||
@@ -777,6 +774,7 @@ void extrude_repeat_mesh(RegionView3D *rv3d, Object *obedit, EditMesh *em, int s
|
||||
|
||||
void spin_mesh(View3D *v3d, Object *obedit, EditMesh *em, int steps, float degr, float *dvec, int mode)
|
||||
{
|
||||
Scene *scene= NULL; // XXX from context!
|
||||
RegionView3D *rv3d= NULL; // XXX from context
|
||||
EditVert *eve,*nextve;
|
||||
float nor[3]= {0.0, 0.0, 0.0};
|
||||
@@ -798,7 +796,7 @@ void spin_mesh(View3D *v3d, Object *obedit, EditMesh *em, int steps, float degr,
|
||||
|
||||
phi= degr*M_PI/360.0;
|
||||
phi/= steps;
|
||||
// if(scene->toolsettings->editbutflag & B_CLOCKWISE) phi= -phi;
|
||||
if(scene->toolsettings->editbutflag & B_CLOCKWISE) phi= -phi;
|
||||
|
||||
if(dvec) {
|
||||
n[0]= rv3d->viewinv[1][0];
|
||||
@@ -821,7 +819,7 @@ void spin_mesh(View3D *v3d, Object *obedit, EditMesh *em, int steps, float degr,
|
||||
Mat3MulMat3(tmat,cmat,bmat);
|
||||
Mat3MulMat3(bmat,imat,tmat);
|
||||
|
||||
// if(mode==0) if(scene->toolsettings->editbutflag & B_KEEPORIG) adduplicateflag(1);
|
||||
if(mode==0) if(scene->toolsettings->editbutflag & B_KEEPORIG) adduplicateflag(em, 1);
|
||||
ok= 1;
|
||||
|
||||
for(a=0;a<steps;a++) {
|
||||
@@ -1184,6 +1182,8 @@ void fill_mesh(EditMesh *em)
|
||||
|
||||
BLI_end_edgefill();
|
||||
|
||||
// XXX option beautyfill */
|
||||
|
||||
waitcursor(0);
|
||||
EM_select_flush(em);
|
||||
// DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
|
||||
@@ -6478,7 +6478,7 @@ static int subdivs_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
||||
p+= sprintf(p, "|%s %%x%d", "fractal", 1);
|
||||
p+= sprintf(p, "|%s %%x%d", "smooth", 0);
|
||||
|
||||
uiPupmenuOperator(C, 20, op, "index", menu);
|
||||
uiPupMenuOperator(C, 20, op, "index", menu);
|
||||
MEM_freeN(menu);
|
||||
|
||||
return OPERATOR_RUNNING_MODAL;
|
||||
@@ -6740,7 +6740,7 @@ static int edit_faces_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
||||
p+= sprintf(p, "|%s %%x%d", "set solid", 0);
|
||||
|
||||
|
||||
uiPupmenuOperator(C, 20, op, "index", menu);
|
||||
uiPupMenuOperator(C, 20, op, "index", menu);
|
||||
MEM_freeN(menu);
|
||||
|
||||
return OPERATOR_RUNNING_MODAL;
|
||||
@@ -6794,4 +6794,4 @@ void MESH_OT_edit_faces(wmOperatorType *ot)
|
||||
/*props */
|
||||
RNA_def_int(ot->srna, "index", 0, 0, INT_MAX, "Index", "", 0, 1000);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,6 +94,8 @@ int editface_containsEdge(struct EditFace *efa, struct EditEdge *eed);
|
||||
|
||||
void em_setup_viewcontext(struct bContext *C, struct ViewContext *vc);
|
||||
|
||||
void MESH_OT_separate(struct wmOperatorType *ot);
|
||||
|
||||
/* ******************* editmesh_add.c */
|
||||
void MESH_OT_add_primitive_plane(struct wmOperatorType *ot);
|
||||
void MESH_OT_add_primitive_cube(struct wmOperatorType *ot);
|
||||
@@ -185,6 +187,7 @@ extern void EM_automerge(int update);
|
||||
void editmesh_select_by_material(EditMesh *em, int index);
|
||||
void righthandfaces(EditMesh *em, int select); /* makes faces righthand turning */
|
||||
void EM_select_more(EditMesh *em);
|
||||
void selectconnected_mesh_all(EditMesh *em);
|
||||
|
||||
/**
|
||||
* findnearestvert
|
||||
|
||||
@@ -74,7 +74,10 @@ static int mesh_add_duplicate_exec(bContext *C, wmOperator *op)
|
||||
|
||||
static int mesh_add_duplicate_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
||||
{
|
||||
WM_cursor_wait(1);
|
||||
mesh_add_duplicate_exec(C, op);
|
||||
WM_cursor_wait(0);
|
||||
|
||||
RNA_int_set(op->ptr, "mode", TFM_TRANSLATION);
|
||||
WM_operator_name_call(C, "TFM_OT_transform", WM_OP_INVOKE_REGION_WIN, op->ptr);
|
||||
|
||||
@@ -135,6 +138,7 @@ void ED_operatortypes_mesh(void)
|
||||
WM_operatortype_append(MESH_OT_removedoublesflag);
|
||||
WM_operatortype_append(MESH_OT_extrude_mesh);
|
||||
WM_operatortype_append(MESH_OT_edit_faces);
|
||||
WM_operatortype_append(MESH_OT_separate);
|
||||
|
||||
}
|
||||
|
||||
@@ -178,5 +182,8 @@ void ED_keymap_mesh(wmWindowManager *wm)
|
||||
/* add */
|
||||
WM_keymap_add_item(keymap, "MESH_OT_add_duplicate", DKEY, KM_PRESS, KM_SHIFT, 0);
|
||||
WM_keymap_add_item(keymap, "OBJECT_OT_mesh_add", AKEY, KM_PRESS, KM_SHIFT, 0);
|
||||
WM_keymap_add_item(keymap, "MESH_OT_separate", PKEY, KM_PRESS, KM_SHIFT, 0);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -284,15 +284,16 @@ void add_object_draw(Scene *scene, View3D *v3d, int type) /* for toolbox or menu
|
||||
/* keep here to get things compile, remove later */
|
||||
}
|
||||
|
||||
static int object_add_exec(bContext *C, wmOperator *op)
|
||||
/* for object add primitive operators */
|
||||
static Object *object_add_type(bContext *C, int type)
|
||||
{
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
Object *ob;
|
||||
int type= RNA_int_get(op->ptr, "type");
|
||||
|
||||
/* hrms, this is editor level operator */
|
||||
/* XXX hrms, this is editor level operator, remove? */
|
||||
ED_view3d_exit_paint_modes(C);
|
||||
|
||||
/* for as long scene has editmode... */
|
||||
if (CTX_data_edit_object(C))
|
||||
ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR); /* freedata, and undo */
|
||||
|
||||
@@ -306,6 +307,14 @@ static int object_add_exec(bContext *C, wmOperator *op)
|
||||
|
||||
DAG_scene_sort(scene);
|
||||
|
||||
return ob;
|
||||
}
|
||||
|
||||
/* for object add operator */
|
||||
static int object_add_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
object_add_type(C, RNA_int_get(op->ptr, "type"));
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
@@ -346,13 +355,14 @@ static int object_add_mesh_exec(bContext *C, wmOperator *op)
|
||||
Object *obedit= CTX_data_edit_object(C);
|
||||
int newob= 0;
|
||||
|
||||
if(obedit==NULL) {
|
||||
RNA_enum_set(op->ptr, "type", OB_MESH);
|
||||
object_add_exec(C, op);
|
||||
if(obedit==NULL || obedit->type!=OB_MESH) {
|
||||
object_add_type(C, OB_MESH);
|
||||
ED_object_enter_editmode(C, 0);
|
||||
newob = 1;
|
||||
}
|
||||
switch(RNA_enum_get(op->ptr, "primtype")) {
|
||||
else DAG_object_flush_update(CTX_data_scene(C), obedit, OB_RECALC_DATA);
|
||||
|
||||
switch(RNA_enum_get(op->ptr, "type")) {
|
||||
case 0:
|
||||
WM_operator_name_call(C, "MESH_OT_add_primitive_plane", WM_OP_INVOKE_REGION_WIN, NULL);
|
||||
break;
|
||||
@@ -386,19 +396,11 @@ static int object_add_mesh_exec(bContext *C, wmOperator *op)
|
||||
ED_object_exit_editmode(C, EM_FREEDATA);
|
||||
}
|
||||
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
static int object_add_mesh_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
||||
{
|
||||
uiMenuItem *head= uiMenuBegin("Add Mesh");
|
||||
|
||||
uiMenuItemsEnumO(head, "OBJECT_OT_mesh_add", "primtype");
|
||||
uiMenuEnd(C, head);
|
||||
|
||||
/* this operator is only for a menu, not used further */
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
void OBJECT_OT_mesh_add(wmOperatorType *ot)
|
||||
{
|
||||
@@ -407,38 +409,48 @@ void OBJECT_OT_mesh_add(wmOperatorType *ot)
|
||||
ot->idname= "OBJECT_OT_mesh_add";
|
||||
|
||||
/* api callbacks */
|
||||
ot->invoke= object_add_mesh_invoke;
|
||||
ot->invoke= WM_menu_invoke;
|
||||
ot->exec= object_add_mesh_exec;
|
||||
|
||||
ot->poll= ED_operator_scene_editable;
|
||||
ot->flag= OPTYPE_REGISTER;
|
||||
|
||||
RNA_def_enum(ot->srna, "type", prop_object_types, 0, "Type", "");
|
||||
RNA_def_enum(ot->srna, "primtype", prop_mesh_types, 0, "Primitive", "");
|
||||
RNA_def_enum(ot->srna, "type", prop_mesh_types, 0, "Primitive", "");
|
||||
}
|
||||
|
||||
static EnumPropertyItem prop_curve_types[] = {
|
||||
{0, "BEZCUVE", "Bezier Curve", ""},
|
||||
{1, "BEZCIRCLE", "Bezier Circle", ""},
|
||||
{2, "NURBSCUVE", "Nurbs Curve", ""},
|
||||
{3, "NURBSCIRCLE", "Nurbs Circle", ""},
|
||||
{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_NURBS|CU_2D|CU_PRIM_PATH, "PATH", "Path", ""},
|
||||
{0, NULL, NULL, NULL}
|
||||
};
|
||||
|
||||
static int object_add_curve_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Object *obedit= CTX_data_edit_object(C);
|
||||
ListBase *editnurb;
|
||||
Nurb *nu;
|
||||
int newob= 0;
|
||||
|
||||
if(obedit==NULL) {
|
||||
RNA_enum_set(op->ptr, "type", OB_MESH);
|
||||
object_add_exec(C, op);
|
||||
if(obedit==NULL || obedit->type!=OB_CURVE) {
|
||||
object_add_type(C, OB_CURVE);
|
||||
ED_object_enter_editmode(C, 0);
|
||||
newob = 1;
|
||||
}
|
||||
switch(RNA_enum_get(op->ptr, "primtype")) {
|
||||
|
||||
|
||||
}
|
||||
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;
|
||||
}
|
||||
@@ -450,21 +462,22 @@ void OBJECT_OT_curve_add(wmOperatorType *ot)
|
||||
ot->idname= "OBJECT_OT_curve_add";
|
||||
|
||||
/* api callbacks */
|
||||
ot->invoke= WM_menu_invoke;
|
||||
ot->exec= object_add_curve_exec;
|
||||
|
||||
ot->poll= ED_operator_scene_editable;
|
||||
ot->flag= OPTYPE_REGISTER;
|
||||
|
||||
RNA_def_enum(ot->srna, "primtype", prop_curve_types, 0, "Type", "");
|
||||
RNA_def_enum(ot->srna, "type", prop_curve_types, 0, "Primitive", "");
|
||||
}
|
||||
|
||||
|
||||
static int object_add_primitive_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
||||
{
|
||||
uiMenuItem *head= uiMenuBegin("Add Object");
|
||||
uiMenuItem *head= uiPupMenuBegin("Add Object");
|
||||
|
||||
uiMenuLevelEnumO(head, "OBJECT_OT_mesh_add", "primtype");
|
||||
uiMenuLevelEnumO(head, "OBJECT_OT_curve_add", "primtype");
|
||||
uiMenuLevelEnumO(head, "OBJECT_OT_mesh_add", "type");
|
||||
uiMenuLevelEnumO(head, "OBJECT_OT_curve_add", "type");
|
||||
uiMenuItemEnumO(head, "OBJECT_OT_object_add", "type", OB_SURF);
|
||||
uiMenuItemEnumO(head, "OBJECT_OT_object_add", "type", OB_MBALL);
|
||||
uiMenuItemEnumO(head, "OBJECT_OT_object_add", "type", OB_CAMERA);
|
||||
@@ -473,7 +486,7 @@ static int object_add_primitive_invoke(bContext *C, wmOperator *op, wmEvent *eve
|
||||
uiMenuItemEnumO(head, "OBJECT_OT_object_add", "type", OB_ARMATURE);
|
||||
uiMenuItemEnumO(head, "OBJECT_OT_object_add", "type", OB_LATTICE);
|
||||
|
||||
uiMenuEnd(C, head);
|
||||
uiPupMenuEnd(C, head);
|
||||
|
||||
/* this operator is only for a menu, not used further */
|
||||
return OPERATOR_CANCELLED;
|
||||
@@ -597,7 +610,7 @@ static void copy_object_set_idnew(Scene *scene, View3D *v3d, int dupflag)
|
||||
#endif // XXX old animation system
|
||||
int a;
|
||||
|
||||
/* check object pointers */
|
||||
/* XXX check object pointers */
|
||||
for(base= FIRSTBASE; base; base= base->next) {
|
||||
if(TESTBASELIB(v3d, base)) {
|
||||
ob= base->object;
|
||||
@@ -2404,7 +2417,7 @@ static int make_parent_exec(bContext *C, wmOperator *op)
|
||||
DAG_scene_sort(CTX_data_scene(C));
|
||||
ED_anim_dag_flush_update(C);
|
||||
|
||||
BIF_undo_push("make Parent");
|
||||
ED_undo_push(C,"make Parent");
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -2412,31 +2425,26 @@ static int make_parent_exec(bContext *C, wmOperator *op)
|
||||
static int make_parent_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
||||
{
|
||||
Object *ob= CTX_data_active_object(C);
|
||||
char *str, string[256];
|
||||
char formatstr[] = "|%s %%x%d";
|
||||
uiMenuItem *head= uiPupMenuBegin("Make Parent To");
|
||||
|
||||
str= string + sprintf(string, "Make Parent To %%t");
|
||||
uiMenuContext(head, WM_OP_EXEC_DEFAULT);
|
||||
uiMenuItemEnumO(head, "OBJECT_OT_make_parent", "type", PAR_OBJECT);
|
||||
|
||||
/* ob becomes parent, make the associated menus */
|
||||
if(ob->type==OB_ARMATURE) {
|
||||
str += sprintf(str, formatstr, "Object", PAR_OBJECT);
|
||||
str += sprintf(str, formatstr, "Armature Deform", PAR_ARMATURE);
|
||||
str += sprintf(str, formatstr, "Bone", PAR_BONE);
|
||||
uiMenuItemEnumO(head, "OBJECT_OT_make_parent", "type", PAR_ARMATURE);
|
||||
uiMenuItemEnumO(head, "OBJECT_OT_make_parent", "type", PAR_BONE);
|
||||
}
|
||||
else if(ob->type==OB_CURVE) {
|
||||
str += sprintf(str, formatstr, "Object", PAR_OBJECT);
|
||||
str += sprintf(str, formatstr, "Curve Deform", PAR_CURVE);
|
||||
str += sprintf(str, formatstr, "Follow Path", PAR_FOLLOW);
|
||||
str += sprintf(str, formatstr, "Path Constraint", PAR_PATH_CONST);
|
||||
uiMenuItemEnumO(head, "OBJECT_OT_make_parent", "type", PAR_CURVE);
|
||||
uiMenuItemEnumO(head, "OBJECT_OT_make_parent", "type", PAR_FOLLOW);
|
||||
uiMenuItemEnumO(head, "OBJECT_OT_make_parent", "type", PAR_PATH_CONST);
|
||||
}
|
||||
else if(ob->type == OB_LATTICE) {
|
||||
str += sprintf(str, formatstr, "Object", PAR_OBJECT);
|
||||
str += sprintf(str, formatstr, "Lattice Deform", PAR_LATTICE);
|
||||
uiMenuItemEnumO(head, "OBJECT_OT_make_parent", "type", PAR_LATTICE);
|
||||
}
|
||||
else
|
||||
str += sprintf(str, formatstr, "Object", PAR_OBJECT);
|
||||
|
||||
uiPupmenuOperator(C, 0, op, "type", string);
|
||||
uiPupMenuEnd(C, head);
|
||||
|
||||
return OPERATOR_RUNNING_MODAL;
|
||||
}
|
||||
@@ -5750,95 +5758,85 @@ void make_local_menu(Scene *scene, View3D *v3d)
|
||||
U.dupflag for default operations or you can construct a flag as python does
|
||||
if the dupflag is 0 then no data will be copied (linked duplicate) */
|
||||
|
||||
static int add_duplicate_exec(bContext *C, wmOperator *op)
|
||||
/* used below, assumes id.new is correct */
|
||||
/* leaves selection of base/object unaltered */
|
||||
static Base *object_add_duplicate_internal(Scene *scene, Base *base, int dupflag)
|
||||
{
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
View3D *v3d= CTX_wm_view3d(C);
|
||||
Base *basen;
|
||||
Base *basen= NULL;
|
||||
Material ***matarar;
|
||||
Object *ob, *obn;
|
||||
ID *id;
|
||||
int dupflag= U.dupflag;
|
||||
int a, didit;
|
||||
|
||||
clear_id_newpoins();
|
||||
clear_sca_new_poins(); /* sensor/contr/act */
|
||||
|
||||
CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) {
|
||||
|
||||
ob= base->object;
|
||||
if(ob->flag & OB_POSEMODE) {
|
||||
; /* nothing? */
|
||||
}
|
||||
else {
|
||||
obn= copy_object(ob);
|
||||
obn->recalc |= OB_RECALC;
|
||||
|
||||
basen= MEM_mallocN(sizeof(Base), "duplibase");
|
||||
*basen= *base;
|
||||
BLI_addhead(&scene->base, basen); /* addhead: prevent eternal loop */
|
||||
basen->object= obn;
|
||||
base->flag &= ~SELECT;
|
||||
|
||||
if(basen->flag & OB_FROMGROUP) {
|
||||
Group *group;
|
||||
for(group= G.main->group.first; group; group= group->id.next) {
|
||||
if(object_in_group(ob, group))
|
||||
add_to_group(group, obn);
|
||||
}
|
||||
obn->flag |= OB_FROMGROUP; /* this flag is unset with copy_object() */
|
||||
}
|
||||
|
||||
if(BASACT==base)
|
||||
ED_base_object_activate(C, basen);
|
||||
|
||||
/* duplicates using userflags */
|
||||
ob= base->object;
|
||||
if(ob->flag & OB_POSEMODE) {
|
||||
; /* nothing? */
|
||||
}
|
||||
else {
|
||||
obn= copy_object(ob);
|
||||
obn->recalc |= OB_RECALC;
|
||||
|
||||
basen= MEM_mallocN(sizeof(Base), "duplibase");
|
||||
*basen= *base;
|
||||
BLI_addhead(&scene->base, basen); /* addhead: prevent eternal loop */
|
||||
basen->object= obn;
|
||||
|
||||
if(basen->flag & OB_FROMGROUP) {
|
||||
Group *group;
|
||||
for(group= G.main->group.first; group; group= group->id.next) {
|
||||
if(object_in_group(ob, group))
|
||||
add_to_group(group, obn);
|
||||
}
|
||||
obn->flag |= OB_FROMGROUP; /* this flag is unset with copy_object() */
|
||||
}
|
||||
|
||||
/* duplicates using userflags */
|
||||
#if 0 // XXX old animation system
|
||||
if(dupflag & USER_DUP_IPO) {
|
||||
bConstraintChannel *chan;
|
||||
id= (ID *)obn->ipo;
|
||||
|
||||
if(dupflag & USER_DUP_IPO) {
|
||||
bConstraintChannel *chan;
|
||||
id= (ID *)obn->ipo;
|
||||
|
||||
if(id) {
|
||||
ID_NEW_US( obn->ipo)
|
||||
else obn->ipo= copy_ipo(obn->ipo);
|
||||
id->us--;
|
||||
}
|
||||
/* Handle constraint ipos */
|
||||
for (chan=obn->constraintChannels.first; chan; chan=chan->next){
|
||||
id= (ID *)chan->ipo;
|
||||
if(id) {
|
||||
ID_NEW_US( obn->ipo)
|
||||
else obn->ipo= copy_ipo(obn->ipo);
|
||||
id->us--;
|
||||
}
|
||||
/* Handle constraint ipos */
|
||||
for (chan=obn->constraintChannels.first; chan; chan=chan->next){
|
||||
id= (ID *)chan->ipo;
|
||||
if(id) {
|
||||
ID_NEW_US( chan->ipo)
|
||||
else chan->ipo= copy_ipo(chan->ipo);
|
||||
id->us--;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(dupflag & USER_DUP_ACT){ /* Not buttons in the UI to modify this, add later? */
|
||||
id= (ID *)obn->action;
|
||||
if (id){
|
||||
ID_NEW_US(obn->action)
|
||||
else{
|
||||
obn->action= copy_action(obn->action);
|
||||
}
|
||||
ID_NEW_US( chan->ipo)
|
||||
else chan->ipo= copy_ipo(chan->ipo);
|
||||
id->us--;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(dupflag & USER_DUP_ACT){ /* Not buttons in the UI to modify this, add later? */
|
||||
id= (ID *)obn->action;
|
||||
if (id){
|
||||
ID_NEW_US(obn->action)
|
||||
else{
|
||||
obn->action= copy_action(obn->action);
|
||||
}
|
||||
id->us--;
|
||||
}
|
||||
}
|
||||
#endif // XXX old animation system
|
||||
if(dupflag & USER_DUP_MAT) {
|
||||
for(a=0; a<obn->totcol; a++) {
|
||||
id= (ID *)obn->mat[a];
|
||||
if(id) {
|
||||
ID_NEW_US(obn->mat[a])
|
||||
else obn->mat[a]= copy_material(obn->mat[a]);
|
||||
id->us--;
|
||||
}
|
||||
if(dupflag & USER_DUP_MAT) {
|
||||
for(a=0; a<obn->totcol; a++) {
|
||||
id= (ID *)obn->mat[a];
|
||||
if(id) {
|
||||
ID_NEW_US(obn->mat[a])
|
||||
else obn->mat[a]= copy_material(obn->mat[a]);
|
||||
id->us--;
|
||||
}
|
||||
}
|
||||
|
||||
id= obn->data;
|
||||
didit= 0;
|
||||
|
||||
switch(obn->type) {
|
||||
}
|
||||
|
||||
id= obn->data;
|
||||
didit= 0;
|
||||
|
||||
switch(obn->type) {
|
||||
case OB_MESH:
|
||||
if(dupflag & USER_DUP_MESH) {
|
||||
ID_NEW_US2( obn->data )
|
||||
@@ -5846,7 +5844,7 @@ static int add_duplicate_exec(bContext *C, wmOperator *op)
|
||||
obn->data= copy_mesh(obn->data);
|
||||
|
||||
if(obn->fluidsimSettings) {
|
||||
obn->fluidsimSettings->orgMesh = (Mesh *)obn->data;
|
||||
obn->fluidsimSettings->orgMesh = (Mesh *)obn->data;
|
||||
}
|
||||
|
||||
didit= 1;
|
||||
@@ -5901,22 +5899,22 @@ static int add_duplicate_exec(bContext *C, wmOperator *op)
|
||||
id->us--;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case OB_ARMATURE:
|
||||
obn->recalc |= OB_RECALC_DATA;
|
||||
if(obn->pose) obn->pose->flag |= POSE_RECALC;
|
||||
|
||||
if(dupflag & USER_DUP_ARM) {
|
||||
ID_NEW_US2(obn->data )
|
||||
else {
|
||||
obn->data= copy_armature(obn->data);
|
||||
armature_rebuild_pose(obn, obn->data);
|
||||
didit= 1;
|
||||
|
||||
if(dupflag & USER_DUP_ARM) {
|
||||
ID_NEW_US2(obn->data )
|
||||
else {
|
||||
obn->data= copy_armature(obn->data);
|
||||
armature_rebuild_pose(obn, obn->data);
|
||||
didit= 1;
|
||||
}
|
||||
id->us--;
|
||||
}
|
||||
id->us--;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
break;
|
||||
|
||||
case OB_LATTICE:
|
||||
if(dupflag!=0) {
|
||||
@@ -5932,26 +5930,66 @@ static int add_duplicate_exec(bContext *C, wmOperator *op)
|
||||
id->us--;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if(dupflag & USER_DUP_MAT) {
|
||||
matarar= give_matarar(obn);
|
||||
if(didit && matarar) {
|
||||
for(a=0; a<obn->totcol; a++) {
|
||||
id= (ID *)(*matarar)[a];
|
||||
if(id) {
|
||||
ID_NEW_US( (*matarar)[a] )
|
||||
else (*matarar)[a]= copy_material((*matarar)[a]);
|
||||
|
||||
id->us--;
|
||||
}
|
||||
}
|
||||
|
||||
if(dupflag & USER_DUP_MAT) {
|
||||
matarar= give_matarar(obn);
|
||||
if(didit && matarar) {
|
||||
for(a=0; a<obn->totcol; a++) {
|
||||
id= (ID *)(*matarar)[a];
|
||||
if(id) {
|
||||
ID_NEW_US( (*matarar)[a] )
|
||||
else (*matarar)[a]= copy_material((*matarar)[a]);
|
||||
|
||||
id->us--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return basen;
|
||||
}
|
||||
|
||||
/* single object duplicate, if dupflag==0, fully linked, else it uses U.dupflag */
|
||||
/* leaves selection of base/object unaltered */
|
||||
Base *ED_object_add_duplicate(Scene *scene, Base *base, int usedupflag)
|
||||
{
|
||||
Base *basen;
|
||||
int dupflag= usedupflag?U.dupflag:0;
|
||||
|
||||
clear_id_newpoins();
|
||||
clear_sca_new_poins(); /* sensor/contr/act */
|
||||
|
||||
basen= object_add_duplicate_internal(scene, base, dupflag);
|
||||
|
||||
DAG_scene_sort(scene);
|
||||
|
||||
return basen;
|
||||
}
|
||||
|
||||
/* contextual operator dupli */
|
||||
static int add_duplicate_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
View3D *v3d= CTX_wm_view3d(C);
|
||||
int dupflag= U.dupflag;
|
||||
|
||||
clear_id_newpoins();
|
||||
clear_sca_new_poins(); /* sensor/contr/act */
|
||||
|
||||
CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) {
|
||||
Base *basen= object_add_duplicate_internal(scene, base, dupflag);
|
||||
|
||||
/* XXX context conflict maybe, itterator could solve this? */
|
||||
ED_base_object_select(base, BA_DESELECT);
|
||||
/* new object becomes active */
|
||||
if(BASACT==base)
|
||||
ED_base_object_activate(C, basen);
|
||||
|
||||
}
|
||||
CTX_DATA_END;
|
||||
|
||||
/* XXX fix this for context */
|
||||
copy_object_set_idnew(scene, v3d, dupflag);
|
||||
|
||||
DAG_scene_sort(scene);
|
||||
|
||||
@@ -1060,13 +1060,6 @@ static void shader_preview_free(void *customdata)
|
||||
MEM_freeN(sp);
|
||||
}
|
||||
|
||||
static void shader_preview_update(void *customdata)
|
||||
{
|
||||
// ShaderPreview *sp= customdata;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void ED_preview_shader_job(const bContext *C, void *owner, ID *id, int sizex, int sizey)
|
||||
{
|
||||
wmJob *steve= WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), owner);
|
||||
@@ -1082,8 +1075,8 @@ void ED_preview_shader_job(const bContext *C, void *owner, ID *id, int sizex, in
|
||||
|
||||
/* setup job */
|
||||
WM_jobs_customdata(steve, sp, shader_preview_free);
|
||||
WM_jobs_timer(steve, 0.1, NC_MATERIAL);
|
||||
WM_jobs_callbacks(steve, shader_preview_startjob, shader_preview_update);
|
||||
WM_jobs_timer(steve, 0.1, NC_MATERIAL, NC_MATERIAL);
|
||||
WM_jobs_callbacks(steve, shader_preview_startjob, NULL, NULL);
|
||||
|
||||
WM_jobs_start(steve);
|
||||
}
|
||||
|
||||
@@ -764,8 +764,8 @@ static char *windowtype_pup(void)
|
||||
|
||||
"|%l" // 33
|
||||
|
||||
"|Ipo Curve Editor %x2" //54
|
||||
"|Action Editor %x12" //73
|
||||
"|Graph Editor %x2" //54
|
||||
"|DopeSheet Editor %x12" //73
|
||||
"|NLA Editor %x13" //94
|
||||
|
||||
"|%l" //97
|
||||
|
||||
@@ -1359,7 +1359,7 @@ static int repeat_history_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
||||
for (i=items-1, lastop= wm->operators.last; lastop; lastop= lastop->prev, i--)
|
||||
p+= sprintf(p, "|%s %%x%d", lastop->type->name, i);
|
||||
|
||||
uiPupmenuOperator(C, i/20, op, "index", menu);
|
||||
uiPupMenuOperator(C, i/20, op, "index", menu);
|
||||
MEM_freeN(menu);
|
||||
|
||||
return OPERATOR_RUNNING_MODAL;
|
||||
@@ -1559,7 +1559,7 @@ static void testfunc(bContext *C, void *argv, int arg)
|
||||
printf("arg %d\n", arg);
|
||||
}
|
||||
|
||||
static void newlevel1(uiMenuItem *head)
|
||||
static void newlevel1(bContext *C, uiMenuItem *head, void *arg)
|
||||
{
|
||||
uiMenuFunc(head, testfunc, NULL);
|
||||
|
||||
@@ -1571,7 +1571,7 @@ static void newlevel1(uiMenuItem *head)
|
||||
|
||||
static int testing123(bContext *C, wmOperator *op, wmEvent *event)
|
||||
{
|
||||
uiMenuItem *head= uiMenuBegin("Hello world");
|
||||
uiMenuItem *head= uiPupMenuBegin("Hello world");
|
||||
|
||||
uiMenuContext(head, WM_OP_EXEC_DEFAULT);
|
||||
uiMenuItemO(head, "SCREEN_OT_region_flip", ICON_PROP_ON);
|
||||
@@ -1580,7 +1580,7 @@ static int testing123(bContext *C, wmOperator *op, wmEvent *event)
|
||||
uiMenuLevel(head, "Submenu", newlevel1);
|
||||
uiMenuItemO(head, "SCREEN_OT_area_rip", ICON_PROP_ON);
|
||||
|
||||
uiMenuEnd(C, head);
|
||||
uiPupMenuEnd(C, head);
|
||||
|
||||
/* this operator is only for a menu, not used further */
|
||||
return OPERATOR_CANCELLED;
|
||||
@@ -1760,6 +1760,10 @@ void ED_keymap_screen(wmWindowManager *wm)
|
||||
WM_keymap_verify_item(keymap, "SCREEN_OT_repeat_last", F4KEY, KM_PRESS, 0, 0);
|
||||
WM_keymap_add_item(keymap, "SCREEN_OT_region_flip", F5KEY, KM_PRESS, 0, 0);
|
||||
|
||||
/* files */
|
||||
WM_keymap_add_item(keymap, "ED_FILE_OT_load", RETKEY, KM_PRESS, 0, 0);
|
||||
WM_keymap_add_item(keymap, "ED_FILE_OT_cancel", ESCKEY, KM_PRESS, 0, 0);
|
||||
|
||||
/* undo */
|
||||
WM_keymap_add_item(keymap, "ED_OT_undo", ZKEY, KM_PRESS, KM_CTRL, 0);
|
||||
WM_keymap_add_item(keymap, "ED_OT_undo", ZKEY, KM_PRESS, KM_OSKEY, 0);
|
||||
|
||||
@@ -145,13 +145,6 @@ typedef struct StrokeCache {
|
||||
ViewContext vc;
|
||||
bglMats *mats;
|
||||
|
||||
/* Mesh data (not copied) can come either directly from a Mesh, or from a MultiresDM */
|
||||
int multires; /* Special handling for multires meshes */
|
||||
MVert *mvert;
|
||||
MFace *mface;
|
||||
int totvert, totface;
|
||||
float *face_normals;
|
||||
|
||||
float *layer_disps; /* Displacements for each vertex */
|
||||
float (*mesh_store)[3]; /* Copy of the mesh vertices' locations */
|
||||
short (*orig_norms)[3]; /* Copy of the mesh vertices' normals */
|
||||
@@ -331,7 +324,7 @@ static void calc_area_normal(Sculpt *sd, float out[3], const ListBase* active_ve
|
||||
}
|
||||
else {
|
||||
for(; node; node = node->next)
|
||||
add_norm_if(out_dir, out, out_flip, cache->mvert[node->Index].no);
|
||||
add_norm_if(out_dir, out, out_flip, sd->session->mvert[node->Index].no);
|
||||
}
|
||||
|
||||
if (out[0]==0.0 && out[1]==0.0 && out[2]==0.0) {
|
||||
@@ -359,7 +352,7 @@ static void do_draw_brush(Sculpt *sd, SculptSession *ss, const ListBase* active_
|
||||
sculpt_axislock(sd, area_normal);
|
||||
|
||||
while(node){
|
||||
float *co= ss->cache->mvert[node->Index].co;
|
||||
float *co= ss->mvert[node->Index].co;
|
||||
|
||||
const float val[3]= {co[0]+area_normal[0]*node->Fade*ss->cache->scale[0],
|
||||
co[1]+area_normal[1]*node->Fade*ss->cache->scale[1],
|
||||
@@ -385,12 +378,12 @@ static void neighbor_average(SculptSession *ss, float avg[3], const int vert)
|
||||
|
||||
/* Don't modify corner vertices */
|
||||
if(ncount==1) {
|
||||
VecCopyf(avg, ss->cache->mvert[vert].co);
|
||||
VecCopyf(avg, ss->mvert[vert].co);
|
||||
return;
|
||||
}
|
||||
|
||||
while(node){
|
||||
f= &ss->cache->mface[node->index];
|
||||
f= &ss->mface[node->index];
|
||||
|
||||
if(f->v4) {
|
||||
skip= (f->v1==vert?2:
|
||||
@@ -401,7 +394,7 @@ static void neighbor_average(SculptSession *ss, float avg[3], const int vert)
|
||||
|
||||
for(i=0; i<(f->v4?4:3); ++i) {
|
||||
if(i != skip && (ncount!=2 || BLI_countlist(&ss->fmap[(&f->v1)[i]]) <= 2)) {
|
||||
VecAddf(avg, avg, ss->cache->mvert[(&f->v1)[i]].co);
|
||||
VecAddf(avg, avg, ss->mvert[(&f->v1)[i]].co);
|
||||
++total;
|
||||
}
|
||||
}
|
||||
@@ -412,7 +405,7 @@ static void neighbor_average(SculptSession *ss, float avg[3], const int vert)
|
||||
if(total>0)
|
||||
VecMulf(avg, 1.0f / total);
|
||||
else
|
||||
VecCopyf(avg, ss->cache->mvert[vert].co);
|
||||
VecCopyf(avg, ss->mvert[vert].co);
|
||||
}
|
||||
|
||||
static void do_smooth_brush(SculptSession *ss, const ListBase* active_verts)
|
||||
@@ -420,7 +413,7 @@ static void do_smooth_brush(SculptSession *ss, const ListBase* active_verts)
|
||||
ActiveData *node= active_verts->first;
|
||||
|
||||
while(node){
|
||||
float *co= ss->cache->mvert[node->Index].co;
|
||||
float *co= ss->mvert[node->Index].co;
|
||||
float avg[3], val[3];
|
||||
|
||||
neighbor_average(ss, avg, node->Index);
|
||||
@@ -438,7 +431,7 @@ static void do_pinch_brush(SculptSession *ss, const ListBase* active_verts)
|
||||
ActiveData *node= active_verts->first;
|
||||
|
||||
while(node) {
|
||||
float *co= ss->cache->mvert[node->Index].co;
|
||||
float *co= ss->mvert[node->Index].co;
|
||||
const float val[3]= {co[0]+(ss->cache->location[0]-co[0])*node->Fade,
|
||||
co[1]+(ss->cache->location[1]-co[1])*node->Fade,
|
||||
co[2]+(ss->cache->location[2]-co[2])*node->Fade};
|
||||
@@ -457,7 +450,7 @@ static void do_grab_brush(Sculpt *sd, SculptSession *ss)
|
||||
sculpt_axislock(sd, grab_delta);
|
||||
|
||||
while(node) {
|
||||
float *co= ss->cache->mvert[node->Index].co;
|
||||
float *co= ss->mvert[node->Index].co;
|
||||
|
||||
VecCopyf(add, grab_delta);
|
||||
VecMulf(add, node->Fade);
|
||||
@@ -482,7 +475,7 @@ static void do_layer_brush(Sculpt *sd, SculptSession *ss, const ListBase *active
|
||||
|
||||
if((bstr > 0 && *disp < bstr) ||
|
||||
(bstr < 0 && *disp > bstr)) {
|
||||
float *co= ss->cache->mvert[node->Index].co;
|
||||
float *co= ss->mvert[node->Index].co;
|
||||
|
||||
*disp+= node->Fade;
|
||||
|
||||
@@ -512,8 +505,8 @@ static void do_inflate_brush(SculptSession *ss, const ListBase *active_verts)
|
||||
float add[3];
|
||||
|
||||
while(node) {
|
||||
float *co= ss->cache->mvert[node->Index].co;
|
||||
short *no= ss->cache->mvert[node->Index].no;
|
||||
float *co= ss->mvert[node->Index].co;
|
||||
short *no= ss->mvert[node->Index].no;
|
||||
|
||||
add[0]= no[0]/ 32767.0f;
|
||||
add[1]= no[1]/ 32767.0f;
|
||||
@@ -549,7 +542,7 @@ static void calc_flatten_center(SculptSession *ss, ActiveData *node, float co[3]
|
||||
|
||||
co[0] = co[1] = co[2] = 0.0f;
|
||||
for(i = 0; i < FLATTEN_SAMPLE_SIZE; ++i)
|
||||
VecAddf(co, co, ss->cache->mvert[outer[i]->Index].co);
|
||||
VecAddf(co, co, ss->mvert[outer[i]->Index].co);
|
||||
VecMulf(co, 1.0f / FLATTEN_SAMPLE_SIZE);
|
||||
}
|
||||
|
||||
@@ -564,7 +557,7 @@ static void do_flatten_brush(Sculpt *sd, SculptSession *ss, const ListBase *acti
|
||||
calc_flatten_center(ss, node, cntr);
|
||||
|
||||
while(node){
|
||||
float *co= ss->cache->mvert[node->Index].co;
|
||||
float *co= ss->mvert[node->Index].co;
|
||||
float p1[3], sub1[3], sub2[3], intr[3], val[3];
|
||||
|
||||
/* Find the intersection between squash-plane and vertex (along the area normal) */
|
||||
@@ -743,7 +736,7 @@ static void sculpt_add_damaged_rect(SculptSession *ss)
|
||||
BLI_addtail(&ss->damaged_rects, rn);
|
||||
|
||||
/* Update insides */
|
||||
for(i=0; i<ss->cache->totvert; ++i) {
|
||||
for(i=0; i<ss->totvert; ++i) {
|
||||
if(!ss->projverts[i].inside) {
|
||||
if(ss->projverts[i].co[0] > rn->r.xmin && ss->projverts[i].co[1] > rn->r.ymin &&
|
||||
ss->projverts[i].co[0] < rn->r.xmax && ss->projverts[i].co[1] < rn->r.ymax) {
|
||||
@@ -757,6 +750,7 @@ static void sculpt_add_damaged_rect(SculptSession *ss)
|
||||
}
|
||||
|
||||
/* Clears the depth buffer in each modified area. */
|
||||
#if 0
|
||||
static void sculpt_clear_damaged_areas(SculptSession *ss)
|
||||
{
|
||||
RectNode *rn= NULL;
|
||||
@@ -785,7 +779,7 @@ static void sculpt_clear_damaged_areas(SculptSession *ss)
|
||||
glClear(GL_DEPTH_BUFFER_BIT);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
static void do_brush_action(Sculpt *sd, StrokeCache *cache)
|
||||
{
|
||||
SculptSession *ss = sd->session;
|
||||
@@ -805,11 +799,11 @@ static void do_brush_action(Sculpt *sd, StrokeCache *cache)
|
||||
/* Build a list of all vertices that are potentially within the brush's
|
||||
area of influence. Only do this once for the grab brush. */
|
||||
if((b->sculpt_tool != SCULPT_TOOL_GRAB) || cache->first_time) {
|
||||
for(i=0; i<cache->totvert; ++i) {
|
||||
for(i=0; i<ss->totvert; ++i) {
|
||||
/* Projverts.inside provides a rough bounding box */
|
||||
if(cache->multires || ss->projverts[i].inside) {
|
||||
if(ss->multires || ss->projverts[i].inside) {
|
||||
//vert= ss->vertexcosnos ? &ss->vertexcosnos[i*6] : a->verts[i].co;
|
||||
vert= cache->mvert[i].co;
|
||||
vert= ss->mvert[i].co;
|
||||
av_dist= VecLenf(ss->cache->location, vert);
|
||||
if(av_dist < cache->radius) {
|
||||
adata= (ActiveData*)MEM_mallocN(sizeof(ActiveData), "ActiveData");
|
||||
@@ -857,7 +851,7 @@ static void do_brush_action(Sculpt *sd, StrokeCache *cache)
|
||||
}
|
||||
|
||||
/* Copy the modified vertices from mesh to the active key */
|
||||
if(keyblock && !cache->multires) {
|
||||
if(keyblock && !ss->multires) {
|
||||
float *co= keyblock->data;
|
||||
if(co) {
|
||||
if(b->sculpt_tool == SCULPT_TOOL_GRAB)
|
||||
@@ -871,7 +865,7 @@ static void do_brush_action(Sculpt *sd, StrokeCache *cache)
|
||||
}
|
||||
}
|
||||
|
||||
if(ss->vertexcosnos && !cache->multires)
|
||||
if(ss->vertexcosnos && !ss->multires)
|
||||
BLI_freelistN(&active_verts);
|
||||
else {
|
||||
if(b->sculpt_tool != SCULPT_TOOL_GRAB)
|
||||
@@ -952,16 +946,16 @@ static void update_damaged_vert(SculptSession *ss, ListBase *lb)
|
||||
|
||||
while(face){
|
||||
float *fn = NULL;
|
||||
if(ss->cache->face_normals)
|
||||
fn = &ss->cache->face_normals[face->index*3];
|
||||
add_face_normal(&norm, ss->cache->mvert, &ss->cache->mface[face->index], fn);
|
||||
if(ss->face_normals)
|
||||
fn = &ss->face_normals[face->index*3];
|
||||
add_face_normal(&norm, ss->mvert, &ss->mface[face->index], fn);
|
||||
face= face->next;
|
||||
}
|
||||
Normalize(&norm.x);
|
||||
|
||||
ss->cache->mvert[vert->Index].no[0]=norm.x*32767;
|
||||
ss->cache->mvert[vert->Index].no[1]=norm.y*32767;
|
||||
ss->cache->mvert[vert->Index].no[2]=norm.z*32767;
|
||||
ss->mvert[vert->Index].no[0]=norm.x*32767;
|
||||
ss->mvert[vert->Index].no[1]=norm.y*32767;
|
||||
ss->mvert[vert->Index].no[2]=norm.z*32767;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -971,18 +965,19 @@ static void calc_damaged_verts(SculptSession *ss)
|
||||
|
||||
for(i=0; i<8; ++i)
|
||||
update_damaged_vert(ss, &ss->cache->grab_active_verts[i]);
|
||||
|
||||
update_damaged_vert(ss, &ss->damaged_verts);
|
||||
BLI_freelistN(&ss->damaged_verts);
|
||||
ss->damaged_verts.first = ss->damaged_verts.last = NULL;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void projverts_clear_inside(SculptSession *ss)
|
||||
{
|
||||
int i;
|
||||
for(i = 0; i < ss->cache->totvert; ++i)
|
||||
for(i = 0; i < ss->totvert; ++i)
|
||||
ss->projverts[i].inside = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void sculpt_update_tex(Sculpt *sd)
|
||||
{
|
||||
@@ -1027,10 +1022,10 @@ static void sculptmode_update_all_projverts(SculptSession *ss)
|
||||
unsigned i;
|
||||
|
||||
if(!ss->projverts)
|
||||
ss->projverts = MEM_mallocN(sizeof(ProjVert)*ss->cache->totvert,"ProjVerts");
|
||||
ss->projverts = MEM_mallocN(sizeof(ProjVert)*ss->totvert,"ProjVerts");
|
||||
|
||||
for(i=0; i<ss->cache->totvert; ++i) {
|
||||
project(ss->cache->mats, ss->vertexcosnos ? &ss->vertexcosnos[i * 6] : ss->cache->mvert[i].co,
|
||||
for(i=0; i<ss->totvert; ++i) {
|
||||
project(ss->cache->mats, ss->vertexcosnos ? &ss->vertexcosnos[i * 6] : ss->mvert[i].co,
|
||||
ss->projverts[i].co);
|
||||
ss->projverts[i].inside= 0;
|
||||
}
|
||||
@@ -1066,32 +1061,31 @@ static struct MultiresModifierData *sculpt_multires_active(Object *ob)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void sculpt_update_mesh_elements(SculptSession *ss, Object *ob)
|
||||
static void sculpt_update_mesh_elements(bContext *C)
|
||||
{
|
||||
StrokeCache *cache = ss->cache;
|
||||
SculptSession *ss = CTX_data_tool_settings(C)->sculpt->session;
|
||||
Object *ob = CTX_data_active_object(C);
|
||||
|
||||
if(sculpt_multires_active(ob)) {
|
||||
DerivedMesh *dm = mesh_get_derived_final(NULL, ob, CD_MASK_BAREMESH); /* XXX scene=? */
|
||||
cache->multires = 1;
|
||||
cache->totvert = dm->getNumVerts(dm);
|
||||
cache->totface = dm->getNumFaces(dm);
|
||||
cache->mvert = dm->getVertDataArray(dm, CD_MVERT);
|
||||
cache->mface = dm->getFaceDataArray(dm, CD_MFACE);
|
||||
cache->face_normals = dm->getFaceDataArray(dm, CD_NORMAL);
|
||||
if((ss->multires = sculpt_multires_active(ob))) {
|
||||
DerivedMesh *dm = mesh_get_derived_final(CTX_data_scene(C), ob, CD_MASK_BAREMESH);
|
||||
ss->totvert = dm->getNumVerts(dm);
|
||||
ss->totface = dm->getNumFaces(dm);
|
||||
ss->mvert = dm->getVertDataArray(dm, CD_MVERT);
|
||||
ss->mface = dm->getFaceDataArray(dm, CD_MFACE);
|
||||
ss->face_normals = dm->getFaceDataArray(dm, CD_NORMAL);
|
||||
}
|
||||
else {
|
||||
Mesh *me = get_mesh(ob);
|
||||
cache->multires = 0;
|
||||
cache->totvert = me->totvert;
|
||||
cache->totface = me->totface;
|
||||
cache->mvert = me->mvert;
|
||||
cache->mface = me->mface;
|
||||
cache->face_normals = NULL;
|
||||
ss->totvert = me->totvert;
|
||||
ss->totface = me->totface;
|
||||
ss->mvert = me->mvert;
|
||||
ss->mface = me->mface;
|
||||
ss->face_normals = NULL;
|
||||
}
|
||||
|
||||
if(cache->totvert != ss->fmap_size) {
|
||||
create_vert_face_map(&ss->fmap, &ss->fmap_mem, cache->mface, cache->totvert, cache->totface);
|
||||
ss->fmap_size = cache->totvert;
|
||||
if(ss->totvert != ss->fmap_size) {
|
||||
create_vert_face_map(&ss->fmap, &ss->fmap_mem, ss->mface, ss->totvert, ss->totface);
|
||||
ss->fmap_size = ss->totvert;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1343,21 +1337,21 @@ static void sculpt_update_cache_invariants(Sculpt *sd, bContext *C, wmOperator *
|
||||
cache->mats = MEM_callocN(sizeof(bglMats), "sculpt bglMats");
|
||||
sculpt_load_mats(cache->mats, &cache->vc);
|
||||
|
||||
sculpt_update_mesh_elements(sd->session, cache->vc.obact);
|
||||
sculpt_update_mesh_elements(C);
|
||||
|
||||
/* Make copies of the mesh vertex locations and normals for some tools */
|
||||
if(sd->brush->sculpt_tool == SCULPT_TOOL_LAYER || (sd->brush->flag & BRUSH_ANCHORED)) {
|
||||
cache->layer_disps = MEM_callocN(sizeof(float) * cache->totvert, "layer brush displacements");
|
||||
cache->mesh_store= MEM_mallocN(sizeof(float) * 3 * cache->totvert, "sculpt mesh vertices copy");
|
||||
for(i = 0; i < cache->totvert; ++i)
|
||||
VecCopyf(cache->mesh_store[i], cache->mvert[i].co);
|
||||
cache->layer_disps = MEM_callocN(sizeof(float) * sd->session->totvert, "layer brush displacements");
|
||||
cache->mesh_store= MEM_mallocN(sizeof(float) * 3 * sd->session->totvert, "sculpt mesh vertices copy");
|
||||
for(i = 0; i < sd->session->totvert; ++i)
|
||||
VecCopyf(cache->mesh_store[i], sd->session->mvert[i].co);
|
||||
|
||||
if(sd->brush->flag & BRUSH_ANCHORED) {
|
||||
cache->orig_norms= MEM_mallocN(sizeof(short) * 3 * cache->totvert, "Sculpt orig norm");
|
||||
for(i = 0; i < cache->totvert; ++i) {
|
||||
cache->orig_norms[i][0] = cache->mvert[i].no[0];
|
||||
cache->orig_norms[i][1] = cache->mvert[i].no[1];
|
||||
cache->orig_norms[i][2] = cache->mvert[i].no[2];
|
||||
cache->orig_norms= MEM_mallocN(sizeof(short) * 3 * sd->session->totvert, "Sculpt orig norm");
|
||||
for(i = 0; i < sd->session->totvert; ++i) {
|
||||
cache->orig_norms[i][0] = sd->session->mvert[i].no[0];
|
||||
cache->orig_norms[i][1] = sd->session->mvert[i].no[1];
|
||||
cache->orig_norms[i][2] = sd->session->mvert[i].no[2];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1490,22 +1484,40 @@ static void sculpt_restore_mesh(Sculpt *sd)
|
||||
|
||||
/* Restore the mesh before continuing with anchored stroke */
|
||||
if((sd->brush->flag & BRUSH_ANCHORED) && cache->mesh_store) {
|
||||
for(i = 0; i < cache->totvert; ++i) {
|
||||
VecCopyf(cache->mvert[i].co, cache->mesh_store[i]);
|
||||
cache->mvert[i].no[0] = cache->orig_norms[i][0];
|
||||
cache->mvert[i].no[1] = cache->orig_norms[i][1];
|
||||
cache->mvert[i].no[2] = cache->orig_norms[i][2];
|
||||
for(i = 0; i < sd->session->totvert; ++i) {
|
||||
VecCopyf(sd->session->mvert[i].co, cache->mesh_store[i]);
|
||||
sd->session->mvert[i].no[0] = cache->orig_norms[i][0];
|
||||
sd->session->mvert[i].no[1] = cache->orig_norms[i][1];
|
||||
sd->session->mvert[i].no[2] = cache->orig_norms[i][2];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void sculpt_post_stroke_free(SculptSession *ss)
|
||||
{
|
||||
//calc_damaged_verts(sd->session, &a);
|
||||
BLI_freelistN(&ss->damaged_rects);
|
||||
BLI_freelistN(&ss->damaged_verts);
|
||||
}
|
||||
|
||||
static void sculpt_flush_update(bContext *C)
|
||||
{
|
||||
Sculpt *s = CTX_data_tool_settings(C)->sculpt;
|
||||
ARegion *ar = CTX_wm_region(C);
|
||||
MultiresModifierData *mmd = s->session->multires;
|
||||
|
||||
calc_damaged_verts(s->session);
|
||||
|
||||
if(mmd) {
|
||||
if(mmd->undo_verts && mmd->undo_verts != s->session->mvert)
|
||||
MEM_freeN(mmd->undo_verts);
|
||||
|
||||
mmd->undo_verts = s->session->mvert;
|
||||
mmd->undo_verts_tot = s->session->totvert;
|
||||
}
|
||||
|
||||
ED_region_tag_redraw(ar);
|
||||
}
|
||||
|
||||
static int sculpt_brush_stroke_modal(bContext *C, wmOperator *op, wmEvent *event)
|
||||
{
|
||||
PointerRNA itemptr;
|
||||
@@ -1515,6 +1527,8 @@ static int sculpt_brush_stroke_modal(bContext *C, wmOperator *op, wmEvent *event
|
||||
float center[3];
|
||||
int mouse[2] = {event->x, event->y};
|
||||
|
||||
sculpt_update_mesh_elements(C);
|
||||
|
||||
unproject(sd->session->cache->mats, center, event->x, event->y,
|
||||
read_cached_depth(&sd->session->cache->vc, event->x, event->y));
|
||||
|
||||
@@ -1528,11 +1542,9 @@ static int sculpt_brush_stroke_modal(bContext *C, wmOperator *op, wmEvent *event
|
||||
sculpt_restore_mesh(sd);
|
||||
do_symmetrical_brush_actions(CTX_data_tool_settings(C)->sculpt, sd->session->cache);
|
||||
|
||||
sculpt_flush_update(C);
|
||||
sculpt_post_stroke_free(sd->session);
|
||||
|
||||
DAG_object_flush_update(CTX_data_scene(C), ob, OB_RECALC_DATA);
|
||||
ED_region_tag_redraw(ar);
|
||||
|
||||
/* Finished */
|
||||
if(event->type == LEFTMOUSE && event->val == 0) {
|
||||
request_depth_update(&sd->session->cache->vc);
|
||||
@@ -1549,8 +1561,6 @@ static int sculpt_brush_stroke_modal(bContext *C, wmOperator *op, wmEvent *event
|
||||
|
||||
static int sculpt_brush_stroke_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Object *ob= CTX_data_active_object(C);
|
||||
ARegion *ar = CTX_wm_region(C);
|
||||
Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
|
||||
|
||||
view3d_operator_needs_opengl(C);
|
||||
@@ -1570,8 +1580,7 @@ static int sculpt_brush_stroke_exec(bContext *C, wmOperator *op)
|
||||
|
||||
sculpt_cache_free(sd->session->cache);
|
||||
|
||||
DAG_object_flush_update(CTX_data_scene(C), ob, OB_RECALC_DATA);
|
||||
ED_region_tag_redraw(ar);
|
||||
sculpt_flush_update(C);
|
||||
|
||||
sculpt_undo_push(C, sd);
|
||||
|
||||
@@ -1655,11 +1664,14 @@ static int sculpt_toggle_mode(bContext *C, wmOperator *op)
|
||||
ts->sculpt->brush = add_brush("test brush");
|
||||
/* Also for testing, set the brush texture to the first available one */
|
||||
if(G.main->tex.first) {
|
||||
mtex = MEM_callocN(sizeof(MTex), "test mtex");
|
||||
ts->sculpt->brush->texact = 0;
|
||||
ts->sculpt->brush->mtex[0] = mtex;
|
||||
mtex->tex = G.main->tex.first;
|
||||
mtex->size[0] = mtex->size[1] = mtex->size[2] = 50;
|
||||
Tex *tex = G.main->tex.first;
|
||||
if(tex->type) {
|
||||
mtex = MEM_callocN(sizeof(MTex), "test mtex");
|
||||
ts->sculpt->brush->texact = 0;
|
||||
ts->sculpt->brush->mtex[0] = mtex;
|
||||
mtex->tex = tex;
|
||||
mtex->size[0] = mtex->size[1] = mtex->size[2] = 50;
|
||||
}
|
||||
}
|
||||
|
||||
ED_undo_push(C, "Enter sculpt");
|
||||
|
||||
@@ -627,6 +627,7 @@ void ACT_OT_keyframes_delete (wmOperatorType *ot)
|
||||
ot->idname= "ACT_OT_keyframes_delete";
|
||||
|
||||
/* api callbacks */
|
||||
ot->invoke= WM_operator_confirm;
|
||||
ot->exec= actkeys_delete_exec;
|
||||
ot->poll= ED_operator_areaactive;
|
||||
|
||||
@@ -825,8 +826,6 @@ void ACT_OT_keyframes_sample (wmOperatorType *ot)
|
||||
|
||||
/* ******************** Set Extrapolation-Type Operator *********************** */
|
||||
|
||||
// XXX rename this operator...
|
||||
|
||||
/* defines for set extrapolation-type for selected keyframes tool */
|
||||
EnumPropertyItem prop_actkeys_expo_types[] = {
|
||||
{FCURVE_EXTRAPOLATE_CONSTANT, "CONSTANT", "Constant Extrapolation", ""},
|
||||
@@ -883,11 +882,11 @@ static int actkeys_expo_exec(bContext *C, wmOperator *op)
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
void ACT_OT_keyframes_expotype (wmOperatorType *ot)
|
||||
void ACT_OT_keyframes_extrapolation_type (wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name= "Set Keyframe Extrapolation";
|
||||
ot->idname= "ACT_OT_keyframes_expotype";
|
||||
ot->idname= "ACT_OT_keyframes_extrapolation_type";
|
||||
|
||||
/* api callbacks */
|
||||
ot->invoke= WM_menu_invoke;
|
||||
@@ -961,11 +960,11 @@ static int actkeys_ipo_exec(bContext *C, wmOperator *op)
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
void ACT_OT_keyframes_ipotype (wmOperatorType *ot)
|
||||
void ACT_OT_keyframes_interpolation_type (wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name= "Set Keyframe Interpolation";
|
||||
ot->idname= "ACT_OT_keyframes_ipotype";
|
||||
ot->idname= "ACT_OT_keyframes_interpolation_type";
|
||||
|
||||
/* api callbacks */
|
||||
ot->invoke= WM_menu_invoke;
|
||||
|
||||
@@ -247,12 +247,12 @@ static void do_keymenu_transformmenu(bContext *C, void *arg, int event)
|
||||
}
|
||||
}
|
||||
|
||||
static uiBlock *action_keymenu_transformmenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused)
|
||||
static uiBlock *action_keymenu_transformmenu(bContext *C, ARegion *ar, void *arg_unused)
|
||||
{
|
||||
uiBlock *block;
|
||||
short yco= 0, menuwidth=120;
|
||||
|
||||
block= uiBeginBlock(C, handle->region, "action_keymenu_transformmenu", UI_EMBOSSP, UI_HELV);
|
||||
block= uiBeginBlock(C, ar, "action_keymenu_transformmenu", UI_EMBOSSP, UI_HELV);
|
||||
uiBlockSetButmFunc(block, do_keymenu_transformmenu, NULL);
|
||||
|
||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1,
|
||||
@@ -293,14 +293,14 @@ static void do_keymenu_snapmenu(bContext *C, void *arg, int event)
|
||||
}
|
||||
}
|
||||
|
||||
static uiBlock *action_keymenu_snapmenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused)
|
||||
static uiBlock *action_keymenu_snapmenu(bContext *C, ARegion *ar, void *arg_unused)
|
||||
{
|
||||
SpaceAction *saction= (SpaceAction*)CTX_wm_space_data(C);
|
||||
uiBlock *block;
|
||||
short yco= 0, menuwidth=120;
|
||||
|
||||
|
||||
block= uiBeginBlock(C, handle->region, "action_keymenu_snapmenu", UI_EMBOSSP, UI_HELV);
|
||||
block= uiBeginBlock(C, ar, "action_keymenu_snapmenu", UI_EMBOSSP, UI_HELV);
|
||||
uiBlockSetButmFunc(block, do_keymenu_snapmenu, NULL);
|
||||
|
||||
if (saction->flag & SACTION_DRAWTIME) {
|
||||
@@ -357,12 +357,12 @@ static void do_keymenu_mirrormenu(bContext *C, void *arg, int event)
|
||||
|
||||
}
|
||||
|
||||
static uiBlock *action_keymenu_mirrormenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused)
|
||||
static uiBlock *action_keymenu_mirrormenu(bContext *C, ARegion *ar, void *arg_unused)
|
||||
{
|
||||
uiBlock *block;
|
||||
short yco= 0, menuwidth=120;
|
||||
|
||||
block= uiBeginBlock(C, handle->region, "action_keymenu_mirrormenu", UI_EMBOSSP, UI_HELV);
|
||||
block= uiBeginBlock(C, ar, "action_keymenu_mirrormenu", UI_EMBOSSP, UI_HELV);
|
||||
uiBlockSetButmFunc(block, do_keymenu_mirrormenu, NULL);
|
||||
|
||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1,
|
||||
@@ -411,12 +411,12 @@ static void do_keymenu_handlemenu(bContext *C, void *arg, int event)
|
||||
}
|
||||
}
|
||||
|
||||
static uiBlock *action_keymenu_handlemenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused)
|
||||
static uiBlock *action_keymenu_handlemenu(bContext *C, ARegion *ar, void *arg_unused)
|
||||
{
|
||||
uiBlock *block;
|
||||
short yco= 0, menuwidth=120;
|
||||
|
||||
block= uiBeginBlock(C, handle->region, "action_keymenu_handlemenu", UI_EMBOSSP, UI_HELV);
|
||||
block= uiBeginBlock(C, ar, "action_keymenu_handlemenu", UI_EMBOSSP, UI_HELV);
|
||||
uiBlockSetButmFunc(block, do_keymenu_handlemenu, NULL);
|
||||
|
||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1,
|
||||
@@ -463,12 +463,12 @@ static void do_keymenu_extendmenu(bContext *C, void *arg, int event)
|
||||
}
|
||||
}
|
||||
|
||||
static uiBlock *action_keymenu_extendmenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused)
|
||||
static uiBlock *action_keymenu_extendmenu(bContext *C, ARegion *ar, void *arg_unused)
|
||||
{
|
||||
uiBlock *block;
|
||||
short yco= 0, menuwidth=120;
|
||||
|
||||
block= uiBeginBlock(C, handle->region, "action_keymenu_extendmenu", UI_EMBOSSP, UI_HELV);
|
||||
block= uiBeginBlock(C, ar, "action_keymenu_extendmenu", UI_EMBOSSP, UI_HELV);
|
||||
uiBlockSetButmFunc(block, do_keymenu_extendmenu, NULL);
|
||||
|
||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1,
|
||||
@@ -512,12 +512,12 @@ static void do_keymenu_intpolmenu(bContext *C, void *arg, int event)
|
||||
}
|
||||
}
|
||||
|
||||
static uiBlock *action_keymenu_intpolmenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused)
|
||||
static uiBlock *action_keymenu_intpolmenu(bContext *C, ARegion *ar, void *arg_unused)
|
||||
{
|
||||
uiBlock *block;
|
||||
short yco= 0, menuwidth=120;
|
||||
|
||||
block= uiBeginBlock(C, handle->region, "action_keymenu_intpolmenu", UI_EMBOSSP, UI_HELV);
|
||||
block= uiBeginBlock(C, ar, "action_keymenu_intpolmenu", UI_EMBOSSP, UI_HELV);
|
||||
uiBlockSetButmFunc(block, do_keymenu_intpolmenu, NULL);
|
||||
|
||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1,
|
||||
@@ -572,13 +572,13 @@ static void do_action_keymenu(bContext *C, void *arg, int event)
|
||||
}
|
||||
}
|
||||
|
||||
static uiBlock *action_keymenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused)
|
||||
static uiBlock *action_keymenu(bContext *C, ARegion *ar, void *arg_unused)
|
||||
{
|
||||
ScrArea *curarea= CTX_wm_area(C);
|
||||
uiBlock *block;
|
||||
short yco= 0, menuwidth=120;
|
||||
|
||||
block= uiBeginBlock(C, handle->region, "action_keymenu", UI_EMBOSSP, UI_HELV);
|
||||
block= uiBeginBlock(C, ar, "action_keymenu", UI_EMBOSSP, UI_HELV);
|
||||
|
||||
|
||||
uiBlockSetButmFunc(block, do_action_keymenu, NULL);
|
||||
@@ -661,13 +661,13 @@ static uiBlock *action_keymenu(bContext *C, uiMenuBlockHandle *handle, void *arg
|
||||
|
||||
|
||||
// framemenu uses functions from keymenu
|
||||
static uiBlock *action_framemenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused)
|
||||
static uiBlock *action_framemenu(bContext *C, ARegion *ar, void *arg_unused)
|
||||
{
|
||||
ScrArea *curarea= CTX_wm_area(C);
|
||||
uiBlock *block;
|
||||
short yco= 0, menuwidth=120;
|
||||
|
||||
block= uiBeginBlock(C, handle->region, "action_framemenu", UI_EMBOSSP, UI_HELV);
|
||||
block= uiBeginBlock(C, ar, "action_framemenu", UI_EMBOSSP, UI_HELV);
|
||||
uiBlockSetButmFunc(block, do_action_keymenu, NULL);
|
||||
|
||||
uiDefIconTextBlockBut(block, action_keymenu_transformmenu,
|
||||
@@ -744,14 +744,14 @@ static void do_markermenu(bContext *C, void *arg, int event)
|
||||
}
|
||||
}
|
||||
|
||||
static uiBlock *action_markermenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused)
|
||||
static uiBlock *action_markermenu(bContext *C, ARegion *ar, void *arg_unused)
|
||||
{
|
||||
SpaceAction *saction= (SpaceAction*)CTX_wm_space_data(C);
|
||||
ScrArea *curarea= CTX_wm_area(C);
|
||||
uiBlock *block;
|
||||
short yco= 0, menuwidth=120;
|
||||
|
||||
block= uiBeginBlock(C, handle->region, "action_markermenu", UI_EMBOSSP, UI_HELV);
|
||||
block= uiBeginBlock(C, ar, "action_markermenu", UI_EMBOSSP, UI_HELV);
|
||||
uiBlockSetButmFunc(block, do_markermenu, NULL);
|
||||
|
||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Add Marker|M", 0, yco-=20,
|
||||
@@ -817,12 +817,12 @@ static void do_channelmenu_posmenu(bContext *C, void *arg, int event)
|
||||
}
|
||||
}
|
||||
|
||||
static uiBlock *action_channelmenu_posmenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused)
|
||||
static uiBlock *action_channelmenu_posmenu(bContext *C, ARegion *ar, void *arg_unused)
|
||||
{
|
||||
uiBlock *block;
|
||||
short yco= 0, menuwidth=120;
|
||||
|
||||
block= uiBeginBlock(C, handle->region, "action_channelmenu_posmenu", UI_EMBOSSP, UI_HELV);
|
||||
block= uiBeginBlock(C, ar, "action_channelmenu_posmenu", UI_EMBOSSP, UI_HELV);
|
||||
uiBlockSetButmFunc(block, do_channelmenu_posmenu, NULL);
|
||||
|
||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1,
|
||||
@@ -871,12 +871,12 @@ static void do_channelmenu_groupmenu(bContext *C, void *arg, int event)
|
||||
}
|
||||
}
|
||||
|
||||
static uiBlock *action_channelmenu_groupmenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused)
|
||||
static uiBlock *action_channelmenu_groupmenu(bContext *C, ARegion *ar, void *arg_unused)
|
||||
{
|
||||
uiBlock *block;
|
||||
short yco= 0, menuwidth=120;
|
||||
|
||||
block= uiBeginBlock(C, handle->region, "action_channelmenu_groupmenu", UI_EMBOSSP, UI_HELV);
|
||||
block= uiBeginBlock(C, ar, "action_channelmenu_groupmenu", UI_EMBOSSP, UI_HELV);
|
||||
uiBlockSetButmFunc(block, do_channelmenu_groupmenu, NULL);
|
||||
|
||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1,
|
||||
@@ -915,12 +915,12 @@ static void do_channelmenu_settingsmenu(bContext *C, void *arg, int event)
|
||||
//setflag_action_channels(event);
|
||||
}
|
||||
|
||||
static uiBlock *action_channelmenu_settingsmenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused)
|
||||
static uiBlock *action_channelmenu_settingsmenu(bContext *C, ARegion *ar, void *arg_unused)
|
||||
{
|
||||
uiBlock *block;
|
||||
short yco= 0, menuwidth=120;
|
||||
|
||||
block= uiBeginBlock(C, handle->region, "action_channelmenu_settingsmenu", UI_EMBOSSP, UI_HELV);
|
||||
block= uiBeginBlock(C, ar, "action_channelmenu_settingsmenu", UI_EMBOSSP, UI_HELV);
|
||||
uiBlockSetButmFunc(block, do_channelmenu_settingsmenu, NULL);
|
||||
|
||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1,
|
||||
@@ -970,13 +970,13 @@ static void do_channelmenu(bContext *C, void *arg, int event)
|
||||
}
|
||||
}
|
||||
|
||||
static uiBlock *action_channelmenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused)
|
||||
static uiBlock *action_channelmenu(bContext *C, ARegion *ar, void *arg_unused)
|
||||
{
|
||||
ScrArea *curarea= CTX_wm_area(C);
|
||||
uiBlock *block;
|
||||
short yco= 0, menuwidth=120;
|
||||
|
||||
block= uiBeginBlock(C, handle->region, "action_channelmenu", UI_EMBOSSP, UI_HELV);
|
||||
block= uiBeginBlock(C, ar, "action_channelmenu", UI_EMBOSSP, UI_HELV);
|
||||
uiBlockSetButmFunc(block, do_channelmenu, NULL);
|
||||
|
||||
uiDefIconTextBlockBut(block, action_channelmenu_groupmenu,
|
||||
@@ -1034,13 +1034,13 @@ static uiBlock *action_channelmenu(bContext *C, uiMenuBlockHandle *handle, void
|
||||
/* Grease Pencil --------------------------- */
|
||||
|
||||
/* Uses channelmenu functions */
|
||||
static uiBlock *action_gplayermenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused)
|
||||
static uiBlock *action_gplayermenu(bContext *C, ARegion *ar, void *arg_unused)
|
||||
{
|
||||
ScrArea *curarea= CTX_wm_area(C);
|
||||
uiBlock *block;
|
||||
short yco= 0, menuwidth=120;
|
||||
|
||||
block= uiBeginBlock(C, handle->region, "action_gplayermenu", UI_EMBOSSP, UI_HELV);
|
||||
block= uiBeginBlock(C, ar, "action_gplayermenu", UI_EMBOSSP, UI_HELV);
|
||||
uiBlockSetButmFunc(block, do_channelmenu, NULL);
|
||||
|
||||
uiDefIconTextBlockBut(block, action_channelmenu_settingsmenu,
|
||||
@@ -1088,13 +1088,13 @@ static void do_selectmenu_columnmenu(bContext *C, void *arg, int event)
|
||||
}
|
||||
}
|
||||
|
||||
static uiBlock *action_selectmenu_columnmenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused)
|
||||
static uiBlock *action_selectmenu_columnmenu(bContext *C, ARegion *ar, void *arg_unused)
|
||||
{
|
||||
SpaceAction *saction= (SpaceAction*)CTX_wm_space_data(C);
|
||||
uiBlock *block;
|
||||
short yco= 0, menuwidth=120;
|
||||
|
||||
block= uiBeginBlock(C, handle->region, "action_selectmenu_columnmenu", UI_EMBOSSP, UI_HELV);
|
||||
block= uiBeginBlock(C, ar, "action_selectmenu_columnmenu", UI_EMBOSSP, UI_HELV);
|
||||
uiBlockSetButmFunc(block, do_selectmenu_columnmenu, NULL);
|
||||
|
||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1,
|
||||
@@ -1198,14 +1198,14 @@ static void do_selectmenu(bContext *C, void *arg, int event)
|
||||
}
|
||||
}
|
||||
|
||||
static uiBlock *action_selectmenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused)
|
||||
static uiBlock *action_selectmenu(bContext *C, ARegion *ar, void *arg_unused)
|
||||
{
|
||||
ScrArea *curarea= CTX_wm_area(C);
|
||||
SpaceAction *saction= (SpaceAction*)CTX_wm_space_data(C);
|
||||
uiBlock *block;
|
||||
short yco= 0, menuwidth=120;
|
||||
|
||||
block= uiBeginBlock(C, handle->region, "action_selectmenu", UI_EMBOSSP, UI_HELV);
|
||||
block= uiBeginBlock(C, ar, "action_selectmenu", UI_EMBOSSP, UI_HELV);
|
||||
uiBlockSetButmFunc(block, do_selectmenu, NULL);
|
||||
|
||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1,
|
||||
@@ -1371,7 +1371,7 @@ static void do_viewmenu(bContext *C, void *arg, int event)
|
||||
}
|
||||
}
|
||||
|
||||
static uiBlock *action_viewmenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused)
|
||||
static uiBlock *action_viewmenu(bContext *C, ARegion *ar, void *arg_unused)
|
||||
{
|
||||
ScrArea *curarea= CTX_wm_area(C);
|
||||
SpaceAction *saction= (SpaceAction*)CTX_wm_space_data(C);
|
||||
@@ -1379,7 +1379,7 @@ static uiBlock *action_viewmenu(bContext *C, uiMenuBlockHandle *handle, void *ar
|
||||
uiBlock *block;
|
||||
short yco= 0, menuwidth=120;
|
||||
|
||||
block= uiBeginBlock(C, handle->region, "viewmenu", UI_EMBOSSP, UI_HELV);
|
||||
block= uiBeginBlock(C, ar, "viewmenu", UI_EMBOSSP, UI_HELV);
|
||||
uiBlockSetButmFunc(block, do_viewmenu, NULL);
|
||||
|
||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1,
|
||||
|
||||
@@ -88,8 +88,8 @@ void ACT_OT_keyframes_clean(struct wmOperatorType *ot);
|
||||
void ACT_OT_keyframes_sample(struct wmOperatorType *ot);
|
||||
|
||||
void ACT_OT_keyframes_handletype(struct wmOperatorType *ot);
|
||||
void ACT_OT_keyframes_ipotype(struct wmOperatorType *ot);
|
||||
void ACT_OT_keyframes_expotype(struct wmOperatorType *ot);
|
||||
void ACT_OT_keyframes_interpolation_type(struct wmOperatorType *ot);
|
||||
void ACT_OT_keyframes_extrapolation_type(struct wmOperatorType *ot);
|
||||
|
||||
void ACT_OT_keyframes_cfrasnap(struct wmOperatorType *ot);
|
||||
void ACT_OT_keyframes_snap(struct wmOperatorType *ot);
|
||||
|
||||
@@ -73,8 +73,8 @@ void action_operatortypes(void)
|
||||
WM_operatortype_append(ACT_OT_keyframes_mirror);
|
||||
WM_operatortype_append(ACT_OT_keyframes_cfrasnap);
|
||||
WM_operatortype_append(ACT_OT_keyframes_handletype);
|
||||
WM_operatortype_append(ACT_OT_keyframes_ipotype);
|
||||
WM_operatortype_append(ACT_OT_keyframes_expotype);
|
||||
WM_operatortype_append(ACT_OT_keyframes_interpolation_type);
|
||||
WM_operatortype_append(ACT_OT_keyframes_extrapolation_type);
|
||||
WM_operatortype_append(ACT_OT_keyframes_sample);
|
||||
WM_operatortype_append(ACT_OT_keyframes_clean);
|
||||
WM_operatortype_append(ACT_OT_keyframes_delete);
|
||||
@@ -121,8 +121,8 @@ static void action_keymap_keyframes (wmWindowManager *wm, ListBase *keymap)
|
||||
|
||||
/* menu + set setting */
|
||||
WM_keymap_add_item(keymap, "ACT_OT_keyframes_handletype", HKEY, KM_PRESS, 0, 0);
|
||||
WM_keymap_add_item(keymap, "ACT_OT_keyframes_ipotype", TKEY, KM_PRESS, KM_SHIFT, 0);
|
||||
WM_keymap_add_item(keymap, "ACT_OT_keyframes_expotype", EKEY, KM_PRESS, KM_SHIFT, 0); // temp...
|
||||
WM_keymap_add_item(keymap, "ACT_OT_keyframes_interpolation_type", TKEY, KM_PRESS, KM_SHIFT, 0);
|
||||
WM_keymap_add_item(keymap, "ACT_OT_keyframes_extrapolation_type", EKEY, KM_PRESS, KM_SHIFT, 0);
|
||||
|
||||
/* destructive */
|
||||
WM_keymap_add_item(keymap, "ACT_OT_keyframes_clean", OKEY, KM_PRESS, 0, 0);
|
||||
@@ -138,6 +138,9 @@ static void action_keymap_keyframes (wmWindowManager *wm, ListBase *keymap)
|
||||
/* auto-set range */
|
||||
WM_keymap_add_item(keymap, "ACT_OT_set_previewrange", PKEY, KM_PRESS, KM_CTRL|KM_ALT, 0);
|
||||
WM_keymap_add_item(keymap, "ACT_OT_view_all", HOMEKEY, KM_PRESS, 0, 0);
|
||||
|
||||
/* generates event, needs to be after select to work */
|
||||
WM_keymap_add_item(keymap, "WM_OT_tweak_gesture", SELECTMOUSE, KM_PRESS, 0, 0);
|
||||
|
||||
/* transform system */
|
||||
transform_keymap_for_space(wm, keymap, SPACE_ACTION);
|
||||
|
||||
@@ -521,7 +521,7 @@ void ACT_OT_keyframes_borderselect(wmOperatorType *ot)
|
||||
*/
|
||||
|
||||
/* defines for column-select mode */
|
||||
EnumPropertyItem prop_column_select_types[] = {
|
||||
static EnumPropertyItem prop_column_select_types[] = {
|
||||
{ACTKEYS_COLUMNSEL_KEYS, "KEYS", "On Selected Keyframes", ""},
|
||||
{ACTKEYS_COLUMNSEL_CFRA, "CFRA", "On Current Frame", ""},
|
||||
{ACTKEYS_COLUMNSEL_MARKERS_COLUMN, "MARKERS_COLUMN", "On Selected Markers", ""},
|
||||
@@ -750,7 +750,7 @@ void ACT_OT_keyframes_columnselect (wmOperatorType *ot)
|
||||
*/
|
||||
|
||||
/* defines for left-right select tool */
|
||||
EnumPropertyItem prop_leftright_select_types[] = {
|
||||
static EnumPropertyItem prop_leftright_select_types[] = {
|
||||
{ACTKEYS_LRSEL_TEST, "CHECK", "Check if Select Left or Right", ""},
|
||||
{ACTKEYS_LRSEL_NONE, "OFF", "Don't select", ""},
|
||||
{ACTKEYS_LRSEL_LEFT, "LEFT", "Before current frame", ""},
|
||||
@@ -978,12 +978,13 @@ static void mouse_columnselect_action_keys (bAnimContext *ac, float selx)
|
||||
Object *nob= ANIM_nla_mapping_get(ac, ale);
|
||||
|
||||
/* set frame for validation callback to refer to */
|
||||
// XXX have a more sensitive range?
|
||||
if (nob)
|
||||
bed.f1= get_action_frame(nob, selx);
|
||||
else
|
||||
bed.f1= selx;
|
||||
|
||||
/* select elements with frame number matching cfraelem */
|
||||
/* select elements with frame number matching cfra */
|
||||
ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, ok_cb, select_cb, NULL);
|
||||
|
||||
#if 0 // XXX reenable when Grease Pencil stuff is back
|
||||
@@ -1067,7 +1068,8 @@ static int actkeys_clickselect_invoke(bContext *C, wmOperator *op, wmEvent *even
|
||||
/* set notifier tha things have changed */
|
||||
ANIM_animdata_send_notifiers(C, &ac, ANIM_CHANGED_BOTH);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
/* for tweak grab to work */
|
||||
return OPERATOR_FINISHED|OPERATOR_PASS_THROUGH;
|
||||
}
|
||||
|
||||
void ACT_OT_keyframes_clickselect (wmOperatorType *ot)
|
||||
|
||||
@@ -298,10 +298,14 @@ 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;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if(wmn->data==ND_KEYS)
|
||||
ED_region_tag_redraw(ar);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -322,10 +326,14 @@ static void action_main_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;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if(wmn->data==ND_KEYS)
|
||||
ED_region_tag_redraw(ar);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -65,13 +65,13 @@ static void do_viewmenu(bContext *C, void *arg, int event)
|
||||
|
||||
}
|
||||
|
||||
static uiBlock *dummy_viewmenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused)
|
||||
static uiBlock *dummy_viewmenu(bContext *C, ARegion *ar, void *arg_unused)
|
||||
{
|
||||
ScrArea *curarea= CTX_wm_area(C);
|
||||
uiBlock *block;
|
||||
short yco= 0, menuwidth=120;
|
||||
|
||||
block= uiBeginBlock(C, handle->region, "dummy_viewmenu", UI_EMBOSSP, UI_HELV);
|
||||
block= uiBeginBlock(C, ar, "dummy_viewmenu", UI_EMBOSSP, UI_HELV);
|
||||
uiBlockSetButmFunc(block, do_viewmenu, NULL);
|
||||
|
||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Nothing yet", 0, yco-=20,
|
||||
|
||||
@@ -89,38 +89,12 @@ enum {
|
||||
|
||||
static void do_file_buttons(bContext *C, void *arg, int event)
|
||||
{
|
||||
SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C);
|
||||
switch(event) {
|
||||
case B_FS_LOAD:
|
||||
{
|
||||
char name[FILE_MAX];
|
||||
|
||||
ED_screen_full_prevspace(C);
|
||||
if(sfile->op) {
|
||||
wmOperator *op= sfile->op;
|
||||
|
||||
/* if load .blend, all UI pointers after exec are invalid! */
|
||||
/* but, operator can be freed still */
|
||||
|
||||
sfile->op = NULL;
|
||||
BLI_strncpy(name, sfile->params->dir, sizeof(name));
|
||||
strcat(name, sfile->params->file);
|
||||
RNA_string_set(op->ptr, "filename", name);
|
||||
|
||||
op->type->exec(C, op);
|
||||
|
||||
WM_operator_free(op);
|
||||
}
|
||||
|
||||
}
|
||||
file_load_exec(C, NULL); /* file_ops.c */
|
||||
break;
|
||||
case B_FS_CANCEL:
|
||||
if(sfile->op) {
|
||||
WM_operator_free(sfile->op);
|
||||
sfile->op = NULL;
|
||||
}
|
||||
ED_screen_full_prevspace(C);
|
||||
|
||||
file_cancel_exec(C, NULL); /* file_ops.c */
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -203,15 +177,16 @@ void file_draw_buttons(const bContext *C, ARegion *ar)
|
||||
static void draw_tile(short sx, short sy, short width, short height, int colorid, int shade)
|
||||
{
|
||||
/* TODO: BIF_ThemeColor seems to need this to show the color, not sure why? - elubie */
|
||||
glEnable(GL_BLEND);
|
||||
glColor4ub(0, 0, 0, 100);
|
||||
glDisable(GL_BLEND);
|
||||
//glEnable(GL_BLEND);
|
||||
//glColor4ub(0, 0, 0, 100);
|
||||
//glDisable(GL_BLEND);
|
||||
/* I think it was a missing glDisable() - ton */
|
||||
|
||||
UI_ThemeColorShade(colorid, shade);
|
||||
uiSetRoundBox(15);
|
||||
glRecti(sx, sy - height, sx + width, sy);
|
||||
// glRecti(sx, sy - height, sx + width, sy);
|
||||
|
||||
// uiRoundBox(sx+TILE_BORDER_X, sy - sfile->prv_h - TILE_BORDER_Y*3 - U.fontsize, sx + sfile->prv_w + TILE_BORDER_X*3, sy, 6);
|
||||
uiRoundBox(sx, sy - height, sx + width, sy, 6);
|
||||
}
|
||||
|
||||
static float shorten_string(char* string, float w)
|
||||
@@ -293,7 +268,10 @@ void file_calc_previews(const bContext *C, ARegion *ar)
|
||||
sfile->tile_h = sfile->prv_h + 4*sfile->prv_border_y + U.fontsize*3/2;
|
||||
width= (v2d->cur.xmax - v2d->cur.xmin - 2*sfile->tile_border_x);
|
||||
columns= file_view_columns(sfile, v2d);
|
||||
rows= filelist_numfiles(sfile->files)/columns + 1; // XXX dirty, modulo is zero
|
||||
if(columns)
|
||||
rows= filelist_numfiles(sfile->files)/columns + 1; // XXX dirty, modulo is zero
|
||||
else
|
||||
rows= filelist_numfiles(sfile->files) + 1; // XXX dirty, modulo is zero
|
||||
height= rows*(sfile->tile_h+2*sfile->tile_border_y) + sfile->tile_border_y*2;
|
||||
} else {
|
||||
sfile->prv_w = 0;
|
||||
@@ -306,7 +284,11 @@ void file_calc_previews(const bContext *C, ARegion *ar)
|
||||
sfile->tile_h = U.fontsize*3/2;
|
||||
height= v2d->cur.ymax - v2d->cur.ymin;
|
||||
rows = file_view_rows(sfile, v2d);
|
||||
columns = filelist_numfiles(sfile->files)/rows + 1; // XXX dirty, modulo is zero
|
||||
if(rows)
|
||||
columns = filelist_numfiles(sfile->files)/rows + 1; // XXX dirty, modulo is zero
|
||||
else
|
||||
columns = filelist_numfiles(sfile->files) + 1; // XXX dirty, modulo is zero
|
||||
|
||||
width = columns * (sfile->tile_w + 2*sfile->tile_border_x) + sfile->tile_border_x*2;
|
||||
}
|
||||
|
||||
@@ -360,10 +342,10 @@ void file_draw_previews(const bContext *C, ARegion *ar)
|
||||
|
||||
if (params->active_file == i) {
|
||||
colorid = TH_ACTIVE;
|
||||
draw_tile(sx, sy, sfile->tile_w, sfile->tile_h, colorid,0);
|
||||
draw_tile(sx - 1, sy, sfile->tile_w + 1, sfile->tile_h, colorid,0);
|
||||
} else if (file->flags & ACTIVE) {
|
||||
colorid = TH_HILITE;
|
||||
draw_tile(sx, sy, sfile->tile_w, sfile->tile_h, colorid,0);
|
||||
draw_tile(sx - 1, sy, sfile->tile_w + 1, sfile->tile_h, colorid,0);
|
||||
} else {
|
||||
colorid = TH_BACK;
|
||||
draw_tile(sx, sy, sfile->tile_w, sfile->tile_h, colorid, -5);
|
||||
@@ -417,18 +399,18 @@ void file_draw_previews(const bContext *C, ARegion *ar)
|
||||
// glaDrawPixelsSafe((float)sx+8 + dx, (float)sy - imgwidth + dy - 8, imb->x, imb->y, imb->x, GL_RGBA, GL_UNSIGNED_BYTE, imb->rect);
|
||||
glColor4f(1.0, 1.0, 1.0, 1.0);
|
||||
glaDrawPixelsTex((float)sx + dx, (float)sy - sfile->prv_h + dy, imb->x, imb->y,GL_UNSIGNED_BYTE, imb->rect);
|
||||
// glDisable(GL_BLEND);
|
||||
glDisable(GL_BLEND);
|
||||
imb = 0;
|
||||
}
|
||||
#if 0
|
||||
}
|
||||
#endif
|
||||
if (type == FILE_MAIN) {
|
||||
glColor3f(1.0f, 1.0f, 1.0f);
|
||||
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
}
|
||||
else {
|
||||
if (S_ISDIR(file->type)) {
|
||||
glColor3f(1.0f, 1.0f, 0.9f);
|
||||
glColor4f(1.0f, 1.0f, 0.9f, 1.0f);
|
||||
}
|
||||
else if (file->flags & IMAGEFILE) {
|
||||
UI_ThemeColor(TH_SEQ_IMAGE);
|
||||
@@ -499,16 +481,17 @@ void file_draw_list(const bContext *C, ARegion *ar)
|
||||
for (i=offset; (i < numfiles); ++i)
|
||||
{
|
||||
sy = ar->v2d.tot.ymax-sfile->tile_border_y - (i%rows)*(sfile->tile_h+sfile->tile_border_y);
|
||||
sx = ar->v2d.tot.xmin +sfile->tile_border_x + (i/rows)*(sfile->tile_w+sfile->tile_border_x);
|
||||
sx = 2 + ar->v2d.tot.xmin +sfile->tile_border_x + (i/rows)*(sfile->tile_w+sfile->tile_border_x);
|
||||
|
||||
file = filelist_file(files, i);
|
||||
|
||||
if (params->active_file == i) {
|
||||
colorid = TH_ACTIVE;
|
||||
draw_tile(sx, sy, sfile->tile_w, sfile->tile_h, colorid,0);
|
||||
if (file->flags & ACTIVE) colorid= TH_HILITE;
|
||||
else colorid = TH_BACK;
|
||||
draw_tile(sx, sy-3, sfile->tile_w, sfile->tile_h, colorid,20);
|
||||
} else if (file->flags & ACTIVE) {
|
||||
colorid = TH_HILITE;
|
||||
draw_tile(sx, sy, sfile->tile_w, sfile->tile_h, colorid,0);
|
||||
draw_tile(sx, sy-3, sfile->tile_w, sfile->tile_h, colorid,0);
|
||||
} else {
|
||||
/*
|
||||
colorid = TH_PANEL;
|
||||
@@ -516,11 +499,11 @@ void file_draw_list(const bContext *C, ARegion *ar)
|
||||
*/
|
||||
}
|
||||
if (type == FILE_MAIN) {
|
||||
glColor3f(1.0f, 1.0f, 1.0f);
|
||||
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
}
|
||||
else {
|
||||
if (S_ISDIR(file->type)) {
|
||||
glColor3f(1.0f, 1.0f, 0.9f);
|
||||
glColor4f(1.0f, 1.0f, 0.9f, 1.0f);
|
||||
}
|
||||
else if (file->flags & IMAGEFILE) {
|
||||
UI_ThemeColor(TH_SEQ_IMAGE);
|
||||
@@ -543,7 +526,7 @@ void file_draw_list(const bContext *C, ARegion *ar)
|
||||
}
|
||||
|
||||
sw = UI_GetStringWidth(G.font, file->size, 0);
|
||||
file_draw_string(sx, sy, file->relname, sfile->tile_w - sw - 2, sfile->tile_h);
|
||||
file_draw_string(sx, sy, file->relname, sfile->tile_w - sw - 5, sfile->tile_h);
|
||||
file_draw_string(sx + sfile->tile_w - sw, sy, file->size, sfile->tile_w - sw, sfile->tile_h);
|
||||
}
|
||||
}
|
||||
@@ -577,9 +560,9 @@ void file_draw_fsmenu(const bContext *C, ARegion *ar)
|
||||
if (params->active_bookmark == i ) {
|
||||
glColor4ub(0, 0, 0, 100);
|
||||
UI_ThemeColor(TH_HILITE);
|
||||
// uiSetRoundBox(15);
|
||||
// uiRoundBox(simasel->bookmarkrect.xmin + TILE_BORDER_X - 1, sy - linestep*0.25, simasel->bookmarkrect.xmax - TILE_BORDER_X + 1, sy + linestep*0.75, 6);
|
||||
glRecti(sx, sy - linestep, sx + bmwidth, sy);
|
||||
uiSetRoundBox(15);
|
||||
uiRoundBox(sx, sy - linestep, sx + bmwidth, sy, 6);
|
||||
// glRecti(sx, sy - linestep, sx + bmwidth, sy);
|
||||
UI_ThemeColor(TH_TEXT_HI);
|
||||
} else {
|
||||
UI_ThemeColor(TH_TEXT);
|
||||
|
||||
@@ -72,13 +72,13 @@ static void do_viewmenu(bContext *C, void *arg, int event)
|
||||
|
||||
}
|
||||
|
||||
static uiBlock *dummy_viewmenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused)
|
||||
static uiBlock *dummy_viewmenu(bContext *C, ARegion *ar, void *arg_unused)
|
||||
{
|
||||
ScrArea *curarea= CTX_wm_area(C);
|
||||
uiBlock *block;
|
||||
short yco= 0, menuwidth=120;
|
||||
|
||||
block= uiBeginBlock(C, handle->region, "dummy_viewmenu", UI_EMBOSSP, UI_HELV);
|
||||
block= uiBeginBlock(C, ar, "dummy_viewmenu", UI_EMBOSSP, UI_HELV);
|
||||
uiBlockSetButmFunc(block, do_viewmenu, NULL);
|
||||
|
||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Nothing yet", 0, yco-=20,
|
||||
|
||||
@@ -47,12 +47,20 @@ void file_draw_fsmenu(const bContext *C, ARegion *ar);
|
||||
|
||||
/* file_ops.h */
|
||||
struct wmOperatorType;
|
||||
struct wmOperator;
|
||||
struct wmEvent;
|
||||
void ED_FILE_OT_highlight(struct wmOperatorType *ot);
|
||||
void ED_FILE_OT_select(struct wmOperatorType *ot);
|
||||
void ED_FILE_OT_select_all(struct wmOperatorType *ot);
|
||||
void ED_FILE_OT_border_select(struct wmOperatorType *ot);
|
||||
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);
|
||||
|
||||
int file_load_exec(bContext *C, struct wmOperator *unused);
|
||||
int file_cancel_exec(bContext *C, struct wmOperator *unused);
|
||||
int file_hilight_set(SpaceFile *sfile, ARegion *ar, int mx, int my);
|
||||
|
||||
#endif /* ED_FILE_INTERN_H */
|
||||
|
||||
|
||||
@@ -398,38 +398,39 @@ void ED_FILE_OT_loadimages(wmOperatorType *ot)
|
||||
/* api callbacks */
|
||||
ot->invoke= loadimages_invoke;
|
||||
|
||||
ot->poll= ED_operator_areaactive;
|
||||
ot->poll= ED_operator_file_active;
|
||||
}
|
||||
|
||||
int file_hilight_set(SpaceFile *sfile, ARegion *ar, int mx, int my)
|
||||
{
|
||||
FileSelectParams* params;
|
||||
int numfiles, actfile;
|
||||
|
||||
if(sfile==NULL || sfile->files==NULL) return 0;
|
||||
|
||||
numfiles = filelist_numfiles(sfile->files);
|
||||
params = ED_fileselect_get_params(sfile);
|
||||
|
||||
if (params->display) {
|
||||
actfile = find_file_mouse_hor(sfile, ar, mx , my);
|
||||
} else {
|
||||
actfile = find_file_mouse_vert(sfile, ar, mx, my);
|
||||
}
|
||||
|
||||
if (actfile >= 0 && actfile < numfiles ) {
|
||||
params->active_file=actfile;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int file_highlight_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
||||
{
|
||||
ScrArea *sa= CTX_wm_area(C);
|
||||
ARegion *ar= CTX_wm_region(C);
|
||||
FileSelectParams* params;
|
||||
short x, y;
|
||||
int actfile;
|
||||
int numfiles;
|
||||
SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C);
|
||||
|
||||
if (!sfile || !sfile->files) return OPERATOR_FINISHED;
|
||||
|
||||
numfiles = filelist_numfiles(sfile->files);
|
||||
|
||||
x = event->x - ar->winrct.xmin;
|
||||
y = event->y - ar->winrct.ymin;
|
||||
|
||||
params = ED_fileselect_get_params(sfile);
|
||||
if (params->display) {
|
||||
actfile = find_file_mouse_hor(sfile, ar,x , y);
|
||||
} else {
|
||||
actfile = find_file_mouse_vert(sfile, ar, x, y);
|
||||
}
|
||||
|
||||
if (actfile >= 0 && actfile < numfiles )
|
||||
{
|
||||
params->active_file=actfile;
|
||||
ED_area_tag_redraw(sa);
|
||||
if( file_hilight_set(sfile, ar, event->x - ar->winrct.xmin, event->y - ar->winrct.ymin)) {
|
||||
ED_area_tag_redraw(CTX_wm_area(C));
|
||||
}
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
@@ -443,6 +444,70 @@ void ED_FILE_OT_highlight(struct wmOperatorType *ot)
|
||||
|
||||
/* api callbacks */
|
||||
ot->invoke= file_highlight_invoke;
|
||||
ot->poll= ED_operator_areaactive;
|
||||
ot->poll= ED_operator_file_active;
|
||||
}
|
||||
|
||||
int file_cancel_exec(bContext *C, wmOperator *unused)
|
||||
{
|
||||
SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C);
|
||||
|
||||
if(sfile->op) {
|
||||
WM_operator_free(sfile->op);
|
||||
sfile->op = NULL;
|
||||
}
|
||||
ED_screen_full_prevspace(C);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
void ED_FILE_OT_cancel(struct wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name= "Cancel File Load";
|
||||
ot->idname= "ED_FILE_OT_cancel";
|
||||
|
||||
/* api callbacks */
|
||||
ot->exec= file_cancel_exec;
|
||||
ot->poll= ED_operator_file_active;
|
||||
}
|
||||
|
||||
|
||||
int file_load_exec(bContext *C, wmOperator *unused)
|
||||
{
|
||||
SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C);
|
||||
char name[FILE_MAX];
|
||||
|
||||
ED_screen_full_prevspace(C);
|
||||
|
||||
if(sfile->op) {
|
||||
wmOperator *op= sfile->op;
|
||||
|
||||
/* if load .blend, all UI pointers after exec are invalid! */
|
||||
/* but, operator can be freed still */
|
||||
|
||||
sfile->op = NULL;
|
||||
BLI_strncpy(name, sfile->params->dir, sizeof(name));
|
||||
strcat(name, sfile->params->file);
|
||||
RNA_string_set(op->ptr, "filename", name);
|
||||
|
||||
op->type->exec(C, op);
|
||||
|
||||
WM_operator_free(op);
|
||||
}
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
void ED_FILE_OT_load(struct wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name= "Load File";
|
||||
ot->idname= "ED_FILE_OT_load";
|
||||
|
||||
/* api callbacks */
|
||||
ot->exec= file_load_exec;
|
||||
ot->poll= ED_operator_file_active; /* <- important, handler is on window level */
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -195,6 +195,7 @@ static void file_main_area_draw(const bContext *C, ARegion *ar)
|
||||
sfile->files = filelist_new();
|
||||
filelist_setdir(sfile->files, params->dir);
|
||||
filelist_settype(sfile->files, params->type);
|
||||
params->active_file = -1; // added this so it opens nicer (ton)
|
||||
}
|
||||
|
||||
if (filelist_empty(sfile->files))
|
||||
@@ -213,15 +214,21 @@ static void file_main_area_draw(const bContext *C, ARegion *ar)
|
||||
if(params->sort!=FILE_SORTALPHA) filelist_sort(sfile->files, params->sort);
|
||||
}
|
||||
|
||||
|
||||
/* clear and setup matrix */
|
||||
UI_GetThemeColor3fv(TH_BACK, col);
|
||||
glClearColor(col[0], col[1], col[2], 0.0);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
file_calc_previews(C,ar);
|
||||
|
||||
/* sets tile/border settings in sfile */
|
||||
file_calc_previews(C, ar);
|
||||
|
||||
/* on first read, find active file */
|
||||
if (params->active_file == -1) {
|
||||
wmEvent *event= CTX_wm_window(C)->eventstate;
|
||||
file_hilight_set(sfile, ar, event->x - ar->winrct.xmin, event->y - ar->winrct.ymin);
|
||||
|
||||
}
|
||||
|
||||
/* data... */
|
||||
UI_view2d_view_ortho(C, v2d);
|
||||
|
||||
@@ -250,8 +257,11 @@ void file_operatortypes(void)
|
||||
WM_operatortype_append(ED_FILE_OT_select_bookmark);
|
||||
WM_operatortype_append(ED_FILE_OT_loadimages);
|
||||
WM_operatortype_append(ED_FILE_OT_highlight);
|
||||
WM_operatortype_append(ED_FILE_OT_load);
|
||||
WM_operatortype_append(ED_FILE_OT_cancel);
|
||||
}
|
||||
|
||||
/* NOTE: do not add .blend file reading on this level */
|
||||
void file_keymap(struct wmWindowManager *wm)
|
||||
{
|
||||
ListBase *keymap= WM_keymap_listbase(wm, "File", SPACE_FILE, 0);
|
||||
@@ -259,6 +269,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_loadimages", TIMER1, KM_ANY, KM_ANY, 0);
|
||||
|
||||
keymap= WM_keymap_listbase(wm, "FileBookmark", SPACE_FILE, 0);
|
||||
|
||||
@@ -83,88 +83,52 @@
|
||||
#define B_SIMA_RECORD 8
|
||||
#define B_SIMA_PLAY 9
|
||||
|
||||
static uiBlock *image_view_viewnavmenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused)
|
||||
static void image_view_viewnavmenu(bContext *C, uiMenuItem *head, void *arg_unused)
|
||||
{
|
||||
uiBlock *block;
|
||||
uiBut *but;
|
||||
int a;
|
||||
|
||||
/* create menu */
|
||||
block= uiBeginBlock(C, handle->region, "image_view_viewnavmenu", UI_EMBOSSP, UI_HELV);
|
||||
|
||||
uiDefMenuButO(block, "IMAGE_OT_view_zoom_in", NULL);
|
||||
uiDefMenuButO(block, "IMAGE_OT_view_zoom_out", NULL);
|
||||
uiMenuItemO(head, "IMAGE_OT_view_zoom_in", ICON_BLANK1);
|
||||
uiMenuItemO(head, "IMAGE_OT_view_zoom_out", ICON_BLANK1);
|
||||
|
||||
uiDefMenuSep(block);
|
||||
uiMenuSeparator(head);
|
||||
|
||||
for(a=0; a<7; a++) {
|
||||
const int ratios[7][2] = {{1, 8}, {1, 4}, {1, 2}, {1, 1}, {2, 1}, {4, 1}, {8, 1}};
|
||||
char namestr[128];
|
||||
|
||||
sprintf(namestr, "Zoom %d:%d", ratios[a][0], ratios[a][1]);
|
||||
|
||||
but= uiDefMenuButO(block, "IMAGE_OT_view_zoom_ratio", namestr);
|
||||
RNA_float_set(uiButGetOperatorPtrRNA(but), "ratio", (float)ratios[a][0]/(float)ratios[a][1]);
|
||||
uiMenuItemFloatO(head, namestr, "IMAGE_OT_view_zoom_ratio", "ratio", (float)ratios[a][0]/(float)ratios[a][1]);
|
||||
}
|
||||
|
||||
/* XXX find key shortcut! */
|
||||
|
||||
/* position menu */
|
||||
uiBlockSetDirection(block, UI_RIGHT);
|
||||
uiTextBoundsBlock(block, 50);
|
||||
|
||||
return block;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void do_viewmenu(bContext *C, void *arg, int event)
|
||||
{
|
||||
switch(event) {
|
||||
case 1: /* View All */
|
||||
do_image_buttons(B_SIMAGEHOME);
|
||||
break;
|
||||
case 4: /* Realtime Panel... */
|
||||
add_blockhandler(curarea, IMAGE_HANDLER_VIEW_PROPERTIES, UI_PNL_UNSTOW);
|
||||
break;
|
||||
case 7: /* Properties Panel */
|
||||
add_blockhandler(curarea, IMAGE_HANDLER_PROPERTIES, UI_PNL_UNSTOW);
|
||||
break;
|
||||
case 8: /* Paint Panel... */
|
||||
add_blockhandler(curarea, IMAGE_HANDLER_PAINT, UI_PNL_UNSTOW);
|
||||
break;
|
||||
case 9:
|
||||
image_viewcenter();
|
||||
break;
|
||||
case 11: /* Curves Panel... */
|
||||
add_blockhandler(curarea, IMAGE_HANDLER_CURVES, UI_PNL_UNSTOW);
|
||||
break;
|
||||
case 12: /* composite preview */
|
||||
toggle_blockhandler(curarea, IMAGE_HANDLER_PREVIEW, 0);
|
||||
scrarea_queue_winredraw(curarea);
|
||||
break;
|
||||
case 13: /* Realtime Panel... */
|
||||
add_blockhandler(curarea, IMAGE_HANDLER_GAME_PROPERTIES, UI_PNL_UNSTOW);
|
||||
break;
|
||||
case 15: /* Grease Pencil... */
|
||||
add_blockhandler(curarea, IMAGE_HANDLER_GREASEPENCIL, UI_PNL_UNSTOW);
|
||||
break;
|
||||
}
|
||||
add_blockhandler(curarea, IMAGE_HANDLER_VIEW_PROPERTIES, UI_PNL_UNSTOW);
|
||||
add_blockhandler(curarea, IMAGE_HANDLER_PROPERTIES, UI_PNL_UNSTOW);
|
||||
add_blockhandler(curarea, IMAGE_HANDLER_PAINT, UI_PNL_UNSTOW);
|
||||
add_blockhandler(curarea, IMAGE_HANDLER_CURVES, UI_PNL_UNSTOW);
|
||||
|
||||
toggle_blockhandler(curarea, IMAGE_HANDLER_PREVIEW, 0);
|
||||
scrarea_queue_winredraw(curarea);
|
||||
|
||||
add_blockhandler(curarea, IMAGE_HANDLER_GAME_PROPERTIES, UI_PNL_UNSTOW);
|
||||
add_blockhandler(curarea, IMAGE_HANDLER_GREASEPENCIL, UI_PNL_UNSTOW);
|
||||
|
||||
allqueue(REDRAWIMAGE, 0);
|
||||
allqueue(REDRAWVIEW3D, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
static uiBlock *image_viewmenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused)
|
||||
static void image_viewmenu(bContext *C, uiMenuItem *head, void *arg_unused)
|
||||
{
|
||||
bScreen *sc= CTX_wm_screen(C);
|
||||
ScrArea *sa= CTX_wm_area(C);
|
||||
SpaceImage *sima= (SpaceImage*)CTX_wm_space_data(C);
|
||||
PointerRNA spaceptr, uvptr;
|
||||
uiBlock *block;
|
||||
int show_paint, show_render, show_uvedit;
|
||||
|
||||
/* retrrieve state */
|
||||
/* retrieve state */
|
||||
RNA_pointer_create(&sc->id, &RNA_SpaceImageEditor, sima, &spaceptr);
|
||||
RNA_pointer_create(&sc->id, &RNA_SpaceUVEditor, sima, &uvptr);
|
||||
|
||||
@@ -173,43 +137,27 @@ static uiBlock *image_viewmenu(bContext *C, uiMenuBlockHandle *handle, void *arg
|
||||
show_uvedit= get_space_image_show_uvedit(sima, CTX_data_edit_object(C));
|
||||
|
||||
/* create menu */
|
||||
block= uiBeginBlock(C, handle->region, "image_viewmenu", UI_EMBOSSP, UI_HELV);
|
||||
|
||||
uiDefMenuButO(block, "IMAGE_OT_toggle_view_properties_panel", NULL); // View Properties...
|
||||
uiDefMenuButO(block, "IMAGE_OT_toggle_image_properties_panel", NULL); // Image Properties...|N
|
||||
uiDefMenuButO(block, "IMAGE_OT_toggle_realtime_properties_panel", NULL); // Real-time properties...
|
||||
if(show_paint) uiDefMenuButO(block, "IMAGE_OT_toggle_paint_panel", NULL); // Paint Tool...|C
|
||||
uiDefMenuButO(block, "IMAGE_OT_toggle_curves_panel", NULL); // Curves Tool...
|
||||
if(show_render) uiDefMenuButO(block, "IMAGE_OT_toggle_compositing_preview_panel", NULL); // Compositing Preview...|Shift P
|
||||
uiDefMenuButO(block, "IMAGE_OT_toggle_grease_pencil_panel", NULL); // Grease Pencil...
|
||||
uiMenuItemO(head, "IMAGE_OT_toggle_view_properties_panel", ICON_MENU_PANEL); // View Properties...
|
||||
uiMenuItemO(head, "IMAGE_OT_toggle_image_properties_panel", ICON_MENU_PANEL); // Image Properties...|N
|
||||
uiMenuItemO(head, "IMAGE_OT_toggle_realtime_properties_panel", ICON_MENU_PANEL); // Real-time properties...
|
||||
if(show_paint) uiMenuItemO(head, "IMAGE_OT_toggle_paint_panel", ICON_MENU_PANEL); // Paint Tool...|C
|
||||
uiMenuItemO(head, "IMAGE_OT_toggle_curves_panel", ICON_MENU_PANEL); // Curves Tool...
|
||||
if(show_render) uiMenuItemO(head, "IMAGE_OT_toggle_compositing_preview_panel", ICON_MENU_PANEL); // Compositing Preview...|Shift P
|
||||
uiMenuItemO(head, "IMAGE_OT_toggle_grease_pencil_panel", ICON_MENU_PANEL); // Grease Pencil...
|
||||
|
||||
uiDefMenuSep(block);
|
||||
uiMenuSeparator(head);
|
||||
|
||||
uiDefMenuTogR(block, &spaceptr, "update_automatically", NULL, NULL);
|
||||
// XXX if(show_uvedit) uiDefMenuTogR(block, &uvptr, "local_view", NULL, "UV Local View"); // Numpad /
|
||||
uiMenuItemBooleanR(head, &spaceptr, "update_automatically");
|
||||
// XXX if(show_uvedit) uiMenuItemBooleanR(head, &uvptr, "local_view"); // "UV Local View", Numpad /
|
||||
|
||||
uiDefMenuSep(block);
|
||||
uiMenuSeparator(head);
|
||||
|
||||
uiDefMenuSub(block, image_view_viewnavmenu, "View Navigation");
|
||||
if(show_uvedit) uiDefMenuButO(block, "IMAGE_OT_view_selected", NULL);
|
||||
uiDefMenuButO(block, "IMAGE_OT_view_all", NULL);
|
||||
uiMenuLevel(head, "View Navigation", image_view_viewnavmenu);
|
||||
if(show_uvedit) uiMenuItemO(head, "IMAGE_OT_view_selected", ICON_BLANK1);
|
||||
uiMenuItemO(head, "IMAGE_OT_view_all", ICON_BLANK1);
|
||||
|
||||
if(sa->full) uiDefMenuButO(block, "SCREEN_OT_screen_full_area", "Tile Window"); // Ctrl UpArrow
|
||||
else uiDefMenuButO(block, "SCREEN_OT_screen_full_area", "Maximize Window"); // Ctr DownArrow
|
||||
|
||||
/* position menu */
|
||||
if(sa->headertype==HEADERTOP) {
|
||||
uiBlockSetDirection(block, UI_DOWN);
|
||||
}
|
||||
else {
|
||||
uiBlockSetDirection(block, UI_TOP);
|
||||
uiBlockFlipOrder(block);
|
||||
}
|
||||
|
||||
uiTextBoundsBlock(block, 50);
|
||||
uiEndBlock(C, block);
|
||||
|
||||
return block;
|
||||
if(sa->full) uiMenuItemO(head, "SCREEN_OT_screen_full_area", ICON_BLANK1); // "Tile Window", Ctrl UpArrow
|
||||
else uiMenuItemO(head, "SCREEN_OT_screen_full_area", ICON_BLANK1); // "Maximize Window", Ctr DownArrow
|
||||
}
|
||||
|
||||
#if 0
|
||||
@@ -230,41 +178,21 @@ static void do_selectmenu(bContext *C, void *arg, int event)
|
||||
}
|
||||
#endif
|
||||
|
||||
static uiBlock *image_selectmenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused)
|
||||
static void image_selectmenu(bContext *C, uiMenuItem *head, void *arg_unused)
|
||||
{
|
||||
ScrArea *sa= CTX_wm_area(C);
|
||||
uiBlock *block;
|
||||
|
||||
/* create menu */
|
||||
block= uiBeginBlock(C, handle->region, "image_selectmenu", UI_EMBOSSP, UI_HELV);
|
||||
uiMenuItemO(head, "UV_OT_border_select", ICON_BLANK1); // Border Select|B
|
||||
uiMenuItemO(head, "UV_OT_border_select_pinned", ICON_BLANK1); // Border Select Pinned|Shift B
|
||||
|
||||
uiDefMenuButO(block, "UV_OT_border_select", NULL); // Border Select|B
|
||||
uiDefMenuButO(block, "UV_OT_border_select_pinned", NULL); // Border Select Pinned|Shift B
|
||||
uiMenuSeparator(head);
|
||||
|
||||
uiMenuItemO(head, "UV_OT_de_select_all", ICON_BLANK1);
|
||||
uiMenuItemO(head, "UV_OT_select_invert", ICON_BLANK1);
|
||||
uiMenuItemO(head, "UV_OT_unlink_selection", ICON_BLANK1); // Unlink Selection|Alt L
|
||||
|
||||
uiMenuSeparator(head);
|
||||
|
||||
uiDefMenuSep(block);
|
||||
|
||||
uiDefMenuButO(block, "UV_OT_de_select_all", NULL);
|
||||
uiDefMenuButO(block, "UV_OT_select_invert", NULL);
|
||||
uiDefMenuButO(block, "UV_OT_unlink_selection", NULL); // Unlink Selection|Alt L
|
||||
|
||||
uiDefMenuSep(block);
|
||||
|
||||
uiDefMenuButO(block, "UV_OT_select_pinned", NULL); // Select Pinned|Shift P
|
||||
uiDefMenuButO(block, "UV_OT_select_linked", NULL); // Select Linked|Ctrl L
|
||||
|
||||
/* position menu */
|
||||
if(sa->headertype==HEADERTOP) {
|
||||
uiBlockSetDirection(block, UI_DOWN);
|
||||
}
|
||||
else {
|
||||
uiBlockSetDirection(block, UI_TOP);
|
||||
uiBlockFlipOrder(block);
|
||||
}
|
||||
|
||||
uiTextBoundsBlock(block, 50);
|
||||
uiEndBlock(C, block);
|
||||
|
||||
return block;
|
||||
uiMenuItemO(head, "UV_OT_select_pinned", ICON_BLANK1); // Select Pinned|Shift P
|
||||
uiMenuItemO(head, "UV_OT_select_linked", ICON_BLANK1); // Select Linked|Ctrl L
|
||||
}
|
||||
|
||||
#if 0
|
||||
@@ -331,12 +259,10 @@ static void do_image_image_rtmappingmenu(void *arg, int event)
|
||||
}
|
||||
#endif
|
||||
|
||||
static uiBlock *image_imagemenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused)
|
||||
static void image_imagemenu(bContext *C, uiMenuItem *head, void *arg_unused)
|
||||
{
|
||||
bScreen *sc= CTX_wm_screen(C);
|
||||
ScrArea *sa= CTX_wm_area(C);
|
||||
SpaceImage *sima= (SpaceImage*)CTX_wm_space_data(C);
|
||||
uiBlock *block;
|
||||
PointerRNA spaceptr;
|
||||
Image *ima;
|
||||
ImBuf *ibuf;
|
||||
@@ -351,34 +277,32 @@ static uiBlock *image_imagemenu(bContext *C, uiMenuBlockHandle *handle, void *ar
|
||||
RNA_pointer_create(&sc->id, &RNA_SpaceImageEditor, sima, &spaceptr);
|
||||
|
||||
/* create menu */
|
||||
block= uiBeginBlock(C, handle->region, "image_imagemenu", UI_EMBOSSP, UI_HELV);
|
||||
|
||||
uiDefMenuButO(block, "IMAGE_OT_new", NULL); // New...|Alt N
|
||||
uiDefMenuButO(block, "IMAGE_OT_open", NULL); // Open...|Alt O
|
||||
uiMenuItemO(head, "IMAGE_OT_new", ICON_BLANK1); // New...|Alt N
|
||||
uiMenuItemO(head, "IMAGE_OT_open", ICON_BLANK1); // Open...|Alt O
|
||||
|
||||
if(ima) {
|
||||
uiDefMenuButO(block, "IMAGE_OT_replace", NULL); // Replace...
|
||||
uiDefMenuButO(block, "IMAGE_OT_reload", NULL); // Reload...|Alt R
|
||||
uiDefMenuButO(block, "IMAGE_OT_save", NULL); // Save|Alt S
|
||||
uiDefMenuButO(block, "IMAGE_OT_save_as", NULL); // Save As...
|
||||
uiMenuItemO(head, "IMAGE_OT_replace", ICON_BLANK1); // Replace...
|
||||
uiMenuItemO(head, "IMAGE_OT_reload", ICON_BLANK1); // Reload...|Alt R
|
||||
uiMenuItemO(head, "IMAGE_OT_save", ICON_BLANK1); // Save|Alt S
|
||||
uiMenuItemO(head, "IMAGE_OT_save_as", ICON_BLANK1); // Save As...
|
||||
if(ima->source == IMA_SRC_SEQUENCE)
|
||||
uiDefMenuButO(block, "IMAGE_OT_save_changed", NULL); // Save Changed Images
|
||||
uiMenuItemO(head, "IMAGE_OT_save_changed", ICON_BLANK1); // Save Changed Images
|
||||
|
||||
if(!show_render) {
|
||||
uiDefMenuSep(block);
|
||||
uiMenuSeparator(head);
|
||||
|
||||
if(ima->packedfile) uiDefMenuButO(block, "IMAGE_OT_unpack", NULL); // Unpack Image...
|
||||
else uiDefMenuButO(block, "IMAGE_OT_pack", NULL); // Pack Image
|
||||
if(ima->packedfile) uiMenuItemO(head, "IMAGE_OT_unpack", ICON_BLANK1); // Unpack Image...
|
||||
else uiMenuItemO(head, "IMAGE_OT_pack", ICON_BLANK1); // Pack Image
|
||||
|
||||
/* 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)
|
||||
uiDefMenuButO(block, "IMAGE_OT_pack_as_png", NULL); // Pack Image As PNG
|
||||
uiMenuItemO(head, "IMAGE_OT_pack_as_png", ICON_BLANK1); // Pack Image As PNG
|
||||
|
||||
uiDefMenuSep(block);
|
||||
uiMenuSeparator(head);
|
||||
|
||||
/* XXX check state better */
|
||||
uiDefMenuTogR(block, &spaceptr, "image_painting", NULL, NULL);
|
||||
uiMenuItemBooleanR(head, &spaceptr, "image_painting");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -398,20 +322,6 @@ static uiBlock *image_imagemenu(bContext *C, uiMenuBlockHandle *handle, void *ar
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* position menu */
|
||||
if(sa->headertype==HEADERTOP) {
|
||||
uiBlockSetDirection(block, UI_DOWN);
|
||||
}
|
||||
else {
|
||||
uiBlockSetDirection(block, UI_TOP);
|
||||
uiBlockFlipOrder(block);
|
||||
}
|
||||
|
||||
uiTextBoundsBlock(block, 80);
|
||||
uiEndBlock(C, block);
|
||||
|
||||
return block;
|
||||
}
|
||||
|
||||
#if 0
|
||||
@@ -432,61 +342,11 @@ static void do_image_uvs_showhidemenu(void *arg, int event)
|
||||
}
|
||||
#endif
|
||||
|
||||
static uiBlock *image_uvs_showhidemenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused)
|
||||
static void image_uvs_showhidemenu(bContext *C, uiMenuItem *head, void *arg_unused)
|
||||
{
|
||||
uiBlock *block;
|
||||
|
||||
/* create menu */
|
||||
block= uiBeginBlock(C, handle->region, "image_uvs_showhidemenu", UI_EMBOSSP, UI_HELV);
|
||||
|
||||
uiDefMenuButO(block, "UV_OT_show_hidden_faces", NULL); // Show Hidden Faces|Alt H
|
||||
uiDefMenuButO(block, "UV_OT_hide_selected_faces", NULL); // Hide Selected Faces|H
|
||||
uiDefMenuButO(block, "UV_OT_hide_deselected_faces", NULL); // Hide Deselected Faces|Shift H
|
||||
|
||||
/* position menu */
|
||||
uiBlockSetDirection(block, UI_RIGHT);
|
||||
uiTextBoundsBlock(block, 60);
|
||||
|
||||
uiEndBlock(C, block);
|
||||
|
||||
return block;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void do_image_uvs_propfalloffmenu(void *arg, int event)
|
||||
{
|
||||
G.scene->prop_mode= event;
|
||||
allqueue(REDRAWVIEW3D, 1);
|
||||
}
|
||||
#endif
|
||||
|
||||
static uiBlock *image_uvs_propfalloffmenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused)
|
||||
{
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
PointerRNA sceneptr;
|
||||
uiBlock *block;
|
||||
|
||||
/* retrieve state */
|
||||
RNA_id_pointer_create(&scene->id, &sceneptr);
|
||||
|
||||
/* create menu */
|
||||
block= uiBeginBlock(C, handle->region, "image_uvs_propfalloffmenu", UI_EMBOSSP, UI_HELV);
|
||||
|
||||
uiDefMenuTogR(block, &sceneptr, "proportional_editing_falloff", "SMOOTH", NULL); // Smooth|Shift O
|
||||
uiDefMenuTogR(block, &sceneptr, "proportional_editing_falloff", "SPHERE", NULL); // Sphere|Shift O
|
||||
uiDefMenuTogR(block, &sceneptr, "proportional_editing_falloff", "ROOT", NULL); // Root|Shift O
|
||||
uiDefMenuTogR(block, &sceneptr, "proportional_editing_falloff", "SHARP", NULL); // Sharp|Shift O
|
||||
uiDefMenuTogR(block, &sceneptr, "proportional_editing_falloff", "LINEAR", NULL); // Linear|Shift O
|
||||
uiDefMenuTogR(block, &sceneptr, "proportional_editing_falloff", "RANDOM", NULL); // Random|Shift O
|
||||
uiDefMenuTogR(block, &sceneptr, "proportional_editing_falloff", "CONSTANT", NULL); // Constant|Shift O
|
||||
|
||||
/* position menu */
|
||||
uiBlockSetDirection(block, UI_RIGHT);
|
||||
uiTextBoundsBlock(block, 60);
|
||||
|
||||
uiEndBlock(C, block);
|
||||
|
||||
return block;
|
||||
uiMenuItemO(head, "UV_OT_show_hidden_faces", ICON_BLANK1); // Show Hidden Faces|Alt H
|
||||
uiMenuItemO(head, "UV_OT_hide_selected_faces", ICON_BLANK1); // Hide Selected Faces|H
|
||||
uiMenuItemO(head, "UV_OT_hide_deselected_faces", ICON_BLANK1); // Hide Deselected Faces|Shift H
|
||||
}
|
||||
|
||||
#if 0
|
||||
@@ -509,24 +369,11 @@ static void do_image_uvs_transformmenu(void *arg, int event)
|
||||
}
|
||||
#endif
|
||||
|
||||
static uiBlock *image_uvs_transformmenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused)
|
||||
static void image_uvs_transformmenu(bContext *C, uiMenuItem *head, void *arg_unused)
|
||||
{
|
||||
uiBlock *block;
|
||||
|
||||
/* create menu */
|
||||
block= uiBeginBlock(C, handle->region, "image_uvs_transformmenu", UI_EMBOSSP, UI_HELV);
|
||||
|
||||
uiDefMenuButO(block, "UV_OT_grab", NULL); // Grab/Move|G
|
||||
uiDefMenuButO(block, "UV_OT_rotate", NULL); // Rotate|R
|
||||
uiDefMenuButO(block, "UV_OT_scale", NULL); // Scale|S
|
||||
|
||||
/* position menu */
|
||||
uiBlockSetDirection(block, UI_RIGHT);
|
||||
uiTextBoundsBlock(block, 60);
|
||||
|
||||
uiEndBlock(C, block);
|
||||
|
||||
return block;
|
||||
uiMenuItemO(head, "UV_OT_grab", ICON_BLANK1); // Grab/Move|G
|
||||
uiMenuItemO(head, "UV_OT_rotate", ICON_BLANK1); // Rotate|R
|
||||
uiMenuItemO(head, "UV_OT_scale", ICON_BLANK1); // Scale|S
|
||||
}
|
||||
|
||||
#if 0
|
||||
@@ -553,26 +400,10 @@ static void do_image_uvs_mirrormenu(void *arg, int event)
|
||||
}
|
||||
#endif
|
||||
|
||||
static uiBlock *image_uvs_mirrormenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused)
|
||||
static void image_uvs_mirrormenu(bContext *C, uiMenuItem *head, void *arg_unused)
|
||||
{
|
||||
uiBlock *block;
|
||||
uiBut *but;
|
||||
|
||||
/* create menu */
|
||||
block= uiBeginBlock(C, handle->region, "image_uvs_mirrormenu", UI_EMBOSSP, UI_HELV);
|
||||
|
||||
but= uiDefMenuButO(block, "UV_OT_mirror", "X Axis"); // M, 1
|
||||
RNA_enum_set(uiButGetOperatorPtrRNA(but), "axis", 'x');
|
||||
but= uiDefMenuButO(block, "UV_OT_mirror", "Y Axis"); // M, 2
|
||||
RNA_enum_set(uiButGetOperatorPtrRNA(but), "axis", 'y');
|
||||
|
||||
/* position menu */
|
||||
uiBlockSetDirection(block, UI_RIGHT);
|
||||
uiTextBoundsBlock(block, 60);
|
||||
|
||||
uiEndBlock(C, block);
|
||||
|
||||
return block;
|
||||
uiMenuItemEnumO(head, "UV_OT_mirror", "axis", 'x'); // "X Axis", M, 1
|
||||
uiMenuItemEnumO(head, "UV_OT_mirror", "axis", 'y'); // "Y Axis", M, 2
|
||||
}
|
||||
|
||||
#if 0
|
||||
@@ -598,29 +429,10 @@ static void do_image_uvs_weldalignmenu(void *arg, int event)
|
||||
}
|
||||
#endif
|
||||
|
||||
static uiBlock *image_uvs_weldalignmenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused)
|
||||
static void image_uvs_weldalignmenu(bContext *C, uiMenuItem *head, void *arg_unused)
|
||||
{
|
||||
uiBlock *block;
|
||||
uiBut *but;
|
||||
|
||||
/* create menu */
|
||||
block= uiBeginBlock(C, handle->region, "image_uvs_weldalignmenu", UI_EMBOSSP, UI_HELV);
|
||||
|
||||
but= uiDefMenuButO(block, "UV_OT_weld", NULL); // W, 1
|
||||
but= uiDefMenuButO(block, "UV_OT_align", "Align Auto"); // W, 2
|
||||
RNA_enum_set(uiButGetOperatorPtrRNA(but), "axis", 'a');
|
||||
but= uiDefMenuButO(block, "UV_OT_align", "Align X"); // W, 3
|
||||
RNA_enum_set(uiButGetOperatorPtrRNA(but), "axis", 'x');
|
||||
but= uiDefMenuButO(block, "UV_OT_align", "Align Y"); // W, 4
|
||||
RNA_enum_set(uiButGetOperatorPtrRNA(but), "axis", 'y');
|
||||
|
||||
/* position menu */
|
||||
uiBlockSetDirection(block, UI_RIGHT);
|
||||
uiTextBoundsBlock(block, 60);
|
||||
|
||||
uiEndBlock(C, block);
|
||||
|
||||
return block;
|
||||
uiMenuItemO(head, "UV_OT_weld", ICON_BLANK1); // W, 1
|
||||
uiMenuItemsEnumO(head, "UV_OT_align", "axis"); // W, 2/3/4
|
||||
}
|
||||
|
||||
#if 0
|
||||
@@ -632,7 +444,7 @@ static void do_image_uvs_scriptsmenu(void *arg, int event)
|
||||
allqueue(REDRAWIMAGE, 0);
|
||||
}
|
||||
|
||||
static uiBlock *image_uvs_scriptsmenu (void *args_unused)
|
||||
static void image_uvs_scriptsmenu (void *args_unused)
|
||||
{
|
||||
uiBlock *block;
|
||||
BPyMenu *pym;
|
||||
@@ -662,10 +474,6 @@ static uiBlock *image_uvs_scriptsmenu (void *args_unused)
|
||||
static void do_uvsmenu(bContext *C, void *arg, int event)
|
||||
{
|
||||
switch(event) {
|
||||
case 1: /* UVs Constrained Rectangular */
|
||||
if(sima->flag & SI_BE_SQUARE) sima->flag &= ~SI_BE_SQUARE;
|
||||
else sima->flag |= SI_BE_SQUARE;
|
||||
break;
|
||||
case 2: /* UVs Clipped to Image Size */
|
||||
if(sima->flag & SI_CLIP_UV) sima->flag &= ~SI_CLIP_UV;
|
||||
else sima->flag |= SI_CLIP_UV;
|
||||
@@ -705,13 +513,11 @@ static void do_uvsmenu(bContext *C, void *arg, int event)
|
||||
}
|
||||
#endif
|
||||
|
||||
static uiBlock *image_uvsmenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused)
|
||||
static void image_uvsmenu(bContext *C, uiMenuItem *head, void *arg_unused)
|
||||
{
|
||||
bScreen *sc= CTX_wm_screen(C);
|
||||
ScrArea *sa= CTX_wm_area(C);
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
SpaceImage *sima= (SpaceImage*)CTX_wm_space_data(C);
|
||||
uiBlock *block;
|
||||
PointerRNA uvptr, sceneptr;
|
||||
Image *ima;
|
||||
ImBuf *ibuf;
|
||||
@@ -724,61 +530,45 @@ static uiBlock *image_uvsmenu(bContext *C, uiMenuBlockHandle *handle, void *arg_
|
||||
RNA_id_pointer_create(&scene->id, &sceneptr);
|
||||
|
||||
/* create menu */
|
||||
block= uiBeginBlock(C, handle->region, "image_imagemenu", UI_EMBOSSP, UI_HELV);
|
||||
uiMenuItemBooleanR(head, &uvptr, "snap_to_pixels");
|
||||
uiMenuItemBooleanR(head, &uvptr, "constrain_to_image_bounds");
|
||||
|
||||
uiDefMenuTogR(block, &uvptr, "snap_to_pixels", 0, NULL);
|
||||
uiDefMenuTogR(block, &uvptr, "constrain_quads_rectangular", 0, NULL);
|
||||
uiDefMenuTogR(block, &uvptr, "constrain_to_image_bounds", 0, NULL);
|
||||
uiMenuSeparator(head);
|
||||
|
||||
uiDefMenuSep(block);
|
||||
uiMenuItemBooleanR(head, &uvptr, "live_unwrap");
|
||||
uiMenuItemO(head, "UV_OT_unwrap", ICON_BLANK1); // Unwrap|E
|
||||
uiMenuItemO(head, "UV_OT_unpin", ICON_BLANK1); // Unpin|Alt P
|
||||
uiMenuItemO(head, "UV_OT_pin", ICON_BLANK1); // Pin|P
|
||||
|
||||
uiDefMenuTogR(block, &uvptr, "live_unwrap", 0, NULL);
|
||||
uiDefMenuButO(block, "UV_OT_unwrap", NULL); // Unwrap|E
|
||||
uiDefMenuButO(block, "UV_OT_unpin", NULL); // Unpin|Alt P
|
||||
uiDefMenuButO(block, "UV_OT_pin", NULL); // Pin|P
|
||||
uiMenuSeparator(head);
|
||||
|
||||
uiDefMenuSep(block);
|
||||
uiMenuItemO(head, "UV_OT_pack_islands", ICON_BLANK1); // Pack Islands|Ctr P
|
||||
uiMenuItemO(head, "UV_OT_average_islands", ICON_BLANK1); // Average Islands Scale|Ctrl A
|
||||
uiMenuItemO(head, "UV_OT_minimize_stretch", ICON_BLANK1); // Minimize Stretch...|Ctrl V
|
||||
uiMenuItemO(head, "UV_OT_stitch", ICON_BLANK1);
|
||||
|
||||
uiDefMenuButO(block, "UV_OT_pack_islands", NULL); // Pack Islands|Ctr P
|
||||
uiDefMenuButO(block, "UV_OT_average_islands", NULL); // Average Islands Scale|Ctrl A
|
||||
uiDefMenuButO(block, "UV_OT_minimize_stretch", NULL); // Minimize Stretch...|Ctrl V
|
||||
uiDefMenuButO(block, "UV_OT_stitch", NULL);
|
||||
uiMenuSeparator(head);
|
||||
|
||||
uiDefMenuSep(block);
|
||||
uiMenuLevel(head, "Transform", image_uvs_transformmenu);
|
||||
uiMenuLevel(head, "Mirror", image_uvs_mirrormenu);
|
||||
uiMenuLevel(head, "Weld/Align", image_uvs_weldalignmenu);
|
||||
|
||||
uiDefMenuSub(block, image_uvs_transformmenu, "Transform");
|
||||
uiDefMenuSub(block, image_uvs_mirrormenu, "Mirror");
|
||||
uiDefMenuSub(block, image_uvs_weldalignmenu, "Weld/Align");
|
||||
uiMenuSeparator(head);
|
||||
|
||||
uiDefMenuSep(block);
|
||||
uiMenuItemBooleanR(head, &sceneptr, "proportional_editing");
|
||||
uiMenuLevelEnumR(head, &sceneptr, "proportional_editing_falloff");
|
||||
|
||||
uiDefMenuTogR(block, &sceneptr, "proportional_editing", 0, NULL);
|
||||
uiDefMenuSub(block, image_uvs_propfalloffmenu, "Proportional Falloff");
|
||||
uiMenuSeparator(head);
|
||||
|
||||
uiDefMenuSep(block);
|
||||
|
||||
uiDefMenuSub(block, image_uvs_showhidemenu, "Show/Hide Faces");
|
||||
uiMenuLevel(head, "Show/Hide Faces", image_uvs_showhidemenu);
|
||||
|
||||
#if 0
|
||||
#ifndef DISABLE_PYTHON
|
||||
uiDefMenuSep(block);
|
||||
uiMenuSeparator(head);
|
||||
|
||||
uiDefMenuSub(block, image_uvs_scriptsmenu, "Scripts");
|
||||
uiMenuLevel(head, "Scripts", image_uvs_scriptsmenu);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if(sa->headertype==HEADERTOP) {
|
||||
uiBlockSetDirection(block, UI_DOWN);
|
||||
}
|
||||
else {
|
||||
uiBlockSetDirection(block, UI_TOP);
|
||||
uiBlockFlipOrder(block);
|
||||
}
|
||||
|
||||
uiTextBoundsBlock(block, 50);
|
||||
uiEndBlock(C, block);
|
||||
|
||||
return block;
|
||||
}
|
||||
|
||||
static void image_menu_uvlayers(Object *obedit, char *menustr, int *active)
|
||||
@@ -1134,23 +924,23 @@ void image_header_buttons(const bContext *C, ARegion *ar)
|
||||
uiBlockSetEmboss(block, UI_EMBOSSP);
|
||||
|
||||
xmax= GetButStringLength("View");
|
||||
uiDefPulldownBut(block, image_viewmenu, NULL, "View", xco, yco-2, xmax-3, 24, "");
|
||||
uiDefMenuBut(block, image_viewmenu, NULL, "View", xco, yco-2, xmax-3, 24, "");
|
||||
xco+= xmax;
|
||||
|
||||
if(show_uvedit) {
|
||||
xmax= GetButStringLength("Select");
|
||||
uiDefPulldownBut(block, image_selectmenu, NULL, "Select", xco, yco-2, xmax-3, 24, "");
|
||||
uiDefMenuBut(block, image_selectmenu, NULL, "Select", xco, yco-2, xmax-3, 24, "");
|
||||
xco+= xmax;
|
||||
}
|
||||
|
||||
menuname= (ibuf && (ibuf->userflags & IB_BITMAPDIRTY))? "Image*": "Image";
|
||||
xmax= GetButStringLength(menuname);
|
||||
uiDefPulldownBut(block, image_imagemenu, NULL, menuname, xco, yco-2, xmax-3, 24, "");
|
||||
uiDefMenuBut(block, image_imagemenu, NULL, menuname, xco, yco-2, xmax-3, 24, "");
|
||||
xco+= xmax;
|
||||
|
||||
if(show_uvedit) {
|
||||
xmax= GetButStringLength("UVs");
|
||||
uiDefPulldownBut(block, image_uvsmenu, NULL, "UVs", xco, yco-2, xmax-3, 24, "");
|
||||
uiDefMenuBut(block, image_uvsmenu, NULL, "UVs", xco, yco-2, xmax-3, 24, "");
|
||||
xco+= xmax;
|
||||
}
|
||||
}
|
||||
@@ -1306,11 +1096,11 @@ void image_header_buttons(const bContext *C, ARegion *ar)
|
||||
/* record & play */
|
||||
uiBlockBeginAlign(block);
|
||||
if(ima->type==IMA_TYPE_COMPOSITE) {
|
||||
uiDefIconButO(block, BUT, "IMAGE_OT_record_composite", WM_OP_INVOKE_REGION_WIN, ICON_REC, xco, yco, XIC, YIC, NULL); // Record Composite
|
||||
//XXX 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)) {
|
||||
uiDefIconButO(block, BUT, "IMAGE_OT_play_composite", WM_OP_INVOKE_REGION_WIN, ICON_PLAY, xco, yco, XIC, YIC, NULL); // PLAY
|
||||
//XXX uiDefIconButO(block, BUT, "IMAGE_OT_play_composite", WM_OP_INVOKE_REGION_WIN, ICON_PLAY, xco, yco, XIC, YIC, NULL); // PLAY
|
||||
xco+= XIC;
|
||||
}
|
||||
uiBlockEndAlign(block);
|
||||
@@ -1327,3 +1117,38 @@ void image_header_buttons(const bContext *C, ARegion *ar)
|
||||
uiDrawBlock(C, block);
|
||||
}
|
||||
|
||||
/********************** toolbox operator *********************/
|
||||
|
||||
static int toolbox_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
||||
{
|
||||
SpaceImage *sima= (SpaceImage*)CTX_wm_space_data(C);
|
||||
Object *obedit= CTX_data_edit_object(C);
|
||||
uiMenuItem *head;
|
||||
int show_uvedit;
|
||||
|
||||
show_uvedit= get_space_image_show_uvedit(sima, obedit);
|
||||
|
||||
head= uiPupMenuBegin("Toolbox");
|
||||
|
||||
uiMenuLevel(head, "View", image_viewmenu);
|
||||
if(show_uvedit) uiMenuLevel(head, "Select", image_selectmenu);
|
||||
uiMenuLevel(head, "Image", image_imagemenu);
|
||||
if(show_uvedit) uiMenuLevel(head, "UVs", image_uvsmenu);
|
||||
|
||||
uiPupMenuEnd(C, head);
|
||||
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
void IMAGE_OT_toolbox(wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name= "Toolbox";
|
||||
ot->idname= "IMAGE_OT_toolbox";
|
||||
|
||||
/* api callbacks */
|
||||
ot->invoke= toolbox_invoke;
|
||||
ot->poll= space_image_main_area_poll;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -47,6 +47,7 @@ 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);
|
||||
@@ -56,10 +57,14 @@ 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);
|
||||
|
||||
void IMAGE_OT_toolbox(struct wmOperatorType *ot);
|
||||
|
||||
/* image_draw.c */
|
||||
void draw_image_main(struct SpaceImage *sima, struct ARegion *ar, struct Scene *scene);
|
||||
|
||||
/* image_ops.c */
|
||||
int space_image_main_area_poll(struct bContext *C);
|
||||
|
||||
void IMAGE_OT_view_all(struct wmOperatorType *ot);
|
||||
void IMAGE_OT_view_pan(struct wmOperatorType *ot);
|
||||
void IMAGE_OT_view_selected(struct wmOperatorType *ot);
|
||||
|
||||
@@ -144,7 +144,7 @@ static void sima_zoom_set_factor(SpaceImage *sima, ARegion *ar, float zoomfac)
|
||||
sima_zoom_set(sima, ar, sima->zoom*zoomfac);
|
||||
}
|
||||
|
||||
static int space_image_main_area_poll(bContext *C)
|
||||
int space_image_main_area_poll(bContext *C)
|
||||
{
|
||||
SpaceLink *slink= CTX_wm_space_data(C);
|
||||
ARegion *ar= CTX_wm_region(C);
|
||||
|
||||
@@ -53,6 +53,7 @@
|
||||
#include "IMB_imbuf.h"
|
||||
#include "IMB_imbuf_types.h"
|
||||
|
||||
#include "ED_image.h"
|
||||
#include "ED_mesh.h"
|
||||
#include "ED_space_api.h"
|
||||
#include "ED_screen.h"
|
||||
@@ -145,6 +146,8 @@ void image_operatortypes(void)
|
||||
WM_operatortype_append(IMAGE_OT_view_zoom_in);
|
||||
WM_operatortype_append(IMAGE_OT_view_zoom_out);
|
||||
WM_operatortype_append(IMAGE_OT_view_zoom_ratio);
|
||||
|
||||
WM_operatortype_append(IMAGE_OT_toolbox);
|
||||
}
|
||||
|
||||
void image_keymap(struct wmWindowManager *wm)
|
||||
@@ -168,6 +171,8 @@ void image_keymap(struct wmWindowManager *wm)
|
||||
RNA_float_set(WM_keymap_add_item(keymap, "IMAGE_OT_view_zoom_ratio", PAD2, KM_PRESS, 0, 0)->ptr, "ratio", 0.5f);
|
||||
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_toolbox", SPACEKEY, KM_PRESS, 0, 0);
|
||||
}
|
||||
|
||||
static void image_refresh(const bContext *C, ScrArea *sa)
|
||||
@@ -215,6 +220,8 @@ static void image_listener(ScrArea *sa, wmNotifier *wmn)
|
||||
case NC_SCENE:
|
||||
switch(wmn->data) {
|
||||
case ND_MODE:
|
||||
case ND_RENDER_RESULT:
|
||||
case ND_COMPO_RESULT:
|
||||
ED_area_tag_refresh(sa);
|
||||
ED_area_tag_redraw(sa);
|
||||
break;
|
||||
@@ -545,6 +552,17 @@ void get_space_image_zoom(SpaceImage *sima, ARegion *ar, float *zoomx, float *zo
|
||||
*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)
|
||||
{
|
||||
int w, h;
|
||||
|
||||
get_space_image_aspect(sima, aspx, aspy);
|
||||
get_space_image_size(sima, &w, &h);
|
||||
|
||||
*aspx *= (float)w;
|
||||
*aspy *= (float)h;
|
||||
}
|
||||
|
||||
int get_space_image_show_render(SpaceImage *sima)
|
||||
{
|
||||
return (sima->image && ELEM(sima->image->type, IMA_TYPE_R_RESULT, IMA_TYPE_COMPOSITE));
|
||||
@@ -583,3 +601,21 @@ int get_space_image_show_uvshadow(SpaceImage *sima, Object *obedit)
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -65,13 +65,13 @@ static void do_viewmenu(bContext *C, void *arg, int event)
|
||||
|
||||
}
|
||||
|
||||
static uiBlock *dummy_viewmenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused)
|
||||
static uiBlock *dummy_viewmenu(bContext *C, ARegion *ar, void *arg_unused)
|
||||
{
|
||||
ScrArea *curarea= CTX_wm_area(C);
|
||||
uiBlock *block;
|
||||
short yco= 0, menuwidth=120;
|
||||
|
||||
block= uiBeginBlock(C, handle->region, "dummy_viewmenu", UI_EMBOSSP, UI_HELV);
|
||||
block= uiBeginBlock(C, ar, "dummy_viewmenu", UI_EMBOSSP, UI_HELV);
|
||||
uiBlockSetButmFunc(block, do_viewmenu, NULL);
|
||||
|
||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Nothing yet", 0, yco-=20,
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -3,7 +3,7 @@ Import ('env')
|
||||
|
||||
sources = env.Glob('*.c')
|
||||
|
||||
incs = '../include ../../blenlib ../../blenkernel ../../makesdna ../../imbuf'
|
||||
incs = '../include ../../blenlib ../../blenkernel ../../makesdna ../../makesrna ../../imbuf'
|
||||
incs += ' ../../windowmanager #/intern/guardedalloc #/extern/glew/include'
|
||||
|
||||
env.BlenderLib ( 'bf_editors_space_ipo', sources, Split(incs), [], libtype=['core'], priority=[50] )
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user