[Bf-blender-cvs] [a0b8a9fe68] master: Alembic: addition of a scope timer to perform basic profiling.

2017-02-24 Thread Kévin Dietrich
Commit: a0b8a9fe6816f1e704b2edbeccddf1e3285e4520
Author: Kévin Dietrich
Date:   Sat Feb 25 06:18:32 2017 +0100
Branches: master
https://developer.blender.org/rBa0b8a9fe6816f1e704b2edbeccddf1e3285e4520

Alembic: addition of a scope timer to perform basic profiling.

===

M   source/blender/alembic/intern/abc_util.cc
M   source/blender/alembic/intern/abc_util.h
M   source/blender/alembic/intern/alembic_capi.cc

===

diff --git a/source/blender/alembic/intern/abc_util.cc 
b/source/blender/alembic/intern/abc_util.cc
index 08c94f437e..158ec263df 100644
--- a/source/blender/alembic/intern/abc_util.cc
+++ b/source/blender/alembic/intern/abc_util.cc
@@ -37,6 +37,8 @@ extern "C" {
 #include "DNA_object_types.h"
 
 #include "BLI_math.h"
+
+#include "PIL_time.h"
 }
 
 std::string get_id_name(Object *ob)
@@ -523,3 +525,15 @@ AbcObjectReader *create_reader(const 
Alembic::AbcGeom::IObject , ImportSe
 
return reader;
 }
+
+/* ** */
+
+ScopeTimer::ScopeTimer(const char *message)
+   : m_message(message)
+   , m_start(PIL_check_seconds_timer())
+{}
+
+ScopeTimer::~ScopeTimer()
+{
+   std::fprintf(stderr, "%s: %fs\n", m_message, PIL_check_seconds_timer() 
- m_start);
+}
diff --git a/source/blender/alembic/intern/abc_util.h 
b/source/blender/alembic/intern/abc_util.h
index a7ac9df91c..85ba4d5c9c 100644
--- a/source/blender/alembic/intern/abc_util.h
+++ b/source/blender/alembic/intern/abc_util.h
@@ -146,4 +146,23 @@ ABC_INLINE void copy_yup_from_zup(short yup[3], const 
short zup[3])
yup[2] = -zup[1];
 }
 
+/* *** */
+
+#undef ABC_DEBUG_TIME
+
+class ScopeTimer {
+   const char *m_message;
+   double m_start;
+
+public:
+   ScopeTimer(const char *message);
+   ~ScopeTimer();
+};
+
+#ifdef ABC_DEBUG_TIME
+#  define SCOPE_TIMER(message) ScopeTimer prof(message)
+#else
+#  define SCOPE_TIMER(message)
+#endif
+
 #endif  /* __ABC_UTIL_H__ */
diff --git a/source/blender/alembic/intern/alembic_capi.cc 
b/source/blender/alembic/intern/alembic_capi.cc
index d8d017119b..dc5146a26e 100644
--- a/source/blender/alembic/intern/alembic_capi.cc
+++ b/source/blender/alembic/intern/alembic_capi.cc
@@ -542,6 +542,8 @@ ABC_INLINE bool is_mesh_and_strands(const IObject )
 
 static void import_startjob(void *user_data, short *stop, short *do_update, 
float *progress)
 {
+   SCOPE_TIMER("Alembic import, objects reading and creation");
+
ImportJobData *data = static_cast(user_data);
 
data->stop = stop;
@@ -677,6 +679,8 @@ static void import_startjob(void *user_data, short *stop, 
short *do_update, floa
 
 static void import_endjob(void *user_data)
 {
+   SCOPE_TIMER("Alembic import, cleanup");
+
ImportJobData *data = static_cast(user_data);
 
std::vector::iterator iter;

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


[Bf-blender-cvs] [2c4564b044] master: Alembic: avoid crashing when reading non-indexed UV params.

2017-02-24 Thread Kévin Dietrich
Commit: 2c4564b044ada4f7f5568735c197afce888d43df
Author: Kévin Dietrich
Date:   Sat Feb 25 07:08:14 2017 +0100
Branches: master
https://developer.blender.org/rB2c4564b044ada4f7f5568735c197afce888d43df

Alembic: avoid crashing when reading non-indexed UV params.

===

M   source/blender/alembic/intern/abc_customdata.cc

===

diff --git a/source/blender/alembic/intern/abc_customdata.cc 
b/source/blender/alembic/intern/abc_customdata.cc
index ebf1b2ba96..0d11ab79dd 100644
--- a/source/blender/alembic/intern/abc_customdata.cc
+++ b/source/blender/alembic/intern/abc_customdata.cc
@@ -327,6 +327,11 @@ static void read_custom_data_ex(const ICompoundProperty 
,
}
else if (data_type == CD_MLOOPUV) {
IV2fGeomParam uv_param(prop, prop_header.getName());
+
+   if (!uv_param.isIndexed()) {
+   return;
+   }
+
IV2fGeomParam::Sample sample;
uv_param.getIndexed(sample, iss);

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


[Bf-blender-cvs] [8c5826f59a] master: Fix T50698: Cycles baking artifacts with transparent surfaces.

2017-02-24 Thread Brecht Van Lommel
Commit: 8c5826f59a37924866ed7dd5bda7fb39c44e8227
Author: Brecht Van Lommel
Date:   Sat Feb 25 03:09:02 2017 +0100
Branches: master
https://developer.blender.org/rB8c5826f59a37924866ed7dd5bda7fb39c44e8227

Fix T50698: Cycles baking artifacts with transparent surfaces.

===

M   intern/cycles/kernel/kernel_bake.h
M   intern/cycles/kernel/kernel_shader.h

===

diff --git a/intern/cycles/kernel/kernel_bake.h 
b/intern/cycles/kernel/kernel_bake.h
index 5bcc57cdcd..f18d145f7c 100644
--- a/intern/cycles/kernel/kernel_bake.h
+++ b/intern/cycles/kernel/kernel_bake.h
@@ -54,7 +54,8 @@ ccl_device_inline void compute_light_pass(KernelGlobals *kg,
float rbsdf = path_state_rng_1D(kg, , , PRNG_BSDF);
shader_eval_surface(kg, sd, , , rbsdf, state.flag, 
SHADER_CONTEXT_MAIN);
 
-   /* TODO, disable the closures we won't need */
+   /* TODO, disable more closures we don't need besides transparent */
+   shader_bsdf_disable_transparency(kg, sd);
 
 #ifdef __BRANCHED_PATH__
if(!kernel_data.integrator.branched) {
diff --git a/intern/cycles/kernel/kernel_shader.h 
b/intern/cycles/kernel/kernel_shader.h
index d0826e5e87..59c1331a63 100644
--- a/intern/cycles/kernel/kernel_shader.h
+++ b/intern/cycles/kernel/kernel_shader.h
@@ -685,6 +685,18 @@ ccl_device float3 shader_bsdf_transparency(KernelGlobals 
*kg, ShaderData *sd)
return eval;
 }
 
+ccl_device void shader_bsdf_disable_transparency(KernelGlobals *kg, ShaderData 
*sd)
+{
+   for(int i = 0; i < ccl_fetch(sd, num_closure); i++) {
+   ShaderClosure *sc = ccl_fetch_array(sd, closure, i);
+
+   if(sc->type == CLOSURE_BSDF_TRANSPARENT_ID) {
+   sc->sample_weight = 0.0f;
+   sc->weight = make_float3(0.0f, 0.0f, 0.0f);
+   }
+   }
+}
+
 ccl_device float3 shader_bsdf_alpha(KernelGlobals *kg, ShaderData *sd)
 {
float3 alpha = make_float3(1.0f, 1.0f, 1.0f) - 
shader_bsdf_transparency(kg, sd);

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


[Bf-blender-cvs] [15f1072ee2] master: Fix build error with macOS / clang / c++11.

2017-02-24 Thread Brecht Van Lommel
Commit: 15f1072ee2e1ff4f0f4c30a9d3a514afa6c371f2
Author: Brecht Van Lommel
Date:   Sat Feb 25 02:35:53 2017 +0100
Branches: master
https://developer.blender.org/rB15f1072ee2e1ff4f0f4c30a9d3a514afa6c371f2

Fix build error with macOS / clang / c++11.

===

M   intern/cycles/bvh/bvh_build.cpp

===

diff --git a/intern/cycles/bvh/bvh_build.cpp b/intern/cycles/bvh/bvh_build.cpp
index fcbc50f4f6..517afc7564 100644
--- a/intern/cycles/bvh/bvh_build.cpp
+++ b/intern/cycles/bvh/bvh_build.cpp
@@ -905,12 +905,13 @@ BVHNode* BVHBuild::create_leaf_node(const BVHRange& range,
 *can not control.
 */
typedef StackAllocator<256, int> LeafStackAllocator;
+   typedef StackAllocator<256, float2> LeafTimeStackAllocator;
typedef StackAllocator<256, BVHReference> LeafReferenceStackAllocator;
 
vector p_type[PRIMITIVE_NUM_TOTAL];
vector p_index[PRIMITIVE_NUM_TOTAL];
vector p_object[PRIMITIVE_NUM_TOTAL];
-   vector p_time[PRIMITIVE_NUM_TOTAL];
+   vector p_time[PRIMITIVE_NUM_TOTAL];
vector 
p_ref[PRIMITIVE_NUM_TOTAL];
 
/* TODO(sergey): In theory we should be able to store references. */
@@ -964,7 +965,7 @@ BVHNode* BVHBuild::create_leaf_node(const BVHRange& range,
vector local_prim_type,
local_prim_index,
local_prim_object;
-   vector local_prim_time;
+   vector local_prim_time;
local_prim_type.resize(num_new_prims);
local_prim_index.resize(num_new_prims);
local_prim_object.resize(num_new_prims);

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


[Bf-blender-cvs] [687bd8e25f] temp-workspace-multi-window: Little utility macros getter/setter compiler hints

2017-02-24 Thread Julian Eisel
Commit: 687bd8e25f8abba14fe82cd858a653fc1088dbe8
Author: Julian Eisel
Date:   Sat Feb 25 00:27:17 2017 +0100
Branches: temp-workspace-multi-window
https://developer.blender.org/rB687bd8e25f8abba14fe82cd858a653fc1088dbe8

Little utility macros getter/setter compiler hints

===

M   source/blender/blenkernel/BKE_workspace.h

===

diff --git a/source/blender/blenkernel/BKE_workspace.h 
b/source/blender/blenkernel/BKE_workspace.h
index be05da62f4..650fcb979c 100644
--- a/source/blender/blenkernel/BKE_workspace.h
+++ b/source/blender/blenkernel/BKE_workspace.h
@@ -103,38 +103,41 @@ WorkSpaceLayout *BKE_workspace_layout_iter_circular(const 
WorkSpace *workspace,
 /*  */
 /* Getters/Setters */
 
-struct ID *BKE_workspace_id_get(WorkSpace *workspace);
-const char *BKE_workspace_name_get(const WorkSpace *workspace);
-WorkSpaceLayout *BKE_workspace_active_layout_get(const struct WorkSpace *ws) 
ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
-void BKE_workspace_active_layout_set(WorkSpace *ws, 
WorkSpaceLayout *layout) ATTR_NONNULL(1);
-struct bScreen *BKE_workspace_active_screen_get(const WorkSpace *ws) 
ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
-voidBKE_workspace_active_screen_set(WorkSpace *ws, struct bScreen 
*screen) ATTR_NONNULL(1);
-enum ObjectMode BKE_workspace_object_mode_get(const WorkSpace *workspace) 
ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
+#define GETTER_ATTRS ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT
+#define SETTER_ATTRS ATTR_NONNULL(1)
+
+struct ID *BKE_workspace_id_get(WorkSpace *workspace) GETTER_ATTRS;
+const char *BKE_workspace_name_get(const WorkSpace *workspace) GETTER_ATTRS;
+WorkSpaceLayout *BKE_workspace_active_layout_get(const struct WorkSpace *ws) 
GETTER_ATTRS;
+void BKE_workspace_active_layout_set(WorkSpace *ws, 
WorkSpaceLayout *layout) SETTER_ATTRS;
+struct bScreen *BKE_workspace_active_screen_get(const WorkSpace *ws) 
GETTER_ATTRS;
+voidBKE_workspace_active_screen_set(WorkSpace *ws, struct bScreen 
*screen) SETTER_ATTRS;
+enum ObjectMode BKE_workspace_object_mode_get(const WorkSpace *workspace) 
GETTER_ATTRS;
 #ifdef USE_WORKSPACE_MODE
-voidBKE_workspace_object_mode_set(WorkSpace *workspace, const enum 
ObjectMode mode) ATTR_NONNULL();
+voidBKE_workspace_object_mode_set(WorkSpace *workspace, const enum 
ObjectMode mode) SETTER_ATTRS;
 #endif
-struct ListBase *BKE_workspace_layouts_get(WorkSpace *workspace) 
ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
-WorkSpaceLayoutType *BKE_workspace_active_layout_type_get(WorkSpace 
*workspace) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
-struct ListBase *BKE_workspace_layout_types_get(WorkSpace *workspace) 
ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
-const char  *BKE_workspace_layout_type_name_get(WorkSpaceLayoutType 
*layout_type) ATTR_NONNULL();
-WorkSpaceLayoutType *BKE_workspace_layout_type_next_get(WorkSpaceLayoutType 
*layout_type) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
-WorkSpaceLayout *BKE_workspace_new_layout_get(const WorkSpace *workspace) 
ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
-void BKE_workspace_new_layout_set(WorkSpace *workspace, 
WorkSpaceLayout *layout) ATTR_NONNULL(1);
-
-WorkSpace *BKE_workspace_next_get(const WorkSpace *workspace) ATTR_NONNULL() 
ATTR_WARN_UNUSED_RESULT;
-WorkSpace *BKE_workspace_prev_get(const WorkSpace *workspace) ATTR_NONNULL() 
ATTR_WARN_UNUSED_RESULT;
-
-struct bScreen *BKE_workspace_layout_screen_get(const WorkSpaceLayout *layout) 
ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
-voidBKE_workspace_layout_screen_set(WorkSpaceLayout *layout, 
struct bScreen *screen) ATTR_NONNULL(1);
-
-WorkSpaceLayout *BKE_workspace_layout_next_get(const WorkSpaceLayout *layout) 
ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
-WorkSpaceLayout *BKE_workspace_layout_prev_get(const WorkSpaceLayout *layout) 
ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
-
-WorkSpace *BKE_workspace_active_get(const WorkSpaceHook *hook) ATTR_NONNULL() 
ATTR_WARN_UNUSED_RESULT;
-void BKE_workspace_active_set(WorkSpaceHook *hook, WorkSpace *workspace) 
ATTR_NONNULL(1);
-WorkSpace *BKE_workspace_active_delayed_get(const WorkSpaceHook *hook) 
ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
-void BKE_workspace_active_delayed_set(WorkSpaceHook *hook, WorkSpace 
*workspace) ATTR_NONNULL(1);
-struct ListBase *BKE_workspace_hook_layouts_get(WorkSpaceHook *workspace_hook) 
ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
+struct ListBase *BKE_workspace_layouts_get(WorkSpace *workspace) GETTER_ATTRS;
+WorkSpaceLayoutType *BKE_workspace_active_layout_type_get(WorkSpace 
*workspace) GETTER_ATTRS;
+struct ListBase *BKE_workspace_layout_types_get(WorkSpace *workspace) 
GETTER_ATTRS;
+const char  *BKE_workspace_layout_type_name_get(WorkSpaceLayoutType 
*layout_type) GETTER_ATTRS;
+WorkSpaceLayoutType 

[Bf-blender-cvs] [9818bf0d56] temp-workspace-multi-window: Add WorkSpaceHook struct as bridge between workspace and window-manager

2017-02-24 Thread Julian Eisel
Commit: 9818bf0d56ebd6ae694312abd50cd293b990679e
Author: Julian Eisel
Date:   Sat Feb 25 00:07:41 2017 +0100
Branches: temp-workspace-multi-window
https://developer.blender.org/rB9818bf0d56ebd6ae694312abd50cd293b990679e

Add WorkSpaceHook struct as bridge between workspace and window-manager

This way we can keep workspace and window-manager data separate and
further steps are made a bit easier.

===

M   source/blender/blenkernel/BKE_workspace.h
M   source/blender/blenkernel/intern/context.c
M   source/blender/blenkernel/intern/image.c
M   source/blender/blenkernel/intern/library_query.c
M   source/blender/blenkernel/intern/scene.c
M   source/blender/blenkernel/intern/workspace.c
M   source/blender/blenloader/intern/readfile.c
M   source/blender/blenloader/intern/versioning_270.c
M   source/blender/blenloader/intern/writefile.c
M   source/blender/depsgraph/intern/depsgraph_tag.cc
M   source/blender/editors/workspace/workspace_layout_edit.c
M   source/blender/makesdna/DNA_windowmanager_types.h
M   source/blender/makesdna/dna_workspace_types.h
M   source/blender/makesrna/intern/rna_wm.c
M   source/blender/windowmanager/intern/wm_window.c

===

diff --git a/source/blender/blenkernel/BKE_workspace.h 
b/source/blender/blenkernel/BKE_workspace.h
index 69d4066b3a..be05da62f4 100644
--- a/source/blender/blenkernel/BKE_workspace.h
+++ b/source/blender/blenkernel/BKE_workspace.h
@@ -35,6 +35,7 @@ struct TransformOrientation;
 struct WorkSpace;
 
 typedef struct WorkSpace WorkSpace;
+typedef struct WorkSpaceHook WorkSpaceHook;
 typedef struct WorkSpaceLayout WorkSpaceLayout;
 typedef struct WorkSpaceLayoutType WorkSpaceLayoutType;
 
@@ -60,6 +61,8 @@ WorkSpaceLayout *BKE_workspace_layout_add_from_type(WorkSpace 
*workspace, WorkSp
 WorkSpaceLayoutType *BKE_workspace_layout_type_add(WorkSpace *workspace, const 
char *name) ATTR_NONNULL();
 WorkSpaceLayout *BKE_workspace_layout_add(WorkSpace *workspace, struct bScreen 
*screen) ATTR_NONNULL();
 void BKE_workspace_layout_remove(WorkSpace *workspace, WorkSpaceLayout 
*layout, struct Main *bmain) ATTR_NONNULL();
+WorkSpaceHook *BKE_workspace_hook_new(void) ATTR_WARN_UNUSED_RESULT;
+void BKE_workspace_hook_delete(WorkSpaceHook *hook) ATTR_NONNULL();
 
 
 /*  */
@@ -127,6 +130,12 @@ void
BKE_workspace_layout_screen_set(WorkSpaceLayout *layout, struct
 WorkSpaceLayout *BKE_workspace_layout_next_get(const WorkSpaceLayout *layout) 
ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
 WorkSpaceLayout *BKE_workspace_layout_prev_get(const WorkSpaceLayout *layout) 
ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
 
+WorkSpace *BKE_workspace_active_get(const WorkSpaceHook *hook) ATTR_NONNULL() 
ATTR_WARN_UNUSED_RESULT;
+void BKE_workspace_active_set(WorkSpaceHook *hook, WorkSpace *workspace) 
ATTR_NONNULL(1);
+WorkSpace *BKE_workspace_active_delayed_get(const WorkSpaceHook *hook) 
ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
+void BKE_workspace_active_delayed_set(WorkSpaceHook *hook, WorkSpace 
*workspace) ATTR_NONNULL(1);
+struct ListBase *BKE_workspace_hook_layouts_get(WorkSpaceHook *workspace_hook) 
ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
+
 /*  */
 /* Don't use outside of BKE! */
 
diff --git a/source/blender/blenkernel/intern/context.c 
b/source/blender/blenkernel/intern/context.c
index d4dd4887e3..d1ac491e4e 100644
--- a/source/blender/blenkernel/intern/context.c
+++ b/source/blender/blenkernel/intern/context.c
@@ -837,7 +837,7 @@ void CTX_wm_window_set(bContext *C, wmWindow *win)
if (C->wm.window) {
C->data.scene = C->wm.window->scene;
}
-   C->wm.workspace = (win) ? win->workspace : NULL;
+   C->wm.workspace = (win) ? BKE_workspace_active_get(win->workspace_hook) 
: NULL;
C->wm.screen = (win) ? BKE_workspace_active_screen_get(C->wm.workspace) 
: NULL;
C->wm.area = NULL;
C->wm.region = NULL;
diff --git a/source/blender/blenkernel/intern/image.c 
b/source/blender/blenkernel/intern/image.c
index c14d03b24c..4ba48260d3 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -2542,7 +2542,8 @@ void BKE_image_walk_all_users(const Main *mainp, void 
*customdata,
/* image window, compo node users */
for (wm = mainp->wm.first; wm; wm = wm->id.next) { /* only 1 wm */
for (win = wm->windows.first; win; win = win->next) {
-   const bScreen *screen = 
BKE_workspace_active_screen_get(win->workspace);
+   WorkSpace *workspace = 
BKE_workspace_active_get(win->workspace_hook);
+   const bScreen *screen = 
BKE_workspace_active_screen_get(workspace);
 
for 

[Bf-blender-cvs] [bda0456933] blender2.8: OpenGL: wm_gesture uses new imm mode

2017-02-24 Thread ianwill
Commit: bda0456933e87c2f623a8e4f980bf7cfc6b3982a
Author: ianwill
Date:   Fri Feb 24 15:33:09 2017 -0500
Branches: blender2.8
https://developer.blender.org/rBbda0456933e87c2f623a8e4f980bf7cfc6b3982a

OpenGL: wm_gesture uses new imm mode

D2376 by @ianwill, part of T49043
review by @merwin

Box select, circle select, etc. Introducing the dashed-line shader! See D2376 
for more info.

===

M   source/blender/gpu/CMakeLists.txt
M   source/blender/gpu/GPU_shader.h
M   source/blender/gpu/intern/gpu_shader.c
A   source/blender/gpu/shaders/gpu_shader_2D_line_dashed_frag.glsl
A   source/blender/gpu/shaders/gpu_shader_2D_line_dashed_vert.glsl
M   source/blender/windowmanager/intern/wm_gesture.c

===

diff --git a/source/blender/gpu/CMakeLists.txt 
b/source/blender/gpu/CMakeLists.txt
index f4627231af..2d82eb692e 100644
--- a/source/blender/gpu/CMakeLists.txt
+++ b/source/blender/gpu/CMakeLists.txt
@@ -140,6 +140,8 @@ data_to_c_simple(shaders/gpu_shader_flat_color_frag.glsl 
SRC)
 data_to_c_simple(shaders/gpu_shader_flat_color_alpha_test_0_frag.glsl SRC)
 data_to_c_simple(shaders/gpu_shader_2D_vert.glsl SRC)
 data_to_c_simple(shaders/gpu_shader_2D_flat_color_vert.glsl SRC)
+data_to_c_simple(shaders/gpu_shader_2D_line_dashed_vert.glsl SRC)
+data_to_c_simple(shaders/gpu_shader_2D_line_dashed_frag.glsl SRC)
 data_to_c_simple(shaders/gpu_shader_2D_smooth_color_vert.glsl SRC)
 data_to_c_simple(shaders/gpu_shader_2D_smooth_color_frag.glsl SRC)
 data_to_c_simple(shaders/gpu_shader_2D_image_vert.glsl SRC)
diff --git a/source/blender/gpu/GPU_shader.h b/source/blender/gpu/GPU_shader.h
index 57309c2ebd..36a59102df 100644
--- a/source/blender/gpu/GPU_shader.h
+++ b/source/blender/gpu/GPU_shader.h
@@ -136,6 +136,8 @@ typedef enum GPUBuiltinShader {
GPU_SHADER_3D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_OUTLINE_SMOOTH,
GPU_SHADER_3D_POINT_VARYING_SIZE_UNIFORM_COLOR,
GPU_SHADER_3D_POINT_VARYING_SIZE_VARYING_COLOR,
+   /* lines */
+   GPU_SHADER_2D_LINE_DASHED_COLOR,
/* lamp drawing */
GPU_SHADER_3D_GROUNDPOINT,
GPU_SHADER_3D_GROUNDLINE,
diff --git a/source/blender/gpu/intern/gpu_shader.c 
b/source/blender/gpu/intern/gpu_shader.c
index a9a8a10cc7..4f5c542850 100644
--- a/source/blender/gpu/intern/gpu_shader.c
+++ b/source/blender/gpu/intern/gpu_shader.c
@@ -98,6 +98,9 @@ extern char 
datatoc_gpu_shader_2D_point_uniform_size_smooth_vert_glsl[];
 extern char 
datatoc_gpu_shader_2D_point_uniform_size_outline_smooth_vert_glsl[];
 extern char 
datatoc_gpu_shader_2D_point_uniform_size_varying_color_outline_smooth_vert_glsl[];
 
+extern char datatoc_gpu_shader_2D_line_dashed_vert_glsl[];
+extern char datatoc_gpu_shader_2D_line_dashed_frag_glsl[];
+
 extern char datatoc_gpu_shader_edges_front_back_persp_vert_glsl[];
 extern char datatoc_gpu_shader_edges_front_back_persp_geom_glsl[];
 extern char datatoc_gpu_shader_edges_front_back_persp_legacy_vert_glsl[];
@@ -705,6 +708,9 @@ GPUShader *GPU_shader_get_builtin_shader(GPUBuiltinShader 
shader)
   
datatoc_gpu_shader_uniform_color_frag_glsl,
   
datatoc_gpu_shader_3D_groundline_geom_glsl },
 
+   [GPU_SHADER_2D_LINE_DASHED_COLOR] = { 
datatoc_gpu_shader_2D_line_dashed_vert_glsl,
+ 
datatoc_gpu_shader_2D_line_dashed_frag_glsl },
+
[GPU_SHADER_3D_OBJECTSPACE_SIMPLE_LIGHTING_VARIYING_COLOR] =
{ 
datatoc_gpu_shader_instance_objectspace_variying_color_vert_glsl,
  datatoc_gpu_shader_simple_lighting_frag_glsl},
diff --git a/source/blender/gpu/shaders/gpu_shader_2D_line_dashed_frag.glsl 
b/source/blender/gpu/shaders/gpu_shader_2D_line_dashed_frag.glsl
new file mode 100644
index 00..85aab7e06e
--- /dev/null
+++ b/source/blender/gpu/shaders/gpu_shader_2D_line_dashed_frag.glsl
@@ -0,0 +1,25 @@
+
+// Draw dashed lines, perforated in screen space.
+// Based on a (3D) version by Mike Erwin.
+
+#if __VERSION__ == 120
+  noperspective varying float distance_along_line;
+  #define fragColor gl_FragColor
+#else
+  noperspective in float distance_along_line;
+  out vec4 fragColor;
+#endif
+
+uniform float dash_width;
+uniform float dash_width_on;
+uniform vec4 color1;
+uniform vec4 color2;
+
+void main()
+{
+   if (mod(distance_along_line, dash_width) <= dash_width_on) {
+   fragColor = color1;
+   } else {
+   fragColor = color2;
+   }
+}
diff --git a/source/blender/gpu/shaders/gpu_shader_2D_line_dashed_vert.glsl 
b/source/blender/gpu/shaders/gpu_shader_2D_line_dashed_vert.glsl
new file mode 100644
index 00..e89b3262fa
--- /dev/null
+++ b/source/blender/gpu/shaders/gpu_shader_2D_line_dashed_vert.glsl
@@ -0,0 +1,20 @@
+
+// Draw dashed lines, perforated in 

[Bf-blender-cvs] [caaf5f0a09] master: Fix T50757: Alembic, assign imported materials to the object data instead of to the object itself.

2017-02-24 Thread Kévin Dietrich
Commit: caaf5f0a09d3f05648068161034756c756052b25
Author: Kévin Dietrich
Date:   Fri Feb 24 21:19:52 2017 +0100
Branches: master
https://developer.blender.org/rBcaaf5f0a09d3f05648068161034756c756052b25

Fix T50757: Alembic, assign imported materials to the object data
instead of to the object itself.

===

M   source/blender/alembic/intern/abc_mesh.cc

===

diff --git a/source/blender/alembic/intern/abc_mesh.cc 
b/source/blender/alembic/intern/abc_mesh.cc
index 8bc9c33505..5a57e43326 100644
--- a/source/blender/alembic/intern/abc_mesh.cc
+++ b/source/blender/alembic/intern/abc_mesh.cc
@@ -691,7 +691,7 @@ static void assign_materials(Main *bmain, Object *ob, const 
std::mapsecond;
}
 
-   assign_material(ob, assigned_name, it->second, 
BKE_MAT_ASSIGN_OBJECT);
+   assign_material(ob, assigned_name, it->second, 
BKE_MAT_ASSIGN_OBDATA);
}
}
 }

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


[Bf-blender-cvs] [275b0628c9] snap_system_clip_planes: Simplification and comments

2017-02-24 Thread Germano Cavalcante
Commit: 275b0628c9d2c425fbef485323e04960d2a559a4
Author: Germano Cavalcante
Date:   Fri Feb 24 15:47:32 2017 -0300
Branches: snap_system_clip_planes
https://developer.blender.org/rB275b0628c9d2c425fbef485323e04960d2a559a4

Simplification and comments

===

M   source/blender/editors/transform/transform_snap_object.c

===

diff --git a/source/blender/editors/transform/transform_snap_object.c 
b/source/blender/editors/transform/transform_snap_object.c
index 3c20020780..84ea0f8344 100644
--- a/source/blender/editors/transform/transform_snap_object.c
+++ b/source/blender/editors/transform/transform_snap_object.c
@@ -1759,18 +1759,14 @@ static bool snapDerivedMesh(
}
}
else { /* TODO (Germano): separate raycast from nearest */
-
-   /* If the tree continues NULL, probably there are no looptris :\
-* In this case, at least take the vertices */
-   if (treedata_lt->vert == NULL) {
-   /* Get the vert array again, to use in the snap to 
verts or edges */
+   if (treedata_lt->vert == NULL) { /* Use 
!treedata_lt->vert_allocated? */
treedata_lt->vert = DM_get_vert_array(dm, 
_lt->vert_allocated);
}
+   if (!treedata_lt->edge_allocated) { /* The reference can be 
lost in dm->release(dm); */
+   treedata_lt->edge = DM_get_edge_array(dm, 
_lt->edge_allocated);
+   }
 
if (snpdt->snap_to_flag & SCE_SELECT_VERTEX) {
-   if (!treedata_lt->edge_allocated) { /* Snap to edges 
may already have been used before */
-   treedata_lt->edge = DM_get_edge_array(dm, 
_lt->edge_allocated);
-   }
if (sod->has_loose_vert) {
/* the tree is owned by the DM and may have 
been freed since we last used! */
if (sod->bvh_trees[0] && 
!bvhcache_has_tree(dm->bvhCache, sod->bvh_trees[0])) {
@@ -1785,10 +1781,8 @@ static bool snapDerivedMesh(
}
}
}
+
if (snpdt->snap_to_flag & SCE_SELECT_EDGE) {
-   if (!treedata_lt->edge_allocated) {
-   treedata_lt->edge = DM_get_edge_array(dm, 
_lt->edge_allocated);
-   }
if (sod->has_loose_edge) {
/* the tree is owned by the DM and may have 
been freed since we last used! */
if (sod->bvh_trees[1] && 
!bvhcache_has_tree(dm->bvhCache, sod->bvh_trees[1])) {
@@ -1833,21 +1827,21 @@ static bool snapDerivedMesh(
flag |= ISECT_CLIP_PLANE;
}
 
-   if (sod->bvh_trees[0]) { /* VERTS */
+   if (sod->bvh_trees[0]) { /* LOOSE_VERTS */
BLI_bvhtree_walk_dfs(
sod->bvh_trees[0],
cb_walk_parent_snap_project, 
cb_walk_leaf_snap_vert,
cb_nearest_walk_order, flag, );
}
 
-   if (sod->bvh_trees[1]) { /* EDGES */
+   if (sod->bvh_trees[1]) { /* LOOSE_EDGES */
BLI_bvhtree_walk_dfs(
sod->bvh_trees[1],
cb_walk_parent_snap_project, 
cb_walk_leaf_snap_edge,
cb_nearest_walk_order, flag, );
}
 
-   if (treedata_lt->tree) { /* LOOPTRIS */
+   if (treedata_lt->tree) { /* LOOPTRIS (for non loose Verts and 
Egdes) */
BLI_bvhtree_walk_dfs(
treedata_lt->tree,
cb_walk_parent_snap_project, 
cb_walk_leaf_snap_tri,

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


[Bf-blender-cvs] [eac6e7ba34] snap_system_clip_planes: `dm->release(dm)` accidentally removed

2017-02-24 Thread Germano Cavalcante
Commit: eac6e7ba34f12c10c642a270a5704009def5c552
Author: Germano Cavalcante
Date:   Fri Feb 24 15:10:35 2017 -0300
Branches: snap_system_clip_planes
https://developer.blender.org/rBeac6e7ba34f12c10c642a270a5704009def5c552

`dm->release(dm)` accidentally removed

I do not know if this call is really necessary, but in doubt I'll leave it as 
it is

===

M   source/blender/editors/transform/transform_snap_object.c

===

diff --git a/source/blender/editors/transform/transform_snap_object.c 
b/source/blender/editors/transform/transform_snap_object.c
index 392c88c441..3c20020780 100644
--- a/source/blender/editors/transform/transform_snap_object.c
+++ b/source/blender/editors/transform/transform_snap_object.c
@@ -1873,6 +1873,8 @@ static bool snapDerivedMesh(
}
}
 
+   dm->release(dm);
+
return retval;
 }

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


[Bf-blender-cvs] [ee1f309f25] snap_system_clip_planes: Merge branch 'snap_system_clip_planes' of g...@git.blender.org:blender.git into snap_system_clip_planes

2017-02-24 Thread Germano Cavalcante
Commit: ee1f309f254ca5bb9196a23acee856f0f4361232
Author: Germano Cavalcante
Date:   Fri Feb 24 14:21:58 2017 -0300
Branches: snap_system_clip_planes
https://developer.blender.org/rBee1f309f254ca5bb9196a23acee856f0f4361232

Merge branch 'snap_system_clip_planes' of g...@git.blender.org:blender.git into 
snap_system_clip_planes

# Conflicts:
#   source/blender/editors/transform/transform_snap_object.c

===



===

diff --cc source/blender/editors/transform/transform_snap_object.c
index 2501489371,b5925aa120..392c88c441
--- a/source/blender/editors/transform/transform_snap_object.c
+++ b/source/blender/editors/transform/transform_snap_object.c
@@@ -1856,7 -1869,11 +1857,6 @@@ static bool snapDerivedMesh
snp_free_nearestdata();
  
if ((neasrest2d.vert_index != -1) || (neasrest2d.edge_index != 
-1)) {
 -
 -  G_treedata = treedata_lt;
 -  G_ed_num = dm->getNumEdges(dm);
 -  G_test_ed("***start***\n", __func__, "");
--
copy_v3_v3(r_loc, neasrest2d.co);
mul_m4_v3(obmat, r_loc);
if (r_no) {

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


[Bf-blender-cvs] [0893f3a2b5] snap_system_clip_planes: Fix crash due to dereferenced array od edges and clean debug printfs

2017-02-24 Thread Germano Cavalcante
Commit: 0893f3a2b5fba4492fa00d507df515847be62b29
Author: Germano Cavalcante
Date:   Fri Feb 24 14:14:49 2017 -0300
Branches: snap_system_clip_planes
https://developer.blender.org/rB0893f3a2b5fba4492fa00d507df515847be62b29

Fix crash due to dereferenced array od edges and clean debug printfs

===

M   source/blender/editors/transform/transform_snap_object.c

===

diff --git a/source/blender/editors/transform/transform_snap_object.c 
b/source/blender/editors/transform/transform_snap_object.c
index 63aa00f1f8..2501489371 100644
--- a/source/blender/editors/transform/transform_snap_object.c
+++ b/source/blender/editors/transform/transform_snap_object.c
@@ -1588,18 +1588,6 @@ static bool snapCamera(
return retval;
 }
 
-static const BVHTreeFromMesh *G_treedata = NULL;
-static uint G_ed_num = 0;
-static void G_test_ed(char *func) {
-   if (G_treedata && G_treedata->edge) {
-   printf("%s\n", func);
-   printf("edge_allocated = %s\n", G_treedata->edge_allocated ? 
"True" : "False");
-   const MEdge *ed = _treedata->edge[G_ed_num - 1];
-   printf("reading edge %d:\n", G_ed_num - 1);
-   printf("\t[v1, v2: %d, %d]\n", ed->v1, ed->v2);
-   }
-}
-
 static bool snapDerivedMesh(
 SnapObjectContext *sctx, SnapData *snpdt,
 Object *ob, float obmat[4][4], const unsigned int ob_index,
@@ -1779,6 +1767,9 @@ static bool snapDerivedMesh(
}
 
if (snpdt->snap_to_flag & SCE_SELECT_VERTEX) {
+   if (!treedata_lt->edge_allocated) { /* Snap to edges 
may already have been used before */
+   treedata_lt->edge = DM_get_edge_array(dm, 
_lt->edge_allocated);
+   }
if (sod->has_loose_vert) {
/* the tree is owned by the DM and may have 
been freed since we last used! */
if (sod->bvh_trees[0] && 
!bvhcache_has_tree(dm->bvhCache, sod->bvh_trees[0])) {
@@ -1786,9 +1777,6 @@ static bool snapDerivedMesh(
sod->bvh_trees[0] = NULL;
}
if (sod->bvh_trees[0] == NULL) {
-   if (treedata_lt->edge == NULL) { /* 
Snap to edges may already have been used before */
-   treedata_lt->edge = 
DM_get_edge_array(dm, _lt->edge_allocated);
-   }
sod->bvh_trees[0] = 
snp_bvhtree_from_mesh_loose_verts(
dm, treedata_lt->edge, 
treedata_lt->vert);
 
@@ -1797,6 +1785,9 @@ static bool snapDerivedMesh(
}
}
if (snpdt->snap_to_flag & SCE_SELECT_EDGE) {
+   if (!treedata_lt->edge_allocated) {
+   treedata_lt->edge = DM_get_edge_array(dm, 
_lt->edge_allocated);
+   }
if (sod->has_loose_edge) {
/* the tree is owned by the DM and may have 
been freed since we last used! */
if (sod->bvh_trees[1] && 
!bvhcache_has_tree(dm->bvhCache, sod->bvh_trees[1])) {
@@ -1804,9 +1795,6 @@ static bool snapDerivedMesh(
sod->bvh_trees[1] = NULL;
}
if (sod->bvh_trees[1] == NULL) {
-   if (treedata_lt->edge == NULL) {
-   treedata_lt->edge = 
DM_get_edge_array(dm, _lt->edge_allocated);
-   }
sod->bvh_trees[1] = 
snp_bvhtree_from_mesh_loose_edges(
dm, treedata_lt->edge, 
treedata_lt->vert);
 
@@ -1869,10 +1857,6 @@ static bool snapDerivedMesh(
 
if ((neasrest2d.vert_index != -1) || (neasrest2d.edge_index != 
-1)) {
 
-   G_treedata = treedata_lt;
-   G_ed_num = dm->getNumEdges(dm);
-   G_test_ed("***start***\n"__func__);
-
copy_v3_v3(r_loc, neasrest2d.co);
mul_m4_v3(obmat, r_loc);
if (r_no) {
@@ -1889,10 +1873,6 @@ static bool snapDerivedMesh(
}
}
 
-   G_test_ed(__func__": before release");
-   dm->release(dm);
-   G_test_ed(__func__": after release :(");
-
return retval;
 }

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


[Bf-blender-cvs] [7017a5fd30] temp-sybren-alembic: Alembic: removed a lot of unnecessary & duplicate code from abc_util.cc

2017-02-24 Thread Sybren A. Stüvel
Commit: 7017a5fd30e7d47a1eaf34dc7716013421a8f70e
Author: Sybren A. Stüvel
Date:   Wed Feb 15 15:20:23 2017 +0100
Branches: temp-sybren-alembic
https://developer.blender.org/rB7017a5fd30e7d47a1eaf34dc7716013421a8f70e

Alembic: removed a lot of unnecessary & duplicate code from abc_util.cc

create_transform_matrix(float[4][4]) did mostly the same as
create_transform_matrix(Object *, float[4][4]), but more elegant.
However, the former has some inconsistencies with the latter (which
are now merged and made explicit, turned out one was for z-up→y-up
while the other was for y-up→z-up), and was renamed to
copy_m44_axis_swap(...) to convey its purpose more clearly.

Furthermore, "loc" has been renamed to "trans", as matrices don't
store locations but translations; and more variables now have a src_
or dst_ prefix to denote whether they contain a matrix/vector in the
source or destination axis orientation.

===

M   source/blender/alembic/intern/abc_util.cc
M   source/blender/alembic/intern/abc_util.h

===

diff --git a/source/blender/alembic/intern/abc_util.cc 
b/source/blender/alembic/intern/abc_util.cc
index d5775f235a..2c9f0f1117 100644
--- a/source/blender/alembic/intern/abc_util.cc
+++ b/source/blender/alembic/intern/abc_util.cc
@@ -160,57 +160,68 @@ static void create_rotation_matrix(
rot_z_mat[1][1] = cos(rz);
 }
 
-/* Recompute transform matrix of object in new coordinate system
- * (from Y-Up to Z-Up).
- *
- * Note that r_mat is used as both input and output parameter.
- */
-void create_transform_matrix(float r_mat[4][4])
+/* Convert matrix from Z=up to Y=up or vice versa. Use yup_mat = zup_mat for 
in-place conversion. */
+void copy_m44_axis_swap(float dst_mat[4][4], float src_mat[4][4], 
AbcAxisSwapMode mode)
 {
-   float rot_mat[3][3], rot[3][3], scale_mat[4][4], invmat[4][4], 
transform_mat[4][4];
+   float dst_rot[3][3], src_rot[3][3], dst_scale_mat[4][4];
float rot_x_mat[3][3], rot_y_mat[3][3], rot_z_mat[3][3];
-   float loc[3], scale[3], euler[3];
+   float src_trans[3], dst_scale[3], src_scale[3], euler[3];
 
-   zero_v3(loc);
-   zero_v3(scale);
+   zero_v3(src_trans);
+   zero_v3(dst_scale);
+   zero_v3(src_scale);
zero_v3(euler);
-   unit_m3(rot);
-   unit_m3(rot_mat);
-   unit_m4(scale_mat);
-   unit_m4(transform_mat);
-   unit_m4(invmat);
+   unit_m3(src_rot);
+   unit_m3(dst_rot);
+   unit_m4(dst_scale_mat);
 
-   /* Compute rotation matrix. */
+   /* We assume there is no sheer component and no homogeneous scaling 
component. */
+   BLI_assert(src_mat[0][3] == 0.0);
+   BLI_assert(src_mat[1][3] == 0.0);
+   BLI_assert(src_mat[2][3] == 0.0);
+   BLI_assert(src_mat[3][3] == 1.0);
 
-   /* Extract location, rotation, and scale from matrix. */
-   mat4_to_loc_rot_size(loc, rot, scale, r_mat);
+   /* Extract translation, rotation, and scale form matrix. */
+   mat4_to_loc_rot_size(src_trans, src_rot, src_scale, src_mat);
 
/* Get euler angles from rotation matrix. */
-   mat3_to_eulO(euler, ROT_MODE_XYZ, rot);
+   mat3_to_eulO(euler, ROT_MODE_XYZ, src_rot);
 
/* Create X, Y, Z rotation matrices from euler angles. */
-   create_rotation_matrix(rot_x_mat, rot_y_mat, rot_z_mat, euler, false);
+   create_rotation_matrix(rot_x_mat, rot_y_mat, rot_z_mat, euler,
+  mode == ABC_ZUP_FROM_YUP);
 
/* Concatenate rotation matrices. */
-   mul_m3_m3m3(rot_mat, rot_mat, rot_y_mat);
-   mul_m3_m3m3(rot_mat, rot_mat, rot_z_mat);
-   mul_m3_m3m3(rot_mat, rot_mat, rot_x_mat);
-
-   /* Add rotation matrix to transformation matrix. */
-   copy_m4_m3(transform_mat, rot_mat);
-
-   /* Add translation to transformation matrix. */
-   copy_zup_from_yup(transform_mat[3], loc);
-
-   /* Create scale matrix. */
-   scale_mat[0][0] = scale[0];
-   scale_mat[1][1] = scale[2];
-   scale_mat[2][2] = scale[1];
+   mul_m3_m3m3(dst_rot, dst_rot, rot_y_mat);
+   mul_m3_m3m3(dst_rot, dst_rot, rot_z_mat);
+   mul_m3_m3m3(dst_rot, dst_rot, rot_x_mat);
+
+   mat3_to_eulO(euler, ROT_MODE_XYZ, dst_rot);
+
+   /* Start construction of dst_mat from rotation matrix */
+   unit_m4(dst_mat);
+   copy_m4_m3(dst_mat, dst_rot);
+
+   /* Apply translation */
+   switch(mode) {
+   case ABC_ZUP_FROM_YUP:
+   copy_zup_from_yup(dst_mat[3], src_trans);
+   break;
+   case ABC_YUP_FROM_ZUP:
+   copy_yup_from_zup(dst_mat[3], src_trans);
+   break;
+   default:
+   BLI_assert(false);
+   }
 
-   /* Add scale to transformation matrix. */
-   mul_m4_m4m4(transform_mat, transform_mat, scale_mat);
+   /* Apply scale matrix. Swaps y and z, but does not
+

[Bf-blender-cvs] [60a2d99044] temp-sybren-alembic: Alembic: Don't compute world matrix when it's not necessary.

2017-02-24 Thread Sybren A. Stüvel
Commit: 60a2d99044c3e7554d813f2e52e108ce449baf5c
Author: Sybren A. Stüvel
Date:   Wed Feb 15 15:30:34 2017 +0100
Branches: temp-sybren-alembic
https://developer.blender.org/rB60a2d99044c3e7554d813f2e52e108ce449baf5c

Alembic: Don't compute world matrix when it's not necessary.

===

M   source/blender/alembic/intern/abc_util.cc

===

diff --git a/source/blender/alembic/intern/abc_util.cc 
b/source/blender/alembic/intern/abc_util.cc
index e3152a17f6..d5775f235a 100644
--- a/source/blender/alembic/intern/abc_util.cc
+++ b/source/blender/alembic/intern/abc_util.cc
@@ -230,11 +230,7 @@ void convert_matrix(const Imath::M44d , Object *ob,
 
create_transform_matrix(r_mat);
 
-   if (ob->parent) {
-   mul_m4_m4m4(r_mat, ob->parent->obmat, r_mat);
-   }
-   /* TODO(kevin) */
-   else if (!has_alembic_parent) {
+   if (!has_alembic_parent) {
/* Only apply scaling to root objects, parenting will propagate 
it. */
float scale_mat[4][4];
scale_m4_fl(scale_mat, scale);
@@ -261,6 +257,9 @@ void create_transform_matrix(Object *obj, float 
transform_mat[4][4])
unit_m4(mat);
 
/* get local matrix. */
+   /* TODO Sybren: when we're exporting as "flat", i.e. non-hierarchial,
+* we should export the world matrix even when the object has a parent
+* Blender Object. */
if (obj->parent) {
invert_m4_m4(invmat, obj->parent->obmat);
mul_m4_m4m4(mat, invmat, obj->obmat);

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


[Bf-blender-cvs] [1e068284c5] temp-sybren-alembic: Alembic: use typedefs to make it easier to handle maps/vectors

2017-02-24 Thread Sybren A. Stüvel
Commit: 1e068284c57b26cc24e0c22df8a41e71aa9efa70
Author: Sybren A. Stüvel
Date:   Tue Feb 21 15:02:17 2017 +0100
Branches: temp-sybren-alembic
https://developer.blender.org/rB1e068284c57b26cc24e0c22df8a41e71aa9efa70

Alembic: use typedefs to make it easier to handle maps/vectors

===

M   source/blender/alembic/intern/abc_exporter.cc
M   source/blender/alembic/intern/abc_exporter.h

===

diff --git a/source/blender/alembic/intern/abc_exporter.cc 
b/source/blender/alembic/intern/abc_exporter.cc
index 7b099bdf25..89d77d94d6 100644
--- a/source/blender/alembic/intern/abc_exporter.cc
+++ b/source/blender/alembic/intern/abc_exporter.cc
@@ -153,13 +153,16 @@ AbcExporter::AbcExporter(Scene *scene, const char 
*filename, ExportSettings 
 
 AbcExporter::~AbcExporter()
 {
-   std::map::iterator it, e;
-   for (it = m_xforms.begin(), e = m_xforms.end(); it != e; ++it) {
-   delete it->second;
+   /* Free xforms map */
+   m_xforms_type::iterator it_x, e_x;
+   for (it_x = m_xforms.begin(), e_x = m_xforms.end(); it_x != e_x; 
++it_x) {
+   delete it_x->second;
}
 
-   for (int i = 0, e = m_shapes.size(); i != e; ++i) {
-   delete m_shapes[i];
+   /* Free shapes vector */
+   m_shapes_type::iterator it_s, e_s;
+   for (it_s = m_shapes.begin(), e_s = m_shapes.end(); it_s != e_s; 
++it_s) {
+   delete *it_s;
}
 
delete m_writer;
@@ -313,8 +316,9 @@ void AbcExporter::operator()(Main *bmain, float , 
bool _canceled)
setCurrentFrame(bmain, frame - m_settings.frame_start);
 
if (shape_frames.count(frame) != 0) {
-   for (int i = 0, e = m_shapes.size(); i != e; ++i) {
-   m_shapes[i]->write();
+   m_shapes_type::iterator xit, xe;
+   for (xit = m_shapes.begin(), xe = m_shapes.end(); xit 
!= xe; ++xit) {
+   (*xit)->write();
}
}
 
@@ -322,7 +326,7 @@ void AbcExporter::operator()(Main *bmain, float , 
bool _canceled)
continue;
}
 
-   std::map::iterator xit, xe;
+   m_xforms_type::iterator xit, xe;
for (xit = m_xforms.begin(), xe = m_xforms.end(); xit != xe; 
++xit) {
xit->second->write();
}
diff --git a/source/blender/alembic/intern/abc_exporter.h 
b/source/blender/alembic/intern/abc_exporter.h
index 6848eda9ad..0249bbf853 100644
--- a/source/blender/alembic/intern/abc_exporter.h
+++ b/source/blender/alembic/intern/abc_exporter.h
@@ -86,8 +86,12 @@ class AbcExporter {
 
ArchiveWriter *m_writer;
 
-   std::map m_xforms;
-   std::vector m_shapes;
+   /* mapping from name to transform writer */
+   typedef std::map m_xforms_type;
+   m_xforms_type m_xforms;
+
+   typedef std::vector m_shapes_type;
+   m_shapes_type m_shapes;
 
 public:
AbcExporter(Scene *scene, const char *filename, ExportSettings 
);

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


[Bf-blender-cvs] [947faf33e3] temp-sybren-alembic: Alembic: added note

2017-02-24 Thread Sybren A. Stüvel
Commit: 947faf33e3faa7f4c83e849fa177c12dbd4b4373
Author: Sybren A. Stüvel
Date:   Wed Feb 15 15:40:33 2017 +0100
Branches: temp-sybren-alembic
https://developer.blender.org/rB947faf33e3faa7f4c83e849fa177c12dbd4b4373

Alembic: added note

===

M   source/blender/alembic/intern/abc_transform.cc

===

diff --git a/source/blender/alembic/intern/abc_transform.cc 
b/source/blender/alembic/intern/abc_transform.cc
index 5f807e2eb4..f34263dcc4 100644
--- a/source/blender/alembic/intern/abc_transform.cc
+++ b/source/blender/alembic/intern/abc_transform.cc
@@ -97,6 +97,9 @@ void AbcTransformWriter::do_write()
 
if (!m_object->parent) {
/* Only apply scaling to root objects, parenting will propagate 
it. */
+   /* TODO Sybren: when we're exporting as "flat", i.e. 
non-hierarchial,
+* we should apply the scale even when the object has a parent
+* Blender Object. */
float scale_mat[4][4];
scale_m4_fl(scale_mat, m_settings.global_scale);
mul_m4_m4m4(mat, mat, scale_mat);

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


[Bf-blender-cvs] [0fe32b0289] temp-sybren-alembic: Alembic: be more explicit in y-up versus z-up variables.

2017-02-24 Thread Sybren A. Stüvel
Commit: 0fe32b0289dd5bb946f7b3f6e83313f78931e342
Author: Sybren A. Stüvel
Date:   Wed Feb 15 15:22:21 2017 +0100
Branches: temp-sybren-alembic
https://developer.blender.org/rB0fe32b0289dd5bb946f7b3f6e83313f78931e342

Alembic: be more explicit in y-up versus z-up variables.

===

M   source/blender/alembic/intern/abc_transform.cc

===

diff --git a/source/blender/alembic/intern/abc_transform.cc 
b/source/blender/alembic/intern/abc_transform.cc
index f34263dcc4..799cf63666 100644
--- a/source/blender/alembic/intern/abc_transform.cc
+++ b/source/blender/alembic/intern/abc_transform.cc
@@ -85,14 +85,14 @@ void AbcTransformWriter::do_write()
return;
}
 
-   float mat[4][4];
-   create_transform_matrix(m_object, mat);
+   float yup_mat[4][4];
+   create_transform_matrix(m_object, yup_mat);
 
/* Only apply rotation to root camera, parenting will propagate it. */
if (m_object->type == OB_CAMERA && !has_parent_camera(m_object)) {
float rot_mat[4][4];
axis_angle_to_mat4_single(rot_mat, 'X', -M_PI_2);
-   mul_m4_m4m4(mat, mat, rot_mat);
+   mul_m4_m4m4(yup_mat, yup_mat, rot_mat);
}
 
if (!m_object->parent) {
@@ -102,12 +102,11 @@ void AbcTransformWriter::do_write()
 * Blender Object. */
float scale_mat[4][4];
scale_m4_fl(scale_mat, m_settings.global_scale);
-   mul_m4_m4m4(mat, mat, scale_mat);
-   mul_v3_fl(mat[3], m_settings.global_scale);
+   mul_m4_m4m4(yup_mat, yup_mat, scale_mat);
+   mul_v3_fl(yup_mat[3], m_settings.global_scale);
}
 
-   m_matrix = convert_matrix(mat);
-
+   m_matrix = convert_matrix(yup_mat);
m_sample.setMatrix(m_matrix);
m_schema.set(m_sample);
 }

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


[Bf-blender-cvs] [70852c88ad] temp-sybren-alembic: Alembic: fixed importer

2017-02-24 Thread Sybren A. Stüvel
Commit: 70852c88ad275cdaac4818b3b90c7a8b97225f8b
Author: Sybren A. Stüvel
Date:   Wed Feb 15 17:29:26 2017 +0100
Branches: temp-sybren-alembic
https://developer.blender.org/rB70852c88ad275cdaac4818b3b90c7a8b97225f8b

Alembic: fixed importer

The importer was guessing whether an Alembic IXform object was part of a
child object, or should be represented as an Empty in Blender. By reversing
the order in which objects are visited, the children can now claim their
parent as part of the same object (so IPolyMesh claims its parent IXform
as part of the same Blender object). This results in much less guesswork.

I've also removed similar guesswork from the code that sets parent pointers,
by simply searching for the parent in a hierarchical way, instead of trying
to predict (again) which IXforms were turned into empties.

Also, visit_object() now actually visits the object -- previously it only
visited its children, and assumed the object it was called on was already
handled by a previous call.

===

M   source/blender/alembic/intern/alembic_capi.cc

===

diff --git a/source/blender/alembic/intern/alembic_capi.cc 
b/source/blender/alembic/intern/alembic_capi.cc
index d8d017119b..c9f4376316 100644
--- a/source/blender/alembic/intern/alembic_capi.cc
+++ b/source/blender/alembic/intern/alembic_capi.cc
@@ -152,7 +152,7 @@ static void gather_objects_paths(const IObject , 
ListBase *object_paths)
}
 #if 0
else {
-   std::cerr << "Skipping " << 
child.getFullName() << '\n';
+   std::cerr << 
"gather_objects_paths(" << object.getFullName() << "): Skipping " << 
child.getFullName() << '\n';
}
 #endif
}
@@ -376,114 +376,162 @@ void ABC_export(
 
 /* ** Import file ** */
 
-static void visit_object(const IObject ,
+static int visit_object(const IObject ,
  std::vector ,
  GHash *parent_map,
  ImportSettings )
 {
if (!object.valid()) {
-   return;
+   std::cerr << "  - " << object.getFullName() << ": object is 
invalid, skipping it and all its children.\n";
+   return false;
}
 
-   for (int i = 0; i < object.getNumChildren(); ++i) {
-   IObject child = object.getChild(i);
-
-   if (!child.valid()) {
-   continue;
-   }
+   // The interpretation of data by the children determine the role of 
this object.
+   // This is especially important for Xform objects, as they can be 
either part of a Blender object
+   // or a Blender object (empty) themselves.
+   size_t children_claiming_this_object = 0;
+   size_t num_children = object.getNumChildren();
+   BLI_assert((int)true == 1);
+   for (size_t i = 0; i < num_children; ++i) {
+   bool child_claims_this_object = 
visit_object(object.getChild(i), readers, parent_map, settings);
+   children_claiming_this_object += child_claims_this_object;  // 
using (int)true == 1
+   }
 
-   AbcObjectReader *reader = NULL;
+   AbcObjectReader *reader = NULL;
 
-   const MetaData  = child.getMetaData();
+   const MetaData  = object.getMetaData();
+// const std::string schema_obj_title = md.get("schemaObjTitle");
+// std::cerr << "  - " << object.getFullName() << "(" << schema_obj_title 
<< "): ";
 
-   if (IXform::matches(md)) {
-   bool create_xform = false;
+   bool parent_is_part_of_this_object = false;
+   if (!object.getParent()) {
+   // The root itself is not an object we should import.
+   }
+   else if (IXform::matches(md)) {
+   bool create_empty;
 
-   /* Check whether or not this object is a Maya locator, 
which is
-* similar to empties used as parent object in Blender. 
*/
-   if (has_property(child.getProperties(), "locator")) {
-   create_xform = true;
-   }
-   else {
-   /* Avoid creating an empty object if the child 
of this transform
-* is not a transform (that is an empty). */
-   if (child.getNumChildren() == 1) {
-   if 
(IXform::matches(child.getChild(0).getMetaData())) {
-   create_xform = true;
-   }
-#if 0
-   else {
-  

[Bf-blender-cvs] [9bf69ab3c1] temp-sybren-alembic: Alembic import: don't crash on instances

2017-02-24 Thread Sybren A. Stüvel
Commit: 9bf69ab3c1ac77ce3cb4fd6090b6e8ff722de64d
Author: Sybren A. Stüvel
Date:   Thu Feb 23 15:56:11 2017 +0100
Branches: temp-sybren-alembic
https://developer.blender.org/rB9bf69ab3c1ac77ce3cb4fd6090b6e8ff722de64d

Alembic import: don't crash on instances

Importing instances (i.e. Alembic objects that reference instance
sources rather than contain data for themselves) isn't supported yet, but
with this change at least it doesn't crash Blender.

===

M   source/blender/alembic/intern/alembic_capi.cc

===

diff --git a/source/blender/alembic/intern/alembic_capi.cc 
b/source/blender/alembic/intern/alembic_capi.cc
index d542c530c3..f773b4a770 100644
--- a/source/blender/alembic/intern/alembic_capi.cc
+++ b/source/blender/alembic/intern/alembic_capi.cc
@@ -376,7 +376,7 @@ void ABC_export(
 
 /* ** Import file ** */
 
-static int visit_object(const IObject ,
+static int visit_object(IObject object,
  std::vector ,
  GHash *readers_map,
  ImportSettings )
@@ -515,6 +515,17 @@ static int visit_object(const IObject ,
 
 // std::cerr << std::endl;
 
+   if (object.isInstanceRoot()) {
+   std::cerr << "Alembic object " << full_name
+ << " is an instance of other object "
+ << object.instanceSourcePath()
+ << ", ignoring for now." << std::endl;
+   if (reader) {
+   delete reader;
+   reader = NULL;
+   }
+   }
+
if (reader) {
readers.push_back(reader);
reader->incref();

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


[Bf-blender-cvs] [75597c03be] temp-sybren-alembic: Alembic import: separated reading matrix and getting the appropriate Xform object

2017-02-24 Thread Sybren A. Stüvel
Commit: 75597c03be7270c507eca3de765b4b706f8d1ff1
Author: Sybren A. Stüvel
Date:   Thu Feb 23 15:58:36 2017 +0100
Branches: temp-sybren-alembic
https://developer.blender.org/rB75597c03be7270c507eca3de765b4b706f8d1ff1

Alembic import: separated reading matrix and getting the appropriate Xform 
object

Also added a bit better error reporting, instead of silently ignoring
invalid Alembic data.

===

M   source/blender/alembic/intern/abc_object.cc
M   source/blender/alembic/intern/abc_object.h

===

diff --git a/source/blender/alembic/intern/abc_object.cc 
b/source/blender/alembic/intern/abc_object.cc
index 3a3b076dbf..7250ebb4c0 100644
--- a/source/blender/alembic/intern/abc_object.cc
+++ b/source/blender/alembic/intern/abc_object.cc
@@ -236,37 +236,50 @@ void AbcObjectReader::readObjectMatrix(const float time)
}
 }
 
-void AbcObjectReader::read_matrix(float mat[4][4], const float time, const 
float scale, bool _constant)
-{
-   IXform ixform;
-   IObject ixform_parent;
 
+Alembic::AbcGeom::IXform AbcObjectReader::xform()
+{
/* Check that we have an empty object (locator, bone head/tail...).  */
if (IXform::matches(m_iobject.getMetaData())) {
-   ixform = IXform(m_iobject, Alembic::AbcGeom::kWrapExisting);
-   ixform_parent = m_iobject.getParent();
+   return IXform(m_iobject, Alembic::AbcGeom::kWrapExisting);
}
-   /* Check that we have an object with actual data. */
-   else if (IXform::matches(m_iobject.getParent().getMetaData())) {
-   ixform = IXform(m_iobject.getParent(), 
Alembic::AbcGeom::kWrapExisting);
-   ixform_parent = m_iobject.getParent().getParent();
+
+   /* Check that we have an object with actual data, in which case the
+* parent Alembic object should contain the transform. */
+   IObject abc_parent = m_iobject.getParent();
+
+   /* The archive's top object can be recognised by not having a parent. */
+   if (abc_parent.getParent()
+   && IXform::matches(abc_parent.getMetaData())) {
+   return IXform(abc_parent, Alembic::AbcGeom::kWrapExisting);
}
+
/* Should not happen. */
-   else {
-   std::cerr << "AbcObjectReader::read_matrix: "
- << "unable to find IXform for Alembic object '"
- << m_iobject.getFullName() << "'\n";
-   BLI_assert(false);
+   std::cerr << "AbcObjectReader::xform(): "
+ << "unable to find IXform for Alembic object '"
+ << m_iobject.getFullName() << "'\n";
+   BLI_assert(false);
+
+   return IXform();
+}
+
+
+void AbcObjectReader::read_matrix(float mat[4][4], const float time, const 
float scale, bool _constant)
+{
+   IXform ixform = xform();
+   if (!ixform) {
return;
}
 
-   const IXformSchema (ixform.getSchema());
-
+   const IXformSchema & schema(ixform.getSchema());
if (!schema.valid()) {
+   std::cerr << "Alembic object " << ixform.getFullName()
+ << " has an invalid schema." << std::endl;
return;
}
 
bool has_alembic_parent;
+   IObject ixform_parent = ixform.getParent();
if (!ixform_parent.getParent()) {
/* The archive top object certainly is not a transform itself, 
so handle
 * it as "no parent". */
diff --git a/source/blender/alembic/intern/abc_object.h 
b/source/blender/alembic/intern/abc_object.h
index 7d400f17a2..6d97c0359b 100644
--- a/source/blender/alembic/intern/abc_object.h
+++ b/source/blender/alembic/intern/abc_object.h
@@ -158,6 +158,12 @@ public:
 
const Alembic::Abc::IObject () const;
 
+   /**
+* Returns the transform of this object. This can be the Alembic object
+* itself (in case of an Empty) or it can be the parent Alembic object.
+*/
+   virtual Alembic::AbcGeom::IXform xform();
+
Object *object() const;
void object(Object *ob);

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


[Bf-blender-cvs] [df4feb33c7] temp-sybren-alembic: Alembic import: fixed bug where local matrix from Alembic was used as object matrix

2017-02-24 Thread Sybren A. Stüvel
Commit: df4feb33c7aeecab9898182e4ebdfc4880f14bab
Author: Sybren A. Stüvel
Date:   Thu Feb 23 16:00:06 2017 +0100
Branches: temp-sybren-alembic
https://developer.blender.org/rBdf4feb33c7aeecab9898182e4ebdfc4880f14bab

Alembic import: fixed bug where local matrix from Alembic was used as object 
matrix

Also renamed AbcObjectReader::readObjectMatrix to
setupObjectTransform, as it does more than just reading the object
matrix; it also sets up an object constraint if the Alembic Xform is
animated.

===

M   source/blender/alembic/intern/abc_object.cc
M   source/blender/alembic/intern/abc_object.h
M   source/blender/alembic/intern/alembic_capi.cc

===

diff --git a/source/blender/alembic/intern/abc_object.cc 
b/source/blender/alembic/intern/abc_object.cc
index 7250ebb4c0..b8152dec7f 100644
--- a/source/blender/alembic/intern/abc_object.cc
+++ b/source/blender/alembic/intern/abc_object.cc
@@ -214,7 +214,7 @@ Imath::M44d get_matrix(const IXformSchema , const 
float time)
return s0.getMatrix();
 }
 
-void AbcObjectReader::readObjectMatrix(const float time)
+void AbcObjectReader::setupObjectTransform(const float time)
 {
bool is_constant = false;
 
@@ -296,6 +296,16 @@ void AbcObjectReader::read_matrix(float mat[4][4], const 
float time, const float
const Imath::M44d matrix = get_matrix(schema, time);
convert_matrix(matrix, m_object, mat, scale, has_alembic_parent);
 
+   if (has_alembic_parent) {
+   /* In this case, the matrix in Alembic is in local coordinates, 
so
+* convert to world matrix. To prevent us from reading and 
accumulating
+* all parent matrices in the Alembic file, we assume that the 
Blender
+* parent object is already updated for the current timekey, 
and use its
+* world matrix. */
+   BLI_assert(m_object->parent);
+   mul_m4_m4m4(mat, m_object->parent->obmat, mat);
+   }
+
is_constant = schema.isConstant();
 }
 
diff --git a/source/blender/alembic/intern/abc_object.h 
b/source/blender/alembic/intern/abc_object.h
index 6d97c0359b..5b7663943c 100644
--- a/source/blender/alembic/intern/abc_object.h
+++ b/source/blender/alembic/intern/abc_object.h
@@ -183,7 +183,8 @@ public:
return dm;
}
 
-   void readObjectMatrix(const float time);
+   /** Reads the object matrix and sets up an object transform if 
animated. */
+   void setupObjectTransform(const float time);
 
void addCacheModifier();
 
diff --git a/source/blender/alembic/intern/alembic_capi.cc 
b/source/blender/alembic/intern/alembic_capi.cc
index f773b4a770..1e34de0500 100644
--- a/source/blender/alembic/intern/alembic_capi.cc
+++ b/source/blender/alembic/intern/alembic_capi.cc
@@ -655,7 +655,6 @@ static void import_startjob(void *user_data, short *stop, 
short *do_update, floa
 
if (reader->valid()) {
reader->readObjectData(data->bmain, 0.0f);
-   reader->readObjectMatrix(0.0f);
 
min_time = std::min(min_time, reader->minTime());
max_time = std::max(max_time, reader->maxTime());
@@ -728,6 +727,12 @@ static void import_startjob(void *user_data, short *stop, 
short *do_update, floa
return;
}
}
+
+   /* Setup transformations and constraints. */
+   for (iter = data->readers.begin(); iter != data->readers.end(); ++iter) 
{
+   AbcObjectReader *reader = *iter;
+   reader->setupObjectTransform(0.0f);
+   }
 }
 
 static void import_endjob(void *user_data)

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


[Bf-blender-cvs] [74e42c9a44] temp-sybren-alembic: Alembic import: be more lenient towards unknown object types.

2017-02-24 Thread Sybren A. Stüvel
Commit: 74e42c9a44a2ba196ac8dc8647b2b6c1db88f4c7
Author: Sybren A. Stüvel
Date:   Thu Feb 23 15:54:46 2017 +0100
Branches: temp-sybren-alembic
https://developer.blender.org/rB74e42c9a44a2ba196ac8dc8647b2b6c1db88f4c7

Alembic import: be more lenient towards unknown object types.

Alembic is an interchange and caching format, that can contain custom
object schemas. Blender shouldn't crash (because of failing asserts) just
because it doesn't know such an object type.

===

M   source/blender/alembic/intern/abc_util.cc
M   source/blender/alembic/intern/alembic_capi.cc

===

diff --git a/source/blender/alembic/intern/abc_util.cc 
b/source/blender/alembic/intern/abc_util.cc
index da081f5b6d..c3c380b534 100644
--- a/source/blender/alembic/intern/abc_util.cc
+++ b/source/blender/alembic/intern/abc_util.cc
@@ -364,7 +364,10 @@ AbcObjectReader *create_reader(const 
Alembic::AbcGeom::IObject , ImportSe
reader = new AbcCurveReader(object, settings);
}
else {
-   assert(false);
+   std::cerr << "Alembic: unknown how to handle objects of schema "
+ << md.get("schemaObjTitle")
+ << ", skipping object "
+ << object.getFullName() << std::endl;
}
 
return reader;
diff --git a/source/blender/alembic/intern/alembic_capi.cc 
b/source/blender/alembic/intern/alembic_capi.cc
index 565867a23a..d542c530c3 100644
--- a/source/blender/alembic/intern/alembic_capi.cc
+++ b/source/blender/alembic/intern/alembic_capi.cc
@@ -507,11 +507,10 @@ static int visit_object(const IObject ,
 //   << " with data " << reader->data_name();
}
else {
-   std::cerr << "object is of unsupported schema type "
- << "'" << object.getMetaData().get("schemaObjTitle") 
<< "'"
+   std::cerr << "Alembic object " << full_name
+ << " is of unsupported schema type '"
+ << object.getMetaData().get("schemaObjTitle") << "'"
  << std::endl;
-   BLI_assert(false);
-   return false;
}
 
 // std::cerr << std::endl;

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


[Bf-blender-cvs] [bc0208f13c] temp-sybren-alembic: Alembic: simplified conditional statements

2017-02-24 Thread Sybren A. Stüvel
Commit: bc0208f13ccaf44ab4b835f6b1a834be1f1268e9
Author: Sybren A. Stüvel
Date:   Thu Feb 23 11:25:42 2017 +0100
Branches: temp-sybren-alembic
https://developer.blender.org/rBbc0208f13ccaf44ab4b835f6b1a834be1f1268e9

Alembic: simplified conditional statements

===

M   source/blender/alembic/intern/abc_object.h

===

diff --git a/source/blender/alembic/intern/abc_object.h 
b/source/blender/alembic/intern/abc_object.h
index 5b7663943c..cf4372b2f5 100644
--- a/source/blender/alembic/intern/abc_object.h
+++ b/source/blender/alembic/intern/abc_object.h
@@ -117,15 +117,7 @@ struct ImportSettings {
 template 
 static bool has_animations(Schema , ImportSettings *settings)
 {
-   if (settings->is_sequence) {
-   return true;
-   }
-
-   if (!schema.isConstant()) {
-   return true;
-   }
-
-   return false;
+   return settings->is_sequence || !schema.isConstant();
 }
 
 /* ** 
*/

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


[Bf-blender-cvs] [fe9c8be208] temp-sybren-alembic: Alembic import: nicer progress updates

2017-02-24 Thread Sybren A. Stüvel
Commit: fe9c8be208e6e14554c99bb35dacbc70323f700a
Author: Sybren A. Stüvel
Date:   Thu Feb 23 16:19:14 2017 +0100
Branches: temp-sybren-alembic
https://developer.blender.org/rBfe9c8be208e6e14554c99bb35dacbc70323f700a

Alembic import: nicer progress updates

===

M   source/blender/alembic/intern/alembic_capi.cc

===

diff --git a/source/blender/alembic/intern/alembic_capi.cc 
b/source/blender/alembic/intern/alembic_capi.cc
index 1e34de0500..d2ecfbf81f 100644
--- a/source/blender/alembic/intern/alembic_capi.cc
+++ b/source/blender/alembic/intern/alembic_capi.cc
@@ -663,7 +663,7 @@ static void import_startjob(void *user_data, short *stop, 
short *do_update, floa
std::cerr << "Object " << reader->name() << " in 
Alembic file " << data->filename << " is invalid.\n";
}
 
-   *data->progress = 0.1f + 0.6f * (++i / size);
+   *data->progress = 0.1f + 0.3f * (++i / size);
*data->do_update = true;
 
if (G.is_break) {
@@ -719,7 +719,7 @@ static void import_startjob(void *user_data, short *stop, 
short *do_update, floa
}
}
 
-   *data->progress = 0.7f + 0.3f * (++i / size);
+   *data->progress = 0.4f + 0.3f * (++i / size);
*data->do_update = true;
 
if (G.is_break) {
@@ -729,9 +729,18 @@ static void import_startjob(void *user_data, short *stop, 
short *do_update, floa
}
 
/* Setup transformations and constraints. */
+   i = 0;
for (iter = data->readers.begin(); iter != data->readers.end(); ++iter) 
{
AbcObjectReader *reader = *iter;
reader->setupObjectTransform(0.0f);
+
+   *data->progress = 0.7f + 0.3f * (++i / size);
+   *data->do_update = true;
+
+   if (G.is_break) {
+   data->was_cancelled = true;
+   return;
+   }
}
 }

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


[Bf-blender-cvs] [87dcbfd000] temp-sybren-alembic: Alembic: Renamed parent_map to reader_map

2017-02-24 Thread Sybren A. Stüvel
Commit: 87dcbfd00060fe71e3eba3a5987c87cfb3104d3c
Author: Sybren A. Stüvel
Date:   Thu Feb 23 10:12:34 2017 +0100
Branches: temp-sybren-alembic
https://developer.blender.org/rB87dcbfd00060fe71e3eba3a5987c87cfb3104d3c

Alembic: Renamed parent_map to reader_map

It's a mapping from full path of an Alembic object to an AbcObjectReader*.
The fact that at some point it is used to construct parent-child relations
doesn't matter.

===

M   source/blender/alembic/intern/alembic_capi.cc

===

diff --git a/source/blender/alembic/intern/alembic_capi.cc 
b/source/blender/alembic/intern/alembic_capi.cc
index c9f4376316..b95c0b2249 100644
--- a/source/blender/alembic/intern/alembic_capi.cc
+++ b/source/blender/alembic/intern/alembic_capi.cc
@@ -378,7 +378,7 @@ void ABC_export(
 
 static int visit_object(const IObject ,
  std::vector ,
- GHash *parent_map,
+ GHash *readers_map,
  ImportSettings )
 {
if (!object.valid()) {
@@ -393,7 +393,7 @@ static int visit_object(const IObject ,
size_t num_children = object.getNumChildren();
BLI_assert((int)true == 1);
for (size_t i = 0; i < num_children; ++i) {
-   bool child_claims_this_object = 
visit_object(object.getChild(i), readers, parent_map, settings);
+   bool child_claims_this_object = 
visit_object(object.getChild(i), readers, readers_map, settings);
children_claiming_this_object += child_claims_this_object;  // 
using (int)true == 1
}
 
@@ -528,7 +528,7 @@ static int visit_object(const IObject ,
/* Cast to `void *` explicitly to avoid compiler errors because 
it
 * is a `const char *` which the compiler cast to `const void *`
 * instead of the expected `void *`. */
-   BLI_ghash_insert(parent_map, (void 
*)object.getFullName().c_str(), reader);
+   BLI_ghash_insert(readers_map, (void 
*)object.getFullName().c_str(), reader);
}
 
return parent_is_part_of_this_object;
@@ -546,7 +546,7 @@ struct ImportJobData {
char filename[1024];
ImportSettings settings;
 
-   GHash *parent_map;
+   GHash *reader_map;
std::vector readers;
 
short *stop;
@@ -621,10 +621,10 @@ static void import_startjob(void *user_data, short *stop, 
short *do_update, floa
*data->do_update = true;
*data->progress = 0.05f;
 
-   data->parent_map = BLI_ghash_str_new("alembic parent ghash");
+   data->reader_map = BLI_ghash_str_new("alembic parent ghash");
 
/* Parse Alembic Archive. */
-   visit_object(archive->getTop(), data->readers, data->parent_map, 
data->settings);
+   visit_object(archive->getTop(), data->readers, data->reader_map, 
data->settings);
 
if (G.is_break) {
data->was_cancelled = true;
@@ -696,7 +696,7 @@ static void import_startjob(void *user_data, short *stop, 
short *do_update, floa
 
while (alembic_parent) {
parent_reader = reinterpret_cast(
-   BLI_ghash_lookup(data->parent_map, 
alembic_parent.getFullName().c_str()));
+   BLI_ghash_lookup(data->reader_map, 
alembic_parent.getFullName().c_str()));
if (parent_reader != NULL) {
break;  // found the parent reader.
}
@@ -767,8 +767,8 @@ static void import_endjob(void *user_data)
}
}
 
-   if (data->parent_map) {
-   BLI_ghash_free(data->parent_map, NULL, NULL);
+   if (data->reader_map) {
+   BLI_ghash_free(data->reader_map, NULL, NULL);
}
 
switch (data->error_code) {
@@ -804,7 +804,7 @@ void ABC_import(bContext *C, const char *filepath, float 
scale, bool is_sequence
job->settings.sequence_len = sequence_len;
job->settings.offset = offset;
job->settings.validate_meshes = validate_meshes;
-   job->parent_map = NULL;
+   job->reader_map = NULL;
job->error_code = ABC_NO_ERROR;
job->was_cancelled = false;

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


[Bf-blender-cvs] [062d322df1] temp-sybren-alembic: Alembic: more const-ness

2017-02-24 Thread Sybren A. Stüvel
Commit: 062d322df17210fdb4b99a3e0723c608362b2491
Author: Sybren A. Stüvel
Date:   Tue Feb 21 15:00:27 2017 +0100
Branches: temp-sybren-alembic
https://developer.blender.org/rB062d322df17210fdb4b99a3e0723c608362b2491

Alembic: more const-ness

===

M   source/blender/alembic/intern/abc_util.cc
M   source/blender/alembic/intern/abc_util.h

===

diff --git a/source/blender/alembic/intern/abc_util.cc 
b/source/blender/alembic/intern/abc_util.cc
index 2c9f0f1117..da081f5b6d 100644
--- a/source/blender/alembic/intern/abc_util.cc
+++ b/source/blender/alembic/intern/abc_util.cc
@@ -39,7 +39,7 @@ extern "C" {
 #include "BLI_math.h"
 }
 
-std::string get_id_name(Object *ob)
+std::string get_id_name(const Object * const ob)
 {
if (!ob) {
return "";
@@ -48,7 +48,7 @@ std::string get_id_name(Object *ob)
return get_id_name(>id);
 }
 
-std::string get_id_name(ID *id)
+std::string get_id_name(const ID * const id)
 {
std::string name(id->name + 2);
std::replace(name.begin(), name.end(), ' ', '_');
@@ -58,7 +58,7 @@ std::string get_id_name(ID *id)
return name;
 }
 
-std::string get_object_dag_path_name(Object *ob, Object *dupli_parent)
+std::string get_object_dag_path_name(const Object * const ob, Object 
*dupli_parent)
 {
std::string name = get_id_name(ob);
 
diff --git a/source/blender/alembic/intern/abc_util.h 
b/source/blender/alembic/intern/abc_util.h
index e700cc39a2..4a5561b47a 100644
--- a/source/blender/alembic/intern/abc_util.h
+++ b/source/blender/alembic/intern/abc_util.h
@@ -44,9 +44,9 @@ struct ImportSettings;
 struct ID;
 struct Object;
 
-std::string get_id_name(ID *id);
-std::string get_id_name(Object *ob);
-std::string get_object_dag_path_name(Object *ob, Object *dupli_parent);
+std::string get_id_name(const ID * const id);
+std::string get_id_name(const Object * const ob);
+std::string get_object_dag_path_name(const Object * const ob, Object 
*dupli_parent);
 
 bool object_selected(Object *ob);
 bool parent_selected(Object *ob);

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


[Bf-blender-cvs] [2074d26943] temp-sybren-alembic: Alembic: don't call object.getFullName() multiple times.

2017-02-24 Thread Sybren A. Stüvel
Commit: 2074d2694348d40e20c0f05d2e1ed43cd7d143bd
Author: Sybren A. Stüvel
Date:   Thu Feb 23 10:16:37 2017 +0100
Branches: temp-sybren-alembic
https://developer.blender.org/rB2074d2694348d40e20c0f05d2e1ed43cd7d143bd

Alembic: don't call object.getFullName() multiple times.

===

M   source/blender/alembic/intern/alembic_capi.cc

===

diff --git a/source/blender/alembic/intern/alembic_capi.cc 
b/source/blender/alembic/intern/alembic_capi.cc
index b95c0b2249..565867a23a 100644
--- a/source/blender/alembic/intern/alembic_capi.cc
+++ b/source/blender/alembic/intern/alembic_capi.cc
@@ -381,8 +381,10 @@ static int visit_object(const IObject ,
  GHash *readers_map,
  ImportSettings )
 {
+   const char *full_name = object.getFullName().c_str();
+
if (!object.valid()) {
-   std::cerr << "  - " << object.getFullName() << ": object is 
invalid, skipping it and all its children.\n";
+   std::cerr << "  - " << full_name << ": object is invalid, 
skipping it and all its children.\n";
return false;
}
 
@@ -520,15 +522,10 @@ static int visit_object(const IObject ,
 
AlembicObjectPath *abc_path = static_cast(
  
MEM_callocN(sizeof(AlembicObjectPath), "AlembicObjectPath"));
-
-   BLI_strncpy(abc_path->path, object.getFullName().c_str(), 
PATH_MAX);
-
+   BLI_strncpy(abc_path->path, full_name, PATH_MAX);
BLI_addtail(_file->object_paths, abc_path);
 
-   /* Cast to `void *` explicitly to avoid compiler errors because 
it
-* is a `const char *` which the compiler cast to `const void *`
-* instead of the expected `void *`. */
-   BLI_ghash_insert(readers_map, (void 
*)object.getFullName().c_str(), reader);
+   BLI_ghash_insert(readers_map, const_cast(full_name), 
reader);
}
 
return parent_is_part_of_this_object;

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


[Bf-blender-cvs] [e3bf02435c] temp-sybren-alembic: Alembic: prevent a couple of unnecessary multiplications

2017-02-24 Thread Sybren A. Stüvel
Commit: e3bf02435c7383d57e2a5b8401ed06187391d2c1
Author: Sybren A. Stüvel
Date:   Wed Feb 15 15:22:49 2017 +0100
Branches: temp-sybren-alembic
https://developer.blender.org/rBe3bf02435c7383d57e2a5b8401ed06187391d2c1

Alembic: prevent a couple of unnecessary multiplications

===

M   source/blender/alembic/intern/abc_transform.cc

===

diff --git a/source/blender/alembic/intern/abc_transform.cc 
b/source/blender/alembic/intern/abc_transform.cc
index 799cf63666..078e999e2b 100644
--- a/source/blender/alembic/intern/abc_transform.cc
+++ b/source/blender/alembic/intern/abc_transform.cc
@@ -102,8 +102,8 @@ void AbcTransformWriter::do_write()
 * Blender Object. */
float scale_mat[4][4];
scale_m4_fl(scale_mat, m_settings.global_scale);
+   scale_mat[3][3] = m_settings.global_scale;  /* also scale 
translation */
mul_m4_m4m4(yup_mat, yup_mat, scale_mat);
-   mul_v3_fl(yup_mat[3], m_settings.global_scale);
}
 
m_matrix = convert_matrix(yup_mat);

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


[Bf-blender-cvs] [5cbff013de] temp-sybren-alembic: Alembic: do not presume to predict the parent name

2017-02-24 Thread Sybren A. Stüvel
Commit: 5cbff013de5188ecbcf45194ed2f253d789133a0
Author: Sybren A. Stüvel
Date:   Wed Feb 15 15:25:16 2017 +0100
Branches: temp-sybren-alembic
https://developer.blender.org/rB5cbff013de5188ecbcf45194ed2f253d789133a0

Alembic: do not presume to predict the parent name

AbcExporter::createTransformWriter() tries to predict the parent Xform
name, but if it cannot be found has multiple ways of creating it, possibly
under a different name than originally searched for.

===

M   source/blender/alembic/intern/abc_exporter.cc
M   source/blender/alembic/intern/abc_exporter.h

===

diff --git a/source/blender/alembic/intern/abc_exporter.cc 
b/source/blender/alembic/intern/abc_exporter.cc
index 77141a9119..7b099bdf25 100644
--- a/source/blender/alembic/intern/abc_exporter.cc
+++ b/source/blender/alembic/intern/abc_exporter.cc
@@ -409,7 +409,7 @@ void AbcExporter::exploreTransform(EvaluationContext 
*eval_ctx, Object *ob, Obje
free_object_duplilist(lb);
 }
 
-void AbcExporter::createTransformWriter(Object *ob, Object *parent, Object 
*dupliObParent)
+AbcTransformWriter * AbcExporter::createTransformWriter(Object *ob, Object 
*parent, Object *dupliObParent)
 {
const std::string name = get_object_dag_path_name(ob, dupliObParent);
 
@@ -418,43 +418,45 @@ void AbcExporter::createTransformWriter(Object *ob, 
Object *parent, Object *dupl
BLI_assert(ob != dupliObParent);
 
/* check if we have already created a transform writer for this object 
*/
-   if (getXForm(name) != NULL){
-   std::cerr << "xform " << name << " already exists\n";
-   return;
+   AbcTransformWriter *my_writer = getXForm(name);
+   if (my_writer != NULL){
+   return my_writer;
}
 
-   AbcTransformWriter *parent_xform = NULL;
+   AbcTransformWriter *parent_writer = NULL;
 
if (parent) {
-   const std::string parentname = get_object_dag_path_name(parent, 
dupliObParent);
-   parent_xform = getXForm(parentname);
-
-   if (!parent_xform) {
-   if (parent->parent) {
-   createTransformWriter(parent, parent->parent, 
dupliObParent);
-   }
-   else if (parent == dupliObParent) {
-   if (dupliObParent->parent == NULL) {
-   createTransformWriter(parent, NULL, 
NULL);
-   }
-   else {
-   createTransformWriter(parent, 
dupliObParent->parent, dupliObParent->parent);
-   }
+   /* Since there are so many different ways to find parents (as 
evident
+* in the number of conditions below), we can't really look up 
the
+* parent by name. We'll just call createTransformWriter(), 
which will
+* return the parent's AbcTransformWriter pointer. */
+   if (parent->parent) {
+   parent_writer = createTransformWriter(parent, 
parent->parent, dupliObParent);
+   }
+   else if (parent == dupliObParent) {
+   if (dupliObParent->parent == NULL) {
+   parent_writer = createTransformWriter(parent, 
NULL, NULL);
}
else {
-   createTransformWriter(parent, dupliObParent, 
dupliObParent);
+   parent_writer = createTransformWriter(parent, 
dupliObParent->parent, dupliObParent->parent);
}
-
-   parent_xform = getXForm(parentname);
}
+   else {
+   parent_writer = createTransformWriter(parent, 
dupliObParent, dupliObParent);
+   }
+
+   BLI_assert(parent_writer);
}
 
-   if (parent_xform) {
-   m_xforms[name] = new AbcTransformWriter(ob, 
parent_xform->alembicXform(), parent_xform, m_trans_sampling_index, m_settings);
+   if (parent_writer) {
+   my_writer = new AbcTransformWriter(ob, 
parent_writer->alembicXform(), parent_writer, m_trans_sampling_index, 
m_settings);
}
else {
-   m_xforms[name] = new AbcTransformWriter(ob, 
m_writer->archive().getTop(), NULL, m_trans_sampling_index, m_settings);
+   my_writer = new AbcTransformWriter(ob, 
m_writer->archive().getTop(), NULL, m_trans_sampling_index, m_settings);
}
+
+   m_xforms[name] = my_writer;
+   return my_writer;
 }
 
 void AbcExporter::createShapeWriters(EvaluationContext *eval_ctx)
diff --git a/source/blender/alembic/intern/abc_exporter.h 
b/source/blender/alembic/intern/abc_exporter.h
index b0eb8e185d..6848eda9ad 100644
--- 

[Bf-blender-cvs] [6e293d9bd1] temp-sybren-alembic: Alembic: added some getter functions to help debug prints etc.

2017-02-24 Thread Sybren A. Stüvel
Commit: 6e293d9bd11be24361f480e4d2d7776028466331
Author: Sybren A. Stüvel
Date:   Wed Feb 15 15:26:00 2017 +0100
Branches: temp-sybren-alembic
https://developer.blender.org/rB6e293d9bd11be24361f480e4d2d7776028466331

Alembic: added some getter functions to help debug prints etc.

===

M   source/blender/alembic/intern/abc_object.h

===

diff --git a/source/blender/alembic/intern/abc_object.h 
b/source/blender/alembic/intern/abc_object.h
index 0f733e67d3..7d400f17a2 100644
--- a/source/blender/alembic/intern/abc_object.h
+++ b/source/blender/alembic/intern/abc_object.h
@@ -161,6 +161,10 @@ public:
Object *object() const;
void object(Object *ob);
 
+   const std::string & name() const { return m_name; }
+   const std::string & object_name() const { return m_object_name; }
+   const std::string & data_name() const { return m_data_name; }
+
virtual bool valid() const = 0;
 
virtual void readObjectData(Main *bmain, float time) = 0;

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


[Bf-blender-cvs] [05950f03cf] temp-sybren-alembic: Alembic: added some clarification

2017-02-24 Thread Sybren A. Stüvel
Commit: 05950f03cfdd701ba6ed210398d178400e666a1e
Author: Sybren A. Stüvel
Date:   Wed Feb 15 15:26:33 2017 +0100
Branches: temp-sybren-alembic
https://developer.blender.org/rB05950f03cfdd701ba6ed210398d178400e666a1e

Alembic: added some clarification

===

M   source/blender/alembic/intern/abc_util.cc

===

diff --git a/source/blender/alembic/intern/abc_util.cc 
b/source/blender/alembic/intern/abc_util.cc
index 08c94f437e..e3152a17f6 100644
--- a/source/blender/alembic/intern/abc_util.cc
+++ b/source/blender/alembic/intern/abc_util.cc
@@ -161,7 +161,10 @@ static void create_rotation_matrix(
 }
 
 /* Recompute transform matrix of object in new coordinate system
- * (from Y-Up to Z-Up). */
+ * (from Y-Up to Z-Up).
+ *
+ * Note that r_mat is used as both input and output parameter.
+ */
 void create_transform_matrix(float r_mat[4][4])
 {
float rot_mat[3][3], rot[3][3], scale_mat[4][4], invmat[4][4], 
transform_mat[4][4];

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


[Bf-blender-cvs] [3d3b4662b7] temp-sybren-alembic: Alembic: import empties under their own name in Alembic, not their parent's

2017-02-24 Thread Sybren A. Stüvel
Commit: 3d3b4662b727b8fc2f2e1e5ba24f69c7e5f1c6e4
Author: Sybren A. Stüvel
Date:   Wed Feb 15 15:32:15 2017 +0100
Branches: temp-sybren-alembic
https://developer.blender.org/rB3d3b4662b727b8fc2f2e1e5ba24f69c7e5f1c6e4

Alembic: import empties under their own name in Alembic, not their parent's

Before this commit something strange happened, as the m_data_name of
an inherit data-less object was used.

===

M   source/blender/alembic/intern/abc_transform.cc

===

diff --git a/source/blender/alembic/intern/abc_transform.cc 
b/source/blender/alembic/intern/abc_transform.cc
index 99bf7de93f..5f807e2eb4 100644
--- a/source/blender/alembic/intern/abc_transform.cc
+++ b/source/blender/alembic/intern/abc_transform.cc
@@ -132,6 +132,10 @@ bool AbcTransformWriter::hasAnimation(Object * /*ob*/) 
const
 AbcEmptyReader::AbcEmptyReader(const Alembic::Abc::IObject , 
ImportSettings )
 : AbcObjectReader(object, settings)
 {
+   /* Empties have no data. It makes the import of Alembic files easier to
+* understand when we name the empty after its name in Alembic. */
+   m_object_name = object.getName();
+
Alembic::AbcGeom::IXform xform(object, Alembic::AbcGeom::kWrapExisting);
m_schema = xform.getSchema();
 
@@ -145,6 +149,7 @@ bool AbcEmptyReader::valid() const
 
 void AbcEmptyReader::readObjectData(Main *bmain, float /*time*/)
 {
-   m_object = BKE_object_add_only_object(bmain, OB_EMPTY, 
m_data_name.c_str());
+   const char *empty_name = m_iobject.getName().c_str();
+   m_object = BKE_object_add_only_object(bmain, OB_EMPTY, empty_name);
m_object->data = NULL;
 }

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


[Bf-blender-cvs] [af11e2f789] temp-sybren-alembic: Alembic: allow copy_{z, y}up_from_{y, z}up() to be called with yup=zup

2017-02-24 Thread Sybren A. Stüvel
Commit: af11e2f789b3b678f375012bac6fddce0c07fd3e
Author: Sybren A. Stüvel
Date:   Wed Feb 15 15:13:24 2017 +0100
Branches: temp-sybren-alembic
https://developer.blender.org/rBaf11e2f789b3b678f375012bac6fddce0c07fd3e

Alembic: allow copy_{z,y}up_from_{y,z}up() to be called with yup=zup

This allows in-place conversion between z-up and y-up, by passing the
same variable to both arguments.

===

M   source/blender/alembic/intern/abc_util.h

===

diff --git a/source/blender/alembic/intern/abc_util.h 
b/source/blender/alembic/intern/abc_util.h
index a7ac9df91c..a71b749d36 100644
--- a/source/blender/alembic/intern/abc_util.h
+++ b/source/blender/alembic/intern/abc_util.h
@@ -118,32 +118,36 @@ AbcObjectReader *create_reader(const 
Alembic::AbcGeom::IObject , ImportSe
 
 ABC_INLINE void copy_zup_from_yup(float zup[3], const float yup[3])
 {
+   const float old_yup1 = yup[1];  /* in case zup == yup */
zup[0] = yup[0];
zup[1] = -yup[2];
-   zup[2] = yup[1];
+   zup[2] = old_yup1;
 }
 
 ABC_INLINE void copy_zup_from_yup(short zup[3], const short yup[3])
 {
+   const float old_yup1 = yup[1];  /* in case zup == yup */
zup[0] = yup[0];
zup[1] = -yup[2];
-   zup[2] = yup[1];
+   zup[2] = old_yup1;
 }
 
 /* Copy from Z-up to Y-up. */
 
 ABC_INLINE void copy_yup_from_zup(float yup[3], const float zup[3])
 {
+   const float old_zup1 = zup[1];  /* in case yup == zup */
yup[0] = zup[0];
yup[1] = zup[2];
-   yup[2] = -zup[1];
+   yup[2] = -old_zup1;
 }
 
 ABC_INLINE void copy_yup_from_zup(short yup[3], const short zup[3])
 {
+   const float old_zup1 = zup[1];  /* in case yup == zup */
yup[0] = zup[0];
yup[1] = zup[2];
-   yup[2] = -zup[1];
+   yup[2] = -old_zup1;
 }
 
 #endif  /* __ABC_UTIL_H__ */

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


[Bf-blender-cvs] [3f4f0a1b38] temp-sybren-alembic: Alembic: cleaned up hack in AbcObjectReader::read_matrix()

2017-02-24 Thread Sybren A. Stüvel
Commit: 3f4f0a1b38201e14a38eaee0d66feb969da644e1
Author: Sybren A. Stüvel
Date:   Wed Feb 15 15:29:41 2017 +0100
Branches: temp-sybren-alembic
https://developer.blender.org/rB3f4f0a1b38201e14a38eaee0d66feb969da644e1

Alembic: cleaned up hack in AbcObjectReader::read_matrix()

===

M   source/blender/alembic/intern/abc_object.cc

===

diff --git a/source/blender/alembic/intern/abc_object.cc 
b/source/blender/alembic/intern/abc_object.cc
index a5b8af542f..3a3b076dbf 100644
--- a/source/blender/alembic/intern/abc_object.cc
+++ b/source/blender/alembic/intern/abc_object.cc
@@ -239,35 +239,24 @@ void AbcObjectReader::readObjectMatrix(const float time)
 void AbcObjectReader::read_matrix(float mat[4][4], const float time, const 
float scale, bool _constant)
 {
IXform ixform;
-   bool has_alembic_parent = false;
+   IObject ixform_parent;
 
/* Check that we have an empty object (locator, bone head/tail...).  */
if (IXform::matches(m_iobject.getMetaData())) {
ixform = IXform(m_iobject, Alembic::AbcGeom::kWrapExisting);
-
-   /* See comment below. */
-   has_alembic_parent = m_iobject.getParent().getParent().valid();
+   ixform_parent = m_iobject.getParent();
}
/* Check that we have an object with actual data. */
else if (IXform::matches(m_iobject.getParent().getMetaData())) {
ixform = IXform(m_iobject.getParent(), 
Alembic::AbcGeom::kWrapExisting);
-
-   /* This is a bit hackish, but we need to make sure that extra
-* transformations added to the matrix (rotation/scale) are 
only applied
-* to root objects. The way objects and their hierarchy are 
created will
-* need to be revisited at some point but for now this seems to 
do the
-* trick.
-*
-* Explanation of the trick:
-* The first getParent() will return this object's 
transformation matrix.
-* The second getParent() will get the parent of the transform, 
but this
-* might be the archive root ('/') which is valid, so we go 
passed it to
-* make sure that there is no parent.
-*/
-   has_alembic_parent = 
m_iobject.getParent().getParent().getParent().valid();
+   ixform_parent = m_iobject.getParent().getParent();
}
/* Should not happen. */
else {
+   std::cerr << "AbcObjectReader::read_matrix: "
+ << "unable to find IXform for Alembic object '"
+ << m_iobject.getFullName() << "'\n";
+   BLI_assert(false);
return;
}
 
@@ -277,6 +266,20 @@ void AbcObjectReader::read_matrix(float mat[4][4], const 
float time, const float
return;
}
 
+   bool has_alembic_parent;
+   if (!ixform_parent.getParent()) {
+   /* The archive top object certainly is not a transform itself, 
so handle
+* it as "no parent". */
+   has_alembic_parent = false;
+   }
+   else {
+   /* Sybren: getInhertisXforms() should be a const function, see 
Alembic
+* pull request at https://github.com/alembic/alembic/pull/111 
and
+* bug report at https://github.com/alembic/alembic/issues/110 
*/
+   IXformSchema & schema_mutable = const_cast(schema);
+   has_alembic_parent = ixform_parent && 
schema_mutable.getInheritsXforms();
+   }
+
const Imath::M44d matrix = get_matrix(schema, time);
convert_matrix(matrix, m_object, mat, scale, has_alembic_parent);

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


[Bf-blender-cvs] [28105d6447] temp-sybren-alembic: Alembic: Removed AbcTransformWriter::m_parent

2017-02-24 Thread Sybren A. Stüvel
Commit: 28105d64479a22c00051439d62c0a89c0ea9692d
Author: Sybren A. Stüvel
Date:   Tue Feb 14 17:32:55 2017 +0100
Branches: temp-sybren-alembic
https://developer.blender.org/rB28105d64479a22c00051439d62c0a89c0ea9692d

Alembic: Removed AbcTransformWriter::m_parent

It was set, but never read anywhere.

===

M   source/blender/alembic/intern/abc_exporter.cc
M   source/blender/alembic/intern/abc_transform.cc
M   source/blender/alembic/intern/abc_transform.h

===

diff --git a/source/blender/alembic/intern/abc_exporter.cc 
b/source/blender/alembic/intern/abc_exporter.cc
index 90a9946938..77141a9119 100644
--- a/source/blender/alembic/intern/abc_exporter.cc
+++ b/source/blender/alembic/intern/abc_exporter.cc
@@ -451,7 +451,6 @@ void AbcExporter::createTransformWriter(Object *ob, Object 
*parent, Object *dupl
 
if (parent_xform) {
m_xforms[name] = new AbcTransformWriter(ob, 
parent_xform->alembicXform(), parent_xform, m_trans_sampling_index, m_settings);
-   m_xforms[name]->setParent(parent);
}
else {
m_xforms[name] = new AbcTransformWriter(ob, 
m_writer->archive().getTop(), NULL, m_trans_sampling_index, m_settings);
diff --git a/source/blender/alembic/intern/abc_transform.cc 
b/source/blender/alembic/intern/abc_transform.cc
index 2c6ef09326..99bf7de93f 100644
--- a/source/blender/alembic/intern/abc_transform.cc
+++ b/source/blender/alembic/intern/abc_transform.cc
@@ -64,7 +64,6 @@ AbcTransformWriter::AbcTransformWriter(Object *ob,
 : AbcObjectWriter(NULL, ob, time_sampling, settings, parent)
 {
m_is_animated = hasAnimation(m_object);
-   m_parent = NULL;
 
if (!m_is_animated) {
time_sampling = 0;
diff --git a/source/blender/alembic/intern/abc_transform.h 
b/source/blender/alembic/intern/abc_transform.h
index 6a3aae216f..b55fa12dad 100644
--- a/source/blender/alembic/intern/abc_transform.h
+++ b/source/blender/alembic/intern/abc_transform.h
@@ -37,7 +37,6 @@ class AbcTransformWriter : public AbcObjectWriter {
Alembic::Abc::M44d m_matrix;
 
bool m_is_animated;
-   Object *m_parent;
bool m_visible;
 
 public:
@@ -49,7 +48,6 @@ public:
 
Alembic::AbcGeom::OXform () { return m_xform;}
virtual Imath::Box3d bounds();
-   void setParent(Object *p) { m_parent = p; }
 
 private:
virtual void do_write();

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


[Bf-blender-cvs] [b265bd0474] temp-sybren-alembic: Alembic: force ALEMBIC_LIB_USES_BOOST=ON when not using C++11

2017-02-24 Thread Sybren A. Stüvel
Commit: b265bd0474ca303b4a5e91c5b3db401b2b58db7e
Author: Sybren A. Stüvel
Date:   Thu Feb 16 10:59:19 2017 +0100
Branches: temp-sybren-alembic
https://developer.blender.org/rBb265bd0474ca303b4a5e91c5b3db401b2b58db7e

Alembic: force ALEMBIC_LIB_USES_BOOST=ON when not using C++11

Alembic requires one of ALEMBIC_LIB_USES_BOOST, ALEMBIC_LIB_USES_TR1, or
C++11, and silently defaults to the latter if the former two are OFF.

===

M   build_files/build_environment/install_deps.sh

===

diff --git a/build_files/build_environment/install_deps.sh 
b/build_files/build_environment/install_deps.sh
index ee49f83b38..ce0eeeca58 100755
--- a/build_files/build_environment/install_deps.sh
+++ b/build_files/build_environment/install_deps.sh
@@ -2266,6 +2266,12 @@ compile_ALEMBIC() {
 
 cmake_d="-D CMAKE_INSTALL_PREFIX=$_inst"
 
+# Without Boost or TR1, Alembic requires C++11.
+if [ "$USE_CXX11" != true ]; then
+  cmake_d="$cmake_d -D ALEMBIC_LIB_USES_BOOST=ON"
+  cmake_d="$cmake_d -D ALEMBIC_LIB_USES_TR1=OFF"
+fi
+
 if [ -d $INST/boost ]; then
   cmake_d="$cmake_d -D BOOST_ROOT=$INST/boost"
   cmake_d="$cmake_d -D USE_STATIC_BOOST=ON"
@@ -2285,8 +2291,6 @@ compile_ALEMBIC() {
   cmake_d="$cmake_d -D USE_STATIC_HDF5=OFF"
   cmake_d="$cmake_d -D ALEMBIC_ILMBASE_LINK_STATIC=OFF"
   cmake_d="$cmake_d -D ALEMBIC_SHARED_LIBS=OFF"
-  cmake_d="$cmake_d -D ALEMBIC_LIB_USES_BOOST=ON"
-  cmake_d="$cmake_d -D ALEMBIC_LIB_USES_TR1=OFF"
   INFO "ILMBASE_ROOT=$INST/openexr"
 fi

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


[Bf-blender-cvs] [7fc2c072fa] snap_system_clip_planes: Fix fix for realloc!

2017-02-24 Thread Bastien Montagne
Commit: 7fc2c072fab86ed7d2f2e66f703773853e3b97dd
Author: Bastien Montagne
Date:   Fri Feb 24 16:48:57 2017 +0100
Branches: snap_system_clip_planes
https://developer.blender.org/rB7fc2c072fab86ed7d2f2e66f703773853e3b97dd

Fix fix for realloc!

===

M   source/blender/editors/transform/transform_snap_object.c

===

diff --git a/source/blender/editors/transform/transform_snap_object.c 
b/source/blender/editors/transform/transform_snap_object.c
index e710a7aab0..b5925aa120 100644
--- a/source/blender/editors/transform/transform_snap_object.c
+++ b/source/blender/editors/transform/transform_snap_object.c
@@ -2638,7 +2638,7 @@ static bool 
transform_snap_context_project_view3d_mixed_impl(
snpdt->clip.plane = temp_plane;
 #else
snpdt->clip.plane = MEM_reallocN(
-   snpdt->clip.plane, 
sizeof(*snpdt->clip.plane) * snpdt->clip.plane_num + 1);
+   snpdt->clip.plane, 
sizeof(*snpdt->clip.plane) * (snpdt->clip.plane_num + 1));
 #endif
}
else {

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


[Bf-blender-cvs] [3d5149b6d7] snap_system_clip_planes: Fix building on linux (gcc).

2017-02-24 Thread Bastien Montagne
Commit: 3d5149b6d71c53188f9da4b2de199afc36e6114e
Author: Bastien Montagne
Date:   Fri Feb 24 16:47:43 2017 +0100
Branches: snap_system_clip_planes
https://developer.blender.org/rB3d5149b6d71c53188f9da4b2de199afc36e6114e

Fix building on linux (gcc).

===

M   source/blender/blenlib/intern/BLI_kdopbvh.c
M   source/blender/editors/transform/transform_snap_object.c
M   source/blenderplayer/bad_level_call_stubs/stubs.c

===

diff --git a/source/blender/blenlib/intern/BLI_kdopbvh.c 
b/source/blender/blenlib/intern/BLI_kdopbvh.c
index b3f107151a..cfe0e037ca 100644
--- a/source/blender/blenlib/intern/BLI_kdopbvh.c
+++ b/source/blender/blenlib/intern/BLI_kdopbvh.c
@@ -1980,7 +1980,7 @@ static bool bvhtree_walk_dfs_recursive(
return walk_leaf_cb((const BVHTreeAxisRange *)node->bv, 
node->index, parent_flag, userdata);
}
else {
-   short i;
+   int i;
/* First pick the closest node to recurse into */
if (walk_order_cb((const BVHTreeAxisRange *)node->bv, 
node->main_axis, parent_flag, userdata)) {
for (i = 0; i != node->totnode; i++) {
diff --git a/source/blender/editors/transform/transform_snap_object.c 
b/source/blender/editors/transform/transform_snap_object.c
index 63aa00f1f8..e710a7aab0 100644
--- a/source/blender/editors/transform/transform_snap_object.c
+++ b/source/blender/editors/transform/transform_snap_object.c
@@ -23,6 +23,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1590,9 +1591,9 @@ static bool snapCamera(
 
 static const BVHTreeFromMesh *G_treedata = NULL;
 static uint G_ed_num = 0;
-static void G_test_ed(char *func) {
+static void G_test_ed(const char *pre, const char *func, const char *post) {
if (G_treedata && G_treedata->edge) {
-   printf("%s\n", func);
+   printf("%s%s%s\n", pre, func, post);
printf("edge_allocated = %s\n", G_treedata->edge_allocated ? 
"True" : "False");
const MEdge *ed = _treedata->edge[G_ed_num - 1];
printf("reading edge %d:\n", G_ed_num - 1);
@@ -1871,7 +1872,7 @@ static bool snapDerivedMesh(
 
G_treedata = treedata_lt;
G_ed_num = dm->getNumEdges(dm);
-   G_test_ed("***start***\n"__func__);
+   G_test_ed("***start***\n", __func__, "");
 
copy_v3_v3(r_loc, neasrest2d.co);
mul_m4_v3(obmat, r_loc);
@@ -1889,9 +1890,9 @@ static bool snapDerivedMesh(
}
}
 
-   G_test_ed(__func__": before release");
+   G_test_ed("", __func__, ": before release");
dm->release(dm);
-   G_test_ed(__func__": after release :(");
+   G_test_ed("", __func__, ": after release :(");
 
return retval;
 }
diff --git a/source/blenderplayer/bad_level_call_stubs/stubs.c 
b/source/blenderplayer/bad_level_call_stubs/stubs.c
index 08d00e9148..59c459a660 100644
--- a/source/blenderplayer/bad_level_call_stubs/stubs.c
+++ b/source/blenderplayer/bad_level_call_stubs/stubs.c
@@ -548,10 +548,9 @@ SnapObjectContext 
*ED_transform_snap_object_context_create_view3d(
 void ED_transform_snap_object_context_destroy(SnapObjectContext *sctx) RET_NONE
 bool ED_transform_snap_object_project_ray_ex(
 struct SnapObjectContext *sctx,
-const unsigned short snap_to,
 const struct SnapObjectParams *params,
-const float ray_start[3], const float ray_normal[3], float *ray_depth,
-/* return args */
+const float ray_start[3], const float ray_normal[3],
+float *ray_depth,
 float r_loc[3], float r_no[3], int *r_index,
 struct Object **r_ob, float r_obmat[4][4]) RET_ZERO

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


[Bf-blender-cvs] [793aaa47ec] snap_system_clip_planes: Fix MEM_reallocN use

2017-02-24 Thread Germano Cavalcante
Commit: 793aaa47ec3eadfb964da36ab62e42e6d2d2548e
Author: Germano Cavalcante
Date:   Fri Feb 24 12:46:02 2017 -0300
Branches: snap_system_clip_planes
https://developer.blender.org/rB793aaa47ec3eadfb964da36ab62e42e6d2d2548e

Fix MEM_reallocN use

===

M   source/blender/editors/transform/transform_snap_object.c

===

diff --git a/source/blender/editors/transform/transform_snap_object.c 
b/source/blender/editors/transform/transform_snap_object.c
index cc520ac1cf..63aa00f1f8 100644
--- a/source/blender/editors/transform/transform_snap_object.c
+++ b/source/blender/editors/transform/transform_snap_object.c
@@ -444,11 +444,8 @@ static bool snapdata_init_v3d(
 
if (rv3d->rflag & RV3D_CLIPPING) {
/* Referencing or copying? */
-   snpdt->clip.plane = MEM_mallocN( 4 * sizeof(float[4]), 
__func__);
-   for (int i = 0; i < 4; i++) {
-   copy_v4_v4(snpdt->clip.plane[i], rv3d->clip[i]);
-   }
-   //memcpy(snpdt->clip.plane, rv3d->clip, 4 * sizeof(float[4]));
+   snpdt->clip.plane = MEM_mallocN( 4 * 
sizeof(*snpdt->clip.plane), __func__);
+   memcpy(snpdt->clip.plane, rv3d->clip, 4 * 
sizeof(*snpdt->clip.plane));
snpdt->clip.plane_num = 4;
 
float dummy_ray_end[3];
@@ -2626,7 +2623,8 @@ static bool 
transform_snap_context_project_view3d_mixed_impl(
mul_m4_v3(imat, normal_local);
 
if (snpdt->clip.plane) {
-#if PREPEND_PLANE
+#define PREPEND_PLANE
+#ifdef PREPEND_PLANE
/* Alloc the new plane at the beginning 
of the array */
float (*temp_plane)[4] = MEM_mallocN(
sizeof(*temp_plane) * 
(snpdt->clip.plane_num + 1), __func__);
@@ -2638,7 +2636,8 @@ static bool 
transform_snap_context_project_view3d_mixed_impl(
 
snpdt->clip.plane = temp_plane;
 #else
-   snpdt->clip.plane = 
MEM_reallocN(snpdt->clip.plane, snpdt->clip.plane_num + 1);
+   snpdt->clip.plane = MEM_reallocN(
+   snpdt->clip.plane, 
sizeof(*snpdt->clip.plane) * snpdt->clip.plane_num + 1);
 #endif
}
else {
@@ -2705,7 +2704,7 @@ static bool 
transform_snap_context_project_view3d_mixed_impl(
 
mul_m4_v3(obmat, far_vert);
 
-#if PREPEND_PLANE
+#ifdef PREPEND_PLANE
plane_from_point_normal_v3(
snpdt->clip.plane[0], far_vert, 
plane_no);

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


[Bf-blender-cvs] [9f69efbd81] snap_system_clip_planes: Innitial commit: Snap system - Adds Clip Plan support and simulates occlusion

2017-02-24 Thread Germano Cavalcante
Commit: 9f69efbd819fc9c914f66fae0368e30ea955182a
Author: Germano Cavalcante
Date:   Fri Feb 24 12:40:39 2017 -0300
Branches: snap_system_clip_planes
https://developer.blender.org/rB9f69efbd819fc9c914f66fae0368e30ea955182a

Innitial commit: Snap system - Adds Clip Plan support and simulates occlusion

The main alterations here were made in the transform_snap_object.c file.
The main change add the "clip plans" of the `rv3d->clip` to bypass the snap to 
unseen elements. This solution continues to take advantage of the BVH.

Since we can use clip planes, we can now simulate occlusion (ie ignore what is 
behind a face), first a raycast is made to get the normal and coordinates of 
the polygon of the hit. Then a plane is created just behind the polygon, thus 
ignoring everything that is behind it when a snap is made for vertex or edge.

This is not the ideal occlusion solution, but it is already a good step to get 
the perfect occlusion test.

In addition to this change other changes were made:

Now snap_to is a flag that can indicate whether the snap is made for one, two 
or all elements at the same time (this will not change much for the user, the 
only operator using mixed snap is the ruler) ;
if the object is in wireframe mode or Bounding Box, they are ignored in snap to 
face (good idea?);
use the BVHTree of looptris to snap vertices and edges (saves memory);

===

M   source/blender/blenkernel/BKE_bvhutils.h
M   source/blender/blenkernel/intern/bvhutils.c
M   source/blender/blenlib/BLI_kdopbvh.h
M   source/blender/blenlib/BLI_math_geom.h
M   source/blender/blenlib/intern/BLI_kdopbvh.c
M   source/blender/blenlib/intern/math_geom.c
M   source/blender/editors/include/ED_transform_snap_object_context.h
M   source/blender/editors/transform/transform_snap_object.c
M   source/blender/makesrna/intern/rna_scene_api.c

===

diff --git a/source/blender/blenkernel/BKE_bvhutils.h 
b/source/blender/blenkernel/BKE_bvhutils.h
index cb72f0859d..351dd652ac 100644
--- a/source/blender/blenkernel/BKE_bvhutils.h
+++ b/source/blender/blenkernel/BKE_bvhutils.h
@@ -160,8 +160,8 @@ BVHTree *bvhtree_from_mesh_looptri(
 struct BVHTreeFromMesh *data, struct DerivedMesh *mesh, float epsilon, 
int tree_type, int axis);
 BVHTree *bvhtree_from_mesh_looptri_ex(
 struct BVHTreeFromMesh *data,
-const struct MVert *vert, const bool vert_allocated,
-const struct MLoop *mloop, const bool loop_allocated,
+struct MVert *vert, const bool vert_allocated,
+struct MLoop *mloop, const bool loop_allocated,
 const struct MLoopTri *looptri, const int looptri_num, const bool 
looptri_allocated,
 const BLI_bitmap *mask, int looptri_num_active,
 float epsilon, int tree_type, int axis);
@@ -195,12 +195,20 @@ enum {
BVHTREE_FROM_LOOPTRI = 3,
 
BVHTREE_FROM_EM_LOOPTRI  = 4,
+
+   BVHTREE_FROM_LOOSE_VERTS = 5,
+   BVHTREE_FROM_LOOSE_EDGES = 6,
 };
 
 
 BVHTree *bvhcache_find(BVHCache *cache, int type);
+BVHTree *bvhcache_thread_safe_find(BVHCache *cache, int type);
+
 bool bvhcache_has_tree(const BVHCache *cache, const BVHTree *tree);
+
 void bvhcache_insert(BVHCache **cache_p, BVHTree *tree, int type);
+void bvhcache_thread_safe_insert(BVHCache **cache_p, BVHTree *tree, int 
type);
+
 void bvhcache_init(BVHCache **cache_p);
 void bvhcache_free(BVHCache **cache_p);
 
diff --git a/source/blender/blenkernel/intern/bvhutils.c 
b/source/blender/blenkernel/intern/bvhutils.c
index c0e4ef37a9..4a548b69f9 100644
--- a/source/blender/blenkernel/intern/bvhutils.c
+++ b/source/blender/blenkernel/intern/bvhutils.c
@@ -431,20 +431,24 @@ static BVHTree *bvhtree_from_mesh_verts_create_tree(
verts_num_active = verts_num;
}
 
-   BVHTree *tree = BLI_bvhtree_new(verts_num_active, epsilon, tree_type, 
axis);
+   if (verts_num_active) {
+   BVHTree *tree = BLI_bvhtree_new(verts_num_active, epsilon, 
tree_type, axis);
 
-   if (tree) {
-   for (int i = 0; i < verts_num; i++) {
-   if (verts_mask && !BLI_BITMAP_TEST_BOOL(verts_mask, i)) 
{
-   continue;
+   if (tree) {
+   for (int i = 0; i < verts_num; i++) {
+   if (verts_mask && 
!BLI_BITMAP_TEST_BOOL(verts_mask, i)) {
+   continue;
+   }
+   BLI_bvhtree_insert(tree, i, vert[i].co, 1);
}
-   BLI_bvhtree_insert(tree, i, vert[i].co, 1);
+   BLI_assert(BLI_bvhtree_get_size(tree) == 
verts_num_active);
+   BLI_bvhtree_balance(tree);
}
-   

[Bf-blender-cvs] [e92f235283] blender-v2.78c-release: Revert "tests: Update hash for OBJ"

2017-02-24 Thread Sergey Sharybin
Commit: e92f235283071c13759bc4e6e861e4e938985307
Author: Sergey Sharybin
Date:   Fri Feb 24 15:32:16 2017 +0100
Branches: blender-v2.78c-release
https://developer.blender.org/rBe92f235283071c13759bc4e6e861e4e938985307

Revert "tests: Update hash for OBJ"

This changed commit was never in the release branches.

Not sure why at some point CTest was expecting new hash.

Probably because addons were pointing to a latest revision.

This reverts commit bc27652e574a58755303442b4820620048d87615.

===

M   tests/python/CMakeLists.txt

===

diff --git a/tests/python/CMakeLists.txt b/tests/python/CMakeLists.txt
index b76c47fcf2..d9731a5dfa 100644
--- a/tests/python/CMakeLists.txt
+++ b/tests/python/CMakeLists.txt
@@ -135,7 +135,7 @@ add_test(export_obj_cube ${TEST_BLENDER_EXE}

--run={'FINISHED'}_scene.obj\(filepath='${TEST_OUT_DIR}/export_obj_cube.obj',use_selection=False\)
--md5_source=${TEST_OUT_DIR}/export_obj_cube.obj
--md5_source=${TEST_OUT_DIR}/export_obj_cube.mtl
-   --md5=e80660437ad9bfe082849641c361a233 --md5_method=FILE
+   --md5=826f74e6b7a2128b0b61a52071ada36e --md5_method=FILE
 )
 
 add_test(export_obj_nurbs ${TEST_BLENDER_EXE}

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


[Bf-blender-cvs] [9062c086b4] master: Fix T50676: Crash on closing while frameserver rendering.

2017-02-24 Thread Bastien Montagne
Commit: 9062c086b481ee9f1307f6e2688d822a1166d805
Author: Bastien Montagne
Date:   Fri Feb 24 14:56:50 2017 +0100
Branches: master
https://developer.blender.org/rB9062c086b481ee9f1307f6e2688d822a1166d805

Fix T50676: Crash on closing while frameserver rendering.

Can't see any reason to call AUD exit early in WM_exit, that's a
low-level module that has no dependency on anything else in Blender, but
is dependency of some other parts of Blender, so it should rather be
exited late in the process!

===

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

===

diff --git a/source/blender/windowmanager/intern/wm_init_exit.c 
b/source/blender/windowmanager/intern/wm_init_exit.c
index c11c398c61..4b2369a1a7 100644
--- a/source/blender/windowmanager/intern/wm_init_exit.c
+++ b/source/blender/windowmanager/intern/wm_init_exit.c
@@ -444,8 +444,6 @@ void WM_exit_ext(bContext *C, const bool do_python)
 {
wmWindowManager *wm = C ? CTX_wm_manager(C) : NULL;
 
-   BKE_sound_exit();
-
/* first wrap up running stuff, we assume only the active WM is running 
*/
/* modal handlers are on window level freed, others too? */
/* note; same code copied in wm_files.c */
@@ -591,6 +589,10 @@ void WM_exit_ext(bContext *C, const bool do_python)
 
BLI_threadapi_exit();
 
+   /* No need to call this early, rather do it late so that other pieces 
of Blender using sound may exit cleanly,
+* see also T50676. */
+   BKE_sound_exit();
+
BKE_blender_atexit();
 
if (MEM_get_memory_blocks_in_use() != 0) {

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


[Bf-blender-cvs] [728fd9a78c] blender-v2.78c-release: Cycles: Fix compilation warning with CUDA on OSX

2017-02-24 Thread Sergey Sharybin
Commit: 728fd9a78cb19a7d4357bfd06ff63bbfa2cd6511
Author: Sergey Sharybin
Date:   Fri Feb 24 14:33:10 2017 +0100
Branches: blender-v2.78c-release
https://developer.blender.org/rB728fd9a78cb19a7d4357bfd06ff63bbfa2cd6511

Cycles: Fix compilation warning with CUDA on OSX

===

M   intern/cycles/util/util_static_assert.h

===

diff --git a/intern/cycles/util/util_static_assert.h 
b/intern/cycles/util/util_static_assert.h
index 033d85e8ec..e90049254d 100644
--- a/intern/cycles/util/util_static_assert.h
+++ b/intern/cycles/util/util_static_assert.h
@@ -43,7 +43,9 @@ template <> class StaticAssertFailure {};
 #endif  /* __COUNTER__ */
 #  endif  /* C++11 or MSVC2015 */
 #else  /* __KERNEL_GPU__ */
-#  define static_assert(statement, message)
+#  ifndef static_assert
+#define static_assert(statement, message)
+#  endif
 #endif  /* __KERNEL_GPU__ */
 
 /* TODO(sergey): For until C++11 is a bare minimum for us,

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


[Bf-blender-cvs] [1e29286c8c] master: Cycles: Fix compilation warning with CUDA on OSX

2017-02-24 Thread Sergey Sharybin
Commit: 1e29286c8c98aedcb01ef66378ca10c49f354e50
Author: Sergey Sharybin
Date:   Fri Feb 24 14:33:10 2017 +0100
Branches: master
https://developer.blender.org/rB1e29286c8c98aedcb01ef66378ca10c49f354e50

Cycles: Fix compilation warning with CUDA on OSX

===

M   intern/cycles/util/util_static_assert.h

===

diff --git a/intern/cycles/util/util_static_assert.h 
b/intern/cycles/util/util_static_assert.h
index 033d85e8ec..e90049254d 100644
--- a/intern/cycles/util/util_static_assert.h
+++ b/intern/cycles/util/util_static_assert.h
@@ -43,7 +43,9 @@ template <> class StaticAssertFailure {};
 #endif  /* __COUNTER__ */
 #  endif  /* C++11 or MSVC2015 */
 #else  /* __KERNEL_GPU__ */
-#  define static_assert(statement, message)
+#  ifndef static_assert
+#define static_assert(statement, message)
+#  endif
 #endif  /* __KERNEL_GPU__ */
 
 /* TODO(sergey): For until C++11 is a bare minimum for us,

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


[Bf-blender-cvs] [90d96de0a8] blender-v2.78c-release: Cycles: Fix non-zero exit status when rendering animation from CLI and running out of memory

2017-02-24 Thread Sergey Sharybin
Commit: 90d96de0a84631169f45bcb9aea0775708a2e4a6
Author: Sergey Sharybin
Date:   Fri Feb 24 14:25:11 2017 +0100
Branches: blender-v2.78c-release
https://developer.blender.org/rB90d96de0a84631169f45bcb9aea0775708a2e4a6

Cycles: Fix non-zero exit status when rendering animation from CLI and running 
out of memory

===

M   source/creator/creator_args.c

===

diff --git a/source/creator/creator_args.c b/source/creator/creator_args.c
index 3335fd3dd5..47079319de 100644
--- a/source/creator/creator_args.c
+++ b/source/creator/creator_args.c
@@ -1398,10 +1398,11 @@ static int arg_handle_render_animation(int 
UNUSED(argc), const char **UNUSED(arg
Render *re = RE_NewRender(scene->id.name);
ReportList reports;
BLI_begin_threaded_malloc();
-   BKE_reports_init(, RPT_PRINT);
+   BKE_reports_init(, RPT_STORE);
RE_SetReports(re, );
RE_BlenderAnim(re, bmain, scene, NULL, scene->lay, 
scene->r.sfra, scene->r.efra, scene->r.frame_step);
RE_SetReports(re, NULL);
+   BKE_reports_clear();
BLI_end_threaded_malloc();
}
else {

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


[Bf-blender-cvs] [f49e28bae7] master: Cycles: Fix non-zero exit status when rendering animation from CLI and running out of memory

2017-02-24 Thread Sergey Sharybin
Commit: f49e28bae71b7efa08df0fe6900595046fa31814
Author: Sergey Sharybin
Date:   Fri Feb 24 14:25:11 2017 +0100
Branches: master
https://developer.blender.org/rBf49e28bae71b7efa08df0fe6900595046fa31814

Cycles: Fix non-zero exit status when rendering animation from CLI and running 
out of memory

===

M   source/creator/creator_args.c

===

diff --git a/source/creator/creator_args.c b/source/creator/creator_args.c
index 77ca055dce..3c01c0c447 100644
--- a/source/creator/creator_args.c
+++ b/source/creator/creator_args.c
@@ -1407,10 +1407,11 @@ static int arg_handle_render_animation(int 
UNUSED(argc), const char **UNUSED(arg
Render *re = RE_NewRender(scene->id.name);
ReportList reports;
BLI_begin_threaded_malloc();
-   BKE_reports_init(, RPT_PRINT);
+   BKE_reports_init(, RPT_STORE);
RE_SetReports(re, );
RE_BlenderAnim(re, bmain, scene, NULL, scene->lay, 
scene->r.sfra, scene->r.efra, scene->r.frame_step);
RE_SetReports(re, NULL);
+   BKE_reports_clear();
BLI_end_threaded_malloc();
}
else {

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


[Bf-blender-cvs] [d9e6268e89] blender-v2.78c-release: Fix Cycles still saving render output when error happened

2017-02-24 Thread Sergey Sharybin
Commit: d9e6268e8912c495a117dc0805ec33dd8125a269
Author: Sergey Sharybin
Date:   Wed Feb 22 13:06:24 2017 +0100
Branches: blender-v2.78c-release
https://developer.blender.org/rBd9e6268e8912c495a117dc0805ec33dd8125a269

Fix Cycles still saving render output when error happened

This was fixed ages ago for the interface case but not for the
command line. The thing here is that currently external engines
are relying on reports system to indicate that error happened
so suppressing reports storage in the background mode prevented
render pipeline from detecting errors happened.

This is all weak and i don't like it, but this is better than
delivering black frames from the farm.

===

M   source/creator/creator_args.c

===

diff --git a/source/creator/creator_args.c b/source/creator/creator_args.c
index c3c76a0d1d..3335fd3dd5 100644
--- a/source/creator/creator_args.c
+++ b/source/creator/creator_args.c
@@ -1355,7 +1355,7 @@ static int arg_handle_render_frame(int argc, const char 
**argv, void *data)
 
re = RE_NewRender(scene->id.name);
BLI_begin_threaded_malloc();
-   BKE_reports_init(, RPT_PRINT);
+   BKE_reports_init(, RPT_STORE);
 
RE_SetReports(re, );
for (int i = 0; i < frames_range_len; i++) {
@@ -1370,6 +1370,7 @@ static int arg_handle_render_frame(int argc, const char 
**argv, void *data)
}
}
RE_SetReports(re, NULL);
+   BKE_reports_clear();
BLI_end_threaded_malloc();
MEM_freeN(frame_range_arr);
return 1;

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


[Bf-blender-cvs] [1f453a8909] blender2.8: OpenColorIO: Update glsl implementation to be ready for ogl 3.3 core

2017-02-24 Thread Clément Foucault
Commit: 1f453a8909527a95fedd597b4fdaab90c18712f9
Author: Clément Foucault
Date:   Fri Feb 24 12:38:35 2017 +0100
Branches: blender2.8
https://developer.blender.org/rB1f453a8909527a95fedd597b4fdaab90c18712f9

OpenColorIO: Update glsl implementation to be ready for ogl 3.3 core

===

M   intern/opencolorio/CMakeLists.txt
M   intern/opencolorio/gpu_shader_display_transform.glsl
A   intern/opencolorio/gpu_shader_display_transform_vertex.glsl
M   intern/opencolorio/ocio_impl_glsl.cc
M   source/blender/gpu/shaders/gpu_shader_2D_image_vert.glsl

===

diff --git a/intern/opencolorio/CMakeLists.txt 
b/intern/opencolorio/CMakeLists.txt
index 61a8d995f4..f7e8d909f2 100644
--- a/intern/opencolorio/CMakeLists.txt
+++ b/intern/opencolorio/CMakeLists.txt
@@ -66,6 +66,7 @@ if(WITH_OPENCOLORIO)
endif()
 
data_to_c_simple(gpu_shader_display_transform.glsl SRC)
+   data_to_c_simple(gpu_shader_display_transform_vertex.glsl SRC)
 endif()
 
 
diff --git a/intern/opencolorio/gpu_shader_display_transform.glsl 
b/intern/opencolorio/gpu_shader_display_transform.glsl
index 853bf57558..4a63405045 100644
--- a/intern/opencolorio/gpu_shader_display_transform.glsl
+++ b/intern/opencolorio/gpu_shader_display_transform.glsl
@@ -10,6 +10,15 @@ uniform float image_texture_width;
 uniform float image_texture_height;
 #endif
 
+#if __VERSION__ < 130
+  varying vec2 texCoord_interp;
+  #define fragColor gl_FragColor
+#else
+  in vec2 texCoord_interp;
+  out vec4 fragColor;
+  #define texture2D texture
+#endif
+
 #ifdef USE_CURVE_MAPPING
 /* Curve mapping parameters
  *
@@ -143,7 +152,7 @@ vec4 apply_dither(vec2 st, vec4 col)
 
 void main()
 {
-   vec4 col = texture2D(image_texture, gl_TexCoord[0].st);
+   vec4 col = texture2D(image_texture, texCoord_interp.st);
 #ifdef USE_CURVE_MAPPING
col = curvemapping_evaluate_premulRGBF(col);
 #endif
@@ -165,8 +174,8 @@ void main()
vec4 result = OCIODisplay(col, lut3d_texture);
 
 #ifdef USE_DITHER
-   result = apply_dither(gl_TexCoord[0].st, result);
+   result = apply_dither(texCoord_interp.st, result);
 #endif
 
-   gl_FragColor = result;
+   fragColor = result;
 }
diff --git a/source/blender/gpu/shaders/gpu_shader_2D_image_vert.glsl 
b/intern/opencolorio/gpu_shader_display_transform_vertex.glsl
similarity index 100%
copy from source/blender/gpu/shaders/gpu_shader_2D_image_vert.glsl
copy to intern/opencolorio/gpu_shader_display_transform_vertex.glsl
diff --git a/intern/opencolorio/ocio_impl_glsl.cc 
b/intern/opencolorio/ocio_impl_glsl.cc
index bf91ea143d..9dba37f27e 100644
--- a/intern/opencolorio/ocio_impl_glsl.cc
+++ b/intern/opencolorio/ocio_impl_glsl.cc
@@ -58,6 +58,7 @@ using namespace OCIO_NAMESPACE;
 static const int LUT3D_EDGE_SIZE = 64;
 
 extern "C" char datatoc_gpu_shader_display_transform_glsl[];
+extern "C" char datatoc_gpu_shader_display_transform_vertex_glsl[];
 
 /*  OpenGL drawing routines using GLSL for color space transform * */
 
@@ -89,6 +90,7 @@ typedef struct OCIO_GLSLDrawState {
 
/* GLSL stuff */
GLuint ocio_shader;
+   GLuint vert_shader;
GLuint program;
 
/* Previous OpenGL state. */
@@ -116,14 +118,15 @@ static GLuint compileShaderText(GLenum shaderType, const 
char *text)
return shader;
 }
 
-static GLuint linkShaders(GLuint ocio_shader)
+static GLuint linkShaders(GLuint ocio_shader, GLuint vert_shader)
 {
-   if (!ocio_shader)
+   if (!ocio_shader || !vert_shader)
return 0;
 
GLuint program = glCreateProgram();
 
glAttachShader(program, ocio_shader);
+   glAttachShader(program, vert_shader);
 
glLinkProgram(program);
 
@@ -339,6 +342,25 @@ bool OCIOImpl::setupGLSLDraw(OCIO_GLSLDrawState **state_r, 
OCIO_ConstProcessorRc
glDeleteShader(state->ocio_shader);
}
 
+   if (state->vert_shader) {
+   glDeleteShader(state->vert_shader);
+   }
+
+   /* Vertex shader */
+   std::ostringstream osv;
+
+   if (supportGLSL13()) {
+   osv << "#version 130\n";
+   }
+   else {
+   osv << "#version 120\n";
+   }
+
+   osv << datatoc_gpu_shader_display_transform_vertex_glsl;
+
+   state->vert_shader = compileShaderText(GL_VERTEX_SHADER, 
osv.str().c_str());
+
+   /* Fragment shader */
std::ostringstream os;
 
if (supportGLSL13()) {
@@ -366,8 +388,8 @@ bool OCIOImpl::setupGLSLDraw(OCIO_GLSLDrawState **state_r, 
OCIO_ConstProcessorRc
 
state->ocio_shader = compileShaderText(GL_FRAGMENT_SHADER, 
os.str().c_str());
 
-   if (state->ocio_shader) {
-   state->program = 

[Bf-blender-cvs] [1e7475a5d7] blender2.8: Opengl glaDrawPixels removal: More descriptive setup.

2017-02-24 Thread Clément Foucault
Commit: 1e7475a5d7878642057ea0cb313b5ee0d4a8545e
Author: Clément Foucault
Date:   Fri Feb 24 11:11:43 2017 +0100
Branches: blender2.8
https://developer.blender.org/rB1e7475a5d7878642057ea0cb313b5ee0d4a8545e

Opengl glaDrawPixels removal: More descriptive setup.

===

M   source/blender/editors/include/BIF_glutil.h
M   source/blender/editors/interface/interface_draw.c
M   source/blender/editors/interface/interface_icons.c
M   source/blender/editors/mask/mask_draw.c
M   source/blender/editors/render/render_internal.c
M   source/blender/editors/render/render_preview.c
M   source/blender/editors/screen/glutil.c
M   source/blender/editors/space_file/file_draw.c
M   source/blender/editors/space_image/image_draw.c
M   source/blender/editors/space_node/drawnode.c
M   source/blender/editors/space_node/node_draw.c
M   source/blender/editors/space_view3d/view3d_draw_legacy.c
M   source/blender/windowmanager/intern/wm_dragdrop.c
M   source/blender/windowmanager/intern/wm_gesture.c

===

diff --git a/source/blender/editors/include/BIF_glutil.h 
b/source/blender/editors/include/BIF_glutil.h
index a3161b49d4..0b85517f33 100644
--- a/source/blender/editors/include/BIF_glutil.h
+++ b/source/blender/editors/include/BIF_glutil.h
@@ -210,6 +210,12 @@ void glaDrawPixelsTex(float x, float y, int img_w, int 
img_h, int format, int ty
 void glaDrawPixelsTex_clipping(float x, float y, int img_w, int img_h, int 
format, int type, int zoomfilter, void *rect,
float clip_min_x, float clip_min_y, float 
clip_max_x, float clip_max_y);
 #endif
+
+/* To be used before calling immDrawPixelsTex
+ * Default shader is GPU_SHADER_2D_IMAGE_COLOR
+ * Returns a shader to be able to set uniforms */
+struct GPUShader *immDrawPixelsTexSetup(int builtin);
+
 /**
  * immDrawPixelsTex - Functions like a limited glDrawPixels, but actually 
draws the
  * image using textures, which can be tremendously faster on low-end
@@ -217,6 +223,8 @@ void glaDrawPixelsTex_clipping(float x, float y, int img_w, 
int img_h, int forma
  * clipped when offscreen. Pixel unpacking parameters and
  * the glPixelZoom values are _not_ respected.
  *
+ * \attention Use immDrawPixelsTexSetup before calling this function.
+ *
  * \attention This routine makes many assumptions: the rect data
  * is expected to be in RGBA byte or float format, and the
  * modelview and projection matrices are assumed to define a
diff --git a/source/blender/editors/interface/interface_draw.c 
b/source/blender/editors/interface/interface_draw.c
index b48eb4d79d..64f7b1adc3 100644
--- a/source/blender/editors/interface/interface_draw.c
+++ b/source/blender/editors/interface/interface_draw.c
@@ -501,6 +501,7 @@ void ui_draw_but_IMAGE(ARegion *UNUSED(ar), uiBut *but, 
uiWidgetColors *UNUSED(w
facy = (float)h / (float)ibuf->y;
}
 
+   immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_COLOR);
immDrawPixelsTex((float)rect->xmin, (float)rect->ymin, ibuf->x, 
ibuf->y, GL_RGBA, GL_UNSIGNED_BYTE, GL_NEAREST, ibuf->rect,
 facx, facy, NULL);

@@ -1735,7 +1736,7 @@ void ui_draw_but_TRACKPREVIEW(ARegion *ar, uiBut *but, 
uiWidgetColors *UNUSED(wc
UI_draw_roundbox_gl_mode(GL_TRIANGLE_FAN, 
rect.xmin - 1, rect.ymin, rect.xmax + 1, rect.ymax + 1, 3.0f, color);
}
 
-   GPU_shader_unbind(); /* make sure there is no program 
bound */
+   immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_COLOR);
immDrawPixelsTex(rect.xmin, rect.ymin + 1, drawibuf->x, 
drawibuf->y, GL_RGBA, GL_UNSIGNED_BYTE, GL_LINEAR, drawibuf->rect, 1.0f, 1.0f, 
NULL);
 
/* draw cross for pixel position */
diff --git a/source/blender/editors/interface/interface_icons.c 
b/source/blender/editors/interface/interface_icons.c
index 3def3e3598..ef394899ac 100644
--- a/source/blender/editors/interface/interface_icons.c
+++ b/source/blender/editors/interface/interface_icons.c
@@ -1009,6 +1009,7 @@ static void icon_draw_rect(float x, float y, int w, int 
h, float UNUSED(aspect),
/* draw */
 #if 0
if (is_preview) {
+   immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_COLOR);
immDrawPixelsTex(draw_x, draw_y, draw_w, draw_h, GL_RGBA, 
GL_UNSIGNED_BYTE, GL_NEAREST, rect,
 1.0f, 1.0f, col);
}
@@ -1017,6 +1018,7 @@ static void icon_draw_rect(float x, float y, int w, int 
h, float UNUSED(aspect),
int bound_options;
GPU_BASIC_SHADER_DISABLE_AND_STORE(bound_options);
 
+   immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_COLOR);
immDrawPixelsTex(draw_x, draw_y, draw_w, draw_h, GL_RGBA, 
GL_UNSIGNED_BYTE, GL_NEAREST, rect,
   

[Bf-blender-cvs] [0584c82ad7] blender2.8: Fix break in drawscredge_area_draw when in fullscreen

2017-02-24 Thread Dalai Felinto
Commit: 0584c82ad7c1c2f133f617c52de28be15f6840d4
Author: Dalai Felinto
Date:   Fri Feb 24 11:05:52 2017 +0100
Branches: blender2.8
https://developer.blender.org/rB0584c82ad7c1c2f133f617c52de28be15f6840d4

Fix break in drawscredge_area_draw when in fullscreen

===

M   source/blender/editors/screen/screen_draw.c

===

diff --git a/source/blender/editors/screen/screen_draw.c 
b/source/blender/editors/screen/screen_draw.c
index 7ba3c4b82b..7d85f9bb1c 100644
--- a/source/blender/editors/screen/screen_draw.c
+++ b/source/blender/editors/screen/screen_draw.c
@@ -241,6 +241,10 @@ static void drawscredge_area_draw(int sizex, int sizey, 
short x1, short y1, shor
if (y2 < sizey - 1) count += 2;
if (y1 > 0) count += 2;
 
+   if (count == 0) {
+   return;
+   }
+
immBegin(GL_LINES, count);
 
/* right border area */

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


[Bf-blender-cvs] [2f9a0dfe64] blender2.8: Fix T50714: Collections: Adding object to scene without an existing collection

2017-02-24 Thread Dalai Felinto
Commit: 2f9a0dfe6429661f1d4bdf28398504df7fe98beb
Author: Dalai Felinto
Date:   Thu Feb 23 12:35:14 2017 +0100
Branches: blender2.8
https://developer.blender.org/rB2f9a0dfe6429661f1d4bdf28398504df7fe98beb

Fix T50714: Collections: Adding object to scene without an existing collection

This was causing blender to segfault.

We now add create a new collection and link to the layer before adding
the new object

(also included unittests, and requires updated lib/tests)

===

M   release/scripts/modules/bpy_extras/object_utils.py
M   source/blender/blenkernel/intern/object.c
M   tests/python/render_layer/CMakeLists.txt
M   tests/python/render_layer/render_layer_common.py
A   tests/python/render_layer/test_object_add_no_collection_cylinder.py
A   tests/python/render_layer/test_object_add_no_collection_empty.py
A   tests/python/render_layer/test_object_add_no_collection_torus.py

===

diff --git a/release/scripts/modules/bpy_extras/object_utils.py 
b/release/scripts/modules/bpy_extras/object_utils.py
index d740137b0c..83d3b2066b 100644
--- a/release/scripts/modules/bpy_extras/object_utils.py
+++ b/release/scripts/modules/bpy_extras/object_utils.py
@@ -121,7 +121,14 @@ def object_data_add(context, obdata, operator=None, 
name=None):
 """
 scene = context.scene
 layer = context.render_layer
-scene_collection = context.scene_collection
+layer_collection = context.layer_collection
+
+if not layer_collection:
+# when there is no collection linked to this render_layer create one
+scene_collection = scene.master_collection.collections.new("")
+layer_collection = layer.collections.link(scene_collection)
+else:
+scene_collection = layer_collection.collection
 
 bpy.ops.object.select_all(action='DESELECT')
 
diff --git a/source/blender/blenkernel/intern/object.c 
b/source/blender/blenkernel/intern/object.c
index ad0ce3fef9..250ad6794f 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -692,6 +692,14 @@ Object *BKE_object_add(
ob->data = BKE_object_obdata_add_from_type(bmain, type, name);
 
lc = BKE_layer_collection_active(sl);
+
+   if (lc == NULL) {
+   BLI_assert(BLI_listbase_count_ex(>layer_collections, 1) == 
0);
+   /* when there is no collection linked to this SceneLayer, 
create one */
+   SceneCollection *sc = BKE_collection_add(scene, NULL, NULL);
+   lc = BKE_collection_link(sl, sc);
+   }
+
BKE_collection_object_add(scene, lc->scene_collection, ob);
 
base = BKE_scene_layer_base_find(sl, ob);
diff --git a/tests/python/render_layer/CMakeLists.txt 
b/tests/python/render_layer/CMakeLists.txt
index ff98d95cc0..7825326817 100644
--- a/tests/python/render_layer/CMakeLists.txt
+++ b/tests/python/render_layer/CMakeLists.txt
@@ -67,6 +67,9 @@ RENDER_LAYER_TEST(operator_context)
 RENDER_LAYER_TEST(object_add_cylinder)
 RENDER_LAYER_TEST(object_add_empty)
 RENDER_LAYER_TEST(object_add_torus)
+RENDER_LAYER_TEST(object_add_no_collection_cylinder)
+RENDER_LAYER_TEST(object_add_no_collection_empty)
+RENDER_LAYER_TEST(object_add_no_collection_torus)
 RENDER_LAYER_TEST(object_copy)
 RENDER_LAYER_TEST(evaluation_visibility_a)
 RENDER_LAYER_TEST(evaluation_visibility_b)
diff --git a/tests/python/render_layer/render_layer_common.py 
b/tests/python/render_layer/render_layer_common.py
index e551518ac5..d24b80e0d0 100644
--- a/tests/python/render_layer/render_layer_common.py
+++ b/tests/python/render_layer/render_layer_common.py
@@ -309,3 +309,30 @@ class RenderLayerTesting(unittest.TestCase):
 ),
 "Scene dump files differ")
 
+def do_object_add_no_collection(self, add_mode):
+"""
+Test for adding objects when no collection
+exists in render layer
+"""
+import bpy
+
+# empty layer of collections
+
+layer = bpy.context.render_layer
+while layer.collections:
+layer.collections.unlink(layer.collections[0])
+
+# add new objects
+if add_mode == 'EMPTY':
+bpy.ops.object.add() # 'Empty'
+
+elif add_mode == 'CYLINDER':
+bpy.ops.mesh.primitive_cylinder_add() # 'Cylinder'
+
+elif add_mode == 'TORUS':
+bpy.ops.mesh.primitive_torus_add() # 'Torus'
+
+self.assertEqual(len(layer.collections), 1, "New collection not 
created")
+collection = layer.collections[0]
+self.assertEqual(len(collection.objects), 1, "New collection is empty")
+
diff --git 
a/tests/python/render_layer/test_object_add_no_collection_cylinder.py 
b/tests/python/render_layer/test_object_add_no_collection_cylinder.py
new file mode 100644
index 00..72bd046d75
--- /dev/null
+++ 

[Bf-blender-cvs] [4c8d8da2e7] blender2.8: Silence warnings in draw_armature.c

2017-02-24 Thread Dalai Felinto
Commit: 4c8d8da2e7c8c0ae82f36aeef2356128df567466
Author: Dalai Felinto
Date:   Thu Feb 23 11:14:19 2017 +0100
Branches: blender2.8
https://developer.blender.org/rB4c8d8da2e7c8c0ae82f36aeef2356128df567466

Silence warnings in draw_armature.c

Also add note about incomplete functions there

===

M   source/blender/draw/intern/draw_armature.c

===

diff --git a/source/blender/draw/intern/draw_armature.c 
b/source/blender/draw/intern/draw_armature.c
index 68d1b3d7ea..24a183d38c 100644
--- a/source/blender/draw/intern/draw_armature.c
+++ b/source/blender/draw/intern/draw_armature.c
@@ -82,7 +82,7 @@ static void update_color(const float const_color[4])
UI_GetThemeColor4fv(TH_VERTEX, colorVertex);
 }
 
-static const float *get_bone_solid_color(EditBone *eBone, bPoseChannel *pchan, 
bArmature *arm)
+static const float *get_bone_solid_color(EditBone *eBone, bPoseChannel 
*UNUSED(pchan), bArmature *UNUSED(arm))
 {
if (constColor)
return colorBoneSolid;
@@ -96,7 +96,7 @@ static const float *get_bone_solid_color(EditBone *eBone, 
bPoseChannel *pchan, b
return colorBoneSolid;
 }
 
-static const float *get_bone_wire_color(EditBone *eBone, bPoseChannel *pchan, 
bArmature *arm)
+static const float *get_bone_wire_color(EditBone *eBone, bPoseChannel 
*UNUSED(pchan), bArmature *UNUSED(arm))
 {
if (constColor)
return constColor;
@@ -210,24 +210,29 @@ static void draw_points(EditBone *eBone, bPoseChannel 
*pchan, bArmature *arm)
DRW_shgroup_bone_point_wire(BONE_VAR(eBone, pchan, disp_tail_mat), 
col_wire_tail);
 }
 
-static void draw_bone_custom_shape(EditBone *eBone, bPoseChannel *pchan, 
bArmature *arm)
+static void draw_bone_custom_shape(EditBone *UNUSED(eBone), bPoseChannel 
*UNUSED(pchan), bArmature *UNUSED(arm))
 {
+   /* work in progress  -- fclem */
 }
 
-static void draw_bone_envelope(EditBone *eBone, bPoseChannel *pchan, bArmature 
*arm)
+static void draw_bone_envelope(EditBone *UNUSED(eBone), bPoseChannel 
*UNUSED(pchan), bArmature *UNUSED(arm))
 {
+   /* work in progress  -- fclem */
 }
 
-static void draw_bone_line(EditBone *eBone, bPoseChannel *pchan, bArmature 
*arm)
+static void draw_bone_line(EditBone *UNUSED(eBone), bPoseChannel 
*UNUSED(pchan), bArmature *UNUSED(arm))
 {
+   /* work in progress  -- fclem */
 }
 
-static void draw_bone_wire(EditBone *eBone, bPoseChannel *pchan, bArmature 
*arm)
+static void draw_bone_wire(EditBone *UNUSED(eBone), bPoseChannel 
*UNUSED(pchan), bArmature *UNUSED(arm))
 {
+   /* work in progress  -- fclem */
 }
 
-static void draw_bone_box(EditBone *eBone, bPoseChannel *pchan, bArmature *arm)
+static void draw_bone_box(EditBone *UNUSED(eBone), bPoseChannel 
*UNUSED(pchan), bArmature *UNUSED(arm))
 {
+   /* work in progress  -- fclem */
 }
 
 static void draw_bone_octahedral(EditBone *eBone, bPoseChannel *pchan, 
bArmature *arm)

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


[Bf-blender-cvs] [8261a84ffb] blender2.8: Unittest: split object_add in individual test files

2017-02-24 Thread Dalai Felinto
Commit: 8261a84ffbe6d6a88389f374656135cef53e5b15
Author: Dalai Felinto
Date:   Thu Feb 23 12:26:48 2017 +0100
Branches: blender2.8
https://developer.blender.org/rB8261a84ffbe6d6a88389f374656135cef53e5b15

Unittest: split object_add in individual test files

(and small cleanup in unittest)

This is required to the upcoming unittest + bugfix

===

M   tests/python/render_layer/CMakeLists.txt
M   tests/python/render_layer/render_layer_common.py
D   tests/python/render_layer/test_object_add.py
A   tests/python/render_layer/test_object_add_cylinder.py
A   tests/python/render_layer/test_object_add_empty.py
A   tests/python/render_layer/test_object_add_torus.py

===

diff --git a/tests/python/render_layer/CMakeLists.txt 
b/tests/python/render_layer/CMakeLists.txt
index f47b193f8c..ff98d95cc0 100644
--- a/tests/python/render_layer/CMakeLists.txt
+++ b/tests/python/render_layer/CMakeLists.txt
@@ -64,7 +64,9 @@ RENDER_LAYER_TEST(active_collection)
 RENDER_LAYER_TEST(object_delete)
 RENDER_LAYER_TEST(link)
 RENDER_LAYER_TEST(operator_context)
-RENDER_LAYER_TEST(object_add)
+RENDER_LAYER_TEST(object_add_cylinder)
+RENDER_LAYER_TEST(object_add_empty)
+RENDER_LAYER_TEST(object_add_torus)
 RENDER_LAYER_TEST(object_copy)
 RENDER_LAYER_TEST(evaluation_visibility_a)
 RENDER_LAYER_TEST(evaluation_visibility_b)
diff --git a/tests/python/render_layer/render_layer_common.py 
b/tests/python/render_layer/render_layer_common.py
index 4a289936b2..e551518ac5 100644
--- a/tests/python/render_layer/render_layer_common.py
+++ b/tests/python/render_layer/render_layer_common.py
@@ -200,18 +200,6 @@ class RenderLayerTesting(unittest.TestCase):
 cls.pretest_parsing()
 
 @classmethod
-def setUp(cls):
-"""Runs once per test"""
-import bpy
-bpy.ops.wm.read_factory_settings()
-
-def path_exists(self, filepath):
-import os
-self.assertTrue(
-os.path.exists(filepath),
-"Test file \"{0}\" not found".format(filepath))
-
-@classmethod
 def get_root(cls):
 """
 return the folder with the test files
@@ -243,3 +231,81 @@ class RenderLayerTesting(unittest.TestCase):
 import_blendfile()
 import blendfile
 
+def setUp(self):
+"""Runs once per test"""
+import bpy
+bpy.ops.wm.read_factory_settings()
+
+def path_exists(self, filepath):
+import os
+self.assertTrue(
+os.path.exists(filepath),
+"Test file \"{0}\" not found".format(filepath))
+
+def do_object_add(self, filepath_json, add_mode):
+"""
+Testing for adding objects and see if they
+go to the right collection
+"""
+import bpy
+import os
+import tempfile
+import filecmp
+
+ROOT = self.get_root()
+with tempfile.TemporaryDirectory() as dirpath:
+filepath_layers = os.path.join(ROOT, 'layers.blend')
+
+# open file
+bpy.ops.wm.open_mainfile('EXEC_DEFAULT', filepath=filepath_layers)
+
+# create sub-collections
+three_b = bpy.data.objects.get('T.3b')
+three_c = bpy.data.objects.get('T.3c')
+
+scene = bpy.context.scene
+subzero = 
scene.master_collection.collections['1'].collections.new('sub-zero')
+scorpion = subzero.collections.new('scorpion')
+subzero.objects.link(three_b)
+scorpion.objects.link(three_c)
+layer = scene.render_layers.new('Fresh new Layer')
+layer.collections.link(subzero)
+
+# change active collection
+layer.collections.active_index = 3
+self.assertEqual(layer.collections.active.name, 'scorpion', "Run: 
test_syncing_object_add")
+
+# change active layer
+override = bpy.context.copy()
+override["render_layer"] = layer
+override["scene_collection"] = layer.collections.active.collection
+
+# add new objects
+if add_mode == 'EMPTY':
+bpy.ops.object.add(override) # 'Empty'
+
+elif add_mode == 'CYLINDER':
+bpy.ops.mesh.primitive_cylinder_add(override) # 'Cylinder'
+
+elif add_mode == 'TORUS':
+bpy.ops.mesh.primitive_torus_add(override) # 'Torus'
+
+# save file
+filepath_objects = os.path.join(dirpath, 'objects.blend')
+bpy.ops.wm.save_mainfile('EXEC_DEFAULT', filepath=filepath_objects)
+
+# get the generated json
+datas = query_scene(filepath_objects, 'Main', 
(get_scene_collections, get_layers))
+self.assertTrue(datas, "Data is not valid")
+
+filepath_objects_json = os.path.join(dirpath, "objects.json")
+with 

[Bf-blender-cvs] [16c6c8a1c4] uv_unwrapping_slim_algorithm: Category: UV Unwrapping SLIM Algorithm Integration

2017-02-24 Thread Aurel Gruber
Commit: 16c6c8a1c4f6bb368cff5d5f60b05cdfced0a8ca
Author: Aurel Gruber
Date:   Fri Feb 24 09:31:38 2017 +0100
Branches: uv_unwrapping_slim_algorithm
https://developer.blender.org/rB16c6c8a1c4f6bb368cff5d5f60b05cdfced0a8ca

Category: UV Unwrapping SLIM Algorithm Integration

adding (unsupported-) eigen files

===

A   extern/Eigen3/unsupported/Eigen/AdolcForward
A   extern/Eigen3/unsupported/Eigen/AlignedVector3
A   extern/Eigen3/unsupported/Eigen/ArpackSupport
A   extern/Eigen3/unsupported/Eigen/AutoDiff
A   extern/Eigen3/unsupported/Eigen/BVH
A   extern/Eigen3/unsupported/Eigen/CMakeLists.txt
A   extern/Eigen3/unsupported/Eigen/FFT
A   extern/Eigen3/unsupported/Eigen/IterativeSolvers
A   extern/Eigen3/unsupported/Eigen/KroneckerProduct
A   extern/Eigen3/unsupported/Eigen/LevenbergMarquardt
A   extern/Eigen3/unsupported/Eigen/MPRealSupport
A   extern/Eigen3/unsupported/Eigen/MatrixFunctions
A   extern/Eigen3/unsupported/Eigen/MoreVectorization
A   extern/Eigen3/unsupported/Eigen/NonLinearOptimization
A   extern/Eigen3/unsupported/Eigen/NumericalDiff
A   extern/Eigen3/unsupported/Eigen/OpenGLSupport
A   extern/Eigen3/unsupported/Eigen/Polynomials
A   extern/Eigen3/unsupported/Eigen/SVD
A   extern/Eigen3/unsupported/Eigen/Skyline
A   extern/Eigen3/unsupported/Eigen/SparseExtra
A   extern/Eigen3/unsupported/Eigen/Splines
A   extern/Eigen3/unsupported/Eigen/src/AutoDiff/AutoDiffJacobian.h
A   extern/Eigen3/unsupported/Eigen/src/AutoDiff/AutoDiffScalar.h
A   extern/Eigen3/unsupported/Eigen/src/AutoDiff/AutoDiffVector.h
A   extern/Eigen3/unsupported/Eigen/src/AutoDiff/CMakeLists.txt
A   extern/Eigen3/unsupported/Eigen/src/BVH/BVAlgorithms.h
A   extern/Eigen3/unsupported/Eigen/src/BVH/CMakeLists.txt
A   extern/Eigen3/unsupported/Eigen/src/BVH/KdBVH.h
A   extern/Eigen3/unsupported/Eigen/src/CMakeLists.txt
A   
extern/Eigen3/unsupported/Eigen/src/Eigenvalues/ArpackSelfAdjointEigenSolver.h
A   extern/Eigen3/unsupported/Eigen/src/Eigenvalues/CMakeLists.txt
A   extern/Eigen3/unsupported/Eigen/src/FFT/CMakeLists.txt
A   extern/Eigen3/unsupported/Eigen/src/FFT/ei_fftw_impl.h
A   extern/Eigen3/unsupported/Eigen/src/FFT/ei_kissfft_impl.h
A   extern/Eigen3/unsupported/Eigen/src/IterativeSolvers/CMakeLists.txt
A   
extern/Eigen3/unsupported/Eigen/src/IterativeSolvers/ConstrainedConjGrad.h
A   extern/Eigen3/unsupported/Eigen/src/IterativeSolvers/DGMRES.h
A   extern/Eigen3/unsupported/Eigen/src/IterativeSolvers/GMRES.h
A   
extern/Eigen3/unsupported/Eigen/src/IterativeSolvers/IncompleteCholesky.h
A   extern/Eigen3/unsupported/Eigen/src/IterativeSolvers/IncompleteLU.h
A   
extern/Eigen3/unsupported/Eigen/src/IterativeSolvers/IterationController.h
A   extern/Eigen3/unsupported/Eigen/src/IterativeSolvers/MINRES.h
A   extern/Eigen3/unsupported/Eigen/src/IterativeSolvers/Scaling.h
A   extern/Eigen3/unsupported/Eigen/src/KroneckerProduct/CMakeLists.txt
A   
extern/Eigen3/unsupported/Eigen/src/KroneckerProduct/KroneckerTensorProduct.h
A   extern/Eigen3/unsupported/Eigen/src/LevenbergMarquardt/CMakeLists.txt
A   
extern/Eigen3/unsupported/Eigen/src/LevenbergMarquardt/CopyrightMINPACK.txt
A   extern/Eigen3/unsupported/Eigen/src/LevenbergMarquardt/LMcovar.h
A   extern/Eigen3/unsupported/Eigen/src/LevenbergMarquardt/LMonestep.h
A   extern/Eigen3/unsupported/Eigen/src/LevenbergMarquardt/LMpar.h
A   extern/Eigen3/unsupported/Eigen/src/LevenbergMarquardt/LMqrsolv.h
A   
extern/Eigen3/unsupported/Eigen/src/LevenbergMarquardt/LevenbergMarquardt.h
A   extern/Eigen3/unsupported/Eigen/src/MatrixFunctions/CMakeLists.txt
A   extern/Eigen3/unsupported/Eigen/src/MatrixFunctions/MatrixExponential.h
A   extern/Eigen3/unsupported/Eigen/src/MatrixFunctions/MatrixFunction.h
A   
extern/Eigen3/unsupported/Eigen/src/MatrixFunctions/MatrixFunctionAtomic.h
A   extern/Eigen3/unsupported/Eigen/src/MatrixFunctions/MatrixLogarithm.h
A   extern/Eigen3/unsupported/Eigen/src/MatrixFunctions/MatrixPower.h
A   extern/Eigen3/unsupported/Eigen/src/MatrixFunctions/MatrixSquareRoot.h
A   extern/Eigen3/unsupported/Eigen/src/MatrixFunctions/StemFunction.h
A   extern/Eigen3/unsupported/Eigen/src/MoreVectorization/CMakeLists.txt
A   extern/Eigen3/unsupported/Eigen/src/MoreVectorization/MathFunctions.h
A   extern/Eigen3/unsupported/Eigen/src/NonLinearOptimization/CMakeLists.txt
A   
extern/Eigen3/unsupported/Eigen/src/NonLinearOptimization/HybridNonLinearSolver.h
A   
extern/Eigen3/unsupported/Eigen/src/NonLinearOptimization/LevenbergMarquardt.h
A   extern/Eigen3/unsupported/Eigen/src/NonLinearOptimization/chkder.h
A   extern/Eigen3/unsupported/Eigen/src/NonLinearOptimization/covar.h
A   

[Bf-blender-cvs] [1cb016491a] uv_unwrapping_slim_algorithm: Category: UV Unwrapping SLIM Algorithm Integration

2017-02-24 Thread Aurel Gruber
Commit: 1cb016491afea7656a3934cfd4bac1ac6d9a0e38
Author: Aurel Gruber
Date:   Fri Feb 24 09:28:33 2017 +0100
Branches: uv_unwrapping_slim_algorithm
https://developer.blender.org/rB1cb016491afea7656a3934cfd4bac1ac6d9a0e38

Category: UV Unwrapping SLIM Algorithm Integration

freeing matrix_transfer properly

===

M   source/blender/editors/uvedit/uvedit_parametrizer.c

===

diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.c 
b/source/blender/editors/uvedit/uvedit_parametrizer.c
index 6ff5176491..e8af44e32b 100644
--- a/source/blender/editors/uvedit/uvedit_parametrizer.c
+++ b/source/blender/editors/uvedit/uvedit_parametrizer.c
@@ -4430,6 +4430,7 @@ void param_slim_end(ParamHandle *handle) {
PHandle *phandle = (PHandle *) handle;
matrix_transfer *mt = phandle->mt;
set_uv_param_slim(handle, mt);
+   free_matrix_transfer(mt);
 }

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