[Bf-blender-cvs] [b997914f80] blender2.8: OpenGL: remove NPOT texture rescaling logic

2017-01-30 Thread Mike Erwin
Commit: b997914f8074a8a715ddcf80f16e5b0ddd5549c6
Author: Mike Erwin
Date:   Tue Jan 31 02:52:43 2017 -0500
Branches: blender2.8
https://developer.blender.org/rBb997914f8074a8a715ddcf80f16e5b0ddd5549c6

OpenGL: remove NPOT texture rescaling logic

This code was already disabled.

We might be able to simplify GPU_check_scaled_image even further. Maybe even 
delete it? Just removing the obvious stuff now.

Keeping is_power_of_2_resolution function since it is still used in DXT logic.

===

M   source/blender/gpu/intern/gpu_draw.c

===

diff --git a/source/blender/gpu/intern/gpu_draw.c 
b/source/blender/gpu/intern/gpu_draw.c
index c8d5d92b66..12a9ab87d5 100644
--- a/source/blender/gpu/intern/gpu_draw.c
+++ b/source/blender/gpu/intern/gpu_draw.c
@@ -38,8 +38,6 @@
 
 #include 
 
-#include "GPU_glew.h"
-
 #include "BLI_blenlib.h"
 #include "BLI_linklist.h"
 #include "BLI_math.h"
@@ -853,32 +851,6 @@ void GPU_create_gl_tex(
int tpx = rectw;
int tpy = recth;
 
-#if 0 /* NPOT support should be a compile-time check */
-   /* scale if not a power of two. this is not strictly necessary for newer
-* GPUs (OpenGL version >= 2.0) since they support 
non-power-of-two-textures 
-* Then don't bother scaling for hardware that supports NPOT textures! 
*/
-   if (textarget == GL_TEXTURE_2D &&
-   ((!GPU_full_non_power_of_two_support() && 
!is_power_of_2_resolution(rectw, recth)) ||
-is_over_resolution_limit(textarget, rectw, recth)))
-   {
-   rectw = smaller_power_of_2_limit(rectw);
-   recth = smaller_power_of_2_limit(recth);
-
-   if (use_high_bit_depth) {
-   ibuf = IMB_allocFromBuffer(NULL, frect, tpx, tpy);
-   IMB_scaleImBuf(ibuf, rectw, recth);
-
-   frect = ibuf->rect_float;
-   }
-   else {
-   ibuf = IMB_allocFromBuffer(rect, NULL, tpx, tpy);
-   IMB_scaleImBuf(ibuf, rectw, recth);
-
-   rect = ibuf->rect;
-   }
-   }
-#endif
-
/* create image */
glGenTextures(1, (GLuint *)bind);
glBindTexture(textarget, *bind);
@@ -1203,13 +1175,7 @@ void GPU_paint_set_mipmap(bool mipmap)
 /* check if image has been downscaled and do scaled partial update */
 static bool GPU_check_scaled_image(ImBuf *ibuf, Image *ima, float *frect, int 
x, int y, int w, int h)
 {
-#if 0 /* NPOT suport should be a compile-time check */
-   if ((!GPU_full_non_power_of_two_support() && 
!is_power_of_2_resolution(ibuf->x, ibuf->y)) ||
-   is_over_resolution_limit(GL_TEXTURE_2D, ibuf->x, ibuf->y))
-#else
-   if (is_over_resolution_limit(GL_TEXTURE_2D, ibuf->x, ibuf->y))
-#endif
-   {
+   if (is_over_resolution_limit(GL_TEXTURE_2D, ibuf->x, ibuf->y)) {
int x_limit = smaller_power_of_2_limit(ibuf->x);
int y_limit = smaller_power_of_2_limit(ibuf->y);

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


[Bf-blender-cvs] [a928a9c1e1] master: Fix compilation error: too few arguments to function call.

2017-01-30 Thread Kévin Dietrich
Commit: a928a9c1e199923090a6ea070332fb8003646590
Author: Kévin Dietrich
Date:   Tue Jan 31 06:59:11 2017 +0100
Branches: master
https://developer.blender.org/rBa928a9c1e199923090a6ea070332fb8003646590

Fix compilation error: too few arguments to function call.

D2492 by @tomjpsun.

===

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

===

diff --git a/source/blender/blenkernel/intern/object.c 
b/source/blender/blenkernel/intern/object.c
index e5393666a7..ff8be5892e 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -1204,7 +1204,7 @@ void BKE_object_make_local_ex(Main *bmain, Object *ob, 
const bool lib_local, con
if (lib_local || is_local) {
if (!is_lib) {
id_clear_lib_data(bmain, >id);
-   BKE_id_expand_local(>id);
+   BKE_id_expand_local(bmain, >id);
if (clear_proxy) {
if (ob->proxy_from != NULL) {
ob->proxy_from->proxy = NULL;

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


[Bf-blender-cvs] [d07e2416db] master: Fix bug not reported: Ruler/Protractor: Snap to vertices and edges was not considering the depth variation

2017-01-30 Thread Germano Cavalcante
Commit: d07e2416dbdfa89fd698aab2fda4804dd6368f1d
Author: Germano Cavalcante
Date:   Mon Jan 30 23:49:09 2017 -0300
Branches: master
https://developer.blender.org/rBd07e2416dbdfa89fd698aab2fda4804dd6368f1d

Fix bug not reported: Ruler/Protractor: Snap to vertices and edges was not 
considering the depth variation

Taking advantage of the area, the depth is decreased 0.01 BU to each loop to 
give priority to elements in order: Vertice > Edge > Face. This increases the 
threshold and improves the snap to multiple elements

===

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 83b04cb7f7..bed451a32d 100644
--- a/source/blender/editors/transform/transform_snap_object.c
+++ b/source/blender/editors/transform/transform_snap_object.c
@@ -1114,10 +1114,13 @@ static bool snapDerivedMesh(
 
float lpmat[4][4];
float ray_org_local[3];
+   float depth_range_local[2];
if (ELEM(snapdata->snap_to, SCE_SNAP_MODE_VERTEX, 
SCE_SNAP_MODE_EDGE)) {
mul_m4_m4m4(lpmat, snapdata->pmat, obmat);
copy_v3_v3(ray_org_local, snapdata->ray_origin);
mul_m4_v3(imat, ray_org_local);
+   depth_range_local[0] = snapdata->depth_range[0] * 
local_scale;
+   depth_range_local[1] = local_depth + 
depth_range_local[0];
}
 
if (do_bb) {
@@ -1326,7 +1329,7 @@ static bool snapDerivedMesh(
 
dist_squared_to_projected_aabb_precalc(
_precalc, lpmat, 
snapdata->win_half,
-   snapdata->depth_range, snapdata->mval, 
ray_org_local, ray_normal_local);
+   depth_range_local, snapdata->mval, 
ray_org_local, ray_normal_local);
 
BVHTree_WalkLeafCallback cb_walk_leaf =
(snapdata->snap_to == SCE_SNAP_MODE_VERTEX) ?
@@ -1400,6 +1403,13 @@ static bool snapEditMesh(
 
mul_mat3_m4_v3(imat, ray_normal_local);
 
+   /* local scale in normal direction */
+   float local_scale = normalize_v3(ray_normal_local);
+   float local_depth = *ray_depth;
+   if (local_depth != BVH_RAYCAST_DIST_MAX) {
+   local_depth *= local_scale;
+   }
+
SnapObjectData_EditMesh *sod = NULL;
 
BVHTreeFromEditMesh *treedata = NULL, treedata_stack;
@@ -1502,13 +1512,6 @@ static bool snapEditMesh(
copy_v3_v3(ray_start_local, snapdata->ray_start);
mul_m4_v3(imat, ray_start_local);
 
-   /* local scale in normal direction */
-   float local_scale = normalize_v3(ray_normal_local);
-   float local_depth = *ray_depth;
-   if (local_depth != BVH_RAYCAST_DIST_MAX) {
-   local_depth *= local_scale;
-   }
-
/* Only use closer ray_start in case of ortho view! In 
perspective one, ray_start
 * may already been *inside* boundbox, leading to snap 
failures (see T38409).
 * Note also ar might be null (see T38435), in this 
case we assume ray_start is ok!
@@ -1615,8 +1618,10 @@ static bool snapEditMesh(
.userdata = _type,
.index = -1};
 
-   float lpmat[4][4];
+   float lpmat[4][4], depth_range_local[2];
mul_m4_m4m4(lpmat, snapdata->pmat, obmat);
+   depth_range_local[0] = snapdata->depth_range[0] * 
local_scale;
+   depth_range_local[1] = local_depth + 
depth_range_local[0];
dist_squared_to_projected_aabb_precalc(
_precalc, lpmat, 
snapdata->win_half,
snapdata->depth_range, snapdata->mval, 
ray_org_local, ray_normal_local);
@@ -2077,9 +2082,6 @@ static bool 
transform_snap_context_project_view3d_mixed_impl(
 
for (int i = 0; i < 3; i++) {
if ((snap_to_flag & (1 << i)) && (is_hit == false || 
use_depth)) {
-   if (use_depth == false) {
-   ray_depth = BVH_RAYCAST_DIST_MAX;
-   }
 
if (ED_transform_snap_object_project_view3d(
sctx,
@@ -2088,6 +2090,14 @@ static bool 
transform_snap_context_project_view3d_mixed_impl(
r_co, r_no))
{
   

[Bf-blender-cvs] [a50b173952] master: Use the same solution to test the pixel distance to the AABB, with BoundBox

2017-01-30 Thread Germano Cavalcante
Commit: a50b173952c85a51828f28569a9923bd29764292
Author: Germano Cavalcante
Date:   Mon Jan 30 22:27:38 2017 -0300
Branches: master
https://developer.blender.org/rBa50b173952c85a51828f28569a9923bd29764292

Use the same solution to test the pixel distance to the AABB, with BoundBox

The previous solution took arbitrary values to determine if the mouse was near 
or not to the Bound Box (it simply scaled the Bound Box).

Now the same function that detected the distance from the BVHTree nodes to the 
mouse is used in the Bound Box

===

M   source/blender/blenkernel/BKE_object.h
M   source/blender/blenkernel/intern/object.c
M   source/blender/editors/transform/transform_snap_object.c

===

diff --git a/source/blender/blenkernel/BKE_object.h 
b/source/blender/blenkernel/BKE_object.h
index 4349e68f7c..d812ab832a 100644
--- a/source/blender/blenkernel/BKE_object.h
+++ b/source/blender/blenkernel/BKE_object.h
@@ -139,7 +139,6 @@ void BKE_boundbox_init_from_minmax(struct BoundBox *bb, 
const float min[3], cons
 void BKE_boundbox_calc_center_aabb(const struct BoundBox *bb, float r_cent[3]);
 void BKE_boundbox_calc_size_aabb(const struct BoundBox *bb, float r_size[3]);
 void BKE_boundbox_minmax(const struct BoundBox *bb, float obmat[4][4], float 
r_min[3], float r_max[3]);
-void BKE_boundbox_scale(struct BoundBox *bb_dst, const struct BoundBox 
*bb_src, float scale);
 struct BoundBox *BKE_boundbox_ensure_minimum_dimensions(
 struct BoundBox *bb, struct BoundBox *bb_temp, const float epsilon);
 
diff --git a/source/blender/blenkernel/intern/object.c 
b/source/blender/blenkernel/intern/object.c
index 09b3a7312b..e5393666a7 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -1204,7 +1204,7 @@ void BKE_object_make_local_ex(Main *bmain, Object *ob, 
const bool lib_local, con
if (lib_local || is_local) {
if (!is_lib) {
id_clear_lib_data(bmain, >id);
-   BKE_id_expand_local(bmain, >id);
+   BKE_id_expand_local(>id);
if (clear_proxy) {
if (ob->proxy_from != NULL) {
ob->proxy_from->proxy = NULL;
@@ -2236,18 +2236,6 @@ void BKE_boundbox_minmax(const BoundBox *bb, float 
obmat[4][4], float r_min[3],
}
 }
 
-void BKE_boundbox_scale(struct BoundBox *bb_dst, const struct BoundBox 
*bb_src, float scale)
-{
-   float cent[3];
-   BKE_boundbox_calc_center_aabb(bb_src, cent);
-
-   for (int i = 0; i < ARRAY_SIZE(bb_dst->vec); i++) {
-   bb_dst->vec[i][0] = ((bb_src->vec[i][0] - cent[0]) * scale) + 
cent[0];
-   bb_dst->vec[i][1] = ((bb_src->vec[i][1] - cent[1]) * scale) + 
cent[1];
-   bb_dst->vec[i][2] = ((bb_src->vec[i][2] - cent[2]) * scale) + 
cent[2];
-   }
-}
-
 /**
  * Returns a BBox which each dimensions are at least epsilon.
  * \note In case a given dimension needs to be enlarged, its final value will 
be in [epsilon, 3 * epsilon] range.
diff --git a/source/blender/editors/transform/transform_snap_object.c 
b/source/blender/editors/transform/transform_snap_object.c
index 3f8e1176f3..5d9892cd50 100644
--- a/source/blender/editors/transform/transform_snap_object.c
+++ b/source/blender/editors/transform/transform_snap_object.c
@@ -244,7 +244,7 @@ typedef struct BVHTreeFromMeshType {
char type;
 } BVHTreeFromMeshType;
 
-/*
+/**
  * Generates a struct with the immutable parameters that will be used on all 
objects.
  *
  * \param snap_to: Element to snap, Vertice, Edge or Face.
@@ -376,15 +376,7 @@ static bool test_projected_edge_dist(
dist_squared_ray_to_seg_v3(ray_start, ray_dir, va, vb, tmp_co, );
return test_projected_vert_dist(depth_range, mval, tmp_co, pmat, 
win_half, is_persp, dist_px_sq, r_co);
 }
-
-/** \} */
-
-
-/*  */
-
-/** \Walk DFS
- * \{ */
-typedef struct Object_Nearest2dPrecalc {
+typedef struct Nearest2dPrecalc {
float ray_origin_local[3];
float ray_direction_local[3];
float ray_inv_dir[3];
@@ -392,76 +384,65 @@ typedef struct Object_Nearest2dPrecalc {
float depth_range[2];
float pmat[4][4]; /* perspective matrix multiplied by object matrix */
float win_half[2];
-   bool is_persp;
-   float dist_px_sq;
 
float mval[2];
bool sign[3];
-   bool r_axis_closest[3];
-
-   void *userdata;
-   int index;
-   float co[3];
-   float no[3];
-} Object_Nearest2dPrecalc;
-
+} Nearest2dPrecalc;
 
-static void nearest2d_precalc(
-Object_Nearest2dPrecalc *neasrest_precalc, SnapData *snapdata,
-const float dist_px, float obmat[4][4],
+/**
+ * \param lpmat: Perspective matrix multiplied by 

[Bf-blender-cvs] [4e1025376e] master: Freestyle: Use of the Fill Range by Selection operator in the mesh edit mode.

2017-01-30 Thread Tamito Kajiyama
Commit: 4e1025376ea18597b8f7b744be7629dc3396bcc4
Author: Tamito Kajiyama
Date:   Tue Jan 31 09:04:05 2017 +0900
Branches: master
https://developer.blender.org/rB4e1025376ea18597b8f7b744be7629dc3396bcc4

Freestyle: Use of the Fill Range by Selection operator in the mesh edit mode.

This revision extends the functionality of the "Fill Range by Selection" button 
in
the "Distance from Camera/Object" modifiers so that only selected mesh vertices
in the edit mode are taken into account  (instead of considering all vertices 
when
in the object mode) to compute the min & max distances from the reference.
This will give users much finer control on the range values.

===

M   release/scripts/startup/bl_operators/freestyle.py

===

diff --git a/release/scripts/startup/bl_operators/freestyle.py 
b/release/scripts/startup/bl_operators/freestyle.py
index e190572d44..fe3b00d54c 100644
--- a/release/scripts/startup/bl_operators/freestyle.py
+++ b/release/scripts/startup/bl_operators/freestyle.py
@@ -75,6 +75,32 @@ class 
SCENE_OT_freestyle_fill_range_by_selection(bpy.types.Operator):
 else:
 self.report({'ERROR'}, "Unexpected modifier type: " + m.type)
 return {'CANCELLED'}
+# Find selected vertices in editmesh
+ob = bpy.context.active_object
+if ob.type == 'MESH' and ob.mode == 'EDIT' and ob.name != ref.name:
+bpy.ops.object.mode_set(mode='OBJECT')
+selected_verts = [v for v in 
bpy.context.active_object.data.vertices if v.select]
+bpy.ops.object.mode_set(mode='EDIT')
+# Compute the min/max distance from the reference to mesh vertices
+min_dist = sys.float_info.max
+max_dist = -min_dist
+if m.type == 'DISTANCE_FROM_CAMERA':
+ob_to_cam = matrix_to_camera * ob.matrix_world
+for vert in selected_verts:
+# dist in the camera space
+dist = (ob_to_cam * vert.co).length
+min_dist = min(dist, min_dist)
+max_dist = max(dist, max_dist)
+elif m.type == 'DISTANCE_FROM_OBJECT':
+for vert in selected_verts:
+# dist in the world space
+dist = (ob.matrix_world * vert.co - target_location).length
+min_dist = min(dist, min_dist)
+max_dist = max(dist, max_dist)
+# Fill the Range Min/Max entries with the computed distances
+m.range_min = min_dist
+m.range_max = max_dist
+return {'FINISHED'}
 # Find selected mesh objects
 selection = [ob for ob in scene.objects if ob.select and ob.type == 
'MESH' and ob.name != ref.name]
 if selection:

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


[Bf-blender-cvs] [4443bad30a] master: Add optional, free-after-use usages mapping of IDs to Main.

2017-01-30 Thread Bastien Montagne
Commit: 4443bad30a3926a33c3ead60f509f637ad29d6c5
Author: Bastien Montagne
Date:   Mon Jan 30 21:00:07 2017 +0100
Branches: master
https://developer.blender.org/rB4443bad30a3926a33c3ead60f509f637ad29d6c5

Add optional, free-after-use usages mapping of IDs to Main.

The new MainIDRelations stores two mappings, one from ID users to ID
used, the other vice-versa.

That data is assumed to be short-living runtime, code creating it is
responsible to clear it asap. It will be much useful in places where we
handle relations between IDs for a lot of them at once.

Note: This commit is not fully functional, that is, the infamous, ugly,
PoS non-ID nodetrees will not be handled correctly when building relations.
Fix needed here is a bit noisy, so will be done in next own commit.

===

M   source/blender/blenkernel/BKE_library.h
M   source/blender/blenkernel/BKE_main.h
M   source/blender/blenkernel/intern/library.c

===

diff --git a/source/blender/blenkernel/BKE_library.h 
b/source/blender/blenkernel/BKE_library.h
index 2d9c35f7fd..34035673f8 100644
--- a/source/blender/blenkernel/BKE_library.h
+++ b/source/blender/blenkernel/BKE_library.h
@@ -105,6 +105,9 @@ void BKE_main_free(struct Main *mainvar);
 void BKE_main_lock(struct Main *bmain);
 void BKE_main_unlock(struct Main *bmain);
 
+void BKE_main_relations_create(struct Main *bmain);
+void BKE_main_relations_free(struct Main *bmain);
+
 struct BlendThumbnail *BKE_main_thumbnail_from_imbuf(struct Main *bmain, 
struct ImBuf *img);
 struct ImBuf *BKE_main_thumbnail_to_imbuf(struct Main *bmain, struct 
BlendThumbnail *data);
 void BKE_main_thumbnail_create(struct Main *bmain);
diff --git a/source/blender/blenkernel/BKE_main.h 
b/source/blender/blenkernel/BKE_main.h
index a4f5c42528..387045878f 100644
--- a/source/blender/blenkernel/BKE_main.h
+++ b/source/blender/blenkernel/BKE_main.h
@@ -51,6 +51,8 @@ extern "C" {
 struct EvaluationContext;
 struct Library;
 struct MainLock;
+struct GHash;
+struct BLI_mempool;
 
 /* Blender thumbnail, as written on file (width, height, and data as char 
RGBA). */
 /* We pack pixel data after that struct. */
@@ -59,6 +61,22 @@ typedef struct BlendThumbnail {
char rect[0];
 } BlendThumbnail;
 
+/* Structs caching relations between data-blocks in a given Main. */
+typedef struct MainIDRelationsEntry {
+   struct MainIDRelationsEntry *next;
+   /* WARNING! for user_to_used, that pointer is really an ID** one, but 
for used_to_user, it’s only an ID* one! */
+   struct ID **id_pointer;
+   int usage_flag;  /* Using IDWALK_ enums, in BKE_library_query.h */
+} MainIDRelationsEntry;
+
+typedef struct MainIDRelations {
+   struct GHash *id_user_to_used;
+   struct GHash *id_used_to_user;
+
+   /* Private... */
+   struct BLI_mempool *entry_pool;
+} MainIDRelations;
+
 typedef struct Main {
struct Main *next, *prev;
char name[1024]; /* 1024 = FILE_MAX */
@@ -111,6 +129,11 @@ typedef struct Main {
/* Evaluation context used by viewport */
struct EvaluationContext *eval_ctx;
 
+   /* Must be generated, used and freed by same code - never assume this 
is valid data unless you know
+* when, who and how it was created.
+* Used by code doing a lot of remapping etc. at once to speed things 
up. */
+   struct MainIDRelations *relations;
+
struct MainLock *lock;
 } Main;
 
diff --git a/source/blender/blenkernel/intern/library.c 
b/source/blender/blenkernel/intern/library.c
index 77013a55d1..a06386f2f6 100644
--- a/source/blender/blenkernel/intern/library.c
+++ b/source/blender/blenkernel/intern/library.c
@@ -76,6 +76,7 @@
 #include "BLI_ghash.h"
 #include "BLI_linklist.h"
 #include "BLI_memarena.h"
+#include "BLI_mempool.h"
 #include "BLI_string_utils.h"
 
 #include "BLI_threads.h"
@@ -1252,6 +1253,10 @@ void BKE_main_free(Main *mainvar)
}
}
 
+   if (mainvar->relations) {
+   BKE_main_relations_free(mainvar);
+   }
+
BLI_spin_end((SpinLock *)mainvar->lock);
MEM_freeN(mainvar->lock);
DEG_evaluation_context_free(mainvar->eval_ctx);
@@ -1268,6 +1273,78 @@ void BKE_main_unlock(struct Main *bmain)
BLI_spin_unlock((SpinLock *) bmain->lock);
 }
 
+
+static int main_relations_create_cb(void *user_data, ID *id_self, ID 
**id_pointer, int cd_flag)
+{
+   MainIDRelations *rel = user_data;
+
+   if (*id_pointer) {
+   MainIDRelationsEntry *entry, **entry_p;
+
+   entry = BLI_mempool_alloc(rel->entry_pool);
+   if (BLI_ghash_ensure_p(rel->id_user_to_used, id_self, (void 
***)_p)) {
+   entry->next = *entry_p;
+   }
+   else {
+   entry->next = NULL;
+   }
+   entry->id_pointer = id_pointer;
+   

[Bf-blender-cvs] [fbd28d375a] master: Fix missing non-ID nodetrees in ID relationships built from library_query.c

2017-01-30 Thread Bastien Montagne
Commit: fbd28d375a758d81b925867efef4d02482d414c6
Author: Bastien Montagne
Date:   Mon Jan 30 21:34:23 2017 +0100
Branches: master
https://developer.blender.org/rBfbd28d375a758d81b925867efef4d02482d414c6

Fix missing non-ID nodetrees in ID relationships built from library_query.c

This shall fix both existing code (bpy mapping, and local/lib usages
checks), and new Main->relations generation.

===

M   source/blender/blenkernel/BKE_library_query.h
M   source/blender/blenkernel/intern/library.c
M   source/blender/blenkernel/intern/library_query.c
M   source/blender/blenkernel/intern/library_remap.c
M   source/blender/windowmanager/intern/wm_operators.c

===

diff --git a/source/blender/blenkernel/BKE_library_query.h 
b/source/blender/blenkernel/BKE_library_query.h
index a7470107c2..c80eb7b076 100644
--- a/source/blender/blenkernel/BKE_library_query.h
+++ b/source/blender/blenkernel/BKE_library_query.h
@@ -46,14 +46,17 @@ enum {
 */
IDWALK_INDIRECT_USAGE = (1 << 2),
 
+   /** That ID is used as mere sub-data by its owner
+* (only case currently: those f***ing nodetrees in materials etc.).
+* This means callback shall not *do* anything, only use this as 
informative data if it needs it. */
+   IDWALK_PRIVATE = (1 << 3),
+
/**
 * Adjusts #ID.us reference-count.
 * \note keep in sync with 'newlibadr_us' use in readfile.c
 */
IDWALK_USER = (1 << 8),
-   /**
-* Ensure #ID.us is at least 1 on use.
-*/
+   /** Ensure #ID.us is at least 1 on use. */
IDWALK_USER_ONE = (1 << 9),
 };
 
diff --git a/source/blender/blenkernel/intern/library.c 
b/source/blender/blenkernel/intern/library.c
index a06386f2f6..bb426ac027 100644
--- a/source/blender/blenkernel/intern/library.c
+++ b/source/blender/blenkernel/intern/library.c
@@ -274,8 +274,12 @@ void BKE_id_clear_newpoin(ID *id)
 }
 
 static int id_expand_local_callback(
-void *UNUSED(user_data), struct ID *id_self, struct ID **id_pointer, 
int UNUSED(cd_flag))
+void *UNUSED(user_data), struct ID *id_self, struct ID **id_pointer, 
int cd_flag)
 {
+   if (cd_flag & IDWALK_PRIVATE) {
+   return IDWALK_RET_NOP;
+   }
+
/* Can hapen that we get unlinkable ID here, e.g. with shapekey 
referring to itself (through drivers)...
 * Just skip it, shape key can only be either indirectly linked, or 
fully local, period.
 * And let's curse one more time that stupid useless shapekey ID type! 
*/
diff --git a/source/blender/blenkernel/intern/library_query.c 
b/source/blender/blenkernel/intern/library_query.c
index fa75c906fb..28f66b5279 100644
--- a/source/blender/blenkernel/intern/library_query.c
+++ b/source/blender/blenkernel/intern/library_query.c
@@ -85,6 +85,7 @@
 #define FOREACH_FINALIZE_VOID FOREACH_FINALIZE: (void)0
 
 #define FOREACH_CALLBACK_INVOKE_ID_PP(_data, id_pp, cb_flag) \
+   CHECK_TYPE(id_pp, ID **); \
if (!((_data)->status & IDWALK_STOP)) { \
const int _flag = (_data)->flag; \
ID *old_id = *(id_pp); \
@@ -265,8 +266,13 @@ static void library_foreach_paint(LibraryForeachIDData 
*data, Paint *paint)
 }
 
 static void library_foreach_ID_as_subdata_link(
-ID *id, LibraryIDLinkCallback callback, void *user_data, int flag, 
LibraryForeachIDData *data)
+ID **id_pp, LibraryIDLinkCallback callback, void *user_data, int flag, 
LibraryForeachIDData *data)
 {
+   /* Needed e.g. for callbacks handling relationships... This call shall 
be absolutely readonly. */
+   ID *id = *id_pp;
+   FOREACH_CALLBACK_INVOKE_ID_PP(data, id_pp, IDWALK_PRIVATE);
+   BLI_assert(id == *id_pp);
+
if (flag & IDWALK_RECURSE) {
/* Defer handling into main loop, recursively calling 
BKE_library_foreach_ID_link in IDWALK_RECURSE case is
 * troublesome, see T49553. */
@@ -278,6 +284,8 @@ static void library_foreach_ID_as_subdata_link(
else {
BKE_library_foreach_ID_link(id, callback, user_data, flag);
}
+
+   FOREACH_FINALIZE_VOID;
 }
 
 /**
@@ -342,7 +350,7 @@ void BKE_library_foreach_ID_link(ID *id, 
LibraryIDLinkCallback callback, void *u
CALLBACK_INVOKE(scene->clip, IDWALK_USER);
if (scene->nodetree) {
/* nodetree **are owned by IDs**, treat 
them as mere sub-data and not real ID! */
-   library_foreach_ID_as_subdata_link((ID 
*)scene->nodetree, callback, user_data, flag, );
+   library_foreach_ID_as_subdata_link((ID 
**)>nodetree, callback, user_data, flag, );
}
/* DO NOT handle scene->basact here, it's 

[Bf-blender-cvs] [bc4aeefe82] master: Make 'make local' twice quicker.

2017-01-30 Thread Bastien Montagne
Commit: bc4aeefe82205efbc9803ba158ec7055cb13ae11
Author: Bastien Montagne
Date:   Mon Jan 30 21:47:48 2017 +0100
Branches: master
https://developer.blender.org/rBbc4aeefe82205efbc9803ba158ec7055cb13ae11

Make 'make local' twice quicker.

Use new Main->relations ID usages mapping in BKE_library_make_local().

This allows a noticeable simplification in code, and can be up to twice
quicker as previous code (Make Local: All from 2 to 1 minute e.g. in a
huge production file with thousands of linked data-blocks).

Note that new code has been successfuly tested with several complex cases
(production files from Agent327), as well as some testcases from recent
bug reports related to that function. But as always, nothing beats real
usage by real users, so please check this before we release 2.79. ;)

Main areas that would be affected: Make Local operations (L shortcut in
3DView), and append from libraries.

===

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

===

diff --git a/source/blender/blenkernel/intern/library.c 
b/source/blender/blenkernel/intern/library.c
index 3f75bb8ec6..daa8c6f5e5 100644
--- a/source/blender/blenkernel/intern/library.c
+++ b/source/blender/blenkernel/intern/library.c
@@ -1704,6 +1704,53 @@ void BKE_main_id_clear_newpoins(Main *bmain)
}
 }
 
+
+static void library_make_local_copying_check(ID *id, GSet *loop_tags, 
MainIDRelations *id_relations, GSet *done_ids)
+{
+   if (BLI_gset_haskey(done_ids, id)) {
+   return;  /* Already checked, nothing else to do. */
+   }
+
+   MainIDRelationsEntry *entry = 
BLI_ghash_lookup(id_relations->id_used_to_user, id);
+   BLI_gset_insert(loop_tags, id);
+   for (; entry != NULL; entry = entry->next) {
+   ID *par_id = (ID *)entry->id_pointer;  /* used_to_user stores 
ID pointer, not pointer to ID pointer... */
+
+   /* Shapekeys are considered 'private' to their owner ID here, 
and never tagged (since they cannot be linked),
+* so we have to switch effective parent to their owner. */
+   if (GS(par_id->name) == ID_KE) {
+   par_id = ((Key *)par_id)->from;
+   }
+
+   if (par_id->lib == NULL) {
+   /* Local user, early out to avoid some gset querying... 
*/
+   continue;
+   }
+   if (!BLI_gset_haskey(done_ids, par_id)) {
+   if (BLI_gset_haskey(loop_tags, par_id)) {
+   /* We are in a 'dependency loop' of IDs, this 
does not say us anything, skip it.
+* Note that this is the situation that can 
lead to archipelagoes of linked data-blocks
+* (since all of them have non-local users, 
they would all be duplicated, leading to a loop of unused
+* linked data-blocks that cannot be freed 
since they all use each other...). */
+   continue;
+   }
+   /* Else, recursively check that user ID. */
+   library_make_local_copying_check(par_id, loop_tags, 
id_relations, done_ids);
+   }
+
+   if (par_id->tag & LIB_TAG_DOIT) {
+   /* This user will be fully local in future, so far so 
good, nothing to do here but check next user. */
+   }
+   else {
+   /* This user won't be fully local in future, so current 
ID won't be either. And we are done checking it. */
+   id->tag &= ~LIB_TAG_DOIT;
+   break;
+   }
+   }
+   BLI_gset_add(done_ids, id);
+   BLI_gset_remove(loop_tags, id, NULL);
+}
+
 /** Make linked datablocks local.
  *
  * \param bmain Almost certainly G.main.
@@ -1714,11 +1761,10 @@ void BKE_main_id_clear_newpoins(Main *bmain)
 /* Note: Old (2.77) version was simply making (tagging) datablocks as local, 
without actually making any check whether
  * they were also indirectly used or not...
  *
- * Current version uses regular id_make_local callback, which is not 
super-efficient since this ends up
- * duplicating some IDs and then removing original ones (due to missing 
knowledge of which ID uses some other ID).
- *
- * However, we now have a first check that allows us to use 'direct 
localization' of a lot of IDs, so performances
- * are now *reasonably* OK.
+ * Current version uses regular id_make_local callback, with advanced 
pre-processing step to detect all cases of
+ * IDs currently indirectly used, but which will be used by local data only 
once this function is finished.
+ * This allows to avoid any uneeded duplication of IDs, and hence all time 
lost afterwards to remove
+ * orphaned linked data-blocks...
  */
 void BKE_library_make_local(

[Bf-blender-cvs] [eadfd901ad] master: Optimization: pass Main to BKE_library_foreach_ID_link() and use its relations.

2017-01-30 Thread Bastien Montagne
Commit: eadfd901ad7c3af4d85b05618352a96a9b4ca9de
Author: Bastien Montagne
Date:   Mon Jan 30 21:41:44 2017 +0100
Branches: master
https://developer.blender.org/rBeadfd901ad7c3af4d85b05618352a96a9b4ca9de

Optimization: pass Main to BKE_library_foreach_ID_link() and use its relations.

Use Main->relations in BKE_library_foreach_ID_link(), when possible
(i.e. IDWALK_READONLY is set), and if the data is available of course.

This is quite minor optimization, no sensible improvements are expected,
but does not hurt either to avoid potentially tens of looping over e.g.
objects constraints and modifiers, or heap of drivers...

===

M   source/blender/blenkernel/BKE_library.h
M   source/blender/blenkernel/BKE_library_query.h
M   source/blender/blenkernel/intern/brush.c
M   source/blender/blenkernel/intern/library.c
M   source/blender/blenkernel/intern/library_query.c
M   source/blender/blenkernel/intern/library_remap.c
M   source/blender/blenkernel/intern/object.c
M   source/blender/editors/object/object_relations.c
M   source/blender/python/intern/bpy_rna_id_collection.c
M   source/blender/windowmanager/intern/wm_operators.c

===

diff --git a/source/blender/blenkernel/BKE_library.h 
b/source/blender/blenkernel/BKE_library.h
index 34035673f8..72ae2cf4ef 100644
--- a/source/blender/blenkernel/BKE_library.h
+++ b/source/blender/blenkernel/BKE_library.h
@@ -86,7 +86,7 @@ bool id_make_local(struct Main *bmain, struct ID *id, const 
bool test, const boo
 bool id_single_user(struct bContext *C, struct ID *id, struct PointerRNA *ptr, 
struct PropertyRNA *prop);
 bool id_copy(struct Main *bmain, struct ID *id, struct ID **newid, bool test);
 void id_sort_by_name(struct ListBase *lb, struct ID *id);
-void BKE_id_expand_local(struct ID *id);
+void BKE_id_expand_local(struct Main *bmain, struct ID *id);
 void BKE_id_copy_ensure_local(struct Main *bmain, struct ID *old_id, struct ID 
*new_id);
 
 bool new_id(struct ListBase *lb, struct ID *id, const char *name);
diff --git a/source/blender/blenkernel/BKE_library_query.h 
b/source/blender/blenkernel/BKE_library_query.h
index c80eb7b076..693d5e9a28 100644
--- a/source/blender/blenkernel/BKE_library_query.h
+++ b/source/blender/blenkernel/BKE_library_query.h
@@ -80,7 +80,8 @@ enum {
 };
 
 /* Loop over all of the ID's this datablock links to. */
-void BKE_library_foreach_ID_link(struct ID *id, LibraryIDLinkCallback 
callback, void *user_data, int flag);
+void BKE_library_foreach_ID_link(
+struct Main *bmain, struct ID *id, LibraryIDLinkCallback callback, 
void *user_data, int flag);
 void BKE_library_update_ID_link_user(struct ID *id_dst, struct ID *id_src, 
const int cd_flag);
 
 int BKE_library_ID_use_ID(struct ID *id_user, struct ID *id_used);
diff --git a/source/blender/blenkernel/intern/brush.c 
b/source/blender/blenkernel/intern/brush.c
index 0d509ecea0..57b707a31d 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -239,7 +239,7 @@ void BKE_brush_make_local(Main *bmain, Brush *brush, const 
bool lib_local)
if (lib_local || is_local) {
if (!is_lib) {
id_clear_lib_data(bmain, >id);
-   BKE_id_expand_local(>id);
+   BKE_id_expand_local(bmain, >id);
 
/* enable fake user by default */
id_fake_user_set(>id);
diff --git a/source/blender/blenkernel/intern/library.c 
b/source/blender/blenkernel/intern/library.c
index bb426ac027..3f75bb8ec6 100644
--- a/source/blender/blenkernel/intern/library.c
+++ b/source/blender/blenkernel/intern/library.c
@@ -293,9 +293,9 @@ static int id_expand_local_callback(
 /**
  * Expand ID usages of given id as 'extern' (and no more indirect) linked 
data. Used by ID copy/make_local functions.
  */
-void BKE_id_expand_local(ID *id)
+void BKE_id_expand_local(Main *bmain, ID *id)
 {
-   BKE_library_foreach_ID_link(id, id_expand_local_callback, NULL, 0);
+   BKE_library_foreach_ID_link(bmain, id, id_expand_local_callback, NULL, 
IDWALK_READONLY);
 }
 
 /**
@@ -304,7 +304,7 @@ void BKE_id_expand_local(ID *id)
 void BKE_id_copy_ensure_local(Main *bmain, ID *old_id, ID *new_id)
 {
if (ID_IS_LINKED_DATABLOCK(old_id)) {
-   BKE_id_expand_local(new_id);
+   BKE_id_expand_local(bmain, new_id);
BKE_id_lib_local_paths(bmain, old_id->lib, new_id);
}
 }
@@ -331,7 +331,7 @@ void BKE_id_make_local_generic(Main *bmain, ID *id, const 
bool id_in_mainlist, c
if (lib_local || is_local) {
if (!is_lib) {
id_clear_lib_data_ex(bmain, id, id_in_mainlist);
-   BKE_id_expand_local(id);
+   BKE_id_expand_local(bmain, id);
}
else {
  

[Bf-blender-cvs] [997a210b08] master: Fix T49632: Grease pencil in "Edit Strokes" mode: Snap tool did not snap points to active object A simple confusion between enums: ~SNAP_NOT_ACTIVE~

2017-01-30 Thread Germano Cavalcante
Commit: 997a210b086f93a881b10cb1c3ba6bedcb33676a
Author: Germano Cavalcante
Date:   Mon Jan 30 18:30:19 2017 -0300
Branches: master
https://developer.blender.org/rB997a210b086f93a881b10cb1c3ba6bedcb33676a

Fix T49632: Grease pencil in "Edit Strokes" mode: Snap tool did not snap points 
to active object
A simple confusion between enums: ~SNAP_NOT_ACTIVE~

===

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

===

diff --git a/source/blender/editors/transform/transform_snap.c 
b/source/blender/editors/transform/transform_snap.c
index f8bb124e94..87ac54b2bd 100644
--- a/source/blender/editors/transform/transform_snap.c
+++ b/source/blender/editors/transform/transform_snap.c
@@ -569,7 +569,9 @@ static void initSnappingMode(TransInfo *t)
else if (t->tsnap.applySnap != NULL && // A snapping function 
actually exist
 (obedit == NULL) ) // Object Mode
{
-   t->tsnap.modeSelect = SNAP_NOT_SELECTED;
+   /* In "Edit Strokes" mode, Snap tool can perform snap 
to selected or active objects (see T49632)
+* TODO: perform self snap in gpencil_strokes */
+   t->tsnap.modeSelect = ((t->options & 
CTX_GPENCIL_STROKES) != 0) ? SNAP_ALL : SNAP_NOT_SELECTED;
}
else {
/* Grid if snap is not possible */
@@ -1214,7 +1216,7 @@ bool snapObjectsTransform(
t->tsnap.object_context,
t->scene->toolsettings->snap_mode,
&(const struct SnapObjectParams){
-   .snap_select = ((t->options & CTX_GPENCIL_STROKES) != 0) ? 
SNAP_NOT_ACTIVE : t->tsnap.modeSelect,
+   .snap_select = t->tsnap.modeSelect,
.use_object_edit_cage = (t->flag & T_EDIT) != 0,
},
mval, dist_px, NULL,
@@ -1304,7 +1306,7 @@ bool peelObjectsTransform(
t->tsnap.object_context,
mval,
&(const struct SnapObjectParams){
-   .snap_select = ((t->options & CTX_GPENCIL_STROKES) != 0) ? 
SNAP_NOT_ACTIVE : t->tsnap.modeSelect,
+   .snap_select = t->tsnap.modeSelect,
.use_object_edit_cage = (t->flag & T_EDIT) != 0,
},
use_peel_object,

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


[Bf-blender-cvs] [5fa0315a75] clay-engine: Mesh batch caches should not be stored in file

2017-01-30 Thread Dalai Felinto
Commit: 5fa0315a754270a82589a7437a3e60cf7e221d78
Author: Dalai Felinto
Date:   Fri Jan 27 15:21:14 2017 +0100
Branches: clay-engine
https://developer.blender.org/rB5fa0315a754270a82589a7437a3e60cf7e221d78

Mesh batch caches should not be stored in file

===

M   source/blender/blenloader/intern/writefile.c

===

diff --git a/source/blender/blenloader/intern/writefile.c 
b/source/blender/blenloader/intern/writefile.c
index 151fd06ed6..2df7fb3bec 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -2271,6 +2271,7 @@ static void write_meshes(WriteData *wd, ListBase *idbase)
CustomData_reset(>pdata);
CustomData_reset(>ldata);
mesh->edit_btmesh = NULL;
+   mesh->batch_cache = NULL;
 
/* now fill in polys to mfaces */
/* XXX This breaks writing design, by using 
temp allocated memory, which will likely generate

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


[Bf-blender-cvs] [a35a66f702] render-layers: Properties Editor: Collection context

2017-01-30 Thread Dalai Felinto
Commit: a35a66f702f613ce405fdb25438b8a1eccbb2278
Author: Dalai Felinto
Date:   Mon Jan 30 18:24:33 2017 +0100
Branches: render-layers
https://developer.blender.org/rBa35a66f702f613ce405fdb25438b8a1eccbb2278

Properties Editor: Collection context

===

M   release/scripts/startup/bl_ui/__init__.py
A   release/scripts/startup/bl_ui/properties_collection.py
M   source/blender/editors/space_buttons/buttons_context.c
M   source/blender/editors/space_buttons/space_buttons.c
M   source/blender/makesdna/DNA_space_types.h
M   source/blender/makesrna/intern/rna_space.c

===

diff --git a/release/scripts/startup/bl_ui/__init__.py 
b/release/scripts/startup/bl_ui/__init__.py
index e39fca6e16..0f26ff7571 100644
--- a/release/scripts/startup/bl_ui/__init__.py
+++ b/release/scripts/startup/bl_ui/__init__.py
@@ -29,6 +29,7 @@ if "bpy" in locals():
 
 _modules = [
 "properties_animviz",
+"properties_collection",
 "properties_constraint",
 "properties_data_armature",
 "properties_data_bone",
diff --git a/release/scripts/startup/bl_ui/properties_collection.py 
b/release/scripts/startup/bl_ui/properties_collection.py
new file mode 100644
index 00..e71cb264f2
--- /dev/null
+++ b/release/scripts/startup/bl_ui/properties_collection.py
@@ -0,0 +1,79 @@
+# # BEGIN GPL LICENSE BLOCK #
+#
+#  This program is free software; you can redistribute it and/or
+#  modify it under the terms of the GNU General Public License
+#  as published by the Free Software Foundation; either version 2
+#  of the License, or (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program; if not, write to the Free Software Foundation,
+#  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# # END GPL LICENSE BLOCK #
+
+# 
+import bpy
+from bpy.types import Panel, UIList
+
+
+class CollectionButtonsPanel:
+bl_space_type = 'PROPERTIES'
+bl_region_type = 'WINDOW'
+bl_context = "collection"
+
+
+class COLLECTION_PT_context_collection(CollectionButtonsPanel, Panel):
+bl_label = ""
+bl_options = {'HIDE_HEADER'}
+
+def draw(self, context):
+layout = self.layout
+space = context.space_data
+
+collection = context.layer_collection
+name = collection.name
+if name == 'Master Collection':
+layout.label(text=name)
+else:
+layout.prop(collection, "name")
+
+
+class COLLECTION_UL_objects(UIList):
+def draw_item(self, context, layout, data, item, icon, active_data, 
active_propname, index):
+# assert(isinstance(item, bpy.types.Object)
+ob = item
+if self.layout_type in {'DEFAULT', 'COMPACT'}:
+layout.label(ob.name, icon_value=icon)
+
+elif self.layout_type == 'GRID':
+layout.alignment = 'CENTER'
+layout.label("", icon_value=icon)
+
+
+class COLLECTION_PT_objects(CollectionButtonsPanel, Panel):
+bl_label = "Objects"
+
+def draw(self, context):
+layout = self.layout
+scene = context.scene
+collection = context.scene_collection
+
+row = layout.row()
+row.template_list("COLLECTION_UL_objects", "name", collection, 
"objects", collection.objects, "active_index", rows=2)
+
+col = row.column(align=True)
+col.operator("collections.objects_add", icon='ZOOMIN', text="")
+col.operator("collections.objects_remove", icon='ZOOMOUT', text="")
+
+row = layout.row(align=True)
+row.operator("collections.objects_select", text="Select")
+row.operator("collections.objects_deselect", text="Deselect")
+
+
+if __name__ == "__main__":  # only for live edit.
+bpy.utils.register_module(__name__)
diff --git a/source/blender/editors/space_buttons/buttons_context.c 
b/source/blender/editors/space_buttons/buttons_context.c
index da3364d872..8106e0cfdd 100644
--- a/source/blender/editors/space_buttons/buttons_context.c
+++ b/source/blender/editors/space_buttons/buttons_context.c
@@ -49,6 +49,7 @@
 
 #include "BKE_context.h"
 #include "BKE_action.h"
+#include "BKE_layer.h"
 #include "BKE_material.h"
 #include "BKE_modifier.h"
 #include "BKE_paint.h"
@@ -553,6 +554,28 @@ static bool buttons_context_linestyle_pinnable(const 
bContext *C)
 }
 #endif
 
+static int buttons_context_path_collection(const bContext *C, ButsContextPath 
*path)
+{
+   PointerRNA *ptr = >ptr[path->len - 1];
+
+   /* if we already have a (pinned) Collection, we're done */
+   if (RNA_struct_is_a(ptr->type, 

[Bf-blender-cvs] [1bfc6e79ee] render-layers: RNA: collection override

2017-01-30 Thread Dalai Felinto
Commit: 1bfc6e79eea93dfd9f32b508f10b1055d3f15fb1
Author: Dalai Felinto
Date:   Mon Jan 30 18:07:38 2017 +0100
Branches: render-layers
https://developer.blender.org/rB1bfc6e79eea93dfd9f32b508f10b1055d3f15fb1

RNA: collection override

===

M   source/blender/makesrna/RNA_access.h
M   source/blender/makesrna/intern/rna_scene.c

===

diff --git a/source/blender/makesrna/RNA_access.h 
b/source/blender/makesrna/RNA_access.h
index c07287abd1..9c45e34f21 100644
--- a/source/blender/makesrna/RNA_access.h
+++ b/source/blender/makesrna/RNA_access.h
@@ -318,6 +318,7 @@ extern StructRNA RNA_Lattice;
 extern StructRNA RNA_LatticeModifier;
 extern StructRNA RNA_LatticePoint;
 extern StructRNA RNA_LayerCollection;
+extern StructRNA RNA_LayerCollectionOverride;
 extern StructRNA RNA_Library;
 extern StructRNA RNA_LimitDistanceConstraint;
 extern StructRNA RNA_LimitLocationConstraint;
diff --git a/source/blender/makesrna/intern/rna_scene.c 
b/source/blender/makesrna/intern/rna_scene.c
index 64feb82020..3456c7107c 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -5559,6 +5559,21 @@ static void rna_def_scene_collection(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Filter Objects", "All the objects 
dynamically added to this collection via the filter");
 }
 
+static void rna_def_layer_collection_override(BlenderRNA *brna)
+{
+   StructRNA *srna;
+   PropertyRNA *prop;
+
+   srna = RNA_def_struct(brna, "LayerCollectionOverride", NULL);
+   RNA_def_struct_sdna(srna, "CollectionOverride");
+   RNA_def_struct_ui_text(srna, "Collection Override", "Collection 
Override");
+
+   prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
+   RNA_def_property_ui_text(prop, "Name", "Collection name");
+   RNA_def_struct_name_property(srna, prop);
+   RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, NULL);
+}
+
 static void rna_def_layer_collection(BlenderRNA *brna)
 {
StructRNA *srna;
@@ -5590,6 +5605,11 @@ static void rna_def_layer_collection(BlenderRNA *brna)
RNA_def_property_collection_funcs(prop, NULL, NULL, NULL, 
"rna_LayerCollection_objects_get", NULL, NULL, NULL, NULL);
RNA_def_property_ui_text(prop, "Objects", "All the objects directly or 
indirectly added to this collection (not including sub-collection objects)");
 
+   prop = RNA_def_property(srna, "overrides", PROP_COLLECTION, PROP_NONE);
+   RNA_def_property_collection_sdna(prop, NULL, "overrides", NULL);
+   RNA_def_property_struct_type(prop, "LayerCollectionOverride");
+   RNA_def_property_ui_text(prop, "Collection Overrides", "");
+
/* Flags */
prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", 
COLLECTION_VISIBLE);
@@ -8173,6 +8193,7 @@ void RNA_def_scene(BlenderRNA *brna)
rna_def_display_safe_areas(brna);
rna_def_scene_collection(brna);
rna_def_layer_collection(brna);
+   rna_def_layer_collection_override(brna);
rna_def_scene_layer(brna);
rna_def_object_base(brna);
RNA_define_animate_sdna(true);

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


[Bf-blender-cvs] [45b9dee8bd] render-layers: SceneCollection.objects.active_index (for user interface)

2017-01-30 Thread Dalai Felinto
Commit: 45b9dee8bd7ec38e31ce95721290a90c0efc18dd
Author: Dalai Felinto
Date:   Mon Jan 30 18:23:05 2017 +0100
Branches: render-layers
https://developer.blender.org/rB45b9dee8bd7ec38e31ce95721290a90c0efc18dd

SceneCollection.objects.active_index (for user interface)

===

M   source/blender/makesdna/DNA_layer_types.h
M   source/blender/makesrna/intern/rna_scene.c

===

diff --git a/source/blender/makesdna/DNA_layer_types.h 
b/source/blender/makesdna/DNA_layer_types.h
index d45334a227..d725a56d82 100644
--- a/source/blender/makesdna/DNA_layer_types.h
+++ b/source/blender/makesdna/DNA_layer_types.h
@@ -73,6 +73,8 @@ typedef struct SceneCollection {
struct SceneCollection *next, *prev;
char name[64]; /* MAX_NAME */
char filter[64]; /* MAX_NAME */
+   int active_object_index; /* for UI */
+   int pad;
ListBase objects;   /* (Object *)LinkData->data */
ListBase filter_objects;/* (Object *)LinkData->data */
ListBase scene_collections; /* nested collections */
diff --git a/source/blender/makesrna/intern/rna_scene.c 
b/source/blender/makesrna/intern/rna_scene.c
index 3456c7107c..bc442692b6 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -2254,6 +2254,26 @@ static void rna_SceneCollection_remove(
WM_main_add_notifier(NC_SCENE | ND_LAYER, NULL);
 }
 
+static int rna_SceneCollection_objects_active_index_get(PointerRNA *ptr)
+{
+   SceneCollection *sc = (SceneCollection *)ptr->data;
+   return sc->active_object_index;
+}
+
+static void rna_SceneCollection_objects_active_index_set(PointerRNA *ptr, int 
value)
+{
+   SceneCollection *sc = (SceneCollection *)ptr->data;
+   sc->active_object_index = value;
+}
+
+static void rna_SceneCollection_objects_active_index_range(
+PointerRNA *ptr, int *min, int *max, int *UNUSED(softmin), int 
*UNUSED(softmax))
+{
+   SceneCollection *sc = (SceneCollection *)ptr->data;
+   *min = 0;
+   *max = max_ii(0, BLI_listbase_count(>objects) - 1);
+}
+
 void rna_SceneCollection_object_link(
 ID *id, SceneCollection *sc, Main *bmain, ReportList *reports, Object 
*ob)
 {
@@ -5501,12 +5521,20 @@ static void rna_def_collection_objects(BlenderRNA 
*brna, PropertyRNA *cprop)
StructRNA *srna;
FunctionRNA *func;
PropertyRNA *parm;
+   PropertyRNA *prop;
 
RNA_def_property_srna(cprop, "CollectionObjects");
srna = RNA_def_struct(brna, "CollectionObjects", NULL);
RNA_def_struct_sdna(srna, "SceneCollection");
RNA_def_struct_ui_text(srna, "Collection Objects", "Objects of a 
collection");
 
+   prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED);
+   RNA_def_property_int_funcs(prop, 
"rna_SceneCollection_objects_active_index_get",
+  
"rna_SceneCollection_objects_active_index_set",
+  
"rna_SceneCollection_objects_active_index_range");
+   RNA_def_property_ui_text(prop, "Active Object Index", "Active index in 
collection objects array");
+   RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, NULL);
+
func = RNA_def_function(srna, "link", 
"rna_SceneCollection_object_link");
RNA_def_function_ui_description(func, "Link an object to collection");
RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN | 
FUNC_USE_REPORTS);

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


[Bf-blender-cvs] [8605eb9c97] render-layers: Collection related operators barebones

2017-01-30 Thread Dalai Felinto
Commit: 8605eb9c971db41a350a1f11d08bc0d56cecae2d
Author: Dalai Felinto
Date:   Mon Jan 30 18:10:12 2017 +0100
Branches: render-layers
https://developer.blender.org/rB8605eb9c971db41a350a1f11d08bc0d56cecae2d

Collection related operators barebones

Those are the operators for the collections editor, and the collection property 
panel

===

M   source/blender/blenkernel/BKE_layer.h
M   source/blender/editors/space_collections/collections_ops.c

===

diff --git a/source/blender/blenkernel/BKE_layer.h 
b/source/blender/blenkernel/BKE_layer.h
index 0f328700bf..8841113210 100644
--- a/source/blender/blenkernel/BKE_layer.h
+++ b/source/blender/blenkernel/BKE_layer.h
@@ -38,6 +38,7 @@ extern "C" {
 #define TODO_LAYER_OVERRIDE /* CollectionOverride */
 #define TODO_LAYER_CONTEXT /* get/set current (context) SceneLayer */
 #define TODO_LAYER_BASE /* Base to ObjectBase related TODO */
+#define TODO_LAYER_OPERATORS /* collection mamanger and property panel 
operators */
 #define TODO_LAYER /* generic todo */
 
 struct LayerCollection;
diff --git a/source/blender/editors/space_collections/collections_ops.c 
b/source/blender/editors/space_collections/collections_ops.c
index c822ac1e82..ff62696621 100644
--- a/source/blender/editors/space_collections/collections_ops.c
+++ b/source/blender/editors/space_collections/collections_ops.c
@@ -22,16 +22,329 @@
  *  \ingroup spcollections
  */
 
+#include "BKE_context.h"
+#include "BKE_layer.h"
+#include "BKE_report.h"
+
+#include "ED_screen.h"
+
 #include "WM_api.h"
+#include "WM_types.h"
+
 #include "collections_intern.h" /* own include */
 
+/*  */
+/* polls */
+
+static SceneCollection *collection_manager_collection_active(bContext *C)
+{
+   TODO_LAYER_OPERATORS;
+   /* consider that we may have overrides active
+* leading to no active collections */
+   return CTX_data_scene_collection(C);
+}
+
+static int operator_not_master_collection_active(bContext *C)
+{
+   if (ED_operator_collections_active(C) == false) {
+   return 0;
+   }
+
+   SceneCollection *sc = collection_manager_collection_active(C);
+   if (sc == NULL) {
+   return 1;
+   }
+
+   return  (sc == BKE_collection_master(CTX_data_scene(C))) ? 0 : 1;
+}
+
+static int operator_top_collection_active(bContext *C)
+{
+   if (ED_operator_collections_active(C) == false) {
+   return 0;
+   }
+
+   SceneCollection *sc = collection_manager_collection_active(C);
+   if (sc == NULL) {
+   return 0;
+   }
+
+   TODO_LAYER_OPERATORS;
+   /* see if it's a top collection */
+   return 1;
+}
+
+static int operator_collection_active(bContext *C)
+{
+   if (ED_operator_collections_active(C) == false) {
+   return 0;
+   }
+   return collection_manager_collection_active(C) ? 1 : 0;
+}
+
+/*  */
+/* collection manager operators */
+
+static int collection_link_invoke(bContext *UNUSED(C), wmOperator *op, const 
wmEvent *UNUSED(event))
+{
+   TODO_LAYER_OPERATORS;
+   BKE_report(op->reports, RPT_ERROR, "COLLECTIONS_OT_collection_link not 
implemented yet");
+   return OPERATOR_CANCELLED;
+}
+
+static void COLLECTIONS_OT_collection_link(wmOperatorType *ot)
+{
+   /* identifiers */
+   ot->name = "Add Collection";
+   ot->idname = "COLLECTIONS_OT_collection_link";
+   ot->description = "Link a new collection to the active layer";
+
+   /* api callbacks */
+   ot->invoke = collection_link_invoke;
+   ot->poll = ED_operator_collections_active;
+
+   /* flags */
+   ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+}
+
+static int collection_unlink_invoke(bContext *UNUSED(C), wmOperator *op, const 
wmEvent *UNUSED(event))
+{
+   TODO_LAYER_OPERATORS;
+   BKE_report(op->reports, RPT_ERROR, "COLLECTIONS_OT_collection_unlink 
not implemented yet");
+   return OPERATOR_CANCELLED;
+}
+
+static void COLLECTIONS_OT_collection_unlink(wmOperatorType *ot)
+{
+   /* identifiers */
+   ot->name = "Add Collection";
+   ot->idname = "COLLECTIONS_OT_collection_unlink";
+   ot->description = "Link a new collection to the active layer";
+
+   /* api callbacks */
+   ot->invoke = collection_unlink_invoke;
+   ot->poll = operator_top_collection_active;
+
+   /* flags */
+   ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+}
+
+static int collection_new_invoke(bContext *C, wmOperator *op, const wmEvent 
*UNUSED(event))
+{
+   Scene *scene = CTX_data_scene(C);
+   SceneLayer *sl = CTX_data_scene_layer(C);
+
+   SceneCollection *sc = BKE_collection_add(scene, NULL, NULL);
+   BKE_collection_link(sl, sc);
+
+   TODO_LAYER_OPERATORS;
+   /* 

[Bf-blender-cvs] [3da834e83c] render-layers: Collection Editor based on patch by Julian Eisel

2017-01-30 Thread Dalai Felinto
Commit: 3da834e83ce9d7056c033148dab04885a6d3b1b7
Author: Dalai Felinto
Date:   Mon Jan 30 14:14:27 2017 +0100
Branches: render-layers
https://developer.blender.org/rB3da834e83ce9d7056c033148dab04885a6d3b1b7

Collection Editor based on patch by Julian Eisel

This is extracted from the layer-manager branch. With the following
changes:

* Renamed references of layer manager to collections manager
* I didn't include the editors/space_collections/ draw and util files.

I still need to bring the drawing code here, so we see something.

===

M   build_files/cmake/macros.cmake
M   release/scripts/startup/bl_ui/__init__.py
A   release/scripts/startup/bl_ui/space_collections.py
M   source/blender/blenkernel/BKE_context.h
M   source/blender/blenkernel/intern/context.c
M   source/blender/blenloader/intern/readfile.c
M   source/blender/blenloader/intern/writefile.c
M   source/blender/editors/CMakeLists.txt
M   source/blender/editors/include/BIF_glutil.h
M   source/blender/editors/include/ED_object.h
M   source/blender/editors/include/ED_screen.h
M   source/blender/editors/include/ED_space_api.h
M   source/blender/editors/include/UI_interface.h
M   source/blender/editors/include/UI_interface_icons.h
M   source/blender/editors/interface/interface_icons.c
M   source/blender/editors/interface/interface_widgets.c
M   source/blender/editors/interface/resources.c
M   source/blender/editors/screen/glutil.c
M   source/blender/editors/screen/screen_ops.c
M   source/blender/editors/space_api/spacetypes.c
A   source/blender/editors/space_collections/CMakeLists.txt
A   source/blender/editors/space_collections/collections_intern.h
A   source/blender/editors/space_collections/collections_ops.c
A   source/blender/editors/space_collections/space_collections.c
M   source/blender/makesdna/DNA_space_types.h
M   source/blender/makesdna/DNA_userdef_types.h
M   source/blender/makesrna/RNA_access.h
M   source/blender/makesrna/intern/rna_space.c
M   source/blender/makesrna/intern/rna_userdef.c
M   source/blender/python/intern/bpy_rna_callback.c
M   source/blender/windowmanager/WM_types.h
M   source/blender/windowmanager/intern/wm_keymap.c

===

diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake
index 09428953a4..83ae56636b 100644
--- a/build_files/cmake/macros.cmake
+++ b/build_files/cmake/macros.cmake
@@ -566,6 +566,7 @@ function(SETUP_BLENDER_SORTED_LIBS)
bf_editor_space_userpref
bf_editor_space_view3d
bf_editor_space_clip
+   bf_editor_space_collections
 
bf_editor_transform
bf_editor_util
diff --git a/release/scripts/startup/bl_ui/__init__.py 
b/release/scripts/startup/bl_ui/__init__.py
index 2389be6787..e39fca6e16 100644
--- a/release/scripts/startup/bl_ui/__init__.py
+++ b/release/scripts/startup/bl_ui/__init__.py
@@ -69,6 +69,7 @@ _modules = [
 "space_graph",
 "space_image",
 "space_info",
+"space_collections",
 "space_logic",
 "space_nla",
 "space_node",
diff --git a/release/scripts/startup/bl_ui/space_collections.py 
b/release/scripts/startup/bl_ui/space_collections.py
new file mode 100644
index 00..e46684b62b
--- /dev/null
+++ b/release/scripts/startup/bl_ui/space_collections.py
@@ -0,0 +1,35 @@
+# # BEGIN GPL LICENSE BLOCK #
+#
+#  This program is free software; you can redistribute it and/or
+#  modify it under the terms of the GNU General Public License
+#  as published by the Free Software Foundation; either version 2
+#  of the License, or (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program; if not, write to the Free Software Foundation,
+#  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# # END GPL LICENSE BLOCK #
+
+# 
+import bpy
+from bpy.types import Header, Menu
+
+
+class COLLECTIONS_HT_header(Header):
+bl_space_type = 'COLLECTION_MANAGER'
+
+def draw(self, context):
+layout = self.layout
+
+layout.template_header()
+layout.label(text="Work in progress")
+
+
+if __name__ == "__main__":  # only for live edit.
+bpy.utils.register_module(__name__)
diff --git a/source/blender/blenkernel/BKE_context.h 
b/source/blender/blenkernel/BKE_context.h
index 649d142d1c..3f13105069 100644
--- a/source/blender/blenkernel/BKE_context.h
+++ b/source/blender/blenkernel/BKE_context.h
@@ -169,6 +169,7 @@ struct SpaceAction 

[Bf-blender-cvs] [f51c34185e] render-layers: bpy.context.layer_collection

2017-01-30 Thread Dalai Felinto
Commit: f51c34185ed424a5e3ea0a2fa2f34f8ec9d678b2
Author: Dalai Felinto
Date:   Mon Jan 30 18:07:14 2017 +0100
Branches: render-layers
https://developer.blender.org/rBf51c34185ed424a5e3ea0a2fa2f34f8ec9d678b2

bpy.context.layer_collection

===

M   source/blender/blenkernel/BKE_context.h
M   source/blender/blenkernel/intern/context.c
M   source/blender/makesrna/RNA_access.h
M   source/blender/makesrna/intern/rna_context.c

===

diff --git a/source/blender/blenkernel/BKE_context.h 
b/source/blender/blenkernel/BKE_context.h
index 3f13105069..2fd11746fb 100644
--- a/source/blender/blenkernel/BKE_context.h
+++ b/source/blender/blenkernel/BKE_context.h
@@ -40,6 +40,7 @@ extern "C" {
 struct ARegion;
 struct bScreen;
 struct CacheFile;
+struct LayerCollection;
 struct ListBase;
 struct Main;
 struct Object;
@@ -243,6 +244,7 @@ int ctx_data_list_count(const bContext *C, int 
(*func)(const bContext *, ListBas
 
 struct Main *CTX_data_main(const bContext *C);
 struct Scene *CTX_data_scene(const bContext *C);
+struct LayerCollection *CTX_data_layer_collection(const bContext *C);
 struct SceneCollection *CTX_data_scene_collection(const bContext *C);
 struct SceneLayer *CTX_data_scene_layer(const bContext *C);
 struct ToolSettings *CTX_data_tool_settings(const bContext *C);
diff --git a/source/blender/blenkernel/intern/context.c 
b/source/blender/blenkernel/intern/context.c
index 85fa57f788..f079ec8f7b 100644
--- a/source/blender/blenkernel/intern/context.c
+++ b/source/blender/blenkernel/intern/context.c
@@ -928,20 +928,39 @@ SceneLayer *CTX_data_scene_layer(const bContext *C)
  * If the scene_collection is linked to the SceneLayer we use it.
  * Otherwise we fallback to the active one of the SceneLayer.
  */
-SceneCollection *CTX_data_scene_collection(const bContext *C)
+LayerCollection *CTX_data_layer_collection(const bContext *C)
 {
SceneLayer *sl = CTX_data_scene_layer(C);
-   SceneCollection *sc;
+   LayerCollection *lc;
+
+   if (ctx_data_pointer_verify(C, "layer_collection", (void *))) {
+   if (BKE_scene_layer_has_collection(sl, lc->scene_collection)) {
+   return lc;
+   }
+   }
+
+   /* fallback */
+   return BKE_layer_collection_active(sl);
+}
 
+SceneCollection *CTX_data_scene_collection(const bContext *C)
+{
+   SceneCollection *sc;
if (ctx_data_pointer_verify(C, "scene_collection", (void *))) {
-   if (BKE_scene_layer_has_collection(sl, sc)) {
+   if (BKE_scene_layer_has_collection(CTX_data_scene_layer(C), 
sc)) {
return sc;
}
}
+   else {
+   LayerCollection *lc = CTX_data_layer_collection(C);
+   if (lc) {
+   return lc->scene_collection;
+   }
+   }
 
/* fallback */
-   LayerCollection *lc = BKE_layer_collection_active(sl);
-   return lc->scene_collection;
+   Scene *scene = CTX_data_scene(C);
+   return BKE_collection_master(scene);
 }
 
 int CTX_data_mode_enum(const bContext *C)
diff --git a/source/blender/makesrna/RNA_access.h 
b/source/blender/makesrna/RNA_access.h
index 48e20e7252..c07287abd1 100644
--- a/source/blender/makesrna/RNA_access.h
+++ b/source/blender/makesrna/RNA_access.h
@@ -317,6 +317,7 @@ extern StructRNA RNA_LaplacianSmoothModifier;
 extern StructRNA RNA_Lattice;
 extern StructRNA RNA_LatticeModifier;
 extern StructRNA RNA_LatticePoint;
+extern StructRNA RNA_LayerCollection;
 extern StructRNA RNA_Library;
 extern StructRNA RNA_LimitDistanceConstraint;
 extern StructRNA RNA_LimitLocationConstraint;
diff --git a/source/blender/makesrna/intern/rna_context.c 
b/source/blender/makesrna/intern/rna_context.c
index 9270cda0d2..27e88f592a 100644
--- a/source/blender/makesrna/intern/rna_context.c
+++ b/source/blender/makesrna/intern/rna_context.c
@@ -120,6 +120,13 @@ static PointerRNA 
rna_Context_scene_collection_get(PointerRNA *ptr)
return rna_pointer_inherit_refine(ptr, _SceneCollection, 
CTX_data_scene_collection(C));
 }
 
+static PointerRNA rna_Context_layer_collection_get(PointerRNA *ptr)
+{
+   bContext *C = (bContext *)ptr->data;
+   ptr->id.data = CTX_data_scene(C);
+   return rna_pointer_inherit_refine(ptr, _LayerCollection, 
CTX_data_layer_collection(C));
+}
+
 static PointerRNA rna_Context_tool_settings_get(PointerRNA *ptr)
 {
bContext *C = (bContext *)ptr->data;
@@ -226,6 +233,11 @@ void RNA_def_context(BlenderRNA *brna)
RNA_def_property_struct_type(prop, "SceneCollection");
RNA_def_property_pointer_funcs(prop, 
"rna_Context_scene_collection_get", NULL, NULL, NULL);
 
+   prop = RNA_def_property(srna, "layer_collection", PROP_POINTER, 
PROP_NONE);
+   RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+   RNA_def_property_struct_type(prop, 

[Bf-blender-cvs] [dce8ef49ff] render-layers: Layers: allow anonymous collection, and set active collection when linking it

2017-01-30 Thread Dalai Felinto
Commit: dce8ef49ffb7c2e38455da8195b9cacba8b0424a
Author: Dalai Felinto
Date:   Mon Jan 30 14:14:52 2017 +0100
Branches: render-layers
https://developer.blender.org/rBdce8ef49ffb7c2e38455da8195b9cacba8b0424a

Layers: allow anonymous collection, and set active collection when linking it

===

M   source/blender/blenkernel/intern/collection.c
M   source/blender/blenkernel/intern/layer.c

===

diff --git a/source/blender/blenkernel/intern/collection.c 
b/source/blender/blenkernel/intern/collection.c
index c7ff70e404..f374ebd1e5 100644
--- a/source/blender/blenkernel/intern/collection.c
+++ b/source/blender/blenkernel/intern/collection.c
@@ -50,8 +50,16 @@
  */
 SceneCollection *BKE_collection_add(Scene *scene, SceneCollection *sc_parent, 
const char *name)
 {
-   SceneCollection *sc = MEM_callocN(sizeof(SceneCollection), "New 
Collection");
SceneCollection *sc_master = BKE_collection_master(scene);
+   SceneCollection *sc = MEM_callocN(sizeof(SceneCollection), "New 
Collection");
+
+   if (!name) {
+   name = DATA_("New Collection");
+   }
+
+   if (!sc_parent) {
+   sc_parent = sc_master;
+   }
 
BLI_strncpy(sc->name, name, sizeof(sc->name));
BLI_uniquename(_master->scene_collections, sc, DATA_("Collection"), 
'.', offsetof(SceneCollection, name), sizeof(sc->name));
diff --git a/source/blender/blenkernel/intern/layer.c 
b/source/blender/blenkernel/intern/layer.c
index bb013b4aa4..39b0053122 100644
--- a/source/blender/blenkernel/intern/layer.c
+++ b/source/blender/blenkernel/intern/layer.c
@@ -30,6 +30,7 @@
 #include "BLI_string_utils.h"
 #include "BLT_translation.h"
 
+#include "BKE_layer.h"
 #include "BKE_collection.h"
 #include "BKE_layer.h"
 #include "BKE_main.h"
@@ -395,6 +396,7 @@ int BKE_layer_collection_findindex(SceneLayer *sl, 
LayerCollection *lc)
 LayerCollection *BKE_collection_link(SceneLayer *sl, SceneCollection *sc)
 {
LayerCollection *lc = layer_collection_add(sl, >layer_collections, 
sc);
+   sl->active_collection = BKE_layer_collection_findindex(sl, lc);
return lc;
 }

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


[Bf-blender-cvs] [f35d38e5a7] render-layers: Collections Editor: populate header with operators

2017-01-30 Thread Dalai Felinto
Commit: f35d38e5a71500f1180a6d8878970c637b675214
Author: Dalai Felinto
Date:   Mon Jan 30 18:23:51 2017 +0100
Branches: render-layers
https://developer.blender.org/rBf35d38e5a71500f1180a6d8878970c637b675214

Collections Editor: populate header with operators

===

M   release/scripts/startup/bl_ui/space_collections.py

===

diff --git a/release/scripts/startup/bl_ui/space_collections.py 
b/release/scripts/startup/bl_ui/space_collections.py
index e46684b62b..9b612ce2ec 100644
--- a/release/scripts/startup/bl_ui/space_collections.py
+++ b/release/scripts/startup/bl_ui/space_collections.py
@@ -28,7 +28,13 @@ class COLLECTIONS_HT_header(Header):
 layout = self.layout
 
 layout.template_header()
-layout.label(text="Work in progress")
+
+row = layout.row(align=True)
+row.operator("collections.collection_new", text="", icon='NEW')
+row.operator("collections.override_new", text="", icon='LINK_AREA')
+row.operator("collections.collection_link", text="", icon='LINKED')
+row.operator("collections.collection_unlink", text="", icon='UNLINKED')
+row.operator("collections.delete", text="", icon='X')
 
 
 if __name__ == "__main__":  # only for live edit.

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


[Bf-blender-cvs] [b86e5a9fbf] clay-engine: Fixed Pointer problem. Now materials are working.

2017-01-30 Thread Clément Foucault
Commit: b86e5a9fbfc7b2b2bb1d80f800ac17f5c4fc1f8a
Author: Clément Foucault
Date:   Mon Jan 30 15:09:35 2017 +0100
Branches: clay-engine
https://developer.blender.org/rBb86e5a9fbfc7b2b2bb1d80f800ac17f5c4fc1f8a

Fixed Pointer problem. Now materials are working.

===

M   source/blender/draw/DRW_engine.h
M   source/blender/draw/engines/clay/clay.c
M   source/blender/draw/intern/DRW_render.h
M   source/blender/draw/intern/draw_manager.c
M   source/blender/makesrna/intern/rna_scene.c

===

diff --git a/source/blender/draw/DRW_engine.h b/source/blender/draw/DRW_engine.h
index 93b5e69d4d..05222574ae 100644
--- a/source/blender/draw/DRW_engine.h
+++ b/source/blender/draw/DRW_engine.h
@@ -39,7 +39,7 @@ void DRW_engines_free(void);
 void DRW_pass_free(struct DRWPass *pass);
 
 /* Settings */
-void *DRW_material_settings_get(struct Material *ma, const char *engine_name, 
void **runtime);
-void *DRW_render_settings_get(struct Scene *scene, const char *engine_name, 
void **runtime);
+void *DRW_material_settings_get(struct Material *ma, const char *engine_name, 
void ***runtime);
+void *DRW_render_settings_get(struct Scene *scene, const char *engine_name, 
void ***runtime);
 
 #endif /* __DRW_ENGINE_H__ */
\ No newline at end of file
diff --git a/source/blender/draw/engines/clay/clay.c 
b/source/blender/draw/engines/clay/clay.c
index d084a3383b..a588412903 100644
--- a/source/blender/draw/engines/clay/clay.c
+++ b/source/blender/draw/engines/clay/clay.c
@@ -487,19 +487,19 @@ static void update_ubo_storage(MaterialRuntimeClay 
*runtime, unsigned int curren
 static void CLAY_update_material_ubo(const struct bContext *C)
 {
Main *bmain = CTX_data_main(C);
-   MaterialRuntimeClay *runtime;
+   MaterialRuntimeClay **runtime;
 
/* Update Default materials */
for (Scene *sce = bmain->scene.first; sce; sce = sce->id.next) {
/* Using render settings as material settings */
-   MaterialEngineSettingsClay *res = DRW_render_settings_get(sce, 
RE_engine_id_BLENDER_CLAY, (void **));
-   CLAY_update_material_runtime(res, );
+   MaterialEngineSettingsClay *res = DRW_render_settings_get(sce, 
RE_engine_id_BLENDER_CLAY, (void ***));
+   CLAY_update_material_runtime(res, runtime);
}
 
/* Update Scene Materials */
for (Material *mat = bmain->mat.first; mat; mat = mat->id.next) {
-   MaterialEngineSettingsClay *mesc = 
DRW_material_settings_get(mat, RE_engine_id_BLENDER_CLAY, (void **));
-   CLAY_update_material_runtime(mesc, );
+   MaterialEngineSettingsClay *mesc = 
DRW_material_settings_get(mat, RE_engine_id_BLENDER_CLAY, (void ***));
+   CLAY_update_material_runtime(mesc, runtime);
}
 
if (data.ubo_flag & CLAY_UBO_REFRESH) {
@@ -507,15 +507,15 @@ static void CLAY_update_material_ubo(const struct 
bContext *C)
 
/* Default materials */
for (Scene *sce = bmain->scene.first; sce; sce = sce->id.next) {
-   DRW_render_settings_get(sce, RE_engine_id_BLENDER_CLAY, 
(void **));
-   update_ubo_storage(runtime, current_id);
+   DRW_render_settings_get(sce, RE_engine_id_BLENDER_CLAY, 
(void ***));
+   update_ubo_storage(*runtime, current_id);
current_id++;
}
 
/* TODO only add materials linked to geometry */
for (Material *mat = bmain->mat.first; mat; mat = mat->id.next) 
{
-   DRW_material_settings_get(mat, 
RE_engine_id_BLENDER_CLAY, (void **));
-   update_ubo_storage(runtime, current_id);
+   DRW_material_settings_get(mat, 
RE_engine_id_BLENDER_CLAY, (void ***));
+   update_ubo_storage(*runtime, current_id);
current_id++;
}
 
@@ -540,12 +540,12 @@ static void CLAY_create_cache(CLAY_PassList *passes, 
const struct bContext *C)
 
/* Clay Pass */
{
-   MaterialRuntimeClay *runtime;
-   DRW_render_settings_get(NULL, RE_engine_id_BLENDER_CLAY, (void 
**));
+   MaterialRuntimeClay **runtime;
+   DRW_render_settings_get(NULL, RE_engine_id_BLENDER_CLAY, (void 
***));
 
passes->clay_pass = DRW_pass_create("Clay Pass", 
DRW_STATE_WRITE_COLOR);
 
-   default_shgrp = CLAY_shgroup_create(passes->clay_pass, 
>material_id);
+   default_shgrp = CLAY_shgroup_create(passes->clay_pass, 
&(*runtime)->material_id);
DRW_shgroup_uniform_block(default_shgrp, "material_block", 
data.mat_ubo, 0);
}
 
diff --git a/source/blender/draw/intern/DRW_render.h 
b/source/blender/draw/intern/DRW_render.h
index 

[Bf-blender-cvs] [f2e217938e] clay-engine: Fixed unfreed memory

2017-01-30 Thread Clément Foucault
Commit: f2e217938ed1c67c2b09b4e77f33f9303b0f0a1f
Author: Clément Foucault
Date:   Mon Jan 30 15:35:12 2017 +0100
Branches: clay-engine
https://developer.blender.org/rBf2e217938ed1c67c2b09b4e77f33f9303b0f0a1f

Fixed unfreed memory

===

M   source/blender/blenkernel/intern/material.c
M   source/blender/blenkernel/intern/scene.c

===

diff --git a/source/blender/blenkernel/intern/material.c 
b/source/blender/blenkernel/intern/material.c
index 3fb7ee89ae..89af048f73 100644
--- a/source/blender/blenkernel/intern/material.c
+++ b/source/blender/blenkernel/intern/material.c
@@ -112,7 +112,13 @@ void BKE_material_free(Material *ma)
BKE_icon_id_delete((ID *)ma);
BKE_previewimg_free(>preview);
 
-   /* TODO Free Engine Settings */
+   for (MaterialEngineSettings *mes = ma->engines_settings.first; mes; mes 
= mes->next) {
+   if (mes->runtime)
+   MEM_SAFE_FREE(mes->runtime);
+   if (mes->data)
+   MEM_SAFE_FREE(mes->data);
+   }
+   BLI_freelistN(>engines_settings);
 }
 
 void BKE_material_init(Material *ma)
diff --git a/source/blender/blenkernel/intern/scene.c 
b/source/blender/blenkernel/intern/scene.c
index b4aa47bf9d..807496d88e 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -569,6 +569,12 @@ void BKE_scene_free(Scene *sce)
sce->collection = NULL;
 
/* Runtime Engine Data */
+   for (RenderEngineSettings *res = sce->engines_settings.first; res; res 
= res->next) {
+   if (res->runtime)
+   MEM_freeN(res->runtime);
+   if (res->data)
+   MEM_freeN(res->data);
+   }
BLI_freelistN(>engines_settings);
 }

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


[Bf-blender-cvs] [106f415ddd] clay-engine: Fix crash on read file

2017-01-30 Thread Clément Foucault
Commit: 106f415ddde2b2b94a7d9bd1f8f9783e3a86358c
Author: Clément Foucault
Date:   Mon Jan 30 15:17:03 2017 +0100
Branches: clay-engine
https://developer.blender.org/rB106f415ddde2b2b94a7d9bd1f8f9783e3a86358c

Fix crash on read file

===

M   source/blender/blenloader/intern/readfile.c

===

diff --git a/source/blender/blenloader/intern/readfile.c 
b/source/blender/blenloader/intern/readfile.c
index 783eb8fd5f..51c28fed11 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -4615,6 +4615,7 @@ static void direct_link_mesh(FileData *fd, Mesh *mesh)
 
mesh->bb = NULL;
mesh->edit_btmesh = NULL;
+   mesh->batch_cache = NULL;

/* happens with old files */
if (mesh->mselect == NULL) {

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


[Bf-blender-cvs] [08675b94ef] clay-engine: Fixed Engine name length

2017-01-30 Thread Clément Foucault
Commit: 08675b94ef15b4ecb94ce0cefcbd4bba9cad60fa
Author: Clément Foucault
Date:   Mon Jan 30 13:03:30 2017 +0100
Branches: clay-engine
https://developer.blender.org/rB08675b94ef15b4ecb94ce0cefcbd4bba9cad60fa

Fixed Engine name length

===

M   source/blender/draw/intern/draw_manager.c
M   source/blender/makesdna/DNA_material_types.h
M   source/blender/makesdna/DNA_scene_types.h

===

diff --git a/source/blender/draw/intern/draw_manager.c 
b/source/blender/draw/intern/draw_manager.c
index 3f5cc156f5..26525954c2 100644
--- a/source/blender/draw/intern/draw_manager.c
+++ b/source/blender/draw/intern/draw_manager.c
@@ -859,7 +859,7 @@ void *DRW_material_settings_get(Material *ma, const char 
*engine_name, void **ru
if (ms == NULL) {
ms = MEM_callocN(sizeof(RenderEngineSettings), 
"RenderEngineSettings");
 
-   BLI_strncpy(ms->name, engine_name, 64);
+   BLI_strncpy(ms->name, engine_name, 32);
 
/* TODO make render_settings_create a polymorphic function */
if (STREQ(engine_name, RE_engine_id_BLENDER_CLAY)) {
@@ -894,7 +894,7 @@ void *DRW_render_settings_get(Scene *scene, const char 
*engine_name, void **runt
if (rs == NULL) {
rs = MEM_callocN(sizeof(RenderEngineSettings), 
"RenderEngineSettings");
 
-   BLI_strncpy(rs->name, engine_name, 64);
+   BLI_strncpy(rs->name, engine_name, 32);
 
/* TODO make render_settings_create a polymorphic function */
if (STREQ(engine_name, RE_engine_id_BLENDER_CLAY)) {
diff --git a/source/blender/makesdna/DNA_material_types.h 
b/source/blender/makesdna/DNA_material_types.h
index 3717561dd0..824925634d 100644
--- a/source/blender/makesdna/DNA_material_types.h
+++ b/source/blender/makesdna/DNA_material_types.h
@@ -93,7 +93,7 @@ typedef struct TexPaintSlot {
 /* Material Engine Settings */
 typedef struct MaterialEngineSettings {
struct MaterialEngineSettings *next, *prev;
-   char name[64]; /* engine name - MAX_NAME */
+   char name[32]; /* engine name - MAX_NAME */
void *runtime; /* To be free on file read */
void *data;
 } MaterialEngineSettings;
diff --git a/source/blender/makesdna/DNA_scene_types.h 
b/source/blender/makesdna/DNA_scene_types.h
index c042716fdc..1ae914eeea 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -550,7 +550,7 @@ typedef enum BakePassFilter {
 
 typedef struct RenderEngineSettings {
struct RenderEngineSettings *next, *prev;
-   char name[64]; /* engine name - MAX_NAME */
+   char name[32]; /* engine name */
void *runtime; /* Here to be free on file read */
void *data;
 } RenderEngineSettings;

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


[Bf-blender-cvs] [12bac207c7] clay-engine: Added scene.active_engine_settings

2017-01-30 Thread Clément Foucault
Commit: 12bac207c7d31206dfca15088bc16587d639dddc
Author: Clément Foucault
Date:   Mon Jan 30 14:41:58 2017 +0100
Branches: clay-engine
https://developer.blender.org/rB12bac207c7d31206dfca15088bc16587d639dddc

Added scene.active_engine_settings

===

M   release/scripts/startup/bl_ui/properties_render.py
M   source/blender/draw/intern/draw_manager.c
M   source/blender/makesrna/intern/rna_scene.c

===

diff --git a/release/scripts/startup/bl_ui/properties_render.py 
b/release/scripts/startup/bl_ui/properties_render.py
index b1c68559d8..5f2c9939dc 100644
--- a/release/scripts/startup/bl_ui/properties_render.py
+++ b/release/scripts/startup/bl_ui/properties_render.py
@@ -590,17 +590,17 @@ class RENDER_PT_clay(RenderButtonsPanel, Panel):
 
 def draw(self, context):
 layout = self.layout;
-# settings = context.scene.engine_settings
-# layout.template_icon_view(settings, "matcap_icon")
-# layout.prop(settings, "matcap_rotation")
-# layout.prop(settings, "matcap_hue")
-# layout.prop(settings, "matcap_saturation")
-# layout.prop(settings, "matcap_value")
-# layout.prop(settings, "ssao_factor_cavity")
-# layout.prop(settings, "ssao_factor_edge")
-# layout.prop(settings, "ssao_distance")
-# layout.prop(settings, "ssao_attenuation")
-# layout.prop(settings, "ssao_samples")
+settings = context.scene.active_engine_settings
+layout.template_icon_view(settings, "matcap_icon")
+layout.prop(settings, "matcap_rotation")
+layout.prop(settings, "matcap_hue")
+layout.prop(settings, "matcap_saturation")
+layout.prop(settings, "matcap_value")
+layout.prop(settings, "ssao_factor_cavity")
+layout.prop(settings, "ssao_factor_edge")
+layout.prop(settings, "ssao_distance")
+layout.prop(settings, "ssao_attenuation")
+layout.prop(settings, "ssao_samples")
 
 
 if __name__ == "__main__":  # only for live edit.
diff --git a/source/blender/draw/intern/draw_manager.c 
b/source/blender/draw/intern/draw_manager.c
index 26525954c2..683c0bd178 100644
--- a/source/blender/draw/intern/draw_manager.c
+++ b/source/blender/draw/intern/draw_manager.c
@@ -905,6 +905,8 @@ void *DRW_render_settings_get(Scene *scene, const char 
*engine_name, void **runt
BLI_assert(false);
}
 
+   printf("DRW_render_settings_get %s\n", rs->name);
+
BLI_addtail(>engines_settings, rs);
}
 
diff --git a/source/blender/makesrna/intern/rna_scene.c 
b/source/blender/makesrna/intern/rna_scene.c
index 2ac8d317b9..604a758980 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -1885,6 +1885,19 @@ static StructRNA 
*rna_RenderEngineSettings_refine(PointerRNA *ptr)
return _RenderEngineSettings;
 }
 
+static PointerRNA rna_RenderEngineSettings_active_get(PointerRNA *ptr)
+{
+   Scene *scene = (Scene *)ptr->data;
+   RenderEngineSettings *res;
+
+   /* Ensure settings exists */
+   DRW_render_settings_get(scene, scene->r.engine, NULL);
+
+   res = BLI_findstring(>engines_settings, scene->r.engine, 
offsetof(RenderEngineSettings, name));
+
+   return rna_pointer_inherit_refine(ptr, _RenderEngineSettings, res);
+}
+
 static void rna_RenderEngineSettings_update(Main *UNUSED(bmain), Scene 
*UNUSED(scene), PointerRNA *ptr)
 {
Scene *sce = (Scene *)ptr->id.data;
@@ -8166,6 +8179,11 @@ void RNA_def_scene(BlenderRNA *brna)
RNA_def_property_struct_type(prop, "RenderEngineSettings");
RNA_def_property_ui_text(prop, "Render Engine Settings", "Engine 
specific render settings");
 
+   prop = RNA_def_property(srna, "active_engine_settings", PROP_POINTER, 
PROP_NONE);
+   RNA_def_property_struct_type(prop, "RenderEngineSettings");
+   RNA_def_property_pointer_funcs(prop, 
"rna_RenderEngineSettings_active_get", NULL, NULL, NULL);
+   RNA_def_property_ui_text(prop, "Active Render Engine Settings", "Active 
Engine specific render settings for this scene");
+
/* Safe Areas */
prop = RNA_def_property(srna, "safe_areas", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "safe_areas");

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


[Bf-blender-cvs] [ba4a30c71b] clay-engine: Fix read/writefile.c

2017-01-30 Thread Clément Foucault
Commit: ba4a30c71baffde4af8e94257f2758a1f35aa23b
Author: Clément Foucault
Date:   Mon Jan 30 12:19:51 2017 +0100
Branches: clay-engine
https://developer.blender.org/rBba4a30c71baffde4af8e94257f2758a1f35aa23b

Fix read/writefile.c

===

M   source/blender/blenloader/intern/readfile.c
M   source/blender/blenloader/intern/writefile.c

===

diff --git a/source/blender/blenloader/intern/readfile.c 
b/source/blender/blenloader/intern/readfile.c
index a8dc9d0ed8..783eb8fd5f 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -3968,6 +3968,7 @@ static void lib_link_material(FileData *fd, Main *main)
 static void direct_link_material(FileData *fd, Material *ma)
 {
int a;
+   MaterialEngineSettings *mes;

ma->adt = newdataadr(fd, ma->adt);
direct_link_animdata(fd, ma->adt);
@@ -3988,6 +3989,12 @@ static void direct_link_material(FileData *fd, Material 
*ma)

ma->preview = direct_link_preview_image(fd, ma->preview);
BLI_listbase_clear(>gpumaterial);
+
+   link_list(fd, >engines_settings);
+   for (mes = ma->engines_settings.first; mes; mes = mes->next) {
+   mes->runtime = NULL;
+   mes->data = newdataadr(fd, mes->data);
+   }
 }
 
 /*  READ PARTICLE SETTINGS * */
@@ -6210,12 +6217,12 @@ static void direct_link_scene(FileData *fd, Scene *sce)
sl->basact = newdataadr(fd, sl->basact);
direct_link_layer_collections(fd, >layer_collections);
}
-#if 0
+
link_list(fd, >engines_settings);
for (res = sce->engines_settings.first; res; res = res->next) {
res->runtime = NULL;
+   res->data = newdataadr(fd, res->data);
}
-#endif
 }
 
 /*  READ WM * */
diff --git a/source/blender/blenloader/intern/writefile.c 
b/source/blender/blenloader/intern/writefile.c
index 4032dbe9d2..151fd06ed6 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -2468,6 +2468,21 @@ static void write_textures(WriteData *wd, ListBase 
*idbase)
mywrite_flush(wd);
 }
 
+static void write_material_engines_settings(WriteData *wd, ListBase *lb)
+{
+   for (MaterialEngineSettings *res = lb->first; res; res = res->next) {
+   writestruct(wd, DATA, MaterialEngineSettings, 1, res);
+
+   if (STREQ(res->name, RE_engine_id_BLENDER_CLAY)) {
+   writestruct(wd, DATA, MaterialEngineSettingsClay, 1, 
res->data);
+   }
+   else {
+   /* No engine matched */
+   /* error: don't know how to write this file */
+   }
+   }
+}
+
 static void write_materials(WriteData *wd, ListBase *idbase)
 {
Material *ma;
@@ -2504,6 +2519,8 @@ static void write_materials(WriteData *wd, ListBase 
*idbase)
}
 
write_previews(wd, ma->preview);
+
+   write_material_engines_settings(wd, 
>engines_settings);
}
ma = ma->id.next;
}
@@ -2650,6 +2667,21 @@ static void write_layer_collections(WriteData *wd, 
ListBase *lb)
}
 }
 
+static void write_render_engines_settings(WriteData *wd, ListBase *lb)
+{
+   for (RenderEngineSettings *res = lb->first; res; res = res->next) {
+   writestruct(wd, DATA, RenderEngineSettings, 1, res);
+
+   if (STREQ(res->name, RE_engine_id_BLENDER_CLAY)) {
+   writestruct(wd, DATA, RenderEngineSettingsClay, 1, 
res->data);
+   }
+   else {
+   /* No engine matched */
+   /* error: don't know how to write this file */
+   }
+   }
+}
+
 static void write_scenes(WriteData *wd, ListBase *scebase)
 {
Scene *sce;
@@ -2666,7 +2698,6 @@ static void write_scenes(WriteData *wd, ListBase *scebase)
FreestyleModuleConfig *fmc;
FreestyleLineSet *fls;
SceneLayer *sl;
-   RenderEngineSettings *res;
 
sce = scebase->first;
while (sce) {
@@ -2879,11 +2910,9 @@ static void write_scenes(WriteData *wd, ListBase 
*scebase)
writelist(wd, DATA, ObjectBase, >object_bases);
write_layer_collections(wd, >layer_collections);
}
-#if 0
-   for (res = sce->engines_settings.first; res; res = res->next) {
-   /* How to write if struct type is not known? */
-   }
-#endif
+
+   write_render_engines_settings(wd, >engines_settings);
+
sce = sce->id.next;
}

___
Bf-blender-cvs mailing list

[Bf-blender-cvs] [4580ace4c1] master: Alembic/CacheFile: fix crash de-referencing NULL pointer.

2017-01-30 Thread Kévin Dietrich
Commit: 4580ace4c1fe984f707385ea0318c53389fd2916
Author: Kévin Dietrich
Date:   Mon Jan 30 10:46:24 2017 +0100
Branches: master
https://developer.blender.org/rB4580ace4c1fe984f707385ea0318c53389fd2916

Alembic/CacheFile: fix crash de-referencing NULL pointer.

===

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

===

diff --git a/source/blender/blenkernel/intern/cachefile.c 
b/source/blender/blenkernel/intern/cachefile.c
index deeb35bd88..3dce08eb75 100644
--- a/source/blender/blenkernel/intern/cachefile.c
+++ b/source/blender/blenkernel/intern/cachefile.c
@@ -215,7 +215,9 @@ void BKE_cachefile_clean(Scene *scene, CacheFile 
*cache_file)
 
if (cache_file == mcmd->cache_file) {
 #ifdef WITH_ALEMBIC
-   CacheReader_free(mcmd->reader);
+   if (mcmd->reader != NULL) {
+   CacheReader_free(mcmd->reader);
+   }
 #endif
mcmd->reader = NULL;
mcmd->object_path[0] = '\0';
@@ -231,7 +233,9 @@ void BKE_cachefile_clean(Scene *scene, CacheFile 
*cache_file)
 
if (cache_file == data->cache_file) {
 #ifdef WITH_ALEMBIC
-   CacheReader_free(data->reader);
+   if (data->reader != NULL) {
+   CacheReader_free(data->reader);
+   }
 #endif
data->reader = NULL;
data->object_path[0] = '\0';

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


[Bf-blender-cvs] [62f2c44ffb] master: Cleanup: Unused function and and variables in snap code

2017-01-30 Thread Sergey Sharybin
Commit: 62f2c44ffb602a8a78f3db13791ac912cd09be8f
Author: Sergey Sharybin
Date:   Mon Jan 30 09:25:21 2017 +0100
Branches: master
https://developer.blender.org/rB62f2c44ffb602a8a78f3db13791ac912cd09be8f

Cleanup: Unused function and and variables in snap code

Please doublecheck ED_transform_snap_object_project_ray_ex() is really
valid, it's weird to have extra arguments here unused.

===

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 0624288f94..3f8e1176f3 100644
--- a/source/blender/editors/transform/transform_snap_object.c
+++ b/source/blender/editors/transform/transform_snap_object.c
@@ -280,25 +280,6 @@ static void snap_data_set(
copy_v2_v2(snapdata->depth_range, depth_range);
 }
 
-static const float *get_vert_co(const BVHTreeFromMeshType *meshdata, const int 
index)
-{
-   switch (meshdata->type) {
-   case SNAP_MESH:
-   {
-   BVHTreeFromMesh *data = meshdata->userdata;
-   const MVert *vert = data->vert;
-   return vert[index].co;
-   }
-   case SNAP_EDIT_MESH:
-   {
-   BVHTreeFromEditMesh *data = meshdata->userdata;
-   BMVert *eve = BM_vert_at_index(data->em->bm, index);
-   return eve->co;
-   }
-   }
-   return NULL;
-}
-
 static void copy_vert_no(const BVHTreeFromMeshType *meshdata, const int index, 
float r_no[3])
 {
switch (meshdata->type) {
@@ -1269,8 +1250,6 @@ static bool snapDerivedMesh(
}
/* SCE_SNAP_MODE_VERTEX or SCE_SNAP_MODE_EDGE */
else {
-   const ARegion *ar = sctx->v3d_data.ar;
-
float ray_org_local[3];
copy_v3_v3(ray_org_local, snapdata->ray_origin);
mul_m4_v3(imat, ray_org_local);
@@ -1557,8 +1536,6 @@ static bool snapEditMesh(
}
}
else {
-   const ARegion *ar = sctx->v3d_data.ar;
-
float ray_org_local[3];
copy_v3_v3(ray_org_local, snapdata->ray_origin);
mul_m4_v3(imat, ray_org_local);
@@ -1898,7 +1875,7 @@ bool ED_transform_snap_object_project_ray_ex(
 SnapObjectContext *sctx,
 const unsigned short snap_to,
 const struct SnapObjectParams *params,
-const float ray_start[3], const float ray_normal[3],
+const float UNUSED(ray_start[3]), const float UNUSED(ray_normal[3]),
 float *ray_depth,
 float r_loc[3], float r_no[3], int *r_index,
 Object **r_ob, float r_obmat[4][4])

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