Merge branch 'master' into blender2.8
This commit is contained in:
@@ -91,7 +91,6 @@ if 'cmake' in builder:
|
|||||||
elif builder.startswith('win32'):
|
elif builder.startswith('win32'):
|
||||||
bits = 32
|
bits = 32
|
||||||
cmake_options.extend(['-G', 'Visual Studio 12 2013'])
|
cmake_options.extend(['-G', 'Visual Studio 12 2013'])
|
||||||
cmake_extra_options.append('-DCUDA_NVCC_EXECUTABLE:FILEPATH=C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v8.0/bin/nvcc.exe')
|
|
||||||
|
|
||||||
elif builder.startswith('linux'):
|
elif builder.startswith('linux'):
|
||||||
tokens = builder.split("_")
|
tokens = builder.split("_")
|
||||||
@@ -111,8 +110,6 @@ if 'cmake' in builder:
|
|||||||
cuda_chroot_name = 'buildbot_' + deb_name + '_x86_64'
|
cuda_chroot_name = 'buildbot_' + deb_name + '_x86_64'
|
||||||
targets = ['player', 'blender', 'cuda']
|
targets = ['player', 'blender', 'cuda']
|
||||||
|
|
||||||
cmake_extra_options.append('-DCUDA_NVCC_EXECUTABLE=/usr/local/cuda/bin/nvcc')
|
|
||||||
|
|
||||||
cmake_options.append("-C" + os.path.join(blender_dir, cmake_config_file))
|
cmake_options.append("-C" + os.path.join(blender_dir, cmake_config_file))
|
||||||
|
|
||||||
# Prepare CMake options needed to configure cuda binaries compilation.
|
# Prepare CMake options needed to configure cuda binaries compilation.
|
||||||
|
@@ -183,6 +183,8 @@ class CyclesRender_PT_sampling(CyclesButtonsPanel, Panel):
|
|||||||
else:
|
else:
|
||||||
sub.label(text="AA Samples:")
|
sub.label(text="AA Samples:")
|
||||||
sub.prop(cscene, "aa_samples", text="Render")
|
sub.prop(cscene, "aa_samples", text="Render")
|
||||||
|
sub.prop(cscene, "preview_aa_samples", text="Preview")
|
||||||
|
|
||||||
col = split.column()
|
col = split.column()
|
||||||
sub = col.column(align=True)
|
sub = col.column(align=True)
|
||||||
sub.label(text="Samples:")
|
sub.label(text="Samples:")
|
||||||
|
@@ -147,10 +147,12 @@ def ui_draw_filter_register(
|
|||||||
return super().operator(*args, **kw)
|
return super().operator(*args, **kw)
|
||||||
|
|
||||||
def draw_override(func_orig, self_real, context):
|
def draw_override(func_orig, self_real, context):
|
||||||
# simple, no wrapping
|
cls_real = self_real.__class__
|
||||||
# return func_orig(self_wrap, context)
|
if cls_real is super:
|
||||||
|
# simple, no wrapping
|
||||||
|
return func_orig(self_real, context)
|
||||||
|
|
||||||
class Wrapper(self_real.__class__):
|
class Wrapper(cls_real):
|
||||||
__slots__ = ()
|
__slots__ = ()
|
||||||
def __getattribute__(self, attr):
|
def __getattribute__(self, attr):
|
||||||
if attr == "layout":
|
if attr == "layout":
|
||||||
|
@@ -48,11 +48,11 @@ def main():
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
# Possibly temp. addons path
|
# Possibly temp. addons path
|
||||||
from os.path import join, dirname, normpath
|
from os.path import join, dirname
|
||||||
sys.path.append(normpath(join(dirname(__file__),
|
sys.path.extend([
|
||||||
"..", "..", "addons", "modules")))
|
join(dirname(dirname(dirname(__file__))), "addons", "modules"),
|
||||||
sys.path.append(join(utils.user_resource('SCRIPTS'),
|
join(utils.user_resource('SCRIPTS'), "addons", "modules"),
|
||||||
"addons", "modules"))
|
])
|
||||||
|
|
||||||
# fake module to allow:
|
# fake module to allow:
|
||||||
# from bpy.types import Panel
|
# from bpy.types import Panel
|
||||||
|
@@ -21,8 +21,7 @@
|
|||||||
# support reloading sub-modules
|
# support reloading sub-modules
|
||||||
if "bpy" in locals():
|
if "bpy" in locals():
|
||||||
from importlib import reload
|
from importlib import reload
|
||||||
for val in _modules_loaded:
|
_modules_loaded[:] = [reload(val) for val in _modules_loaded]
|
||||||
reload(val)
|
|
||||||
del reload
|
del reload
|
||||||
|
|
||||||
_modules = [
|
_modules = [
|
||||||
@@ -73,4 +72,5 @@ def unregister():
|
|||||||
from bpy.utils import unregister_class
|
from bpy.utils import unregister_class
|
||||||
for mod in reversed(_modules_loaded):
|
for mod in reversed(_modules_loaded):
|
||||||
for cls in reversed(mod.classes):
|
for cls in reversed(mod.classes):
|
||||||
unregister_class(cls)
|
if cls.is_registered:
|
||||||
|
unregister_class(cls)
|
||||||
|
@@ -23,8 +23,7 @@
|
|||||||
# support reloading sub-modules
|
# support reloading sub-modules
|
||||||
if "bpy" in locals():
|
if "bpy" in locals():
|
||||||
from importlib import reload
|
from importlib import reload
|
||||||
for val in _modules_loaded:
|
_modules_loaded[:] = [reload(val) for val in _modules_loaded]
|
||||||
reload(val)
|
|
||||||
del reload
|
del reload
|
||||||
|
|
||||||
_modules = [
|
_modules = [
|
||||||
@@ -150,7 +149,8 @@ def unregister():
|
|||||||
from bpy.utils import unregister_class
|
from bpy.utils import unregister_class
|
||||||
for mod in reversed(_modules_loaded):
|
for mod in reversed(_modules_loaded):
|
||||||
for cls in reversed(mod.classes):
|
for cls in reversed(mod.classes):
|
||||||
unregister_class(cls)
|
if cls.is_registered:
|
||||||
|
unregister_class(cls)
|
||||||
|
|
||||||
# Define a default UIList, when a list does not need any custom drawing...
|
# Define a default UIList, when a list does not need any custom drawing...
|
||||||
# Keep in sync with its #defined name in UI_interface.h
|
# Keep in sync with its #defined name in UI_interface.h
|
||||||
|
@@ -50,6 +50,7 @@ bool BKE_blendfile_read_from_memory(
|
|||||||
bool BKE_blendfile_read_from_memfile(
|
bool BKE_blendfile_read_from_memfile(
|
||||||
struct bContext *C, struct MemFile *memfile,
|
struct bContext *C, struct MemFile *memfile,
|
||||||
struct ReportList *reports, int skip_flag);
|
struct ReportList *reports, int skip_flag);
|
||||||
|
void BKE_blendfile_read_make_empty(struct bContext *C);
|
||||||
|
|
||||||
struct UserDef *BKE_blendfile_userdef_read(
|
struct UserDef *BKE_blendfile_userdef_read(
|
||||||
const char *filepath, struct ReportList *reports);
|
const char *filepath, struct ReportList *reports);
|
||||||
|
@@ -426,6 +426,32 @@ bool BKE_blendfile_read_from_memfile(
|
|||||||
return (bfd != NULL);
|
return (bfd != NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Utility to make a file 'empty' used for startup to optionally give an empty file.
|
||||||
|
* Handy for tests.
|
||||||
|
*/
|
||||||
|
void BKE_blendfile_read_make_empty(bContext *C)
|
||||||
|
{
|
||||||
|
Main *bmain = CTX_data_main(C);
|
||||||
|
|
||||||
|
ListBase *lbarray[MAX_LIBARRAY];
|
||||||
|
ID *id;
|
||||||
|
int a;
|
||||||
|
|
||||||
|
a = set_listbasepointers(bmain, lbarray);
|
||||||
|
while (a--) {
|
||||||
|
id = lbarray[a]->first;
|
||||||
|
if (id != NULL) {
|
||||||
|
if (ELEM(GS(id->name), ID_SCE, ID_SCR, ID_WM)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
while ((id = lbarray[a]->first)) {
|
||||||
|
BKE_libblock_delete(bmain, id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* only read the userdef from a .blend */
|
/* only read the userdef from a .blend */
|
||||||
UserDef *BKE_blendfile_userdef_read(const char *filepath, ReportList *reports)
|
UserDef *BKE_blendfile_userdef_read(const char *filepath, ReportList *reports)
|
||||||
{
|
{
|
||||||
|
@@ -86,13 +86,14 @@
|
|||||||
/* Core/Shared Utilities */
|
/* Core/Shared Utilities */
|
||||||
|
|
||||||
/* Poll callback for interpolation operators */
|
/* Poll callback for interpolation operators */
|
||||||
static int gpencil_interpolate_poll(bContext *C)
|
static int gpencil_view3d_poll(bContext *C)
|
||||||
{
|
{
|
||||||
bGPdata *gpd = CTX_data_gpencil_data(C);
|
bGPdata *gpd = CTX_data_gpencil_data(C);
|
||||||
bGPDlayer *gpl = CTX_data_active_gpencil_layer(C);
|
bGPDlayer *gpl = CTX_data_active_gpencil_layer(C);
|
||||||
|
|
||||||
/* only 3D view */
|
/* only 3D view */
|
||||||
if (CTX_wm_area(C)->spacetype != SPACE_VIEW3D) {
|
ScrArea *sa = CTX_wm_area(C);
|
||||||
|
if (sa && sa->spacetype != SPACE_VIEW3D) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -673,7 +674,7 @@ void GPENCIL_OT_interpolate(wmOperatorType *ot)
|
|||||||
ot->invoke = gpencil_interpolate_invoke;
|
ot->invoke = gpencil_interpolate_invoke;
|
||||||
ot->modal = gpencil_interpolate_modal;
|
ot->modal = gpencil_interpolate_modal;
|
||||||
ot->cancel = gpencil_interpolate_cancel;
|
ot->cancel = gpencil_interpolate_cancel;
|
||||||
ot->poll = gpencil_interpolate_poll;
|
ot->poll = gpencil_view3d_poll;
|
||||||
|
|
||||||
/* flags */
|
/* flags */
|
||||||
ot->flag = OPTYPE_UNDO | OPTYPE_BLOCKING;
|
ot->flag = OPTYPE_UNDO | OPTYPE_BLOCKING;
|
||||||
@@ -1017,7 +1018,7 @@ void GPENCIL_OT_interpolate_sequence(wmOperatorType *ot)
|
|||||||
|
|
||||||
/* api callbacks */
|
/* api callbacks */
|
||||||
ot->exec = gpencil_interpolate_seq_exec;
|
ot->exec = gpencil_interpolate_seq_exec;
|
||||||
ot->poll = gpencil_interpolate_poll;
|
ot->poll = gpencil_view3d_poll;
|
||||||
|
|
||||||
/* flags */
|
/* flags */
|
||||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||||
@@ -1025,24 +1026,14 @@ void GPENCIL_OT_interpolate_sequence(wmOperatorType *ot)
|
|||||||
|
|
||||||
/* ******************** Remove Breakdowns ************************ */
|
/* ******************** Remove Breakdowns ************************ */
|
||||||
|
|
||||||
/* Same as gpencil_interpolate_poll(),
|
|
||||||
* except we ALSO need to have an active frame that is a breakdown
|
|
||||||
*/
|
|
||||||
static int gpencil_interpolate_reverse_poll(bContext *C)
|
static int gpencil_interpolate_reverse_poll(bContext *C)
|
||||||
{
|
{
|
||||||
bGPdata *gpd = CTX_data_gpencil_data(C);
|
if (!gpencil_view3d_poll(C)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
bGPDlayer *gpl = CTX_data_active_gpencil_layer(C);
|
bGPDlayer *gpl = CTX_data_active_gpencil_layer(C);
|
||||||
|
|
||||||
/* only 3D view */
|
|
||||||
if (CTX_wm_area(C)->spacetype != SPACE_VIEW3D) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* need data to interpolate */
|
|
||||||
if (ELEM(NULL, gpd, gpl)) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* need to be on a breakdown frame */
|
/* need to be on a breakdown frame */
|
||||||
if ((gpl->actframe == NULL) || (gpl->actframe->key_type != BEZT_KEYTYPE_BREAKDOWN)) {
|
if ((gpl->actframe == NULL) || (gpl->actframe->key_type != BEZT_KEYTYPE_BREAKDOWN)) {
|
||||||
CTX_wm_operator_poll_msg_set(C, "Expected current frame to be a breakdown");
|
CTX_wm_operator_poll_msg_set(C, "Expected current frame to be a breakdown");
|
||||||
|
@@ -1485,7 +1485,6 @@ static int skin_root_mark_exec(bContext *C, wmOperator *UNUSED(op))
|
|||||||
Object *ob = CTX_data_edit_object(C);
|
Object *ob = CTX_data_edit_object(C);
|
||||||
BMEditMesh *em = BKE_editmesh_from_object(ob);
|
BMEditMesh *em = BKE_editmesh_from_object(ob);
|
||||||
BMesh *bm = em->bm;
|
BMesh *bm = em->bm;
|
||||||
const int cd_vert_skin_offset = CustomData_get_offset(&bm->vdata, CD_MVERT_SKIN);
|
|
||||||
BMVert *bm_vert;
|
BMVert *bm_vert;
|
||||||
BMIter bm_iter;
|
BMIter bm_iter;
|
||||||
GSet *visited;
|
GSet *visited;
|
||||||
@@ -1494,6 +1493,8 @@ static int skin_root_mark_exec(bContext *C, wmOperator *UNUSED(op))
|
|||||||
|
|
||||||
BKE_mesh_ensure_skin_customdata(ob->data);
|
BKE_mesh_ensure_skin_customdata(ob->data);
|
||||||
|
|
||||||
|
const int cd_vert_skin_offset = CustomData_get_offset(&bm->vdata, CD_MVERT_SKIN);
|
||||||
|
|
||||||
BM_ITER_MESH (bm_vert, &bm_iter, bm, BM_VERTS_OF_MESH) {
|
BM_ITER_MESH (bm_vert, &bm_iter, bm, BM_VERTS_OF_MESH) {
|
||||||
if (BM_elem_flag_test(bm_vert, BM_ELEM_SELECT) &&
|
if (BM_elem_flag_test(bm_vert, BM_ELEM_SELECT) &&
|
||||||
BLI_gset_add(visited, bm_vert))
|
BLI_gset_add(visited, bm_vert))
|
||||||
|
@@ -643,7 +643,8 @@ bool WM_file_read(bContext *C, const char *filepath, ReportList *reports)
|
|||||||
* When not-null, this is written into the user preferences.
|
* When not-null, this is written into the user preferences.
|
||||||
*/
|
*/
|
||||||
int wm_homefile_read(
|
int wm_homefile_read(
|
||||||
bContext *C, ReportList *reports, bool use_factory_settings,
|
bContext *C, ReportList *reports,
|
||||||
|
bool use_factory_settings, bool use_empty_data,
|
||||||
const char *filepath_startup_override, const char *app_template_override)
|
const char *filepath_startup_override, const char *app_template_override)
|
||||||
{
|
{
|
||||||
ListBase wmbase;
|
ListBase wmbase;
|
||||||
@@ -779,6 +780,10 @@ int wm_homefile_read(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (use_empty_data) {
|
||||||
|
BKE_blendfile_read_make_empty(C);
|
||||||
|
}
|
||||||
|
|
||||||
/* Load template preferences,
|
/* Load template preferences,
|
||||||
* unlike regular preferences we only use some of the settings,
|
* unlike regular preferences we only use some of the settings,
|
||||||
* see: BKE_blender_userdef_set_app_template */
|
* see: BKE_blender_userdef_set_app_template */
|
||||||
@@ -1551,6 +1556,7 @@ static int wm_homefile_read_exec(bContext *C, wmOperator *op)
|
|||||||
const char *app_template;
|
const char *app_template;
|
||||||
PropertyRNA *prop_app_template = RNA_struct_find_property(op->ptr, "app_template");
|
PropertyRNA *prop_app_template = RNA_struct_find_property(op->ptr, "app_template");
|
||||||
const bool use_splash = !use_factory_settings && RNA_boolean_get(op->ptr, "use_splash");
|
const bool use_splash = !use_factory_settings && RNA_boolean_get(op->ptr, "use_splash");
|
||||||
|
const bool use_empty_data = RNA_boolean_get(op->ptr, "use_empty");
|
||||||
|
|
||||||
if (prop_app_template && RNA_property_is_set(op->ptr, prop_app_template)) {
|
if (prop_app_template && RNA_property_is_set(op->ptr, prop_app_template)) {
|
||||||
RNA_property_string_get(op->ptr, prop_app_template, app_template_buf);
|
RNA_property_string_get(op->ptr, prop_app_template, app_template_buf);
|
||||||
@@ -1560,7 +1566,7 @@ static int wm_homefile_read_exec(bContext *C, wmOperator *op)
|
|||||||
app_template = NULL;
|
app_template = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wm_homefile_read(C, op->reports, use_factory_settings, filepath, app_template)) {
|
if (wm_homefile_read(C, op->reports, use_factory_settings, use_empty_data, filepath, app_template)) {
|
||||||
if (use_splash) {
|
if (use_splash) {
|
||||||
WM_init_splash(C);
|
WM_init_splash(C);
|
||||||
}
|
}
|
||||||
@@ -1591,6 +1597,9 @@ void WM_OT_read_homefile(wmOperatorType *ot)
|
|||||||
"Load user interface setup from the .blend file");
|
"Load user interface setup from the .blend file");
|
||||||
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
||||||
|
|
||||||
|
prop = RNA_def_boolean(ot->srna, "use_empty", false, "Empty", "");
|
||||||
|
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
||||||
|
|
||||||
/* So the splash can be kept open after loading a file (for templates). */
|
/* So the splash can be kept open after loading a file (for templates). */
|
||||||
prop = RNA_def_boolean(ot->srna, "use_splash", false, "Splash", "");
|
prop = RNA_def_boolean(ot->srna, "use_splash", false, "Splash", "");
|
||||||
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
||||||
@@ -1615,6 +1624,9 @@ void WM_OT_read_factory_settings(wmOperatorType *ot)
|
|||||||
prop = RNA_def_string(ot->srna, "app_template", "Template", sizeof(U.app_template), "", "");
|
prop = RNA_def_string(ot->srna, "app_template", "Template", sizeof(U.app_template), "", "");
|
||||||
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
||||||
|
|
||||||
|
prop = RNA_def_boolean(ot->srna, "use_empty", false, "Empty", "");
|
||||||
|
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
||||||
|
|
||||||
/* omit poll to run in background mode */
|
/* omit poll to run in background mode */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -193,7 +193,7 @@ void WM_init(bContext *C, int argc, const char **argv)
|
|||||||
wm_init_reports(C);
|
wm_init_reports(C);
|
||||||
|
|
||||||
/* get the default database, plus a wm */
|
/* get the default database, plus a wm */
|
||||||
wm_homefile_read(C, NULL, G.factory_startup, NULL, NULL);
|
wm_homefile_read(C, NULL, G.factory_startup, false, NULL, NULL);
|
||||||
|
|
||||||
|
|
||||||
BLT_lang_set(NULL);
|
BLT_lang_set(NULL);
|
||||||
|
@@ -121,6 +121,13 @@ static void wm_keymap_item_properties_update_ot(wmKeyMapItem *kmi)
|
|||||||
if (ot->srna != kmi->ptr->type) {
|
if (ot->srna != kmi->ptr->type) {
|
||||||
/* matches wm_keymap_item_properties_set but doesnt alloc new ptr */
|
/* matches wm_keymap_item_properties_set but doesnt alloc new ptr */
|
||||||
WM_operator_properties_create_ptr(kmi->ptr, ot);
|
WM_operator_properties_create_ptr(kmi->ptr, ot);
|
||||||
|
/* 'kmi->ptr->data' NULL'd above, keep using existing properties.
|
||||||
|
* Note: the operators property types may have changed,
|
||||||
|
* we will need a more comprehensive sanitize function to support this properly.
|
||||||
|
*/
|
||||||
|
if (kmi->properties) {
|
||||||
|
kmi->ptr->data = kmi->properties;
|
||||||
|
}
|
||||||
WM_operator_properties_sanitize(kmi->ptr, 1);
|
WM_operator_properties_sanitize(kmi->ptr, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -336,7 +336,7 @@ void wm_window_close(bContext *C, wmWindowManager *wm, wmWindow *win)
|
|||||||
if (tmpwin == NULL)
|
if (tmpwin == NULL)
|
||||||
do_exit = 1;
|
do_exit = 1;
|
||||||
|
|
||||||
if ((U.uiflag & USER_QUIT_PROMPT) && !wm->file_saved) {
|
if ((U.uiflag & USER_QUIT_PROMPT) && !wm->file_saved && !G.background) {
|
||||||
if (do_exit) {
|
if (do_exit) {
|
||||||
if (!GHOST_confirmQuit(win->ghostwin))
|
if (!GHOST_confirmQuit(win->ghostwin))
|
||||||
return;
|
return;
|
||||||
|
@@ -36,7 +36,8 @@ struct wmOperatorType;
|
|||||||
/* wm_files.c */
|
/* wm_files.c */
|
||||||
void wm_history_file_read(void);
|
void wm_history_file_read(void);
|
||||||
int wm_homefile_read(
|
int wm_homefile_read(
|
||||||
struct bContext *C, struct ReportList *reports, bool use_factory_settings,
|
struct bContext *C, struct ReportList *reports,
|
||||||
|
bool use_factory_settings, bool use_empty_data,
|
||||||
const char *filepath_startup_override, const char *app_template_override);
|
const char *filepath_startup_override, const char *app_template_override);
|
||||||
void wm_file_read_report(bContext *C);
|
void wm_file_read_report(bContext *C);
|
||||||
|
|
||||||
|
@@ -48,29 +48,17 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
||||||
def clear_scene():
|
def batch_import(
|
||||||
import bpy
|
operator="",
|
||||||
unique_obs = set()
|
path="",
|
||||||
for scene in bpy.data.scenes:
|
save_path="",
|
||||||
for obj in scene.objects[:]:
|
match="",
|
||||||
scene.objects.unlink(obj)
|
start=0,
|
||||||
unique_obs.add(obj)
|
end=sys.maxsize,
|
||||||
|
):
|
||||||
# remove obdata, for now only worry about the startup scene
|
|
||||||
for bpy_data_iter in (bpy.data.objects, bpy.data.meshes, bpy.data.lamps, bpy.data.cameras):
|
|
||||||
for id_data in bpy_data_iter:
|
|
||||||
bpy_data_iter.remove(id_data)
|
|
||||||
|
|
||||||
|
|
||||||
def batch_import(operator="",
|
|
||||||
path="",
|
|
||||||
save_path="",
|
|
||||||
match="",
|
|
||||||
start=0,
|
|
||||||
end=sys.maxsize,
|
|
||||||
):
|
|
||||||
import addon_utils
|
import addon_utils
|
||||||
_reset_all = addon_utils.reset_all # XXX, hack
|
_reset_all = addon_utils.reset_all # XXX, hack
|
||||||
|
_disable_all = addon_utils.disable_all # XXX, hack
|
||||||
|
|
||||||
import fnmatch
|
import fnmatch
|
||||||
|
|
||||||
@@ -116,11 +104,12 @@ def batch_import(operator="",
|
|||||||
|
|
||||||
# hack so loading the new file doesn't undo our loaded addons
|
# hack so loading the new file doesn't undo our loaded addons
|
||||||
addon_utils.reset_all = lambda: None # XXX, hack
|
addon_utils.reset_all = lambda: None # XXX, hack
|
||||||
|
addon_utils.disable_all = lambda: None # XXX, hack
|
||||||
|
|
||||||
bpy.ops.wm.read_factory_settings()
|
bpy.ops.wm.read_factory_settings(use_empty=True)
|
||||||
|
|
||||||
addon_utils.reset_all = _reset_all # XXX, hack
|
addon_utils.reset_all = _reset_all # XXX, hack
|
||||||
clear_scene()
|
addon_utils.disable_all = _disable_all # XXX, hack
|
||||||
|
|
||||||
result = op(filepath=f)
|
result = op(filepath=f)
|
||||||
|
|
||||||
|
@@ -31,7 +31,6 @@
|
|||||||
import math
|
import math
|
||||||
|
|
||||||
USE_QUICK_RENDER = False
|
USE_QUICK_RENDER = False
|
||||||
IS_BMESH = hasattr(__import__("bpy").types, "LoopColors")
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
# utility functions
|
# utility functions
|
||||||
@@ -203,13 +202,8 @@ def defaults_object(obj):
|
|||||||
|
|
||||||
mesh.show_normal_vertex = True
|
mesh.show_normal_vertex = True
|
||||||
|
|
||||||
# lame!
|
for poly in mesh.polygons:
|
||||||
if IS_BMESH:
|
poly.use_smooth = True
|
||||||
for poly in mesh.polygons:
|
|
||||||
poly.use_smooth = True
|
|
||||||
else:
|
|
||||||
for face in mesh.faces:
|
|
||||||
face.use_smooth = True
|
|
||||||
|
|
||||||
|
|
||||||
def defaults_modifier(mod):
|
def defaults_modifier(mod):
|
||||||
@@ -220,16 +214,14 @@ def defaults_modifier(mod):
|
|||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
# models (utils)
|
# models (utils)
|
||||||
|
|
||||||
|
def mesh_bmesh_poly_elems(poly, elems):
|
||||||
|
vert_start = poly.loop_start
|
||||||
|
vert_total = poly.loop_total
|
||||||
|
return elems[vert_start:vert_start + vert_total]
|
||||||
|
|
||||||
if IS_BMESH:
|
def mesh_bmesh_poly_vertices(poly):
|
||||||
def mesh_bmesh_poly_elems(poly, elems):
|
return [loop.vertex_index
|
||||||
vert_start = poly.loop_start
|
for loop in mesh_bmesh_poly_elems(poly, poly.id_data.loops)]
|
||||||
vert_total = poly.loop_total
|
|
||||||
return elems[vert_start:vert_start + vert_total]
|
|
||||||
|
|
||||||
def mesh_bmesh_poly_vertices(poly):
|
|
||||||
return [loop.vertex_index
|
|
||||||
for loop in mesh_bmesh_poly_elems(poly, poly.id_data.loops)]
|
|
||||||
|
|
||||||
|
|
||||||
def mesh_bounds(mesh):
|
def mesh_bounds(mesh):
|
||||||
@@ -258,21 +250,14 @@ def mesh_uv_add(obj):
|
|||||||
|
|
||||||
uv_lay = obj.data.uv_textures.new()
|
uv_lay = obj.data.uv_textures.new()
|
||||||
|
|
||||||
if IS_BMESH:
|
# XXX, odd that we need to do this. until UV's and texface
|
||||||
# XXX, odd that we need to do this. until UV's and texface
|
# are separated we will need to keep it
|
||||||
# are separated we will need to keep it
|
uv_loops = obj.data.uv_layers[-1]
|
||||||
uv_loops = obj.data.uv_layers[-1]
|
uv_list = uv_loops.data[:]
|
||||||
uv_list = uv_loops.data[:]
|
for poly in obj.data.polygons:
|
||||||
for poly in obj.data.polygons:
|
poly_uvs = mesh_bmesh_poly_elems(poly, uv_list)
|
||||||
poly_uvs = mesh_bmesh_poly_elems(poly, uv_list)
|
for i, c in enumerate(poly_uvs):
|
||||||
for i, c in enumerate(poly_uvs):
|
c.uv = uvs[i % 4]
|
||||||
c.uv = uvs[i % 4]
|
|
||||||
else:
|
|
||||||
for uv in uv_lay.data:
|
|
||||||
uv.uv1 = uvs[0]
|
|
||||||
uv.uv2 = uvs[1]
|
|
||||||
uv.uv3 = uvs[2]
|
|
||||||
uv.uv4 = uvs[3]
|
|
||||||
|
|
||||||
return uv_lay
|
return uv_lay
|
||||||
|
|
||||||
@@ -296,21 +281,12 @@ def mesh_vcol_add(obj, mode=0):
|
|||||||
|
|
||||||
mesh = obj.data
|
mesh = obj.data
|
||||||
|
|
||||||
if IS_BMESH:
|
col_list = vcol_lay.data[:]
|
||||||
col_list = vcol_lay.data[:]
|
for poly in mesh.polygons:
|
||||||
for poly in mesh.polygons:
|
face_verts = mesh_bmesh_poly_vertices(poly)
|
||||||
face_verts = mesh_bmesh_poly_vertices(poly)
|
poly_cols = mesh_bmesh_poly_elems(poly, col_list)
|
||||||
poly_cols = mesh_bmesh_poly_elems(poly, col_list)
|
for i, c in enumerate(poly_cols):
|
||||||
for i, c in enumerate(poly_cols):
|
c.color = colors_get(face_verts[i])
|
||||||
c.color = colors_get(face_verts[i])
|
|
||||||
else:
|
|
||||||
for i, col in enumerate(vcol_lay.data):
|
|
||||||
face_verts = mesh.faces[i].vertices
|
|
||||||
col.color1 = colors_get(face_verts[0])
|
|
||||||
col.color2 = colors_get(face_verts[1])
|
|
||||||
col.color3 = colors_get(face_verts[2])
|
|
||||||
if len(face_verts) == 4:
|
|
||||||
col.color4 = colors_get(face_verts[3])
|
|
||||||
|
|
||||||
return vcol_lay
|
return vcol_lay
|
||||||
|
|
||||||
@@ -470,10 +446,7 @@ def modifier_build_add(scene, obj):
|
|||||||
defaults_modifier(mod)
|
defaults_modifier(mod)
|
||||||
|
|
||||||
# ensure we display some faces
|
# ensure we display some faces
|
||||||
if IS_BMESH:
|
totface = len(obj.data.polygons)
|
||||||
totface = len(obj.data.polygons)
|
|
||||||
else:
|
|
||||||
totface = len(obj.data.faces)
|
|
||||||
|
|
||||||
mod.frame_start = totface // 2
|
mod.frame_start = totface // 2
|
||||||
mod.frame_duration = totface
|
mod.frame_duration = totface
|
||||||
|
@@ -65,6 +65,7 @@ op_blacklist = (
|
|||||||
"wm.blenderplayer_start",
|
"wm.blenderplayer_start",
|
||||||
"wm.recover_auto_save",
|
"wm.recover_auto_save",
|
||||||
"wm.quit_blender",
|
"wm.quit_blender",
|
||||||
|
"wm.window_close",
|
||||||
"wm.url_open",
|
"wm.url_open",
|
||||||
"wm.doc_view",
|
"wm.doc_view",
|
||||||
"wm.doc_edit",
|
"wm.doc_edit",
|
||||||
@@ -308,16 +309,7 @@ def run_ops(operators, setup_func=None, reset=True):
|
|||||||
|
|
||||||
# contexts
|
# contexts
|
||||||
def ctx_clear_scene(): # copied from batch_import.py
|
def ctx_clear_scene(): # copied from batch_import.py
|
||||||
unique_obs = set()
|
bpy.ops.wm.read_factory_settings(use_empty=True)
|
||||||
for scene in bpy.data.scenes:
|
|
||||||
for obj in scene.objects[:]:
|
|
||||||
scene.objects.unlink(obj)
|
|
||||||
unique_obs.add(obj)
|
|
||||||
|
|
||||||
# remove obdata, for now only worry about the startup scene
|
|
||||||
for bpy_data_iter in (bpy.data.objects, bpy.data.meshes, bpy.data.lamps, bpy.data.cameras):
|
|
||||||
for id_data in bpy_data_iter:
|
|
||||||
bpy_data_iter.remove(id_data)
|
|
||||||
|
|
||||||
|
|
||||||
def ctx_editmode_mesh():
|
def ctx_editmode_mesh():
|
||||||
|
Reference in New Issue
Block a user