forked from bartvdbraak/blender
Merging r41176 through r41192 from trunk into soc-2011-tomato
This commit is contained in:
commit
0d6915a4e7
@ -1655,15 +1655,8 @@ GHOST_TSuccess GHOST_SystemCocoa::handleKeyEvent(void *eventPtr)
|
||||
return GHOST_kFailure;
|
||||
}
|
||||
|
||||
/* unicode input - not entirely supported yet
|
||||
* but we are getting the right byte, Blender is not drawing it though
|
||||
* also some languages may need special treatment:
|
||||
- Japanese: romanji is used as input, and every 2 letters OSX converts the text
|
||||
to Hiragana/Katakana.
|
||||
- Korean: one add one letter at a time, and then the OSX join them in the equivalent
|
||||
combined letter.
|
||||
*/
|
||||
char utf8_buf[6]= {'\0'};
|
||||
ascii = 0;
|
||||
|
||||
switch ([event type]) {
|
||||
|
||||
@ -1678,39 +1671,21 @@ GHOST_TSuccess GHOST_SystemCocoa::handleKeyEvent(void *eventPtr)
|
||||
keyCode = convertKey([event keyCode],0,
|
||||
[event type] == NSKeyDown?kUCKeyActionDown:kUCKeyActionUp);
|
||||
|
||||
/* ascii */
|
||||
/* handling both unicode or ascii */
|
||||
characters = [event characters];
|
||||
if ([characters length]>0) { //Check for dead keys
|
||||
//Convert characters to iso latin 1 encoding
|
||||
convertedCharacters = [characters dataUsingEncoding:NSISOLatin1StringEncoding];
|
||||
if ([convertedCharacters length]>0)
|
||||
ascii =((char*)[convertedCharacters bytes])[0];
|
||||
else
|
||||
ascii = 0; //Character not available in iso latin 1 encoding
|
||||
}
|
||||
else
|
||||
ascii= 0;
|
||||
|
||||
/* unicode */
|
||||
if ([characters length]>0) {
|
||||
convertedCharacters = [characters dataUsingEncoding:NSUTF8StringEncoding];
|
||||
if ([convertedCharacters length]>0) {
|
||||
utf8_buf[0] = ((char*)[convertedCharacters bytes])[0];
|
||||
utf8_buf[1] = ((char*)[convertedCharacters bytes])[1];
|
||||
utf8_buf[2] = ((char*)[convertedCharacters bytes])[2];
|
||||
utf8_buf[3] = ((char*)[convertedCharacters bytes])[3];
|
||||
utf8_buf[4] = ((char*)[convertedCharacters bytes])[4];
|
||||
utf8_buf[5] = ((char*)[convertedCharacters bytes])[5];
|
||||
|
||||
for (int x = 0; x < [convertedCharacters length]; x++) {
|
||||
utf8_buf[x] = ((char*)[convertedCharacters bytes])[x];
|
||||
}
|
||||
else {
|
||||
utf8_buf[0] = '\0';
|
||||
|
||||
/* ascii is a subset of unicode */
|
||||
if ([convertedCharacters length] == 1) {
|
||||
ascii = utf8_buf[0];
|
||||
}
|
||||
}
|
||||
|
||||
/* XXX the above code gives us the right utf8, however if we pass it along Font Object doesn't work.
|
||||
let's leave utf8 disabled for OSX before we fix that */
|
||||
utf8_buf[0] = '\0';//to be removed once things are working
|
||||
|
||||
if ((keyCode == GHOST_kKeyQ) && (m_modifierMask & NSCommandKeyMask))
|
||||
break; //Cmd-Q is directly handled by Cocoa
|
||||
|
||||
@ -1718,8 +1693,8 @@ GHOST_TSuccess GHOST_SystemCocoa::handleKeyEvent(void *eventPtr)
|
||||
pushEvent( new GHOST_EventKey([event timestamp]*1000, GHOST_kEventKeyDown, window, keyCode, ascii, utf8_buf) );
|
||||
//printf("Key down rawCode=0x%x charsIgnoringModifiers=%c keyCode=%u ascii=%i %c utf8=%s\n",[event keyCode],[charsIgnoringModifiers length]>0?[charsIgnoringModifiers characterAtIndex:0]:' ',keyCode,ascii,ascii, utf8_buf);
|
||||
} else {
|
||||
pushEvent( new GHOST_EventKey([event timestamp]*1000, GHOST_kEventKeyUp, window, keyCode, ascii, utf8_buf) );
|
||||
//printf("Key down rawCode=0x%x charsIgnoringModifiers=%c keyCode=%u ascii=%i %c utf8=%s\n",[event keyCode],[charsIgnoringModifiers length]>0?[charsIgnoringModifiers characterAtIndex:0]:' ',keyCode,ascii,ascii, utf8_buf);
|
||||
pushEvent( new GHOST_EventKey([event timestamp]*1000, GHOST_kEventKeyUp, window, keyCode, 0, '\0') );
|
||||
//printf("Key up rawCode=0x%x charsIgnoringModifiers=%c keyCode=%u ascii=%i %c utf8=%s\n",[event keyCode],[charsIgnoringModifiers length]>0?[charsIgnoringModifiers characterAtIndex:0]:' ',keyCode,ascii,ascii, utf8_buf);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -712,21 +712,23 @@ GHOST_EventKey* GHOST_SystemWin32::processKeyEvent(GHOST_IWindow *window, RAWINP
|
||||
GHOST_SystemWin32 * system = (GHOST_SystemWin32 *)getSystem();
|
||||
GHOST_TKey key = system->hardKey(window, raw, &keyDown, &vk);
|
||||
GHOST_EventKey* event;
|
||||
|
||||
if (key != GHOST_kKeyUnknown) {
|
||||
char ascii = '\0';
|
||||
char utf8_char[6] = {0} ;
|
||||
|
||||
unsigned short utf16[2]={0};
|
||||
wchar_t utf16[2]={0};
|
||||
BYTE state[256];
|
||||
GetKeyboardState((PBYTE)state);
|
||||
GetKeyboardState((PBYTE)state);
|
||||
|
||||
if(ToAsciiEx(vk, 0, state, utf16, 0, system->m_keylayout))
|
||||
WideCharToMultiByte(CP_ACP, 0x00000400,
|
||||
if(ToUnicodeEx(vk, 0, state, utf16, 2, 0, system->m_keylayout))
|
||||
WideCharToMultiByte(CP_UTF8, 0,
|
||||
(wchar_t*)utf16, 1,
|
||||
(LPSTR) &ascii, 1,
|
||||
NULL,NULL);
|
||||
(LPSTR) utf8_char, 5,
|
||||
NULL,NULL); else *utf8_char = 0;
|
||||
|
||||
/* TODO, last arg is utf8, need to pass utf8 arg */
|
||||
event = new GHOST_EventKey(system->getMilliSeconds(), keyDown ? GHOST_kEventKeyDown: GHOST_kEventKeyUp, window, key, ascii, NULL);
|
||||
if(!keyDown) utf8_char[0] = '\0';
|
||||
|
||||
event = new GHOST_EventKey(system->getMilliSeconds(), keyDown ? GHOST_kEventKeyDown: GHOST_kEventKeyUp, window, key, (*utf8_char & 0x80)?'?':*utf8_char, utf8_char);
|
||||
|
||||
#ifdef GHOST_DEBUG
|
||||
std::cout << ascii << std::endl;
|
||||
|
@ -50,9 +50,8 @@
|
||||
extern int datatoc_bfont_ttf_size;
|
||||
extern char datatoc_bfont_ttf[];
|
||||
|
||||
// XXX, bad, but BLI uses these
|
||||
char bprogname[160]= "";
|
||||
char U[1024]= {0};
|
||||
/* cheat */
|
||||
char U[1024]= {0};
|
||||
#endif
|
||||
|
||||
#include "Util.h"
|
||||
|
@ -49,14 +49,14 @@
|
||||
* the Standard Template Library but without the painful get()
|
||||
* semantics to access the internal c style pointer.
|
||||
*
|
||||
* It is often useful to explicitely decalre ownership of memory
|
||||
* It is often useful to explicitly declare ownership of memory
|
||||
* allocated on the heap within class or function scope. This
|
||||
* class helps you to encapsulate this ownership within a value
|
||||
* type. When an instance of this class goes out of scope it
|
||||
* makes sure that any memory associated with it's internal pointer
|
||||
* is deleted. It can help to inform users of an aggregate class
|
||||
* that it owns instances of it's members and these instances
|
||||
* should not be shared. This is not reliably enforcable in C++
|
||||
* should not be shared. This is not reliably enforceable in C++
|
||||
* but this class attempts to make the 1-1 relationship clear.
|
||||
*
|
||||
* @section Example usage
|
||||
|
@ -136,7 +136,7 @@ char *blf_dir_search(const char *file)
|
||||
|
||||
for(dir=global_font_dir.first; dir; dir= dir->next) {
|
||||
BLI_join_dirfile(full_path, sizeof(full_path), dir->path, file);
|
||||
if (BLI_exist(full_path)) {
|
||||
if (BLI_exists(full_path)) {
|
||||
s= BLI_strdup(full_path);
|
||||
break;
|
||||
}
|
||||
@ -144,7 +144,7 @@ char *blf_dir_search(const char *file)
|
||||
|
||||
if (!s) {
|
||||
/* check the current directory, why not ? */
|
||||
if (BLI_exist(file))
|
||||
if (BLI_exists(file))
|
||||
s= BLI_strdup(file);
|
||||
}
|
||||
|
||||
@ -198,13 +198,13 @@ char *blf_dir_metrics_search(const char *filename)
|
||||
s[2]= 'm';
|
||||
|
||||
/* first check .afm */
|
||||
if (BLI_exist(s))
|
||||
if (BLI_exists(s))
|
||||
return s;
|
||||
|
||||
/* and now check .pfm */
|
||||
s[0]= 'p';
|
||||
|
||||
if (BLI_exist(s))
|
||||
if (BLI_exists(s))
|
||||
return s;
|
||||
}
|
||||
MEM_freeN(mfile);
|
||||
|
@ -55,6 +55,7 @@
|
||||
|
||||
#include "BLI_linklist.h" /* linknode */
|
||||
#include "BLI_string.h"
|
||||
#include "BLI_utildefines.h"
|
||||
#include "BLI_path_util.h"
|
||||
|
||||
#define DOMAIN_NAME "blender"
|
||||
|
@ -34,7 +34,6 @@
|
||||
*/
|
||||
|
||||
#include "BLI_kdopbvh.h"
|
||||
#include "BLI_linklist.h"
|
||||
|
||||
/*
|
||||
* This header encapsulates necessary code to buld a BVH
|
||||
@ -118,7 +117,7 @@ void free_bvhtree_from_mesh(struct BVHTreeFromMesh *data);
|
||||
#define BVHTREE_FROM_VERTICES 1
|
||||
#define BVHTREE_FROM_EDGES 2
|
||||
|
||||
typedef LinkNode* BVHCache;
|
||||
typedef struct LinkNode* BVHCache;
|
||||
|
||||
|
||||
/*
|
||||
|
@ -50,6 +50,7 @@
|
||||
#include "BLI_memarena.h"
|
||||
#include "BLI_pbvh.h"
|
||||
#include "BLI_utildefines.h"
|
||||
#include "BLI_linklist.h"
|
||||
|
||||
#include "BKE_cdderivedmesh.h"
|
||||
#include "BKE_displist.h"
|
||||
|
@ -59,7 +59,6 @@
|
||||
#include "BLI_blenlib.h"
|
||||
#include "BLI_bpath.h"
|
||||
#include "BLI_dynstr.h"
|
||||
#include "BLI_path_util.h"
|
||||
#include "BLI_utildefines.h"
|
||||
#include "BLI_callbacks.h"
|
||||
|
||||
@ -551,7 +550,7 @@ void BKE_write_undo(bContext *C, const char *name)
|
||||
counter= counter % U.undosteps;
|
||||
|
||||
BLI_snprintf(numstr, sizeof(numstr), "%d.blend", counter);
|
||||
BLI_make_file_string("/", filepath, btempdir, numstr);
|
||||
BLI_make_file_string("/", filepath, BLI_temporary_dir(), numstr);
|
||||
|
||||
/* success= */ /* UNUSED */ BLO_write_file(CTX_data_main(C), filepath, fileflags, NULL, NULL);
|
||||
|
||||
@ -721,7 +720,7 @@ void BKE_undo_save_quit(void)
|
||||
/* no undo state to save */
|
||||
if(undobase.first==undobase.last) return;
|
||||
|
||||
BLI_make_file_string("/", str, btempdir, "quit.blend");
|
||||
BLI_make_file_string("/", str, BLI_temporary_dir(), "quit.blend");
|
||||
|
||||
file = open(str,O_BINARY+O_WRONLY+O_CREAT+O_TRUNC, 0666);
|
||||
if(file == -1) {
|
||||
|
@ -40,6 +40,7 @@
|
||||
|
||||
#include "BLI_editVert.h"
|
||||
#include "BLI_utildefines.h"
|
||||
#include "BLI_linklist.h"
|
||||
|
||||
#include "BKE_DerivedMesh.h"
|
||||
|
||||
|
@ -40,6 +40,7 @@
|
||||
#include "BLI_math.h"
|
||||
#include "BLI_edgehash.h"
|
||||
#include "BLI_utildefines.h"
|
||||
#include "BLI_linklist.h"
|
||||
|
||||
#include "BKE_cdderivedmesh.h"
|
||||
#include "BKE_cloth.h"
|
||||
|
@ -41,7 +41,6 @@
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "BLI_blenlib.h"
|
||||
#include "BLI_listbase.h"
|
||||
#include "BLI_math.h"
|
||||
#include "BLI_editVert.h"
|
||||
#include "BLI_utildefines.h"
|
||||
|
@ -47,7 +47,6 @@
|
||||
#include "DNA_ID.h"
|
||||
|
||||
#include "BLI_blenlib.h"
|
||||
#include "BLI_path_util.h"
|
||||
#include "BLI_linklist.h"
|
||||
#include "BLI_math.h"
|
||||
#include "BLI_mempool.h"
|
||||
|
@ -59,8 +59,6 @@
|
||||
#include "BLI_math.h"
|
||||
#include "BLI_blenlib.h"
|
||||
#include "BLI_jitter.h"
|
||||
#include "BLI_listbase.h"
|
||||
#include "BLI_noise.h"
|
||||
#include "BLI_rand.h"
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
|
@ -54,6 +54,7 @@
|
||||
#include "BLI_utildefines.h"
|
||||
#include "BLI_path_util.h"
|
||||
#include "BLI_listbase.h"
|
||||
#include "BLI_linklist.h"
|
||||
#include "BLI_string.h"
|
||||
|
||||
#include "BKE_bmesh.h"
|
||||
|
@ -54,6 +54,7 @@
|
||||
#include "BLI_kdtree.h"
|
||||
#include "BLI_rand.h"
|
||||
#include "BLI_threads.h"
|
||||
#include "BLI_linklist.h"
|
||||
|
||||
#include "BKE_anim.h"
|
||||
#include "BKE_animsys.h"
|
||||
|
@ -64,13 +64,12 @@
|
||||
#include "BLI_rand.h"
|
||||
#include "BLI_jitter.h"
|
||||
#include "BLI_math.h"
|
||||
#include "BLI_blenlib.h"
|
||||
#include "BLI_blenlib.h" /* BLI_storage.h For _LARGEFILE64_SOURCE; zlib needs this on some systems */
|
||||
#include "BLI_kdtree.h"
|
||||
#include "BLI_kdopbvh.h"
|
||||
#include "BLI_listbase.h"
|
||||
#include "BLI_threads.h"
|
||||
#include "BLI_storage.h" /* For _LARGEFILE64_SOURCE; zlib needs this on some systems */
|
||||
#include "BLI_utildefines.h"
|
||||
#include "BLI_linklist.h"
|
||||
|
||||
#include "BKE_main.h"
|
||||
#include "BKE_animsys.h"
|
||||
|
@ -923,8 +923,8 @@ static int ptcache_path(PTCacheID *pid, char *filename)
|
||||
}
|
||||
|
||||
/* use the temp path. this is weak but better then not using point cache at all */
|
||||
/* btempdir is assumed to exist and ALWAYS has a trailing slash */
|
||||
BLI_snprintf(filename, MAX_PTCACHE_PATH, "%s"PTCACHE_PATH"%d", btempdir, abs(getpid()));
|
||||
/* temporary directory is assumed to exist and ALWAYS has a trailing slash */
|
||||
BLI_snprintf(filename, MAX_PTCACHE_PATH, "%s"PTCACHE_PATH"%d", BLI_temporary_dir(), abs(getpid()));
|
||||
|
||||
return BLI_add_slash(filename); /* new strlen() */
|
||||
}
|
||||
@ -2363,7 +2363,7 @@ void BKE_ptcache_remove(void)
|
||||
|
||||
ptcache_path(NULL, path);
|
||||
|
||||
if (BLI_exist(path)) {
|
||||
if (BLI_exists(path)) {
|
||||
/* The pointcache dir exists? - remove all pointcache */
|
||||
|
||||
DIR *dir;
|
||||
|
@ -51,6 +51,7 @@
|
||||
#include "BLI_listbase.h"
|
||||
#include "BLI_path_util.h"
|
||||
#include "BLI_string.h"
|
||||
#include "BLI_storage.h"
|
||||
#include "BLI_threads.h"
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
@ -61,9 +62,10 @@
|
||||
#include "BKE_sequencer.h"
|
||||
#include "BKE_fcurve.h"
|
||||
#include "BKE_scene.h"
|
||||
#include "RNA_access.h"
|
||||
#include "BKE_utildefines.h"
|
||||
|
||||
#include "RNA_access.h"
|
||||
|
||||
#include "RE_pipeline.h"
|
||||
|
||||
#include <pthread.h>
|
||||
|
@ -141,7 +141,7 @@ static CCGSubSurf *_getSubSurf(CCGSubSurf *prevSS, int subdivLevels, int useAgin
|
||||
ccgSubSurf_setUseAgeCounts(ccgSS, 1, 8, 8, 8);
|
||||
}
|
||||
|
||||
ccgSubSurf_setCalcVertexNormals(ccgSS, 1, BLI_STRUCT_OFFSET(DMGridData, no));
|
||||
ccgSubSurf_setCalcVertexNormals(ccgSS, 1, offsetof(DMGridData, no));
|
||||
|
||||
return ccgSS;
|
||||
}
|
||||
|
@ -64,8 +64,6 @@ struct ListBase;
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
extern char btempdir[]; /* creator.c temp dir used instead of U.tempdir, set with BLI_where_is_temp( btempdir, 1 ); */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@ -86,13 +84,6 @@ extern "C" {
|
||||
|
||||
#include "BLI_noise.h"
|
||||
|
||||
/**
|
||||
* @param strct The structure of interest
|
||||
* @param member The name of a member field of @a strct
|
||||
* @retval The offset in bytes of @a member within @a strct
|
||||
*/
|
||||
#define BLI_STRUCT_OFFSET(strct, member) ((int)(intptr_t) &((strct*) 0)->member)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -46,10 +46,6 @@ void BLI_recurdir_fileops(const char *dirname);
|
||||
int BLI_link(const char *file, const char *to);
|
||||
int BLI_is_writable(const char *filename);
|
||||
|
||||
/**
|
||||
* @attention Do not confuse with BLI_exist
|
||||
*/
|
||||
int BLI_exists(const char *file);
|
||||
int BLI_copy_fileops(const char *file, const char *to);
|
||||
int BLI_rename(const char *from, const char *to);
|
||||
int BLI_gzip(const char *from, const char *to);
|
||||
@ -58,11 +54,6 @@ int BLI_delete(const char *file, int dir, int recursive);
|
||||
int BLI_move(const char *file, const char *to);
|
||||
int BLI_touch(const char *file);
|
||||
|
||||
/* only for the sane unix world: direct calls to system functions :( */
|
||||
#ifndef WIN32
|
||||
void BLI_setCmdCallBack(int (*f)(char*));
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -65,10 +65,6 @@ char *BLI_get_folder_version(const int id, const int ver, const int do_check);
|
||||
#define BLENDER_SYSTEM_PLUGINS 54
|
||||
#define BLENDER_SYSTEM_PYTHON 54
|
||||
|
||||
#define BLENDER_TEMP 80
|
||||
|
||||
#define BLENDER_USERFOLDER(id) (id >= BLENDER_USER_CONFIG && id <= BLENDER_USER_PLUGINS)
|
||||
|
||||
/* for BLI_get_folder_version only */
|
||||
#define BLENDER_RESOURCE_PATH_USER 0
|
||||
#define BLENDER_RESOURCE_PATH_LOCAL 1
|
||||
@ -78,17 +74,6 @@ char *BLI_get_folder_version(const int id, const int ver, const int do_check);
|
||||
#define BLENDER_BOOKMARK_FILE "bookmarks.txt"
|
||||
#define BLENDER_HISTORY_FILE "recent-files.txt"
|
||||
|
||||
#ifdef WIN32
|
||||
#define BLENDER_USER_FORMAT "%s\\Blender Foundation\\Blender\\%s"
|
||||
#define BLENDER_SYSTEM_FORMAT "%s\\Blender Foundation\\Blender\\%s"
|
||||
#elif defined(__APPLE__)
|
||||
#define BLENDER_USER_FORMAT "%s/Blender/%s"
|
||||
#define BLENDER_SYSTEM_FORMAT "%s/Blender/%s"
|
||||
#else
|
||||
#define BLENDER_USER_FORMAT "%s/.blender/%s"
|
||||
#define BLENDER_SYSTEM_FORMAT "%s/blender/%s"
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
#define SEP '\\'
|
||||
#define ALTSEP '/'
|
||||
@ -181,29 +166,20 @@ void BLI_path_rel(char *file, const char *relfile);
|
||||
*/
|
||||
void BLI_char_switch(char *string, char from, char to);
|
||||
|
||||
/**
|
||||
* Checks if name is a fully qualified filename to an executable.
|
||||
* If not it searches $PATH for the file. On Windows it also
|
||||
* adds the correct extension (.com .exe etc) from
|
||||
* $PATHEXT if necessary. Also on Windows it translates
|
||||
* the name to its 8.3 version to prevent problems with
|
||||
* spaces and stuff. Final result is returned in fullname.
|
||||
*
|
||||
* @param fullname The full path and full name of the executable
|
||||
* @param name The name of the executable (usually argv[0]) to be checked
|
||||
*/
|
||||
void BLI_where_am_i(char *fullname, const size_t maxlen, const char *name);
|
||||
|
||||
/**
|
||||
* Gets the temp directory when blender first runs.
|
||||
* If the default path is not found, use try $TEMP
|
||||
*
|
||||
* Also make sure the temp dir has a trailing slash
|
||||
*
|
||||
* @param fullname The full path to the temp directory
|
||||
*/
|
||||
void BLI_where_is_temp(char *fullname, const size_t maxlen, int usertemp);
|
||||
/* Initialize path to program executable */
|
||||
void BLI_init_program_path(const char *argv0);
|
||||
/* Initialize path to temporary directory.
|
||||
* NOTE: On Window userdir will be set to the temporary directory! */
|
||||
void BLI_init_temporary_dir(char *userdir);
|
||||
|
||||
/* Path to executable */
|
||||
const char *BLI_program_path(void);
|
||||
/* Path to directory of executable */
|
||||
const char *BLI_program_dir(void);
|
||||
/* Path to temporary directory (with trailing slash) */
|
||||
const char *BLI_temporary_dir(void);
|
||||
/* Path to the system temporary directory (with trailing slash) */
|
||||
void BLI_system_temporary_dir(char *dir);
|
||||
|
||||
#ifdef WITH_ICONV
|
||||
void BLI_string_to_utf8(char *original, char *utf_8, const char *code);
|
||||
|
@ -33,46 +33,35 @@
|
||||
* \ingroup bli
|
||||
*/
|
||||
|
||||
#ifdef WIN32
|
||||
/* for size_t, only needed on win32 for some reason */
|
||||
/* for size_t (needed on windows) */
|
||||
#include <stddef.h>
|
||||
#endif
|
||||
|
||||
struct direntry;
|
||||
|
||||
|
||||
void BLI_adddirstrings(void);
|
||||
void BLI_builddir(const char *dirname, const char *relname);
|
||||
int BLI_compare(struct direntry *entry1, struct direntry *entry2);
|
||||
|
||||
size_t BLI_filesize(int file);
|
||||
size_t BLI_filepathsize(const char *path);
|
||||
double BLI_diskfree(const char *dir);
|
||||
char *BLI_getwdN(char *dir, const int maxncpy);
|
||||
|
||||
unsigned int BLI_getdir(const char *dirname, struct direntry **filelist);
|
||||
/**
|
||||
* @attention Do not confuse with BLI_exists
|
||||
*/
|
||||
int BLI_exist(const char *name);
|
||||
/**
|
||||
* Read a file as ASCII lines. An empty list is
|
||||
* returned if the file cannot be opened or read.
|
||||
*
|
||||
* @attention The returned list should be free'd with
|
||||
* BLI_free_file_lines.
|
||||
*
|
||||
* @param name The name of the file to read.
|
||||
* @retval A list of strings representing the file lines.
|
||||
*/
|
||||
|
||||
/* test if file or directory exists */
|
||||
int BLI_exists(const char *name);
|
||||
/* test if there is a directory at the specified path */
|
||||
int BLI_is_dir(const char *file);
|
||||
|
||||
struct LinkNode *BLI_read_file_as_lines(const char *name);
|
||||
/**
|
||||
* Read a file as ASCII lines. An empty list is
|
||||
* returned if the file cannot be opened or read.
|
||||
*
|
||||
* @attention The returned list should be free'd with
|
||||
* BLI_free_file_lines.
|
||||
*
|
||||
* @param name The name of the file to read.
|
||||
* @retval A list of strings representing the file lines.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Free the list returned by BLI_read_file_as_lines.
|
||||
*/
|
||||
struct LinkNode *BLI_read_file_as_lines(const char *name);
|
||||
void BLI_free_file_lines(struct LinkNode *lines);
|
||||
|
||||
/* Compare if one was last modified before the other */
|
||||
|
@ -67,63 +67,113 @@
|
||||
#define MAX3(x,y,z) MAX2( MAX2((x),(y)) , (z) )
|
||||
#define MAX4(x,y,z,a) MAX2( MAX2((x),(y)) , MAX2((z),(a)) )
|
||||
|
||||
#define INIT_MINMAX(min, max) { (min)[0]= (min)[1]= (min)[2]= 1.0e30f; (max)[0]= (max)[1]= (max)[2]= -1.0e30f; }
|
||||
|
||||
#define INIT_MINMAX2(min, max) { (min)[0]= (min)[1]= 1.0e30f; (max)[0]= (max)[1]= -1.0e30f; }
|
||||
|
||||
#define DO_MIN(vec, min) { if( (min)[0]>(vec)[0] ) (min)[0]= (vec)[0]; \
|
||||
if( (min)[1]>(vec)[1] ) (min)[1]= (vec)[1]; \
|
||||
if( (min)[2]>(vec)[2] ) (min)[2]= (vec)[2]; } \
|
||||
|
||||
#define DO_MAX(vec, max) { if( (max)[0]<(vec)[0] ) (max)[0]= (vec)[0]; \
|
||||
if( (max)[1]<(vec)[1] ) (max)[1]= (vec)[1]; \
|
||||
if( (max)[2]<(vec)[2] ) (max)[2]= (vec)[2]; } \
|
||||
|
||||
#define DO_MINMAX(vec, min, max) { if( (min)[0]>(vec)[0] ) (min)[0]= (vec)[0]; \
|
||||
if( (min)[1]>(vec)[1] ) (min)[1]= (vec)[1]; \
|
||||
if( (min)[2]>(vec)[2] ) (min)[2]= (vec)[2]; \
|
||||
if( (max)[0]<(vec)[0] ) (max)[0]= (vec)[0]; \
|
||||
if( (max)[1]<(vec)[1] ) (max)[1]= (vec)[1]; \
|
||||
if( (max)[2]<(vec)[2] ) (max)[2]= (vec)[2]; } \
|
||||
|
||||
#define DO_MINMAX2(vec, min, max) { if( (min)[0]>(vec)[0] ) (min)[0]= (vec)[0]; \
|
||||
if( (min)[1]>(vec)[1] ) (min)[1]= (vec)[1]; \
|
||||
if( (max)[0]<(vec)[0] ) (max)[0]= (vec)[0]; \
|
||||
if( (max)[1]<(vec)[1] ) (max)[1]= (vec)[1]; }
|
||||
#define INIT_MINMAX(min, max) { \
|
||||
(min)[0]= (min)[1]= (min)[2]= 1.0e30f; \
|
||||
(max)[0]= (max)[1]= (max)[2]= -1.0e30f; \
|
||||
}
|
||||
#define INIT_MINMAX2(min, max) { \
|
||||
(min)[0]= (min)[1]= 1.0e30f; \
|
||||
(max)[0]= (max)[1]= -1.0e30f; \
|
||||
}
|
||||
#define DO_MIN(vec, min) { \
|
||||
if( (min)[0]>(vec)[0] ) (min)[0]= (vec)[0]; \
|
||||
if( (min)[1]>(vec)[1] ) (min)[1]= (vec)[1]; \
|
||||
if( (min)[2]>(vec)[2] ) (min)[2]= (vec)[2]; \
|
||||
}
|
||||
#define DO_MAX(vec, max) { \
|
||||
if( (max)[0]<(vec)[0] ) (max)[0]= (vec)[0]; \
|
||||
if( (max)[1]<(vec)[1] ) (max)[1]= (vec)[1]; \
|
||||
if( (max)[2]<(vec)[2] ) (max)[2]= (vec)[2]; \
|
||||
}
|
||||
#define DO_MINMAX(vec, min, max) { \
|
||||
if( (min)[0]>(vec)[0] ) (min)[0]= (vec)[0]; \
|
||||
if( (min)[1]>(vec)[1] ) (min)[1]= (vec)[1]; \
|
||||
if( (min)[2]>(vec)[2] ) (min)[2]= (vec)[2]; \
|
||||
if( (max)[0]<(vec)[0] ) (max)[0]= (vec)[0]; \
|
||||
if( (max)[1]<(vec)[1] ) (max)[1]= (vec)[1]; \
|
||||
if( (max)[2]<(vec)[2] ) (max)[2]= (vec)[2]; \
|
||||
}
|
||||
#define DO_MINMAX2(vec, min, max) { \
|
||||
if( (min)[0]>(vec)[0] ) (min)[0]= (vec)[0]; \
|
||||
if( (min)[1]>(vec)[1] ) (min)[1]= (vec)[1]; \
|
||||
if( (max)[0]<(vec)[0] ) (max)[0]= (vec)[0]; \
|
||||
if( (max)[1]<(vec)[1] ) (max)[1]= (vec)[1]; \
|
||||
}
|
||||
|
||||
/* some math and copy defines */
|
||||
|
||||
#ifndef SWAP
|
||||
# define SWAP(type, a, b) { type sw_ap; sw_ap=(a); (a)=(b); (b)=sw_ap; }
|
||||
# define SWAP(type, a, b) { type sw_ap; sw_ap=(a); (a)=(b); (b)=sw_ap; }
|
||||
#endif
|
||||
|
||||
#define ABS(a) ( (a)<0 ? (-(a)) : (a) )
|
||||
|
||||
#define AVG2(x, y) ( 0.5 * ((x) + (y)) )
|
||||
#define ABS(a) ( (a)<0 ? (-(a)) : (a) )
|
||||
|
||||
#define FTOCHAR(val) ((val)<=0.0f)? 0 : (((val)>(1.0f-0.5f/255.0f))? 255 : (char)((255.0f*(val))+0.5f))
|
||||
#define FTOUSHORT(val) ((val >= 1.0f-0.5f/65535)? 65535: (val <= 0.0f)? 0: (unsigned short)(val*65535.0f + 0.5f))
|
||||
#define F3TOCHAR3(v2,v1) (v1)[0]=FTOCHAR((v2[0])); (v1)[1]=FTOCHAR((v2[1])); (v1)[2]=FTOCHAR((v2[2]))
|
||||
#define F3TOCHAR4(v2,v1) { (v1)[0]=FTOCHAR((v2[0])); (v1)[1]=FTOCHAR((v2[1])); (v1)[2]=FTOCHAR((v2[2])); \
|
||||
(v1)[3] = 255; }
|
||||
#define F4TOCHAR4(v2,v1) { (v1)[0]=FTOCHAR((v2[0])); (v1)[1]=FTOCHAR((v2[1])); (v1)[2]=FTOCHAR((v2[2])); \
|
||||
(v1)[3]=FTOCHAR((v2[3])); }
|
||||
#define F3TOCHAR3(v2, v1) { \
|
||||
(v1)[0]= FTOCHAR((v2[0])); \
|
||||
(v1)[1]= FTOCHAR((v2[1])); \
|
||||
(v1)[2]= FTOCHAR((v2[2])); \
|
||||
}
|
||||
#define F3TOCHAR4(v2, v1) { \
|
||||
(v1)[0]= FTOCHAR((v2[0])); \
|
||||
(v1)[1]= FTOCHAR((v2[1])); \
|
||||
(v1)[2]= FTOCHAR((v2[2])); \
|
||||
(v1)[3]= 255; \
|
||||
}
|
||||
#define F4TOCHAR4(v2, v1) { \
|
||||
(v1)[0]= FTOCHAR((v2[0])); \
|
||||
(v1)[1]= FTOCHAR((v2[1])); \
|
||||
(v1)[2]= FTOCHAR((v2[2])); \
|
||||
(v1)[3]= FTOCHAR((v2[3])); \
|
||||
}
|
||||
#define VECCOPY(v1, v2) { \
|
||||
*(v1)= *(v2); \
|
||||
*(v1+1)= *(v2+1); \
|
||||
*(v1+2)= *(v2+2); \
|
||||
}
|
||||
#define VECCOPY2D(v1, v2) { \
|
||||
*(v1)= *(v2); \
|
||||
*(v1+1)= *(v2+1); \
|
||||
}
|
||||
#define QUATCOPY(v1, v2) { \
|
||||
*(v1)= *(v2); \
|
||||
*(v1+1)= *(v2+1); \
|
||||
*(v1+2)= *(v2+2); \
|
||||
*(v1+3)= *(v2+3); \
|
||||
}
|
||||
#define VECADD(v1,v2,v3) { \
|
||||
*(v1)= *(v2) + *(v3); \
|
||||
*(v1+1)= *(v2+1) + *(v3+1); \
|
||||
*(v1+2)= *(v2+2) + *(v3+2); \
|
||||
}
|
||||
#define VECSUB(v1,v2,v3) { \
|
||||
*(v1)= *(v2) - *(v3); \
|
||||
*(v1+1)= *(v2+1) - *(v3+1); \
|
||||
*(v1+2)= *(v2+2) - *(v3+2); \
|
||||
}
|
||||
#define VECSUB2D(v1,v2,v3) { \
|
||||
*(v1)= *(v2) - *(v3); \
|
||||
*(v1+1)= *(v2+1) - *(v3+1); \
|
||||
}
|
||||
#define VECADDFAC(v1,v2,v3,fac) { \
|
||||
*(v1)= *(v2) + *(v3)*(fac); \
|
||||
*(v1+1)= *(v2+1) + *(v3+1)*(fac); \
|
||||
*(v1+2)= *(v2+2) + *(v3+2)*(fac); \
|
||||
}
|
||||
#define VECSUBFAC(v1,v2,v3,fac) { \
|
||||
*(v1)= *(v2) - *(v3)*(fac); \
|
||||
*(v1+1)= *(v2+1) - *(v3+1)*(fac); \
|
||||
*(v1+2)= *(v2+2) - *(v3+2)*(fac); \
|
||||
}
|
||||
#define QUATADDFAC(v1,v2,v3,fac) { \
|
||||
*(v1)= *(v2) + *(v3)*(fac); \
|
||||
*(v1+1)= *(v2+1) + *(v3+1)*(fac); \
|
||||
*(v1+2)= *(v2+2) + *(v3+2)*(fac); \
|
||||
*(v1+3)= *(v2+3) + *(v3+3)*(fac); \
|
||||
}
|
||||
|
||||
|
||||
#define VECCOPY(v1,v2) {*(v1)= *(v2); *(v1+1)= *(v2+1); *(v1+2)= *(v2+2);}
|
||||
#define VECCOPY2D(v1,v2) {*(v1)= *(v2); *(v1+1)= *(v2+1);}
|
||||
#define QUATCOPY(v1,v2) {*(v1)= *(v2); *(v1+1)= *(v2+1); *(v1+2)= *(v2+2); *(v1+3)= *(v2+3);}
|
||||
#define LONGCOPY(a, b, c) {int lcpc=c, *lcpa=(int *)a, *lcpb=(int *)b; while(lcpc-->0) *(lcpa++)= *(lcpb++);}
|
||||
|
||||
|
||||
#define VECADD(v1,v2,v3) {*(v1)= *(v2) + *(v3); *(v1+1)= *(v2+1) + *(v3+1); *(v1+2)= *(v2+2) + *(v3+2);}
|
||||
#define VECSUB(v1,v2,v3) {*(v1)= *(v2) - *(v3); *(v1+1)= *(v2+1) - *(v3+1); *(v1+2)= *(v2+2) - *(v3+2);}
|
||||
#define VECSUB2D(v1,v2,v3) {*(v1)= *(v2) - *(v3); *(v1+1)= *(v2+1) - *(v3+1);}
|
||||
#define VECADDFAC(v1,v2,v3,fac) {*(v1)= *(v2) + *(v3)*(fac); *(v1+1)= *(v2+1) + *(v3+1)*(fac); *(v1+2)= *(v2+2) + *(v3+2)*(fac);}
|
||||
#define VECSUBFAC(v1,v2,v3,fac) {*(v1)= *(v2) - *(v3)*(fac); *(v1+1)= *(v2+1) - *(v3+1)*(fac); *(v1+2)= *(v2+2) - *(v3+2)*(fac);}
|
||||
#define QUATADDFAC(v1,v2,v3,fac) {*(v1)= *(v2) + *(v3)*(fac); *(v1+1)= *(v2+1) + *(v3+1)*(fac); *(v1+2)= *(v2+2) + *(v3+2)*(fac); *(v1+3)= *(v2+3) + *(v3+3)*(fac);}
|
||||
|
||||
#define INPR(v1, v2) ( (v1)[0]*(v2)[0] + (v1)[1]*(v2)[1] + (v1)[2]*(v2)[2] )
|
||||
#define INPR(v1, v2) ( (v1)[0]*(v2)[0] + (v1)[1]*(v2)[1] + (v1)[2]*(v2)[2] )
|
||||
|
||||
/* some misc stuff.... */
|
||||
#define CLAMP(a, b, c) if((a)<(b)) (a)=(b); else if((a)>(c)) (a)=(c)
|
||||
@ -138,28 +188,36 @@
|
||||
#define IN_RANGE_INCL(a, b, c) ((b < c)? ((b<=a && a<=c)? 1:0) : ((c<=a && a<=b)? 1:0))
|
||||
|
||||
/* array helpers */
|
||||
#define ARRAY_LAST_ITEM(arr_start, arr_dtype, elem_size, tot) (arr_dtype *)((char*)arr_start + (elem_size*(tot - 1)))
|
||||
#define ARRAY_HAS_ITEM(item, arr_start, arr_dtype, elem_size, tot) ((item >= arr_start) && (item <= ARRAY_LAST_ITEM(arr_start, arr_dtype, elem_size, tot)))
|
||||
#define ARRAY_LAST_ITEM(arr_start, arr_dtype, elem_size, tot) \
|
||||
(arr_dtype *)((char*)arr_start + (elem_size*(tot - 1)))
|
||||
|
||||
#define ARRAY_HAS_ITEM(item, arr_start, arr_dtype, elem_size, tot) ( \
|
||||
(item >= arr_start) && \
|
||||
(item <= ARRAY_LAST_ITEM(arr_start, arr_dtype, elem_size, tot)) \
|
||||
)
|
||||
|
||||
/* This one rotates the bytes in an int64, int (32) and short (16) */
|
||||
#define SWITCH_INT64(a) { \
|
||||
char s_i, *p_i; \
|
||||
p_i= (char *)&(a); \
|
||||
s_i=p_i[0]; p_i[0]=p_i[7]; p_i[7]=s_i; \
|
||||
s_i=p_i[1]; p_i[1]=p_i[6]; p_i[6]=s_i; \
|
||||
s_i=p_i[2]; p_i[2]=p_i[5]; p_i[5]=s_i; \
|
||||
s_i=p_i[3]; p_i[3]=p_i[4]; p_i[4]=s_i; }
|
||||
#define SWITCH_INT64(a) { \
|
||||
char s_i, *p_i; \
|
||||
p_i= (char *)&(a); \
|
||||
s_i= p_i[0]; p_i[0]= p_i[7]; p_i[7]= s_i; \
|
||||
s_i= p_i[1]; p_i[1]= p_i[6]; p_i[6]= s_i; \
|
||||
s_i= p_i[2]; p_i[2]= p_i[5]; p_i[5]= s_i; \
|
||||
s_i= p_i[3]; p_i[3]= p_i[4]; p_i[4]= s_i; \
|
||||
}
|
||||
|
||||
#define SWITCH_INT(a) { \
|
||||
char s_i, *p_i; \
|
||||
p_i= (char *)&(a); \
|
||||
s_i=p_i[0]; p_i[0]=p_i[3]; p_i[3]=s_i; \
|
||||
s_i=p_i[1]; p_i[1]=p_i[2]; p_i[2]=s_i; }
|
||||
#define SWITCH_INT(a) { \
|
||||
char s_i, *p_i; \
|
||||
p_i= (char *)&(a); \
|
||||
s_i= p_i[0]; p_i[0]= p_i[3]; p_i[3]= s_i; \
|
||||
s_i= p_i[1]; p_i[1]= p_i[2]; p_i[2]= s_i; \
|
||||
}
|
||||
|
||||
#define SWITCH_SHORT(a) { \
|
||||
char s_i, *p_i; \
|
||||
p_i= (char *)&(a); \
|
||||
s_i=p_i[0]; p_i[0]=p_i[1]; p_i[1]=s_i; }
|
||||
#define SWITCH_SHORT(a) { \
|
||||
char s_i, *p_i; \
|
||||
p_i= (char *)&(a); \
|
||||
s_i=p_i[0]; p_i[0]=p_i[1]; p_i[1]=s_i; \
|
||||
}
|
||||
|
||||
|
||||
/* Warning-free macros for storing ints in pointers. Use these _only_
|
||||
@ -221,25 +279,25 @@
|
||||
# else
|
||||
# define _dummy_abort() (void)0
|
||||
# endif
|
||||
# if defined(__GNUC__) || defined(_MSC_VER) /* just want to check if __func__ is available */
|
||||
# define BLI_assert(a) \
|
||||
do { \
|
||||
if (!(a)) { \
|
||||
fprintf(stderr, \
|
||||
"BLI_assert failed: %s, %s(), %d at \'%s\'\n", \
|
||||
__FILE__, __func__, __LINE__, STRINGIFY(a)); \
|
||||
_dummy_abort(); \
|
||||
} \
|
||||
# if defined(__GNUC__) || defined(_MSC_VER) /* check __func__ is available */
|
||||
# define BLI_assert(a) \
|
||||
do { \
|
||||
if (!(a)) { \
|
||||
fprintf(stderr, \
|
||||
"BLI_assert failed: %s, %s(), %d at \'%s\'\n", \
|
||||
__FILE__, __func__, __LINE__, STRINGIFY(a)); \
|
||||
_dummy_abort(); \
|
||||
} \
|
||||
} while (0)
|
||||
# else
|
||||
# define BLI_assert(a) \
|
||||
do { \
|
||||
if (0 == (a)) { \
|
||||
fprintf(stderr, \
|
||||
"BLI_assert failed: %s, %d at \'%s\'\n", \
|
||||
__FILE__, __LINE__, STRINGIFY(a)); \
|
||||
_dummy_abort(); \
|
||||
} \
|
||||
do { \
|
||||
if (0 == (a)) { \
|
||||
fprintf(stderr, \
|
||||
"BLI_assert failed: %s, %d at \'%s\'\n", \
|
||||
__FILE__, __LINE__, STRINGIFY(a)); \
|
||||
_dummy_abort(); \
|
||||
} \
|
||||
} while (0)
|
||||
# endif
|
||||
#else
|
||||
|
@ -195,10 +195,6 @@ int BLI_touch(const char *file)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int BLI_exists(const char *file) {
|
||||
return BLI_exist(file);
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
static char str[MAXPATHLEN+12];
|
||||
|
@ -41,7 +41,7 @@
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "DNA_userdef_types.h"
|
||||
#include "DNA_listBase.h"
|
||||
|
||||
#include "BLI_fileops.h"
|
||||
#include "BLI_path_util.h"
|
||||
@ -84,11 +84,24 @@
|
||||
|
||||
#endif /* WIN32 */
|
||||
|
||||
/* standard paths */
|
||||
#ifdef WIN32
|
||||
#define BLENDER_USER_FORMAT "%s\\Blender Foundation\\Blender\\%s"
|
||||
#define BLENDER_SYSTEM_FORMAT "%s\\Blender Foundation\\Blender\\%s"
|
||||
#elif defined(__APPLE__)
|
||||
#define BLENDER_USER_FORMAT "%s/Blender/%s"
|
||||
#define BLENDER_SYSTEM_FORMAT "%s/Blender/%s"
|
||||
#else
|
||||
#define BLENDER_USER_FORMAT "%s/.blender/%s"
|
||||
#define BLENDER_SYSTEM_FORMAT "%s/blender/%s"
|
||||
#endif
|
||||
|
||||
/* local */
|
||||
#define UNIQUE_NAME_MAX 128
|
||||
|
||||
extern char bprogname[];
|
||||
extern char bprogdir[];
|
||||
static char bprogname[FILE_MAX]; /* path to program executable */
|
||||
static char bprogdir[FILE_MAX]; /* path in which executable is located */
|
||||
static char btempdir[FILE_MAX]; /* temporary directory */
|
||||
|
||||
static int add_win32_extension(char *name);
|
||||
static char *blender_version_decimal(const int ver);
|
||||
@ -1634,7 +1647,7 @@ static int add_win32_extension(char *name)
|
||||
int retval = 0;
|
||||
int type;
|
||||
|
||||
type = BLI_exist(name);
|
||||
type = BLI_exists(name);
|
||||
if ((type == 0) || S_ISDIR(type)) {
|
||||
#ifdef _WIN32
|
||||
char filename[FILE_MAXDIR+FILE_MAXFILE];
|
||||
@ -1654,7 +1667,7 @@ static int add_win32_extension(char *name)
|
||||
strcat(filename, extensions);
|
||||
}
|
||||
|
||||
type = BLI_exist(filename);
|
||||
type = BLI_exists(filename);
|
||||
if (type && (! S_ISDIR(type))) {
|
||||
retval = 1;
|
||||
strcpy(name, filename);
|
||||
@ -1670,8 +1683,19 @@ static int add_win32_extension(char *name)
|
||||
return (retval);
|
||||
}
|
||||
|
||||
/* filename must be FILE_MAX length minimum */
|
||||
void BLI_where_am_i(char *fullname, const size_t maxlen, const char *name)
|
||||
/*
|
||||
* Checks if name is a fully qualified filename to an executable.
|
||||
* If not it searches $PATH for the file. On Windows it also
|
||||
* adds the correct extension (.com .exe etc) from
|
||||
* $PATHEXT if necessary. Also on Windows it translates
|
||||
* the name to its 8.3 version to prevent problems with
|
||||
* spaces and stuff. Final result is returned in fullname.
|
||||
*
|
||||
* @param fullname The full path and full name of the executable
|
||||
* (must be FILE_MAX minimum)
|
||||
* @param name The name of the executable (usually argv[0]) to be checked
|
||||
*/
|
||||
static void bli_where_am_i(char *fullname, const size_t maxlen, const char *name)
|
||||
{
|
||||
char filename[FILE_MAXDIR+FILE_MAXFILE];
|
||||
const char *path = NULL, *temp;
|
||||
@ -1751,12 +1775,37 @@ void BLI_where_am_i(char *fullname, const size_t maxlen, const char *name)
|
||||
}
|
||||
}
|
||||
|
||||
void BLI_where_is_temp(char *fullname, const size_t maxlen, int usertemp)
|
||||
void BLI_init_program_path(const char *argv0)
|
||||
{
|
||||
bli_where_am_i(bprogname, sizeof(bprogname), argv0);
|
||||
BLI_split_dir_part(bprogname, bprogdir, sizeof(bprogdir));
|
||||
}
|
||||
|
||||
const char *BLI_program_path(void)
|
||||
{
|
||||
return bprogname;
|
||||
}
|
||||
|
||||
const char *BLI_program_dir(void)
|
||||
{
|
||||
return bprogdir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the temp directory when blender first runs.
|
||||
* If the default path is not found, use try $TEMP
|
||||
*
|
||||
* Also make sure the temp dir has a trailing slash
|
||||
*
|
||||
* @param fullname The full path to the temp directory
|
||||
* @param userdir Directory specified in user preferences
|
||||
*/
|
||||
void BLI_where_is_temp(char *fullname, const size_t maxlen, char *userdir)
|
||||
{
|
||||
fullname[0] = '\0';
|
||||
|
||||
if (usertemp && BLI_is_dir(U.tempdir)) {
|
||||
BLI_strncpy(fullname, U.tempdir, maxlen);
|
||||
if (userdir && BLI_is_dir(userdir)) {
|
||||
BLI_strncpy(fullname, userdir, maxlen);
|
||||
}
|
||||
|
||||
|
||||
@ -1790,13 +1839,28 @@ void BLI_where_is_temp(char *fullname, const size_t maxlen, int usertemp)
|
||||
/* add a trailing slash if needed */
|
||||
BLI_add_slash(fullname);
|
||||
#ifdef WIN32
|
||||
if(U.tempdir != fullname) {
|
||||
BLI_strncpy(U.tempdir, fullname, maxlen); /* also set user pref to show %TEMP%. /tmp/ is just plain confusing for Windows users. */
|
||||
if(userdir != fullname) {
|
||||
BLI_strncpy(userdir, fullname, maxlen); /* also set user pref to show %TEMP%. /tmp/ is just plain confusing for Windows users. */
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void BLI_init_temporary_dir(char *userdir)
|
||||
{
|
||||
BLI_where_is_temp(btempdir, FILE_MAX, userdir);
|
||||
}
|
||||
|
||||
const char *BLI_temporary_dir(void)
|
||||
{
|
||||
return btempdir;
|
||||
}
|
||||
|
||||
void BLI_system_temporary_dir(char *dir)
|
||||
{
|
||||
BLI_where_is_temp(dir, FILE_MAX, NULL);
|
||||
}
|
||||
|
||||
#ifdef WITH_ICONV
|
||||
|
||||
void BLI_string_to_utf8(char *original, char *utf_8, const char *code)
|
||||
|
@ -438,7 +438,7 @@ size_t BLI_filepathsize(const char *path)
|
||||
}
|
||||
|
||||
|
||||
int BLI_exist(const char *name)
|
||||
int BLI_exists(const char *name)
|
||||
{
|
||||
#if defined(WIN32) && !defined(__MINGW32__)
|
||||
struct _stat64i32 st;
|
||||
@ -471,7 +471,7 @@ int BLI_exist(const char *name)
|
||||
/* would be better in fileops.c except that it needs stat.h so add here */
|
||||
int BLI_is_dir(const char *file)
|
||||
{
|
||||
return S_ISDIR(BLI_exist(file));
|
||||
return S_ISDIR(BLI_exists(file));
|
||||
}
|
||||
|
||||
LinkNode *BLI_read_file_as_lines(const char *name)
|
||||
|
@ -8802,7 +8802,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
|
||||
|
||||
for (wo = main->world.first; wo; wo= wo->id.next) {
|
||||
/* Migrate to Bullet for games, except for the NaN versions */
|
||||
/* People can still explicitely choose for Sumo (after 2.42 is out) */
|
||||
/* People can still explicitly choose for Sumo (after 2.42 is out) */
|
||||
if(main->versionfile > 225)
|
||||
wo->physicsEngine = WOPHY_BULLET;
|
||||
if(WO_AODIST == wo->aomode)
|
||||
|
@ -60,7 +60,7 @@ extern "C"
|
||||
export_settings.filepath = (char *)filepath;
|
||||
|
||||
/* annoying, collada crashes if file cant be created! [#27162] */
|
||||
if(!BLI_exist(filepath)) {
|
||||
if(!BLI_exists(filepath)) {
|
||||
BLI_make_existing_file(filepath); /* makes the dir if its not there */
|
||||
if(BLI_touch(filepath) == 0) {
|
||||
return 0;
|
||||
|
@ -118,7 +118,7 @@ int getname_anim_fcurve(char *name, ID *id, FCurve *fcu)
|
||||
PropertyRNA *nameprop= RNA_struct_name_property(ptr.type);
|
||||
if (nameprop) {
|
||||
/* this gets a string which will need to be freed */
|
||||
structname= RNA_property_string_get_alloc(&ptr, nameprop, NULL, 0);
|
||||
structname= RNA_property_string_get_alloc(&ptr, nameprop, NULL, 0, NULL);
|
||||
free_structname= 1;
|
||||
}
|
||||
else
|
||||
|
@ -1593,17 +1593,18 @@ void ui_get_but_string(uiBut *but, char *str, size_t maxlen)
|
||||
if(but->rnaprop && ELEM3(but->type, TEX, IDPOIN, SEARCH_MENU)) {
|
||||
PropertyType type;
|
||||
char *buf= NULL;
|
||||
int buf_len;
|
||||
|
||||
type= RNA_property_type(but->rnaprop);
|
||||
|
||||
if(type == PROP_STRING) {
|
||||
/* RNA string */
|
||||
buf= RNA_property_string_get_alloc(&but->rnapoin, but->rnaprop, str, maxlen);
|
||||
buf= RNA_property_string_get_alloc(&but->rnapoin, but->rnaprop, str, maxlen, &buf_len);
|
||||
}
|
||||
else if(type == PROP_POINTER) {
|
||||
/* RNA pointer */
|
||||
PointerRNA ptr= RNA_property_pointer_get(&but->rnapoin, but->rnaprop);
|
||||
buf= RNA_struct_name_get_alloc(&ptr, str, maxlen);
|
||||
buf= RNA_struct_name_get_alloc(&ptr, str, maxlen, &buf_len);
|
||||
}
|
||||
|
||||
if(!buf) {
|
||||
@ -1611,7 +1612,7 @@ void ui_get_but_string(uiBut *but, char *str, size_t maxlen)
|
||||
}
|
||||
else if(buf && buf != str) {
|
||||
/* string was too long, we have to truncate */
|
||||
BLI_strncpy(str, buf, maxlen);
|
||||
memcpy(str, buf, MIN2(maxlen, buf_len+1));
|
||||
MEM_freeN(buf);
|
||||
}
|
||||
}
|
||||
|
@ -2210,15 +2210,11 @@ static int ui_do_but_HOTKEYEVT(bContext *C, uiBut *but, uiHandleButtonData *data
|
||||
|
||||
/* always set */
|
||||
but->modifier_key = 0;
|
||||
if(event->shift)
|
||||
but->modifier_key |= KM_SHIFT;
|
||||
if(event->alt)
|
||||
but->modifier_key |= KM_ALT;
|
||||
if(event->ctrl)
|
||||
but->modifier_key |= KM_CTRL;
|
||||
if(event->oskey)
|
||||
but->modifier_key |= KM_OSKEY;
|
||||
|
||||
if(event->shift) but->modifier_key |= KM_SHIFT;
|
||||
if(event->alt) but->modifier_key |= KM_ALT;
|
||||
if(event->ctrl) but->modifier_key |= KM_CTRL;
|
||||
if(event->oskey) but->modifier_key |= KM_OSKEY;
|
||||
|
||||
ui_check_but(but);
|
||||
ED_region_tag_redraw(data->region);
|
||||
|
||||
@ -3684,7 +3680,7 @@ static int ui_do_but_CURVE(bContext *C, uiBlock *block, uiBut *but, uiHandleButt
|
||||
if(sel!= -1) {
|
||||
/* ok, we move a point */
|
||||
/* deselect all if this one is deselect. except if we hold shift */
|
||||
if(event->shift==0) {
|
||||
if(event->shift == FALSE) {
|
||||
for(a=0; a<cuma->totpoint; a++)
|
||||
cmp[a].flag &= ~SELECT;
|
||||
cmp[sel].flag |= SELECT;
|
||||
@ -3723,7 +3719,7 @@ static int ui_do_but_CURVE(bContext *C, uiBlock *block, uiBut *but, uiHandleButt
|
||||
|
||||
if(!data->dragchange) {
|
||||
/* deselect all, select one */
|
||||
if(event->shift==0) {
|
||||
if(event->shift == FALSE) {
|
||||
for(a=0; a<cuma->totpoint; a++)
|
||||
cmp[a].flag &= ~SELECT;
|
||||
cmp[data->dragsel].flag |= SELECT;
|
||||
@ -4584,7 +4580,7 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, wmEvent *event)
|
||||
ui_but_drop (C, event, but, data);
|
||||
}
|
||||
/* handle keyframing */
|
||||
else if(event->type == IKEY && !ELEM3(1, event->ctrl, event->oskey, event->shift) && event->val == KM_PRESS) {
|
||||
else if(event->type == IKEY && !ELEM3(KM_MOD_FIRST, event->ctrl, event->oskey, event->shift) && event->val == KM_PRESS) {
|
||||
if(event->alt)
|
||||
ui_but_anim_delete_keyframe(C);
|
||||
else
|
||||
@ -4595,7 +4591,7 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, wmEvent *event)
|
||||
return WM_UI_HANDLER_BREAK;
|
||||
}
|
||||
/* handle drivers */
|
||||
else if(event->type == DKEY && !ELEM3(1, event->ctrl, event->oskey, event->shift) && event->val == KM_PRESS) {
|
||||
else if(event->type == DKEY && !ELEM3(KM_MOD_FIRST, event->ctrl, event->oskey, event->shift) && event->val == KM_PRESS) {
|
||||
if(event->alt)
|
||||
ui_but_anim_remove_driver(C);
|
||||
else
|
||||
@ -4606,7 +4602,7 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, wmEvent *event)
|
||||
return WM_UI_HANDLER_BREAK;
|
||||
}
|
||||
/* handle keyingsets */
|
||||
else if(event->type == KKEY && !ELEM3(1, event->ctrl, event->oskey, event->shift) && event->val == KM_PRESS) {
|
||||
else if(event->type == KKEY && !ELEM3(KM_MOD_FIRST, event->ctrl, event->oskey, event->shift) && event->val == KM_PRESS) {
|
||||
if(event->alt)
|
||||
ui_but_anim_remove_keyingset(C);
|
||||
else
|
||||
@ -6079,9 +6075,9 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle
|
||||
case ZKEY:
|
||||
{
|
||||
if( (event->val == KM_PRESS) &&
|
||||
(event->shift == FALSE) &&
|
||||
(event->ctrl == FALSE) &&
|
||||
(event->oskey == FALSE)
|
||||
(event->shift == FALSE) &&
|
||||
(event->ctrl == FALSE) &&
|
||||
(event->oskey == FALSE)
|
||||
) {
|
||||
for(but= block->buttons.first; but; but= but->next) {
|
||||
|
||||
|
@ -1221,7 +1221,7 @@ static void rna_search_cb(const struct bContext *C, void *arg_but, const char *s
|
||||
iconid= ui_id_icon_get((bContext*)C, id, 1);
|
||||
}
|
||||
else {
|
||||
name= RNA_struct_name_get_alloc(&itemptr, NULL, 0);
|
||||
name= RNA_struct_name_get_alloc(&itemptr, NULL, 0, NULL); /* could use the string length here */
|
||||
iconid = 0;
|
||||
}
|
||||
|
||||
|
@ -1042,7 +1042,7 @@ int ui_handler_panel_region(bContext *C, wmEvent *event)
|
||||
inside= 1;
|
||||
|
||||
if(inside && event->val==KM_PRESS) {
|
||||
if(event->type == AKEY && !ELEM4(1, event->ctrl, event->oskey, event->shift, event->alt)) {
|
||||
if(event->type == AKEY && !ELEM4(KM_MOD_FIRST, event->ctrl, event->oskey, event->shift, event->alt)) {
|
||||
|
||||
if(pa->flag & PNL_CLOSEDY) {
|
||||
if((block->maxy <= my) && (block->maxy+PNL_HEADER >= my))
|
||||
|
@ -2085,7 +2085,7 @@ static void list_item_row(bContext *C, uiLayout *layout, PointerRNA *ptr, Pointe
|
||||
if(icon == ICON_NONE || icon == ICON_DOT)
|
||||
icon= 0;
|
||||
|
||||
namebuf= RNA_struct_name_get_alloc(itemptr, NULL, 0);
|
||||
namebuf= RNA_struct_name_get_alloc(itemptr, NULL, 0, NULL);
|
||||
name= (namebuf)? namebuf: "";
|
||||
|
||||
/* hardcoded types */
|
||||
@ -2270,7 +2270,7 @@ void uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, const char *
|
||||
|
||||
if(found) {
|
||||
/* create button */
|
||||
name= RNA_struct_name_get_alloc(&itemptr, NULL, 0);
|
||||
name= RNA_struct_name_get_alloc(&itemptr, NULL, 0, NULL);
|
||||
icon= list_item_icon_get(C, &itemptr, rnaicon, 0);
|
||||
uiItemL(row, (name)? name: "", icon);
|
||||
|
||||
|
@ -1167,7 +1167,7 @@ void init_userdef_do_versions(void)
|
||||
}
|
||||
if(U.mixbufsize==0) U.mixbufsize= 2048;
|
||||
if (strcmp(U.tempdir, "/") == 0) {
|
||||
BLI_where_is_temp(U.tempdir, sizeof(U.tempdir), FALSE);
|
||||
BLI_system_temporary_dir(U.tempdir);
|
||||
}
|
||||
if (U.autokey_mode == 0) {
|
||||
/* 'add/replace' but not on */
|
||||
|
@ -53,6 +53,7 @@
|
||||
#include "BLI_listbase.h"
|
||||
#include "BLI_utildefines.h"
|
||||
#include "BLI_math_vector.h"
|
||||
#include "BLI_linklist.h"
|
||||
|
||||
#include "ED_object.h"
|
||||
#include "ED_mesh.h"
|
||||
|
@ -3700,7 +3700,7 @@ static void brush_edit_apply_event(bContext *C, wmOperator *op, wmEvent *event)
|
||||
RNA_collection_add(op->ptr, "stroke", &itemptr);
|
||||
|
||||
RNA_float_set_array(&itemptr, "mouse", mouse);
|
||||
RNA_boolean_set(&itemptr, "pen_flip", event->shift != 0); // XXX hardcoded
|
||||
RNA_boolean_set(&itemptr, "pen_flip", event->shift != FALSE); // XXX hardcoded
|
||||
|
||||
/* apply */
|
||||
brush_edit_apply(C, op, &itemptr);
|
||||
|
@ -50,7 +50,6 @@
|
||||
#include "DNA_object_fluidsim.h"
|
||||
|
||||
#include "BLI_blenlib.h"
|
||||
#include "BLI_fileops.h"
|
||||
#include "BLI_threads.h"
|
||||
#include "BLI_math.h"
|
||||
#include "BLI_utildefines.h"
|
||||
@ -833,7 +832,7 @@ static void fluidsim_delete_until_lastframe(FluidsimSettings *fss)
|
||||
|
||||
curFrame++;
|
||||
|
||||
if((exists = BLI_exist(targetFile)))
|
||||
if((exists = BLI_exists(targetFile)))
|
||||
{
|
||||
BLI_delete(targetFile, 0, 0);
|
||||
BLI_delete(targetFileVel, 0, 0);
|
||||
|
@ -47,7 +47,6 @@
|
||||
#include "BLI_blenlib.h"
|
||||
#include "BLI_math.h"
|
||||
#include "BLI_editVert.h"
|
||||
#include "BLI_listbase.h"
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#include "BKE_animsys.h"
|
||||
|
@ -925,7 +925,7 @@ void buttons_context_draw(const bContext *C, uiLayout *layout)
|
||||
|
||||
if(ptr->data) {
|
||||
icon= RNA_struct_ui_icon(ptr->type);
|
||||
name= RNA_struct_name_get_alloc(ptr, namebuf, sizeof(namebuf));
|
||||
name= RNA_struct_name_get_alloc(ptr, namebuf, sizeof(namebuf), NULL);
|
||||
|
||||
if(name) {
|
||||
if(!ELEM(sbuts->mainb, BCONTEXT_RENDER, BCONTEXT_SCENE) && ptr->type == &RNA_Scene)
|
||||
|
@ -169,7 +169,7 @@ static int file_browse_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
||||
if(!prop)
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
str= RNA_property_string_get_alloc(&ptr, prop, NULL, 0);
|
||||
str= RNA_property_string_get_alloc(&ptr, prop, NULL, 0, NULL);
|
||||
|
||||
/* useful yet irritating feature, Shift+Click to open the file
|
||||
* Alt+Click to browse a folder in the OS's browser */
|
||||
|
@ -749,7 +749,7 @@ int file_exec(bContext *C, wmOperator *exec_op)
|
||||
|
||||
file_sfile_to_operator(op, sfile, filepath);
|
||||
|
||||
if (BLI_exist(sfile->params->dir))
|
||||
if (BLI_exists(sfile->params->dir))
|
||||
fsmenu_insert_entry(fsmenu_get(), FS_CATEGORY_RECENT, sfile->params->dir, 0, 1);
|
||||
|
||||
BLI_make_file_string(G.main->name, filepath, BLI_get_folder_create(BLENDER_USER_CONFIG, NULL), BLENDER_BOOKMARK_FILE);
|
||||
|
@ -64,7 +64,6 @@
|
||||
|
||||
#include "BLI_blenlib.h"
|
||||
#include "BLI_linklist.h"
|
||||
#include "BLI_path_util.h"
|
||||
#include "BLI_storage_types.h"
|
||||
#include "BLI_dynstr.h"
|
||||
#include "BLI_utildefines.h"
|
||||
|
@ -278,7 +278,7 @@ void fsmenu_read_bookmarks(struct FSMenu* fsmenu, const char *filename)
|
||||
if (line[len-1] == '\n') {
|
||||
line[len-1] = '\0';
|
||||
}
|
||||
if (BLI_exist(line)) {
|
||||
if (BLI_exists(line)) {
|
||||
fsmenu_insert_entry(fsmenu, category, line, 0, 1);
|
||||
}
|
||||
}
|
||||
|
@ -68,7 +68,6 @@
|
||||
|
||||
|
||||
#include "BLI_math.h"
|
||||
#include "BLI_blenlib.h"
|
||||
#include "BLI_storage_types.h"
|
||||
|
||||
#include "RE_pipeline.h"
|
||||
|
@ -1021,7 +1021,7 @@ static void tree_element_to_path(SpaceOops *soops, TreeElement *te, TreeStoreEle
|
||||
/* tsenext= TREESTORE(temnext); */ /* UNUSED */
|
||||
|
||||
nextptr= &temnext->rnaptr;
|
||||
name= RNA_struct_name_get_alloc(nextptr, buf, sizeof(buf));
|
||||
name= RNA_struct_name_get_alloc(nextptr, buf, sizeof(buf), NULL);
|
||||
|
||||
if(name) {
|
||||
/* if possible, use name as a key in the path */
|
||||
|
@ -972,7 +972,7 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i
|
||||
}
|
||||
else if(type == TSE_RNA_STRUCT) {
|
||||
/* struct */
|
||||
te->name= RNA_struct_name_get_alloc(ptr, NULL, 0);
|
||||
te->name= RNA_struct_name_get_alloc(ptr, NULL, 0, NULL);
|
||||
|
||||
if(te->name)
|
||||
te->flag |= TE_FREE_NAME;
|
||||
|
@ -40,7 +40,6 @@
|
||||
|
||||
#include "BLI_blenlib.h"
|
||||
#include "BLI_math.h"
|
||||
#include "BLI_path_util.h"
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#include "BKE_context.h"
|
||||
|
@ -1581,10 +1581,11 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int
|
||||
{
|
||||
if (kmi->propvalue == TFM_MODAL_SNAP_INV_ON && kmi->val == KM_PRESS)
|
||||
{
|
||||
if ((ELEM(kmi->type, LEFTCTRLKEY, RIGHTCTRLKEY) && event->ctrl) ||
|
||||
(ELEM(kmi->type, LEFTSHIFTKEY, RIGHTSHIFTKEY) && event->shift) ||
|
||||
(ELEM(kmi->type, LEFTALTKEY, RIGHTALTKEY) && event->alt) ||
|
||||
(kmi->type == OSKEY && event->oskey)) {
|
||||
if ((ELEM(kmi->type, LEFTCTRLKEY, RIGHTCTRLKEY) && event->ctrl) ||
|
||||
(ELEM(kmi->type, LEFTSHIFTKEY, RIGHTSHIFTKEY) && event->shift) ||
|
||||
(ELEM(kmi->type, LEFTALTKEY, RIGHTALTKEY) && event->alt) ||
|
||||
((kmi->type == OSKEY) && event->oskey) )
|
||||
{
|
||||
t->modifiers |= MOD_SNAP_INVERT;
|
||||
}
|
||||
break;
|
||||
|
@ -67,9 +67,6 @@
|
||||
# include <dirent.h>
|
||||
#endif
|
||||
|
||||
#include "BLI_blenlib.h" /* BLI_remlink BLI_filesize BLI_addtail
|
||||
BLI_countlist BLI_stringdec */
|
||||
|
||||
#include "imbuf.h"
|
||||
|
||||
#include "AVI_avi.h"
|
||||
|
@ -649,7 +649,7 @@ PropertyRNA *RNA_struct_type_find_property(StructRNA *srna, const char *identifi
|
||||
FunctionRNA *RNA_struct_find_function(PointerRNA *ptr, const char *identifier);
|
||||
const struct ListBase *RNA_struct_type_functions(StructRNA *srna);
|
||||
|
||||
char *RNA_struct_name_get_alloc(PointerRNA *ptr, char *fixedbuf, int fixedlen);
|
||||
char *RNA_struct_name_get_alloc(PointerRNA *ptr, char *fixedbuf, int fixedlen, int *r_len);
|
||||
|
||||
/* Properties
|
||||
*
|
||||
@ -756,7 +756,7 @@ void RNA_property_float_get_default_array(PointerRNA *ptr, PropertyRNA *prop, fl
|
||||
float RNA_property_float_get_default_index(PointerRNA *ptr, PropertyRNA *prop, int index);
|
||||
|
||||
void RNA_property_string_get(PointerRNA *ptr, PropertyRNA *prop, char *value);
|
||||
char *RNA_property_string_get_alloc(PointerRNA *ptr, PropertyRNA *prop, char *fixedbuf, int fixedlen);
|
||||
char *RNA_property_string_get_alloc(PointerRNA *ptr, PropertyRNA *prop, char *fixedbuf, int fixedlen, int *r_len);
|
||||
void RNA_property_string_set(PointerRNA *ptr, PropertyRNA *prop, const char *value);
|
||||
int RNA_property_string_length(PointerRNA *ptr, PropertyRNA *prop);
|
||||
void RNA_property_string_get_default(PointerRNA *ptr, PropertyRNA *prop, char *value);
|
||||
@ -824,20 +824,6 @@ int RNA_path_resolve_full(PointerRNA *ptr, const char *path,
|
||||
char *RNA_path_from_ID_to_struct(PointerRNA *ptr);
|
||||
char *RNA_path_from_ID_to_property(PointerRNA *ptr, PropertyRNA *prop);
|
||||
|
||||
#if 0
|
||||
/* Dependency
|
||||
*
|
||||
* Experimental code that will generate callbacks for each dependency
|
||||
* between ID types. This may end up being useful for UI
|
||||
* and evaluation code that needs to know such dependencies for correct
|
||||
* redraws and re-evaluations. */
|
||||
|
||||
typedef void (*PropDependencyCallback)(void *udata, PointerRNA *from, PointerRNA *to);
|
||||
void RNA_test_dependencies_cb(void *udata, PointerRNA *from, PointerRNA *to);
|
||||
|
||||
void RNA_generate_dependencies(PointerRNA *mainptr, void *udata, PropDependencyCallback cb);
|
||||
#endif
|
||||
|
||||
/* Quick name based property access
|
||||
*
|
||||
* These are just an easier way to access property values without having to
|
||||
|
@ -748,12 +748,12 @@ void RNA_struct_blender_type_set(StructRNA *srna, void *blender_type)
|
||||
srna->blender_type= blender_type;
|
||||
}
|
||||
|
||||
char *RNA_struct_name_get_alloc(PointerRNA *ptr, char *fixedbuf, int fixedlen)
|
||||
char *RNA_struct_name_get_alloc(PointerRNA *ptr, char *fixedbuf, int fixedlen, int *r_len)
|
||||
{
|
||||
PropertyRNA *nameprop;
|
||||
|
||||
if(ptr->data && (nameprop = RNA_struct_name_property(ptr->type)))
|
||||
return RNA_property_string_get_alloc(ptr, nameprop, fixedbuf, fixedlen);
|
||||
return RNA_property_string_get_alloc(ptr, nameprop, fixedbuf, fixedlen, r_len);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@ -2276,7 +2276,8 @@ void RNA_property_string_get(PointerRNA *ptr, PropertyRNA *prop, char *value)
|
||||
strcpy(value, sprop->defaultvalue);
|
||||
}
|
||||
|
||||
char *RNA_property_string_get_alloc(PointerRNA *ptr, PropertyRNA *prop, char *fixedbuf, int fixedlen)
|
||||
char *RNA_property_string_get_alloc(PointerRNA *ptr, PropertyRNA *prop,
|
||||
char *fixedbuf, int fixedlen, int *r_len)
|
||||
{
|
||||
char *buf;
|
||||
int length;
|
||||
@ -2301,6 +2302,10 @@ char *RNA_property_string_get_alloc(PointerRNA *ptr, PropertyRNA *prop, char *fi
|
||||
BLI_assert(buf[length] == '\0');
|
||||
#endif
|
||||
|
||||
if (r_len) {
|
||||
*r_len= length;
|
||||
}
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
@ -2836,15 +2841,17 @@ int RNA_property_collection_lookup_string(PointerRNA *ptr, PropertyRNA *prop, co
|
||||
PropertyRNA *nameprop;
|
||||
char name[256], *nameptr;
|
||||
int found= 0;
|
||||
int keylen= strlen(key);
|
||||
int namelen;
|
||||
|
||||
RNA_property_collection_begin(ptr, prop, &iter);
|
||||
for(; iter.valid; RNA_property_collection_next(&iter)) {
|
||||
if(iter.ptr.data && iter.ptr.type->nameproperty) {
|
||||
nameprop= iter.ptr.type->nameproperty;
|
||||
|
||||
nameptr= RNA_property_string_get_alloc(&iter.ptr, nameprop, name, sizeof(name));
|
||||
nameptr= RNA_property_string_get_alloc(&iter.ptr, nameprop, name, sizeof(name), &namelen);
|
||||
|
||||
if(strcmp(nameptr, key) == 0) {
|
||||
if((keylen == namelen) && (strcmp(nameptr, key) == 0)) {
|
||||
*r_ptr= iter.ptr;
|
||||
found= 1;
|
||||
}
|
||||
@ -4254,7 +4261,7 @@ char *RNA_string_get_alloc(PointerRNA *ptr, const char *name, char *fixedbuf, in
|
||||
PropertyRNA *prop= RNA_struct_find_property(ptr, name);
|
||||
|
||||
if(prop) {
|
||||
return RNA_property_string_get_alloc(ptr, prop, fixedbuf, fixedlen);
|
||||
return RNA_property_string_get_alloc(ptr, prop, fixedbuf, fixedlen, NULL); /* TODO, pass length */
|
||||
}
|
||||
else {
|
||||
printf("%s: %s.%s not found.\n", __func__, ptr->type->identifier, name);
|
||||
@ -5442,7 +5449,7 @@ int RNA_property_copy(PointerRNA *ptr, PointerRNA *fromptr, PropertyRNA *prop, i
|
||||
}
|
||||
case PROP_STRING:
|
||||
{
|
||||
char *value= RNA_property_string_get_alloc(fromptr, prop, NULL, 0);
|
||||
char *value= RNA_property_string_get_alloc(fromptr, prop, NULL, 0, NULL);
|
||||
RNA_property_string_set(ptr, prop, value);
|
||||
MEM_freeN(value);
|
||||
return 1;
|
||||
|
@ -40,7 +40,6 @@
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include "BLI_blenlib.h"
|
||||
#include "BKE_armature.h"
|
||||
|
||||
void rna_EditBone_align_roll(EditBone *ebo, float no[3])
|
||||
|
@ -42,8 +42,6 @@
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include "BLI_blenlib.h"
|
||||
|
||||
#include "BKE_animsys.h"
|
||||
#include "BKE_fcurve.h"
|
||||
|
||||
|
@ -96,7 +96,7 @@ static int fluidsim_find_lastframe(FluidsimSettings *fss)
|
||||
do {
|
||||
BLI_strncpy(targetFile, targetDir, sizeof(targetFile));
|
||||
BLI_path_frame(targetFile, curFrame++, 0);
|
||||
} while(BLI_exist(targetFile));
|
||||
} while(BLI_exists(targetFile));
|
||||
|
||||
return curFrame - 1;
|
||||
}
|
||||
|
@ -40,8 +40,6 @@
|
||||
|
||||
#ifdef RNA_RUNTIME
|
||||
|
||||
#include "BLI_path_util.h"
|
||||
|
||||
static int rna_GPencilLayer_active_frame_editable(PointerRNA *ptr)
|
||||
{
|
||||
bGPDlayer *gpl= (bGPDlayer *)ptr->data;
|
||||
|
@ -98,8 +98,6 @@ static EnumPropertyItem empty_vortex_shape_items[] = {
|
||||
#include "BKE_pointcache.h"
|
||||
#include "BKE_depsgraph.h"
|
||||
|
||||
#include "BLI_blenlib.h"
|
||||
|
||||
#include "ED_object.h"
|
||||
|
||||
static void rna_Cache_change(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
|
||||
|
@ -120,7 +120,6 @@ EnumPropertyItem part_hair_ren_as_items[] = {
|
||||
#ifdef RNA_RUNTIME
|
||||
|
||||
#include "BLI_math.h"
|
||||
#include "BLI_listbase.h"
|
||||
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_cloth.h"
|
||||
|
@ -175,7 +175,6 @@ EnumPropertyItem image_color_mode_items[] ={
|
||||
|
||||
#include "BLI_threads.h"
|
||||
#include "BLI_editVert.h"
|
||||
#include "BLI_blenlib.h"
|
||||
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_global.h"
|
||||
|
@ -295,8 +295,7 @@ static void rna_userdef_addon_remove(bAddon *bext)
|
||||
|
||||
static void rna_userdef_temp_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *UNUSED(ptr))
|
||||
{
|
||||
extern char btempdir[];
|
||||
BLI_where_is_temp(btempdir, FILE_MAX, 1);
|
||||
BLI_init_temporary_dir(U.tempdir);
|
||||
}
|
||||
|
||||
static void rna_userdef_text_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *UNUSED(ptr))
|
||||
|
@ -47,6 +47,7 @@
|
||||
#include "BLI_edgehash.h"
|
||||
#include "BLI_math.h"
|
||||
#include "BLI_utildefines.h"
|
||||
#include "BLI_linklist.h"
|
||||
|
||||
|
||||
#include "BKE_cdderivedmesh.h"
|
||||
|
@ -105,7 +105,7 @@ void fluidsim_init(FluidsimModifierData *fluidmd)
|
||||
|
||||
/* elubie: changed this to default to the same dir as the render output
|
||||
to prevent saving to C:\ on Windows */
|
||||
BLI_strncpy(fss->surfdataPath, btempdir, FILE_MAX);
|
||||
BLI_strncpy(fss->surfdataPath, BLI_temporary_dir(), FILE_MAX);
|
||||
|
||||
// first init of bounding box
|
||||
// no bounding box needed
|
||||
|
@ -1320,7 +1320,7 @@ void IIR_gauss(CompBuf* src, float sigma, int chan, int xy)
|
||||
|
||||
if ((xy < 1) || (xy > 3)) xy = 3;
|
||||
|
||||
// XXX The YVV macro defined below explicitely expects sources of at least 3x3 pixels,
|
||||
// XXX The YVV macro defined below explicitly expects sources of at least 3x3 pixels,
|
||||
// so just skiping blur along faulty direction if src's def is below that limit!
|
||||
if (src->x < 3) xy &= ~(int) 1;
|
||||
if (src->y < 3) xy &= ~(int) 2;
|
||||
@ -1346,7 +1346,7 @@ void IIR_gauss(CompBuf* src, float sigma, int chan, int xy)
|
||||
// it seems to work, not entirely sure if it is actually totally correct,
|
||||
// Besides J.M.Geusebroek's anigauss.c (see http://www.science.uva.nl/~mark),
|
||||
// found one other implementation by Cristoph Lampert,
|
||||
// but neither seem to be quite the same, result seems to be ok sofar anyway.
|
||||
// but neither seem to be quite the same, result seems to be ok so far anyway.
|
||||
// Extra scale factor here to not have to do it in filter,
|
||||
// though maybe this had something to with the precision errors
|
||||
sc = cf[0]/((1.0 + cf[1] - cf[2] + cf[3])*(1.0 - cf[1] - cf[2] - cf[3])*(1.0 + cf[2] + (cf[1] - cf[3])*cf[3]));
|
||||
|
@ -86,8 +86,9 @@ static CompBuf *dblur(bNode *node, CompBuf *img, int iterations, int wrap,
|
||||
getpix(tmp, cs * u + ss * v + center_x_pix, cs * v - ss * u + center_y_pix, col);
|
||||
|
||||
/* mix img and transformed tmp */
|
||||
for(j= 0; j < 4; ++j)
|
||||
img->rect[p + j]= AVG2(img->rect[p + j], col[j]);
|
||||
for(j= 0; j < 4; ++j) {
|
||||
img->rect[p + j]= 0.5f * (img->rect[p + j] + col[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -36,8 +36,6 @@
|
||||
#ifndef BPY_EXTERN_H
|
||||
#define BPY_EXTERN_H
|
||||
|
||||
extern char bprogname[]; /* holds a copy of argv[0], from creator.c */
|
||||
|
||||
struct Text; /* defined in DNA_text_types.h */
|
||||
struct ID; /* DNA_ID.h */
|
||||
struct Object; /* DNA_object_types.h */
|
||||
|
@ -67,9 +67,9 @@ PyObject *BPy_IDGroup_WrapData( ID *id, IDProperty *prop )
|
||||
switch ( prop->type ) {
|
||||
case IDP_STRING:
|
||||
#ifdef USE_STRING_COERCE
|
||||
return PyC_UnicodeFromByte(IDP_Array(prop));
|
||||
return PyC_UnicodeFromByteAndSize(IDP_Array(prop), prop->len);
|
||||
#else
|
||||
return PyUnicode_FromString(IDP_Array(prop));
|
||||
return PyUnicode_FromStringAndSize(IDP_Array(prop), prop->len);
|
||||
#endif
|
||||
case IDP_INT:
|
||||
return PyLong_FromLong( (long)prop->data.val );
|
||||
@ -485,9 +485,9 @@ static PyObject *BPy_IDGroup_MapDataToPy(IDProperty *prop)
|
||||
switch (prop->type) {
|
||||
case IDP_STRING:
|
||||
#ifdef USE_STRING_COERCE
|
||||
return PyC_UnicodeFromByte(IDP_Array(prop));
|
||||
return PyC_UnicodeFromByteAndSize(IDP_Array(prop), prop->len);
|
||||
#else
|
||||
return PyUnicode_FromString(IDP_Array(prop));
|
||||
return PyUnicode_FromStringAndSize(IDP_Array(prop), prop->len);
|
||||
#endif
|
||||
break;
|
||||
case IDP_FLOAT:
|
||||
|
@ -386,9 +386,9 @@ const char *PyC_UnicodeAsByte(PyObject *py_str, PyObject **coerce)
|
||||
}
|
||||
}
|
||||
|
||||
PyObject *PyC_UnicodeFromByte(const char *str)
|
||||
PyObject *PyC_UnicodeFromByteAndSize(const char *str, Py_ssize_t size)
|
||||
{
|
||||
PyObject *result= PyUnicode_FromString(str);
|
||||
PyObject *result= PyUnicode_FromStringAndSize(str, size);
|
||||
if (result) {
|
||||
/* 99% of the time this is enough but we better support non unicode
|
||||
* chars since blender doesnt limit this */
|
||||
@ -397,11 +397,16 @@ PyObject *PyC_UnicodeFromByte(const char *str)
|
||||
else {
|
||||
PyErr_Clear();
|
||||
/* this means paths will always be accessible once converted, on all OS's */
|
||||
result= PyUnicode_DecodeFSDefault(str);
|
||||
result= PyUnicode_DecodeFSDefaultAndSize(str, size);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
PyObject *PyC_UnicodeFromByte(const char *str)
|
||||
{
|
||||
return PyC_UnicodeFromByteAndSize(str, strlen(str));
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
* Description: This function creates a new Python dictionary object.
|
||||
* note: dict is owned by sys.modules["__main__"] module, reference is borrowed
|
||||
|
@ -40,8 +40,9 @@ void PyC_FileAndNum_Safe(const char **filename, int *lineno); /* checks python
|
||||
int PyC_AsArray(void *array, PyObject *value, const int length, const PyTypeObject *type, const short is_double, const char *error_prefix);
|
||||
|
||||
/* follow http://www.python.org/dev/peps/pep-0383/ */
|
||||
PyObject * PyC_UnicodeFromByte(const char *str);
|
||||
const char * PyC_UnicodeAsByte(PyObject *py_str, PyObject **coerce); /* coerce must be NULL */
|
||||
PyObject * PyC_UnicodeFromByte(const char *str);
|
||||
PyObject * PyC_UnicodeFromByteAndSize(const char *str, Py_ssize_t size);
|
||||
const char * PyC_UnicodeAsByte(PyObject *py_str, PyObject **coerce); /* coerce must be NULL */
|
||||
|
||||
/* name namespace function for bpy & bge */
|
||||
PyObject * PyC_DefaultNameSpace(const char *filename);
|
||||
|
@ -93,8 +93,6 @@ static PyStructSequence_Desc app_info_desc= {
|
||||
|
||||
static PyObject *make_app_info(void)
|
||||
{
|
||||
extern char bprogname[]; /* argv[0] from creator.c */
|
||||
|
||||
PyObject *app_info;
|
||||
int pos= 0;
|
||||
|
||||
@ -118,7 +116,7 @@ static PyObject *make_app_info(void)
|
||||
SetStrItem("");
|
||||
#endif
|
||||
SetStrItem(STRINGIFY(BLENDER_VERSION_CYCLE));
|
||||
SetStrItem(bprogname);
|
||||
SetStrItem(BLI_program_path());
|
||||
SetObjItem(PyBool_FromLong(G.background));
|
||||
|
||||
/* build info */
|
||||
@ -200,8 +198,7 @@ static int bpy_app_debug_value_set(PyObject *UNUSED(self), PyObject *value, void
|
||||
|
||||
static PyObject *bpy_app_tempdir_get(PyObject *UNUSED(self), void *UNUSED(closure))
|
||||
{
|
||||
extern char btempdir[];
|
||||
return PyC_UnicodeFromByte(btempdir);
|
||||
return PyC_UnicodeFromByte(BLI_temporary_dir());
|
||||
}
|
||||
|
||||
static PyObject *bpy_app_driver_dict_get(PyObject *UNUSED(self), void *UNUSED(closure))
|
||||
|
@ -193,9 +193,9 @@ void BPY_python_start(int argc, const char **argv)
|
||||
PyThreadState *py_tstate= NULL;
|
||||
|
||||
/* not essential but nice to set our name */
|
||||
static wchar_t bprogname_wchar[FILE_MAXDIR+FILE_MAXFILE]; /* python holds a reference */
|
||||
BLI_strncpy_wchar_from_utf8(bprogname_wchar, bprogname, sizeof(bprogname_wchar) / sizeof(wchar_t));
|
||||
Py_SetProgramName(bprogname_wchar);
|
||||
static wchar_t program_path_wchar[FILE_MAXDIR+FILE_MAXFILE]; /* python holds a reference */
|
||||
BLI_strncpy_wchar_from_utf8(program_path_wchar, BLI_program_path(), sizeof(program_path_wchar) / sizeof(wchar_t));
|
||||
Py_SetProgramName(program_path_wchar);
|
||||
|
||||
/* must run before python initializes */
|
||||
PyImport_ExtendInittab(bpy_internal_modules);
|
||||
@ -203,9 +203,9 @@ void BPY_python_start(int argc, const char **argv)
|
||||
/* allow to use our own included python */
|
||||
PyC_SetHomePath(BLI_get_folder(BLENDER_SYSTEM_PYTHON, NULL));
|
||||
|
||||
/* Python 3.2 now looks for '2.58/python/include/python3.2d/pyconfig.h' to parse
|
||||
* from the 'sysconfig' module which is used by 'site', so for now disable site.
|
||||
* alternatively we could copy the file. */
|
||||
/* Python 3.2 now looks for '2.xx/python/include/python3.2d/pyconfig.h' to
|
||||
* parse from the 'sysconfig' module which is used by 'site',
|
||||
* so for now disable site. alternatively we could copy the file. */
|
||||
Py_NoSiteFlag= 1;
|
||||
|
||||
Py_Initialize();
|
||||
@ -215,8 +215,11 @@ void BPY_python_start(int argc, const char **argv)
|
||||
{
|
||||
int i;
|
||||
PyObject *py_argv= PyList_New(argc);
|
||||
for (i=0; i<argc; i++)
|
||||
PyList_SET_ITEM(py_argv, i, PyC_UnicodeFromByte(argv[i])); /* should fix bug #20021 - utf path name problems, by replacing PyUnicode_FromString */
|
||||
for (i=0; i<argc; i++) {
|
||||
/* should fix bug #20021 - utf path name problems, by replacing
|
||||
* PyUnicode_FromString, with this one */
|
||||
PyList_SET_ITEM(py_argv, i, PyC_UnicodeFromByte(argv[i]));
|
||||
}
|
||||
|
||||
PySys_SetObject("argv", py_argv);
|
||||
Py_DECREF(py_argv);
|
||||
|
@ -810,7 +810,7 @@ static PyObject *pyrna_struct_str(BPy_StructRNA *self)
|
||||
}
|
||||
|
||||
/* print name if available */
|
||||
name= RNA_struct_name_get_alloc(&self->ptr, NULL, FALSE);
|
||||
name= RNA_struct_name_get_alloc(&self->ptr, NULL, 0, NULL);
|
||||
if (name) {
|
||||
ret= PyUnicode_FromFormat("<bpy_struct, %.200s(\"%.200s\")>",
|
||||
RNA_struct_identifier(self->ptr.type),
|
||||
@ -901,7 +901,7 @@ static PyObject *pyrna_prop_str(BPy_PropertyRNA *self)
|
||||
/* if a pointer, try to print name of pointer target too */
|
||||
if (RNA_property_type(self->prop) == PROP_POINTER) {
|
||||
ptr= RNA_property_pointer_get(&self->ptr, self->prop);
|
||||
name= RNA_struct_name_get_alloc(&ptr, NULL, FALSE);
|
||||
name= RNA_struct_name_get_alloc(&ptr, NULL, 0, NULL);
|
||||
|
||||
if (name) {
|
||||
ret= PyUnicode_FromFormat("<bpy_%.200s, %.200s.%.200s(\"%.200s\")>",
|
||||
@ -1257,14 +1257,22 @@ static PyObject *pyrna_enum_to_py(PointerRNA *ptr, PropertyRNA *prop, int val)
|
||||
ret= PyUnicode_FromString(enum_item->identifier);
|
||||
}
|
||||
else {
|
||||
const char *ptr_name= RNA_struct_name_get_alloc(ptr, NULL, FALSE);
|
||||
const char *ptr_name= RNA_struct_name_get_alloc(ptr, NULL, 0, NULL);
|
||||
|
||||
/* prefer not fail silently incase of api errors, maybe disable it later */
|
||||
printf("RNA Warning: Current value \"%d\" matches no enum in '%s', '%s', '%s'\n", val, RNA_struct_identifier(ptr->type), ptr_name, RNA_property_identifier(prop));
|
||||
printf("RNA Warning: Current value \"%d\" "
|
||||
"matches no enum in '%s', '%s', '%s'\n",
|
||||
val, RNA_struct_identifier(ptr->type),
|
||||
ptr_name, RNA_property_identifier(prop));
|
||||
|
||||
#if 0 // gives python decoding errors while generating docs :(
|
||||
char error_str[256];
|
||||
BLI_snprintf(error_str, sizeof(error_str), "RNA Warning: Current value \"%d\" matches no enum in '%s', '%s', '%s'", val, RNA_struct_identifier(ptr->type), ptr_name, RNA_property_identifier(prop));
|
||||
BLI_snprintf(error_str, sizeof(error_str),
|
||||
"RNA Warning: Current value \"%d\" "
|
||||
"matches no enum in '%s', '%s', '%s'",
|
||||
val, RNA_struct_identifier(ptr->type),
|
||||
ptr_name, RNA_property_identifier(prop));
|
||||
|
||||
PyErr_Warn(PyExc_RuntimeWarning, error_str);
|
||||
#endif
|
||||
|
||||
@ -1311,19 +1319,20 @@ PyObject *pyrna_prop_to_py(PointerRNA *ptr, PropertyRNA *prop)
|
||||
{
|
||||
int subtype= RNA_property_subtype(prop);
|
||||
const char *buf;
|
||||
int buf_len;
|
||||
char buf_fixed[32];
|
||||
|
||||
buf= RNA_property_string_get_alloc(ptr, prop, buf_fixed, sizeof(buf_fixed));
|
||||
buf= RNA_property_string_get_alloc(ptr, prop, buf_fixed, sizeof(buf_fixed), &buf_len);
|
||||
#ifdef USE_STRING_COERCE
|
||||
/* only file paths get special treatment, they may contain non utf-8 chars */
|
||||
if (ELEM3(subtype, PROP_FILEPATH, PROP_DIRPATH, PROP_FILENAME)) {
|
||||
ret= PyC_UnicodeFromByte(buf);
|
||||
ret= PyC_UnicodeFromByteAndSize(buf, buf_len);
|
||||
}
|
||||
else {
|
||||
ret= PyUnicode_FromString(buf);
|
||||
ret= PyUnicode_FromStringAndSize(buf, buf_len);
|
||||
}
|
||||
#else // USE_STRING_COERCE
|
||||
ret= PyUnicode_FromString(buf);
|
||||
ret= PyUnicode_FromStringAndSize(buf, buf_len);
|
||||
#endif // USE_STRING_COERCE
|
||||
if (buf_fixed != buf) {
|
||||
MEM_freeN((void *)buf);
|
||||
@ -3127,14 +3136,15 @@ static void pyrna_dir_members_rna(PyObject *list, PointerRNA *ptr)
|
||||
* Collect RNA attributes
|
||||
*/
|
||||
char name[256], *nameptr;
|
||||
int namelen;
|
||||
|
||||
iterprop= RNA_struct_iterator_property(ptr->type);
|
||||
|
||||
RNA_PROP_BEGIN(ptr, itemptr, iterprop) {
|
||||
nameptr= RNA_struct_name_get_alloc(&itemptr, name, sizeof(name));
|
||||
nameptr= RNA_struct_name_get_alloc(&itemptr, name, sizeof(name), &namelen);
|
||||
|
||||
if (nameptr) {
|
||||
pystring= PyUnicode_FromString(nameptr);
|
||||
pystring= PyUnicode_FromStringAndSize(nameptr, namelen);
|
||||
PyList_Append(list, pystring);
|
||||
Py_DECREF(pystring);
|
||||
|
||||
@ -3716,13 +3726,14 @@ static PyObject *pyrna_prop_collection_keys(BPy_PropertyRNA *self)
|
||||
PyObject *ret= PyList_New(0);
|
||||
PyObject *item;
|
||||
char name[256], *nameptr;
|
||||
int namelen;
|
||||
|
||||
RNA_PROP_BEGIN(&self->ptr, itemptr, self->prop) {
|
||||
nameptr= RNA_struct_name_get_alloc(&itemptr, name, sizeof(name));
|
||||
nameptr= RNA_struct_name_get_alloc(&itemptr, name, sizeof(name), &namelen);
|
||||
|
||||
if (nameptr) {
|
||||
/* add to python list */
|
||||
item= PyUnicode_FromString(nameptr);
|
||||
item= PyUnicode_FromStringAndSize(nameptr, namelen);
|
||||
PyList_Append(ret, item);
|
||||
Py_DECREF(item);
|
||||
/* done */
|
||||
@ -3751,15 +3762,16 @@ static PyObject *pyrna_prop_collection_items(BPy_PropertyRNA *self)
|
||||
PyObject *ret= PyList_New(0);
|
||||
PyObject *item;
|
||||
char name[256], *nameptr;
|
||||
int namelen;
|
||||
int i= 0;
|
||||
|
||||
RNA_PROP_BEGIN(&self->ptr, itemptr, self->prop) {
|
||||
if (itemptr.data) {
|
||||
/* add to python list */
|
||||
item= PyTuple_New(2);
|
||||
nameptr= RNA_struct_name_get_alloc(&itemptr, name, sizeof(name));
|
||||
nameptr= RNA_struct_name_get_alloc(&itemptr, name, sizeof(name), &namelen);
|
||||
if (nameptr) {
|
||||
PyTuple_SET_ITEM(item, 0, PyUnicode_FromString(nameptr));
|
||||
PyTuple_SET_ITEM(item, 0, PyUnicode_FromStringAndSize(nameptr, namelen));
|
||||
if (name != nameptr)
|
||||
MEM_freeN(nameptr);
|
||||
}
|
||||
|
@ -478,7 +478,7 @@ static void scene_unique_exr_name(Scene *scene, char *str, int sample)
|
||||
else
|
||||
BLI_snprintf(name, sizeof(name), "%s_%s%d.exr", fi, scene->id.name+2, sample);
|
||||
|
||||
BLI_make_file_string("/", str, btempdir, name);
|
||||
BLI_make_file_string("/", str, BLI_temporary_dir(), name);
|
||||
}
|
||||
|
||||
static void render_unique_exr_name(Render *re, char *str, int sample)
|
||||
@ -3146,11 +3146,11 @@ void RE_BlenderAnim(Render *re, Main *bmain, Scene *scene, Object *camera_overri
|
||||
if(scene->r.mode & (R_NO_OVERWRITE | R_TOUCH))
|
||||
BKE_makepicstring(name, scene->r.pic, scene->r.cfra, scene->r.imtype, scene->r.scemode & R_EXTENSION, TRUE);
|
||||
|
||||
if(scene->r.mode & R_NO_OVERWRITE && BLI_exist(name)) {
|
||||
if(scene->r.mode & R_NO_OVERWRITE && BLI_exists(name)) {
|
||||
printf("skipping existing frame \"%s\"\n", name);
|
||||
continue;
|
||||
}
|
||||
if(scene->r.mode & R_TOUCH && !BLI_exist(name)) {
|
||||
if(scene->r.mode & R_TOUCH && !BLI_exists(name)) {
|
||||
BLI_make_existing_file(name); /* makes the dir if its not there */
|
||||
BLI_touch(name);
|
||||
}
|
||||
@ -3175,7 +3175,7 @@ void RE_BlenderAnim(Render *re, Main *bmain, Scene *scene, Object *camera_overri
|
||||
if(G.afbreek==1) {
|
||||
/* remove touched file */
|
||||
if(BKE_imtype_is_movie(scene->r.imtype) == 0) {
|
||||
if (scene->r.mode & R_TOUCH && BLI_exist(name) && BLI_filepathsize(name) == 0) {
|
||||
if (scene->r.mode & R_TOUCH && BLI_exists(name) && BLI_filepathsize(name) == 0) {
|
||||
BLI_delete(name, 0, 0);
|
||||
}
|
||||
}
|
||||
|
@ -98,6 +98,11 @@ enum {
|
||||
#define KM_ALT2 64
|
||||
#define KM_OSKEY2 128
|
||||
|
||||
/* KM_MOD_ flags for wmKeyMapItem and wmEvent.alt/shift/oskey/ctrl */
|
||||
/* note that KM_ANY and FALSE are used with these defines too */
|
||||
#define KM_MOD_FIRST 1
|
||||
#define KM_MOD_SECOND 2
|
||||
|
||||
/* type: defined in wm_event_types.c */
|
||||
#define KM_TEXTINPUT -2
|
||||
|
||||
|
@ -2611,39 +2611,43 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U
|
||||
GHOST_TEventKeyData *kd= customdata;
|
||||
event.type= convert_key(kd->key);
|
||||
event.ascii= kd->ascii;
|
||||
strcpy(event.utf8_buf, kd->utf8_buf);
|
||||
memcpy(event.utf8_buf, kd->utf8_buf,sizeof(event.utf8_buf));/* might be not null terminated*/
|
||||
event.val= (type==GHOST_kEventKeyDown)?KM_PRESS:KM_RELEASE;
|
||||
|
||||
/* exclude arrow keys, esc, etc from text input */
|
||||
if(type==GHOST_kEventKeyUp || (event.ascii<32 && event.ascii>0))
|
||||
event.ascii= '\0';
|
||||
|
||||
/* modifiers */
|
||||
if (event.type==LEFTSHIFTKEY || event.type==RIGHTSHIFTKEY) {
|
||||
event.shift= evt->shift= (event.val==KM_PRESS);
|
||||
if(event.val==KM_PRESS && (evt->ctrl || evt->alt || evt->oskey))
|
||||
event.shift= evt->shift = 3; // define?
|
||||
}
|
||||
else if (event.type==LEFTCTRLKEY || event.type==RIGHTCTRLKEY) {
|
||||
event.ctrl= evt->ctrl= (event.val==KM_PRESS);
|
||||
if(event.val==KM_PRESS && (evt->shift || evt->alt || evt->oskey))
|
||||
event.ctrl= evt->ctrl = 3; // define?
|
||||
}
|
||||
else if (event.type==LEFTALTKEY || event.type==RIGHTALTKEY) {
|
||||
event.alt= evt->alt= (event.val==KM_PRESS);
|
||||
if(event.val==KM_PRESS && (evt->ctrl || evt->shift || evt->oskey))
|
||||
event.alt= evt->alt = 3; // define?
|
||||
}
|
||||
else if (event.type==OSKEY) {
|
||||
event.oskey= evt->oskey= (event.val==KM_PRESS);
|
||||
if(event.val==KM_PRESS && (evt->ctrl || evt->alt || evt->shift))
|
||||
event.oskey= evt->oskey = 3; // define?
|
||||
if(type==GHOST_kEventKeyUp) {
|
||||
if (event.ascii<32 && event.ascii > 0) {
|
||||
event.ascii= '\0';
|
||||
}
|
||||
|
||||
/* ghost should do this already for key up */
|
||||
if (event.utf8_buf[0]) {
|
||||
printf("%s: ghost on you're platform is misbehaving, utf8 events on key up!\n", __func__);
|
||||
}
|
||||
event.utf8_buf[0]= '\0';
|
||||
}
|
||||
else {
|
||||
|
||||
/* modifiers */
|
||||
/* assigning both first and second is strange - campbell */
|
||||
switch(event.type) {
|
||||
case LEFTSHIFTKEY: case RIGHTSHIFTKEY:
|
||||
event.shift= evt->shift= (event.val==KM_PRESS) ? ((evt->ctrl || evt->alt || evt->oskey) ? (KM_MOD_FIRST | KM_MOD_SECOND) : KM_MOD_FIRST) : FALSE;
|
||||
break;
|
||||
case LEFTCTRLKEY: case RIGHTCTRLKEY:
|
||||
event.ctrl= evt->ctrl= (event.val==KM_PRESS) ? ((evt->shift || evt->alt || evt->oskey) ? (KM_MOD_FIRST | KM_MOD_SECOND) : KM_MOD_FIRST) : FALSE;
|
||||
break;
|
||||
case LEFTALTKEY: case RIGHTALTKEY:
|
||||
event.alt= evt->alt= (event.val==KM_PRESS) ? ((evt->ctrl || evt->shift || evt->oskey) ? (KM_MOD_FIRST | KM_MOD_SECOND) : KM_MOD_FIRST) : FALSE;
|
||||
break;
|
||||
case OSKEY:
|
||||
event.oskey= evt->oskey= (event.val==KM_PRESS) ? ((evt->ctrl || evt->alt || evt->shift) ? (KM_MOD_FIRST | KM_MOD_SECOND) : KM_MOD_FIRST) : FALSE;
|
||||
break;
|
||||
default:
|
||||
if(event.val==KM_PRESS && event.keymodifier==0)
|
||||
evt->keymodifier= event.type; /* only set in eventstate, for next event */
|
||||
else if(event.val==KM_RELEASE && event.keymodifier==event.type)
|
||||
event.keymodifier= evt->keymodifier= 0;
|
||||
break;
|
||||
}
|
||||
|
||||
/* this case happens on some systems that on holding a key pressed,
|
||||
@ -2729,4 +2733,8 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* Handy when debugging checking events */
|
||||
/* WM_event_print(&event); */
|
||||
|
||||
}
|
||||
|
@ -289,8 +289,9 @@ static void wm_init_userdef(bContext *C)
|
||||
if ((U.flag & USER_SCRIPT_AUTOEXEC_DISABLE) == 0) G.f |= G_SCRIPT_AUTOEXEC;
|
||||
else G.f &= ~G_SCRIPT_AUTOEXEC;
|
||||
}
|
||||
|
||||
/* update tempdir from user preferences */
|
||||
BLI_where_is_temp(btempdir, FILE_MAX, 1);
|
||||
BLI_init_temporary_dir(U.tempdir);
|
||||
}
|
||||
|
||||
|
||||
@ -856,14 +857,14 @@ void wm_autosave_location(char *filepath)
|
||||
* BLI_make_file_string will create string that has it most likely on C:\
|
||||
* through get_default_root().
|
||||
* If there is no C:\tmp autosave fails. */
|
||||
if (!BLI_exists(btempdir)) {
|
||||
if (!BLI_exists(BLI_temporary_dir())) {
|
||||
savedir = BLI_get_folder_create(BLENDER_USER_AUTOSAVE, NULL);
|
||||
BLI_make_file_string("/", filepath, savedir, pidstr);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
BLI_make_file_string("/", filepath, btempdir, pidstr);
|
||||
BLI_make_file_string("/", filepath, BLI_temporary_dir(), pidstr);
|
||||
}
|
||||
|
||||
void WM_autosave_init(wmWindowManager *wm)
|
||||
@ -921,7 +922,7 @@ void wm_autosave_delete(void)
|
||||
|
||||
if(BLI_exists(filename)) {
|
||||
char str[FILE_MAXDIR+FILE_MAXFILE];
|
||||
BLI_make_file_string("/", str, btempdir, "quit.blend");
|
||||
BLI_make_file_string("/", str, BLI_temporary_dir(), "quit.blend");
|
||||
|
||||
/* if global undo; remove tempsave, otherwise rename */
|
||||
if(U.uiflag & USER_GLOBALUNDO) BLI_delete(filename, 0, 0);
|
||||
|
@ -310,31 +310,15 @@ static void keymap_event_set(wmKeyMapItem *kmi, short type, short val, int modif
|
||||
kmi->type= type;
|
||||
kmi->val= val;
|
||||
kmi->keymodifier= keymodifier;
|
||||
|
||||
|
||||
if(modifier == KM_ANY) {
|
||||
kmi->shift= kmi->ctrl= kmi->alt= kmi->oskey= KM_ANY;
|
||||
}
|
||||
else {
|
||||
|
||||
kmi->shift= kmi->ctrl= kmi->alt= kmi->oskey= 0;
|
||||
|
||||
/* defines? */
|
||||
if(modifier & KM_SHIFT)
|
||||
kmi->shift= 1;
|
||||
else if(modifier & KM_SHIFT2)
|
||||
kmi->shift= 2;
|
||||
if(modifier & KM_CTRL)
|
||||
kmi->ctrl= 1;
|
||||
else if(modifier & KM_CTRL2)
|
||||
kmi->ctrl= 2;
|
||||
if(modifier & KM_ALT)
|
||||
kmi->alt= 1;
|
||||
else if(modifier & KM_ALT2)
|
||||
kmi->alt= 2;
|
||||
if(modifier & KM_OSKEY)
|
||||
kmi->oskey= 1;
|
||||
else if(modifier & KM_OSKEY2)
|
||||
kmi->oskey= 2;
|
||||
kmi->shift= (modifier & KM_SHIFT) ? KM_MOD_FIRST : ((modifier & KM_SHIFT2) ? KM_MOD_SECOND : FALSE);
|
||||
kmi->ctrl= (modifier & KM_CTRL) ? KM_MOD_FIRST : ((modifier & KM_CTRL2) ? KM_MOD_SECOND : FALSE);
|
||||
kmi->alt= (modifier & KM_ALT) ? KM_MOD_FIRST : ((modifier & KM_ALT2) ? KM_MOD_SECOND : FALSE);
|
||||
kmi->oskey= (modifier & KM_OSKEY) ? KM_MOD_FIRST : ((modifier & KM_OSKEY2) ? KM_MOD_SECOND : FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1807,7 +1807,7 @@ static int wm_recover_last_session_exec(bContext *C, wmOperator *op)
|
||||
WM_event_add_notifier(C, NC_WINDOW, NULL);
|
||||
|
||||
/* load file */
|
||||
BLI_make_file_string("/", filename, btempdir, "quit.blend");
|
||||
BLI_make_file_string("/", filename, BLI_temporary_dir(), "quit.blend");
|
||||
WM_read_file(C, filename, op->reports);
|
||||
|
||||
G.fileflags &= ~G_FILE_RECOVER;
|
||||
|
@ -129,7 +129,6 @@ struct RenderResult *RE_GetResult(struct Render *re){return (struct RenderResult
|
||||
struct Render *RE_GetRender(const char *name){return (struct Render *) NULL;}
|
||||
|
||||
/* blenkernel */
|
||||
char btempdir[] = "";
|
||||
void RE_FreeRenderResult(struct RenderResult *res){}
|
||||
struct RenderResult *RE_MultilayerConvert(void *exrhandle, int rectx, int recty){return (struct RenderResult *) NULL;}
|
||||
void RE_GetResultImage(struct Render *re, struct RenderResult *rr){}
|
||||
|
@ -62,6 +62,7 @@
|
||||
|
||||
#include "DNA_ID.h"
|
||||
#include "DNA_scene_types.h"
|
||||
#include "DNA_userdef_types.h"
|
||||
|
||||
#include "BLI_blenlib.h"
|
||||
|
||||
@ -145,10 +146,6 @@ static int print_version(int argc, const char **argv, void *data);
|
||||
|
||||
extern int pluginapi_force_ref(void); /* from blenpluginapi:pluginapi.c */
|
||||
|
||||
char bprogname[FILE_MAX];
|
||||
char bprogdir[FILE_MAX];
|
||||
char btempdir[FILE_MAX];
|
||||
|
||||
#define BLEND_VERSION_STRING_FMT "Blender %d.%02d (sub %d)\n", BLENDER_VERSION/100, BLENDER_VERSION%100, BLENDER_SUBVERSION
|
||||
|
||||
/* Initialize callbacks for the modules that need them */
|
||||
@ -1166,11 +1163,8 @@ int main(int argc, const char **argv)
|
||||
fpsetmask(0);
|
||||
#endif
|
||||
|
||||
// copy path to executable in bprogname. playanim and creting runtimes
|
||||
// need this.
|
||||
|
||||
BLI_where_am_i(bprogname, sizeof(bprogname), argv[0]);
|
||||
BLI_split_dir_part(bprogname, bprogdir, sizeof(bprogdir));
|
||||
// initialize path to executable
|
||||
BLI_init_program_path(argv[0]);
|
||||
|
||||
BLI_threadapi_init();
|
||||
|
||||
@ -1225,7 +1219,8 @@ int main(int argc, const char **argv)
|
||||
WM_init(C, argc, argv);
|
||||
|
||||
/* this is properly initialized with user defs, but this is default */
|
||||
BLI_where_is_temp(btempdir, FILE_MAX, 1); /* call after loading the startup.blend so we can read U.tempdir */
|
||||
/* call after loading the startup.blend so we can read U.tempdir */
|
||||
BLI_init_temporary_dir(U.tempdir);
|
||||
|
||||
#ifdef WITH_SDL
|
||||
BLI_setenv("SDL_VIDEODRIVER", "dummy");
|
||||
@ -1236,7 +1231,8 @@ int main(int argc, const char **argv)
|
||||
|
||||
WM_init(C, argc, argv);
|
||||
|
||||
BLI_where_is_temp(btempdir, FILE_MAX, 0); /* call after loading the startup.blend so we can read U.tempdir */
|
||||
/* don't use user preferences temp dir */
|
||||
BLI_init_temporary_dir(NULL);
|
||||
}
|
||||
#ifdef WITH_PYTHON
|
||||
/**
|
||||
|
@ -76,9 +76,6 @@ extern "C"
|
||||
|
||||
int GHOST_HACK_getFirstFile(char buf[]);
|
||||
|
||||
extern char bprogname[]; /* holds a copy of argv[0], from creator.c */
|
||||
extern char btempdir[]; /* use this to store a valid temp directory */
|
||||
|
||||
// For BLF
|
||||
#include "BLF_api.h"
|
||||
#include "BLF_translation.h"
|
||||
@ -116,9 +113,6 @@ extern char datatoc_bfont_ttf[];
|
||||
const int kMinWindowWidth = 100;
|
||||
const int kMinWindowHeight = 100;
|
||||
|
||||
char bprogname[FILE_MAX];
|
||||
char bprogdir[FILE_MAX];
|
||||
|
||||
static void mem_error_cb(const char *errorStr)
|
||||
{
|
||||
fprintf(stderr, "%s", errorStr);
|
||||
@ -380,8 +374,8 @@ int main(int argc, char** argv)
|
||||
signal (SIGFPE, SIG_IGN);
|
||||
#endif /* __alpha__ */
|
||||
#endif /* __linux__ */
|
||||
BLI_where_am_i(bprogname, sizeof(bprogname), argv[0]);
|
||||
BLI_split_dir_part(bprogname, bprogdir, sizeof(bprogdir));
|
||||
BLI_init_program_path(argv[0]);
|
||||
BLI_init_temporary_dir(NULL);
|
||||
#ifdef __APPLE__
|
||||
// Can't use Carbon right now because of double defined type ID (In Carbon.h and DNA_ID.h, sigh)
|
||||
/*
|
||||
@ -786,7 +780,7 @@ int main(int argc, char** argv)
|
||||
}
|
||||
else
|
||||
{
|
||||
bfd = load_game_data(bprogname, filename[0]? filename: NULL);
|
||||
bfd = load_game_data(BLI_program_path(), filename[0]? filename: NULL);
|
||||
}
|
||||
|
||||
//::printf("game data loaded from %s\n", filename);
|
||||
|
@ -98,7 +98,7 @@ void KX_BulletPhysicsController::SetObject (SG_IObject* object)
|
||||
if (m_bSensor)
|
||||
{
|
||||
// use a different callback function for sensor object,
|
||||
// bullet will not synchronize, we must do it explicitely
|
||||
// bullet will not synchronize, we must do it explicitly
|
||||
SG_Callbacks& callbacks = gameobj->GetSGNode()->GetCallBackFunctions();
|
||||
callbacks.m_updatefunc = KX_GameObject::SynchronizeTransformFunc;
|
||||
}
|
||||
|
@ -767,7 +767,7 @@ void CcdPhysicsController::SetPhysicsEnvironment(class PHY_IPhysicsEnvironment *
|
||||
if (m_cci.m_physicsEnv != physicsEnv)
|
||||
{
|
||||
// since the environment is changing, we must also move the controler to the
|
||||
// new environement. Note that we don't handle sensor explicitely: this
|
||||
// new environment. Note that we don't handle sensor explicitly: this
|
||||
// function can be called on sensor but only when they are not registered
|
||||
if (m_cci.m_physicsEnv->removeCcdPhysicsController(this))
|
||||
{
|
||||
|
@ -63,7 +63,7 @@ struct PHY_RayCastResult
|
||||
/**
|
||||
* This class replaces the ignoreController parameter of rayTest function.
|
||||
* It allows more sophisticated filtering on the physics controller before computing the ray intersection to save CPU.
|
||||
* It is only used to its full extend by the Ccd physics environement (Bullet).
|
||||
* It is only used to its full extend by the Ccd physics environment (Bullet).
|
||||
*/
|
||||
class PHY_IRayCastFilterCallback
|
||||
{
|
||||
|
@ -607,7 +607,7 @@ void VideoFFmpeg::openCam (char * file, short camIdx)
|
||||
// The driver name is constructed automatically from the device type:
|
||||
// v4l : /dev/video<camIdx>
|
||||
// dv1394: /dev/dv1394/<camIdx>
|
||||
// If you have different driver name, you can specify the driver name explicitely
|
||||
// If you have different driver name, you can specify the driver name explicitly
|
||||
// instead of device type. Examples of valid filename:
|
||||
// /dev/v4l/video0:pal
|
||||
// /dev/ieee1394/1:ntsc
|
||||
|
Loading…
Reference in New Issue
Block a user