Cycles: svn merge -r41266:41467 ^/trunk/blender
This commit is contained in:
@@ -81,53 +81,52 @@ static PyObject *bpy_script_paths(PyObject *UNUSED(self))
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int bpy_blend_paths_visit_cb(void *userdata, char *UNUSED(path_dst), const char *path_src)
|
||||
{
|
||||
PyObject *list= (PyObject *)userdata;
|
||||
PyObject *item= PyUnicode_DecodeFSDefault(path_src);
|
||||
PyList_Append(list, item);
|
||||
Py_DECREF(item);
|
||||
return FALSE; /* never edits the path */
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(bpy_blend_paths_doc,
|
||||
".. function:: blend_paths(absolute=False)\n"
|
||||
".. function:: blend_paths(absolute=False, packed=False, local=False)\n"
|
||||
"\n"
|
||||
" Returns a list of paths to external files referenced by the loaded .blend file.\n"
|
||||
"\n"
|
||||
" :arg absolute: When true the paths returned are made absolute.\n"
|
||||
" :type absolute: boolean\n"
|
||||
" :arg packed: When true skip file paths for packed data.\n"
|
||||
" :type packed: boolean\n"
|
||||
" :arg local: When true skip linked library paths.\n"
|
||||
" :type local: boolean\n"
|
||||
" :return: path list.\n"
|
||||
" :rtype: list of strings\n"
|
||||
);
|
||||
static PyObject *bpy_blend_paths(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
|
||||
{
|
||||
struct BPathIterator *bpi;
|
||||
PyObject *list, *st; /* stupidly big string to be safe */
|
||||
/* be sure there is low chance of the path being too short */
|
||||
char filepath_expanded[1024];
|
||||
const char *lib;
|
||||
int flag= 0;
|
||||
PyObject *list;
|
||||
|
||||
int absolute= 0;
|
||||
static const char *kwlist[]= {"absolute", NULL};
|
||||
int absolute= FALSE;
|
||||
int packed= FALSE;
|
||||
int local= FALSE;
|
||||
static const char *kwlist[]= {"absolute", "packed", "local", NULL};
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kw, "|i:blend_paths", (char **)kwlist, &absolute))
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kw, "|ii:blend_paths",
|
||||
(char **)kwlist, &absolute, &packed))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (absolute) flag |= BPATH_TRAVERSE_ABS;
|
||||
if (!packed) flag |= BPATH_TRAVERSE_SKIP_PACKED;
|
||||
if (local) flag |= BPATH_TRAVERSE_SKIP_LIBRARY;
|
||||
|
||||
list= PyList_New(0);
|
||||
|
||||
for (BLI_bpathIterator_init(&bpi, G.main, G.main->name, 0); !BLI_bpathIterator_isDone(bpi); BLI_bpathIterator_step(bpi)) {
|
||||
/* build the list */
|
||||
if (absolute) {
|
||||
BLI_bpathIterator_getPathExpanded(bpi, filepath_expanded);
|
||||
}
|
||||
else {
|
||||
lib= BLI_bpathIterator_getLib(bpi);
|
||||
if (lib && (BLI_path_cmp(lib, BLI_bpathIterator_getBasePath(bpi)))) { /* relative path to the library is NOT the same as our blendfile path, return an absolute path */
|
||||
BLI_bpathIterator_getPathExpanded(bpi, filepath_expanded);
|
||||
}
|
||||
else {
|
||||
BLI_bpathIterator_getPath(bpi, filepath_expanded);
|
||||
}
|
||||
}
|
||||
st= PyUnicode_DecodeFSDefault(filepath_expanded);
|
||||
|
||||
PyList_Append(list, st);
|
||||
Py_DECREF(st);
|
||||
}
|
||||
|
||||
BLI_bpathIterator_free(bpi);
|
||||
bpath_traverse_main(G.main, bpy_blend_paths_visit_cb, flag, (void *)list);
|
||||
|
||||
return list;
|
||||
}
|
||||
@@ -147,10 +146,10 @@ static PyObject *bpy_user_resource(PyObject *UNUSED(self), PyObject *args, PyObj
|
||||
return NULL;
|
||||
|
||||
/* stupid string compare */
|
||||
if (!strcmp(type, "DATAFILES")) folder_id= BLENDER_USER_DATAFILES;
|
||||
else if (!strcmp(type, "CONFIG")) folder_id= BLENDER_USER_CONFIG;
|
||||
else if (!strcmp(type, "SCRIPTS")) folder_id= BLENDER_USER_SCRIPTS;
|
||||
else if (!strcmp(type, "AUTOSAVE")) folder_id= BLENDER_USER_AUTOSAVE;
|
||||
if (!strcmp(type, "DATAFILES")) folder_id= BLENDER_USER_DATAFILES;
|
||||
else if (!strcmp(type, "CONFIG")) folder_id= BLENDER_USER_CONFIG;
|
||||
else if (!strcmp(type, "SCRIPTS")) folder_id= BLENDER_USER_SCRIPTS;
|
||||
else if (!strcmp(type, "AUTOSAVE")) folder_id= BLENDER_USER_AUTOSAVE;
|
||||
else {
|
||||
PyErr_SetString(PyExc_ValueError, "invalid resource argument");
|
||||
return NULL;
|
||||
|
@@ -310,13 +310,14 @@ static void bpy_lib_exit_warn_type(BPy_Library *self, PyObject *item)
|
||||
|
||||
static PyObject *bpy_lib_exit(BPy_Library *self, PyObject *UNUSED(args))
|
||||
{
|
||||
Main *bmain= CTX_data_main(BPy_GetContext());
|
||||
Main *mainl= NULL;
|
||||
int err= 0;
|
||||
|
||||
flag_all_listbases_ids(LIB_PRE_EXISTING, 1);
|
||||
|
||||
/* here appending/linking starts */
|
||||
mainl= BLO_library_append_begin(CTX_data_main(BPy_GetContext()), &(self->blo_handle), self->relpath);
|
||||
mainl= BLO_library_append_begin(bmain, &(self->blo_handle), self->relpath);
|
||||
|
||||
{
|
||||
int i= 0, code;
|
||||
@@ -399,7 +400,7 @@ static PyObject *bpy_lib_exit(BPy_Library *self, PyObject *UNUSED(args))
|
||||
/* append, rather than linking */
|
||||
if ((self->flag & FILE_LINK)==0) {
|
||||
Library *lib= BLI_findstring(&G.main->library, self->abspath, offsetof(Library, name));
|
||||
if (lib) all_local(lib, 1);
|
||||
if (lib) BKE_library_make_local(bmain, lib, 1);
|
||||
else BLI_assert(!"cant find name of just added library!");
|
||||
}
|
||||
}
|
||||
|
@@ -236,7 +236,7 @@ static PyObject* GPU_export_shader(PyObject* UNUSED(self), PyObject *args, PyObj
|
||||
PY_DICT_ADD_LONG(dict,uniform,texnumber);
|
||||
}
|
||||
if (uniform->texpixels) {
|
||||
val = PyByteArray_FromStringAndSize((const char *)uniform->texpixels, uniform->texsize);
|
||||
val = PyByteArray_FromStringAndSize((const char *)uniform->texpixels, uniform->texsize * 4);
|
||||
PyDict_SetItemString(dict, "texpixels", val);
|
||||
Py_DECREF(val);
|
||||
PY_DICT_ADD_LONG(dict,uniform,texsize);
|
||||
|
Reference in New Issue
Block a user