2004-01-04 22:10:36 +00:00
|
|
|
/*
|
2002-10-12 11:37:38 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
2008-04-16 22:40:48 +00:00
|
|
|
* of the License, or (at your option) any later version.
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
|
|
|
* All rights reserved.
|
|
|
|
*/
|
2010-02-08 13:55:31 +00:00
|
|
|
|
2019-02-17 21:08:12 +00:00
|
|
|
/** \file
|
|
|
|
* \ingroup creator
|
2011-02-25 10:01:33 +00:00
|
|
|
*/
|
|
|
|
|
2016-02-27 18:10:00 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2011-02-25 10:01:33 +00:00
|
|
|
|
2016-02-27 18:10:00 +00:00
|
|
|
#ifdef WIN32
|
|
|
|
# if defined(_MSC_VER) && defined(_M_X64)
|
|
|
|
# include <math.h> /* needed for _set_FMA3_enable */
|
|
|
|
# endif
|
|
|
|
# include <windows.h>
|
|
|
|
# include "utfconv.h"
|
2010-10-31 00:56:46 +00:00
|
|
|
#endif
|
2010-02-01 01:43:31 +00:00
|
|
|
|
2016-02-27 18:10:00 +00:00
|
|
|
#include "MEM_guardedalloc.h"
|
2010-02-01 01:43:31 +00:00
|
|
|
|
2018-03-29 18:38:32 +00:00
|
|
|
#include "CLG_log.h"
|
|
|
|
|
2016-07-12 02:53:49 +00:00
|
|
|
#include "DNA_genfile.h"
|
|
|
|
|
2016-02-27 18:10:00 +00:00
|
|
|
#include "BLI_args.h"
|
|
|
|
#include "BLI_threads.h"
|
|
|
|
#include "BLI_utildefines.h"
|
|
|
|
#include "BLI_callbacks.h"
|
|
|
|
#include "BLI_string.h"
|
2018-03-29 18:38:32 +00:00
|
|
|
#include "BLI_system.h"
|
2010-02-01 01:43:31 +00:00
|
|
|
|
2016-02-27 18:10:00 +00:00
|
|
|
/* mostly init functions */
|
|
|
|
#include "BKE_appdir.h"
|
|
|
|
#include "BKE_blender.h"
|
|
|
|
#include "BKE_brush.h"
|
2016-08-26 12:25:03 +00:00
|
|
|
#include "BKE_cachefile.h"
|
2016-02-27 18:10:00 +00:00
|
|
|
#include "BKE_context.h"
|
|
|
|
#include "BKE_font.h"
|
|
|
|
#include "BKE_global.h"
|
|
|
|
#include "BKE_material.h"
|
|
|
|
#include "BKE_modifier.h"
|
2018-07-31 08:22:19 +00:00
|
|
|
#include "BKE_gpencil_modifier.h"
|
2016-02-27 18:10:00 +00:00
|
|
|
#include "BKE_node.h"
|
2018-07-31 08:22:19 +00:00
|
|
|
#include "BKE_shader_fx.h"
|
2016-02-27 18:10:00 +00:00
|
|
|
#include "BKE_sound.h"
|
|
|
|
#include "BKE_image.h"
|
2016-12-28 16:30:58 +00:00
|
|
|
#include "BKE_particle.h"
|
2010-02-01 01:43:31 +00:00
|
|
|
|
2017-04-06 13:40:08 +00:00
|
|
|
#include "DEG_depsgraph.h"
|
2010-02-01 01:43:31 +00:00
|
|
|
|
2016-02-27 18:10:00 +00:00
|
|
|
#include "IMB_imbuf.h" /* for IMB_init */
|
2016-01-14 22:57:54 +00:00
|
|
|
|
2016-02-27 18:10:00 +00:00
|
|
|
#include "RE_engine.h"
|
|
|
|
#include "RE_render_ext.h"
|
2016-01-14 22:57:54 +00:00
|
|
|
|
2016-02-27 18:10:00 +00:00
|
|
|
#include "ED_datafiles.h"
|
2016-01-14 22:57:54 +00:00
|
|
|
|
2016-02-27 18:10:00 +00:00
|
|
|
#include "WM_api.h"
|
2018-05-23 06:20:46 +00:00
|
|
|
#include "WM_toolsystem.h"
|
2016-01-14 22:57:54 +00:00
|
|
|
|
2016-02-27 18:10:00 +00:00
|
|
|
#include "RNA_define.h"
|
2016-01-14 22:57:54 +00:00
|
|
|
|
2016-02-27 18:10:00 +00:00
|
|
|
#ifdef WITH_FREESTYLE
|
|
|
|
# include "FRS_freestyle.h"
|
|
|
|
#endif
|
2016-01-14 22:57:54 +00:00
|
|
|
|
2016-02-27 18:10:00 +00:00
|
|
|
#include <signal.h>
|
2010-05-30 14:05:58 +00:00
|
|
|
|
2016-02-27 18:10:00 +00:00
|
|
|
#ifdef __FreeBSD__
|
|
|
|
# include <floatingpoint.h>
|
|
|
|
#endif
|
2016-01-14 22:57:54 +00:00
|
|
|
|
2016-02-27 18:10:00 +00:00
|
|
|
#ifdef WITH_BINRELOC
|
|
|
|
# include "binreloc.h"
|
|
|
|
#endif
|
2016-01-14 22:57:54 +00:00
|
|
|
|
2016-02-27 18:10:00 +00:00
|
|
|
#ifdef WITH_LIBMV
|
|
|
|
# include "libmv-capi.h"
|
|
|
|
#endif
|
2013-02-11 03:01:50 +00:00
|
|
|
|
2016-02-27 18:10:00 +00:00
|
|
|
#ifdef WITH_CYCLES_LOGGING
|
|
|
|
# include "CCL_api.h"
|
|
|
|
#endif
|
2013-02-11 03:01:50 +00:00
|
|
|
|
2016-02-27 18:10:00 +00:00
|
|
|
#ifdef WITH_SDL_DYNLOAD
|
|
|
|
# include "sdlew.h"
|
|
|
|
#endif
|
2013-02-11 03:01:50 +00:00
|
|
|
|
2016-02-27 18:10:00 +00:00
|
|
|
#include "creator_intern.h" /* own include */
|
2015-12-31 11:29:20 +00:00
|
|
|
|
|
|
|
|
2016-02-27 18:10:00 +00:00
|
|
|
/* Local Function prototypes */
|
|
|
|
#ifdef WITH_PYTHON_MODULE
|
|
|
|
int main_python_enter(int argc, const char **argv);
|
|
|
|
void main_python_exit(void);
|
|
|
|
#endif
|
2010-02-01 01:43:31 +00:00
|
|
|
|
2016-02-27 18:10:00 +00:00
|
|
|
/* written to by 'creator_args.c' */
|
|
|
|
struct ApplicationState app_state = {
|
|
|
|
.signal = {
|
|
|
|
.use_crash_handler = true,
|
|
|
|
.use_abort_handler = true,
|
|
|
|
},
|
|
|
|
.exit_code_on_error = {
|
|
|
|
.python = 0,
|
2019-01-06 13:06:58 +00:00
|
|
|
},
|
2016-02-27 18:10:00 +00:00
|
|
|
};
|
2010-05-30 14:05:58 +00:00
|
|
|
|
2016-02-27 18:10:00 +00:00
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/** \name Application Level Callbacks
|
|
|
|
*
|
|
|
|
* Initialize callbacks for the modules that need them.
|
|
|
|
*
|
|
|
|
* \{ */
|
2015-12-31 11:29:20 +00:00
|
|
|
|
2016-02-27 18:10:00 +00:00
|
|
|
static void callback_mem_error(const char *errorStr)
|
2011-01-26 16:30:12 +00:00
|
|
|
{
|
2016-02-27 18:10:00 +00:00
|
|
|
fputs(errorStr, stderr);
|
|
|
|
fflush(stderr);
|
2011-01-26 16:30:12 +00:00
|
|
|
}
|
|
|
|
|
2016-02-27 18:10:00 +00:00
|
|
|
static void main_callback_setup(void)
|
2010-02-01 01:43:31 +00:00
|
|
|
{
|
2016-02-27 18:10:00 +00:00
|
|
|
/* Error output from the alloc routines: */
|
|
|
|
MEM_set_error_callback(callback_mem_error);
|
2010-02-01 01:43:31 +00:00
|
|
|
}
|
|
|
|
|
2016-06-24 00:05:23 +00:00
|
|
|
/* free data on early exit (if Python calls 'sys.exit()' while parsing args for eg). */
|
|
|
|
struct CreatorAtExitData {
|
|
|
|
bArgs *ba;
|
|
|
|
#ifdef WIN32
|
|
|
|
const char **argv;
|
|
|
|
int argv_num;
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
static void callback_main_atexit(void *user_data)
|
|
|
|
{
|
|
|
|
struct CreatorAtExitData *app_init_data = user_data;
|
|
|
|
|
|
|
|
if (app_init_data->ba) {
|
|
|
|
BLI_argsFree(app_init_data->ba);
|
|
|
|
app_init_data->ba = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef WIN32
|
|
|
|
if (app_init_data->argv) {
|
|
|
|
while (app_init_data->argv_num) {
|
2016-07-20 21:38:15 +00:00
|
|
|
free((void *)app_init_data->argv[--app_init_data->argv_num]);
|
2016-06-24 00:05:23 +00:00
|
|
|
}
|
2016-07-20 21:38:15 +00:00
|
|
|
free((void *)app_init_data->argv);
|
2016-06-24 00:05:23 +00:00
|
|
|
app_init_data->argv = NULL;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2018-03-29 18:38:32 +00:00
|
|
|
static void callback_clg_fatal(void *fp)
|
|
|
|
{
|
|
|
|
BLI_system_backtrace(fp);
|
|
|
|
}
|
|
|
|
|
2016-02-27 18:10:00 +00:00
|
|
|
/** \} */
|
2013-01-03 23:27:20 +00:00
|
|
|
|
2012-03-31 00:59:17 +00:00
|
|
|
|
2016-02-27 18:10:00 +00:00
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/** \name Main Function
|
|
|
|
* \{ */
|
2010-02-01 01:43:31 +00:00
|
|
|
|
2011-02-20 23:39:29 +00:00
|
|
|
#ifdef WITH_PYTHON_MODULE
|
|
|
|
/* allow python module to call main */
|
2012-05-21 09:00:35 +00:00
|
|
|
# define main main_python_enter
|
2012-03-28 05:09:50 +00:00
|
|
|
static void *evil_C = NULL;
|
2012-01-16 14:13:41 +00:00
|
|
|
|
2012-05-21 09:00:35 +00:00
|
|
|
# ifdef __APPLE__
|
|
|
|
/* environ is not available in mac shared libraries */
|
|
|
|
# include <crt_externs.h>
|
2012-01-16 14:13:41 +00:00
|
|
|
char **environ = NULL;
|
2012-05-21 09:00:35 +00:00
|
|
|
# endif
|
2011-02-20 23:39:29 +00:00
|
|
|
#endif
|
|
|
|
|
2014-03-30 09:14:57 +00:00
|
|
|
/**
|
2016-01-24 03:25:01 +00:00
|
|
|
* Blender's main function responsibilities are:
|
2014-03-30 09:14:57 +00:00
|
|
|
* - setup subsystems.
|
|
|
|
* - handle arguments.
|
2016-01-24 03:25:01 +00:00
|
|
|
* - run #WM_main() event loop,
|
|
|
|
* or exit immediately when running in background mode.
|
2014-03-30 09:14:57 +00:00
|
|
|
*/
|
|
|
|
int main(
|
2015-03-27 16:32:56 +00:00
|
|
|
int argc,
|
2012-03-20 02:17:37 +00:00
|
|
|
#ifdef WIN32
|
2014-03-30 09:14:57 +00:00
|
|
|
const char **UNUSED(argv_c)
|
2012-03-20 02:17:37 +00:00
|
|
|
#else
|
2014-03-30 09:14:57 +00:00
|
|
|
const char **argv
|
2012-03-20 02:17:37 +00:00
|
|
|
#endif
|
2015-03-27 16:32:56 +00:00
|
|
|
)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2013-10-10 11:58:01 +00:00
|
|
|
bContext *C;
|
2012-06-15 21:19:05 +00:00
|
|
|
|
|
|
|
#ifndef WITH_PYTHON_MODULE
|
2010-02-01 01:43:31 +00:00
|
|
|
bArgs *ba;
|
2012-06-15 21:19:05 +00:00
|
|
|
#endif
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2015-03-27 16:32:56 +00:00
|
|
|
#ifdef WIN32
|
|
|
|
char **argv;
|
|
|
|
int argv_num;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* --- end declarations --- */
|
|
|
|
|
2017-12-04 06:19:34 +00:00
|
|
|
/* ensure we free data on early-exit */
|
|
|
|
struct CreatorAtExitData app_init_data = {NULL};
|
2016-06-24 00:05:23 +00:00
|
|
|
BKE_blender_atexit_register(callback_main_atexit, &app_init_data);
|
2015-03-27 16:32:56 +00:00
|
|
|
|
2018-07-03 07:08:00 +00:00
|
|
|
/* Unbuffered stdout makes stdout and stderr better synchronized, and helps
|
2018-06-28 13:32:14 +00:00
|
|
|
* when stepping through code in a debugger (prints are immediately
|
|
|
|
* visible). */
|
2018-06-28 15:07:10 +00:00
|
|
|
setvbuf(stdout, NULL, _IONBF, 0);
|
2018-06-28 13:32:14 +00:00
|
|
|
|
2014-09-05 09:09:54 +00:00
|
|
|
#ifdef WIN32
|
2016-03-31 11:45:33 +00:00
|
|
|
/* We delay loading of openmp so we can set the policy here. */
|
|
|
|
# if defined(_MSC_VER)
|
|
|
|
_putenv_s("OMP_WAIT_POLICY", "PASSIVE");
|
|
|
|
# endif
|
|
|
|
|
2019-01-15 12:25:45 +00:00
|
|
|
/* FMA3 support in the 2013 CRT is broken on Vista and Windows 7 RTM
|
|
|
|
* (fixed in SP1). Just disable it. */
|
2015-06-20 05:17:32 +00:00
|
|
|
# if defined(_MSC_VER) && defined(_M_X64)
|
2014-10-02 08:32:59 +00:00
|
|
|
_set_FMA3_enable(0);
|
2014-09-05 09:09:54 +00:00
|
|
|
# endif
|
|
|
|
|
|
|
|
/* Win32 Unicode Args */
|
2013-10-31 23:52:44 +00:00
|
|
|
/* NOTE: cannot use guardedalloc malloc here, as it's not yet initialized
|
2013-10-10 11:58:01 +00:00
|
|
|
* (it depends on the args passed in, which is what we're getting here!)
|
|
|
|
*/
|
2015-03-27 16:32:56 +00:00
|
|
|
{
|
|
|
|
wchar_t **argv_16 = CommandLineToArgvW(GetCommandLineW(), &argc);
|
|
|
|
argv = malloc(argc * sizeof(char *));
|
|
|
|
for (argv_num = 0; argv_num < argc; argv_num++) {
|
|
|
|
argv[argv_num] = alloc_utf_8_from_16(argv_16[argv_num], 0);
|
|
|
|
}
|
|
|
|
LocalFree(argv_16);
|
2016-06-24 00:05:23 +00:00
|
|
|
|
|
|
|
/* free on early-exit */
|
|
|
|
app_init_data.argv = argv;
|
|
|
|
app_init_data.argv_num = argv_num;
|
2012-03-20 02:17:37 +00:00
|
|
|
}
|
2015-03-27 16:32:56 +00:00
|
|
|
#endif /* WIN32 */
|
2012-03-20 02:17:37 +00:00
|
|
|
|
2013-10-10 11:58:01 +00:00
|
|
|
/* NOTE: Special exception for guarded allocator type switch:
|
|
|
|
* we need to perform switch from lock-free to fully
|
|
|
|
* guarded allocator before any allocation happened.
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < argc; i++) {
|
|
|
|
if (STREQ(argv[i], "--debug") || STREQ(argv[i], "-d") ||
|
2015-09-02 03:39:55 +00:00
|
|
|
STREQ(argv[i], "--debug-memory") || STREQ(argv[i], "--debug-all"))
|
2013-10-10 11:58:01 +00:00
|
|
|
{
|
|
|
|
printf("Switching to fully guarded memory allocator.\n");
|
|
|
|
MEM_use_guarded_allocator();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if (STREQ(argv[i], "--")) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-15 11:11:59 +00:00
|
|
|
#ifdef BUILD_DATE
|
|
|
|
{
|
|
|
|
time_t temp_time = build_commit_timestamp;
|
|
|
|
struct tm *tm = gmtime(&temp_time);
|
2013-11-17 15:39:26 +00:00
|
|
|
if (LIKELY(tm)) {
|
|
|
|
strftime(build_commit_date, sizeof(build_commit_date), "%Y-%m-%d", tm);
|
|
|
|
strftime(build_commit_time, sizeof(build_commit_time), "%H:%M", tm);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
const char *unknown = "date-unknown";
|
|
|
|
BLI_strncpy(build_commit_date, unknown, sizeof(build_commit_date));
|
|
|
|
BLI_strncpy(build_commit_time, unknown, sizeof(build_commit_time));
|
|
|
|
}
|
2013-11-15 11:11:59 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-11-17 11:35:36 +00:00
|
|
|
#ifdef WITH_SDL_DYNLOAD
|
|
|
|
sdlewInit();
|
|
|
|
#endif
|
|
|
|
|
2018-03-29 18:38:32 +00:00
|
|
|
/* Initialize logging */
|
|
|
|
CLG_init();
|
|
|
|
CLG_fatal_fn_set(callback_clg_fatal);
|
|
|
|
|
2013-10-10 11:58:01 +00:00
|
|
|
C = CTX_create();
|
|
|
|
|
2011-02-20 23:39:29 +00:00
|
|
|
#ifdef WITH_PYTHON_MODULE
|
2012-01-16 14:13:41 +00:00
|
|
|
#ifdef __APPLE__
|
|
|
|
environ = *_NSGetEnviron();
|
|
|
|
#endif
|
|
|
|
|
2011-02-20 23:39:29 +00:00
|
|
|
#undef main
|
2012-03-28 05:09:50 +00:00
|
|
|
evil_C = C;
|
2011-02-20 23:39:29 +00:00
|
|
|
#endif
|
|
|
|
|
2012-03-20 02:17:37 +00:00
|
|
|
|
|
|
|
|
2008-01-18 21:39:47 +00:00
|
|
|
#ifdef WITH_BINRELOC
|
2012-03-28 05:09:50 +00:00
|
|
|
br_init(NULL);
|
2008-01-18 15:10:17 +00:00
|
|
|
#endif
|
|
|
|
|
2011-11-07 12:55:18 +00:00
|
|
|
#ifdef WITH_LIBMV
|
|
|
|
libmv_initLogging(argv[0]);
|
2014-10-06 12:54:35 +00:00
|
|
|
#elif defined(WITH_CYCLES_LOGGING)
|
2014-09-08 12:01:24 +00:00
|
|
|
CCL_init_logging(argv[0]);
|
2011-11-07 12:55:18 +00:00
|
|
|
#endif
|
|
|
|
|
2016-02-27 18:10:00 +00:00
|
|
|
main_callback_setup();
|
2018-06-17 15:06:28 +00:00
|
|
|
|
2014-12-25 14:12:56 +00:00
|
|
|
#if defined(__APPLE__) && !defined(WITH_PYTHON_MODULE)
|
2015-03-27 16:32:56 +00:00
|
|
|
/* patch to ignore argument finder gives us (pid?) */
|
2015-01-26 15:03:11 +00:00
|
|
|
if (argc == 2 && STREQLEN(argv[1], "-psn_", 5)) {
|
2014-12-25 14:12:56 +00:00
|
|
|
extern int GHOST_HACK_getFirstFile(char buf[]);
|
|
|
|
static char firstfilebuf[512];
|
|
|
|
|
|
|
|
argc = 1;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2014-12-25 14:12:56 +00:00
|
|
|
if (GHOST_HACK_getFirstFile(firstfilebuf)) {
|
|
|
|
argc = 2;
|
|
|
|
argv[1] = firstfilebuf;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2018-06-17 15:06:28 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
#ifdef __FreeBSD__
|
|
|
|
fpsetmask(0);
|
|
|
|
#endif
|
|
|
|
|
2012-03-28 05:09:50 +00:00
|
|
|
/* initialize path to executable */
|
2014-11-23 14:54:29 +00:00
|
|
|
BKE_appdir_program_path_init(argv[0]);
|
2010-03-14 17:18:36 +00:00
|
|
|
|
2010-04-13 12:51:03 +00:00
|
|
|
BLI_threadapi_init();
|
2018-11-27 17:21:43 +00:00
|
|
|
BLI_thread_put_process_on_fast_node();
|
2010-04-13 12:51:03 +00:00
|
|
|
|
2016-07-12 02:53:49 +00:00
|
|
|
DNA_sdna_current_init();
|
|
|
|
|
2016-04-24 12:42:41 +00:00
|
|
|
BKE_blender_globals_init(); /* blender.c */
|
2002-10-12 11:37:38 +00:00
|
|
|
|
Merge image related changes from the render branch. This includes the image
tile cache code in imbuf, but it is not hooked up to the render engine.
Imbuf module: some small refactoring and removing a lot of unused or old code
(about 6.5k lines).
* Added a ImFileType struct with callbacks to make adding an file format type,
or making changes to the API easier.
* Move imbuf init/exit code into IMB_init()/IMB_exit() functions.
* Increased mipmap levels from 10 to 20, you run into this limit already with
a 2k image.
* Removed hamx, amiga, anim5 format support.
* Removed colormap saving, only simple colormap code now for reading tga.
* Removed gen_dynlibtiff.py, editing this is almost as much work as just
editing the code directly.
* Functions removed that were only used for sequencer plugin API:
IMB_anim_nextpic, IMB_clever_double, IMB_antialias, IMB_gamwarp,
IMB_scalefieldImBuf, IMB_scalefastfieldImBuf, IMB_onethird, IMB_halflace,
IMB_dit0, IMB_dit2, IMB_cspace
* Write metadata info into OpenEXR images. Can be viewed with the command
line utility 'exrheader'
For the image tile cache code, see this page:
http://wiki.blender.org/index.php/Dev:2.5/Source/Imaging/ImageTileCache
2010-05-07 15:18:04 +00:00
|
|
|
IMB_init();
|
2016-08-26 12:25:03 +00:00
|
|
|
BKE_cachefiles_init();
|
2012-11-15 15:59:58 +00:00
|
|
|
BKE_images_init();
|
2013-08-19 09:05:34 +00:00
|
|
|
BKE_modifier_init();
|
2018-07-31 08:22:19 +00:00
|
|
|
BKE_gpencil_modifier_init();
|
|
|
|
BKE_shaderfx_init();
|
2017-04-06 13:40:08 +00:00
|
|
|
DEG_register_node_types();
|
Merge image related changes from the render branch. This includes the image
tile cache code in imbuf, but it is not hooked up to the render engine.
Imbuf module: some small refactoring and removing a lot of unused or old code
(about 6.5k lines).
* Added a ImFileType struct with callbacks to make adding an file format type,
or making changes to the API easier.
* Move imbuf init/exit code into IMB_init()/IMB_exit() functions.
* Increased mipmap levels from 10 to 20, you run into this limit already with
a 2k image.
* Removed hamx, amiga, anim5 format support.
* Removed colormap saving, only simple colormap code now for reading tga.
* Removed gen_dynlibtiff.py, editing this is almost as much work as just
editing the code directly.
* Functions removed that were only used for sequencer plugin API:
IMB_anim_nextpic, IMB_clever_double, IMB_antialias, IMB_gamwarp,
IMB_scalefieldImBuf, IMB_scalefastfieldImBuf, IMB_onethird, IMB_halflace,
IMB_dit0, IMB_dit2, IMB_cspace
* Write metadata info into OpenEXR images. Can be viewed with the command
line utility 'exrheader'
For the image tile cache code, see this page:
http://wiki.blender.org/index.php/Dev:2.5/Source/Imaging/ImageTileCache
2010-05-07 15:18:04 +00:00
|
|
|
|
2013-03-24 12:13:13 +00:00
|
|
|
BKE_brush_system_init();
|
2016-01-26 20:32:48 +00:00
|
|
|
RE_texture_rng_init();
|
2018-06-17 15:06:28 +00:00
|
|
|
|
2013-03-24 12:13:13 +00:00
|
|
|
|
2012-05-05 00:23:55 +00:00
|
|
|
BLI_callback_global_init();
|
2011-06-24 16:54:30 +00:00
|
|
|
|
2003-04-30 13:22:26 +00:00
|
|
|
/* first test for background */
|
2012-06-15 21:19:05 +00:00
|
|
|
#ifndef WITH_PYTHON_MODULE
|
2012-04-14 11:58:52 +00:00
|
|
|
ba = BLI_argsInit(argc, (const char **)argv); /* skip binary path */
|
2016-06-24 00:05:23 +00:00
|
|
|
|
|
|
|
/* ensure we free on early exit */
|
|
|
|
app_init_data.ba = ba;
|
|
|
|
|
2018-04-16 12:07:42 +00:00
|
|
|
main_args_setup(C, ba);
|
2003-12-24 16:44:24 +00:00
|
|
|
|
2010-02-01 01:43:31 +00:00
|
|
|
BLI_argsParse(ba, 1, NULL, NULL);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2016-02-27 18:10:00 +00:00
|
|
|
main_signal_setup();
|
2015-03-03 12:39:15 +00:00
|
|
|
|
2013-02-06 13:07:45 +00:00
|
|
|
#else
|
2019-01-15 12:25:45 +00:00
|
|
|
/* using preferences or user startup makes no sense for py-as-module */
|
|
|
|
G.factory_startup = true;
|
2013-02-06 13:07:45 +00:00
|
|
|
#endif
|
2012-08-06 16:07:11 +00:00
|
|
|
|
2013-04-29 16:03:21 +00:00
|
|
|
#ifdef WITH_FFMPEG
|
|
|
|
IMB_ffmpeg_init();
|
|
|
|
#endif
|
|
|
|
|
2012-08-06 16:07:11 +00:00
|
|
|
/* after level 1 args, this is so playanim skips RNA init */
|
|
|
|
RNA_init();
|
|
|
|
|
|
|
|
RE_engines_init();
|
|
|
|
init_nodesystem();
|
2016-12-28 16:30:58 +00:00
|
|
|
psys_init_rng();
|
2012-08-06 16:07:11 +00:00
|
|
|
/* end second init */
|
|
|
|
|
|
|
|
|
2011-06-04 14:12:55 +00:00
|
|
|
#if defined(WITH_PYTHON_MODULE) || defined(WITH_HEADLESS)
|
2013-02-01 08:24:18 +00:00
|
|
|
G.background = true; /* python module mode ALWAYS runs in background mode (for now) */
|
2011-02-20 23:39:29 +00:00
|
|
|
#else
|
2013-02-01 08:24:18 +00:00
|
|
|
if (G.background) {
|
2016-02-27 18:10:00 +00:00
|
|
|
main_signal_setup_background();
|
2013-02-01 08:24:18 +00:00
|
|
|
}
|
2011-02-20 23:39:29 +00:00
|
|
|
#endif
|
2012-12-11 22:00:22 +00:00
|
|
|
|
2007-04-12 06:21:31 +00:00
|
|
|
/* background render uses this font too */
|
2012-08-11 15:24:31 +00:00
|
|
|
BKE_vfont_builtin_register(datatoc_bfont_pfb, datatoc_bfont_pfb_size);
|
2010-04-24 16:35:16 +00:00
|
|
|
|
2012-03-18 07:38:51 +00:00
|
|
|
/* Initialize ffmpeg if built in, also needed for bg mode if videos are
|
2012-03-09 18:28:30 +00:00
|
|
|
* rendered via ffmpeg */
|
2015-03-26 10:35:41 +00:00
|
|
|
BKE_sound_init_once();
|
2018-06-17 15:06:28 +00:00
|
|
|
|
Giant commit!
A full detailed description of this will be done later... is several days
of work. Here's a summary:
Render:
- Full cleanup of render code, removing *all* globals and bad level calls
all over blender. Render module is now not called abusive anymore
- API-fied calls to rendering
- Full recode of internal render pipeline. Is now rendering tiles by
default, prepared for much smarter 'bucket' render later.
- Each thread now can render a full part
- Renders were tested with 4 threads, goes fine, apart from some lookup
tables in softshadow and AO still
- Rendering is prepared to do multiple layers and passes
- No single 32 bits trick in render code anymore, all 100% floats now.
Writing images/movies
- moved writing images to blender kernel (bye bye 'schrijfplaatje'!)
- made a new Movie handle system, also in kernel. This will enable much
easier use of movies in Blender
PreviewRender:
- Using new render API, previewrender (in buttons) now uses regular render
code to generate images.
- new datafile 'preview.blend.c' has the preview scenes in it
- previews get rendered in exact displayed size (1 pixel = 1 pixel)
3D Preview render
- new; press Pkey in 3d window, for a panel that continuously renders
(pkey is for games, i know... but we dont do that in orange now!)
- this render works nearly identical to buttons-preview render, so it stops
rendering on any event (mouse, keyboard, etc)
- on moving/scaling the panel, the render code doesn't recreate all geometry
- same for shifting/panning view
- all other operations (now) regenerate the full render database still.
- this is WIP... but big fun, especially for simple scenes!
Compositor
- Using same node system as now in use for shaders, you can composit images
- works pretty straightforward... needs much more options/tools and integration
with rendering still
- is not threaded yet, nor is so smart to only recalculate changes... will be
done soon!
- the "Render Result" node will get all layers/passes as output sockets
- The "Output" node renders to a builtin image, which you can view in the Image
window. (yes, output nodes to render-result, and to files, is on the list!)
The Bad News
- "Unified Render" is removed. It might come back in some stage, but this
system should be built from scratch. I can't really understand this code...
I expect it is not much needed, especially with advanced layer/passes
control
- Panorama render, Field render, Motion blur, is not coded yet... (I had to
recode every single feature in render, so...!)
- Lens Flare is also not back... needs total revision, might become composit
effect though (using zbuffer for visibility)
- Part render is gone! (well, thats obvious, its default now).
- The render window is only restored with limited functionality... I am going
to check first the option to render to a Image window, so Blender can become
a true single-window application. :)
For example, the 'Spare render buffer' (jkey) doesnt work.
- Render with border, now default creates a smaller image
- No zbuffers are written yet... on the todo!
- Scons files and MSVC will need work to get compiling again
OK... thats what I can quickly recall. Now go compiling!
2006-01-23 22:05:47 +00:00
|
|
|
init_def_material();
|
2004-01-04 22:10:36 +00:00
|
|
|
|
2012-03-28 05:09:50 +00:00
|
|
|
if (G.background == 0) {
|
2012-06-15 21:19:05 +00:00
|
|
|
#ifndef WITH_PYTHON_MODULE
|
2010-02-01 01:43:31 +00:00
|
|
|
BLI_argsParse(ba, 2, NULL, NULL);
|
|
|
|
BLI_argsParse(ba, 3, NULL, NULL);
|
2012-06-15 21:19:05 +00:00
|
|
|
#endif
|
2012-04-14 11:58:52 +00:00
|
|
|
WM_init(C, argc, (const char **)argv);
|
2011-01-19 09:13:24 +00:00
|
|
|
|
2010-03-16 17:23:20 +00:00
|
|
|
/* this is properly initialized with user defs, but this is default */
|
2011-10-21 17:37:38 +00:00
|
|
|
/* call after loading the startup.blend so we can read U.tempdir */
|
2014-11-23 14:54:29 +00:00
|
|
|
BKE_tempdir_init(U.tempdir);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-06-15 21:19:05 +00:00
|
|
|
#ifndef WITH_PYTHON_MODULE
|
2010-02-01 01:43:31 +00:00
|
|
|
BLI_argsParse(ba, 3, NULL, NULL);
|
2012-06-15 21:19:05 +00:00
|
|
|
#endif
|
2009-11-11 04:08:09 +00:00
|
|
|
|
2012-04-14 11:58:52 +00:00
|
|
|
WM_init(C, argc, (const char **)argv);
|
2009-11-11 04:08:09 +00:00
|
|
|
|
2011-10-21 17:37:38 +00:00
|
|
|
/* don't use user preferences temp dir */
|
2014-11-23 14:54:29 +00:00
|
|
|
BKE_tempdir_init(NULL);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2010-10-31 04:11:39 +00:00
|
|
|
#ifdef WITH_PYTHON
|
New scripts:
- hotkeys, obdatacopier and renameobjectbyblock, all from Jean-Michel Soler (jms);
- bevel_center by Loic Berthe, suggested for inclusion by jms;
- doc_browser, by Daniel Dunbar (Zr)
Thanks to them for the new contributions!
(I included doc_browser at 'Misc' because only users interested in script writing would actually use it, but it could also be under 'Help'. Opinions?)
BPython related:
- Added scriptlink methods to object, lamp, camera and world.
- Object: added object.makeTrack and object.clearTrack (old track method).
- sys: made sys.exists(path) return 0 for not found; 1 for file, 2 for dir and -1 for neither.
- doc updates and fixes.
- made ONLOAD event work. G.f's SCENESCRIPT bit was being zeroed in set_app_data.
- Blender: updated functions Load and Save to support the builtin importers and exporters besides .blend (dxf, videoscape, vrml 1.0, stl, ...)
- Draw: added mouse wheel events.
- Scene: added scene.play to play back animations (like ALT+A and SHIFT+ALT+A). Makes a good counter, too, when the 'win' attribute is set to a space that doesn't "animate".
The scene.play() addition and the fix to ONLOAD scriptlinks is part of the work for a Blender demo mode. It already works, but I'll still add support for Radiosity calculations and fix a thing in main(): it executes onload scripts too early (BIF_Init), giving funny results in alt+a animations and renderings when firing up Blender. Loading after the program is up has no such problems. When I finish I'll post examples of demo mode scripts.
2004-07-03 05:17:04 +00:00
|
|
|
/**
|
2009-09-18 22:25:49 +00:00
|
|
|
* NOTE: the U.pythondir string is NULL until WM_init() is executed,
|
New scripts:
- hotkeys, obdatacopier and renameobjectbyblock, all from Jean-Michel Soler (jms);
- bevel_center by Loic Berthe, suggested for inclusion by jms;
- doc_browser, by Daniel Dunbar (Zr)
Thanks to them for the new contributions!
(I included doc_browser at 'Misc' because only users interested in script writing would actually use it, but it could also be under 'Help'. Opinions?)
BPython related:
- Added scriptlink methods to object, lamp, camera and world.
- Object: added object.makeTrack and object.clearTrack (old track method).
- sys: made sys.exists(path) return 0 for not found; 1 for file, 2 for dir and -1 for neither.
- doc updates and fixes.
- made ONLOAD event work. G.f's SCENESCRIPT bit was being zeroed in set_app_data.
- Blender: updated functions Load and Save to support the builtin importers and exporters besides .blend (dxf, videoscape, vrml 1.0, stl, ...)
- Draw: added mouse wheel events.
- Scene: added scene.play to play back animations (like ALT+A and SHIFT+ALT+A). Makes a good counter, too, when the 'win' attribute is set to a space that doesn't "animate".
The scene.play() addition and the fix to ONLOAD scriptlinks is part of the work for a Blender demo mode. It already works, but I'll still add support for Radiosity calculations and fix a thing in main(): it executes onload scripts too early (BIF_Init), giving funny results in alt+a animations and renderings when firing up Blender. Loading after the program is up has no such problems. When I finish I'll post examples of demo mode scripts.
2004-07-03 05:17:04 +00:00
|
|
|
* so we provide the BPY_ function below to append the user defined
|
2012-03-03 11:45:08 +00:00
|
|
|
* python-dir to Python's sys.path at this point. Simply putting
|
|
|
|
* WM_init() before #BPY_python_start() crashes Blender at startup.
|
New scripts:
- hotkeys, obdatacopier and renameobjectbyblock, all from Jean-Michel Soler (jms);
- bevel_center by Loic Berthe, suggested for inclusion by jms;
- doc_browser, by Daniel Dunbar (Zr)
Thanks to them for the new contributions!
(I included doc_browser at 'Misc' because only users interested in script writing would actually use it, but it could also be under 'Help'. Opinions?)
BPython related:
- Added scriptlink methods to object, lamp, camera and world.
- Object: added object.makeTrack and object.clearTrack (old track method).
- sys: made sys.exists(path) return 0 for not found; 1 for file, 2 for dir and -1 for neither.
- doc updates and fixes.
- made ONLOAD event work. G.f's SCENESCRIPT bit was being zeroed in set_app_data.
- Blender: updated functions Load and Save to support the builtin importers and exporters besides .blend (dxf, videoscape, vrml 1.0, stl, ...)
- Draw: added mouse wheel events.
- Scene: added scene.play to play back animations (like ALT+A and SHIFT+ALT+A). Makes a good counter, too, when the 'win' attribute is set to a space that doesn't "animate".
The scene.play() addition and the fix to ONLOAD scriptlinks is part of the work for a Blender demo mode. It already works, but I'll still add support for Radiosity calculations and fix a thing in main(): it executes onload scripts too early (BIF_Init), giving funny results in alt+a animations and renderings when firing up Blender. Loading after the program is up has no such problems. When I finish I'll post examples of demo mode scripts.
2004-07-03 05:17:04 +00:00
|
|
|
*/
|
2010-03-16 17:37:34 +00:00
|
|
|
|
2012-07-06 23:56:59 +00:00
|
|
|
/* TODO - U.pythondir */
|
2010-11-04 13:13:31 +00:00
|
|
|
#else
|
|
|
|
printf("\n* WARNING * - Blender compiled without Python!\nthis is not intended for typical usage\n\n");
|
2008-10-28 18:47:13 +00:00
|
|
|
#endif
|
2018-06-17 15:06:28 +00:00
|
|
|
|
2009-09-18 22:25:49 +00:00
|
|
|
CTX_py_init_set(C, 1);
|
2018-11-13 18:02:12 +00:00
|
|
|
WM_keyconfig_init(C);
|
2009-09-18 22:25:49 +00:00
|
|
|
|
2012-12-20 07:57:26 +00:00
|
|
|
#ifdef WITH_FREESTYLE
|
2009-11-10 00:03:31 +00:00
|
|
|
/* initialize Freestyle */
|
|
|
|
FRS_initialize();
|
|
|
|
FRS_set_context(C);
|
2012-12-20 07:57:26 +00:00
|
|
|
#endif
|
2009-11-10 00:03:31 +00:00
|
|
|
|
2003-09-09 21:26:34 +00:00
|
|
|
/* OK we are ready for it */
|
2012-06-15 21:19:05 +00:00
|
|
|
#ifndef WITH_PYTHON_MODULE
|
2016-02-27 18:10:00 +00:00
|
|
|
main_args_setup_post(C, ba);
|
2012-06-15 21:19:05 +00:00
|
|
|
#endif
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2016-06-24 00:05:23 +00:00
|
|
|
/* Explicitly free data allocated for argument parsing:
|
|
|
|
* - 'ba'
|
|
|
|
* - 'argv' on WIN32.
|
|
|
|
*/
|
|
|
|
callback_main_atexit(&app_init_data);
|
|
|
|
BKE_blender_atexit_unregister(callback_main_atexit, &app_init_data);
|
|
|
|
|
|
|
|
/* paranoid, avoid accidental re-use */
|
2012-06-15 21:19:05 +00:00
|
|
|
#ifndef WITH_PYTHON_MODULE
|
2016-06-24 00:05:23 +00:00
|
|
|
ba = NULL;
|
|
|
|
(void)ba;
|
2012-06-15 21:19:05 +00:00
|
|
|
#endif
|
2010-01-27 11:18:55 +00:00
|
|
|
|
2012-03-20 02:17:37 +00:00
|
|
|
#ifdef WIN32
|
|
|
|
argv = NULL;
|
2016-06-24 00:05:23 +00:00
|
|
|
(void)argv;
|
2012-03-20 02:17:37 +00:00
|
|
|
#endif
|
|
|
|
|
2011-02-20 23:39:29 +00:00
|
|
|
#ifdef WITH_PYTHON_MODULE
|
|
|
|
return 0; /* keep blender in background mode running */
|
|
|
|
#endif
|
|
|
|
|
2012-03-06 18:40:15 +00:00
|
|
|
if (G.background) {
|
2016-01-24 03:25:01 +00:00
|
|
|
/* Using window-manager API in background mode is a bit odd, but works fine. */
|
2009-09-18 22:25:49 +00:00
|
|
|
WM_exit(C);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2010-03-05 10:37:55 +00:00
|
|
|
else {
|
2013-06-10 00:42:16 +00:00
|
|
|
if (!G.file_loaded) {
|
2010-03-05 10:37:55 +00:00
|
|
|
WM_init_splash(C);
|
2012-03-07 04:53:43 +00:00
|
|
|
}
|
2010-03-05 10:37:55 +00:00
|
|
|
}
|
2009-09-18 22:25:49 +00:00
|
|
|
|
|
|
|
WM_main(C);
|
2009-11-23 13:58:55 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
return 0;
|
2018-09-02 08:28:27 +00:00
|
|
|
} /* end of int main(argc, argv) */
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2011-07-10 18:54:02 +00:00
|
|
|
#ifdef WITH_PYTHON_MODULE
|
|
|
|
void main_python_exit(void)
|
|
|
|
{
|
2014-02-12 19:53:42 +00:00
|
|
|
WM_exit_ext((bContext *)evil_C, true);
|
2012-03-28 05:09:50 +00:00
|
|
|
evil_C = NULL;
|
2011-07-10 18:54:02 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2016-02-27 18:10:00 +00:00
|
|
|
/** \} */
|