[Bf-blender-cvs] [43a1310508] HMD_viewport: Fixes Oculus CV1 Lens Correction

2017-03-23 Thread Joey Ferwerda
Commit: 43a1310508bb083aad8ad2b65def9e8d05ea6e57
Author: Joey Ferwerda
Date:   Fri Mar 24 05:57:03 2017 +0100
Branches: HMD_viewport
https://developer.blender.org/rB43a1310508bb083aad8ad2b65def9e8d05ea6e57

Fixes Oculus CV1 Lens Correction

===

M   extern/openhmd/src/drv_oculus_rift/rift.c
M   extern/openhmd/src/openhmd.c
M   extern/openhmd/src/openhmdi.h

===

diff --git a/extern/openhmd/src/drv_oculus_rift/rift.c 
b/extern/openhmd/src/drv_oculus_rift/rift.c
index caf367eb24..bc4bddac5d 100644
--- a/extern/openhmd/src/drv_oculus_rift/rift.c
+++ b/extern/openhmd/src/drv_oculus_rift/rift.c
@@ -320,23 +320,19 @@ static ohmd_device* open_device(ohmd_driver* driver, 
ohmd_device_desc* desc)
//setup generic distortion coeffs, from hand-calibration
switch (desc->revision) {
case REV_DK2:
-   priv->base.properties.universal_distortion_k[0] = 0.247;
-   priv->base.properties.universal_distortion_k[1] = 
-0.145;
-   priv->base.properties.universal_distortion_k[2] = 0.103;
-   priv->base.properties.universal_distortion_k[3] = 0.795;
-   priv->base.properties.universal_aberration_k[0] = 0.985;
-   priv->base.properties.universal_aberration_k[1] = 1.000;
-   priv->base.properties.universal_aberration_k[2] = 1.015;
+   
ohmd_set_universal_distortion_k(&(priv->base.properties), 0.247, -0.145, 0.103, 
0.795);
+   
ohmd_set_universal_aberration_k(&(priv->base.properties), 0.985, 1.000, 1.015);
break;
case REV_DK1:
-   priv->base.properties.universal_distortion_k[0] = 1.003;
-   priv->base.properties.universal_distortion_k[1] = 
-1.005;
-   priv->base.properties.universal_distortion_k[2] = 0.403;
-   priv->base.properties.universal_distortion_k[3] = 0.599;
-   priv->base.properties.universal_aberration_k[0] = 0.985;
-   priv->base.properties.universal_aberration_k[1] = 1.000;
-   priv->base.properties.universal_aberration_k[2] = 1.015;
+   
ohmd_set_universal_distortion_k(&(priv->base.properties), 1.003, -1.005, 0.403, 
0.599);
+   
ohmd_set_universal_aberration_k(&(priv->base.properties), 0.985, 1.000, 1.015);
break;
+   case REV_CV1:
+   
ohmd_set_universal_distortion_k(&(priv->base.properties), 0.098, .324, -0.241, 
0.819);
+   
ohmd_set_universal_aberration_k(&(priv->base.properties), 0.9952420, 1.0, 
1.0008074);
+   /* CV1 reports IPD, but not lens center, at least not 
anywhere I could find, so use the manually measured value of 0.054 */
+   priv->display_info.lens_separation = 0.054;
+   priv->base.properties.lens_sep = 
priv->display_info.lens_separation;
default:
break;
}
@@ -344,9 +340,6 @@ static ohmd_device* open_device(ohmd_driver* driver, 
ohmd_device_desc* desc)
// calculate projection eye projection matrices from the device 
properties
//ohmd_calc_default_proj_matrices(>base.properties);
float l,r,t,b,n,f;
-   mat4x4f l_proj; // left projection matrix
-   mat4x4f r_proj; // right projection matrix
-   mat4x4f translate;
// left eye screen bounds
l = -1.0f * (priv->display_info.h_screen_size/2 - 
priv->display_info.lens_separation/2);
r = priv->display_info.lens_separation/2;
@@ -355,18 +348,16 @@ static ohmd_device* open_device(ohmd_driver* driver, 
ohmd_device_desc* desc)
n = priv->display_info.eye_to_screen_distance[0];
f = n*10e6;
//LOGD("l: %0.3f, r: %0.3f, b: %0.3f, t: %0.3f, n: %0.3f, f: %0.3f", 
l,r,b,t,n,f);
-   omat4x4f_init_frustum(_proj, l, r, b, t, n, f);
-   omat4x4f_init_translate(, r, 0, 0); //shift over eye offset
-   omat4x4f_mult(, _proj, >base.properties.proj_left); 
//LEFT multiply inside OpenHMD
+   /* eye separation is handled by IPD in the Modelview matrix */
+   omat4x4f_init_frustum(>base.properties.proj_left, l, r, b, t, n, 
f);
//right eye screen bounds
l = -1.0f * priv->display_info.lens_separation/2;
r = priv->display_info.h_screen_size/2 - 
priv->display_info.lens_separation/2;
n = priv->display_info.eye_to_screen_distance[1];
f = n*10e6;
//LOGD("l: %0.3f, r: %0.3f, b: %0.3f, t: %0.3f, n: %0.3f, f: %0.3f", 
l,r,b,t,n,f);
-   omat4x4f_init_frustum(_proj, l, r, b, t, n, f);
-   omat4x4f_init_translate(, l, 0, 0); //shift over eye offset
-   omat4x4f_mult(, _proj, 

[Bf-blender-cvs] [634067f442] HMD_viewport: OpenHMD update, disables OVRService upon starting the device, only when run with administrator. Requires custom build of hidapi for now (github TheOnlyJoey/

2017-03-23 Thread Joey Ferwerda
Commit: 634067f44221916b1f4bcc156698bf6de4b7d578
Author: Joey Ferwerda
Date:   Fri Mar 24 02:07:07 2017 +0100
Branches: HMD_viewport
https://developer.blender.org/rB634067f44221916b1f4bcc156698bf6de4b7d578

OpenHMD update, disables OVRService upon starting the device, only when run 
with administrator.
Requires custom build of hidapi for now (github TheOnlyJoey/hidapi)

===

M   extern/openhmd/src/drv_oculus_rift/rift.c

===

diff --git a/extern/openhmd/src/drv_oculus_rift/rift.c 
b/extern/openhmd/src/drv_oculus_rift/rift.c
index 2011704105..caf367eb24 100644
--- a/extern/openhmd/src/drv_oculus_rift/rift.c
+++ b/extern/openhmd/src/drv_oculus_rift/rift.c
@@ -235,6 +235,8 @@ static ohmd_device* open_device(ohmd_driver* driver, 
ohmd_device_desc* desc)
 
priv->base.ctx = driver->ctx;
 
+   ohmd_toggle_ovr_service(0); //disable OVRService if running
+
// Open the HID device
priv->handle = hid_open_path(desc->path);
 
@@ -445,8 +447,6 @@ ohmd_driver* ohmd_create_oculus_rift_drv(ohmd_context* ctx)
if(drv == NULL)
return NULL;
 
-   ohmd_toggle_ovr_service(0); //disable OVRService if running
-
drv->get_device_list = get_device_list;
drv->open_device = open_device;
drv->destroy = destroy_driver;

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [69397fee48] app-templates: Use keymap from template prefs

2017-03-23 Thread Campbell Barton
Commit: 69397fee48c32fdd249ccf71684a30506ebbeb12
Author: Campbell Barton
Date:   Fri Mar 24 11:23:46 2017 +1100
Branches: app-templates
https://developer.blender.org/rB69397fee48c32fdd249ccf71684a30506ebbeb12

Use keymap from template prefs

===

M   source/blender/blenkernel/BKE_blender.h
M   source/blender/blenkernel/intern/blender.c
M   source/blender/windowmanager/intern/wm_files.c

===

diff --git a/source/blender/blenkernel/BKE_blender.h 
b/source/blender/blenkernel/BKE_blender.h
index d89f9b28c6..d55926ffb1 100644
--- a/source/blender/blenkernel/BKE_blender.h
+++ b/source/blender/blenkernel/BKE_blender.h
@@ -52,7 +52,7 @@ void BKE_blender_userdef_set_data(struct UserDef *userdef);
 void BKE_blender_userdef_free_data(struct UserDef *userdef);
 void BKE_blender_userdef_refresh(void);
 
-void BKE_blender_userdef_set_template(struct UserDef *userdef);
+void BKE_blender_userdef_set_app_template(struct UserDef *userdef);
 
 /* set this callback when a UI is running */
 void BKE_blender_callback_test_break_set(void (*func)(void));
diff --git a/source/blender/blenkernel/intern/blender.c 
b/source/blender/blenkernel/intern/blender.c
index ce3b623002..ceb641073e 100644
--- a/source/blender/blenkernel/intern/blender.c
+++ b/source/blender/blenkernel/intern/blender.c
@@ -242,7 +242,7 @@ void BKE_blender_userdef_refresh(void)
  * Write U from userdef.
  * This function defines which settings a template will override for the user 
preferences.
  */
-void BKE_blender_userdef_set_template(UserDef *userdef)
+void BKE_blender_userdef_set_app_template(UserDef *userdef)
 {
/* TODO:
 * - keymaps
@@ -259,11 +259,13 @@ void BKE_blender_userdef_set_template(UserDef *userdef)
 
/* for some types we need custom free functions */
userdef_free_addons();
+   userdef_free_keymaps();
 
LIST_OVERRIDE(uistyles);
LIST_OVERRIDE(uifonts);
LIST_OVERRIDE(themes);
LIST_OVERRIDE(addons);
+   LIST_OVERRIDE(user_keymaps);
 
MEMCPY_OVERRIDE(light);
 
diff --git a/source/blender/windowmanager/intern/wm_files.c 
b/source/blender/windowmanager/intern/wm_files.c
index 82ded46317..5a9543bc1d 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -790,7 +790,7 @@ int wm_homefile_read(
datatoc_startup_blend, 
datatoc_startup_blend_size, NULL);
}
if (userdef_template) {
-   BKE_blender_userdef_set_template(userdef_template);
+   BKE_blender_userdef_set_app_template(userdef_template);
BKE_blender_userdef_free_data(userdef_template);
MEM_freeN(userdef_template);
}

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [4e0b55d9bc] app-templates: Merge branch 'master' into app-templates

2017-03-23 Thread Campbell Barton
Commit: 4e0b55d9bc460f94eb04fe4e1c8b6b0255004fec
Author: Campbell Barton
Date:   Fri Mar 24 10:40:07 2017 +1100
Branches: app-templates
https://developer.blender.org/rB4e0b55d9bc460f94eb04fe4e1c8b6b0255004fec

Merge branch 'master' into app-templates

===



===



___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [ac0cbb7d1e] app-templates: Use BKE_appdir_folder_id_ex

2017-03-23 Thread Campbell Barton
Commit: ac0cbb7d1e438b6bf27a49c1e25fc9087e3edab1
Author: Campbell Barton
Date:   Fri Mar 24 10:49:32 2017 +1100
Branches: app-templates
https://developer.blender.org/rBac0cbb7d1e438b6bf27a49c1e25fc9087e3edab1

Use BKE_appdir_folder_id_ex

===

M   source/blender/blenkernel/BKE_appdir.h
M   source/blender/blenkernel/intern/appdir.c
M   source/blender/windowmanager/intern/wm_files.c
M   source/blender/windowmanager/intern/wm_operators.c

===

diff --git a/source/blender/blenkernel/BKE_appdir.h 
b/source/blender/blenkernel/BKE_appdir.h
index f7774a90f9..ac8f861fa5 100644
--- a/source/blender/blenkernel/BKE_appdir.h
+++ b/source/blender/blenkernel/BKE_appdir.h
@@ -34,7 +34,7 @@ const char *BKE_appdir_folder_id_user_notest(const int 
folder_id, const char *su
 const char *BKE_appdir_folder_id_version(const int folder_id, const int ver, 
const bool do_check);
 
 bool BKE_appdir_app_template_any(void);
-bool BKE_appdir_app_template_id_search(char *path, size_t path_len, const char 
*app_template);
+bool BKE_appdir_app_template_id_search(const char *app_template, char *path, 
size_t path_len);
 
 /* Initialize path to program executable */
 voidBKE_appdir_program_path_init(const char *argv0);
diff --git a/source/blender/blenkernel/intern/appdir.c 
b/source/blender/blenkernel/intern/appdir.c
index 0b6ea4f014..43fd47981b 100644
--- a/source/blender/blenkernel/intern/appdir.c
+++ b/source/blender/blenkernel/intern/appdir.c
@@ -698,26 +698,31 @@ static const int app_template_directory_id[2] = {
  */
 bool BKE_appdir_app_template_any(void)
 {
+   char temp_dir[FILE_MAX];
for (int i = 0; i < 2; i++) {
-   if (BKE_appdir_folder_id(app_template_directory_id[i], 
app_template_directory_search[i])) {
+   if (BKE_appdir_folder_id_ex(
+   app_template_directory_id[i], 
app_template_directory_search[i],
+   temp_dir, sizeof(temp_dir)))
+   {
return true;
}
}
return false;
 }
 
-bool BKE_appdir_app_template_id_search(char *path, size_t path_len, const char 
*app_template)
+bool BKE_appdir_app_template_id_search(const char *app_template, char *path, 
size_t path_len)
 {
for (int i = 0; i < 2; i++) {
char subdir[FILE_MAX];
BLI_join_dirfile(subdir, sizeof(subdir), 
app_template_directory_search[i], app_template);
-   const char *filepath_startup_template = 
BKE_appdir_folder_id(app_template_directory_id[i], subdir);
-   if (filepath_startup_template) {
-   BLI_strncpy(path, filepath_startup_template, path_len);
-   return path;
+   if (BKE_appdir_folder_id_ex(
+   app_template_directory_id[i], subdir,
+   path, path_len))
+   {
+   return true;
}
}
-   return NULL;
+   return false;
 }
 
 /**
diff --git a/source/blender/windowmanager/intern/wm_files.c 
b/source/blender/windowmanager/intern/wm_files.c
index 5c44e6f09b..82ded46317 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -726,7 +726,7 @@ int wm_homefile_read(
}
 
if (app_template != NULL) {
-   BKE_appdir_app_template_id_search(template_directory, 
sizeof(template_directory), app_template);
+   BKE_appdir_app_template_id_search(app_template, 
template_directory, sizeof(template_directory));
}
 
/* insert template name into startup file */
diff --git a/source/blender/windowmanager/intern/wm_operators.c 
b/source/blender/windowmanager/intern/wm_operators.c
index 981ef60fad..39e06ccc3c 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -1770,8 +1770,8 @@ static uiBlock *wm_block_create_splash(bContext *C, 
ARegion *ar, void *UNUSED(ar
char template_directory[FILE_MAX];
 
if (BKE_appdir_app_template_id_search(
-   template_directory, sizeof(template_directory),
-   U.app_template))
+   U.app_template,
+   template_directory, sizeof(template_directory)))
{
BLI_join_dirfile(
splash_filepath, sizeof(splash_filepath), 
template_directory,

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [6a6566a7fc] master: Cleanup: line-length

2017-03-23 Thread Campbell Barton
Commit: 6a6566a7fcbdba4f0711293cce73dbd93b75a7df
Author: Campbell Barton
Date:   Fri Mar 24 10:11:01 2017 +1100
Branches: master
https://developer.blender.org/rB6a6566a7fcbdba4f0711293cce73dbd93b75a7df

Cleanup: line-length

===

M   source/blender/blenkernel/intern/appdir.c

===

diff --git a/source/blender/blenkernel/intern/appdir.c 
b/source/blender/blenkernel/intern/appdir.c
index f2f0a92d8b..347ae2d5d8 100644
--- a/source/blender/blenkernel/intern/appdir.c
+++ b/source/blender/blenkernel/intern/appdir.c
@@ -201,7 +201,8 @@ static bool get_path_local(char *targetpath, const char 
*folder_name, const char
 
/* try EXECUTABLE_DIR/2.5x/folder_name - new default directory for 
local blender installed files */
 #ifdef __APPLE__
-   static char osx_resourses[FILE_MAX]; /* due new codesign situation in 
OSX > 10.9.5 we must move the blender_version dir with contents to Resources */
+   /* due new codesign situation in OSX > 10.9.5 we must move the 
blender_version dir with contents to Resources */
+   static char osx_resourses[FILE_MAX];
sprintf(osx_resourses, "%s../Resources", bprogdir);
return test_path(targetpath, osx_resourses, 
blender_version_decimal(ver), relfolder);
 #else
@@ -233,7 +234,9 @@ static bool is_portable_install(void)
  * \param ver  Blender version, used to construct a subdirectory name
  * \return true if it was able to construct such a path.
  */
-static bool get_path_user(char *targetpath, const char *folder_name, const 
char *subfolder_name, const char *envvar, const int ver)
+static bool get_path_user(
+char *targetpath, const char *folder_name, const char *subfolder_name,
+const char *envvar, const int ver)
 {
char user_path[FILE_MAX];
const char *user_base_path;
@@ -283,7 +286,9 @@ static bool get_path_user(char *targetpath, const char 
*folder_name, const char
  * \param ver  Blender version, used to construct a subdirectory name
  * \return  true if it was able to construct such a path.
  */
-static bool get_path_system(char *targetpath, const char *folder_name, const 
char *subfolder_name, const char *envvar, const int ver)
+static bool get_path_system(
+char *targetpath, const char *folder_name, const char *subfolder_name,
+const char *envvar, const int ver)
 {
char system_path[FILE_MAX];
const char *system_base_path;
@@ -713,7 +718,8 @@ static void where_is_temp(char *fullname, char *basename, 
const size_t maxlen, c
BLI_add_slash(fullname);
 #ifdef WIN32
if (userdir && userdir != fullname) {
-   BLI_strncpy(userdir, fullname, maxlen); /* also set 
user pref to show %TEMP%. /tmp/ is just plain confusing for Windows users. */
+   /* also set user pref to show %TEMP%. /tmp/ is just 
plain confusing for Windows users. */
+   BLI_strncpy(userdir, fullname, maxlen);
}
 #endif
}

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [0453c807e0] master: Add: BKE_appdir_folder_id_ex

2017-03-23 Thread Campbell Barton
Commit: 0453c807e0b3e18c7df4b61affba8069bb8858ac
Author: Campbell Barton
Date:   Fri Mar 24 10:35:58 2017 +1100
Branches: master
https://developer.blender.org/rB0453c807e0b3e18c7df4b61affba8069bb8858ac

Add: BKE_appdir_folder_id_ex

Allows getting the path without using a static string.

===

M   source/blender/blenkernel/BKE_appdir.h
M   source/blender/blenkernel/intern/appdir.c

===

diff --git a/source/blender/blenkernel/BKE_appdir.h 
b/source/blender/blenkernel/BKE_appdir.h
index 077fe2a629..c6587b9466 100644
--- a/source/blender/blenkernel/BKE_appdir.h
+++ b/source/blender/blenkernel/BKE_appdir.h
@@ -27,6 +27,7 @@
 /* note on naming: typical _get() suffix is omitted here,
  * since its the main purpose of the API. */
 const char *BKE_appdir_folder_default(void);
+const char *BKE_appdir_folder_id_ex(const int folder_id, const char 
*subfolder, char *path, size_t path_len);
 const char *BKE_appdir_folder_id(const int folder_id, const char *subfolder);
 const char *BKE_appdir_folder_id_create(const int folder_id, const char 
*subfolder);
 const char *BKE_appdir_folder_id_user_notest(const int folder_id, const char 
*subfolder);
diff --git a/source/blender/blenkernel/intern/appdir.c 
b/source/blender/blenkernel/intern/appdir.c
index 347ae2d5d8..3fb8a14796 100644
--- a/source/blender/blenkernel/intern/appdir.c
+++ b/source/blender/blenkernel/intern/appdir.c
@@ -114,18 +114,26 @@ static char *blender_version_decimal(const int ver)
  * Concatenates path_base, (optional) path_sep and (optional) folder_name into 
targetpath,
  * returning true if result points to a directory.
  */
-static bool test_path(char *targetpath, const char *path_base, const char 
*path_sep, const char *folder_name)
+static bool test_path(
+char *targetpath, size_t targetpath_len,
+const char *path_base, const char *path_sep, const char *folder_name)
 {
char tmppath[FILE_MAX];

-   if (path_sep) BLI_join_dirfile(tmppath, sizeof(tmppath), path_base, 
path_sep);
-   else BLI_strncpy(tmppath, path_base, sizeof(tmppath));
+   if (path_sep) {
+   BLI_join_dirfile(tmppath, sizeof(tmppath), path_base, path_sep);
+   }
+   else {
+   BLI_strncpy(tmppath, path_base, sizeof(tmppath));
+   }
 
/* rare cases folder_name is omitted (when looking for 
~/.config/blender/2.xx dir only) */
-   if (folder_name)
-   BLI_make_file_string("/", targetpath, tmppath, folder_name);
-   else
-   BLI_strncpy(targetpath, tmppath, sizeof(tmppath));
+   if (folder_name) {
+   BLI_join_dirfile(targetpath, targetpath_len, tmppath, 
folder_name);
+   }
+   else {
+   BLI_strncpy(targetpath, tmppath, targetpath_len);
+   }
/* FIXME: why is "//" on front of tmppath expanded to "/" (by 
BLI_join_dirfile)
 * if folder_name is specified but not otherwise? */
 
@@ -179,7 +187,9 @@ static bool test_env_path(char *path, const char *envvar)
  * \param ver  To construct name of version-specific directory within bprogdir
  * \return true if such a directory exists.
  */
-static bool get_path_local(char *targetpath, const char *folder_name, const 
char *subfolder_name, const int ver)
+static bool get_path_local(
+char *targetpath, size_t targetpath_len,
+const char *folder_name, const char *subfolder_name, const int ver)
 {
char relfolder[FILE_MAX];

@@ -204,9 +214,9 @@ static bool get_path_local(char *targetpath, const char 
*folder_name, const char
/* due new codesign situation in OSX > 10.9.5 we must move the 
blender_version dir with contents to Resources */
static char osx_resourses[FILE_MAX];
sprintf(osx_resourses, "%s../Resources", bprogdir);
-   return test_path(targetpath, osx_resourses, 
blender_version_decimal(ver), relfolder);
+   return test_path(targetpath, targetpath_len, osx_resourses, 
blender_version_decimal(ver), relfolder);
 #else
-   return test_path(targetpath, bprogdir, blender_version_decimal(ver), 
relfolder);
+   return test_path(targetpath, targetpath_len, bprogdir, 
blender_version_decimal(ver), relfolder);
 #endif
 }
 
@@ -220,7 +230,7 @@ static bool is_portable_install(void)
const int ver = BLENDER_VERSION;
char path[FILE_MAX];
 
-   return get_path_local(path, "config", NULL, ver);
+   return get_path_local(path, sizeof(path), "config", NULL, ver);
 }
 
 /**
@@ -235,21 +245,21 @@ static bool is_portable_install(void)
  * \return true if it was able to construct such a path.
  */
 static bool get_path_user(
-char *targetpath, const char *folder_name, const char *subfolder_name,
+char *targetpath, size_t targetpath_len, const char *folder_name, 
const char *subfolder_name,
 const char *envvar, const int ver)
 {
char 

[Bf-blender-cvs] [62cf6f1eed] app-templates: Change path resolution order to match script resolution order

2017-03-23 Thread Campbell Barton
Commit: 62cf6f1eed51c297d1ceda17cae11672e905f048
Author: Campbell Barton
Date:   Fri Mar 24 10:08:24 2017 +1100
Branches: app-templates
https://developer.blender.org/rB62cf6f1eed51c297d1ceda17cae11672e905f048

Change path resolution order to match script resolution order

===

M   source/blender/blenkernel/intern/appdir.c

===

diff --git a/source/blender/blenkernel/intern/appdir.c 
b/source/blender/blenkernel/intern/appdir.c
index 8438d582fd..f6d6cb1cac 100644
--- a/source/blender/blenkernel/intern/appdir.c
+++ b/source/blender/blenkernel/intern/appdir.c
@@ -656,13 +656,13 @@ bool BKE_appdir_program_python_search(
 }
 
 static const char *app_template_directory_search[2] = {
-   "startup" SEP_STR "bl_app_templates_system",
"startup" SEP_STR "bl_app_templates_user",
+   "startup" SEP_STR "bl_app_templates_system",
 };
 
 static const int app_template_directory_id[2] = {
-   BLENDER_SYSTEM_SCRIPTS,
BLENDER_USER_SCRIPTS,
+   BLENDER_SYSTEM_SCRIPTS,
 };
 
 /**

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [60d36203e5] app-templates: Cleanup

2017-03-23 Thread Campbell Barton
Commit: 60d36203e55c6a5aac87b61925516496507a58d2
Author: Campbell Barton
Date:   Fri Mar 24 08:42:22 2017 +1100
Branches: app-templates
https://developer.blender.org/rB60d36203e55c6a5aac87b61925516496507a58d2

Cleanup

===

M   release/scripts/modules/bl_app_template_utils.py

===

diff --git a/release/scripts/modules/bl_app_template_utils.py 
b/release/scripts/modules/bl_app_template_utils.py
index 5f490f6156..0ff75a7c81 100644
--- a/release/scripts/modules/bl_app_template_utils.py
+++ b/release/scripts/modules/bl_app_template_utils.py
@@ -60,7 +60,7 @@ def _enable(template_id, *, handle_error=None, 
ignore_not_found=False):
 import traceback
 traceback.print_exc()
 
-# Split registering up into 3 steps so we can undo
+# Split registering up into 2 steps so we can undo
 # if it fails par way through.
 
 # disable the context, using the context at all is
@@ -78,10 +78,7 @@ def _enable(template_id, *, handle_error=None, 
ignore_not_found=False):
 handle_error(ex)
 return None
 
-# 2) try register collected modules
-# removed, templates need to handle own registration now.
-
-# 3) try run the modules register function
+# 2) try run the modules register function
 try:
 mod.register()
 except Exception as ex:

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [5f2f80d143] app-templates: Cleanup: cruft

2017-03-23 Thread Campbell Barton
Commit: 5f2f80d1437f96c4e52d3def1a7b0e7fca8f85eb
Author: Campbell Barton
Date:   Fri Mar 24 07:33:33 2017 +1100
Branches: app-templates
https://developer.blender.org/rB5f2f80d1437f96c4e52d3def1a7b0e7fca8f85eb

Cleanup: cruft

===

M   release/scripts/modules/bl_app_template_utils.py

===

diff --git a/release/scripts/modules/bl_app_template_utils.py 
b/release/scripts/modules/bl_app_template_utils.py
index 834280cb75..5f490f6156 100644
--- a/release/scripts/modules/bl_app_template_utils.py
+++ b/release/scripts/modules/bl_app_template_utils.py
@@ -25,17 +25,10 @@ In most cases users of this module will simply call 
'activate'.
 """
 
 __all__ = (
-# "paths",
-# "modules",
-# "check",
-# "enable",
-# "disable",
-
 "activate",
 "import_from_path",
 "import_from_id",
 "reset",
-# "module_bl_info",
 )
 
 import bpy as _bpy
@@ -113,7 +106,8 @@ def _disable(template_id, *, handle_error=None):
 
 :arg template_id: The name of the template and module.
 :type template_id: string
-:arg handle_error: Called in the case of an error, taking an exception 
argument.
+:arg handle_error: Called in the case of an error,
+   taking an exception argument.
 :type handle_error: function
 """
 import sys
@@ -125,9 +119,6 @@ def _disable(template_id, *, handle_error=None):
 
 mod = _modules.get(template_id)
 
-# possible this addon is from a previous session and didn't load a
-# module this time. So even if the module is not found, still disable
-# the addon in the user prefs.
 if mod and getattr(mod, "__template_enabled__", False) is not False:
 mod.__template_enabled__ = False
 
@@ -206,18 +197,6 @@ def reset(*, reload_scripts=False):
 if _bpy.app.debug_python:
 print("bl_app_template_utils.reset('%s')" % template_id)
 
-if reload_scripts and False:
-# TODO, seems correct but reload fails
-import importlib
-import os
-import sys
-_modules_new = {}
-for key, mod in _modules.items():
-# Will always be 'template' but just use convention of __name__ to 
be sure.
-module_name = mod.__name__
-_modules_new[key] = importlib.reload(mod)
-_modules.clear()
-_modules.update(_modules_new)
-del _modules_new
+# TODO reload_scripts
 
 activate(template_id)

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [5d6e9f237b] blender2.8: OpenGL: viewport background & depth buffer fixes

2017-03-23 Thread Mike Erwin
Commit: 5d6e9f237be3379b63169f86b8f4117752d095b3
Author: Mike Erwin
Date:   Thu Mar 23 16:27:57 2017 -0400
Branches: blender2.8
https://developer.blender.org/rB5d6e9f237be3379b63169f86b8f4117752d095b3

OpenGL: viewport background & depth buffer fixes

Untangling some of the logic in view3d_draw.

===

M   source/blender/editors/space_view3d/view3d_draw.c
M   source/blender/editors/space_view3d/view3d_draw_legacy.c

===

diff --git a/source/blender/editors/space_view3d/view3d_draw.c 
b/source/blender/editors/space_view3d/view3d_draw.c
index 33448a577a..808a5f3429 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -814,8 +814,6 @@ static void view3d_draw_background_gradient(void)
 {
/* TODO: finish 2D API & draw background with that */
 
-   glClear(GL_DEPTH_BUFFER_BIT);
-
VertexFormat *format = immVertexFormat();
unsigned pos = add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
unsigned color = add_attrib(format, "color", COMP_U8, 3, 
NORMALIZE_INT_TO_FLOAT);
@@ -826,7 +824,7 @@ static void view3d_draw_background_gradient(void)
UI_GetThemeColor3ubv(TH_LOW_GRAD, col_lo);
UI_GetThemeColor3ubv(TH_HIGH_GRAD, col_hi);
 
-   immBegin(GL_QUADS, 4);
+   immBegin(PRIM_TRIANGLE_FAN, 4);
immAttrib3ubv(color, col_lo);
immVertex2f(pos, -1.0f, -1.0f);
immVertex2f(pos, 1.0f, -1.0f);
@@ -841,13 +839,8 @@ static void view3d_draw_background_gradient(void)
 
 static void view3d_draw_background_none(void)
 {
-   if (UI_GetThemeValue(TH_SHOW_BACK_GRAD)) {
-   view3d_draw_background_gradient();
-   }
-   else {
-   UI_ThemeClearColorAlpha(TH_HIGH_GRAD, 1.0f);
-   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-   }
+   UI_ThemeClearColorAlpha(TH_HIGH_GRAD, 1.0f);
+   glClear(GL_COLOR_BUFFER_BIT);
 }
 
 static void view3d_draw_background_world(Scene *scene, View3D *v3d, 
RegionView3D *rv3d)
@@ -859,9 +852,6 @@ static void view3d_draw_background_world(Scene *scene, 
View3D *v3d, RegionView3D
GPU_material_bind(gpumat, 1, 1, 1.0f, false, rv3d->viewmat, 
rv3d->viewinv, rv3d->viewcamtexcofac, (v3d->scenelock != 0));
 
if (GPU_material_bound(gpumat)) {
-
-   glClear(GL_DEPTH_BUFFER_BIT);
-
/* TODO viewport (dfelinto): GPU_material_bind relies 
on immediate mode,
* we can't get rid of the following code without a 
bigger refactor
* or we dropping this functionality. */
@@ -874,14 +864,12 @@ static void view3d_draw_background_world(Scene *scene, 
View3D *v3d, RegionView3D
glEnd();
 
GPU_material_unbind(gpumat);
+   return;
}
-   else {
-   view3d_draw_background_none();
-   }
-   }
-   else {
-   view3d_draw_background_none();
}
+
+   /* if any of the above fails */
+   view3d_draw_background_none();
 }
 
 /*  solid plates * */
@@ -895,11 +883,8 @@ static void view3d_draw_background(const bContext *C)
View3D *v3d = CTX_wm_view3d(C);
RegionView3D *rv3d = CTX_wm_region_view3d(C);
 
-   glDisable(GL_DEPTH_TEST);
-   glDepthMask(GL_TRUE);
/* Background functions do not read or write depth, but they do clear 
or completely
-* overwrite color buffer. It's more efficient to clear color & depth 
in once call, so
-* background functions do this even though they don't use depth.
+* overwrite color buffer.
 */
 
switch (v3d->debug.background) {
@@ -912,7 +897,6 @@ static void view3d_draw_background(const bContext *C)
case V3D_DEBUG_BACKGROUND_NONE:
default:
view3d_draw_background_none();
-   break;
}
 }
 
@@ -2139,7 +2123,6 @@ static void view3d_draw_solid_plates(const bContext *C, 
ARegion *ar, DrawData *d
 {
/* realtime plates */
if ((!draw_data->is_render) || draw_data->clip_border) {
-   view3d_draw_background(C);
view3d_draw_render_solid_surfaces(C, ar, true);
view3d_draw_render_transparent_surfaces(C);
view3d_draw_post_draw(C);
@@ -2183,7 +2166,6 @@ static void view3d_draw_non_meshes(const bContext *C, 
ARegion *ar)
((v3d->drawtype == OB_RENDER) && 
(v3d->prev_drawtype == OB_BOUNDBOX)));
 
glEnable(GL_DEPTH_TEST);
-   glDepthMask(GL_TRUE);
/* TODO Viewport
 * we are already temporarily writing to zbuffer in draw_object()
 * for now let's avoid writing again to zbuffer to prevent 

[Bf-blender-cvs] [ef5589c32d] app-templates: Merge branch 'master' into app-templates

2017-03-23 Thread Campbell Barton
Commit: ef5589c32d3fec669d5e0a53ce724f066b7d9929
Author: Campbell Barton
Date:   Fri Mar 24 07:04:57 2017 +1100
Branches: app-templates
https://developer.blender.org/rBef5589c32d3fec669d5e0a53ce724f066b7d9929

Merge branch 'master' into app-templates

===



===



___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [a98cc75431] app-templates: Minor cleanup

2017-03-23 Thread Campbell Barton
Commit: a98cc75431f3d585eaa5f77a1a44cebc31826ae1
Author: Campbell Barton
Date:   Fri Mar 24 06:27:44 2017 +1100
Branches: app-templates
https://developer.blender.org/rBa98cc75431f3d585eaa5f77a1a44cebc31826ae1

Minor cleanup

===

M   source/blender/windowmanager/intern/wm_files.c

===

diff --git a/source/blender/windowmanager/intern/wm_files.c 
b/source/blender/windowmanager/intern/wm_files.c
index 9003625930..5c44e6f09b 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -470,6 +470,7 @@ static void wm_file_read_post(bContext *C, bool 
is_startup_file)
if (is_startup_file) {
/* possible python hasn't been initialized */
if (CTX_py_init_get(C)) {
+   /* Only run when we have a template path found. */
if (BKE_appdir_app_template_any()) {
BPY_execute_string(C, 
"__import__('bl_app_template_utils').reset()");
}
@@ -648,7 +649,7 @@ int wm_homefile_read(
ListBase wmbase;
char filepath_startup[FILE_MAX];
char filepath_userdef[FILE_MAX];
-   /* When 'app_template' is set: 
'{BLENDER_SYSTEM_SCRIPTS}/startup/bl_app_templates_system/{app_template}' */
+   /* When 'app_template' is set: 
'{scripts}/startup/bl_app_templates_system/{app_template}' */
char template_directory[FILE_MAX];
bool success = false;

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [096602d3a8] master: bpy.path.display_name: strip spaces

2017-03-23 Thread Campbell Barton
Commit: 096602d3a86b013771fcbc0268ef2c554a694636
Author: Campbell Barton
Date:   Fri Mar 24 06:48:24 2017 +1100
Branches: master
https://developer.blender.org/rB096602d3a86b013771fcbc0268ef2c554a694636

bpy.path.display_name: strip spaces

Useful for Python module paths that can't start with numbers.

===

M   release/scripts/modules/bpy/path.py

===

diff --git a/release/scripts/modules/bpy/path.py 
b/release/scripts/modules/bpy/path.py
index a864a86eba..e17d710068 100644
--- a/release/scripts/modules/bpy/path.py
+++ b/release/scripts/modules/bpy/path.py
@@ -204,7 +204,9 @@ def display_name(name):
 name = name.replace("_colon_", ":")
 name = name.replace("_plus_", "+")
 
-name = name.replace("_", " ")
+# strip to allow underscore prefix
+# (when paths can't start with numbers for eg).
+name = name.replace("_", " ").lstrip(" ")
 
 if name.islower():
 name = name.lower().title()

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [a4274a632a] app-templates: Fix BKE_appdir_app_template_id_search and splash loading

2017-03-23 Thread Campbell Barton
Commit: a4274a632a7b526281df55cd4e5904764cf331d6
Author: Campbell Barton
Date:   Fri Mar 24 05:48:40 2017 +1100
Branches: app-templates
https://developer.blender.org/rBa4274a632a7b526281df55cd4e5904764cf331d6

Fix BKE_appdir_app_template_id_search and splash loading

===

M   source/blender/blenkernel/intern/appdir.c
M   source/blender/windowmanager/intern/wm_operators.c

===

diff --git a/source/blender/blenkernel/intern/appdir.c 
b/source/blender/blenkernel/intern/appdir.c
index 4cacdbffc9..8438d582fd 100644
--- a/source/blender/blenkernel/intern/appdir.c
+++ b/source/blender/blenkernel/intern/appdir.c
@@ -681,8 +681,9 @@ bool BKE_appdir_app_template_any(void)
 bool BKE_appdir_app_template_id_search(char *path, size_t path_len, const char 
*app_template)
 {
for (int i = 0; i < 2; i++) {
-   BLI_join_dirfile(path, sizeof(path), 
app_template_directory_search[i], app_template);
-   const char *filepath_startup_template = 
BKE_appdir_folder_id(app_template_directory_id[i], path);
+   char subdir[FILE_MAX];
+   BLI_join_dirfile(subdir, sizeof(subdir), 
app_template_directory_search[i], app_template);
+   const char *filepath_startup_template = 
BKE_appdir_folder_id(app_template_directory_id[i], subdir);
if (filepath_startup_template) {
BLI_strncpy(path, filepath_startup_template, path_len);
return path;
diff --git a/source/blender/windowmanager/intern/wm_operators.c 
b/source/blender/windowmanager/intern/wm_operators.c
index 0d47d39d5d..981ef60fad 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -1766,15 +1766,17 @@ static uiBlock *wm_block_create_splash(bContext *C, 
ARegion *ar, void *UNUSED(ar
/* overwrite splash with template image */
if (U.app_template[0] != '\0') {
ImBuf *ibuf_template = NULL;
-   char temp_path[FILE_MAX];
-   BLI_join_dirfile(temp_path, sizeof(temp_path), "app_templates", 
U.app_template);
-   const char *filepath_template = 
BKE_appdir_folder_id(BLENDER_DATAFILES, temp_path);
+   char splash_filepath[FILE_MAX];
+   char template_directory[FILE_MAX];
 
-   if (filepath_template) {
+   if (BKE_appdir_app_template_id_search(
+   template_directory, sizeof(template_directory),
+   U.app_template))
+   {
BLI_join_dirfile(
-   temp_path, sizeof(temp_path), filepath_template,
+   splash_filepath, sizeof(splash_filepath), 
template_directory,
(U.pixelsize == 2) ? "splash_2x.png" : 
"splash.png");
-   ibuf_template = IMB_loadiffname(temp_path, IB_rect, 
NULL);
+   ibuf_template = IMB_loadiffname(splash_filepath, 
IB_rect, NULL);
if (ibuf_template) {
const int x_expect = ibuf_template->x;
const int y_expect = 230 * (int)U.pixelsize;
@@ -1784,7 +1786,7 @@ static uiBlock *wm_block_create_splash(bContext *C, 
ARegion *ar, void *UNUSED(ar
}
else {
printf("Splash expected %dx%d found 
%dx%d, ignoring: %s\n",
-  x_expect, y_expect, 
ibuf_template->x, ibuf_template->y, temp_path);
+  x_expect, y_expect, 
ibuf_template->x, ibuf_template->y, splash_filepath);
}
IMB_freeImBuf(ibuf_template);
}

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [dcfb47d236] app-templates: Make BKE_appdir_app_template_id_search take a path arg

2017-03-23 Thread Campbell Barton
Commit: dcfb47d236222cb9998b5c59a923d8f8389360a9
Author: Campbell Barton
Date:   Fri Mar 24 05:39:23 2017 +1100
Branches: app-templates
https://developer.blender.org/rBdcfb47d236222cb9998b5c59a923d8f8389360a9

Make BKE_appdir_app_template_id_search take a path arg

===

M   source/blender/blenkernel/BKE_appdir.h
M   source/blender/blenkernel/intern/appdir.c
M   source/blender/windowmanager/intern/wm_files.c

===

diff --git a/source/blender/blenkernel/BKE_appdir.h 
b/source/blender/blenkernel/BKE_appdir.h
index 84621a8463..c51d21a531 100644
--- a/source/blender/blenkernel/BKE_appdir.h
+++ b/source/blender/blenkernel/BKE_appdir.h
@@ -32,8 +32,8 @@ const char *BKE_appdir_folder_id_create(const int folder_id, 
const char *subfold
 const char *BKE_appdir_folder_id_user_notest(const int folder_id, const char 
*subfolder);
 const char *BKE_appdir_folder_id_version(const int folder_id, const int ver, 
const bool do_check);
 
-boolBKE_appdir_app_template_any(void);
-const char *BKE_appdir_app_template_id_search(const char *app_template);
+bool BKE_appdir_app_template_any(void);
+bool BKE_appdir_app_template_id_search(char *path, size_t path_len, const char 
*app_template);
 
 /* Initialize path to program executable */
 voidBKE_appdir_program_path_init(const char *argv0);
diff --git a/source/blender/blenkernel/intern/appdir.c 
b/source/blender/blenkernel/intern/appdir.c
index 5df32e5a82..4cacdbffc9 100644
--- a/source/blender/blenkernel/intern/appdir.c
+++ b/source/blender/blenkernel/intern/appdir.c
@@ -678,14 +678,13 @@ bool BKE_appdir_app_template_any(void)
return false;
 }
 
-const char *BKE_appdir_app_template_id_search(const char *app_template)
+bool BKE_appdir_app_template_id_search(char *path, size_t path_len, const char 
*app_template)
 {
-   static char path[FILE_MAX] = "";
for (int i = 0; i < 2; i++) {
BLI_join_dirfile(path, sizeof(path), 
app_template_directory_search[i], app_template);
const char *filepath_startup_template = 
BKE_appdir_folder_id(app_template_directory_id[i], path);
if (filepath_startup_template) {
-   BLI_strncpy(path, filepath_startup_template, 
sizeof(path));
+   BLI_strncpy(path, filepath_startup_template, path_len);
return path;
}
}
diff --git a/source/blender/windowmanager/intern/wm_files.c 
b/source/blender/windowmanager/intern/wm_files.c
index d4abbb4bc0..9003625930 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -725,10 +725,7 @@ int wm_homefile_read(
}
 
if (app_template != NULL) {
-   const char *path = 
BKE_appdir_app_template_id_search(app_template);
-   if (path) {
-   BLI_strncpy(template_directory, path, 
sizeof(template_directory));
-   }
+   BKE_appdir_app_template_id_search(template_directory, 
sizeof(template_directory), app_template);
}
 
/* insert template name into startup file */

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [a898509cc2] app-templates: Merge branch 'master' into app-templates

2017-03-23 Thread Campbell Barton
Commit: a898509cc2d4cffc0d48da64e13fee9a7afbcf4a
Author: Campbell Barton
Date:   Fri Mar 24 05:24:57 2017 +1100
Branches: app-templates
https://developer.blender.org/rBa898509cc2d4cffc0d48da64e13fee9a7afbcf4a

Merge branch 'master' into app-templates

===



===



___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [05b7591c62] master: BLI_path_util: Add string versions of SEP, ALTSEP

2017-03-23 Thread Campbell Barton
Commit: 05b7591c6240a3af1b71420ac3386787f1f384da
Author: Campbell Barton
Date:   Fri Mar 24 05:23:03 2017 +1100
Branches: master
https://developer.blender.org/rB05b7591c6240a3af1b71420ac3386787f1f384da

BLI_path_util: Add string versions of SEP, ALTSEP

This allows for adding separators in string literals.

===

M   source/blender/blenlib/BLI_path_util.h

===

diff --git a/source/blender/blenlib/BLI_path_util.h 
b/source/blender/blenlib/BLI_path_util.h
index 1c1725923a..a4f5c3c7a0 100644
--- a/source/blender/blenlib/BLI_path_util.h
+++ b/source/blender/blenlib/BLI_path_util.h
@@ -39,14 +39,6 @@ extern "C" {
 
 struct ListBase;
 
-#ifdef WIN32
-#define SEP '\\'
-#define ALTSEP '/'
-#else
-#define SEP '/'
-#define ALTSEP '\\'
-#endif
-
 void BLI_setenv(const char *env, const char *val) ATTR_NONNULL(1);
 void BLI_setenv_if_new(const char *env, const char *val) ATTR_NONNULL(1);
 
@@ -145,6 +137,18 @@ bool BLI_path_suffix(char *string, size_t maxlen, const 
char *suffix, const char
 #  define FILE_MAX1024
 #endif
 
+#ifdef WIN32
+#  define SEP'\\'
+#  define ALTSEP '/'
+#  define SEP_STR"\\"
+#  define ALTSEP_STR "/"
+#else
+#  define SEP'/'
+#  define ALTSEP '\\'
+#  define SEP_STR"/"
+#  define ALTSEP_STR "\\"
+#endif
+
 /* Parent and current dir helpers. */
 #define FILENAME_PARENT ".."
 #define FILENAME_CURRENT "."

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [9af6f40e4d] master: addon_utils: add disable_all function

2017-03-23 Thread Campbell Barton
Commit: 9af6f40e4dcf0dc6e95a809ed0998bbdb8189a86
Author: Campbell Barton
Date:   Fri Mar 24 05:20:26 2017 +1100
Branches: master
https://developer.blender.org/rB9af6f40e4dcf0dc6e95a809ed0998bbdb8189a86

addon_utils: add disable_all function

===

M   release/scripts/modules/addon_utils.py

===

diff --git a/release/scripts/modules/addon_utils.py 
b/release/scripts/modules/addon_utils.py
index 886f078f04..51e3e65b78 100644
--- a/release/scripts/modules/addon_utils.py
+++ b/release/scripts/modules/addon_utils.py
@@ -24,6 +24,7 @@ __all__ = (
 "check",
 "enable",
 "disable",
+"disable_all",
 "reset_all",
 "module_bl_info",
 )
@@ -444,6 +445,13 @@ def reset_all(*, reload_scripts=False):
 disable(mod_name)
 
 
+def disable_all():
+import sys
+for mod_name, mod in sys.modules.items():
+if getattr(mod, "__addon_enabled__", False):
+disable(mod_name)
+
+
 def module_bl_info(mod, info_basis=None):
 if info_basis is None:
 info_basis = {

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [1f65ed254e] app-templates: Merge branch 'master' into app-templates

2017-03-23 Thread Campbell Barton
Commit: 1f65ed254eaebbfe7e60ffa81a744de2ac61d817
Author: Campbell Barton
Date:   Fri Mar 24 05:19:04 2017 +1100
Branches: app-templates
https://developer.blender.org/rB1f65ed254eaebbfe7e60ffa81a744de2ac61d817

Merge branch 'master' into app-templates

===



===



___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [6180b2911b] app-templates: Cleanup, also move SEP_STR into the header

2017-03-23 Thread Campbell Barton
Commit: 6180b2911bd9eb9cc3724c731df99a68e2667a3a
Author: Campbell Barton
Date:   Fri Mar 24 05:13:36 2017 +1100
Branches: app-templates
https://developer.blender.org/rB6180b2911bd9eb9cc3724c731df99a68e2667a3a

Cleanup, also move SEP_STR into the header

===

M   release/scripts/modules/bl_app_override/helpers.py
M   release/scripts/modules/bpy/utils/__init__.py
M   source/blender/blenkernel/intern/appdir.c
M   source/blender/blenlib/BLI_path_util.h

===

diff --git a/release/scripts/modules/bl_app_override/helpers.py 
b/release/scripts/modules/bl_app_override/helpers.py
index ccce200c21..bf42c7809a 100644
--- a/release/scripts/modules/bl_app_override/helpers.py
+++ b/release/scripts/modules/bl_app_override/helpers.py
@@ -32,7 +32,7 @@ class AppOverrideState:
 storing the result, then restoring later on.
 
 Instead, the class can define callbacks (documented below),
-Then call  call ``setup``, to reverse this call ``teardown``.
+Then call ``setup``, and ``teardown`` to reverse.
 
 All of the callbacks below are optional,
 leaving them undeclared means you're opting out of manipulating
diff --git a/release/scripts/modules/bpy/utils/__init__.py 
b/release/scripts/modules/bpy/utils/__init__.py
index f760f52615..cefa505d8a 100644
--- a/release/scripts/modules/bpy/utils/__init__.py
+++ b/release/scripts/modules/bpy/utils/__init__.py
@@ -369,10 +369,7 @@ def app_template_paths(subdir=None):
 
 :arg subdir: Optional subdir.
 :type subdir: string
-:arg check_all: Include local, user and system paths rather just the paths
-   blender uses.
-:type check_all: bool
-:return: script paths.
+:return: app template paths.
 :rtype: list
 """
 import os
diff --git a/source/blender/blenkernel/intern/appdir.c 
b/source/blender/blenkernel/intern/appdir.c
index a86ef11254..5df32e5a82 100644
--- a/source/blender/blenkernel/intern/appdir.c
+++ b/source/blender/blenkernel/intern/appdir.c
@@ -655,23 +655,19 @@ bool BKE_appdir_program_python_search(
return is_found;
 }
 
-#ifdef WIN32
-#  define SEP_STR "\\"
-#else
-#  define SEP_STR "/"
-#endif
-
 static const char *app_template_directory_search[2] = {
"startup" SEP_STR "bl_app_templates_system",
"startup" SEP_STR "bl_app_templates_user",
 };
-#undef SEP_STR
 
 static const int app_template_directory_id[2] = {
BLENDER_SYSTEM_SCRIPTS,
BLENDER_USER_SCRIPTS,
 };
 
+/**
+ * Return true if templates exist
+ */
 bool BKE_appdir_app_template_any(void)
 {
for (int i = 0; i < 2; i++) {
diff --git a/source/blender/blenlib/BLI_path_util.h 
b/source/blender/blenlib/BLI_path_util.h
index 1c1725923a..a4f5c3c7a0 100644
--- a/source/blender/blenlib/BLI_path_util.h
+++ b/source/blender/blenlib/BLI_path_util.h
@@ -39,14 +39,6 @@ extern "C" {
 
 struct ListBase;
 
-#ifdef WIN32
-#define SEP '\\'
-#define ALTSEP '/'
-#else
-#define SEP '/'
-#define ALTSEP '\\'
-#endif
-
 void BLI_setenv(const char *env, const char *val) ATTR_NONNULL(1);
 void BLI_setenv_if_new(const char *env, const char *val) ATTR_NONNULL(1);
 
@@ -145,6 +137,18 @@ bool BLI_path_suffix(char *string, size_t maxlen, const 
char *suffix, const char
 #  define FILE_MAX1024
 #endif
 
+#ifdef WIN32
+#  define SEP'\\'
+#  define ALTSEP '/'
+#  define SEP_STR"\\"
+#  define ALTSEP_STR "/"
+#else
+#  define SEP'/'
+#  define ALTSEP '\\'
+#  define SEP_STR"/"
+#  define ALTSEP_STR "\\"
+#endif
+
 /* Parent and current dir helpers. */
 #define FILENAME_PARENT ".."
 #define FILENAME_CURRENT "."

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [96e1b46791] blender2.8: OpenGL Immediate Mode: finalize `image_draw`

2017-03-23 Thread Germano Cavalcante
Commit: 96e1b46791d57b81ac34ab42b782471c0099d291
Author: Germano Cavalcante
Date:   Thu Mar 23 14:56:42 2017 -0300
Branches: blender2.8
https://developer.blender.org/rB96e1b46791d57b81ac34ab42b782471c0099d291

OpenGL Immediate Mode: finalize `image_draw`

The directive `#if 0` was ignored.

Part of T49043

===

M   source/blender/editors/space_image/image_draw.c

===

diff --git a/source/blender/editors/space_image/image_draw.c 
b/source/blender/editors/space_image/image_draw.c
index d525886996..e8b32789cb 100644
--- a/source/blender/editors/space_image/image_draw.c
+++ b/source/blender/editors/space_image/image_draw.c
@@ -481,7 +481,6 @@ static void draw_image_buffer(const bContext *C, SpaceImage 
*sima, ARegion *ar,
 {
int x, y;
 
-   /* set zoom */
glaDefine2DArea(>winrct);

/* find window pixel coordinates of origin */
@@ -548,9 +547,6 @@ static void draw_image_buffer(const bContext *C, SpaceImage 
*sima, ARegion *ar,
if (sima->flag & SI_USE_ALPHA)
glDisable(GL_BLEND);
}
-
-   /* reset zoom */
-   glPixelZoom(1.0f, 1.0f);
 }
 
 static unsigned int *get_part_from_buffer(unsigned int *buffer, int width, 
short startx, short starty, short endx, short endy)
@@ -918,8 +914,12 @@ void draw_image_cache(const bContext *C, ARegion *ar)
/* Draw current frame. */
x = (cfra - sfra) / (efra - sfra + 1) * ar->winx;
 
-   UI_ThemeColor(TH_CFRAME);
-   glRecti(x, 0, x + ceilf(framelen), 8 * UI_DPI_FAC);
+   unsigned pos = add_attrib(immVertexFormat(), "pos", COMP_I32, 2, 
CONVERT_INT_TO_FLOAT);
+   immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
+   immUniformThemeColor(TH_CFRAME);
+   immRecti(pos, x, 0, x + ceilf(framelen), 8 * UI_DPI_FAC);
+   immUnbindProgram();
+
ED_region_cache_draw_curfra_label(cfra, x, 8.0f * UI_DPI_FAC);
 
if (mask != NULL) {

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [27248c8636] master: Cycles: Remove unused macro

2017-03-23 Thread Sergey Sharybin
Commit: 27248c8636ab8a6fa1e082ce9bc9bbdb09174358
Author: Sergey Sharybin
Date:   Thu Mar 23 17:59:02 2017 +0100
Branches: master
https://developer.blender.org/rB27248c8636ab8a6fa1e082ce9bc9bbdb09174358

Cycles: Remove unused macro

===

M   intern/cycles/kernel/geom/geom_triangle_intersect.h

===

diff --git a/intern/cycles/kernel/geom/geom_triangle_intersect.h 
b/intern/cycles/kernel/geom/geom_triangle_intersect.h
index 313121104f..584d0b3508 100644
--- a/intern/cycles/kernel/geom/geom_triangle_intersect.h
+++ b/intern/cycles/kernel/geom/geom_triangle_intersect.h
@@ -22,16 +22,6 @@
 
 CCL_NAMESPACE_BEGIN
 
-/* Workaround stupidness of CUDA/OpenCL which doesn't allow to access indexed
- * component of float3 value.
- */
-#ifndef __KERNEL_CPU__
-#  define IDX(vec, idx) \
-((idx == 0) ? ((vec).x) : ( (idx == 1) ? ((vec).y) : ((vec).z) ))
-#else
-#  define IDX(vec, idx) ((vec)[idx])
-#endif
-
 /* Ray-Triangle intersection for BVH traversal
  *
  * Sven Woop
@@ -309,6 +299,4 @@ ccl_device_inline float3 
triangle_refine_subsurface(KernelGlobals *kg,
return P;
 }
 
-#undef IDX
-
 CCL_NAMESPACE_END

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [ba8c7d2ba1] master: Cycles: Use SSE-optimized version of triangle intersection for motion triangles

2017-03-23 Thread Sergey Sharybin
Commit: ba8c7d2ba120f5ba7fdbaef67fe2e301ec3e5dcb
Author: Sergey Sharybin
Date:   Thu Mar 23 16:16:05 2017 +0100
Branches: master
https://developer.blender.org/rBba8c7d2ba120f5ba7fdbaef67fe2e301ec3e5dcb

Cycles: Use SSE-optimized version of triangle intersection for motion triangles

The title says it all actually. Gives up to 10% speedup on test scenes here
on i7-6800K.

Render times on GPU are unreliable here, but there might be some slowdown
caused by watertight nature of intersections.

===

M   intern/cycles/kernel/bvh/bvh_shadow_all.h
M   intern/cycles/kernel/bvh/bvh_subsurface.h
M   intern/cycles/kernel/bvh/bvh_traversal.h
M   intern/cycles/kernel/bvh/bvh_volume.h
M   intern/cycles/kernel/bvh/bvh_volume_all.h
M   intern/cycles/kernel/bvh/qbvh_shadow_all.h
M   intern/cycles/kernel/bvh/qbvh_subsurface.h
M   intern/cycles/kernel/bvh/qbvh_traversal.h
M   intern/cycles/kernel/bvh/qbvh_volume.h
M   intern/cycles/kernel/bvh/qbvh_volume_all.h
M   intern/cycles/kernel/geom/geom_motion_triangle_intersect.h

===

diff --git a/intern/cycles/kernel/bvh/bvh_shadow_all.h 
b/intern/cycles/kernel/bvh/bvh_shadow_all.h
index a6e23d9f38..8f7c005e96 100644
--- a/intern/cycles/kernel/bvh/bvh_shadow_all.h
+++ b/intern/cycles/kernel/bvh/bvh_shadow_all.h
@@ -209,9 +209,9 @@ bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
 #if BVH_FEATURE(BVH_MOTION)
case 
PRIMITIVE_MOTION_TRIANGLE: {
hit = 
motion_triangle_intersect(kg,
+   
_precalc,

isect_array,

P,
-   
dir,

ray->time,

PATH_RAY_SHADOW,

object,
diff --git a/intern/cycles/kernel/bvh/bvh_subsurface.h 
b/intern/cycles/kernel/bvh/bvh_subsurface.h
index 11ea1f89c8..cb7a4e3bc3 100644
--- a/intern/cycles/kernel/bvh/bvh_subsurface.h
+++ b/intern/cycles/kernel/bvh/bvh_subsurface.h
@@ -214,9 +214,9 @@ void BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
for(; prim_addr < prim_addr2; 
prim_addr++) {

kernel_assert(kernel_tex_fetch(__prim_type, prim_addr) == type);

motion_triangle_intersect_subsurface(kg,
+   
 _precalc,

 ss_isect,

 P,
-   
 dir,

 ray->time,

 object,

 prim_addr,
diff --git a/intern/cycles/kernel/bvh/bvh_traversal.h 
b/intern/cycles/kernel/bvh/bvh_traversal.h
index 7c4671e074..eac98a3165 100644
--- a/intern/cycles/kernel/bvh/bvh_traversal.h
+++ b/intern/cycles/kernel/bvh/bvh_traversal.h
@@ -267,9 +267,9 @@ ccl_device_noinline bool 
BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,

BVH_DEBUG_NEXT_INTERSECTION();

kernel_assert(kernel_tex_fetch(__prim_type, prim_addr) == type);

if(motion_triangle_intersect(kg,
+   
 _precalc,

 isect,

 P,
-   
 dir,

 ray->time,
   

[Bf-blender-cvs] [f8a999c965] master: Cycles: Move triangle intersection precalc to an util file

2017-03-23 Thread Sergey Sharybin
Commit: f8a999c965435ed6cf3ed83aa4f1121c79f2a403
Author: Sergey Sharybin
Date:   Thu Mar 23 13:01:42 2017 +0100
Branches: master
https://developer.blender.org/rBf8a999c965435ed6cf3ed83aa4f1121c79f2a403

Cycles: Move triangle intersection precalc to an util file

This is a preparation work for the followup commit which wil l move
remaining parts of Woop intersection logic to an utility file.

Doing it as a separate commit to keep changes more atomic and easier
to bisect when/if needed.

===

M   intern/cycles/kernel/bvh/bvh_shadow_all.h
M   intern/cycles/kernel/bvh/bvh_subsurface.h
M   intern/cycles/kernel/bvh/bvh_traversal.h
M   intern/cycles/kernel/bvh/bvh_volume.h
M   intern/cycles/kernel/bvh/bvh_volume_all.h
M   intern/cycles/kernel/bvh/qbvh_shadow_all.h
M   intern/cycles/kernel/bvh/qbvh_subsurface.h
M   intern/cycles/kernel/bvh/qbvh_traversal.h
M   intern/cycles/kernel/bvh/qbvh_volume.h
M   intern/cycles/kernel/bvh/qbvh_volume_all.h
M   intern/cycles/kernel/geom/geom_triangle_intersect.h
M   intern/cycles/util/util_math_intersect.h

===

diff --git a/intern/cycles/kernel/bvh/bvh_shadow_all.h 
b/intern/cycles/kernel/bvh/bvh_shadow_all.h
index b4f65bc8ef..a6e23d9f38 100644
--- a/intern/cycles/kernel/bvh/bvh_shadow_all.h
+++ b/intern/cycles/kernel/bvh/bvh_shadow_all.h
@@ -100,8 +100,8 @@ bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
gen_idirsplat_swap(pn, shuf_identity, shuf_swap, idir, idirsplat, 
shufflexyz);
 #endif  /* __KERNEL_SSE2__ */
 
-   IsectPrecalc isect_precalc;
-   triangle_intersect_precalc(dir, _precalc);
+   TriangleIsectPrecalc isect_precalc;
+   ray_triangle_intersect_precalc(dir, _precalc);
 
/* traversal loop */
do {
@@ -314,7 +314,7 @@ bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
isect_t = bvh_instance_push(kg, object, 
ray, , , , isect_t);
 #  endif
 
-   triangle_intersect_precalc(dir, 
_precalc);
+   ray_triangle_intersect_precalc(dir, 
_precalc);
num_hits_in_instance = 0;
isect_array->t = isect_t;
 
@@ -354,7 +354,7 @@ bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
bvh_instance_pop_factor(kg, object, ray, , 
, , _fac);
 #  endif
 
-   triangle_intersect_precalc(dir, _precalc);
+   ray_triangle_intersect_precalc(dir, 
_precalc);
 
/* scale isect->t to adjust for instancing */
for(int i = 0; i < num_hits_in_instance; i++) {
@@ -367,7 +367,7 @@ bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
 #  else
bvh_instance_pop(kg, object, ray, , , 
, FLT_MAX);
 #  endif
-   triangle_intersect_precalc(dir, _precalc);
+   ray_triangle_intersect_precalc(dir, 
_precalc);
}
 
isect_t = tmax;
diff --git a/intern/cycles/kernel/bvh/bvh_subsurface.h 
b/intern/cycles/kernel/bvh/bvh_subsurface.h
index 583f7f7c46..11ea1f89c8 100644
--- a/intern/cycles/kernel/bvh/bvh_subsurface.h
+++ b/intern/cycles/kernel/bvh/bvh_subsurface.h
@@ -109,8 +109,8 @@ void BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
gen_idirsplat_swap(pn, shuf_identity, shuf_swap, idir, idirsplat, 
shufflexyz);
 #endif
 
-   IsectPrecalc isect_precalc;
-   triangle_intersect_precalc(dir, _precalc);
+   TriangleIsectPrecalc isect_precalc;
+   ray_triangle_intersect_precalc(dir, _precalc);
 
/* traversal loop */
do {
diff --git a/intern/cycles/kernel/bvh/bvh_traversal.h 
b/intern/cycles/kernel/bvh/bvh_traversal.h
index 0eca0c8e38..7c4671e074 100644
--- a/intern/cycles/kernel/bvh/bvh_traversal.h
+++ b/intern/cycles/kernel/bvh/bvh_traversal.h
@@ -104,8 +104,8 @@ ccl_device_noinline bool 
BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
gen_idirsplat_swap(pn, shuf_identity, shuf_swap, idir, idirsplat, 
shufflexyz);
 #endif
 
-   IsectPrecalc isect_precalc;
-   triangle_intersect_precalc(dir, _precalc);
+   TriangleIsectPrecalc isect_precalc;
+   ray_triangle_intersect_precalc(dir, _precalc);
 
/* traversal loop */
do {
@@ -358,7 +358,7 @@ ccl_device_noinline bool 
BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
 #  else
isect->t = bvh_instance_push(kg, 
object, ray, , , , isect->t);
 #  endif
-   triangle_intersect_precalc(dir, 
_precalc);
+   ray_triangle_intersect_precalc(dir, 
_precalc);
 
 #  if defined(__KERNEL_SSE2__)

[Bf-blender-cvs] [2a5d7b5b1e] master: Cycles: Use utility function for SSS triangle intersection

2017-03-23 Thread Sergey Sharybin
Commit: 2a5d7b5b1e0345ce8ebf40c78ecd31eaeaa88f6d
Author: Sergey Sharybin
Date:   Thu Mar 23 15:17:26 2017 +0100
Branches: master
https://developer.blender.org/rB2a5d7b5b1e0345ce8ebf40c78ecd31eaeaa88f6d

Cycles: Use utility function for SSS triangle intersection

This effectively de-duplicates triangle intersection logic implemented
for both regular triangle and SSS triangle.

===

M   intern/cycles/kernel/geom/geom_triangle_intersect.h

===

diff --git a/intern/cycles/kernel/geom/geom_triangle_intersect.h 
b/intern/cycles/kernel/geom/geom_triangle_intersect.h
index ea2ee5c353..973b356637 100644
--- a/intern/cycles/kernel/geom/geom_triangle_intersect.h
+++ b/intern/cycles/kernel/geom/geom_triangle_intersect.h
@@ -102,129 +102,27 @@ ccl_device_inline void triangle_intersect_subsurface(
 uint *lcg_state,
 int max_hits)
 {
-   const int kx = isect_precalc->kx;
-   const int ky = isect_precalc->ky;
-   const int kz = isect_precalc->kz;
-   const float Sx = isect_precalc->Sx;
-   const float Sy = isect_precalc->Sy;
-   const float Sz = isect_precalc->Sz;
-
-   /* Calculate vertices relative to ray origin. */
const uint tri_vindex = kernel_tex_fetch(__prim_tri_index, prim_addr);
-   const float4 tri_a = kernel_tex_fetch(__prim_tri_verts, tri_vindex+0),
-tri_b = kernel_tex_fetch(__prim_tri_verts, tri_vindex+1),
-tri_c = kernel_tex_fetch(__prim_tri_verts, tri_vindex+2);
 
 #if defined(__KERNEL_AVX2__) && defined(__KERNEL_SSE__)
-   const avxf avxf_P(P.m128, P.m128);
-
-   const avxf tri_ab = kernel_tex_fetch_avxf(__prim_tri_verts, tri_vindex 
+ 0);
-   const avxf tri_bc = kernel_tex_fetch_avxf(__prim_tri_verts, tri_vindex 
+ 1);
-
-   const avxf AB = tri_ab - avxf_P;
-   const avxf BC = tri_bc - avxf_P;
-
-   const __m256i permuteMask = _mm256_set_epi32(0x3, kz, ky, kx, 0x3, kz, 
ky, kx);
-
-   const avxf AB_k = shuffle(AB, permuteMask);
-   const avxf BC_k = shuffle(BC, permuteMask);
-
-   /* Akz, Akz, Bkz, Bkz, Bkz, Bkz, Ckz, Ckz */
-   const avxf ABBC_kz = shuffle<2>(AB_k, BC_k);
-
-   /* Akx, Aky, Bkx, Bky, Bkx,Bky, Ckx, Cky */
-   const avxf ABBC_kxy = shuffle<0,1,0,1>(AB_k, BC_k);
-
-   const avxf Sxy(Sy, Sx, Sy, Sx);
-
-   /* Ax, Ay, Bx, By, Bx, By, Cx, Cy */
-   const avxf ABBC_xy = nmadd(ABBC_kz, Sxy, ABBC_kxy);
-
-   float ABBC_kz_array[8];
-   _mm256_storeu_ps((float*)_kz_array, ABBC_kz);
-
-   const float A_kz = ABBC_kz_array[0];
-   const float B_kz = ABBC_kz_array[2];
-   const float C_kz = ABBC_kz_array[6];
-
-   /* By, Bx, Cy, Cx, By, Bx, Ay, Ax */
-   const avxf BCBA_yx = permute<3,2,7,6,3,2,1,0>(ABBC_xy);
-
-   const avxf negMask(0,0,0,0,0x8000, 0x8000, 0x8000, 
0x8000);
-
-   /* W   U V
-* (AxBy-AyBx) (BxCy-ByCx) XX XX (BxBy-ByBx) (CxAy-CyAx) XX XX
-*/
-   const avxf WUVxx_neg = _mm256_hsub_ps(ABBC_xy * BCBA_yx, negMask /* 
Dont care */);
-
-   const avxf WUVWnegWUVW = permute<0,1,5,0,0,1,5,0>(WUVxx_neg) ^ 
negMask;
-
-   /* Calculate scaled barycentric coordinates. */
-   float WUVW_array[4];
-   _mm_storeu_ps((float*)_array, _mm256_castps256_ps128 
(WUVWnegWUVW));
-
-   const float W = WUVW_array[0];
-   const float U = WUVW_array[1];
-   const float V = WUVW_array[2];
-
-   const int WUVW_mask = 0x7 & _mm256_movemask_ps(WUVWnegWUVW);
-   const int WUVW_zero = 0x7 & 
_mm256_movemask_ps(_mm256_cmp_ps(WUVWnegWUVW,
-  _mm256_setzero_ps(), 0));
-
-   if(!((WUVW_mask == 7) || (WUVW_mask == 0)) && ((WUVW_mask | WUVW_zero) 
!= 7)) {
-   return;
-   }
+   const ssef *verts = (ssef*)>__prim_tri_verts.data[tri_vindex];
 #else
-   const float3 A = make_float3(tri_a.x - P.x, tri_a.y - P.y, tri_a.z - 
P.z);
-   const float3 B = make_float3(tri_b.x - P.x, tri_b.y - P.y, tri_b.z - 
P.z);
-   const float3 C = make_float3(tri_c.x - P.x, tri_c.y - P.y, tri_c.z - 
P.z);
-
-   const float A_kx = IDX(A, kx), A_ky = IDX(A, ky), A_kz = IDX(A, kz);
-   const float B_kx = IDX(B, kx), B_ky = IDX(B, ky), B_kz = IDX(B, kz);
-   const float C_kx = IDX(C, kx), C_ky = IDX(C, ky), C_kz = IDX(C, kz);
-
-   /* Perform shear and scale of vertices. */
-   const float Ax = A_kx - Sx * A_kz;
-   const float Ay = A_ky - Sy * A_kz;
-   const float Bx = B_kx - Sx * B_kz;
-   const float By = B_ky - Sy * B_kz;
-   const float Cx = C_kx - Sx * C_kz;
-   const float Cy = C_ky - Sy * C_kz;
-
-   /* Calculate scaled barycentric coordinates. */
-   float U = Cx * By - Cy * Bx;
-   float V = Ax * Cy - Ay * Cx;
-   float W = Bx * Ay - By * Ax;
-
-   if((U < 0.0f || 

[Bf-blender-cvs] [a5b6742ed2] master: Cycles: Move watertight triangle intersection to an utility file

2017-03-23 Thread Sergey Sharybin
Commit: a5b6742ed277533f32fefa27f9763e101fa0545d
Author: Sergey Sharybin
Date:   Thu Mar 23 13:30:18 2017 +0100
Branches: master
https://developer.blender.org/rBa5b6742ed277533f32fefa27f9763e101fa0545d

Cycles: Move watertight triangle intersection to an utility file

This way the code can be reused more easily.

===

M   intern/cycles/kernel/geom/geom_triangle_intersect.h
M   intern/cycles/util/util_math_intersect.h

===

diff --git a/intern/cycles/kernel/geom/geom_triangle_intersect.h 
b/intern/cycles/kernel/geom/geom_triangle_intersect.h
index 12700c7a24..ea2ee5c353 100644
--- a/intern/cycles/kernel/geom/geom_triangle_intersect.h
+++ b/intern/cycles/kernel/geom/geom_triangle_intersect.h
@@ -48,145 +48,39 @@ ccl_device_inline bool triangle_intersect(KernelGlobals 
*kg,
   int object,
   int prim_addr)
 {
-   const int kx = isect_precalc->kx;
-   const int ky = isect_precalc->ky;
-   const int kz = isect_precalc->kz;
-   const float Sx = isect_precalc->Sx;
-   const float Sy = isect_precalc->Sy;
-   const float Sz = isect_precalc->Sz;
-
-   /* Calculate vertices relative to ray origin. */
const uint tri_vindex = kernel_tex_fetch(__prim_tri_index, prim_addr);
 
 #if defined(__KERNEL_AVX2__) && defined(__KERNEL_SSE__)
-   const avxf avxf_P(P.m128, P.m128);
-
-   const ssef *ssef_verts = (ssef*)>__prim_tri_verts.data[tri_vindex];
-   const avxf tri_ab = _mm256_loadu_ps((float *)(ssef_verts));
-   const avxf tri_bc = _mm256_loadu_ps((float *)(ssef_verts + 1));
-
-   const avxf AB = tri_ab - avxf_P;
-   const avxf BC = tri_bc - avxf_P;
-
-   const __m256i permute_mask = _mm256_set_epi32(0x3, kz, ky, kx, 0x3, kz, 
ky, kx);
-
-   const avxf AB_k = shuffle(AB, permute_mask);
-   const avxf BC_k = shuffle(BC, permute_mask);
-
-   /* Akz, Akz, Bkz, Bkz, Bkz, Bkz, Ckz, Ckz */
-   const avxf ABBC_kz = shuffle<2>(AB_k, BC_k);
-
-   /* Akx, Aky, Bkx, Bky, Bkx,Bky, Ckx, Cky */
-   const avxf ABBC_kxy = shuffle<0,1,0,1>(AB_k, BC_k);
-
-   const avxf Sxy(Sy, Sx, Sy, Sx);
-
-   /* Ax, Ay, Bx, By, Bx, By, Cx, Cy */
-   const avxf ABBC_xy = nmadd(ABBC_kz, Sxy, ABBC_kxy);
-
-   float ABBC_kz_array[8];
-   _mm256_storeu_ps((float*)_kz_array, ABBC_kz);
-
-   const float A_kz = ABBC_kz_array[0];
-   const float B_kz = ABBC_kz_array[2];
-   const float C_kz = ABBC_kz_array[6];
-
-   /* By, Bx, Cy, Cx, By, Bx, Ay, Ax */
-   const avxf BCBA_yx = permute<3,2,7,6,3,2,1,0>(ABBC_xy);
-
-   const avxf neg_mask(0,0,0,0,0x8000, 0x8000, 0x8000, 
0x8000);
-
-   /* W   U V
-* (AxBy-AyBx) (BxCy-ByCx) XX XX (BxBy-ByBx) (CxAy-CyAx) XX XX
-*/
-   const avxf WUVxx_neg = _mm256_hsub_ps(ABBC_xy * BCBA_yx, neg_mask 
/* Dont care */);
-
-   const avxf WUVWnegWUVW = permute<0,1,5,0,0,1,5,0>(WUVxx_neg) ^ 
neg_mask;
-
-   /* Calculate scaled barycentric coordinates. */
-   float WUVW_array[4];
-   _mm_storeu_ps((float*)_array, _mm256_castps256_ps128 
(WUVWnegWUVW));
-
-   const float W = WUVW_array[0];
-   const float U = WUVW_array[1];
-   const float V = WUVW_array[2];
-
-   const int WUVW_mask = 0x7 & _mm256_movemask_ps(WUVWnegWUVW);
-   const int WUVW_zero = 0x7 & 
_mm256_movemask_ps(_mm256_cmp_ps(WUVWnegWUVW,
-  _mm256_setzero_ps(), 0));
-
-   if(!((WUVW_mask == 7) || (WUVW_mask == 0)) && ((WUVW_mask | WUVW_zero) 
!= 7)) {
-   return false;
-   }
+   const ssef *verts = (ssef*)>__prim_tri_verts.data[tri_vindex];
 #else
const float4 tri_a = kernel_tex_fetch(__prim_tri_verts, tri_vindex+0),
 tri_b = kernel_tex_fetch(__prim_tri_verts, tri_vindex+1),
 tri_c = kernel_tex_fetch(__prim_tri_verts, tri_vindex+2);
-   const float3 A = make_float3(tri_a.x - P.x, tri_a.y - P.y, tri_a.z - 
P.z);
-   const float3 B = make_float3(tri_b.x - P.x, tri_b.y - P.y, tri_b.z - 
P.z);
-   const float3 C = make_float3(tri_c.x - P.x, tri_c.y - P.y, tri_c.z - 
P.z);
-
-   const float A_kx = IDX(A, kx), A_ky = IDX(A, ky), A_kz = IDX(A, kz);
-   const float B_kx = IDX(B, kx), B_ky = IDX(B, ky), B_kz = IDX(B, kz);
-   const float C_kx = IDX(C, kx), C_ky = IDX(C, ky), C_kz = IDX(C, kz);
-
-   /* Perform shear and scale of vertices. */
-   const float Ax = A_kx - Sx * A_kz;
-   const float Ay = A_ky - Sy * A_kz;
-   const float Bx = B_kx - Sx * B_kz;
-   const float By = B_ky - Sy * B_kz;
-   const float Cx = C_kx - Sx * C_kz;
-   const float Cy = C_ky - Sy * C_kz;
-
-   /* Calculate scaled barycentric coordinates. */
-   float U = Cx * By 

[Bf-blender-cvs] [a96110e710] master: Cycles: Remove old non-optimized triangle intersection function

2017-03-23 Thread Sergey Sharybin
Commit: a96110e7102d7a54127994b81c8c049f6e5fdeea
Author: Sergey Sharybin
Date:   Thu Mar 23 17:59:34 2017 +0100
Branches: master
https://developer.blender.org/rBa96110e7102d7a54127994b81c8c049f6e5fdeea

Cycles: Remove old non-optimized triangle intersection function

It is unused now and if we want similar function we should use
Pluecker intersection which is same performance with SSE optimization
but which is more watertight.

===

M   intern/cycles/util/util_math_intersect.h

===

diff --git a/intern/cycles/util/util_math_intersect.h 
b/intern/cycles/util/util_math_intersect.h
index 5bd3a52dce..9e0587e1af 100644
--- a/intern/cycles/util/util_math_intersect.h
+++ b/intern/cycles/util/util_math_intersect.h
@@ -290,49 +290,6 @@ ccl_device_forceinline bool ray_triangle_intersect(
 
 #undef IDX
 
-ccl_device_inline bool ray_triangle_intersect_uv(
-float3 ray_P, float3 ray_D, float ray_t,
-float3 v0, float3 v1, float3 v2,
-float *isect_u, float *isect_v, float *isect_t)
-{
-   /* Calculate intersection. */
-   const float3 e1 = v1 - v0;
-   const float3 e2 = v2 - v0;
-   const float3 s1 = cross(ray_D, e2);
-
-   const float divisor = dot(s1, e1);
-   if(UNLIKELY(divisor == 0.0f)) {
-   return false;
-   }
-   const float inv_divisor = 1.0f/divisor;
-
-   /* Compute first barycentric coordinate. */
-   const float3 d = ray_P - v0;
-   const float u = dot(d, s1)*inv_divisor;
-   if(u < 0.0f) {
-   return false;
-   }
-   /* Compute second barycentric coordinate. */
-   const float3 s2 = cross(d, e1);
-   const float v = dot(ray_D, s2)*inv_divisor;
-   if(v < 0.0f) {
-   return false;
-   }
-   const float b0 = 1.0f - u - v;
-   if(b0 < 0.0f) {
-   return false;
-   }
-   /* Compute distance to intersection point. */
-   const float t = dot(e2, s2)*inv_divisor;
-   if(t < 0.0f || t > ray_t) {
-   return false;
-   }
-   *isect_u = u;
-   *isect_v = v;
-   *isect_t = t;
-   return true;
-}
-
 ccl_device bool ray_quad_intersect(float3 ray_P, float3 ray_D,
float ray_mint, float ray_maxt,
float3 quad_P,

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [b797a5ff78] master: Cycles: Cleanup, move utility function to utility file

2017-03-23 Thread Sergey Sharybin
Commit: b797a5ff7849b6c32c7aefeccbf52445c9ccc597
Author: Sergey Sharybin
Date:   Thu Mar 23 12:55:51 2017 +0100
Branches: master
https://developer.blender.org/rBb797a5ff7849b6c32c7aefeccbf52445c9ccc597

Cycles: Cleanup, move utility function to utility file

Was an old TODO, this function is handy for some math utilities as well.

===

M   intern/cycles/kernel/geom/geom_triangle_intersect.h
M   intern/cycles/util/util_math.h

===

diff --git a/intern/cycles/kernel/geom/geom_triangle_intersect.h 
b/intern/cycles/kernel/geom/geom_triangle_intersect.h
index 4f4ee93c07..ca6e54c6b3 100644
--- a/intern/cycles/kernel/geom/geom_triangle_intersect.h
+++ b/intern/cycles/kernel/geom/geom_triangle_intersect.h
@@ -96,12 +96,6 @@ void triangle_intersect_precalc(float3 dir,
isect_precalc->kz = kz;
 }
 
-/* TODO(sergey): Make it general utility function. */
-ccl_device_inline float xor_signmask(float x, int y)
-{
-   return __int_as_float(__float_as_int(x) ^ y);
-}
-
 ccl_device_inline bool triangle_intersect(KernelGlobals *kg,
   const IsectPrecalc *isect_precalc,
   Intersection *isect,
diff --git a/intern/cycles/util/util_math.h b/intern/cycles/util/util_math.h
index 329b7f645c..a41beab628 100644
--- a/intern/cycles/util/util_math.h
+++ b/intern/cycles/util/util_math.h
@@ -1451,6 +1451,11 @@ ccl_device_inline float beta(float x, float y)
 #endif
 }
 
+ccl_device_inline float xor_signmask(float x, int y)
+{
+   return __int_as_float(__float_as_int(x) ^ y);
+}
+
 /* projections */
 ccl_device_inline float2 map_to_tube(const float3 co)
 {

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [aa0602130b] master: Cycles: Cleanup, code style and comments

2017-03-23 Thread Sergey Sharybin
Commit: aa0602130bef65a11d068db7f3641a6f51fd3427
Author: Sergey Sharybin
Date:   Thu Mar 23 12:53:45 2017 +0100
Branches: master
https://developer.blender.org/rBaa0602130bef65a11d068db7f3641a6f51fd3427

Cycles: Cleanup, code style and comments

===

M   intern/cycles/util/util_math_intersect.h

===

diff --git a/intern/cycles/util/util_math_intersect.h 
b/intern/cycles/util/util_math_intersect.h
index 0cf3cbcff9..870f33cee0 100644
--- a/intern/cycles/util/util_math_intersect.h
+++ b/intern/cycles/util/util_math_intersect.h
@@ -22,63 +22,60 @@ CCL_NAMESPACE_BEGIN
 /* Ray Intersection */
 
 ccl_device bool ray_sphere_intersect(
-   float3 ray_P, float3 ray_D, float ray_t,
-   float3 sphere_P, float sphere_radius,
-   float3 *isect_P, float *isect_t)
+float3 ray_P, float3 ray_D, float ray_t,
+float3 sphere_P, float sphere_radius,
+float3 *isect_P, float *isect_t)
 {
-   float3 d = sphere_P - ray_P;
-   float radiussq = sphere_radius*sphere_radius;
-   float tsq = dot(d, d);
-
-   if(tsq > radiussq) { /* ray origin outside sphere */
-   float tp = dot(d, ray_D);
-
-   if(tp < 0.0f) /* dir points away from sphere */
+   const float3 d = sphere_P - ray_P;
+   const float radiussq = sphere_radius*sphere_radius;
+   const float tsq = dot(d, d);
+
+   if(tsq > radiussq) {
+   /* Ray origin outside sphere. */
+   const float tp = dot(d, ray_D);
+   if(tp < 0.0f) {
+   /* Ray  points away from sphere. */
return false;
-
-   float dsq = tsq - tp*tp; /* pythagoras */
-
-   if(dsq > radiussq) /* closest point on ray outside sphere */
+   }
+   const float dsq = tsq - tp*tp;  /* pythagoras */
+   if(dsq > radiussq)  {
+   /* Closest point on ray outside sphere. */
return false;
-
-   float t = tp - sqrtf(radiussq - dsq); /* pythagoras */
-
+   }
+   const float t = tp - sqrtf(radiussq - dsq);  /* pythagoras */
if(t < ray_t) {
*isect_t = t;
*isect_P = ray_P + ray_D*t;
return true;
}
}
-
return false;
 }
 
 ccl_device bool ray_aligned_disk_intersect(
-   float3 ray_P, float3 ray_D, float ray_t,
-   float3 disk_P, float disk_radius,
-   float3 *isect_P, float *isect_t)
+float3 ray_P, float3 ray_D, float ray_t,
+float3 disk_P, float disk_radius,
+float3 *isect_P, float *isect_t)
 {
-   /* aligned disk normal */
+   /* Aligned disk normal. */
float disk_t;
-   float3 disk_N = normalize_len(ray_P - disk_P, _t);
-   float div = dot(ray_D, disk_N);
-
-   if(UNLIKELY(div == 0.0f))
+   const float3 disk_N = normalize_len(ray_P - disk_P, _t);
+   const float div = dot(ray_D, disk_N);
+   if(UNLIKELY(div == 0.0f)) {
return false;
-
-   /* compute t to intersection point */
-   float t = -disk_t/div;
-   if(t < 0.0f || t > ray_t)
+   }
+   /* Compute t to intersection point. */
+   const float t = -disk_t/div;
+   if(t < 0.0f || t > ray_t) {
return false;
-   
-   /* test if within radius */
+   }
+   /* Test if within radius. */
float3 P = ray_P + ray_D*t;
-   if(len_squared(P - disk_P) > disk_radius*disk_radius)
+   if(len_squared(P - disk_P) > disk_radius*disk_radius) {
return false;
-
+   }
*isect_P = P;
*isect_t = t;
-
return true;
 }
 
@@ -87,69 +84,72 @@ ccl_device_inline bool ray_triangle_intersect_uv(
 float3 v0, float3 v1, float3 v2,
 float *isect_u, float *isect_v, float *isect_t)
 {
-   /* Calculate intersection */
-   float3 e1 = v1 - v0;
-   float3 e2 = v2 - v0;
-   float3 s1 = cross(ray_D, e2);
+   /* Calculate intersection. */
+   const float3 e1 = v1 - v0;
+   const float3 e2 = v2 - v0;
+   const float3 s1 = cross(ray_D, e2);
 
const float divisor = dot(s1, e1);
-   if(UNLIKELY(divisor == 0.0f))
+   if(UNLIKELY(divisor == 0.0f)) {
return false;
+   }
+   const float inv_divisor = 1.0f/divisor;
 
-   const float invdivisor = 1.0f/divisor;
-
-   /* compute first barycentric coordinate */
+   /* Compute first barycentric coordinate. */
const float3 d = ray_P - v0;
-   const float u = dot(d, s1)*invdivisor;
-   if(u < 0.0f)
+   const float u = dot(d, s1)*inv_divisor;
+   if(u < 0.0f) {
return false;
-
-   /* Compute second barycentric coordinate */
+   }
+   /* Compute second barycentric coordinate. */

[Bf-blender-cvs] [5c06ff8bb9] master: Cycles: Cleanup, remove unused function

2017-03-23 Thread Sergey Sharybin
Commit: 5c06ff8bb96d014dda33874d357ecb4652558998
Author: Sergey Sharybin
Date:   Thu Mar 23 12:04:49 2017 +0100
Branches: master
https://developer.blender.org/rB5c06ff8bb96d014dda33874d357ecb4652558998

Cycles: Cleanup, remove unused function

===

M   intern/cycles/util/util_math.h

===

diff --git a/intern/cycles/util/util_math.h b/intern/cycles/util/util_math.h
index 27d4ae510c..da18ae907a 100644
--- a/intern/cycles/util/util_math.h
+++ b/intern/cycles/util/util_math.h
@@ -1514,49 +1514,6 @@ ccl_device bool ray_aligned_disk_intersect(
return true;
 }
 
-ccl_device bool ray_triangle_intersect(
-   float3 ray_P, float3 ray_D, float ray_t,
-   float3 v0, float3 v1, float3 v2,
-   float3 *isect_P, float *isect_t)
-{
-   /* Calculate intersection */
-   float3 e1 = v1 - v0;
-   float3 e2 = v2 - v0;
-   float3 s1 = cross(ray_D, e2);
-
-   const float divisor = dot(s1, e1);
-   if(UNLIKELY(divisor == 0.0f))
-   return false;
-
-   const float invdivisor = 1.0f/divisor;
-
-   /* compute first barycentric coordinate */
-   const float3 d = ray_P - v0;
-   const float u = dot(d, s1)*invdivisor;
-   if(u < 0.0f)
-   return false;
-
-   /* Compute second barycentric coordinate */
-   const float3 s2 = cross(d, e1);
-   const float v = dot(ray_D, s2)*invdivisor;
-   if(v < 0.0f)
-   return false;
-
-   const float b0 = 1.0f - u - v;
-   if(b0 < 0.0f)
-   return false;
-
-   /* compute t to intersection point */
-   const float t = dot(e2, s2)*invdivisor;
-   if(t < 0.0f || t > ray_t)
-   return false;
-
-   *isect_t = t;
-   *isect_P = ray_P + ray_D*t;
-
-   return true;
-}
-
 ccl_device_inline bool ray_triangle_intersect_uv(
 float3 ray_P, float3 ray_D, float ray_t,
 float3 v0, float3 v1, float3 v2,

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [e8ff06186e] master: Cycles: Cleanup, inline AVX register construction from kernel global data

2017-03-23 Thread Sergey Sharybin
Commit: e8ff06186ee031e67e554467ced7cd16ac34af94
Author: Sergey Sharybin
Date:   Thu Mar 23 12:41:33 2017 +0100
Branches: master
https://developer.blender.org/rBe8ff06186ee031e67e554467ced7cd16ac34af94

Cycles: Cleanup, inline AVX register construction from kernel global data

Currently should be no functional changes, preparing for some upcoming refactor.

===

M   intern/cycles/kernel/geom/geom_triangle_intersect.h
M   intern/cycles/kernel/kernel_compat_cpu.h

===

diff --git a/intern/cycles/kernel/geom/geom_triangle_intersect.h 
b/intern/cycles/kernel/geom/geom_triangle_intersect.h
index 4d234dd62b..4f4ee93c07 100644
--- a/intern/cycles/kernel/geom/geom_triangle_intersect.h
+++ b/intern/cycles/kernel/geom/geom_triangle_intersect.h
@@ -123,8 +123,9 @@ ccl_device_inline bool triangle_intersect(KernelGlobals *kg,
 #if defined(__KERNEL_AVX2__) && defined(__KERNEL_SSE__)
const avxf avxf_P(P.m128, P.m128);
 
-   const avxf tri_ab = kernel_tex_fetch_avxf(__prim_tri_verts, tri_vindex 
+ 0);
-   const avxf tri_bc = kernel_tex_fetch_avxf(__prim_tri_verts, tri_vindex 
+ 1);
+   const ssef *ssef_verts = (ssef*)>__prim_tri_verts.data[tri_vindex];
+   const avxf tri_ab = _mm256_loadu_ps((float *)(ssef_verts));
+   const avxf tri_bc = _mm256_loadu_ps((float *)(ssef_verts + 1));
 
const avxf AB = tri_ab - avxf_P;
const avxf BC = tri_bc - avxf_P;
diff --git a/intern/cycles/kernel/kernel_compat_cpu.h 
b/intern/cycles/kernel/kernel_compat_cpu.h
index e347a1eca1..96276f313f 100644
--- a/intern/cycles/kernel/kernel_compat_cpu.h
+++ b/intern/cycles/kernel/kernel_compat_cpu.h
@@ -87,9 +87,9 @@ template struct texture  {
ccl_always_inline avxf fetch_avxf(const int index)
{
kernel_assert(index >= 0 && (index+1) < width);
-   ssef *ssefData = (ssef*)data;
-   ssef *ssefNodeData = [index];
-   return _mm256_loadu_ps((float *)ssefNodeData);
+   ssef *ssef_data = (ssef*)data;
+   ssef *ssef_node_data = _data[index];
+   return _mm256_loadu_ps((float *)ssef_node_data);
}
 
 #endif

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [9fdc5345cd] uv_unwrapping_slim_algorithm: merging master into release

2017-03-23 Thread Aurel Gruber
Commit: 9fdc5345cde7381747c465e09bb404a749a34b06
Author: Aurel Gruber
Date:   Thu Mar 23 16:44:22 2017 +0100
Branches: uv_unwrapping_slim_algorithm
https://developer.blender.org/rB9fdc5345cde7381747c465e09bb404a749a34b06

merging master into release

===

M   intern/slim/area_compensation.h
M   intern/slim/geometry_data_retrieval.h
M   intern/slim/intern/area_compensation.cpp
M   intern/slim/intern/geometry_data_retrieval.cpp
M   intern/slim/intern/least_squares_relocator.cpp
M   intern/slim/intern/slim.cpp
M   intern/slim/intern/slim_capi.cpp
M   intern/slim/intern/slim_parametrizer.cpp
M   intern/slim/intern/uv_initializer.cpp
M   intern/slim/slim.h
M   intern/slim/slim_capi.h
M   intern/slim/slim_parametrizer.h
M   intern/slim/uv_initializer.h
M   source/blender/editors/uvedit/uvedit_parametrizer.c
M   source/blender/editors/uvedit/uvedit_parametrizer.h
M   source/blender/editors/uvedit/uvedit_unwrap_ops.c

===

diff --git a/intern/slim/area_compensation.h b/intern/slim/area_compensation.h
index d44bdc1961..9469fcca20 100644
--- a/intern/slim/area_compensation.h
+++ b/intern/slim/area_compensation.h
@@ -35,5 +35,5 @@ using namespace igl;
 
 namespace areacomp {
void correctMapSurfaceAreaIfNecessary(SLIMData *slimData);
-   void correctMeshSurfaceAreaIfNecessary(SLIMData *slimData, double 
relative_scale = 1.0);
+   void correctMeshSurfaceAreaIfNecessary(SLIMData *slimData);
 }
diff --git a/intern/slim/geometry_data_retrieval.h 
b/intern/slim/geometry_data_retrieval.h
index 21c7658233..2af4fce8e4 100644
--- a/intern/slim/geometry_data_retrieval.h
+++ b/intern/slim/geometry_data_retrieval.h
@@ -67,7 +67,7 @@ namespace retrieval {
double weightInfluence;
};
 
-   void constructSlimData(GeometryData , SLIMData *slimData, bool 
skipInitialization, int slim_reflection_mode);
+   void constructSlimData(GeometryData , SLIMData *slimData, bool 
skipInitialization, int slim_reflection_mode, double relativeScale);
 
void retrievePinnedVertices(GeometryData , bool 
borderVerticesArePinned);
 
diff --git a/intern/slim/intern/area_compensation.cpp 
b/intern/slim/intern/area_compensation.cpp
index f755e48c61..040cfae950 100644
--- a/intern/slim/intern/area_compensation.cpp
+++ b/intern/slim/intern/area_compensation.cpp
@@ -70,7 +70,7 @@ namespace areacomp {
correctGeometrySize(resultingAreaToExpectedAreaRatio, 
slimData->V_o, desiredRatio);
}
 
-   void correctMeshSurfaceAreaIfNecessary(SLIMData *slimData, double 
relative_scale){
+   void correctMeshSurfaceAreaIfNecessary(SLIMData *slimData){
int numberOfPinnedVertices = slimData->b.rows();
bool pinnedVerticesExist = numberOfPinnedVertices > 0;
bool needsAreaCorrection =  slimData->skipInitialization || 
pinnedVerticesExist;
@@ -78,7 +78,7 @@ namespace areacomp {
if(!needsAreaCorrection){
return;
}
-   //TODO: should instead compare area of convex hull / size of 
convex hull of both major and minor axis
+
double areaOfPreinitializedMap = 
computeSurfaceArea(slimData->V_o, slimData->F);
if (!areaOfPreinitializedMap){
return;
@@ -92,7 +92,7 @@ namespace areacomp {
double surfaceAreaOf3DMesh = computeSurfaceArea(slimData->V, 
slimData->F);
double surfaceAreaToMapAreaRatio = surfaceAreaOf3DMesh / 
areaOfPreinitializedMap;
 
-   double desiredRatio = relative_scale;
+   double desiredRatio = 1.0;
correctGeometrySize(surfaceAreaToMapAreaRatio, slimData->V, 
desiredRatio);
}
 }
diff --git a/intern/slim/intern/geometry_data_retrieval.cpp 
b/intern/slim/intern/geometry_data_retrieval.cpp
index 6a8fac223b..5cc418be15 100644
--- a/intern/slim/intern/geometry_data_retrieval.cpp
+++ b/intern/slim/intern/geometry_data_retrieval.cpp
@@ -97,9 +97,10 @@ namespace retrieval {
return (skipInitialization && hasValidPreinitializedMap(gd));
}
 
-   void constructSlimData(GeometryData , SLIMData *slimData, bool 
skipInitialization, int slim_reflection_mode){
+   void constructSlimData(GeometryData , SLIMData *slimData, bool 
skipInitialization, int slim_reflection_mode, double relativeScale){
slimData->skipInitialization = canInitializationBeSkipped(gd, 
skipInitialization);
slimData->weightInfluence = gd.weightInfluence;
+   slimData->relativeScale = relativeScale;
slimData->slim_reflection_mode = slim_reflection_mode;
slimData->withWeightedParameterization = 
gd.withWeightedParameteriztion;
setGeometryDataMatrices(gd, slimData);
diff --git 

[Bf-blender-cvs] [0475c0c41e] uv_unwrapping_slim_algorithm: UV Unwrapping SLIM reducing SLIM iterations per live-unwrap-step to 3, taking care of memory leaks, removing packing when minimizi-stretch w

2017-03-23 Thread Aurel Gruber
Commit: 0475c0c41e492cfbf6d2c5efb3601cbc19a0cc9c
Author: Aurel Gruber
Date:   Thu Mar 16 11:08:02 2017 +0100
Branches: uv_unwrapping_slim_algorithm
https://developer.blender.org/rB0475c0c41e492cfbf6d2c5efb3601cbc19a0cc9c

UV Unwrapping SLIM reducing SLIM iterations per live-unwrap-step to 3, taking 
care of memory leaks, removing packing when minimizi-stretch with non-fix border

===

M   intern/slim/intern/slim_parametrizer.cpp
M   source/blender/editors/uvedit/uvedit_unwrap_ops.c

===

diff --git a/intern/slim/intern/slim_parametrizer.cpp 
b/intern/slim/intern/slim_parametrizer.cpp
index e799dd70a6..225674149a 100644
--- a/intern/slim/intern/slim_parametrizer.cpp
+++ b/intern/slim/intern/slim_parametrizer.cpp
@@ -93,7 +93,7 @@ static void adjustPins(SLIMData *slimData, int n_pins, int* 
selectedPinnedVertex
Executes several iterations of SLIM when used with LiveUnwrap
  */
 void param_slim_live_unwrap(SLIMData *slimData, int n_pins, int* 
selectedPinnedVertexIndices, double *selectedPinnedVertexPositions2D) {
-   int numberOfIterations = 5;
+   int numberOfIterations = 3;
adjustPins(slimData, n_pins, selectedPinnedVertexIndices, 
selectedPinnedVertexPositions2D);
// recompute current energy
recompute_energy(*slimData);
diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c 
b/source/blender/editors/uvedit/uvedit_unwrap_ops.c
index b530e554fd..27b9e55a4f 100644
--- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c
+++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c
@@ -662,11 +662,7 @@ static void minimize_stretch_iteration(bContext *C, 
wmOperator *op, bool interac
 
//  Assign new UVs back to each vertex
set_uv_param_slim(mss->handle, rs->mt);
-   if (!(mss->fixBorder)) {
-   if (mss->noPins){
-   param_pack(mss->handle, 0, false);
-   }
-   }
+
param_flush(mss->handle);
 
 
@@ -702,12 +698,6 @@ static void minimize_stretch_exit(bContext *C, wmOperator 
*op, bool cancel)
 
set_uv_param_slim(mss->handle, rs->mt);
 
-   if (!(mss->fixBorder)) {
-   if (mss->noPins){
-   param_pack(mss->handle, 0, false);
-   }
-   }
-
param_flush(mss->handle);
param_delete(mss->handle);
 
@@ -999,6 +989,9 @@ void ED_uvedit_live_unwrap_re_solve(void)
  
pinned_vertex_indices,
  
pinned_vertex_positions_2D);
SLIM_transfer_uvs_blended(rs->mt, slimPtr, 
chartNr, 0);
+
+   MEM_freeN(pinned_vertex_indices);
+   MEM_freeN(pinned_vertex_positions_2D);
}
 
//  Assign new UVs back to each vertex

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [e04970b392] master: Fix player stubs (tm)

2017-03-23 Thread Jens Verwiebe
Commit: e04970b392cdce4cf7b2d89b6cb3e7b623629103
Author: Jens Verwiebe
Date:   Thu Mar 23 15:47:23 2017 +0100
Branches: master
https://developer.blender.org/rBe04970b392cdce4cf7b2d89b6cb3e7b623629103

Fix player stubs (tm)

===

M   source/blenderplayer/bad_level_call_stubs/stubs.c

===

diff --git a/source/blenderplayer/bad_level_call_stubs/stubs.c 
b/source/blenderplayer/bad_level_call_stubs/stubs.c
index 3b07d0acf5..d659f5c1a8 100644
--- a/source/blenderplayer/bad_level_call_stubs/stubs.c
+++ b/source/blenderplayer/bad_level_call_stubs/stubs.c
@@ -737,7 +737,8 @@ int collada_export(struct Scene *sce,
int use_blender_profile,
int sort_by_name,
BC_export_transformation_type export_transformation_type,
-   int open_sim) RET_ZERO
+   int open_sim,
+   int keep_bind_info) RET_ZERO
 
 void ED_mesh_calc_tessface(struct Mesh *mesh, bool free_mpoly) RET_NONE

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [3de5e71501] blender2.8: GLSL viewport: Fix shader compilation error.

2017-03-23 Thread Clément Foucault
Commit: 3de5e7150194717f5977e437aaf966f1db7a900a
Author: Clément Foucault
Date:   Thu Mar 23 15:07:33 2017 +0100
Branches: blender2.8
https://developer.blender.org/rB3de5e7150194717f5977e437aaf966f1db7a900a

GLSL viewport: Fix shader compilation error.

Moved the global lib insertion to the draw manager instead

===

M   source/blender/draw/intern/draw_manager.c
M   source/blender/gpu/intern/gpu_shader.c

===

diff --git a/source/blender/draw/intern/draw_manager.c 
b/source/blender/draw/intern/draw_manager.c
index 2146e53df6..ee51ec4276 100644
--- a/source/blender/draw/intern/draw_manager.c
+++ b/source/blender/draw/intern/draw_manager.c
@@ -25,6 +25,7 @@
 
 #include 
 
+#include "BLI_dynstr.h"
 #include "BLI_listbase.h"
 #include "BLI_rect.h"
 #include "BLI_string.h"
@@ -318,7 +319,40 @@ GPUShader *DRW_shader_create(const char *vert, const char 
*geom, const char *fra
 
 GPUShader *DRW_shader_create_with_lib(const char *vert, const char *geom, 
const char *frag, const char *lib, const char *defines)
 {
-   return GPU_shader_create(vert, frag, geom, lib, defines, 0, 0, 0);
+   GPUShader *sh;
+   char *vert_with_lib = NULL;
+   char *frag_with_lib = NULL;
+   char *geom_with_lib = NULL;
+
+   DynStr *ds_vert = BLI_dynstr_new();
+   BLI_dynstr_append(ds_vert, lib);
+   BLI_dynstr_append(ds_vert, vert);
+   vert_with_lib = BLI_dynstr_get_cstring(ds_vert);
+   BLI_dynstr_free(ds_vert);
+
+   DynStr *ds_frag = BLI_dynstr_new();
+   BLI_dynstr_append(ds_frag, lib);
+   BLI_dynstr_append(ds_frag, frag);
+   frag_with_lib = BLI_dynstr_get_cstring(ds_frag);
+   BLI_dynstr_free(ds_frag);
+
+   if (geom) {
+   DynStr *ds_geom = BLI_dynstr_new();
+   BLI_dynstr_append(ds_geom, lib);
+   BLI_dynstr_append(ds_geom, geom);
+   geom_with_lib = BLI_dynstr_get_cstring(ds_geom);
+   BLI_dynstr_free(ds_geom);
+   }
+
+   sh = GPU_shader_create(vert_with_lib, frag_with_lib, geom_with_lib, 
NULL, defines, 0, 0, 0);
+
+   MEM_freeN(vert_with_lib);
+   MEM_freeN(frag_with_lib);
+   if (geom) {
+   MEM_freeN(geom_with_lib);
+   }
+
+   return sh;
 }
 
 GPUShader *DRW_shader_create_2D(const char *frag, const char *defines)
diff --git a/source/blender/gpu/intern/gpu_shader.c 
b/source/blender/gpu/intern/gpu_shader.c
index 0546e18866..d2d8011829 100644
--- a/source/blender/gpu/intern/gpu_shader.c
+++ b/source/blender/gpu/intern/gpu_shader.c
@@ -371,7 +371,6 @@ GPUShader *GPU_shader_create_ex(const char *vertexcode,
source[num_source++] = standard_defines;
 
if (defines) source[num_source++] = defines;
-   if (libcode) source[num_source++] = libcode;
source[num_source++] = vertexcode;
 
glAttachShader(shader->program, shader->vertex);
@@ -437,7 +436,6 @@ GPUShader *GPU_shader_create_ex(const char *vertexcode,
source[num_source++] = standard_defines;
 
if (defines) source[num_source++] = defines;
-   if (libcode) source[num_source++] = libcode;
source[num_source++] = geocode;
 
glAttachShader(shader->program, shader->geometry);

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [092d673689] master: Added new option for storing bindpose matrix, see T50412

2017-03-23 Thread Gaia Clary
Commit: 092d67368955d93392528eddd4bbc452adf04893
Author: Gaia Clary
Date:   Thu Mar 23 00:07:05 2017 +0100
Branches: master
https://developer.blender.org/rB092d67368955d93392528eddd4bbc452adf04893

Added new option for storing bindpose matrix, see T50412

===

M   source/blender/collada/ArmatureImporter.cpp
M   source/blender/collada/ExportSettings.h
M   source/blender/collada/ImportSettings.h
M   source/blender/collada/collada.cpp
M   source/blender/collada/collada.h
M   source/blender/editors/io/io_collada.c
M   source/blender/makesrna/intern/rna_scene_api.c

===

diff --git a/source/blender/collada/ArmatureImporter.cpp 
b/source/blender/collada/ArmatureImporter.cpp
index 398c4a2c10..2e4a7dfebc 100644
--- a/source/blender/collada/ArmatureImporter.cpp
+++ b/source/blender/collada/ArmatureImporter.cpp
@@ -93,6 +93,7 @@ int ArmatureImporter::create_bone(SkinInfo *skin, 
COLLADAFW::Node *node, EditBon
 {
float mat[4][4];
float joint_inv_bind_mat[4][4];
+   float joint_bind_mat[4][4];
int chain_length = 0;
 
//Checking if bone is already made.
@@ -116,7 +117,7 @@ int ArmatureImporter::create_bone(SkinInfo *skin, 
COLLADAFW::Node *node, EditBon
 
// get original world-space matrix
invert_m4_m4(mat, joint_inv_bind_mat);
-
+   copy_m4_m4(joint_bind_mat, mat);
// And make local to armature
Object *ob_arm = skin->BKE_armature_from_object();
if (ob_arm) {
@@ -165,6 +166,14 @@ int ArmatureImporter::create_bone(SkinInfo *skin, 
COLLADAFW::Node *node, EditBon
bone->roll = angle;
}
copy_v3_v3(bone->head, mat[3]);
+
+   if (bone_is_skinned)
+   {
+   float rest_mat[4][4];
+   get_node_mat(rest_mat, node, NULL, NULL, NULL);
+   bc_create_bindpose_properties(this->import_settings, bone, 
joint_bind_mat, rest_mat);
+   }
+
add_v3_v3v3(bone->tail, bone->head, tail); //tail must be non zero
 
/* find smallest bone length in armature (used later for leaf bone 
length) */
@@ -266,7 +275,6 @@ void ArmatureImporter::fix_parent_connect(bArmature 
*armature, Bone *bone)
 
 }
 
-
 void ArmatureImporter::connect_bone_chains(bArmature *armature, Bone 
*parentbone, int clip)
 {
BoneExtensionMap _bones = 
bone_extension_manager.getExtensionMap(armature);
@@ -302,7 +310,6 @@ void ArmatureImporter::connect_bone_chains(bArmature 
*armature, Bone *parentbone
EditBone *pebone = bc_get_edit_bone(armature, parentbone->name);
EditBone *cebone = bc_get_edit_bone(armature, 
dominant_child->get_name());
if (pebone && !(cebone->flag & BONE_CONNECTED)) {
-
float vec[3];
sub_v3_v3v3(vec, cebone->head, pebone->head);
 
diff --git a/source/blender/collada/ExportSettings.h 
b/source/blender/collada/ExportSettings.h
index 9451cac9da..03e380dc19 100644
--- a/source/blender/collada/ExportSettings.h
+++ b/source/blender/collada/ExportSettings.h
@@ -51,7 +51,9 @@ public:
bool use_blender_profile;
bool sort_by_name;
BC_export_transformation_type export_transformation_type;
+
bool open_sim;
+   bool keep_bind_info;
 
char *filepath;
LinkNode *export_set;
diff --git a/source/blender/collada/ImportSettings.h 
b/source/blender/collada/ImportSettings.h
index 2c52d73e75..4a2d4e8046 100644
--- a/source/blender/collada/ImportSettings.h
+++ b/source/blender/collada/ImportSettings.h
@@ -37,6 +37,7 @@ public:
bool fix_orientation;
int  min_chain_length;
char *filepath;
+   bool keep_bind_info;
 };
 
 #endif
diff --git a/source/blender/collada/collada.cpp 
b/source/blender/collada/collada.cpp
index fe8b1d2320..c0784ca8eb 100644
--- a/source/blender/collada/collada.cpp
+++ b/source/blender/collada/collada.cpp
@@ -48,7 +48,8 @@ int collada_import(bContext *C,
   int find_chains,
   int auto_connect,
   int fix_orientation,
-  int min_chain_length)
+  int min_chain_length,
+  int keep_bind_info)
 {
 
ImportSettings import_settings;
@@ -58,6 +59,7 @@ int collada_import(bContext *C,
import_settings.find_chains  = find_chains != 0;
import_settings.fix_orientation  = fix_orientation != 0;
import_settings.min_chain_length = min_chain_length;
+   import_settings.keep_bind_info = keep_bind_info;
 
DocumentImporter imp(C, _settings);
if (imp.import()) return 1;
@@ -87,7 +89,9 @@ int collada_export(Scene *sce,

[Bf-blender-cvs] [6cfa962986] master: Collada - removed TransformBase baseclass (not needed for anything)

2017-03-23 Thread Gaia Clary
Commit: 6cfa9629861b44b6f5438047502a9a72ded66938
Author: Gaia Clary
Date:   Thu Mar 23 12:45:40 2017 +0100
Branches: master
https://developer.blender.org/rB6cfa9629861b44b6f5438047502a9a72ded66938

Collada - removed TransformBase baseclass (not needed for anything)

===

M   source/blender/collada/AnimationImporter.cpp
M   source/blender/collada/TransformReader.h
M   source/blender/collada/TransformWriter.cpp
M   source/blender/collada/TransformWriter.h
M   source/blender/collada/collada_internal.cpp
M   source/blender/collada/collada_internal.h

===

diff --git a/source/blender/collada/AnimationImporter.cpp 
b/source/blender/collada/AnimationImporter.cpp
index 3801c9300d..bd47ee0214 100644
--- a/source/blender/collada/AnimationImporter.cpp
+++ b/source/blender/collada/AnimationImporter.cpp
@@ -1934,7 +1934,7 @@ Object 
*AnimationImporter::get_joint_object(COLLADAFW::Node *root, COLLADAFW::No
mul_m4_m4m4(mat, ipar, temp);
}
 
-   TransformBase::decompose(mat, job->loc, NULL, job->quat, 
job->size);
+   bc_decompose(mat, job->loc, NULL, job->quat, job->size);
 
if (par_job) {
job->parent = par_job;
diff --git a/source/blender/collada/TransformReader.h 
b/source/blender/collada/TransformReader.h
index c598c466c9..08bb17ccac 100644
--- a/source/blender/collada/TransformReader.h
+++ b/source/blender/collada/TransformReader.h
@@ -43,7 +43,7 @@
 
 //struct Object;
 
-class TransformReader : public TransformBase
+class TransformReader
 {
 protected:
 
diff --git a/source/blender/collada/TransformWriter.cpp 
b/source/blender/collada/TransformWriter.cpp
index 908111ebae..b7eeff3b07 100644
--- a/source/blender/collada/TransformWriter.cpp
+++ b/source/blender/collada/TransformWriter.cpp
@@ -27,11 +27,10 @@
 
 
 #include "BKE_object.h"
+#include "BLI_math.h"
 
 #include "TransformWriter.h"
 
-#include "BLI_math.h"
-
 void TransformWriter::add_node_transform(COLLADASW::Node& node, float 
mat[4][4], float parent_mat[4][4])
 {
float loc[3], rot[3], scale[3];
@@ -51,7 +50,7 @@ void TransformWriter::add_node_transform(COLLADASW::Node& 
node, float mat[4][4],
converter->mat4_to_dae_double(dmat, local);
delete converter;
 
-   TransformBase::decompose(local, loc, rot, NULL, scale);
+   bc_decompose(local, loc, rot, NULL, scale);
 
if (node.getType() == COLLADASW::Node::JOINT) {
// XXX Why are joints handled differently ?
@@ -116,7 +115,7 @@ void 
TransformWriter::add_node_transform_ob(COLLADASW::Node& node, Object *ob, B
case BC_TRANSFORMATION_TYPE_TRANSROTLOC:
{
float loc[3], rot[3], scale[3];
-   TransformBase::decompose(f_obmat, loc, rot, NULL, 
scale);
+   bc_decompose(f_obmat, loc, rot, NULL, scale);
add_transform(node, loc, rot, scale); 
break;
}
diff --git a/source/blender/collada/TransformWriter.h 
b/source/blender/collada/TransformWriter.h
index 7f69a4b9c9..5bb13d4aac 100644
--- a/source/blender/collada/TransformWriter.h
+++ b/source/blender/collada/TransformWriter.h
@@ -33,9 +33,10 @@
 #include "DNA_object_types.h"
 
 #include "collada_internal.h"
+#include "collada_utils.h"
 #include "collada.h"
 
-class TransformWriter : protected TransformBase
+class TransformWriter
 {
 protected:
void add_node_transform(COLLADASW::Node& node, float mat[4][4], float 
parent_mat[4][4]);
diff --git a/source/blender/collada/collada_internal.cpp 
b/source/blender/collada/collada_internal.cpp
index 70b44ebc22..6ebde6bd77 100644
--- a/source/blender/collada/collada_internal.cpp
+++ b/source/blender/collada/collada_internal.cpp
@@ -162,18 +162,6 @@ void UnitConverter::calculate_scale(Scene )
size_to_mat4(scale_mat4, rescale);
 }
 
-void TransformBase::decompose(float mat[4][4], float *loc, float eul[3], float 
quat[4], float *size)
-{
-   mat4_to_size(size, mat);
-   if (eul) {
-   mat4_to_eul(eul, mat);
-   }
-   if (quat) {
-   mat4_to_quat(quat, mat);
-   }
-   copy_v3_v3(loc, mat[3]);
-}
-
 /**
  * Translation map.
  * Used to translate every COLLADA id to a valid id, no matter what "wrong" 
letters may be
diff --git a/source/blender/collada/collada_internal.h 
b/source/blender/collada/collada_internal.h
index 482dbf9ab3..1c7aa160f5 100644
--- a/source/blender/collada/collada_internal.h
+++ b/source/blender/collada/collada_internal.h
@@ -85,12 +85,6 @@ public:
 
 };
 
-class TransformBase
-{
-public:
-   void decompose(float mat[4][4], float *loc, float eul[3], float 
quat[4], float *size);
-};
-
 extern void clear_global_id_map();
 /** Look at documentation of translate_map */
 extern std::string 

[Bf-blender-cvs] [2c78b0c71f] master: Collada - Export: now use bind_mat and rest_mat custom properties (when the use_bind_info option is enabled and the properties exist)

2017-03-23 Thread Gaia Clary
Commit: 2c78b0c71fc0a31016d081ee6a5a8fafc27c48cd
Author: Gaia Clary
Date:   Thu Mar 23 14:11:55 2017 +0100
Branches: master
https://developer.blender.org/rB2c78b0c71fc0a31016d081ee6a5a8fafc27c48cd

Collada - Export: now use bind_mat and rest_mat custom properties (when the 
use_bind_info option is enabled and the properties exist)

===

M   source/blender/collada/ArmatureExporter.cpp

===

diff --git a/source/blender/collada/ArmatureExporter.cpp 
b/source/blender/collada/ArmatureExporter.cpp
index 40065956ec..49722873a9 100644
--- a/source/blender/collada/ArmatureExporter.cpp
+++ b/source/blender/collada/ArmatureExporter.cpp
@@ -256,47 +256,57 @@ void ArmatureExporter::add_bone_transform(Object *ob_arm, 
Bone *bone, COLLADASW:
//bPoseChannel *pchan = BKE_pose_channel_find_name(ob_arm->pose, 
bone->name);
 
float mat[4][4];
+   float bone_rest_mat[4][4]; /* derived from bone->arm_mat */
+   float parent_rest_mat[4][4]; /* derived from bone->parent->arm_mat */
 
-   if (bone->parent) {
-   // get bone-space matrix from parent pose
-   /*bPoseChannel *parchan = 
BKE_pose_channel_find_name(ob_arm->pose, bone->parent->name);
-   float invpar[4][4];
-   invert_m4_m4(invpar, parchan->pose_mat);
-   mul_m4_m4m4(mat, invpar, pchan->pose_mat);*/
-   
-   float invpar[4][4];
-   invert_m4_m4(invpar, bone->parent->arm_mat);
-   mul_m4_m4m4(mat, invpar, bone->arm_mat);
+   bool has_restmat = bc_get_property_matrix(bone, "rest_mat", mat);
 
-   }
-   else {
+   if (!has_restmat) {
+
+   /* Have no restpose matrix stored, try old style <= Blender 
2.78 */

-   //copy_m4_m4(mat, pchan->pose_mat);
-   //pose mat is object space
-   //New change: export bone->arm_mat
-   copy_m4_m4(mat, bone->arm_mat);
-   }
+   bc_create_restpose_mat(this->export_settings, bone, 
bone_rest_mat, bone->arm_mat, true);
 
-   // OPEN_SIM_COMPATIBILITY
-   if (export_settings->open_sim) {
-   // Remove rotations vs armature from transform
-   // parent_rest_rot * mat * irest_rot
-   float temp[4][4];
-   copy_m4_m4(temp, bone->arm_mat);
-   temp[3][0] = temp[3][1] = temp[3][2] = 0.0f;
-   invert_m4(temp);
+   if (bone->parent) {
+   // get bone-space matrix from parent pose
+   /*bPoseChannel *parchan = 
BKE_pose_channel_find_name(ob_arm->pose, bone->parent->name);
+   float invpar[4][4];
+   invert_m4_m4(invpar, parchan->pose_mat);
+   mul_m4_m4m4(mat, invpar, pchan->pose_mat);*/
+   float invpar[4][4];
+   bc_create_restpose_mat(this->export_settings, 
bone->parent, parent_rest_mat, bone->parent->arm_mat, true);
 
-   mul_m4_m4m4(mat, mat, temp);
+   invert_m4_m4(invpar, parent_rest_mat);
+   mul_m4_m4m4(mat, invpar, bone_rest_mat);
 
-   if (bone->parent) {
-   copy_m4_m4(temp, bone->parent->arm_mat);
+   }
+   else {
+   copy_m4_m4(mat, bone_rest_mat);
+   }
+
+   // OPEN_SIM_COMPATIBILITY
+   if (export_settings->open_sim) {
+   // Remove rotations vs armature from transform
+   // parent_rest_rot * mat * irest_rot
+   float temp[4][4];
+   copy_m4_m4(temp, bone_rest_mat);
temp[3][0] = temp[3][1] = temp[3][2] = 0.0f;
+   invert_m4(temp);
+
+   mul_m4_m4m4(mat, mat, temp);
 
-   mul_m4_m4m4(mat, temp, mat);
+   if (bone->parent) {
+   copy_m4_m4(temp, parent_rest_mat);
+   temp[3][0] = temp[3][1] = temp[3][2] = 0.0f;
+
+   mul_m4_m4m4(mat, temp, mat);
+   }
}
}
 
+   bc_sanitize_mat(mat, 6); // XXX: Make this optional ?
TransformWriter::add_node_transform(node, mat, NULL);
+
 }
 
 std::string ArmatureExporter::get_controller_id(Object *ob_arm, Object *ob)

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [ec3989441f] master: fix: collada - Connected bones get their tails set to wrong location when fix leaf nodes option is enabled

2017-03-23 Thread Gaia Clary
Commit: ec3989441f8ad514a7110587e77611573c65a409
Author: Gaia Clary
Date:   Tue Mar 21 17:24:39 2017 +0100
Branches: master
https://developer.blender.org/rBec3989441f8ad514a7110587e77611573c65a409

fix: collada - Connected bones get their tails set to wrong location when fix 
leaf nodes option is enabled

===

M   source/blender/collada/ArmatureImporter.cpp

===

diff --git a/source/blender/collada/ArmatureImporter.cpp 
b/source/blender/collada/ArmatureImporter.cpp
index d5c1af9347..a365b5ca35 100644
--- a/source/blender/collada/ArmatureImporter.cpp
+++ b/source/blender/collada/ArmatureImporter.cpp
@@ -324,10 +324,15 @@ void ArmatureImporter::connect_bone_chains(bArmature 
*armature, Bone *parentbone
if (len_squared_v3(vec) > MINIMUM_BONE_LENGTH)
{
copy_v3_v3(pebone->tail, cebone->head);
+   pbe->set_tail(pebone->tail); /* to make 
fix_leafbone happy ...*/
if (pbe && pbe->get_chain_length() >= 
this->import_settings->min_chain_length) {
+
+   BoneExtended *cbe = 
extended_bones[cebone->name];
+   cbe->set_use_connect(true);
+
cebone->flag |= BONE_CONNECTED;
-   printf("Connecting chain: parent %s --> 
%s (child)\n", pebone->name, cebone->name);
pbe->set_leaf_bone(false);
+   printf("Connect Bone chain: parent (%s 
--> %s) child)\n", pebone->name, cebone->name);
}
}
}

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [33e32c341a] master: collada: add extern 'C' for c header includes

2017-03-23 Thread Gaia Clary
Commit: 33e32c341aa0139f8ac03006d9b14c7df6277d65
Author: Gaia Clary
Date:   Tue Mar 21 17:42:34 2017 +0100
Branches: master
https://developer.blender.org/rB33e32c341aa0139f8ac03006d9b14c7df6277d65

collada: add extern 'C' for c header includes

===

M   source/blender/collada/ArmatureImporter.cpp

===

diff --git a/source/blender/collada/ArmatureImporter.cpp 
b/source/blender/collada/ArmatureImporter.cpp
index a365b5ca35..6a8fe2e13f 100644
--- a/source/blender/collada/ArmatureImporter.cpp
+++ b/source/blender/collada/ArmatureImporter.cpp
@@ -32,6 +32,7 @@
 
 #include "COLLADAFWUniqueId.h"
 
+extern "C" {
 #include "BKE_action.h"
 #include "BKE_depsgraph.h"
 #include "BKE_object.h"
@@ -39,6 +40,7 @@
 #include "BLI_string.h"
 #include "BLI_listbase.h"
 #include "ED_armature.h"
+}
 
 #include "ArmatureImporter.h"

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [51d4743033] master: Collada - Added support for custom bind matrix (using new bind_mat custom property)

2017-03-23 Thread Gaia Clary
Commit: 51d4743033a39a90e60cdad3dd30ffa834d999de
Author: Gaia Clary
Date:   Thu Mar 23 12:53:56 2017 +0100
Branches: master
https://developer.blender.org/rB51d4743033a39a90e60cdad3dd30ffa834d999de

Collada - Added support for custom bind matrix (using new bind_mat custom 
property)

===

M   source/blender/collada/ControllerExporter.cpp

===

diff --git a/source/blender/collada/ControllerExporter.cpp 
b/source/blender/collada/ControllerExporter.cpp
index a868adc1e6..62a474b518 100644
--- a/source/blender/collada/ControllerExporter.cpp
+++ b/source/blender/collada/ControllerExporter.cpp
@@ -580,30 +580,35 @@ std::string 
ControllerExporter::add_inv_bind_mats_source(Object *ob_arm, ListBas
float world[4][4];
float inv_bind_mat[4][4];
 
+   float bind_mat[4][4]; /* derived from bone->arm_mat */
+
+   bool has_bindmat = bc_get_property_matrix(pchan->bone, 
"bind_mat", bind_mat);

-   // SL/OPEN_SIM COMPATIBILITY
-   if (export_settings->open_sim) {
-   // Only translations, no rotation vs armature
-   float temp[4][4];
-   unit_m4(temp);
-   copy_v3_v3(temp[3], pchan->bone->arm_mat[3]);
-   mul_m4_m4m4(world, ob_arm->obmat, temp);
-
-   // Add Maya restpose matrix (if defined as 
properties)
-   float restpose_mat[4][4];
-   create_restpose_mat(pchan->bone, restpose_mat);
-   mul_m4_m4m4(world, world, restpose_mat);
+   if (!has_bindmat) {
 
-   }
-   else {
-   // make world-space matrix, arm_mat is 
armature-space
-   mul_m4_m4m4(world, ob_arm->obmat, 
pchan->bone->arm_mat);
+   /* Have no bind matrix stored, try old style <= 
Blender 2.78 */
+
+   bc_create_restpose_mat(this->export_settings, 
pchan->bone, bind_mat, pchan->bone->arm_mat, true);
+
+   // SL/OPEN_SIM COMPATIBILITY
+   if (export_settings->open_sim) {
+
+   float loc[3];
+   float rot[3] = { 0, 0, 0 };
+   float scale[3];
+   bc_decompose(bind_mat, loc, NULL, NULL, 
scale);
+
+   // Only translations, no rotation vs 
armature
+   loc_eulO_size_to_mat4(bind_mat, loc, 
rot, scale, 6);
+   }
}
 
+   // make world-space matrix (bind_mat is armature-space)
+   mul_m4_m4m4(world, ob_arm->obmat, bind_mat);
 
invert_m4_m4(mat, world);
converter.mat4_to_dae(inv_bind_mat, mat);
-
+   bc_sanitize_mat(inv_bind_mat, 6); // XXX: Make this 
optional ?
source.appendValues(inv_bind_mat);
}
}

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [7c094f6079] master: Collada - Added some helper functions into collada_utils, for common usage in the collada module

2017-03-23 Thread Gaia Clary
Commit: 7c094f6079aca16b02571c96ee4a4ed30b4d610f
Author: Gaia Clary
Date:   Thu Mar 23 12:38:41 2017 +0100
Branches: master
https://developer.blender.org/rB7c094f6079aca16b02571c96ee4a4ed30b4d610f

Collada - Added some helper functions into collada_utils, for common usage in 
the collada module

===

M   source/blender/collada/collada_utils.cpp
M   source/blender/collada/collada_utils.h

===

diff --git a/source/blender/collada/collada_utils.cpp 
b/source/blender/collada/collada_utils.cpp
index 2efa8b21d8..407f079901 100644
--- a/source/blender/collada/collada_utils.cpp
+++ b/source/blender/collada/collada_utils.cpp
@@ -33,6 +33,7 @@
 #include "COLLADAFWMeshVertexData.h"
 
 #include "collada_utils.h"
+#include "ExportSettings.h"
 
 extern "C" {
 #include "DNA_modifier_types.h"
@@ -352,6 +353,28 @@ void bc_match_scale(std::vector *objects_done,
}
 }
 
+/*
+Convenience function to get only the needed components of a matrix
+*/
+void bc_decompose(float mat[4][4], float *loc, float eul[3], float quat[4], 
float *size)
+{
+   if (size) {
+   mat4_to_size(size, mat);
+   }
+
+   if (eul) {
+   mat4_to_eul(eul, mat);
+   }
+
+   if (quat) {
+   mat4_to_quat(quat, mat);
+   }
+
+   if (loc) {
+   copy_v3_v3(loc, mat[3]);
+   }
+}
+
 void bc_triangulate_mesh(Mesh *me)
 {
bool use_beauty  = false;
@@ -612,3 +635,212 @@ int BoneExtended::get_use_connect()
 {
return this->use_connect;
 }
+
+/**
+* Stores a 4*4 matrix as a custom bone property array of size 16
+*/
+void bc_set_IDPropertyMatrix(EditBone *ebone, const char *key, float mat[4][4])
+{
+   IDProperty *idgroup = (IDProperty *)ebone->prop;
+   if (idgroup == NULL)
+   {
+   IDPropertyTemplate val = { 0 };
+   idgroup = IDP_New(IDP_GROUP, , "RNA_EditBone ID 
properties");
+   ebone->prop = idgroup;
+   }
+
+   IDPropertyTemplate val = { 0 };
+   val.array.len = 16;
+   val.array.type = IDP_FLOAT;
+
+   IDProperty *data = IDP_New(IDP_ARRAY, , key);
+   float *array = (float *)IDP_Array(data);
+   for (int i = 0; i < 4; i++)
+   for (int j = 0; j < 4; j++)
+   array[4 * i + j] = mat[i][j];
+
+   IDP_AddToGroup(idgroup, data);
+}
+
+#if 0
+/**
+* Stores a Float value as a custom bone property
+*
+* Note: This function is currently not needed. Keep for future usage
+*/
+static void bc_set_IDProperty(EditBone *ebone, const char *key, float value)
+{
+   if (ebone->prop == NULL)
+   {
+   IDPropertyTemplate val = { 0 };
+   ebone->prop = IDP_New(IDP_GROUP, , "RNA_EditBone ID 
properties");
+   }
+
+   IDProperty *pgroup = (IDProperty *)ebone->prop;
+   IDPropertyTemplate val = { 0 };
+   IDProperty *prop = IDP_New(IDP_FLOAT, , key);
+   IDP_Float(prop) = value;
+   IDP_AddToGroup(pgroup, prop);
+
+}
+#endif
+
+/*
+* Get a custom property when it exists.
+* This function is also used to check if a property exists.
+*/
+IDProperty *bc_get_IDProperty(Bone *bone, std::string key)
+{
+   return (bone->prop == NULL) ? NULL : 
IDP_GetPropertyFromGroup(bone->prop, key.c_str());
+}
+
+/**
+* Read a custom bone property and convert to float
+* Return def if the property does not exist.
+*/
+float bc_get_property(Bone *bone, std::string key, float def)
+{
+   float result = def;
+   IDProperty *property = bc_get_IDProperty(bone, key);
+   if (property) {
+   switch (property->type) {
+   case IDP_INT:
+   result = (float)(IDP_Int(property));
+   break;
+   case IDP_FLOAT:
+   result = (float)(IDP_Float(property));
+   break;
+   case IDP_DOUBLE:
+   result = (float)(IDP_Double(property));
+   break;
+   default:
+   result = def;
+   }
+   }
+   return result;
+}
+
+/**
+* Read a custom bone property and convert to matrix
+* Return true if conversion was succesfull
+* 
+* Return false if:
+* - the property does not exist
+* - is not an array of size 16
+*/
+bool bc_get_property_matrix(Bone *bone, std::string key, float mat[4][4])
+{
+   IDProperty *property = bc_get_IDProperty(bone, key);
+   if (property && property->type == IDP_ARRAY && property->len == 16) {
+   float *array = (float *)IDP_Array(property);
+   for (int i = 0; i < 4; i++)
+   for (int j = 0; j < 4; j++)
+   mat[i][j] = array[4 * i + j];
+   return true;
+   }
+   return false;
+}
+
+/**
+* get a vector that is stored in 3 custom properties (used in Blender <= 2.78)
+*/
+void 

[Bf-blender-cvs] [476f5c473a] master: Collada - remove no longer used functions (moved to collada_utils)

2017-03-23 Thread Gaia Clary
Commit: 476f5c473ac752d58922e1fefbcbb5e8078d178d
Author: Gaia Clary
Date:   Thu Mar 23 14:09:00 2017 +0100
Branches: master
https://developer.blender.org/rB476f5c473ac752d58922e1fefbcbb5e8078d178d

Collada - remove no longer used functions (moved to collada_utils)

===

M   source/blender/collada/ControllerExporter.cpp

===

diff --git a/source/blender/collada/ControllerExporter.cpp 
b/source/blender/collada/ControllerExporter.cpp
index 62a474b518..5444c9dfa6 100644
--- a/source/blender/collada/ControllerExporter.cpp
+++ b/source/blender/collada/ControllerExporter.cpp
@@ -463,81 +463,6 @@ std::string ControllerExporter::add_joints_source(Object 
*ob_arm, ListBase *defb
return source_id;
 }
 
-static float get_property(Bone *bone, const char *key, float def)
-{
-   float result = def;
-   if (bone->prop) {
-   IDProperty *property = IDP_GetPropertyFromGroup(bone->prop, 
key);
-   if (property) {
-   switch (property->type) {
-   case IDP_INT:
-   result = (float)(IDP_Int(property));
-   break;
-   case IDP_FLOAT:
-   result = (float)(IDP_Float(property));
-   break;
-   case IDP_DOUBLE:
-   result = (float)(IDP_Double(property));
-   break;
-   default:
-   result = def;
-   }
-   }
-   }
-   return result;
-}
-
-/**
- * This function creates an arbitrary rest pose matrix from
- * data provided as custom properties. This is a workaround
- * for support of maya's restpose matrix which can be arbitrary
- * in opposition to Blender where the Rest pose Matrix is always
- * the Identity matrix.
- *
- * The custom properties are:
- *
- * restpose_scale_x
- * restpose_scale_y
- * restpose_scale_z
- *
- * restpose_rot_x
- * restpose_rot_y
- * restpose_rot_z
- *
- * restpose_loc_x
- * restpose_loc_y
- * restpose_loc_z
- *
- * The matrix is only setup if the scale AND the rot properties are defined.
- * The presence of the loc properties is optional.
- *
- * This feature has been implemented to support Second Life "Fitted Mesh"
- * TODO: Check if an arbitrary rest pose matrix makes sense within Blender.
- * Eventually leverage the custom property data into an "official" 
- * Edit_bone Property
- */
-static void create_restpose_mat(Bone *bone, float mat[4][4])
-{
-   float loc[3] = {
-   get_property(bone, "restpose_loc_x", 0.0),
-   get_property(bone, "restpose_loc_y", 0.0),
-   get_property(bone, "restpose_loc_z", 0.0)
-   };
-
-   float rot[3] = {
-   DEG2RADF(get_property(bone, "restpose_rot_x", 0.0)),
-   DEG2RADF(get_property(bone, "restpose_rot_y", 0.0)),
-   DEG2RADF(get_property(bone, "restpose_rot_z", 0.0))
-   };
-
-   float scale[3] = {
-   get_property(bone, "restpose_scale_x", 1.0),
-   get_property(bone, "restpose_scale_y", 1.0),
-   get_property(bone, "restpose_scale_z", 1.0)
-   };
-
-   loc_eulO_size_to_mat4(mat, loc, rot, scale, 6);
-}
 
 std::string ControllerExporter::add_inv_bind_mats_source(Object *ob_arm, 
ListBase *defbase, const std::string& controller_id)
 {

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [b48ba0909a] master: Collada - Import: now add bind_mat and rest_mat as custom properties (when the use_bind_info option is enabled)

2017-03-23 Thread Gaia Clary
Commit: b48ba0909a2a609fadc91e9f6e1c031b99e6464e
Author: Gaia Clary
Date:   Thu Mar 23 14:10:57 2017 +0100
Branches: master
https://developer.blender.org/rBb48ba0909a2a609fadc91e9f6e1c031b99e6464e

Collada - Import: now add bind_mat and rest_mat as custom properties (when the 
use_bind_info option is enabled)

===

M   source/blender/collada/ArmatureImporter.cpp

===

diff --git a/source/blender/collada/ArmatureImporter.cpp 
b/source/blender/collada/ArmatureImporter.cpp
index 2e4a7dfebc..0ea8324ed7 100644
--- a/source/blender/collada/ArmatureImporter.cpp
+++ b/source/blender/collada/ArmatureImporter.cpp
@@ -42,6 +42,7 @@ extern "C" {
 #include "ED_armature.h"
 }
 
+#include "collada_utils.h"
 #include "ArmatureImporter.h"
 
 // use node name, or fall back to original id if not present (name is optional)
@@ -171,7 +172,8 @@ int ArmatureImporter::create_bone(SkinInfo *skin, 
COLLADAFW::Node *node, EditBon
{
float rest_mat[4][4];
get_node_mat(rest_mat, node, NULL, NULL, NULL);
-   bc_create_bindpose_properties(this->import_settings, bone, 
joint_bind_mat, rest_mat);
+   bc_set_IDPropertyMatrix(bone, "bind_mat", joint_bind_mat);
+   bc_set_IDPropertyMatrix(bone, "rest_mat", rest_mat);
}
 
add_v3_v3v3(bone->tail, bone->head, tail); //tail must be non zero

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [339d0170d1] master: collada: Simplify reading Node Matrix

2017-03-23 Thread Gaia Clary
Commit: 339d0170d1843e6a67217cfc4085af8725708eca
Author: Gaia Clary
Date:   Tue Mar 21 18:05:10 2017 +0100
Branches: master
https://developer.blender.org/rB339d0170d1843e6a67217cfc4085af8725708eca

collada: Simplify reading Node Matrix

===

M   source/blender/collada/ArmatureImporter.cpp
M   source/blender/collada/TransformReader.cpp
M   source/blender/collada/TransformReader.h

===

diff --git a/source/blender/collada/ArmatureImporter.cpp 
b/source/blender/collada/ArmatureImporter.cpp
index 13196c4a15..398c4a2c10 100644
--- a/source/blender/collada/ArmatureImporter.cpp
+++ b/source/blender/collada/ArmatureImporter.cpp
@@ -132,18 +132,7 @@ int ArmatureImporter::create_bone(SkinInfo *skin, 
COLLADAFW::Node *node, EditBon
 
// create a bone even if there's no joint data for it (i.e. it has no 
influence)
if (!bone_is_skinned) {
-   float obmat[4][4];
-   // bone-space
-   get_node_mat(obmat, node, NULL, NULL);
-
-   // get world-space
-   if (parent) {
-   mul_m4_m4m4(mat, parent_mat, obmat);
-   }
-   else {
-   copy_m4_m4(mat, obmat);
-   }
-
+   get_node_mat(mat, node, NULL, NULL, parent_mat);
}
 
if (parent) bone->parent = parent;
diff --git a/source/blender/collada/TransformReader.cpp 
b/source/blender/collada/TransformReader.cpp
index f8f31304d2..7f742be7e3 100644
--- a/source/blender/collada/TransformReader.cpp
+++ b/source/blender/collada/TransformReader.cpp
@@ -34,7 +34,21 @@ TransformReader::TransformReader(UnitConverter *conv) : 
unit_converter(conv)
/* pass */
 }
 
-void TransformReader::get_node_mat(float mat[4][4], COLLADAFW::Node *node, 
std::map *animation_map, Object *ob)
+void TransformReader::get_node_mat(
+   float mat[4][4],
+   COLLADAFW::Node *node,
+   std::map *animation_map,
+   Object *ob)
+{
+   get_node_mat(mat, node, animation_map, ob, NULL);
+}
+
+void TransformReader::get_node_mat(
+   float mat[4][4],
+   COLLADAFW::Node *node,
+   std::map *animation_map,
+   Object *ob,
+   float parent_mat[4][4])
 {
float cur[4][4];
float copy[4][4];
@@ -52,6 +66,9 @@ void TransformReader::get_node_mat(float mat[4][4], 
COLLADAFW::Node *node, std::
// then this is considered as redundant 
information.
// So if we find a Matrix we use that and 
return.
dae_matrix_to_mat4(tm, mat);
+   if (parent_mat) {
+   mul_m4_m4m4(mat, parent_mat, mat);
+   }
return;
case COLLADAFW::Transformation::TRANSLATE:
dae_translate_to_mat4(tm, cur);
@@ -80,6 +97,10 @@ void TransformReader::get_node_mat(float mat[4][4], 
COLLADAFW::Node *node, std::
(*animation_map)[anim_list_id] = anim;
}
}
+
+   if (parent_mat) {
+   mul_m4_m4m4(mat, parent_mat, mat);
+   }
 }
 
 void TransformReader::dae_rotate_to_mat4(COLLADAFW::Transformation *tm, float 
m[4][4])
diff --git a/source/blender/collada/TransformReader.h 
b/source/blender/collada/TransformReader.h
index ab974b9ba8..c598c466c9 100644
--- a/source/blender/collada/TransformReader.h
+++ b/source/blender/collada/TransformReader.h
@@ -59,7 +59,8 @@ public:
TransformReader(UnitConverter *conv);
 
void get_node_mat(float mat[4][4], COLLADAFW::Node *node, 
std::map *animation_map, Object *ob);
-   
+   void get_node_mat(float mat[4][4], COLLADAFW::Node *node, 
std::map *animation_map, Object *ob, float 
parent_mat[4][4]);
+
void dae_rotate_to_mat4(COLLADAFW::Transformation *tm, float m[4][4]);
void dae_translate_to_mat4(COLLADAFW::Transformation *tm, float 
m[4][4]);
void dae_scale_to_mat4(COLLADAFW::Transformation *tm, float m[4][4]);

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [1978ac65c4] master: collada: use local variable to avoid repeated call of bone chain_length_calculator

2017-03-23 Thread Gaia Clary
Commit: 1978ac65c43533d4539c1b06621ef999c8d0a5c2
Author: Gaia Clary
Date:   Tue Mar 21 17:13:31 2017 +0100
Branches: master
https://developer.blender.org/rB1978ac65c43533d4539c1b06621ef999c8d0a5c2

collada: use local variable to avoid repeated call of bone 
chain_length_calculator

===

M   source/blender/collada/ArmatureImporter.cpp

===

diff --git a/source/blender/collada/ArmatureImporter.cpp 
b/source/blender/collada/ArmatureImporter.cpp
index 5b3340a938..d5c1af9347 100644
--- a/source/blender/collada/ArmatureImporter.cpp
+++ b/source/blender/collada/ArmatureImporter.cpp
@@ -290,12 +290,13 @@ void ArmatureImporter::connect_bone_chains(bArmature 
*armature, Bone *parentbone
for (; child; child = child->next) {
BoneExtended *be = extended_bones[child->name];
if (be != NULL) {
-   if (be->get_chain_length() <= clip) {
-   if (be->get_chain_length() > maxlen) {
+   int chain_len = be->get_chain_length();
+   if (chain_len <= clip) {
+   if (chain_len > maxlen) {
dominant_child = be;
-   maxlen = be->get_chain_length();
+   maxlen = chain_len;
}
-   else if (be->get_chain_length() == 
maxlen) {
+   else if (chain_len == maxlen) {
dominant_child = NULL;
}
}

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [1729dd9998] master: collada: Make sure that bone use_conncet is set to false when connect type is not defined in Import

2017-03-23 Thread Gaia Clary
Commit: 1729dd99981ad2d35582ebb67d32542a0e0b24bd
Author: Gaia Clary
Date:   Tue Mar 21 17:49:21 2017 +0100
Branches: master
https://developer.blender.org/rB1729dd99981ad2d35582ebb67d32542a0e0b24bd

collada: Make sure that bone use_conncet is set to false when connect type is 
not defined in Import

===

M   source/blender/collada/ArmatureImporter.cpp

===

diff --git a/source/blender/collada/ArmatureImporter.cpp 
b/source/blender/collada/ArmatureImporter.cpp
index 6a8fe2e13f..13196c4a15 100644
--- a/source/blender/collada/ArmatureImporter.cpp
+++ b/source/blender/collada/ArmatureImporter.cpp
@@ -159,10 +159,11 @@ int ArmatureImporter::create_bone(SkinInfo *skin, 
COLLADAFW::Node *node, EditBon
int use_connect = be.get_use_connect();
 
switch (use_connect) {
-   case 1:  bone->flag |= BONE_CONNECTED;
-break;
-   case 0:  bone->flag &= ~BONE_CONNECTED;
-   case -1: break; // not defined
+   case 1: bone->flag |= BONE_CONNECTED;
+   break;
+   case -1:/* Connect type not specified */
+   case 0: bone->flag &= ~BONE_CONNECTED;
+   break;
}
 
if (be.has_roll()) {

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [89631485cc] master: collada: use vector copy function instead of direct assigning

2017-03-23 Thread Gaia Clary
Commit: 89631485ccf5fac5e61f77f29c4b9ca2e9779574
Author: Gaia Clary
Date:   Tue Mar 21 17:10:19 2017 +0100
Branches: master
https://developer.blender.org/rB89631485ccf5fac5e61f77f29c4b9ca2e9779574

collada: use vector copy function instead of direct assigning

===

M   source/blender/collada/ArmatureImporter.cpp

===

diff --git a/source/blender/collada/ArmatureImporter.cpp 
b/source/blender/collada/ArmatureImporter.cpp
index f4ce399277..5b3340a938 100644
--- a/source/blender/collada/ArmatureImporter.cpp
+++ b/source/blender/collada/ArmatureImporter.cpp
@@ -322,10 +322,7 @@ void ArmatureImporter::connect_bone_chains(bArmature 
*armature, Bone *parentbone
 
if (len_squared_v3(vec) > MINIMUM_BONE_LENGTH)
{
-   pebone->tail[0] = cebone->head[0];
-   pebone->tail[1] = cebone->head[1];
-   pebone->tail[2] = cebone->head[2];
-
+   copy_v3_v3(pebone->tail, cebone->head);
if (pbe && pbe->get_chain_length() >= 
this->import_settings->min_chain_length) {
cebone->flag |= BONE_CONNECTED;
printf("Connecting chain: parent %s --> 
%s (child)\n", pebone->name, cebone->name);

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [f98d9baea9] blender2.8: Revert own previous commit, the bug is already fixed a fiew commits before. Sorry for the noise.

2017-03-23 Thread Alexander Romanov
Commit: f98d9baea9e8a928fdd5cec6c2add9b9ef50cf23
Author: Alexander Romanov
Date:   Thu Mar 23 16:36:28 2017 +0300
Branches: blender2.8
https://developer.blender.org/rBf98d9baea9e8a928fdd5cec6c2add9b9ef50cf23

Revert own previous commit, the bug is already fixed a fiew commits before. 
Sorry for the noise.

===

M   source/blender/windowmanager/intern/wm_gesture.c

===

diff --git a/source/blender/windowmanager/intern/wm_gesture.c 
b/source/blender/windowmanager/intern/wm_gesture.c
index b9f5a43e3e..d4bbc4c7a6 100644
--- a/source/blender/windowmanager/intern/wm_gesture.c
+++ b/source/blender/windowmanager/intern/wm_gesture.c
@@ -414,14 +414,6 @@ static void wm_gesture_draw_lasso(wmWindow *win, wmGesture 
*gt, bool filled)
unsigned pos = add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
unsigned line_origin = add_attrib(format, "line_origin", COMP_F32, 2, 
KEEP_FLOAT);
 
-   numverts = gt->points;
-   if (gt->type == WM_GESTURE_LASSO) {
-   numverts++;
-   }
-
-   if (numverts <= 1)
-   return;
-
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
 
immUniform4f("color1", 0.4f, 0.4f, 0.4f, 1.0f);

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [0b9041905f] blender2.8: Fix (unreported) assertion in immBegin. Zerro number of points (Ctrl+LMouse without moving in node space)

2017-03-23 Thread Alexander Romanov
Commit: 0b9041905faff61db41ebc6efa2d653d17b46d30
Author: Alexander Romanov
Date:   Thu Mar 23 15:54:14 2017 +0300
Branches: blender2.8
https://developer.blender.org/rB0b9041905faff61db41ebc6efa2d653d17b46d30

Fix (unreported) assertion in immBegin. Zerro number of points (Ctrl+LMouse 
without moving in node space)

===

M   source/blender/windowmanager/intern/wm_gesture.c

===

diff --git a/source/blender/windowmanager/intern/wm_gesture.c 
b/source/blender/windowmanager/intern/wm_gesture.c
index d4bbc4c7a6..b9f5a43e3e 100644
--- a/source/blender/windowmanager/intern/wm_gesture.c
+++ b/source/blender/windowmanager/intern/wm_gesture.c
@@ -414,6 +414,14 @@ static void wm_gesture_draw_lasso(wmWindow *win, wmGesture 
*gt, bool filled)
unsigned pos = add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
unsigned line_origin = add_attrib(format, "line_origin", COMP_F32, 2, 
KEEP_FLOAT);
 
+   numverts = gt->points;
+   if (gt->type == WM_GESTURE_LASSO) {
+   numverts++;
+   }
+
+   if (numverts <= 1)
+   return;
+
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
 
immUniform4f("color1", 0.4f, 0.4f, 0.4f, 1.0f);

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [be4d04f24d] app-templates: Merge branch 'master' into app-templates

2017-03-23 Thread Campbell Barton
Commit: be4d04f24dd23297d42b48769279452b3885c794
Author: Campbell Barton
Date:   Thu Mar 23 20:51:14 2017 +1100
Branches: app-templates
https://developer.blender.org/rBbe4d04f24dd23297d42b48769279452b3885c794

Merge branch 'master' into app-templates

===



===



___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [5bd6561266] app-templates: Don't attempt template loading when they're not present

2017-03-23 Thread Campbell Barton
Commit: 5bd65612661dcb181540242e774fdc7548cdb738
Author: Campbell Barton
Date:   Thu Mar 23 20:32:23 2017 +1100
Branches: app-templates
https://developer.blender.org/rB5bd65612661dcb181540242e774fdc7548cdb738

Don't attempt template loading when they're not present

===

M   release/scripts/modules/bpy/utils/__init__.py
M   source/blender/blenkernel/BKE_appdir.h
M   source/blender/blenkernel/intern/appdir.c
M   source/blender/windowmanager/intern/wm_files.c

===

diff --git a/release/scripts/modules/bpy/utils/__init__.py 
b/release/scripts/modules/bpy/utils/__init__.py
index 5e21ef1905..f760f52615 100644
--- a/release/scripts/modules/bpy/utils/__init__.py
+++ b/release/scripts/modules/bpy/utils/__init__.py
@@ -68,7 +68,6 @@ import os as _os
 import sys as _sys
 
 import addon_utils as _addon_utils
-import bl_app_template_utils as _bl_app_template_utils
 
 _user_preferences = _bpy.context.user_preferences
 _script_module_dirs = "startup", "modules"
@@ -248,7 +247,10 @@ def load_scripts(reload_scripts=False, 
refresh_scripts=False):
 test_register(mod)
 
 # load template (if set)
-_bl_app_template_utils.reset(reload_scripts=reload_scripts)
+if any(_bpy.utils.app_template_paths()):
+import bl_app_template_utils
+bl_app_template_utils.reset(reload_scripts=reload_scripts)
+del bl_app_template_utils
 
 # deal with addons separately
 _initialize = getattr(_addon_utils, "_initialize", None)
diff --git a/source/blender/blenkernel/BKE_appdir.h 
b/source/blender/blenkernel/BKE_appdir.h
index 52a6cfad43..84621a8463 100644
--- a/source/blender/blenkernel/BKE_appdir.h
+++ b/source/blender/blenkernel/BKE_appdir.h
@@ -32,7 +32,8 @@ const char *BKE_appdir_folder_id_create(const int folder_id, 
const char *subfold
 const char *BKE_appdir_folder_id_user_notest(const int folder_id, const char 
*subfolder);
 const char *BKE_appdir_folder_id_version(const int folder_id, const int ver, 
const bool do_check);
 
-const char *BKE_appdir_template_id_search(const char *app_template);
+boolBKE_appdir_app_template_any(void);
+const char *BKE_appdir_app_template_id_search(const char *app_template);
 
 /* Initialize path to program executable */
 voidBKE_appdir_program_path_init(const char *argv0);
diff --git a/source/blender/blenkernel/intern/appdir.c 
b/source/blender/blenkernel/intern/appdir.c
index 758eb77cfb..a86ef11254 100644
--- a/source/blender/blenkernel/intern/appdir.c
+++ b/source/blender/blenkernel/intern/appdir.c
@@ -655,28 +655,44 @@ bool BKE_appdir_program_python_search(
return is_found;
 }
 
-const char *BKE_appdir_template_id_search(const char *app_template)
-{
 #ifdef WIN32
 #  define SEP_STR "\\"
 #else
 #  define SEP_STR "/"
 #endif
+
+static const char *app_template_directory_search[2] = {
+   "startup" SEP_STR "bl_app_templates_system",
+   "startup" SEP_STR "bl_app_templates_user",
+};
+#undef SEP_STR
+
+static const int app_template_directory_id[2] = {
+   BLENDER_SYSTEM_SCRIPTS,
+   BLENDER_USER_SCRIPTS,
+};
+
+bool BKE_appdir_app_template_any(void)
+{
+   for (int i = 0; i < 2; i++) {
+   if (BKE_appdir_folder_id(app_template_directory_id[i], 
app_template_directory_search[i])) {
+   return true;
+   }
+   }
+   return false;
+}
+
+const char *BKE_appdir_app_template_id_search(const char *app_template)
+{
static char path[FILE_MAX] = "";
-   int folder_id[2] = {BLENDER_SYSTEM_SCRIPTS, BLENDER_USER_SCRIPTS};
-   const char *folder_name[2] = {
-   "startup" SEP_STR "bl_app_templates_system",
-   "startup" SEP_STR "bl_app_templates_user",
-   };
for (int i = 0; i < 2; i++) {
-   BLI_join_dirfile(path, sizeof(path), folder_name[i], 
app_template);
-   const char *filepath_startup_template = 
BKE_appdir_folder_id(folder_id[i], path);
+   BLI_join_dirfile(path, sizeof(path), 
app_template_directory_search[i], app_template);
+   const char *filepath_startup_template = 
BKE_appdir_folder_id(app_template_directory_id[i], path);
if (filepath_startup_template) {
BLI_strncpy(path, filepath_startup_template, 
sizeof(path));
return path;
}
}
-#undef SEP_STR
return NULL;
 }
 
diff --git a/source/blender/windowmanager/intern/wm_files.c 
b/source/blender/windowmanager/intern/wm_files.c
index 44b5b75763..d4abbb4bc0 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -470,8 +470,9 @@ static void wm_file_read_post(bContext *C, bool 
is_startup_file)
if (is_startup_file) {
/* possible python hasn't been initialized */
if 

[Bf-blender-cvs] [1600b93fb8] master: UI: allow to extend camera as a menu

2017-03-23 Thread Campbell Barton
Commit: 1600b93fb822ea39383ea6849f866aac767ceb12
Author: Campbell Barton
Date:   Thu Mar 23 20:42:44 2017 +1100
Branches: master
https://developer.blender.org/rB1600b93fb822ea39383ea6849f866aac767ceb12

UI: allow to extend camera as a menu

Needed for T46853

===

M   release/scripts/modules/bpy_types.py
M   release/scripts/startup/bl_ui/space_view3d.py

===

diff --git a/release/scripts/modules/bpy_types.py 
b/release/scripts/modules/bpy_types.py
index 5eb8b94656..600b29a6b2 100644
--- a/release/scripts/modules/bpy_types.py
+++ b/release/scripts/modules/bpy_types.py
@@ -683,6 +683,10 @@ class _GenericUI:
 return draw_funcs
 
 @classmethod
+def is_extended(cls):
+return bool(getattr(cls.draw, "_draw_funcs", None))
+
+@classmethod
 def append(cls, draw_func):
 """
 Append a draw function to this menu,
diff --git a/release/scripts/startup/bl_ui/space_view3d.py 
b/release/scripts/startup/bl_ui/space_view3d.py
index b718228e7b..e17d237b06 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -1206,6 +1206,16 @@ class INFO_MT_lamp_add(Menu):
 layout.operator_enum("object.lamp_add", "type")
 
 
+class INFO_MT_camera_add(Menu):
+bl_idname = "INFO_MT_camera_add"
+bl_label = "Camera"
+
+def draw(self, context):
+layout = self.layout
+layout.operator_context = 'EXEC_REGION_WIN'
+layout.operator("object.camera_add", text="Camera", 
icon='OUTLINER_OB_CAMERA')
+
+
 class INFO_MT_add(Menu):
 bl_label = "Add"
 
@@ -1237,7 +1247,11 @@ class INFO_MT_add(Menu):
 layout.operator("object.speaker_add", text="Speaker", 
icon='OUTLINER_OB_SPEAKER')
 layout.separator()
 
-layout.operator("object.camera_add", text="Camera", 
icon='OUTLINER_OB_CAMERA')
+if INFO_MT_camera_add.is_extended():
+layout.menu("INFO_MT_camera_add", icon='OUTLINER_OB_CAMERA')
+else:
+INFO_MT_camera_add.draw(self, context)
+
 layout.menu("INFO_MT_lamp_add", icon='OUTLINER_OB_LAMP')
 layout.separator()

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [8ab88f7367] app-templates: Experimental use of package for storing

2017-03-23 Thread Campbell Barton
Commit: 8ab88f73672153d4f170072ca3f8ba5268856741
Author: Campbell Barton
Date:   Thu Mar 23 17:47:58 2017 +1100
Branches: app-templates
https://developer.blender.org/rB8ab88f73672153d4f170072ca3f8ba5268856741

Experimental use of package for storing

===

M   release/scripts/modules/bl_app_template_utils.py
M   release/scripts/modules/bpy/utils/__init__.py
A   release/scripts/startup/bl_app_templates_system/__init__.py
R099release/datafiles/app_templates/101/template/__init__.py
release/scripts/startup/bl_app_templates_system/blender_101/__init__.py
R100
release/datafiles/app_templates/101/addons/template_101_library/__init__.py 
release/scripts/startup/bl_app_templates_system/blender_101/addons/template_101_library/__init__.py
R100
release/datafiles/app_templates/101/addons/template_101_library/data/object/icosahedron.blend
   
release/scripts/startup/bl_app_templates_system/blender_101/addons/template_101_library/data/object/icosahedron.blend
R100
release/datafiles/app_templates/101/addons/template_101_library/data/object/teapot.blend

release/scripts/startup/bl_app_templates_system/blender_101/addons/template_101_library/data/object/teapot.blend
R100release/datafiles/app_templates/101/splash.png  
release/scripts/startup/bl_app_templates_system/blender_101/splash.png
R100release/datafiles/app_templates/101/splash_2x.png   
release/scripts/startup/bl_app_templates_system/blender_101/splash_2x.png
R100release/datafiles/app_templates/101/startup.blend   
release/scripts/startup/bl_app_templates_system/blender_101/startup.blend
R100release/datafiles/app_templates/101/template/ui.py  
release/scripts/startup/bl_app_templates_system/blender_101/ui.py
R100release/datafiles/app_templates/101/userpref.blend  
release/scripts/startup/bl_app_templates_system/blender_101/userpref.blend
R100release/datafiles/app_templates/3d_print/template/__init__.py   
release/scripts/startup/bl_app_templates_system/lighting/__init__.py
R100release/datafiles/app_templates/lighting/startup.blend  
release/scripts/startup/bl_app_templates_system/lighting/startup.blend
R100release/datafiles/app_templates/lighting/template/__init__.py   
release/scripts/startup/bl_app_templates_system/print_3d/__init__.py
R100release/datafiles/app_templates/3d_print/startup.blend  
release/scripts/startup/bl_app_templates_system/print_3d/startup.blend
M   release/scripts/startup/bl_ui/space_userpref.py
M   source/blender/blenkernel/BKE_appdir.h
M   source/blender/blenkernel/intern/appdir.c
M   source/blender/windowmanager/intern/wm_files.c

===

diff --git a/release/scripts/modules/bl_app_template_utils.py 
b/release/scripts/modules/bl_app_template_utils.py
index af0dbe507f..834280cb75 100644
--- a/release/scripts/modules/bl_app_template_utils.py
+++ b/release/scripts/modules/bl_app_template_utils.py
@@ -57,35 +57,6 @@ _app_template = {
 _modules = {}
 
 
-# -
-# Helper Classes
-
-# Avoids leaving sys.paths & modules in an unknown state.
-class _IsolateImportHelper:
-
-__slots__ = ("path", "module", "module_name")
-
-def __init__(self, path, module_name):
-self.path = path
-self.module_name = module_name
-
-def __enter__(self):
-import sys
-self.module = sys.modules.pop(self.module_name, None)
-sys.path.insert(0, self.path)
-
-def __exit__(self, type, value, traceback):
-import sys
-if self.module is not None:
-sys.modules[self.module_name] = self.module
-else:
-sys.modules.pop(self.module_name, None)
-try:
-sys.path.remove(self.path)
-except Exception:
-pass
-
-
 def _enable(template_id, *, handle_error=None, ignore_not_found=False):
 import os
 import sys
@@ -177,17 +148,20 @@ def _disable(template_id, *, handle_error=None):
 def import_from_path(path, ignore_not_found=False):
 """
 Imports 'startup' from a path.
+
+/usr/share/blender/2.79/scripts/startup/bl_app_templates_system/101
 """
-module_name = "template"
-# loading packages without modifying sys.path is some dark-art.
-# for now just use regular import but don't use sys.modules for cache.
-with _IsolateImportHelper(path, module_name):
-try:
-return __import__(module_name)
-except ModuleNotFoundError as ex:
-if ignore_not_found and ex.name == module_name:
-return None
-raise ex
+import os
+from importlib import import_module
+base_module, template_id = path.rsplit(os.sep, 2)[-2:]
+module_name = base_module + "." + template_id
+
+try:
+return import_module(module_name)
+except ModuleNotFoundError as 

[Bf-blender-cvs] [17b47b1da7] app-templates: Minor fixes

2017-03-23 Thread Campbell Barton
Commit: 17b47b1da74d2a9c2124531dbde9575ea8930621
Author: Campbell Barton
Date:   Thu Mar 23 19:52:28 2017 +1100
Branches: app-templates
https://developer.blender.org/rB17b47b1da74d2a9c2124531dbde9575ea8930621

Minor fixes

===

M   source/blender/windowmanager/intern/wm_files.c
M   source/creator/CMakeLists.txt

===

diff --git a/source/blender/windowmanager/intern/wm_files.c 
b/source/blender/windowmanager/intern/wm_files.c
index 752d1f4bde..44b5b75763 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -1506,7 +1506,6 @@ static int wm_homefile_read_exec(bContext *C, wmOperator 
*op)
 
char app_template_buf[sizeof(U.app_template)];
const char *app_template;
-   /* const bool is_app_template = !use_factory_settings && 
RNA_boolean_get(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");
 
diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt
index fe12aa1bd2..eea4554594 100644
--- a/source/creator/CMakeLists.txt
+++ b/source/creator/CMakeLists.txt
@@ -334,12 +334,6 @@ install(
"file(REMOVE_RECURSE ${TARGETDIR_VER})"
 )
 
-install(
-   DIRECTORY ${CMAKE_SOURCE_DIR}/release/datafiles/app_templates
-   DESTINATION ${TARGETDIR_VER}/datafiles
-   PATTERN "__pycache__" EXCLUDE
-)
-
 if(WITH_PYTHON)
# install(CODE "message(\"copying blender scripts...\")")

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [8ab88f7367] app-templates-package: Experimental use of package for storing

2017-03-23 Thread Campbell Barton
Commit: 8ab88f73672153d4f170072ca3f8ba5268856741
Author: Campbell Barton
Date:   Thu Mar 23 17:47:58 2017 +1100
Branches: app-templates-package
https://developer.blender.org/rB8ab88f73672153d4f170072ca3f8ba5268856741

Experimental use of package for storing

===

M   release/scripts/modules/bl_app_template_utils.py
M   release/scripts/modules/bpy/utils/__init__.py
A   release/scripts/startup/bl_app_templates_system/__init__.py
R099release/datafiles/app_templates/101/template/__init__.py
release/scripts/startup/bl_app_templates_system/blender_101/__init__.py
R100
release/datafiles/app_templates/101/addons/template_101_library/__init__.py 
release/scripts/startup/bl_app_templates_system/blender_101/addons/template_101_library/__init__.py
R100
release/datafiles/app_templates/101/addons/template_101_library/data/object/icosahedron.blend
   
release/scripts/startup/bl_app_templates_system/blender_101/addons/template_101_library/data/object/icosahedron.blend
R100
release/datafiles/app_templates/101/addons/template_101_library/data/object/teapot.blend

release/scripts/startup/bl_app_templates_system/blender_101/addons/template_101_library/data/object/teapot.blend
R100release/datafiles/app_templates/101/splash.png  
release/scripts/startup/bl_app_templates_system/blender_101/splash.png
R100release/datafiles/app_templates/101/splash_2x.png   
release/scripts/startup/bl_app_templates_system/blender_101/splash_2x.png
R100release/datafiles/app_templates/101/startup.blend   
release/scripts/startup/bl_app_templates_system/blender_101/startup.blend
R100release/datafiles/app_templates/101/template/ui.py  
release/scripts/startup/bl_app_templates_system/blender_101/ui.py
R100release/datafiles/app_templates/101/userpref.blend  
release/scripts/startup/bl_app_templates_system/blender_101/userpref.blend
R100release/datafiles/app_templates/3d_print/template/__init__.py   
release/scripts/startup/bl_app_templates_system/lighting/__init__.py
R100release/datafiles/app_templates/lighting/startup.blend  
release/scripts/startup/bl_app_templates_system/lighting/startup.blend
R100release/datafiles/app_templates/lighting/template/__init__.py   
release/scripts/startup/bl_app_templates_system/print_3d/__init__.py
R100release/datafiles/app_templates/3d_print/startup.blend  
release/scripts/startup/bl_app_templates_system/print_3d/startup.blend
M   release/scripts/startup/bl_ui/space_userpref.py
M   source/blender/blenkernel/BKE_appdir.h
M   source/blender/blenkernel/intern/appdir.c
M   source/blender/windowmanager/intern/wm_files.c

===

diff --git a/release/scripts/modules/bl_app_template_utils.py 
b/release/scripts/modules/bl_app_template_utils.py
index af0dbe507f..834280cb75 100644
--- a/release/scripts/modules/bl_app_template_utils.py
+++ b/release/scripts/modules/bl_app_template_utils.py
@@ -57,35 +57,6 @@ _app_template = {
 _modules = {}
 
 
-# -
-# Helper Classes
-
-# Avoids leaving sys.paths & modules in an unknown state.
-class _IsolateImportHelper:
-
-__slots__ = ("path", "module", "module_name")
-
-def __init__(self, path, module_name):
-self.path = path
-self.module_name = module_name
-
-def __enter__(self):
-import sys
-self.module = sys.modules.pop(self.module_name, None)
-sys.path.insert(0, self.path)
-
-def __exit__(self, type, value, traceback):
-import sys
-if self.module is not None:
-sys.modules[self.module_name] = self.module
-else:
-sys.modules.pop(self.module_name, None)
-try:
-sys.path.remove(self.path)
-except Exception:
-pass
-
-
 def _enable(template_id, *, handle_error=None, ignore_not_found=False):
 import os
 import sys
@@ -177,17 +148,20 @@ def _disable(template_id, *, handle_error=None):
 def import_from_path(path, ignore_not_found=False):
 """
 Imports 'startup' from a path.
+
+/usr/share/blender/2.79/scripts/startup/bl_app_templates_system/101
 """
-module_name = "template"
-# loading packages without modifying sys.path is some dark-art.
-# for now just use regular import but don't use sys.modules for cache.
-with _IsolateImportHelper(path, module_name):
-try:
-return __import__(module_name)
-except ModuleNotFoundError as ex:
-if ignore_not_found and ex.name == module_name:
-return None
-raise ex
+import os
+from importlib import import_module
+base_module, template_id = path.rsplit(os.sep, 2)[-2:]
+module_name = base_module + "." + template_id
+
+try:
+return import_module(module_name)
+except 

[Bf-blender-cvs] [4f4a484b9b] master: Cloth refactor: Remove goal springs and some other cleanup

2017-03-23 Thread Luca Rood
Commit: 4f4a484b9b208fe5719825aa750b72e0b67937c8
Author: Luca Rood
Date:   Thu Mar 23 03:52:31 2017 -0300
Branches: master
https://developer.blender.org/rB4f4a484b9b208fe5719825aa750b72e0b67937c8

Cloth refactor: Remove goal springs and some other cleanup

This removes the goal springs, in favor of simply calculating the goal forces 
on the vertices directly. The vertices already store all the necessary data for 
the goal forces, thus the springs were redundant, and just defined both ends as 
being the same vertex.

The main advantage of removing the goal springs, is an increase in flexibility, 
allowing us to much more nicely do some neat dynamic stuff with the goals/pins, 
such as animated vertex weights. But this also has the advantage of simpler 
code, and a slightly reduced memory footprint.

This also removes the `f`, `dfdx` and `dfdv` fields from the `ClothSpring` 
struct, as that data is only used by the solver, and is re-computed on each 
step, and thus does not need to be stored throughout the simulation.

Reviewers: sergey

Reviewed By: sergey

Tags: #physics

Differential Revision: https://developer.blender.org/D2514

===

M   source/blender/blenkernel/BKE_cloth.h
M   source/blender/blenkernel/intern/cloth.c
M   source/blender/physics/intern/BPH_mass_spring.cpp
M   source/blender/physics/intern/implicit.h
M   source/blender/physics/intern/implicit_blender.c

===

diff --git a/source/blender/blenkernel/BKE_cloth.h 
b/source/blender/blenkernel/BKE_cloth.h
index 36330242f1..6c517bd02d 100644
--- a/source/blender/blenkernel/BKE_cloth.h
+++ b/source/blender/blenkernel/BKE_cloth.h
@@ -136,9 +136,6 @@ typedef struct ClothSpring {
float   restlen;/* The original length of the spring.   */
int type;   /* types defined in BKE_cloth.h ("springType") 
*/
int flags;  /* defined in BKE_cloth.h, e.g. deactivated due 
to tearing */
-   float dfdx[3][3];
-   float dfdv[3][3];
-   float f[3];
float   stiffness;  /* stiffness factor from the vertex groups */
float editrestlen;

@@ -240,9 +237,6 @@ void bvhselftree_update_from_cloth(struct ClothModifierData 
*clmd, bool moving);
 // needed for button_object.c
 void cloth_clear_cache (struct Object *ob, struct ClothModifierData *clmd, 
float framenr );
 
-// needed for cloth.c
-int cloth_add_spring (struct ClothModifierData *clmd, unsigned int indexA, 
unsigned int indexB, float restlength, int spring_type);
-
 void cloth_parallel_transport_hair_frame(float mat[3][3], const float 
dir_old[3], const float dir_new[3]);
 
 
diff --git a/source/blender/blenkernel/intern/cloth.c 
b/source/blender/blenkernel/intern/cloth.c
index 28ef3f6f24..ee0fde1ea6 100644
--- a/source/blender/blenkernel/intern/cloth.c
+++ b/source/blender/blenkernel/intern/cloth.c
@@ -869,12 +869,6 @@ static int cloth_from_object(Object *ob, ClothModifierData 
*clmd, DerivedMesh *d
return 0;
}

-   for ( i = 0; i < dm->getNumVerts(dm); i++) {
-   if ((!(cloth->verts[i].flags & CLOTH_VERT_FLAG_PINNED)) && 
(cloth->verts[i].goal > ALMOST_ZERO)) {
-   cloth_add_spring (clmd, i, i, 0.0, 
CLOTH_SPRING_TYPE_GOAL);
-   }
-   }
-   
// init our solver
BPH_cloth_solver_init(ob, clmd);

@@ -944,37 +938,6 @@ BLI_INLINE void spring_verts_ordered_set(ClothSpring 
*spring, int v0, int v1)
}
 }
 
-// be careful: implicit solver has to be resettet when using this one!
-// --> only for implicit handling of this spring!
-int cloth_add_spring(ClothModifierData *clmd, unsigned int indexA, unsigned 
int indexB, float restlength, int spring_type)
-{
-   Cloth *cloth = clmd->clothObject;
-   ClothSpring *spring = NULL;
-   
-   if (cloth) {
-   // TODO: look if this spring is already there
-   
-   spring = (ClothSpring *)MEM_callocN ( sizeof ( ClothSpring ), 
"cloth spring" );
-   
-   if (!spring)
-   return 0;
-   
-   spring->ij = indexA;
-   spring->kl = indexB;
-   spring->restlen =  restlength;
-   spring->type = spring_type;
-   spring->flags = 0;
-   spring->stiffness = 0;
-   
-   cloth->numsprings++;
-   
-   BLI_linklist_prepend ( >springs, spring );
-   
-   return 1;
-   }
-   return 0;
-}
-
 static void cloth_free_edgelist(LinkNodePair *edgelist, unsigned int mvert_num)
 {
if (edgelist) {
diff --git a/source/blender/physics/intern/BPH_mass_spring.cpp 
b/source/blender/physics/intern/BPH_mass_spring.cpp
index 359395b63c..b694b6e994 100644
---