Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/creator/creator.c')
-rw-r--r--source/creator/creator.c149
1 files changed, 52 insertions, 97 deletions
diff --git a/source/creator/creator.c b/source/creator/creator.c
index e1c777f8136..40525bb3add 100644
--- a/source/creator/creator.c
+++ b/source/creator/creator.c
@@ -403,6 +403,27 @@ static int print_help(int UNUSED(argc), const char **UNUSED(argv), void *data)
return 0;
}
+static int parse_relative_int(const char *str, int pos, int neg, int min, int max)
+{
+ int ret;
+
+ switch (*str) {
+ case '+':
+ ret = pos + atoi(str + 1);
+ break;
+ case '-':
+ ret = (neg - atoi(str + 1)) + 1;
+ break;
+ default:
+ ret = atoi(str);
+ break;
+ }
+
+ CLAMP(ret, min, max);
+
+ return ret;
+}
+
static int end_arguments(int UNUSED(argc), const char **UNUSED(argv), void *UNUSED(data))
{
return -1;
@@ -1067,23 +1088,11 @@ static int render_frame(int argc, const char **argv, void *data)
int frame;
ReportList reports;
- switch (*argv[1]) {
- case '+':
- frame = scene->r.sfra + atoi(argv[1] + 1);
- break;
- case '-':
- frame = (scene->r.efra - atoi(argv[1] + 1)) + 1;
- break;
- default:
- frame = atoi(argv[1]);
- break;
- }
+ frame = parse_relative_int(argv[1], scene->r.sfra, scene->r.efra, MINAFRAME, MAXFRAME);
BLI_begin_threaded_malloc();
BKE_reports_init(&reports, RPT_PRINT);
- frame = CLAMPIS(frame, MINAFRAME, MAXFRAME);
-
RE_SetReports(re, &reports);
RE_BlenderAnim(re, bmain, scene, NULL, scene->lay, frame, frame, scene->r.frame_step);
RE_SetReports(re, NULL);
@@ -1144,8 +1153,8 @@ static int set_start_frame(int argc, const char **argv, void *data)
Scene *scene = CTX_data_scene(C);
if (scene) {
if (argc > 1) {
- int frame = atoi(argv[1]);
- (scene->r.sfra) = CLAMPIS(frame, MINFRAME, MAXFRAME);
+ scene->r.sfra = parse_relative_int(argv[1], scene->r.sfra, scene->r.sfra - 1, MINAFRAME, MAXFRAME);
+
return 1;
}
else {
@@ -1165,8 +1174,7 @@ static int set_end_frame(int argc, const char **argv, void *data)
Scene *scene = CTX_data_scene(C);
if (scene) {
if (argc > 1) {
- int frame = atoi(argv[1]);
- (scene->r.efra) = CLAMPIS(frame, MINFRAME, MAXFRAME);
+ scene->r.efra = parse_relative_int(argv[1], scene->r.efra, scene->r.efra - 1, MINAFRAME, MAXFRAME);
return 1;
}
else {
@@ -1238,7 +1246,7 @@ static int run_python_file(int argc, const char **argv, void *data)
/* Make the path absolute because its needed for relative linked blends to be found */
char filename[FILE_MAX];
BLI_strncpy(filename, argv[1], sizeof(filename));
- BLI_path_cwd(filename);
+ BLI_path_cwd(filename, sizeof(filename));
BPY_CTX_SETUP(BPY_filepath_exec(C, filename, NULL));
@@ -1353,6 +1361,8 @@ static int set_addons(int argc, const char **argv, void *data)
static int load_file(int UNUSED(argc), const char **argv, void *data)
{
bContext *C = data;
+ ReportList reports;
+ bool success;
/* Make the path absolute because its needed for relative linked blends to be found */
char filename[FILE_MAX];
@@ -1363,80 +1373,25 @@ static int load_file(int UNUSED(argc), const char **argv, void *data)
}
BLI_strncpy(filename, argv[0], sizeof(filename));
- BLI_path_cwd(filename);
-
- if (G.background) {
- int retval;
-
- BLI_callback_exec(CTX_data_main(C), NULL, BLI_CB_EVT_LOAD_PRE);
-
- retval = BKE_read_file(C, filename, NULL);
-
- /* we successfully loaded a blend file, get sure that
- * pointcache works */
- if (retval != BKE_READ_FILE_FAIL) {
- wmWindowManager *wm = CTX_wm_manager(C);
- Main *bmain = CTX_data_main(C);
-
- /* special case, 2.4x files */
- if (wm == NULL && BLI_listbase_is_empty(&bmain->wm)) {
- extern void wm_add_default(bContext *C);
-
- /* wm_add_default() needs the screen to be set. */
- CTX_wm_screen_set(C, bmain->screen.first);
- wm_add_default(C);
- }
-
- CTX_wm_manager_set(C, NULL); /* remove wm to force check */
- WM_check(C);
- if (bmain->name[0]) {
- G.save_over = 1;
- G.relbase_valid = 1;
- }
- else {
- G.save_over = 0;
- G.relbase_valid = 0;
- }
- if (CTX_wm_manager(C) == NULL) CTX_wm_manager_set(C, wm); /* reset wm */
-
- /* WM_file_read would call normally */
- ED_editors_init(C);
- DAG_on_visible_update(bmain, true);
- BKE_scene_update_tagged(bmain->eval_ctx, bmain, CTX_data_scene(C));
- }
- else {
- /* failed to load file, stop processing arguments */
- if (G.background) {
- /* Set is_break if running in the background mode so
- * blender will return non-zero exit code which then
- * could be used in automated script to control how
- * good or bad things are.
- */
- G.is_break = true;
- }
- return -1;
+ BLI_path_cwd(filename, sizeof(filename));
+
+ /* load the file */
+ BKE_reports_init(&reports, RPT_PRINT);
+ WM_file_autoexec_init(filename);
+ success = WM_file_read(C, filename, &reports);
+ BKE_reports_clear(&reports);
+
+ if (success == false) {
+ /* failed to load file, stop processing arguments */
+ if (G.background) {
+ /* Set is_break if running in the background mode so
+ * blender will return non-zero exit code which then
+ * could be used in automated script to control how
+ * good or bad things are.
+ */
+ G.is_break = true;
}
-
- /* WM_file_read() runs normally but since we're in background mode do here */
-#ifdef WITH_PYTHON
- /* run any texts that were loaded in and flagged as modules */
- BPY_python_reset(C);
-#endif
-
- BLI_callback_exec(CTX_data_main(C), NULL, BLI_CB_EVT_LOAD_POST);
-
- /* happens for the UI on file reading too (huh? (ton))*/
- // XXX BKE_undo_reset();
- // BKE_undo_write("original"); /* save current state */
- }
- else {
- /* we are not running in background mode here, but start blender in UI mode with
- * a file - this should do everything a 'load file' does */
- ReportList reports;
- BKE_reports_init(&reports, RPT_PRINT);
- WM_file_autoexec_init(filename);
- WM_file_read(C, filename, &reports);
- BKE_reports_clear(&reports);
+ return -1;
}
G.file_loaded = 1;
@@ -1483,7 +1438,7 @@ static void setupArguments(bContext *C, bArgs *ba, SYS_SystemHandle *syshandle)
"\n\t-g linearmipmap\t\tLinear Texture Mipmapping instead of Nearest (default)";
static char debug_doc[] = "\n\tTurn debugging on\n"
- "\n\t* Prints every operator call and their arguments"
+ "\n\t* Enables memory error detection"
"\n\t* Disables mouse grab (to interact with a debugger in some cases)"
"\n\t* Keeps Python's 'sys.stdin' rather than setting it to None";
@@ -1534,7 +1489,7 @@ static void setupArguments(bContext *C, bArgs *ba, SYS_SystemHandle *syshandle)
BLI_argsAdd(ba, 1, NULL, "--debug-python", "\n\tEnable debug messages for Python", debug_mode_generic, (void *)G_DEBUG_PYTHON);
BLI_argsAdd(ba, 1, NULL, "--debug-events", "\n\tEnable debug messages for the event system", debug_mode_generic, (void *)G_DEBUG_EVENTS);
BLI_argsAdd(ba, 1, NULL, "--debug-handlers", "\n\tEnable debug messages for event handling", debug_mode_generic, (void *)G_DEBUG_HANDLERS);
- BLI_argsAdd(ba, 1, NULL, "--debug-wm", "\n\tEnable debug messages for the window manager", debug_mode_generic, (void *)G_DEBUG_WM);
+ BLI_argsAdd(ba, 1, NULL, "--debug-wm", "\n\tEnable debug messages for the window manager, also prints every operator call", debug_mode_generic, (void *)G_DEBUG_WM);
BLI_argsAdd(ba, 1, NULL, "--debug-all", "\n\tEnable all debug messages (excludes libmv)", debug_mode_generic, (void *)G_DEBUG_ALL);
BLI_argsAdd(ba, 1, NULL, "--debug-fpe", "\n\tEnable floating point exceptions", set_fpe, NULL);
@@ -1551,7 +1506,7 @@ static void setupArguments(bContext *C, bArgs *ba, SYS_SystemHandle *syshandle)
BLI_argsAdd(ba, 1, NULL, "--debug-jobs", "\n\tEnable time profiling for background jobs.", debug_mode_generic, (void *)G_DEBUG_JOBS);
BLI_argsAdd(ba, 1, NULL, "--debug-gpu", "\n\tEnable gpu debug context and information for OpenGL 4.3+.", debug_mode_generic, (void *)G_DEBUG_GPU);
BLI_argsAdd(ba, 1, NULL, "--debug-depsgraph", "\n\tEnable debug messages from dependency graph", debug_mode_generic, (void *)G_DEBUG_DEPSGRAPH);
- BLI_argsAdd(ba, 1, NULL, "--debug-depsgraph-no-threads", "\n\tSwitch dependency graph to a single threaded evlauation", debug_mode_generic, (void *)G_DEBUG_DEPSGRAPH_NO_THREADS);
+ BLI_argsAdd(ba, 1, NULL, "--debug-depsgraph-no-threads", "\n\tSwitch dependency graph to a single threaded evaluation", debug_mode_generic, (void *)G_DEBUG_DEPSGRAPH_NO_THREADS);
BLI_argsAdd(ba, 1, NULL, "--debug-gpumem", "\n\tEnable GPU memory stats in status bar", debug_mode_generic, (void *)G_DEBUG_GPU_MEM);
BLI_argsAdd(ba, 1, NULL, "--enable-new-depsgraph", "\n\tUse new dependency graph", depsgraph_use_new, NULL);
@@ -1585,8 +1540,8 @@ static void setupArguments(bContext *C, bArgs *ba, SYS_SystemHandle *syshandle)
BLI_argsAdd(ba, 4, "-f", "--render-frame", "<frame>\n\tRender frame <frame> and save it.\n\t+<frame> start frame relative, -<frame> end frame relative.", render_frame, C);
BLI_argsAdd(ba, 4, "-a", "--render-anim", "\n\tRender frames from start to end (inclusive)", render_animation, C);
BLI_argsAdd(ba, 4, "-S", "--scene", "<name>\n\tSet the active scene <name> for rendering", set_scene, C);
- BLI_argsAdd(ba, 4, "-s", "--frame-start", "<frame>\n\tSet start to frame <frame> (use before the -a argument)", set_start_frame, C);
- BLI_argsAdd(ba, 4, "-e", "--frame-end", "<frame>\n\tSet end to frame <frame> (use before the -a argument)", set_end_frame, C);
+ BLI_argsAdd(ba, 4, "-s", "--frame-start", "<frame>\n\tSet start to frame <frame>, supports +/- for relative frames too.", set_start_frame, C);
+ BLI_argsAdd(ba, 4, "-e", "--frame-end", "<frame>\n\tSet end to frame <frame>, supports +/- for relative frames too.", set_end_frame, C);
BLI_argsAdd(ba, 4, "-j", "--frame-jump", "<frames>\n\tSet number of frames to step forward after each rendered frame", set_skip_frame, C);
BLI_argsAdd(ba, 4, "-P", "--python", "<filename>\n\tRun the given Python script file", run_python_file, C);
BLI_argsAdd(ba, 4, NULL, "--python-text", "<name>\n\tRun the given Python script text block", run_python_text, C);
@@ -1675,7 +1630,7 @@ int main(
int i;
for (i = 0; i < argc; i++) {
if (STREQ(argv[i], "--debug") || STREQ(argv[i], "-d") ||
- STREQ(argv[i], "--debug-memory"))
+ STREQ(argv[i], "--debug-memory") || STREQ(argv[i], "--debug-all"))
{
printf("Switching to fully guarded memory allocator.\n");
MEM_use_guarded_allocator();