[Bf-blender-cvs] [805cabdf177] master: Fix T64483: crash when hovering over outliner after closing render window

2019-07-09 Thread Sybren A. Stüvel
Commit: 805cabdf177af6c71da6239ff3fc5d2524286a18
Author: Sybren A. Stüvel
Date:   Tue Jul 9 11:51:56 2019 +0200
Branches: master
https://developer.blender.org/rB805cabdf177af6c71da6239ff3fc5d2524286a18

Fix T64483: crash when hovering over outliner after closing render window

The `tselem->id` pointer can also be used for non-ID data (according to
this comment in DNA_outliner_types.h:

```
/* XXX We actually also store non-ID data in this pointer for identifying
 * the TreeStoreElem for a TreeElement when rebuilding the tree. Ugly! */
```

As such, I don't mind adding a `NULL`-check in the
`is_object_data_in_editmode()` function. After all, when there is no
object, its data certainly is not in edit mode.

===

M   source/blender/editors/space_outliner/outliner_draw.c

===

diff --git a/source/blender/editors/space_outliner/outliner_draw.c 
b/source/blender/editors/space_outliner/outliner_draw.c
index 7451c8672f4..31783e09aeb 100644
--- a/source/blender/editors/space_outliner/outliner_draw.c
+++ b/source/blender/editors/space_outliner/outliner_draw.c
@@ -116,6 +116,10 @@ static void outliner_tree_dimensions(SpaceOutliner *soops, 
int *r_width, int *r_
  */
 static bool is_object_data_in_editmode(const ID *id, const Object *obact)
 {
+  if (id == NULL) {
+return false;
+  }
+
   const short id_type = GS(id->name);
 
   if (id_type == ID_GD && obact && obact->data == id) {

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


[Bf-blender-cvs] [dd84ff212aa] master: Fix crash when redoing Set Origin operator

2019-07-09 Thread Sybren A. Stüvel
Commit: dd84ff212aa5c9d6c1a03888583e11f64a978a1a
Author: Sybren A. Stüvel
Date:   Tue Jul 9 14:45:08 2019 +0200
Branches: master
https://developer.blender.org/rBdd84ff212aa5c9d6c1a03888583e11f64a978a1a

Fix crash when redoing Set Origin operator

The operator was using a non-evaluated depsgraph to get the evaluated
scene, which caused the crash.

This fixes the crash reported in T66605, but not the problem where
sometimes object origins aren't set.

===

M   source/blender/editors/object/object_transform.c

===

diff --git a/source/blender/editors/object/object_transform.c 
b/source/blender/editors/object/object_transform.c
index bde8bc6080c..025128a04e3 100644
--- a/source/blender/editors/object/object_transform.c
+++ b/source/blender/editors/object/object_transform.c
@@ -465,6 +465,7 @@ static void ignore_parent_tx(Main *bmain, Depsgraph 
*depsgraph, Scene *scene, Ob
 {
   Object workob;
   Object *ob_child;
+
   Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
 
   /* a change was made, adjust the children to compensate */
@@ -974,7 +975,7 @@ static int object_origin_set_exec(bContext *C, wmOperator 
*op)
   Scene *scene = CTX_data_scene(C);
   Object *obact = CTX_data_active_object(C);
   Object *obedit = CTX_data_edit_object(C);
-  Depsgraph *depsgraph = CTX_data_depsgraph(C);
+  Depsgraph *depsgraph = CTX_data_evaluated_depsgraph(C);
   Object *tob;
   float cent[3], cent_neg[3], centn[3];
   const float *cursor = scene->cursor.location;

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


[Bf-blender-cvs] [b77c01924ab] master: Alembic import: fix crash when loading invalid mesh

2019-07-09 Thread Sybren A. Stüvel
Commit: b77c01924ab8ee01ecec8188de644f3b76072b6f
Author: Sybren A. Stüvel
Date:   Tue Jul 9 16:57:30 2019 +0200
Branches: master
https://developer.blender.org/rBb77c01924ab8ee01ecec8188de644f3b76072b6f

Alembic import: fix crash when loading invalid mesh

These were just some missing nullptr checks.

===

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 0ff3360d644..b0129a358ec 100644
--- a/source/blender/alembic/intern/abc_mesh.cc
+++ b/source/blender/alembic/intern/abc_mesh.cc
@@ -1122,7 +1122,9 @@ Mesh *AbcMeshReader::read_mesh(Mesh *existing_mesh,
 sample = m_schema.getValue(sample_sel);
   }
   catch (Alembic::Util::Exception &ex) {
-*err_str = "Error reading mesh sample; more detail on the console";
+if (err_str != nullptr) {
+  *err_str = "Error reading mesh sample; more detail on the console";
+}
 printf("Alembic: error reading mesh sample for '%s/%s' at time %f: %s\n",
m_iobject.getFullName().c_str(),
m_schema.getName().c_str(),
@@ -1417,7 +1419,9 @@ Mesh *AbcSubDReader::read_mesh(Mesh *existing_mesh,
 sample = m_schema.getValue(sample_sel);
   }
   catch (Alembic::Util::Exception &ex) {
-*err_str = "Error reading mesh sample; more detail on the console";
+if (err_str != nullptr) {
+  *err_str = "Error reading mesh sample; more detail on the console";
+}
 printf("Alembic: error reading mesh sample for '%s/%s' at time %f: %s\n",
m_iobject.getFullName().c_str(),
m_schema.getName().c_str(),

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


[Bf-blender-cvs] [817e2796cbe] master: Fix T52814 and T58686: Alembic crashing on fluid sim export

2019-07-09 Thread Sybren A. Stüvel
Commit: 817e2796cbe4c6e115c8a4b6bf535017043be930
Author: Sybren A. Stüvel
Date:   Tue Jul 9 16:22:52 2019 +0200
Branches: master
https://developer.blender.org/rB817e2796cbe4c6e115c8a4b6bf535017043be930

Fix T52814 and T58686: Alembic crashing on fluid sim export

The velocities std::vector was allocated in too narrow a scope, causing
use-after-free errors.

===

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 7f7afe0ce5e..0ff3360d644 100644
--- a/source/blender/alembic/intern/abc_mesh.cc
+++ b/source/blender/alembic/intern/abc_mesh.cc
@@ -409,6 +409,7 @@ void AbcGenericMeshWriter::writeMesh(struct Mesh *mesh)
 {
   std::vector points, normals;
   std::vector poly_verts, loop_counts;
+  std::vector velocities;
 
   bool smooth_normal = false;
 
@@ -458,9 +459,7 @@ void AbcGenericMeshWriter::writeMesh(struct Mesh *mesh)
   }
 
   if (m_is_liquid) {
-std::vector velocities;
 getVelocities(mesh, velocities);
-
 m_mesh_sample.setVelocities(V3fArraySample(velocities));
   }

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


[Bf-blender-cvs] [0829bd7b66a] master: Alembic export: avoid BLI_assert() failure when object is not in depsgraph

2019-07-10 Thread Sybren A. Stüvel
Commit: 0829bd7b66a709ea924cacf90cc1469e6907af5a
Author: Sybren A. Stüvel
Date:   Wed Jul 10 09:56:27 2019 +0200
Branches: master
https://developer.blender.org/rB0829bd7b66a709ea924cacf90cc1469e6907af5a

Alembic export: avoid BLI_assert() failure when object is not in depsgraph

When the object we iterate over is not part of the depsgraph, we cannot
get the evaluated copy to export. This workaround is temporary to avoid
a BLI_assert() failure getting the evaluated mesh of this object.

This will be handled more elegantly in the new AbstractHierarchyIterator
that I'm working on, but that requires a bigger change than we should
allow this close to the 2.80 release candidate.

This fixes a problem described in T58686.

===

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

===

diff --git a/source/blender/alembic/intern/abc_exporter.cc 
b/source/blender/alembic/intern/abc_exporter.cc
index e39b5686c82..56fb5a68402 100644
--- a/source/blender/alembic/intern/abc_exporter.cc
+++ b/source/blender/alembic/intern/abc_exporter.cc
@@ -165,6 +165,15 @@ static bool export_object(const ExportSettings *const 
settings,
 }
   }
 
+  Object *ob_eval = DEG_get_evaluated_object(settings->depsgraph, 
base->object);
+  if ((ob_eval->id.tag & LIB_TAG_COPIED_ON_WRITE) == 0) {
+/* XXX fix after 2.80: the object was not part of the depsgraph, and thus 
we cannot get the
+ * evaluated copy to export. This will be handled more elegantly in the new
+ * AbstractHierarchyIterator that Sybren is working on. This condition is 
temporary, and avoids
+ * a BLI_assert() failure getting the evaluated mesh of this object. */
+return false;
+  }
+
   //  if (settings->renderable_only && (ob->restrictflag & 
OB_RESTRICT_RENDER)) {
   //  return false;
   //  }

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


[Bf-blender-cvs] [12ceea04344] master: Fix crash when clicking in window while Blender starts

2019-07-10 Thread Sybren A. Stüvel
Commit: 12ceea04344ac8267d391b57187ffd0aa336c3cb
Author: Sybren A. Stüvel
Date:   Wed Jul 10 12:32:10 2019 +0200
Branches: master
https://developer.blender.org/rB12ceea04344ac8267d391b57187ffd0aa336c3cb

Fix crash when clicking in window while Blender starts

A mouse click in the window will trigger the `VIEW3D_OT_cursor3d` operator
before the viewport is available. This causes a segfault in
`GPU_viewport_engines_data_validate()`.

Other callers of `WM_draw_region_get_viewport()` already check for `NULL`
being returned and handle it gracefully.

Reviewed By: jbakker, fclem

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

===

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

===

diff --git a/source/blender/editors/space_view3d/view3d_draw.c 
b/source/blender/editors/space_view3d/view3d_draw.c
index 2e34ff7f9c1..eef36dae86a 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -804,7 +804,11 @@ void ED_view3d_draw_depth(Depsgraph *depsgraph, ARegion 
*ar, View3D *v3d, bool a
   GPU_depth_test(true);
 
   GPUViewport *viewport = WM_draw_region_get_viewport(ar, 0);
-  DRW_draw_depth_loop(depsgraph, ar, v3d, viewport);
+  /* When Blender is starting, a click event can trigger a depth test while 
the viewport is not
+   * yet available. */
+  if (viewport != NULL) {
+DRW_draw_depth_loop(depsgraph, ar, v3d, viewport);
+  }
 
   if (rv3d->rflag & RV3D_CLIPPING) {
 ED_view3d_clipping_disable();

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


[Bf-blender-cvs] [b39d7e484c6] master: Fix T66631: Crash when converting objects from Curve to Mesh

2019-07-10 Thread Sybren A. Stüvel
Commit: b39d7e484c6be45fb8ffe0809aecb5726b7d1936
Author: Sybren A. Stüvel
Date:   Wed Jul 10 12:58:39 2019 +0200
Branches: master
https://developer.blender.org/rBb39d7e484c6be45fb8ffe0809aecb5726b7d1936

Fix T66631: Crash when converting objects from Curve to Mesh

When `BKE_mesh_new_from_object()` cannot convert an object to a mesh, it
returns `NULL`. This case was not handled at all in
`BKE_mesh_new_from_object_to_bmain()` or `curvetomesh()`, causing a
segmentation fault.

This commit fixes the segmentation fault, and leaves the curve object as
a curve object.

Reviewed By: mont29, brecht, sergey

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

===

M   source/blender/blenkernel/intern/mesh_convert.c
M   source/blender/editors/object/object_add.c

===

diff --git a/source/blender/blenkernel/intern/mesh_convert.c 
b/source/blender/blenkernel/intern/mesh_convert.c
index dd36da44b92..fec83ebc899 100644
--- a/source/blender/blenkernel/intern/mesh_convert.c
+++ b/source/blender/blenkernel/intern/mesh_convert.c
@@ -1048,6 +1048,7 @@ static Mesh *mesh_new_from_curve_type_object(Object 
*object)
   /* BKE_mesh_from_nurbs changes the type to a mesh, check it worked. If it 
didn't the curve did
* not have any segments or otherwise would have generated an empty mesh. */
   if (temp_object->type != OB_MESH) {
+BKE_id_free(NULL, temp_object->data);
 BKE_id_free(NULL, temp_object);
 return NULL;
   }
@@ -1216,6 +1217,10 @@ Mesh *BKE_mesh_new_from_object_to_bmain(Main *bmain,
 bool preserve_all_data_layers)
 {
   Mesh *mesh = BKE_mesh_new_from_object(depsgraph, object, 
preserve_all_data_layers);
+  if (mesh == NULL) {
+/* Unable to convert the object to a mesh. */
+return NULL;
+  }
 
   /* Make sure mesh only points original datablocks, also increase users of 
materials and other
* possibly referenced data-blocks.
diff --git a/source/blender/editors/object/object_add.c 
b/source/blender/editors/object/object_add.c
index 51b40a968ed..f8cf55933aa 100644
--- a/source/blender/editors/object/object_add.c
+++ b/source/blender/editors/object/object_add.c
@@ -2036,7 +2036,13 @@ static void curvetomesh(Main *bmain, Depsgraph 
*depsgraph, Object *ob)
 {
   Object *object_eval = DEG_get_evaluated_object(depsgraph, ob);
   Curve *curve = ob->data;
+
   Mesh *mesh = BKE_mesh_new_from_object_to_bmain(bmain, depsgraph, 
object_eval, true);
+  if (mesh == NULL) {
+/* Unable to convert the curve to a mesh. */
+return;
+  }
+
   BKE_object_free_modifiers(ob, 0);
   /* Replace curve used by the object itself. */
   ob->data = mesh;
@@ -2125,7 +2131,7 @@ static Base *duplibase_for_convert(
 static int convert_exec(bContext *C, wmOperator *op)
 {
   Main *bmain = CTX_data_main(C);
-  Depsgraph *depsgraph = CTX_data_depsgraph(C);
+  Depsgraph *depsgraph = CTX_data_evaluated_depsgraph(C);
   Scene *scene = CTX_data_scene(C);
   ViewLayer *view_layer = CTX_data_view_layer(C);
   Base *basen = NULL, *basact = NULL;
@@ -2344,8 +2350,9 @@ static int convert_exec(bContext *C, wmOperator *op)
   BKE_curve_curve_dimension_update(cu);
 
   if (target == OB_MESH) {
+/* No assumption should be made that the resulting objects is a mesh, 
as conversion can
+ * fail. */
 curvetomesh(bmain, depsgraph, newob);
-
 /* meshes doesn't use displist */
 BKE_object_free_curve_cache(newob);
   }
@@ -2368,8 +2375,9 @@ static int convert_exec(bContext *C, wmOperator *op)
   newob = ob;
 }
 
+/* No assumption should be made that the resulting objects is a mesh, 
as conversion can
+ * fail. */
 curvetomesh(bmain, depsgraph, newob);
-
 /* meshes doesn't use displist */
 BKE_object_free_curve_cache(newob);
   }

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


[Bf-blender-cvs] [d305148fae6] sybren-usd: HAIR TEST

2019-07-11 Thread Sybren A. Stüvel
Commit: d305148fae683fb01951a217281abe16bb39dbd4
Author: Sybren A. Stüvel
Date:   Thu Jul 11 15:08:40 2019 +0200
Branches: sybren-usd
https://developer.blender.org/rBd305148fae683fb01951a217281abe16bb39dbd4

HAIR TEST

===

M   source/blender/usd/intern/usd_writer_hair.cc

===

diff --git a/source/blender/usd/intern/usd_writer_hair.cc 
b/source/blender/usd/intern/usd_writer_hair.cc
index d8df9294c16..af0d23addcd 100644
--- a/source/blender/usd/intern/usd_writer_hair.cc
+++ b/source/blender/usd/intern/usd_writer_hair.cc
@@ -31,7 +31,9 @@ void USDHairWriter::do_write(HierarchyContext &context)
 
   pxr::VtArray points;
   pxr::VtIntArray curve_point_counts;
+  pxr::VtArray colors;
   curve_point_counts.reserve(psys->totpart);
+  colors.reserve(psys->totpart);
 
   ParticleCacheKey **cache = psys->pathcache;
   ParticleCacheKey *strand;
@@ -40,7 +42,7 @@ void USDHairWriter::do_write(HierarchyContext &context)
 
 int point_count = strand->segments + 1;
 curve_point_counts.push_back(point_count);
-// colors.push_back(pxr::GfVec3f(strand->col));
+colors.push_back(pxr::GfVec3f(strand->col));
 
 for (int point_index = 0; point_index < point_count; ++point_index, 
++strand) {
   points.push_back(pxr::GfVec3f(strand->co));
@@ -49,11 +51,11 @@ void USDHairWriter::do_write(HierarchyContext &context)
 
   curves.CreatePointsAttr().Set(points, timecode);
   curves.CreateCurveVertexCountsAttr().Set(curve_point_counts, timecode);
+  curves.CreateDisplayColorAttr(pxr::VtValue(colors));
 
   if (psys->totpart > 0) {
-pxr::VtArray colors;
-colors.push_back(pxr::GfVec3f(cache[0]->col));
-curves.CreateDisplayColorAttr(pxr::VtValue(colors));
+// pxr::VtArray colors;
+// colors.push_back(pxr::GfVec3f(cache[0]->col));
   }
 }

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


[Bf-blender-cvs] [ac529e10c71] sybren-usd: Merge remote-tracking branch 'origin/master' into sybren-usd

2019-07-11 Thread Sybren A. Stüvel
Commit: ac529e10c71b5798d47a2d08606fa1d69c080de7
Author: Sybren A. Stüvel
Date:   Thu Jul 11 11:52:15 2019 +0200
Branches: sybren-usd
https://developer.blender.org/rBac529e10c71b5798d47a2d08606fa1d69c080de7

Merge remote-tracking branch 'origin/master' into sybren-usd

===



===



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


[Bf-blender-cvs] [449a1366c80] sybren-usd: USD Export: stop when user presses escape

2019-07-11 Thread Sybren A. Stüvel
Commit: 449a1366c808c76c3bb04f587976c0a8088c4ad1
Author: Sybren A. Stüvel
Date:   Thu Jul 11 16:25:53 2019 +0200
Branches: sybren-usd
https://developer.blender.org/rB449a1366c808c76c3bb04f587976c0a8088c4ad1

USD Export: stop when user presses escape

===

M   source/blender/usd/intern/usd_capi.cc

===

diff --git a/source/blender/usd/intern/usd_capi.cc 
b/source/blender/usd/intern/usd_capi.cc
index 757e2283948..a39f7a2f98d 100644
--- a/source/blender/usd/intern/usd_capi.cc
+++ b/source/blender/usd/intern/usd_capi.cc
@@ -122,6 +122,9 @@ static void export_startjob(void *customdata, short *stop, 
short *do_update, flo
   float progress_per_frame = 0.8f / std::max(1, (scene->r.efra - 
scene->r.sfra + 1));
 
   for (float frame = scene->r.sfra; frame <= scene->r.efra; frame++) {
+if (G.is_break)
+  break;
+
 printf("\033[35;1mFRAME\033[0m %f\n", frame);
 // Update the scene for the next frame to render.
 scene->r.cfra = static_cast(frame);

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


[Bf-blender-cvs] [1ef924700c8] sybren-usd: USD: use a struct USDMeshData to group mesh data for USD export

2019-07-11 Thread Sybren A. Stüvel
Commit: 1ef924700c802896a556f687af6c5f4d01289a4b
Author: Sybren A. Stüvel
Date:   Thu Jul 11 17:09:07 2019 +0200
Branches: sybren-usd
https://developer.blender.org/rB1ef924700c802896a556f687af6c5f4d01289a4b

USD: use a struct USDMeshData to group mesh data for USD export

===

M   source/blender/usd/intern/usd_writer_mesh.cc
M   source/blender/usd/intern/usd_writer_mesh.h

===

diff --git a/source/blender/usd/intern/usd_writer_mesh.cc 
b/source/blender/usd/intern/usd_writer_mesh.cc
index 2ca8dd064d8..c6c7f51c7c9 100644
--- a/source/blender/usd/intern/usd_writer_mesh.cc
+++ b/source/blender/usd/intern/usd_writer_mesh.cc
@@ -51,6 +51,13 @@ void USDGenericMeshWriter::free_export_mesh(Mesh *mesh)
   BKE_id_free(NULL, mesh);
 }
 
+struct USDMeshData {
+  pxr::VtArray points;
+  pxr::VtIntArray face_vertex_counts;
+  pxr::VtIntArray face_indices;
+  std::map face_groups;
+};
+
 void USDGenericMeshWriter::write_mesh(HierarchyContext &context, Mesh *mesh)
 {
   pxr::UsdTimeCode timecode = get_export_time_code();
@@ -61,58 +68,50 @@ void USDGenericMeshWriter::write_mesh(HierarchyContext 
&context, Mesh *mesh)
 
   pxr::UsdGeomMesh usd_mesh = pxr::UsdGeomMesh::Define(stage, usd_path_);
 
-  // USD structures for mesh data.
-  pxr::VtArray usd_points;
-  pxr::VtIntArray usd_face_vertex_counts, usd_face_indices;
-  std::map usd_face_groups;
-
-  get_geometry_data(mesh, usd_points, usd_face_vertex_counts, 
usd_face_indices, usd_face_groups);
+  USDMeshData usd_mesh_data;
+  get_geometry_data(mesh, usd_mesh_data);
 
-  usd_mesh.CreatePointsAttr().Set(usd_points, timecode);
-  usd_mesh.CreateFaceVertexCountsAttr().Set(usd_face_vertex_counts, timecode);
-  usd_mesh.CreateFaceVertexIndicesAttr().Set(usd_face_indices, timecode);
+  usd_mesh.CreatePointsAttr().Set(usd_mesh_data.points, timecode);
+  usd_mesh.CreateFaceVertexCountsAttr().Set(usd_mesh_data.face_vertex_counts, 
timecode);
+  usd_mesh.CreateFaceVertexIndicesAttr().Set(usd_mesh_data.face_indices, 
timecode);
 
   // TODO(Sybren): figure out what happens when the face groups change.
   if (frame_has_been_written_) {
 return;
   }
 
-  assign_materials(context, usd_mesh, usd_face_groups);
+  assign_materials(context, usd_mesh, usd_mesh_data.face_groups);
 }
 
-void USDGenericMeshWriter::get_geometry_data(const Mesh *mesh,
- pxr::VtArray 
&usd_points,
- pxr::VtIntArray 
&usd_face_vertex_counts,
- pxr::VtIntArray &usd_face_indices,
- std::map 
&usd_face_groups)
+void USDGenericMeshWriter::get_geometry_data(const Mesh *mesh, struct 
USDMeshData &usd_mesh_data)
 {
   /* Only construct face groups (a.k.a. geometry subsets) when we need them 
for material
* assignments. */
   bool construct_face_groups = mesh->totcol > 1;
 
-  usd_points.reserve(mesh->totvert);
-  usd_face_vertex_counts.reserve(mesh->totpoly);
-  usd_face_indices.reserve(mesh->totloop);
+  usd_mesh_data.points.reserve(mesh->totvert);
+  usd_mesh_data.face_vertex_counts.reserve(mesh->totpoly);
+  usd_mesh_data.face_indices.reserve(mesh->totloop);
 
   // TODO(Sybren): there is probably a more C++-y way to do this, which avoids 
copying the entire
   // mesh to a different structure. I haven't seen the approach below in the 
USD exporters for
   // Maya/Houdini, but it's simple and it works for now.
   const MVert *verts = mesh->mvert;
   for (int i = 0; i < mesh->totvert; ++i) {
-usd_points.push_back(pxr::GfVec3f(verts[i].co));
+usd_mesh_data.points.push_back(pxr::GfVec3f(verts[i].co));
   }
 
   MLoop *mloop = mesh->mloop;
   MPoly *mpoly = mesh->mpoly;
   for (int i = 0; i < mesh->totpoly; ++i, ++mpoly) {
 MLoop *loop = mloop + mpoly->loopstart;
-usd_face_vertex_counts.push_back(mpoly->totloop);
+usd_mesh_data.face_vertex_counts.push_back(mpoly->totloop);
 for (int j = 0; j < mpoly->totloop; ++j, ++loop) {
-  usd_face_indices.push_back(loop->v);
+  usd_mesh_data.face_indices.push_back(loop->v);
 }
 
 if (construct_face_groups) {
-  usd_face_groups[mpoly->mat_nr].push_back(i);
+  usd_mesh_data.face_groups[mpoly->mat_nr].push_back(i);
 }
   }
 }
diff --git a/source/blender/usd/intern/usd_writer_mesh.h 
b/source/blender/usd/intern/usd_writer_mesh.h
index ee3a392ff51..b137b16a843 100644
--- a/source/blender/usd/intern/usd_writer_mesh.h
+++ b/source/blender/usd/intern/usd_writer_mesh.h
@@ -5,6 +5,8 @@
 
 #include 
 
+struct USDMeshData;
+
 /* Writer for USD geometry. Does not assume the object is a mesh object. */
 class USDGenericMeshWriter : public USDAbstractWriter {
  public:
@@ -18,11 +20,7 @@ class USDGenericMeshWrite

[Bf-blender-cvs] [9ca6ac79326] sybren-usd: USD: Add missing curly braces

2019-07-11 Thread Sybren A. Stüvel
Commit: 9ca6ac793267dd581f5efd02832baf382ee2d117
Author: Sybren A. Stüvel
Date:   Thu Jul 11 17:25:36 2019 +0200
Branches: sybren-usd
https://developer.blender.org/rB9ca6ac793267dd581f5efd02832baf382ee2d117

USD: Add missing curly braces

No functional changes.

===

M   source/blender/usd/intern/usd_capi.cc

===

diff --git a/source/blender/usd/intern/usd_capi.cc 
b/source/blender/usd/intern/usd_capi.cc
index a39f7a2f98d..36bc20aae0f 100644
--- a/source/blender/usd/intern/usd_capi.cc
+++ b/source/blender/usd/intern/usd_capi.cc
@@ -122,8 +122,9 @@ static void export_startjob(void *customdata, short *stop, 
short *do_update, flo
   float progress_per_frame = 0.8f / std::max(1, (scene->r.efra - 
scene->r.sfra + 1));
 
   for (float frame = scene->r.sfra; frame <= scene->r.efra; frame++) {
-if (G.is_break)
+if (G.is_break) {
   break;
+}
 
 printf("\033[35;1mFRAME\033[0m %f\n", frame);
 // Update the scene for the next frame to render.

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


[Bf-blender-cvs] [bc583d8e6ca] sybren-usd: Merge remote-tracking branch 'origin/master' into sybren-usd

2019-07-12 Thread Sybren A. Stüvel
Commit: bc583d8e6ca98608e898762f4003a1a69ed6db1e
Author: Sybren A. Stüvel
Date:   Fri Jul 12 10:34:33 2019 +0200
Branches: sybren-usd
https://developer.blender.org/rBbc583d8e6ca98608e898762f4003a1a69ed6db1e

Merge remote-tracking branch 'origin/master' into sybren-usd

===



===



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


[Bf-blender-cvs] [5c4e22c1e85] sybren-usd: USD: Write current Blender version into USD file

2019-07-12 Thread Sybren A. Stüvel
Commit: 5c4e22c1e85b692d68233ead259d7070e19e653a
Author: Sybren A. Stüvel
Date:   Fri Jul 12 12:11:23 2019 +0200
Branches: sybren-usd
https://developer.blender.org/rB5c4e22c1e85b692d68233ead259d7070e19e653a

USD: Write current Blender version into USD file

===

M   source/blender/usd/intern/usd_capi.cc

===

diff --git a/source/blender/usd/intern/usd_capi.cc 
b/source/blender/usd/intern/usd_capi.cc
index 36bc20aae0f..cedc539acbd 100644
--- a/source/blender/usd/intern/usd_capi.cc
+++ b/source/blender/usd/intern/usd_capi.cc
@@ -32,6 +32,7 @@ extern "C" {
 
 #include "DNA_scene_types.h"
 
+#include "BKE_blender_version.h"
 #include "BKE_context.h"
 #include "BKE_global.h"
 #include "BKE_scene.h"
@@ -107,6 +108,7 @@ static void export_startjob(void *customdata, short *stop, 
short *do_update, flo
 usd_stage->SetMetadata(pxr::UsdGeomTokens->upAxis, 
pxr::VtValue(pxr::UsdGeomTokens->z));
 usd_stage->SetMetadata(pxr::UsdGeomTokens->metersPerUnit,
pxr::VtValue(scene->unit.scale_length));
+usd_stage->GetRootLayer()->SetDocumentation(std::string("Blender ") + 
versionstr);
 
 // Set up the stage for animated data.
 if (data->params.export_animation) {

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


[Bf-blender-cvs] [66518ce11b1] sybren-usd: USD: Write edge creases to USD mesh

2019-07-12 Thread Sybren A. Stüvel
Commit: 66518ce11b1889fcde1df829cfab3605c023a447
Author: Sybren A. Stüvel
Date:   Fri Jul 12 12:21:01 2019 +0200
Branches: sybren-usd
https://developer.blender.org/rB66518ce11b1889fcde1df829cfab3605c023a447

USD: Write edge creases to USD mesh

Only the crease is written to USD. The "Sharp" edge flag doesn't seem to
be supported by USD, or at least I couldn't find it in the API docs.

===

M   source/blender/usd/intern/usd_writer_mesh.cc

===

diff --git a/source/blender/usd/intern/usd_writer_mesh.cc 
b/source/blender/usd/intern/usd_writer_mesh.cc
index c6c7f51c7c9..7ce3102d864 100644
--- a/source/blender/usd/intern/usd_writer_mesh.cc
+++ b/source/blender/usd/intern/usd_writer_mesh.cc
@@ -56,6 +56,22 @@ struct USDMeshData {
   pxr::VtIntArray face_vertex_counts;
   pxr::VtIntArray face_indices;
   std::map face_groups;
+
+  /* The length of this array specifies the number of creases on the surface. 
Each element gives
+   * the number of (must be adjacent) vertices in each crease, whose indices 
are linearly laid out
+   * in the 'creaseIndices' attribute. Since each crease must be at least one 
edge long, each
+   * element of this array should be greater than one. */
+  pxr::VtIntArray crease_lengths;
+  /* The indices of all vertices forming creased edges. The size of this array 
must be equal to the
+   * sum of all elements of the 'creaseLengths' attribute. */
+  pxr::VtIntArray crease_vertex_indices;
+  /* The per-crease or per-edge sharpness for all creases 
(Usd.Mesh.SHARPNESS_INFINITE for a
+   * perfectly sharp crease). Since 'creaseLengths' encodes the number of 
vertices in each crease,
+   * the number of elements in this array will be either len(creaseLengths) or 
the sum over all X
+   * of (creaseLengths[X] - 1). Note that while the RI spec allows each crease 
to have either a
+   * single sharpness or a value per-edge, USD will encode either a single 
sharpness per crease on
+   * a mesh, or sharpnesses for all edges making up the creases on a mesh. */
+  pxr::VtFloatArray crease_sharpnesses;
 };
 
 void USDGenericMeshWriter::write_mesh(HierarchyContext &context, Mesh *mesh)
@@ -75,6 +91,12 @@ void USDGenericMeshWriter::write_mesh(HierarchyContext 
&context, Mesh *mesh)
   usd_mesh.CreateFaceVertexCountsAttr().Set(usd_mesh_data.face_vertex_counts, 
timecode);
   usd_mesh.CreateFaceVertexIndicesAttr().Set(usd_mesh_data.face_indices, 
timecode);
 
+  if (!usd_mesh_data.crease_lengths.empty()) {
+usd_mesh.CreateCreaseLengthsAttr().Set(usd_mesh_data.crease_lengths, 
timecode);
+
usd_mesh.CreateCreaseIndicesAttr().Set(usd_mesh_data.crease_vertex_indices, 
timecode);
+
usd_mesh.CreateCreaseSharpnessesAttr().Set(usd_mesh_data.crease_sharpnesses, 
timecode);
+  }
+
   // TODO(Sybren): figure out what happens when the face groups change.
   if (frame_has_been_written_) {
 return;
@@ -83,23 +105,24 @@ void USDGenericMeshWriter::write_mesh(HierarchyContext 
&context, Mesh *mesh)
   assign_materials(context, usd_mesh, usd_mesh_data.face_groups);
 }
 
-void USDGenericMeshWriter::get_geometry_data(const Mesh *mesh, struct 
USDMeshData &usd_mesh_data)
+static void get_vertices(const Mesh *mesh, struct USDMeshData &usd_mesh_data)
 {
-  /* Only construct face groups (a.k.a. geometry subsets) when we need them 
for material
-   * assignments. */
-  bool construct_face_groups = mesh->totcol > 1;
-
   usd_mesh_data.points.reserve(mesh->totvert);
-  usd_mesh_data.face_vertex_counts.reserve(mesh->totpoly);
-  usd_mesh_data.face_indices.reserve(mesh->totloop);
 
-  // TODO(Sybren): there is probably a more C++-y way to do this, which avoids 
copying the entire
-  // mesh to a different structure. I haven't seen the approach below in the 
USD exporters for
-  // Maya/Houdini, but it's simple and it works for now.
   const MVert *verts = mesh->mvert;
   for (int i = 0; i < mesh->totvert; ++i) {
 usd_mesh_data.points.push_back(pxr::GfVec3f(verts[i].co));
   }
+}
+
+static void get_loops_polys(const Mesh *mesh, struct USDMeshData 
&usd_mesh_data)
+{
+  /* Only construct face groups (a.k.a. geometry subsets) when we need them 
for material
+   * assignments. */
+  bool construct_face_groups = mesh->totcol > 1;
+
+  usd_mesh_data.face_vertex_counts.reserve(mesh->totpoly);
+  usd_mesh_data.face_indices.reserve(mesh->totloop);
 
   MLoop *mloop = mesh->mloop;
   MPoly *mpoly = mesh->mpoly;
@@ -116,6 +139,38 @@ void USDGenericMeshWriter::get_geometry_data(const Mesh 
*mesh, struct USDMeshDat
   }
 }
 
+static void get_creases(const Mesh *mesh, struct USDMeshData &usd_mesh_data)
+{
+  const float factor = 1.0f / 255.0f;
+
+  MEdge *edge = mesh->medge;
+  float sharpness;
+  for (int edge_idx = 0, totedge = mesh->totedge; edge_idx < tot

[Bf-blender-cvs] [4e5ef649944] sybren-usd: USD: Export UV maps of meshes

2019-07-12 Thread Sybren A. Stüvel
Commit: 4e5ef6499440806d586e4aa5e21a2e3fb11b6a05
Author: Sybren A. Stüvel
Date:   Fri Jul 12 14:15:08 2019 +0200
Branches: sybren-usd
https://developer.blender.org/rB4e5ef6499440806d586e4aa5e21a2e3fb11b6a05

USD: Export UV maps of meshes

Each UV map is stored on the mesh in a separate primvar. Materials can
refer to these UV maps, but this is not yet exported by Blender.

===

M   source/blender/usd/intern/usd_writer_mesh.cc
M   source/blender/usd/intern/usd_writer_mesh.h

===

diff --git a/source/blender/usd/intern/usd_writer_mesh.cc 
b/source/blender/usd/intern/usd_writer_mesh.cc
index 14b5761ead9..d8807157f53 100644
--- a/source/blender/usd/intern/usd_writer_mesh.cc
+++ b/source/blender/usd/intern/usd_writer_mesh.cc
@@ -74,6 +74,31 @@ struct USDMeshData {
   pxr::VtFloatArray crease_sharpnesses;
 };
 
+void USDGenericMeshWriter::write_uv_maps(const Mesh *mesh, pxr::UsdGeomMesh 
usd_mesh)
+{
+  pxr::UsdTimeCode timecode = get_export_time_code();
+
+  const CustomData *ldata = &mesh->ldata;
+  for (int layer_idx = 0; layer_idx < ldata->totlayer; layer_idx++) {
+const CustomDataLayer *layer = &ldata->layers[layer_idx];
+if (layer->type != CD_MLOOPUV) {
+  continue;
+}
+
+// UV coordinates are stored in a Primvar on the Mesh, and can be 
referenced from materials.
+pxr::TfToken primvar_name(pxr::TfMakeValidIdentifier(std::string("uv_") + 
layer->name));
+pxr::UsdGeomPrimvar uv_coords_primvar = usd_mesh.CreatePrimvar(
+primvar_name, pxr::SdfValueTypeNames->TexCoord2fArray, 
pxr::UsdGeomTokens->faceVarying);
+
+MLoopUV *mloopuv = static_cast(layer->data);
+pxr::VtArray uv_coords;
+for (int loop_idx = 0; loop_idx < mesh->totloop; loop_idx++) {
+  uv_coords.push_back(pxr::GfVec2f(mloopuv[loop_idx].uv));
+}
+uv_coords_primvar.Set(uv_coords, timecode);
+  }
+}
+
 void USDGenericMeshWriter::write_mesh(HierarchyContext &context, Mesh *mesh)
 {
   pxr::UsdTimeCode timecode = get_export_time_code();
@@ -97,6 +122,8 @@ void USDGenericMeshWriter::write_mesh(HierarchyContext 
&context, Mesh *mesh)
 
usd_mesh.CreateCreaseSharpnessesAttr().Set(usd_mesh_data.crease_sharpnesses, 
timecode);
   }
 
+  write_uv_maps(mesh, usd_mesh);
+
   // TODO(Sybren): figure out what happens when the face groups change.
   if (frame_has_been_written_) {
 return;
diff --git a/source/blender/usd/intern/usd_writer_mesh.h 
b/source/blender/usd/intern/usd_writer_mesh.h
index b137b16a843..3fef22dd2b5 100644
--- a/source/blender/usd/intern/usd_writer_mesh.h
+++ b/source/blender/usd/intern/usd_writer_mesh.h
@@ -24,6 +24,7 @@ class USDGenericMeshWriter : public USDAbstractWriter {
   void assign_materials(const HierarchyContext &context,
 pxr::UsdGeomMesh usd_mesh,
 const std::map 
&usd_face_groups);
+  void write_uv_maps(const Mesh *mesh, pxr::UsdGeomMesh usd_mesh);
 };
 
 class USDMeshWriter : public USDGenericMeshWriter {

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


[Bf-blender-cvs] [176f8947cd5] sybren-usd: USD: Write mesh single/doublesidedness

2019-07-12 Thread Sybren A. Stüvel
Commit: 176f8947cd50f6a472dce67451b201bf74ae6dc1
Author: Sybren A. Stüvel
Date:   Fri Jul 12 12:22:15 2019 +0200
Branches: sybren-usd
https://developer.blender.org/rB176f8947cd50f6a472dce67451b201bf74ae6dc1

USD: Write mesh single/doublesidedness

USD seems to support neither per-material nor per-face-group
double-sidedness, so we just use the flag from the first non-empty
material slot. If there is no material we default to double-sidedness.

===

M   source/blender/usd/intern/usd_writer_mesh.cc

===

diff --git a/source/blender/usd/intern/usd_writer_mesh.cc 
b/source/blender/usd/intern/usd_writer_mesh.cc
index 7ce3102d864..14b5761ead9 100644
--- a/source/blender/usd/intern/usd_writer_mesh.cc
+++ b/source/blender/usd/intern/usd_writer_mesh.cc
@@ -192,10 +192,21 @@ void USDGenericMeshWriter::assign_materials(
 
 pxr::UsdShadeMaterial usd_material = ensure_usd_material(material);
 usd_material.Bind(usd_mesh.GetPrim());
+
+/* USD seems to support neither per-material nor per-face-group 
double-sidedness, so we just
+ * use the flag from the first non-empty material slot. */
+usd_mesh.CreateDoubleSidedAttr(
+pxr::VtValue((material->blend_flag & MA_BL_CULL_BACKFACE) == 0));
+
 mesh_material_bound = true;
 break;
   }
 
+  if (!mesh_material_bound) {
+/* Blender defaults to double-sided, but USD to single-sided. */
+usd_mesh.CreateDoubleSidedAttr(pxr::VtValue(true));
+  }
+
   if (!mesh_material_bound || usd_face_groups.size() < 2) {
 /* Either all material slots were empty or there is only one material in 
use. As geometry
  * subsets are only written when actually used to assign a material, and 
the mesh already has

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


[Bf-blender-cvs] [325501247d8] master: Fix AttributeError in mesh properties panel when mesh is pinned

2019-07-12 Thread Sybren A. Stüvel
Commit: 325501247d88647fd2457f9fc02209aadc6a52f1
Author: Sybren A. Stüvel
Date:   Fri Jul 12 14:18:17 2019 +0200
Branches: master
https://developer.blender.org/rB325501247d88647fd2457f9fc02209aadc6a52f1

Fix AttributeError in mesh properties panel when mesh is pinned

When a mesh datablock is pinned in the properties panel,
`context.object` is `None`. This in turn causes `obj.mode` to raise an
`AttributeError` exception as `None.mode` doesn't exist.

Since there is no (fast/simple) way to check whether the owning object
is in edit mode or not, the properties will be disabled. Not ideal, but
better than spewing an exception on every panel draw.

Reviewed By: campbellbarton, brecht

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

===

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

===

diff --git a/release/scripts/startup/bl_ui/properties_data_mesh.py 
b/release/scripts/startup/bl_ui/properties_data_mesh.py
index e4fd09bb5ff..63e4d44eada 100644
--- a/release/scripts/startup/bl_ui/properties_data_mesh.py
+++ b/release/scripts/startup/bl_ui/properties_data_mesh.py
@@ -483,7 +483,7 @@ class DATA_PT_customdata(MeshButtonsPanel, Panel):
 
 col = layout.column()
 
-col.enabled = (obj.mode != 'EDIT')
+col.enabled = obj is not None and obj.mode != 'EDIT'
 col.prop(me, "use_customdata_vertex_bevel")
 col.prop(me, "use_customdata_edge_bevel")
 col.prop(me, "use_customdata_edge_crease")

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


[Bf-blender-cvs] [b3a659dd167] sybren-usd: USD: Avoid writing invisible particle emitter meshes

2019-07-12 Thread Sybren A. Stüvel
Commit: b3a659dd167daee904b2b4f28bc78add49392988
Author: Sybren A. Stüvel
Date:   Fri Jul 12 15:20:02 2019 +0200
Branches: sybren-usd
https://developer.blender.org/rBb3a659dd167daee904b2b4f28bc78add49392988

USD: Avoid writing invisible particle emitter meshes

===

M   source/blender/usd/intern/usd_writer_mesh.cc
M   source/blender/usd/intern/usd_writer_mesh.h

===

diff --git a/source/blender/usd/intern/usd_writer_mesh.cc 
b/source/blender/usd/intern/usd_writer_mesh.cc
index d8807157f53..18992beab1b 100644
--- a/source/blender/usd/intern/usd_writer_mesh.cc
+++ b/source/blender/usd/intern/usd_writer_mesh.cc
@@ -10,14 +10,29 @@ extern "C" {
 #include "BKE_library.h"
 #include "BKE_material.h"
 
+#include "DEG_depsgraph.h"
+
 #include "DNA_mesh_types.h"
 #include "DNA_meshdata_types.h"
+#include "DNA_particle_types.h"
 }
 
 USDGenericMeshWriter::USDGenericMeshWriter(const USDExporterContext &ctx) : 
USDAbstractWriter(ctx)
 {
 }
 
+bool USDGenericMeshWriter::is_supported(const Object *object) const
+{
+  // Reject meshes that have a particle system that should have its emitter 
hidden.
+  if (object->particlesystem.first != NULL) {
+char check_flag = export_params.evaluation_mode == DAG_EVAL_RENDER ? 
OB_DUPLI_FLAG_RENDER :
+ 
OB_DUPLI_FLAG_VIEWPORT;
+return object->duplicator_visibility_flag & check_flag;
+  }
+
+  return true;
+}
+
 void USDGenericMeshWriter::do_write(HierarchyContext &context)
 {
   Object *object_eval = context.object;
diff --git a/source/blender/usd/intern/usd_writer_mesh.h 
b/source/blender/usd/intern/usd_writer_mesh.h
index 3fef22dd2b5..aea49fe9523 100644
--- a/source/blender/usd/intern/usd_writer_mesh.h
+++ b/source/blender/usd/intern/usd_writer_mesh.h
@@ -13,6 +13,7 @@ class USDGenericMeshWriter : public USDAbstractWriter {
   USDGenericMeshWriter(const USDExporterContext &ctx);
 
  protected:
+  virtual bool is_supported(const Object *object) const override;
   virtual void do_write(HierarchyContext &context) override;
 
   virtual Mesh *get_export_mesh(Object *object_eval, bool &r_needsfree) = 0;

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


[Bf-blender-cvs] [53e20493642] sybren-usd: USD: Offer choice for viewport or render settings

2019-07-12 Thread Sybren A. Stüvel
Commit: 53e2049364229c00eb926e5c65e35b86acb04a26
Author: Sybren A. Stüvel
Date:   Fri Jul 12 15:19:44 2019 +0200
Branches: sybren-usd
https://developer.blender.org/rB53e2049364229c00eb926e5c65e35b86acb04a26

USD: Offer choice for viewport or render settings

The exporter operator now takes a parameter to choose the depsgraph
evaluation mode (Viewport/Render). This makes it easier to switch between
exporting particle hair (Render) or mesh hair (Viewport).

===

M   source/blender/editors/io/io_usd.c
M   source/blender/usd/intern/abstract_hierarchy_iterator.cc
M   source/blender/usd/intern/usd_capi.cc
M   source/blender/usd/usd.h

===

diff --git a/source/blender/editors/io/io_usd.c 
b/source/blender/editors/io/io_usd.c
index 62e3bcd0955..6041ffcbf21 100644
--- a/source/blender/editors/io/io_usd.c
+++ b/source/blender/editors/io/io_usd.c
@@ -37,9 +37,25 @@
 #  include "WM_api.h"
 #  include "WM_types.h"
 
+#  include "DEG_depsgraph.h"
+
 #  include "io_usd.h"
 #  include "usd.h"
 
+const EnumPropertyItem rna_enum_usd_export_evaluation_mode_items[] = {
+{DAG_EVAL_RENDER,
+ "RENDER",
+ 0,
+ "Render",
+ "Use Render settings for object visibility, modifier settings, etc"},
+{DAG_EVAL_VIEWPORT,
+ "VIEWPORT",
+ 0,
+ "Viewport",
+ "Use Viewport settings for object visibility, modifier settings, etc"},
+{0, NULL, 0, NULL, NULL},
+};
+
 static int wm_usd_export_invoke(bContext *C, wmOperator *op, const wmEvent 
*event)
 {
   if (!RNA_struct_property_is_set(op->ptr, "as_background_job")) {
@@ -86,12 +102,14 @@ static int wm_usd_export_exec(bContext *C, wmOperator *op)
   const bool visible_objects_only = RNA_boolean_get(op->ptr, 
"visible_objects_only");
   const bool export_animation = RNA_boolean_get(op->ptr, "export_animation");
   const bool export_hair = RNA_boolean_get(op->ptr, "export_hair");
+  const bool evaluation_mode = RNA_boolean_get(op->ptr, "evaluation_mode");
 
   struct USDExportParams params = {
   export_animation,
   export_hair,
   selected_objects_only,
   visible_objects_only,
+  evaluation_mode,
   };
 
   bool ok = USD_export(scene, C, filename, ¶ms, as_background_job);
@@ -121,14 +139,14 @@ void WM_OT_usd_export(struct wmOperatorType *ot)
 
   RNA_def_boolean(ot->srna,
   "visible_objects_only",
-  false,
+  true,
   "Only Export Visible Objects",
   "Only visible objects are exported. Invisible parents of 
visible objects are "
   "exported as empty transform");
 
   RNA_def_boolean(ot->srna,
   "export_animation",
-  true,
+  false,
   "Export Animation",
   "When true, the render frame range is exported. When false, 
only the current "
   "frame is exported");
@@ -136,6 +154,13 @@ void WM_OT_usd_export(struct wmOperatorType *ot)
   RNA_def_boolean(
   ot->srna, "export_hair", false, "Export Hair", "When true, hair is 
exported as USD curves");
 
+  RNA_def_enum(ot->srna,
+   "evaluation_mode",
+   rna_enum_usd_export_evaluation_mode_items,
+   DAG_EVAL_RENDER,
+   "Evaluation Mode",
+   "Determines visibility of objects and modifier settings");
+
   RNA_def_boolean(
   ot->srna,
   "as_background_job",
diff --git a/source/blender/usd/intern/abstract_hierarchy_iterator.cc 
b/source/blender/usd/intern/abstract_hierarchy_iterator.cc
index fc40178365f..b8cbe8b64f7 100644
--- a/source/blender/usd/intern/abstract_hierarchy_iterator.cc
+++ b/source/blender/usd/intern/abstract_hierarchy_iterator.cc
@@ -314,6 +314,9 @@ void AbstractHierarchyIterator::make_writers(const 
HierarchyContext &parent_cont
 }
 
 BLI_assert(DEG_is_evaluated_object(context.object));
+/* XXX This can lead to too many XForms being written. For example, a 
camera writer can refuse
+ * to write an orthographic camera. By the time that this is known, the 
XForm has already been
+ * written. */
 xform_writer->write(context);
 
 if (!context.weak_export) {
diff --git a/source/blender/usd/intern/usd_capi.cc 
b/source/blender/usd/intern/usd_capi.cc
index cedc539acbd..d1b84c453bc 100644
--- a/source/blender/usd/intern/usd_capi.cc
+++ b/source/blender/usd/intern/usd_capi.cc
@@ -196,7 +196,7 @@ bool USD_export(Scene *scene,
   BLI_strncpy(job->filename, filepath, 1024);
 
   ViewLayer *view_layer = CT

[Bf-blender-cvs] [46dbb8b92df] sybren-usd: Merge remote-tracking branch 'origin/master' into sybren-usd

2019-07-12 Thread Sybren A. Stüvel
Commit: 46dbb8b92dfd17efc8d13e3cc4ac5b9aeb81fdb7
Author: Sybren A. Stüvel
Date:   Fri Jul 12 14:24:28 2019 +0200
Branches: sybren-usd
https://developer.blender.org/rB46dbb8b92dfd17efc8d13e3cc4ac5b9aeb81fdb7

Merge remote-tracking branch 'origin/master' into sybren-usd

===



===



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


[Bf-blender-cvs] [4217d6fd542] sybren-usd: USD: added USD export to the File > Export menu

2019-07-16 Thread Sybren A. Stüvel
Commit: 4217d6fd5421834b95b574d4bbba203a365ae4f7
Author: Sybren A. Stüvel
Date:   Fri Jul 12 15:59:35 2019 +0200
Branches: sybren-usd
https://developer.blender.org/rB4217d6fd5421834b95b574d4bbba203a365ae4f7

USD: added USD export to the File > Export menu

This also required exposing the build option `bpy.app.build_options.usd`.

===

M   release/scripts/startup/bl_ui/space_topbar.py
M   source/blender/python/intern/CMakeLists.txt
M   source/blender/python/intern/bpy_app_build_options.c

===

diff --git a/release/scripts/startup/bl_ui/space_topbar.py 
b/release/scripts/startup/bl_ui/space_topbar.py
index 382e421eecd..8195d580c46 100644
--- a/release/scripts/startup/bl_ui/space_topbar.py
+++ b/release/scripts/startup/bl_ui/space_topbar.py
@@ -405,6 +405,8 @@ class TOPBAR_MT_file_export(Menu):
 self.layout.operator("wm.collada_export", text="Collada (Default) 
(.dae)")
 if bpy.app.build_options.alembic:
 self.layout.operator("wm.alembic_export", text="Alembic (.abc)")
+if bpy.app.build_options.usd:
+self.layout.operator("wm.usd_export", text="Universal Scene 
Description (.usdc, .usda)")
 
 
 class TOPBAR_MT_file_external_data(Menu):
diff --git a/source/blender/python/intern/CMakeLists.txt 
b/source/blender/python/intern/CMakeLists.txt
index fc945562c98..4a80d7569a8 100644
--- a/source/blender/python/intern/CMakeLists.txt
+++ b/source/blender/python/intern/CMakeLists.txt
@@ -295,6 +295,10 @@ if(WITH_ALEMBIC)
   )
 endif()
 
+if(WITH_USD)
+  add_definitions(-DWITH_USD)
+endif()
+
 if(WITH_OPENIMAGEIO)
   add_definitions(-DWITH_OPENIMAGEIO)
   list(APPEND INC
diff --git a/source/blender/python/intern/bpy_app_build_options.c 
b/source/blender/python/intern/bpy_app_build_options.c
index a841e974e85..2e87b215e9d 100644
--- a/source/blender/python/intern/bpy_app_build_options.c
+++ b/source/blender/python/intern/bpy_app_build_options.c
@@ -59,6 +59,7 @@ static PyStructSequence_Field app_builtopts_info_fields[] = {
 {(char *)"openmp", NULL},
 {(char *)"openvdb", NULL},
 {(char *)"alembic", NULL},
+{(char *)"usd", NULL},
 {NULL},
 };
 
@@ -268,6 +269,12 @@ static PyObject *make_builtopts_info(void)
   SetObjIncref(Py_False);
 #endif
 
+#ifdef WITH_USD
+  SetObjIncref(Py_True);
+#else
+  SetObjIncref(Py_False);
+#endif
+
 #undef SetObjIncref
 
   return builtopts_info;

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


[Bf-blender-cvs] [6ea1176d1f5] sybren-usd: USD: Make USD_PATH configurable via a CMake variable

2019-07-16 Thread Sybren A. Stüvel
Commit: 6ea1176d1f5a36f5a6d87a5a6d1b1450dfdbd359
Author: Sybren A. Stüvel
Date:   Tue Jul 16 10:49:13 2019 +0200
Branches: sybren-usd
https://developer.blender.org/rB6ea1176d1f5a36f5a6d87a5a6d1b1450dfdbd359

USD: Make USD_PATH configurable via a CMake variable

The default is still `USD_PATH=/opt/usd`, and using USD still requires you
to manually install USD without Python bindings.

===

M   CMakeLists.txt
M   source/blender/usd/CMakeLists.txt

===

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 31ba7874fdb..464ddf1cc02 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -325,6 +325,7 @@ option(WITH_ALEMBIC_HDF5"Enable Legacy Alembic 
Support (not officially s
 
 # Universal Scene Description support
 option(WITH_USD "Enable Universal Scene Description (USD) 
Support" OFF)
+set(USD_PATH "/opt/usd" CACHE STRING "Universal Scene Description (USD) 
installation path")
 
 # 3D format support
 # Disable opencollada when we don't have precompiled libs
diff --git a/source/blender/usd/CMakeLists.txt 
b/source/blender/usd/CMakeLists.txt
index 3c76c95e31c..95046a48a74 100644
--- a/source/blender/usd/CMakeLists.txt
+++ b/source/blender/usd/CMakeLists.txt
@@ -18,7 +18,7 @@
 # All rights reserved.
 # * END GPL LICENSE BLOCK *
 
-include(/opt/usd/pxrConfig.cmake)
+include(${USD_PATH}/pxrConfig.cmake)
 
 # This suppresses the warning "This file includes at least one deprecated or 
antiquated header which
 # may be removed without further notice at a future date", which is caused by 
the USD library

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


[Bf-blender-cvs] [e6e69a28ab2] master: Fixed crash when adding/removing custom normals from pinned mesh

2019-07-16 Thread Sybren A. Stüvel
Commit: e6e69a28ab28631b2b1b99f55fb618459e7671ad
Author: Sybren A. Stüvel
Date:   Tue Jul 16 15:06:25 2019 +0200
Branches: master
https://developer.blender.org/rBe6e69a28ab28631b2b1b99f55fb618459e7671ad

Fixed crash when adding/removing custom normals from pinned mesh

When a mesh is pinned in the properties panel, Blender crashes when you
click the "Add Custom Split Normals Data".

The code calls `ob = ED_object_context(C)` which returns NULL when the
mesh is pinned in the properties panel, causing a segfault when trying
to get the mesh via `ob->data`.

A new function `ED_mesh_context(C)` avoids this by first checking
whether a mesh was pinned in the context. If not, it checks the pinned
object's data. If that's not there, or it's not a mesh, it returns the
active object's mesh. Finally it returns NULL if there is no active
object, or if the active object is not a mesh object.

Reviewed By: brecht, mont29

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

===

M   source/blender/editors/include/ED_mesh.h
M   source/blender/editors/include/ED_screen.h
M   source/blender/editors/mesh/mesh_data.c
M   source/blender/editors/screen/screen_ops.c

===

diff --git a/source/blender/editors/include/ED_mesh.h 
b/source/blender/editors/include/ED_mesh.h
index 5d8038d0b28..d2613facd83 100644
--- a/source/blender/editors/include/ED_mesh.h
+++ b/source/blender/editors/include/ED_mesh.h
@@ -393,6 +393,9 @@ bool ED_mesh_color_remove_named(struct Mesh *me, const char 
*name);
 void ED_mesh_report_mirror(struct wmOperator *op, int totmirr, int totfail);
 void ED_mesh_report_mirror_ex(struct wmOperator *op, int totmirr, int totfail, 
char selectmode);
 
+/* Returns the pinned mesh, the mesh from the pinned object, or the mesh from 
the active object. */
+struct Mesh *ED_mesh_context(struct bContext *C);
+
 /* mesh backup */
 typedef struct BMBackup {
   struct BMesh *bmcopy;
diff --git a/source/blender/editors/include/ED_screen.h 
b/source/blender/editors/include/ED_screen.h
index fc43144417a..e67a3b003fc 100644
--- a/source/blender/editors/include/ED_screen.h
+++ b/source/blender/editors/include/ED_screen.h
@@ -337,6 +337,7 @@ bool ED_operator_object_active(struct bContext *C);
 bool ED_operator_object_active_editable(struct bContext *C);
 bool ED_operator_object_active_editable_mesh(struct bContext *C);
 bool ED_operator_object_active_editable_font(struct bContext *C);
+bool ED_operator_editable_mesh(struct bContext *C);
 bool ED_operator_editmesh(struct bContext *C);
 bool ED_operator_editmesh_view3d(struct bContext *C);
 bool ED_operator_editmesh_region_view3d(struct bContext *C);
diff --git a/source/blender/editors/mesh/mesh_data.c 
b/source/blender/editors/mesh/mesh_data.c
index a6934326d68..ee8de9d8ea9 100644
--- a/source/blender/editors/mesh/mesh_data.c
+++ b/source/blender/editors/mesh/mesh_data.c
@@ -41,6 +41,7 @@
 
 #include "DEG_depsgraph.h"
 
+#include "RNA_access.h"
 #include "RNA_define.h"
 
 #include "WM_api.h"
@@ -629,8 +630,7 @@ void MESH_OT_vertex_color_remove(wmOperatorType *ot)
 
 static int mesh_customdata_clear_exec__internal(bContext *C, char htype, int 
type)
 {
-  Object *obedit = ED_object_context(C);
-  Mesh *me = obedit->data;
+  Mesh *me = ED_mesh_context(C);
 
   int tot;
   CustomData *data = mesh_customdata_get_type(me, htype, &tot);
@@ -788,8 +788,7 @@ void MESH_OT_customdata_skin_clear(wmOperatorType *ot)
 /* Clear custom loop normals */
 static int mesh_customdata_custom_splitnormals_add_exec(bContext *C, 
wmOperator *UNUSED(op))
 {
-  Object *ob = ED_object_context(C);
-  Mesh *me = ob->data;
+  Mesh *me = ED_mesh_context(C);
 
   if (!BKE_mesh_has_custom_loop_normals(me)) {
 CustomData *data = GET_CD_DATA(me, ldata);
@@ -853,7 +852,7 @@ void 
MESH_OT_customdata_custom_splitnormals_add(wmOperatorType *ot)
 
   /* api callbacks */
   ot->exec = mesh_customdata_custom_splitnormals_add_exec;
-  ot->poll = ED_operator_object_active_editable_mesh;
+  ot->poll = ED_operator_editable_mesh;
 
   /* flags */
   ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -861,8 +860,7 @@ void 
MESH_OT_customdata_custom_splitnormals_add(wmOperatorType *ot)
 
 static int mesh_customdata_custom_splitnormals_clear_exec(bContext *C, 
wmOperator *UNUSED(op))
 {
-  Object *ob = ED_object_context(C);
-  Mesh *me = ob->data;
+  Mesh *me = ED_mesh_context(C);
 
   if (BKE_mesh_has_custom_loop_normals(me)) {
 return mesh_customdata_clear_exec__internal(C, BM_LOOP, 
CD_CUSTOMLOOPNORMAL);
@@ -879,7 +877,7 @@ void 
MESH_OT_customdata_custom_splitnormals_clear(wmOperatorType *ot)
 
   /* api callbacks */
   ot->exec = mesh_customdata_custom_splitnormals_clear_exec;
-  ot->poll = ED_operator_object_active_editable_mesh;
+  ot->poll = ED_operat

[Bf-blender-cvs] [26ec89d8644] sybren-usd: Merge remote-tracking branch 'origin/master' into sybren-usd

2019-07-16 Thread Sybren A. Stüvel
Commit: 26ec89d8644759fd3a4b318ed3877b35c0b2bf07
Author: Sybren A. Stüvel
Date:   Tue Jul 16 13:28:43 2019 +0200
Branches: sybren-usd
https://developer.blender.org/rB26ec89d8644759fd3a4b318ed3877b35c0b2bf07

Merge remote-tracking branch 'origin/master' into sybren-usd

===



===



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


[Bf-blender-cvs] [275d2374b16] sybren-usd: USD: Fixed bug getting evaluation mode property

2019-07-16 Thread Sybren A. Stüvel
Commit: 275d2374b16923b8f23c7ade8c43656f381ffe3e
Author: Sybren A. Stüvel
Date:   Tue Jul 16 12:13:37 2019 +0200
Branches: sybren-usd
https://developer.blender.org/rB275d2374b16923b8f23c7ade8c43656f381ffe3e

USD: Fixed bug getting evaluation mode property

===

M   source/blender/editors/io/io_usd.c

===

diff --git a/source/blender/editors/io/io_usd.c 
b/source/blender/editors/io/io_usd.c
index 6041ffcbf21..529a330ca14 100644
--- a/source/blender/editors/io/io_usd.c
+++ b/source/blender/editors/io/io_usd.c
@@ -102,7 +102,7 @@ static int wm_usd_export_exec(bContext *C, wmOperator *op)
   const bool visible_objects_only = RNA_boolean_get(op->ptr, 
"visible_objects_only");
   const bool export_animation = RNA_boolean_get(op->ptr, "export_animation");
   const bool export_hair = RNA_boolean_get(op->ptr, "export_hair");
-  const bool evaluation_mode = RNA_boolean_get(op->ptr, "evaluation_mode");
+  const bool evaluation_mode = RNA_enum_get(op->ptr, "evaluation_mode");
 
   struct USDExportParams params = {
   export_animation,

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


[Bf-blender-cvs] [c5197cdf4bc] sybren-usd: USD: Fixed issue with mesh particle export

2019-07-16 Thread Sybren A. Stüvel
Commit: c5197cdf4bcc1ca34a9b0e745732a42fee1b4442
Author: Sybren A. Stüvel
Date:   Tue Jul 16 12:44:47 2019 +0200
Branches: sybren-usd
https://developer.blender.org/rBc5197cdf4bcc1ca34a9b0e745732a42fee1b4442

USD: Fixed issue with mesh particle export

When mesh particles were exported, the object name was still used for each
instance of that object. As such, only one instance was written to USD.
This is now fixed by suffixing the object name with the particle's
persistent ID, giving each particle XForm a unique name.

Particles are still only written when they are alive, which means that they
are always visible (there is currently no code that deals with marking them
as invisible outside their lifespan).

===

M   source/blender/usd/intern/abstract_hierarchy_iterator.cc
M   source/blender/usd/intern/abstract_hierarchy_iterator.h
M   source/blender/usd/intern/usd_hierarchy_iterator.cc
M   source/blender/usd/intern/usd_hierarchy_iterator.h
M   source/blender/usd/intern/usd_writer_transform.cc

===

diff --git a/source/blender/usd/intern/abstract_hierarchy_iterator.cc 
b/source/blender/usd/intern/abstract_hierarchy_iterator.cc
index b8cbe8b64f7..2bd368de221 100644
--- a/source/blender/usd/intern/abstract_hierarchy_iterator.cc
+++ b/source/blender/usd/intern/abstract_hierarchy_iterator.cc
@@ -1,5 +1,8 @@
 #include "abstract_hierarchy_iterator.h"
 
+#include 
+#include 
+#include 
 #include 
 
 extern "C" {
@@ -23,6 +26,19 @@ const HierarchyContext &HierarchyContext::root()
   return root_hierarchy_context;
 }
 
+bool HierarchyContext::operator<(const HierarchyContext &other) const
+{
+  if (object != other.object) {
+return object < other.object;
+  }
+  if (duplicator != NULL && duplicator == other.duplicator) {
+// Only resort to string comparisons when both objects are created by the 
same duplicator.
+return export_name < other.export_name;
+  }
+
+  return export_parent < other.export_parent;
+}
+
 AbstractHierarchyIterator::AbstractHierarchyIterator(Depsgraph *depsgraph)
 : depsgraph(depsgraph), writers()
 {
@@ -180,6 +196,7 @@ void AbstractHierarchyIterator::visit_object(Object *object,
 {
   HierarchyContext context;
   context.object = object;
+  context.export_name = get_object_name(object);
   context.export_parent = export_parent;
   context.duplicator = nullptr;
   context.weak_export = weak_export;
@@ -192,7 +209,7 @@ void AbstractHierarchyIterator::visit_object(Object *object,
 
   // std::string export_parent_name = export_parent ? 
get_object_name(export_parent) : "/";
   // printf("OB %30s %p (export-parent=%s; world x = %f)\n",
-  //get_object_name(context.object).c_str(),
+  //context.export_name.c_str(),
   //context.object,
   //export_parent_name.c_str(),
   //context.matrix_world[3][0]);
@@ -232,11 +249,21 @@ void 
AbstractHierarchyIterator::visit_dupli_object(DupliObject *dupli_object,
   context.animation_check_include_parent = animation_check_include_parent;
   copy_m4_m4(context.matrix_world, dupli_object->mat);
 
+  std::string export_parent_name = context.export_parent ? 
get_object_name(context.export_parent) :
+   "/";
+
+  // Construct export name for the dupli-instance.
+  std::stringstream suffix_stream;
+  suffix_stream << std::hex;
+  for (int i = 0; i < MAX_DUPLI_RECUR && dupli_object->persistent_id[i] != 
INT_MAX; i++) {
+suffix_stream << "-" << dupli_object->persistent_id[i];
+  }
+  context.export_name = make_valid_name(get_object_name(context.object) + 
suffix_stream.str());
+
   export_graph[graph_index].insert(context);
 
-  // std::string export_parent_name = export_parent ? 
get_object_name(export_parent) : "/";
   // printf("DU %30s %p (export-parent=%s; duplicator = %s; world x = 
%f)\n",
-  //get_object_name(context.object).c_str(),
+  //context.export_name.c_str(),
   //context.object,
   //export_parent_name.c_str(),
   //duplicator->id.name + 2,
@@ -291,19 +318,21 @@ void AbstractHierarchyIterator::make_writers(const 
HierarchyContext &parent_cont
 invert_m4_m4(parent_matrix_inv_world, parent_context.matrix_world);
   }
 
-  for (HierarchyContext context :
-   export_graph[std::make_pair(parent_context.object, 
parent_context.duplicator)]) {
-std::string export_path = path_concatenate(parent_context.export_path,
-   
get_object_name(context.object));
+  ExportGraph::mapped_type &graph_children =
+  export_graph[std::make_pair(parent_context.object, 
parent_context.duplicator)];
+  for (HierarchyContext context : g

[Bf-blender-cvs] [d4bec94864a] sybren-usd: USD: Cleanup, removed commented-out debug code

2019-07-16 Thread Sybren A. Stüvel
Commit: d4bec94864a602dbe0289a294cba4e9118ef1fca
Author: Sybren A. Stüvel
Date:   Tue Jul 16 15:46:19 2019 +0200
Branches: sybren-usd
https://developer.blender.org/rBd4bec94864a602dbe0289a294cba4e9118ef1fca

USD: Cleanup, removed commented-out debug code

===

M   source/blender/usd/intern/abstract_hierarchy_iterator.cc

===

diff --git a/source/blender/usd/intern/abstract_hierarchy_iterator.cc 
b/source/blender/usd/intern/abstract_hierarchy_iterator.cc
index 2bd368de221..0ab8678d437 100644
--- a/source/blender/usd/intern/abstract_hierarchy_iterator.cc
+++ b/source/blender/usd/intern/abstract_hierarchy_iterator.cc
@@ -64,77 +64,8 @@ void AbstractHierarchyIterator::release_writers()
 void AbstractHierarchyIterator::iterate()
 {
   construct_export_graph();
-
-  // // For debug: print the export graph.
-  // printf("== Export graph pre-prune:\n");
-  // for (auto it : export_graph) {
-  //   const std::pair &parent_info = it.first;
-  //   Object *const export_parent = parent_info.first;
-  //   Object *const duplicator = parent_info.second;
-
-  //   if (duplicator != nullptr) {
-  // printf("DU %s (as dupped by %s):\n",
-  //export_parent == nullptr ? "-null-" : (export_parent->id.name 
+ 2),
-  //duplicator->id.name + 2);
-  //   }
-  //   else {
-  // printf("OB %s:\n", export_parent == nullptr ? "-null-" : 
(export_parent->id.name +
-  // 2));
-  //   }
-
-  //   for (auto child_it : it.second) {
-  // if (child_it.duplicator == nullptr) {
-  //   printf("   - %s%s\n",
-  //  child_it.object->id.name + 2,
-  //  child_it.weak_export ? " (weak)" : "");
-  // }
-  // else {
-  //   printf("   - %s (dup by %s%s)\n",
-  //  child_it.object->id.name + 2,
-  //  child_it.duplicator->id.name + 2,
-  //  child_it.weak_export ? ", weak" : "");
-  // }
-  //   }
-  // }
-
   prune_export_graph();
-
-  // // For debug: print the export graph.
-  // printf("== Export graph post-prune:\n");
-  // for (auto it : export_graph) {
-  //   const std::pair &parent_info = it.first;
-  //   Object *const export_parent = parent_info.first;
-  //   Object *const duplicator = parent_info.second;
-
-  //   if (duplicator != nullptr) {
-  // printf("DU %s (as dupped by %s):\n",
-  //export_parent == nullptr ? "-null-" : (export_parent->id.name 
+ 2),
-  //duplicator->id.name + 2);
-  //   }
-  //   else {
-  // printf("OB %s:\n", export_parent == nullptr ? "-null-" : 
(export_parent->id.name +
-  // 2));
-  //   }
-
-  //   for (auto child_it : it.second) {
-  // if (child_it.duplicator == nullptr) {
-  //   printf("   - %s%s\n",
-  //  child_it.object->id.name + 2,
-  //  child_it.weak_export ? " (weak)" : "");
-  // }
-  // else {
-  //   printf("   - %s (dup by %s%s)\n",
-  //  child_it.object->id.name + 2,
-  //  child_it.duplicator->id.name + 2,
-  //  child_it.weak_export ? ", weak" : "");
-  // }
-  //   }
-  // }
-
-  // For debug: print the export paths.
-  // printf("== Export paths:\n");
   make_writers(HierarchyContext::root(), nullptr);
-
   export_graph.clear();
 }

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


[Bf-blender-cvs] [9a62bb6ce57] sybren-usd: USD: Changed ExportGraph type to hold HierarchyContext pointers

2019-07-16 Thread Sybren A. Stüvel
Commit: 9a62bb6ce5723e3ab802d1f6382c5f0909b49a5a
Author: Sybren A. Stüvel
Date:   Tue Jul 16 18:37:21 2019 +0200
Branches: sybren-usd
https://developer.blender.org/rB9a62bb6ce5723e3ab802d1f6382c5f0909b49a5a

USD: Changed ExportGraph type to hold HierarchyContext pointers

This allows us to change the stored HierarchyContext objects in a future
commit.

No functional changes.

===

M   source/blender/usd/intern/abstract_hierarchy_iterator.cc
M   source/blender/usd/intern/abstract_hierarchy_iterator.h
M   source/blender/usd/intern/usd_hierarchy_iterator.cc
M   source/blender/usd/intern/usd_hierarchy_iterator.h

===

diff --git a/source/blender/usd/intern/abstract_hierarchy_iterator.cc 
b/source/blender/usd/intern/abstract_hierarchy_iterator.cc
index 0ab8678d437..2f82399a8bc 100644
--- a/source/blender/usd/intern/abstract_hierarchy_iterator.cc
+++ b/source/blender/usd/intern/abstract_hierarchy_iterator.cc
@@ -20,10 +20,9 @@ extern "C" {
 #include "DEG_depsgraph_query.h"
 }
 
-const HierarchyContext &HierarchyContext::root()
+const HierarchyContext *HierarchyContext::root()
 {
-  static const HierarchyContext root_hierarchy_context = {.object = nullptr};
-  return root_hierarchy_context;
+  return nullptr;
 }
 
 bool HierarchyContext::operator<(const HierarchyContext &other) const
@@ -63,13 +62,13 @@ void AbstractHierarchyIterator::release_writers()
 
 void AbstractHierarchyIterator::iterate()
 {
-  construct_export_graph();
-  prune_export_graph();
+  export_graph_construct();
+  export_graph_prune();
   make_writers(HierarchyContext::root(), nullptr);
-  export_graph.clear();
+  export_graph_clear();
 }
 
-void AbstractHierarchyIterator::construct_export_graph()
+void AbstractHierarchyIterator::export_graph_construct()
 {
   Scene *scene = DEG_get_evaluated_scene(depsgraph);
 
@@ -125,25 +124,25 @@ void AbstractHierarchyIterator::visit_object(Object 
*object,
  Object *export_parent,
  bool weak_export)
 {
-  HierarchyContext context;
-  context.object = object;
-  context.export_name = get_object_name(object);
-  context.export_parent = export_parent;
-  context.duplicator = nullptr;
-  context.weak_export = weak_export;
-  context.animation_check_include_parent = false;
-  context.export_path = "";
-  context.parent_writer = nullptr;
-  copy_m4_m4(context.matrix_world, object->obmat);
+  HierarchyContext *context = new HierarchyContext();
+  context->object = object;
+  context->export_name = get_object_name(object);
+  context->export_parent = export_parent;
+  context->duplicator = nullptr;
+  context->weak_export = weak_export;
+  context->animation_check_include_parent = false;
+  context->export_path = "";
+  context->parent_writer = nullptr;
+  copy_m4_m4(context->matrix_world, object->obmat);
 
   export_graph[std::make_pair(export_parent, nullptr)].insert(context);
 
   // std::string export_parent_name = export_parent ? 
get_object_name(export_parent) : "/";
   // printf("OB %30s %p (export-parent=%s; world x = %f)\n",
-  //context.export_name.c_str(),
-  //context.object,
+  //context->export_name.c_str(),
+  //context->object,
   //export_parent_name.c_str(),
-  //context.matrix_world[3][0]);
+  //context->matrix_world[3][0]);
 }
 
 void AbstractHierarchyIterator::visit_dupli_object(DupliObject *dupli_object,
@@ -153,19 +152,19 @@ void 
AbstractHierarchyIterator::visit_dupli_object(DupliObject *dupli_object,
   ExportGraph::key_type graph_index;
   bool animation_check_include_parent = false;
 
-  HierarchyContext context;
-  context.object = dupli_object->ob;
-  context.duplicator = duplicator;
-  context.weak_export = false;
-  context.export_path = "";
-  context.parent_writer = nullptr;
+  HierarchyContext *context = new HierarchyContext();
+  context->object = dupli_object->ob;
+  context->duplicator = duplicator;
+  context->weak_export = false;
+  context->export_path = "";
+  context->parent_writer = nullptr;
 
   /* If the dupli-object's scene parent is also instanced by this object, use 
that as the
* export parent. Otherwise use the dupli-parent as export parent. */
   Object *parent = dupli_object->ob->parent;
   if (parent != nullptr && dupli_set.find(parent) != dupli_set.end()) {
 // The parent object is part of the duplicated collection.
-context.export_parent = parent;
+context->export_parent = parent;
 graph_index = std::make_pair(parent, duplicator);
   }
   else {
@@ -173,15 +172,16 @@ void 
AbstractHierarchyIterator::visit_dupli_object(DupliObject *dupli_object,
  * transform of this

[Bf-blender-cvs] [85dd4d4e3ba] sybren-usd: USD: prevent crash when writing hair system with empty pathcache

2019-07-19 Thread Sybren A. Stüvel
Commit: 85dd4d4e3baa5b33260a5f06c6fbb782a6aa10fb
Author: Sybren A. Stüvel
Date:   Fri Jul 19 11:14:26 2019 +0200
Branches: sybren-usd
https://developer.blender.org/rB85dd4d4e3baa5b33260a5f06c6fbb782a6aa10fb

USD: prevent crash when writing hair system with empty pathcache

Not sure what causes `psys->pathcache` to be `nullptr` in the first place,
but at least this prevents Blender from crashing.

===

M   source/blender/usd/intern/usd_writer_hair.cc

===

diff --git a/source/blender/usd/intern/usd_writer_hair.cc 
b/source/blender/usd/intern/usd_writer_hair.cc
index af0d23addcd..37bc6a00c9b 100644
--- a/source/blender/usd/intern/usd_writer_hair.cc
+++ b/source/blender/usd/intern/usd_writer_hair.cc
@@ -18,6 +18,11 @@ USDHairWriter::USDHairWriter(const USDExporterContext &ctx) 
: USDAbstractWriter(
 void USDHairWriter::do_write(HierarchyContext &context)
 {
   ParticleSystem *psys = context.particle_system;
+  ParticleCacheKey **cache = psys->pathcache;
+  if (cache == nullptr) {
+return;
+  }
+
   pxr::UsdTimeCode timecode = get_export_time_code();
 
   printf("\033[34;1mHAIR writer\033[0m writing %s %s\n",
@@ -35,7 +40,6 @@ void USDHairWriter::do_write(HierarchyContext &context)
   curve_point_counts.reserve(psys->totpart);
   colors.reserve(psys->totpart);
 
-  ParticleCacheKey **cache = psys->pathcache;
   ParticleCacheKey *strand;
   for (int strand_index = 0; strand_index < psys->totpart; ++strand_index) {
 strand = cache[strand_index];

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


[Bf-blender-cvs] [e92989b0c1c] sybren-usd: USD: removed 'parent_writer' pointer

2019-07-19 Thread Sybren A. Stüvel
Commit: e92989b0c1c0a518a3208e98cd2b6af0cc424469
Author: Sybren A. Stüvel
Date:   Wed Jul 17 12:18:42 2019 +0200
Branches: sybren-usd
https://developer.blender.org/rBe92989b0c1c0a518a3208e98cd2b6af0cc424469

USD: removed 'parent_writer' pointer

The `parent_writer` pointer was intended to be used by an Alembic writer,
but now it's getting in the way. I'm removing it from the
`AbstractHierarchyIterator` with the intent of either restoring it or
finding another solution when we actually implement Alembic writers.

===

M   source/blender/usd/intern/abstract_hierarchy_iterator.cc
M   source/blender/usd/intern/abstract_hierarchy_iterator.h

===

diff --git a/source/blender/usd/intern/abstract_hierarchy_iterator.cc 
b/source/blender/usd/intern/abstract_hierarchy_iterator.cc
index 8d18d1f5b8d..10379b0a2b9 100644
--- a/source/blender/usd/intern/abstract_hierarchy_iterator.cc
+++ b/source/blender/usd/intern/abstract_hierarchy_iterator.cc
@@ -64,7 +64,7 @@ void AbstractHierarchyIterator::iterate()
 {
   export_graph_construct();
   export_graph_prune();
-  make_writers(HierarchyContext::root(), nullptr);
+  make_writers(HierarchyContext::root());
   export_graph_clear();
 }
 
@@ -132,7 +132,6 @@ void AbstractHierarchyIterator::visit_object(Object *object,
   context->weak_export = weak_export;
   context->animation_check_include_parent = false;
   context->export_path = "";
-  context->parent_writer = nullptr;
   copy_m4_m4(context->matrix_world, object->obmat);
 
   export_graph[std::make_pair(export_parent, nullptr)].insert(context);
@@ -157,7 +156,6 @@ void 
AbstractHierarchyIterator::visit_dupli_object(DupliObject *dupli_object,
   context->duplicator = duplicator;
   context->weak_export = false;
   context->export_path = "";
-  context->parent_writer = nullptr;
 
   /* If the dupli-object's scene parent is also instanced by this object, use 
that as the
* export parent. Otherwise use the dupli-parent as export parent. */
@@ -259,8 +257,7 @@ AbstractHierarchyIterator::ExportGraph::mapped_type 
&AbstractHierarchyIterator::
   return export_graph[std::make_pair(parent_object, parent_duplicator)];
 }
 
-void AbstractHierarchyIterator::make_writers(const HierarchyContext 
*parent_context,
- AbstractHierarchyWriter 
*parent_writer)
+void AbstractHierarchyIterator::make_writers(const HierarchyContext 
*parent_context)
 {
   AbstractHierarchyWriter *xform_writer = nullptr;
   float parent_matrix_inv_world[4][4];
@@ -276,7 +273,6 @@ void AbstractHierarchyIterator::make_writers(const 
HierarchyContext *parent_cont
 
   for (HierarchyContext *context : graph_children(parent_context)) {
 std::string export_path = path_concatenate(parent_export_path, 
context->export_name);
-context->parent_writer = parent_writer;
 context->export_path = export_path;
 copy_m4_m4(context->parent_matrix_inv_world, parent_matrix_inv_world);
 
@@ -301,19 +297,19 @@ void AbstractHierarchyIterator::make_writers(const 
HierarchyContext *parent_cont
 xform_writer->write(*context);
 
 if (!context->weak_export) {
-  make_writers_particle_systems(context, xform_writer);
-  make_writer_object_data(context, xform_writer);
+  make_writers_particle_systems(context);
+  make_writer_object_data(context);
 }
 
 // Recurse into this object's children.
-make_writers(context, xform_writer);
+make_writers(context);
   }
 
   // TODO(Sybren): iterate over all unused writers and call 
unused_during_iteration() or something.
 }
 
 void AbstractHierarchyIterator::make_writers_particle_systems(
-const HierarchyContext *xform_context, AbstractHierarchyWriter 
*xform_writer)
+const HierarchyContext *xform_context)
 {
   Object *object = xform_context->object;
   ParticleSystem *psys = static_cast(object->particlesystem.first);
@@ -325,7 +321,6 @@ void 
AbstractHierarchyIterator::make_writers_particle_systems(
 HierarchyContext hair_context = *xform_context;
 hair_context.export_path = path_concatenate(xform_context->export_path,
 get_id_name(&psys->part->id));
-hair_context.parent_writer = xform_writer;
 hair_context.particle_system = psys;
 
 AbstractHierarchyWriter *writer = nullptr;
@@ -344,8 +339,7 @@ void 
AbstractHierarchyIterator::make_writers_particle_systems(
   }
 }
 
-void AbstractHierarchyIterator::make_writer_object_data(const HierarchyContext 
*context,
-
AbstractHierarchyWriter *xform_writer)
+void AbstractHierarchyIterator::make_writer_object_data(const HierarchyContext 
*context)
 {
   if (context->object->data == nullptr) {
 return;
@@ -356,7 +350,6 @

[Bf-blender-cvs] [14a84d76e88] sybren-usd: USD: Experimental support for instancing/referencing

2019-07-19 Thread Sybren A. Stüvel
Commit: 14a84d76e880572ff93318c1d543bb193413ce98
Author: Sybren A. Stüvel
Date:   Thu Jul 18 12:44:48 2019 +0200
Branches: sybren-usd
https://developer.blender.org/rB14a84d76e880572ff93318c1d543bb193413ce98

USD: Experimental support for instancing/referencing

Dupli-object meshes are now written to USD as references to the origina
mesh. This is still very limited in correctness, as there are issues
referencing to materials from a referenced mesh.

I am still committing this, as it also introduces some code clarifications
and gives us a place to start when continuing the quest for proper
instancing in USD.

===

M   source/blender/editors/io/io_usd.c
M   source/blender/usd/intern/abstract_hierarchy_iterator.cc
M   source/blender/usd/intern/abstract_hierarchy_iterator.h
M   source/blender/usd/intern/usd_writer_mesh.cc
M   source/blender/usd/usd.h

===

diff --git a/source/blender/editors/io/io_usd.c 
b/source/blender/editors/io/io_usd.c
index 529a330ca14..71c65eef4f6 100644
--- a/source/blender/editors/io/io_usd.c
+++ b/source/blender/editors/io/io_usd.c
@@ -102,6 +102,7 @@ static int wm_usd_export_exec(bContext *C, wmOperator *op)
   const bool visible_objects_only = RNA_boolean_get(op->ptr, 
"visible_objects_only");
   const bool export_animation = RNA_boolean_get(op->ptr, "export_animation");
   const bool export_hair = RNA_boolean_get(op->ptr, "export_hair");
+  const bool use_instancing = RNA_boolean_get(op->ptr, "use_instancing");
   const bool evaluation_mode = RNA_enum_get(op->ptr, "evaluation_mode");
 
   struct USDExportParams params = {
@@ -109,6 +110,7 @@ static int wm_usd_export_exec(bContext *C, wmOperator *op)
   export_hair,
   selected_objects_only,
   visible_objects_only,
+  use_instancing,
   evaluation_mode,
   };
 
@@ -154,6 +156,13 @@ void WM_OT_usd_export(struct wmOperatorType *ot)
   RNA_def_boolean(
   ot->srna, "export_hair", false, "Export Hair", "When true, hair is 
exported as USD curves");
 
+  RNA_def_boolean(ot->srna,
+  "use_instancing",
+  false,
+  "Use Instancing (EXPERIMENTAL)",
+  "When true, dupli-objects are written as instances of the 
original in USD. "
+  "Experimental feature, not working perfectly");
+
   RNA_def_enum(ot->srna,
"evaluation_mode",
rna_enum_usd_export_evaluation_mode_items,
diff --git a/source/blender/usd/intern/abstract_hierarchy_iterator.cc 
b/source/blender/usd/intern/abstract_hierarchy_iterator.cc
index b8a6dcad548..d0492b76d30 100644
--- a/source/blender/usd/intern/abstract_hierarchy_iterator.cc
+++ b/source/blender/usd/intern/abstract_hierarchy_iterator.cc
@@ -38,6 +38,19 @@ bool HierarchyContext::operator<(const HierarchyContext 
&other) const
   return export_parent < other.export_parent;
 }
 
+bool HierarchyContext::is_instance() const
+{
+  return !original_export_path.empty();
+}
+void HierarchyContext::mark_as_instance_of(const std::string 
&reference_export_path)
+{
+  original_export_path = reference_export_path;
+}
+void HierarchyContext::mark_as_not_instanced()
+{
+  original_export_path.clear();
+}
+
 AbstractHierarchyIterator::AbstractHierarchyIterator(Depsgraph *depsgraph)
 : depsgraph(depsgraph), writers()
 {
@@ -80,15 +93,21 @@ void AbstractHierarchyIterator::debug_print_export_graph() 
const
 total_graph_size += map_iter.second.size();
 for (HierarchyContext *child_ctx : map_iter.second) {
   if (child_ctx->duplicator == nullptr) {
-printf("   - %s%s\n",
+printf("   - %s%s%s\n",
child_ctx->object->id.name + 2,
-   child_ctx->weak_export ? " \033[97m(weak)\033[0m" : "");
+   child_ctx->weak_export ? " \033[97m(weak)\033[0m" : "",
+   child_ctx->original_export_path.size() ?
+   (std::string("ref ") + 
child_ctx->original_export_path).c_str() :
+   "");
   }
   else {
-printf("   - %s (dup by %s%s)\n",
+printf("   - %s (dup by %s%s) %s\n",
child_ctx->object->id.name + 2,
child_ctx->duplicator->id.name + 2,
-   child_ctx->weak_export ? ", \033[97mweak\033[0m" : "");
+   child_ctx->weak_export ? ", \033[97mweak\033[0m" : "",
+   child_ctx->original_export_path.size() ?
+   (std::string("ref ") + 
child_ctx->original_export_path).c_str() :
+   

[Bf-blender-cvs] [f2ffc2c0b86] sybren-usd: USD: added debug function for printing the export graph

2019-07-19 Thread Sybren A. Stüvel
Commit: f2ffc2c0b8622fd9ae785e68c2f4e09a01eb98bf
Author: Sybren A. Stüvel
Date:   Wed Jul 17 14:35:34 2019 +0200
Branches: sybren-usd
https://developer.blender.org/rBf2ffc2c0b8622fd9ae785e68c2f4e09a01eb98bf

USD: added debug function for printing the export graph

===

M   source/blender/usd/intern/abstract_hierarchy_iterator.cc
M   source/blender/usd/intern/abstract_hierarchy_iterator.h

===

diff --git a/source/blender/usd/intern/abstract_hierarchy_iterator.cc 
b/source/blender/usd/intern/abstract_hierarchy_iterator.cc
index 10379b0a2b9..b8a6dcad548 100644
--- a/source/blender/usd/intern/abstract_hierarchy_iterator.cc
+++ b/source/blender/usd/intern/abstract_hierarchy_iterator.cc
@@ -60,6 +60,41 @@ void AbstractHierarchyIterator::release_writers()
   writers.clear();
 }
 
+void AbstractHierarchyIterator::debug_print_export_graph() const
+{
+  size_t total_graph_size = 0;
+  for (const ExportGraph::value_type &map_iter : export_graph) {
+const std::pair &parent_info = map_iter.first;
+Object *const export_parent = parent_info.first;
+Object *const duplicator = parent_info.second;
+
+if (duplicator != nullptr) {
+  printf("DU %s (as dupped by %s):\n",
+ export_parent == nullptr ? "-null-" : (export_parent->id.name + 
2),
+ duplicator->id.name + 2);
+}
+else {
+  printf("OB %s:\n", export_parent == nullptr ? "-null-" : 
(export_parent->id.name + 2));
+}
+
+total_graph_size += map_iter.second.size();
+for (HierarchyContext *child_ctx : map_iter.second) {
+  if (child_ctx->duplicator == nullptr) {
+printf("   - %s%s\n",
+   child_ctx->object->id.name + 2,
+   child_ctx->weak_export ? " \033[97m(weak)\033[0m" : "");
+  }
+  else {
+printf("   - %s (dup by %s%s)\n",
+   child_ctx->object->id.name + 2,
+   child_ctx->duplicator->id.name + 2,
+   child_ctx->weak_export ? ", \033[97mweak\033[0m" : "");
+  }
+}
+  }
+  printf("(Total graph size: %lu objects\n", total_graph_size);
+}
+
 void AbstractHierarchyIterator::iterate()
 {
   export_graph_construct();
diff --git a/source/blender/usd/intern/abstract_hierarchy_iterator.h 
b/source/blender/usd/intern/abstract_hierarchy_iterator.h
index f2a1907bd8d..baa14969390 100644
--- a/source/blender/usd/intern/abstract_hierarchy_iterator.h
+++ b/source/blender/usd/intern/abstract_hierarchy_iterator.h
@@ -108,6 +108,8 @@ class AbstractHierarchyIterator {
   virtual std::string make_valid_name(const std::string &name) const;
 
  private:
+  void debug_print_export_graph() const;
+
   void export_graph_construct();
   void export_graph_prune();
   void export_graph_clear();

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


[Bf-blender-cvs] [e847ceb42e6] sybren-usd: USD: Fix missing writer pointer

2019-07-19 Thread Sybren A. Stüvel
Commit: e847ceb42e69bb6fdea92fbff0343e2b5316bbc7
Author: Sybren A. Stüvel
Date:   Thu Jul 18 12:45:17 2019 +0200
Branches: sybren-usd
https://developer.blender.org/rBe847ceb42e69bb6fdea92fbff0343e2b5316bbc7

USD: Fix missing writer pointer

Fixes bug introduced in previous commit.

===

M   source/blender/usd/intern/abstract_hierarchy_iterator.cc

===

diff --git a/source/blender/usd/intern/abstract_hierarchy_iterator.cc 
b/source/blender/usd/intern/abstract_hierarchy_iterator.cc
index 2f82399a8bc..8d18d1f5b8d 100644
--- a/source/blender/usd/intern/abstract_hierarchy_iterator.cc
+++ b/source/blender/usd/intern/abstract_hierarchy_iterator.cc
@@ -429,5 +429,8 @@ AbstractHierarchyWriter 
*AbstractHierarchyIterator::ensure_writer(
   if (writer == nullptr) {
 return nullptr;
   }
+
+  writers[context->export_path] = writer;
+
   return writer;
 }

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


[Bf-blender-cvs] [45a19261616] sybren-usd: USD: initial support for exporting lights

2019-07-19 Thread Sybren A. Stüvel
Commit: 45a192616167691209aa13dc15e16014a40bb013
Author: Sybren A. Stüvel
Date:   Fri Jul 19 16:34:00 2019 +0200
Branches: sybren-usd
https://developer.blender.org/rB45a192616167691209aa13dc15e16014a40bb013

USD: initial support for exporting lights

USD does not seem to support spot lights, so those aren't exported yet.
The units used for the light intensity is also still a bit of a mystery.

===

M   source/blender/usd/CMakeLists.txt
M   source/blender/usd/intern/usd_hierarchy_iterator.cc
A   source/blender/usd/intern/usd_writer_light.cc
A   source/blender/usd/intern/usd_writer_light.h

===

diff --git a/source/blender/usd/CMakeLists.txt 
b/source/blender/usd/CMakeLists.txt
index 95046a48a74..1861b8c41b9 100644
--- a/source/blender/usd/CMakeLists.txt
+++ b/source/blender/usd/CMakeLists.txt
@@ -53,6 +53,7 @@ set(SRC
   intern/usd_writer_abstract.cc
   intern/usd_writer_camera.cc
   intern/usd_writer_hair.cc
+  intern/usd_writer_light.cc
   intern/usd_writer_mesh.cc
   intern/usd_writer_transform.cc
 
@@ -62,6 +63,7 @@ set(SRC
   intern/usd_writer_abstract.h
   intern/usd_writer_camera.h
   intern/usd_writer_hair.h
+  intern/usd_writer_light.h
   intern/usd_writer_mesh.h
   intern/usd_writer_transform.h
 )
diff --git a/source/blender/usd/intern/usd_hierarchy_iterator.cc 
b/source/blender/usd/intern/usd_hierarchy_iterator.cc
index 7636ec7d3f3..3214f25386e 100644
--- a/source/blender/usd/intern/usd_hierarchy_iterator.cc
+++ b/source/blender/usd/intern/usd_hierarchy_iterator.cc
@@ -4,6 +4,7 @@
 #include "usd_writer_abstract.h"
 #include "usd_writer_camera.h"
 #include "usd_writer_hair.h"
+#include "usd_writer_light.h"
 #include "usd_writer_mesh.h"
 #include "usd_writer_transform.h"
 
@@ -87,13 +88,15 @@ AbstractHierarchyWriter 
*USDHierarchyIterator::create_data_writer(const Hierarch
 case OB_CAMERA:
   data_writer = new USDCameraWriter(usd_export_context);
   break;
+case OB_LAMP:
+  data_writer = new USDLightWriter(usd_export_context);
+  break;
 
 case OB_EMPTY:
 case OB_CURVE:
 case OB_SURF:
 case OB_FONT:
 case OB_MBALL:
-case OB_LAMP:
 case OB_SPEAKER:
 case OB_LIGHTPROBE:
 case OB_LATTICE:
diff --git a/source/blender/usd/intern/usd_writer_light.cc 
b/source/blender/usd/intern/usd_writer_light.cc
new file mode 100644
index 000..bbba8c7ab89
--- /dev/null
+++ b/source/blender/usd/intern/usd_writer_light.cc
@@ -0,0 +1,88 @@
+#include "usd_writer_light.h"
+#include "usd_hierarchy_iterator.h"
+
+#include 
+#include 
+#include 
+#include 
+
+extern "C" {
+#include "BLI_assert.h"
+#include "BLI_utildefines.h"
+
+#include "DNA_light_types.h"
+#include "DNA_object_types.h"
+}
+
+USDLightWriter::USDLightWriter(const USDExporterContext &ctx) : 
USDAbstractWriter(ctx)
+{
+}
+
+bool USDLightWriter::is_supported(const Object *object) const
+{
+  Light *light = static_cast(object->data);
+  return ELEM(light->type, LA_AREA, LA_LOCAL, LA_SUN);
+}
+
+void USDLightWriter::do_write(HierarchyContext &context)
+{
+  pxr::UsdTimeCode timecode = get_export_time_code();
+
+  Light *light = static_cast(context.object->data);
+  pxr::UsdLuxLight usd_light;
+
+  switch (light->type) {
+case LA_AREA:
+  switch (light->area_shape) {
+case LA_AREA_DISK:
+case LA_AREA_ELLIPSE: { /* An ellipse light will deteriorate into a 
disk light. */
+  pxr::UsdLuxDiskLight disk_light = 
pxr::UsdLuxDiskLight::Define(stage, usd_path_);
+  disk_light.CreateRadiusAttr().Set(light->area_size, timecode);
+  usd_light = disk_light;
+  break;
+}
+case LA_AREA_RECT: {
+  pxr::UsdLuxRectLight rect_light = 
pxr::UsdLuxRectLight::Define(stage, usd_path_);
+  rect_light.CreateWidthAttr().Set(light->area_size, timecode);
+  rect_light.CreateHeightAttr().Set(light->area_sizey, timecode);
+  usd_light = rect_light;
+  break;
+}
+case LA_AREA_SQUARE: {
+  pxr::UsdLuxRectLight rect_light = 
pxr::UsdLuxRectLight::Define(stage, usd_path_);
+  rect_light.CreateWidthAttr().Set(light->area_size, timecode);
+  rect_light.CreateHeightAttr().Set(light->area_size, timecode);
+  usd_light = rect_light;
+  break;
+}
+  }
+  break;
+case LA_LOCAL: {
+  pxr::UsdLuxSphereLight sphere_light = 
pxr::UsdLuxSphereLight::Define(stage, usd_path_);
+  sphere_light.CreateRadiusAttr().Set(light->area_size, timecode);
+  usd_light = sphere_light;
+  break;
+}
+case LA_SUN:
+  usd_light = pxr::UsdLuxDistantLight::Define(stage, usd_path_);
+  break;
+default:
+  BLI_assert(!"is

[Bf-blender-cvs] [fd71798e2f2] sybren-usd: USD: reduce hair colours to one colour per hair strand

2019-07-23 Thread Sybren A. Stüvel
Commit: fd71798e2f21b76621f16147d0c4c7754fe93ee9
Author: Sybren A. Stüvel
Date:   Tue Jul 23 11:17:01 2019 +0200
Branches: sybren-usd
https://developer.blender.org/rBfd71798e2f21b76621f16147d0c4c7754fe93ee9

USD: reduce hair colours to one colour per hair strand

The colours weren't written correctly, so this just reduces the amount of
data that's written. This'll probably be used until we decide to evaluate
the hair material.

===

M   source/blender/usd/intern/usd_writer_hair.cc

===

diff --git a/source/blender/usd/intern/usd_writer_hair.cc 
b/source/blender/usd/intern/usd_writer_hair.cc
index 37bc6a00c9b..9b53659ed6a 100644
--- a/source/blender/usd/intern/usd_writer_hair.cc
+++ b/source/blender/usd/intern/usd_writer_hair.cc
@@ -36,9 +36,7 @@ void USDHairWriter::do_write(HierarchyContext &context)
 
   pxr::VtArray points;
   pxr::VtIntArray curve_point_counts;
-  pxr::VtArray colors;
   curve_point_counts.reserve(psys->totpart);
-  colors.reserve(psys->totpart);
 
   ParticleCacheKey *strand;
   for (int strand_index = 0; strand_index < psys->totpart; ++strand_index) {
@@ -46,7 +44,6 @@ void USDHairWriter::do_write(HierarchyContext &context)
 
 int point_count = strand->segments + 1;
 curve_point_counts.push_back(point_count);
-colors.push_back(pxr::GfVec3f(strand->col));
 
 for (int point_index = 0; point_index < point_count; ++point_index, 
++strand) {
   points.push_back(pxr::GfVec3f(strand->co));
@@ -55,11 +52,11 @@ void USDHairWriter::do_write(HierarchyContext &context)
 
   curves.CreatePointsAttr().Set(points, timecode);
   curves.CreateCurveVertexCountsAttr().Set(curve_point_counts, timecode);
-  curves.CreateDisplayColorAttr(pxr::VtValue(colors));
 
   if (psys->totpart > 0) {
-// pxr::VtArray colors;
-// colors.push_back(pxr::GfVec3f(cache[0]->col));
+pxr::VtArray colors;
+colors.push_back(pxr::GfVec3f(cache[0]->col));
+curves.CreateDisplayColorAttr().Set(pxr::VtValue(colors), timecode);
   }
 }

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


[Bf-blender-cvs] [5f5540eaf69] sybren-usd: USD: Removed debug prints

2019-07-25 Thread Sybren A. Stüvel
Commit: 5f5540eaf69b668f80335918664107096dab4820
Author: Sybren A. Stüvel
Date:   Thu Jul 25 12:59:11 2019 +0200
Branches: sybren-usd
https://developer.blender.org/rB5f5540eaf69b668f80335918664107096dab4820

USD: Removed debug prints

No functional changes.

===

M   source/blender/usd/intern/abstract_hierarchy_iterator.cc
M   source/blender/usd/intern/usd_capi.cc
M   source/blender/usd/intern/usd_hierarchy_iterator.cc
M   source/blender/usd/intern/usd_writer_abstract.cc
M   source/blender/usd/intern/usd_writer_hair.cc
M   source/blender/usd/intern/usd_writer_mesh.cc

===

diff --git a/source/blender/usd/intern/abstract_hierarchy_iterator.cc 
b/source/blender/usd/intern/abstract_hierarchy_iterator.cc
index d0492b76d30..9eb3c5d6ff2 100644
--- a/source/blender/usd/intern/abstract_hierarchy_iterator.cc
+++ b/source/blender/usd/intern/abstract_hierarchy_iterator.cc
@@ -128,7 +128,6 @@ void AbstractHierarchyIterator::export_graph_construct()
 {
   Scene *scene = DEG_get_evaluated_scene(depsgraph);
 
-  // printf("== Visiting objects:\n");
   DEG_OBJECT_ITER_BEGIN (depsgraph,
  object,
  DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY |
@@ -192,13 +191,6 @@ void AbstractHierarchyIterator::visit_object(Object 
*object,
   copy_m4_m4(context->matrix_world, object->obmat);
 
   export_graph[std::make_pair(export_parent, nullptr)].insert(context);
-
-  // std::string export_parent_name = export_parent ? 
get_object_name(export_parent) : "/";
-  // printf("OB %30s %p (export-parent=%s; world x = %f)\n",
-  //context->export_name.c_str(),
-  //context->object,
-  //export_parent_name.c_str(),
-  //context->matrix_world[3][0]);
 }
 
 void AbstractHierarchyIterator::visit_dupli_object(DupliObject *dupli_object,
@@ -244,16 +236,6 @@ void 
AbstractHierarchyIterator::visit_dupli_object(DupliObject *dupli_object,
   context->export_name = make_valid_name(get_object_name(context->object) + 
suffix_stream.str());
 
   export_graph[graph_index].insert(context);
-
-  // std::string export_parent_name = context->export_parent ?
-  //  
get_object_name(context->export_parent) :
-  //  "/";
-  // printf("DU %30s %p (export-parent=%s; duplicator = %s; world x = 
%f)\n",
-  //context->export_name.c_str(),
-  //context->object,
-  //export_parent_name.c_str(),
-  //duplicator->id.name + 2,
-  //context->matrix_world[3][0]);
 }
 
 static bool prune_the_weak(const HierarchyContext *context,
@@ -365,10 +347,6 @@ void 
AbstractHierarchyIterator::determine_duplication_references(
 if (it == originals_export_paths.end()) {
   // The original was not found, so mark this instance as "original".
   std::string data_path = get_object_data_path(context);
-  // printf(
-  // "%s\033[93mUSD issue\033[0m: %s is DATA instance of %p, but 
no original DATA path
-  // " "is known\n", indent.c_str(), data_path.c_str(), 
orig_data_id);
-
   context->mark_as_not_instanced();
   originals_export_paths[orig_id] = context->export_path;
   originals_export_paths[orig_data_id] = data_path;
diff --git a/source/blender/usd/intern/usd_capi.cc 
b/source/blender/usd/intern/usd_capi.cc
index d1b84c453bc..ecf20b737ce 100644
--- a/source/blender/usd/intern/usd_capi.cc
+++ b/source/blender/usd/intern/usd_capi.cc
@@ -128,7 +128,6 @@ static void export_startjob(void *customdata, short *stop, 
short *do_update, flo
   break;
 }
 
-printf("\033[35;1mFRAME\033[0m %f\n", frame);
 // Update the scene for the next frame to render.
 scene->r.cfra = static_cast(frame);
 scene->r.subframe = frame - scene->r.cfra;
diff --git a/source/blender/usd/intern/usd_hierarchy_iterator.cc 
b/source/blender/usd/intern/usd_hierarchy_iterator.cc
index 3214f25386e..2202d132293 100644
--- a/source/blender/usd/intern/usd_hierarchy_iterator.cc
+++ b/source/blender/usd/intern/usd_hierarchy_iterator.cc
@@ -70,9 +70,6 @@ USDExporterContext 
USDHierarchyIterator::create_usd_export_context(const Hierarc
 
 AbstractHierarchyWriter *USDHierarchyIterator::create_xform_writer(const 
HierarchyContext *context)
 {
-  // printf(
-  // "\033[32;1mCREATE\033[0m %s at %s\n", context->object->id.name,
-  // context->export_path.c_str());
   return new USDTransformWriter(create_usd_export_context(context));
 }
 
@@ -102,9 +99,6 @@ AbstractHierarchyWriter 
*USDHierarchyIterator::create_data_writer(const Hierarch
 case OB_LATTICE:
 case OB_ARMATURE:
 case OB_GPENCIL:
-

[Bf-blender-cvs] [1416add5190] sybren-usd: Merge remote-tracking branch 'origin/master' into sybren-usd

2019-07-25 Thread Sybren A. Stüvel
Commit: 1416add5190d89e10dfbff34f922ea94a7c117ae
Author: Sybren A. Stüvel
Date:   Thu Jul 25 12:49:12 2019 +0200
Branches: sybren-usd
https://developer.blender.org/rB1416add5190d89e10dfbff34f922ea94a7c117ae

Merge remote-tracking branch 'origin/master' into sybren-usd

===



===



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


[Bf-blender-cvs] [33954860c88] sybren-usd: USD: replaced throwing temp C++ exception with BLI_assert() call

2019-07-25 Thread Sybren A. Stüvel
Commit: 33954860c88f75597f41ad98afd717e6ec36b156
Author: Sybren A. Stüvel
Date:   Thu Jul 25 14:46:13 2019 +0200
Branches: sybren-usd
https://developer.blender.org/rB33954860c88f75597f41ad98afd717e6ec36b156

USD: replaced throwing temp C++ exception with BLI_assert() call

The exception was for making things easier to debug for me. Now the issues
are gracefully ignored when things go bad, which is better for users.

No functional changes.

===

M   source/blender/usd/intern/usd_writer_mesh.cc

===

diff --git a/source/blender/usd/intern/usd_writer_mesh.cc 
b/source/blender/usd/intern/usd_writer_mesh.cc
index 3bcad763018..c50910ce8f9 100644
--- a/source/blender/usd/intern/usd_writer_mesh.cc
+++ b/source/blender/usd/intern/usd_writer_mesh.cc
@@ -6,6 +6,8 @@
 #include 
 
 extern "C" {
+#include "BLI_assert.h"
+
 #include "BKE_anim.h"
 #include "BKE_library.h"
 #include "BKE_material.h"
@@ -123,25 +125,27 @@ void USDGenericMeshWriter::write_mesh(HierarchyContext 
&context, Mesh *mesh)
 // This object data is instanced, just reference the original instead of 
writing a copy.
 if (context.export_path == context.original_export_path) {
   printf("USD ref error: export path is reference path: %s\n", 
context.export_path.c_str());
-  throw "JEEKL";
+  BLI_assert(!"USD reference error");
+  return;
 }
 pxr::SdfPath ref_path(context.original_export_path);
-if (usd_mesh.GetPrim().GetReferences().AddInternalReference(ref_path)) {
-  /* The material path will be of the form , 
which is outside the
-  subtree pointed to by ref_path. As a result, the referenced data is not 
allowed to point out
-  of its own subtree. It does work when we override the material with 
exactly the same path,
-  though.*/
-  assign_materials(context, usd_mesh, usd_mesh_data.face_groups);
+if (!usd_mesh.GetPrim().GetReferences().AddInternalReference(ref_path)) {
+  /* See this URL for a description fo why referencing may fail"
+   * 
https://graphics.pixar.com/usd/docs/api/class_usd_references.html#Usd_Failing_References
+   */
+  printf("USD Export warning: unable to add reference from %s to %s, not 
instancing object\n",
+ context.export_path.c_str(),
+ context.original_export_path.c_str());
   return;
 }
-/* See
-
https://graphics.pixar.com/usd/docs/api/class_usd_references.html#Usd_Failing_References
- * for a description fo why referencing may fail. */
-printf("USD Export warning: unable to add reference from %s to %s, not 
instancing object\n",
-   context.export_path.c_str(),
-   context.original_export_path.c_str());
-throw "JE MOEDER";
+/* The material path will be of the form , 
which is outside the
+subtree pointed to by ref_path. As a result, the referenced data is not 
allowed to point out
+of its own subtree. It does work when we override the material with 
exactly the same path,
+though.*/
+assign_materials(context, usd_mesh, usd_mesh_data.face_groups);
+return;
   }
+
   usd_mesh.CreatePointsAttr().Set(usd_mesh_data.points, timecode);
   usd_mesh.CreateFaceVertexCountsAttr().Set(usd_mesh_data.face_vertex_counts, 
timecode);
   usd_mesh.CreateFaceVertexIndicesAttr().Set(usd_mesh_data.face_indices, 
timecode);

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


[Bf-blender-cvs] [71966f856fa] sybren-usd: USD: simplified nested condition in USDAbstractWriter::write()

2019-07-25 Thread Sybren A. Stüvel
Commit: 71966f856fabfc44210663eb0ac820e676fbb192
Author: Sybren A. Stüvel
Date:   Thu Jul 25 14:48:02 2019 +0200
Branches: sybren-usd
https://developer.blender.org/rB71966f856fabfc44210663eb0ac820e676fbb192

USD: simplified nested condition in USDAbstractWriter::write()

By flipping a condition the code became much simpler.

No functional changes.

===

M   source/blender/usd/intern/usd_writer_abstract.cc

===

diff --git a/source/blender/usd/intern/usd_writer_abstract.cc 
b/source/blender/usd/intern/usd_writer_abstract.cc
index 4b5724e6ba2..c7c2496ea33 100644
--- a/source/blender/usd/intern/usd_writer_abstract.cc
+++ b/source/blender/usd/intern/usd_writer_abstract.cc
@@ -43,14 +43,13 @@ pxr::UsdTimeCode USDAbstractWriter::get_export_time_code() 
const
 
 void USDAbstractWriter::write(HierarchyContext &context)
 {
-  if (frame_has_been_written_) {
-if (!is_animated_) {
-  return;
-}
-  }
-  else {
+  if (!frame_has_been_written_) {
 is_animated_ = export_params.export_animation && 
check_is_animated(context);
   }
+  else if (!is_animated_) {
+/* A frame has alrady been written, and without animation one frame is 
enough. */
+return;
+  }
 
   do_write(context);

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


[Bf-blender-cvs] [adaf37f4d5d] sybren-usd: USD: Remove the "uv_" prefix from exported UV maps

2019-07-25 Thread Sybren A. Stüvel
Commit: adaf37f4d5da35b7ada286bdda9a1dfa5207639f
Author: Sybren A. Stüvel
Date:   Thu Jul 25 15:41:47 2019 +0200
Branches: sybren-usd
https://developer.blender.org/rBadaf37f4d5da35b7ada286bdda9a1dfa5207639f

USD: Remove the "uv_" prefix from exported UV maps

The primvar name is now the same as the UV Map name. This is to allow
the standard name "st" for texture coordinates by naming the UV Map as
such, without having to guess which UV Map is the "standard" one.

===

M   source/blender/usd/intern/usd_writer_mesh.cc

===

diff --git a/source/blender/usd/intern/usd_writer_mesh.cc 
b/source/blender/usd/intern/usd_writer_mesh.cc
index c50910ce8f9..f2ddbbd628f 100644
--- a/source/blender/usd/intern/usd_writer_mesh.cc
+++ b/source/blender/usd/intern/usd_writer_mesh.cc
@@ -99,8 +99,11 @@ void USDGenericMeshWriter::write_uv_maps(const Mesh *mesh, 
pxr::UsdGeomMesh usd_
   continue;
 }
 
-// UV coordinates are stored in a Primvar on the Mesh, and can be 
referenced from materials.
-pxr::TfToken primvar_name(pxr::TfMakeValidIdentifier(std::string("uv_") + 
layer->name));
+/* UV coordinates are stored in a Primvar on the Mesh, and can be 
referenced from materials.
+ * The primvar name is the same as the UV Map name. This is to allow the 
standard name "st"
+ * for texture coordinates by naming the UV Map as such, without having to 
guess which UV Map
+ * is the "standard" one. */
+pxr::TfToken primvar_name(pxr::TfMakeValidIdentifier(layer->name));
 pxr::UsdGeomPrimvar uv_coords_primvar = usd_mesh.CreatePrimvar(
 primvar_name, pxr::SdfValueTypeNames->TexCoord2fArray, 
pxr::UsdGeomTokens->faceVarying);

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


[Bf-blender-cvs] [f64f0506b72] sybren-usd: USD: Export mesh normals

2019-07-25 Thread Sybren A. Stüvel
Commit: f64f0506b725412419dc6de55d728fecafdc5b35
Author: Sybren A. Stüvel
Date:   Thu Jul 25 16:31:56 2019 +0200
Branches: sybren-usd
https://developer.blender.org/rBf64f0506b725412419dc6de55d728fecafdc5b35

USD: Export mesh normals

We now write face-varying mesh normals to USD. When the mesh has custom
loop normals those are written. Otherwise the poly flag `ME_SMOOTH` is
inspected to determine the normals.

This commits also changes the subdivision scheme from the default value
'Catmull Clark' to 'None', indicating we're exporting a polygonal mesh.
This is necessary for USD to understand our normals; otherwise the mesh
is always rendered smooth. In the future we may want to expose this
choice of subdivision scheme to the user, or auto-detect it when we
actually support exporting pre-subdivision meshes.

A possible optimisation could be to inspect whether all polygons are
smooth or flat, and mark the USD mesh as such. This can be added when
needed.

===

M   source/blender/usd/intern/usd_writer_mesh.cc
M   source/blender/usd/intern/usd_writer_mesh.h

===

diff --git a/source/blender/usd/intern/usd_writer_mesh.cc 
b/source/blender/usd/intern/usd_writer_mesh.cc
index f2ddbbd628f..752a5a6b7c5 100644
--- a/source/blender/usd/intern/usd_writer_mesh.cc
+++ b/source/blender/usd/intern/usd_writer_mesh.cc
@@ -7,10 +7,13 @@
 
 extern "C" {
 #include "BLI_assert.h"
+#include "BLI_math_vector.h"
 
 #include "BKE_anim.h"
+#include "BKE_customdata.h"
 #include "BKE_library.h"
 #include "BKE_material.h"
+#include "BKE_mesh.h"
 
 #include "DEG_depsgraph.h"
 
@@ -160,12 +163,14 @@ void USDGenericMeshWriter::write_mesh(HierarchyContext 
&context, Mesh *mesh)
   }
 
   write_uv_maps(mesh, usd_mesh);
+  write_normals(mesh, usd_mesh);
 
   // TODO(Sybren): figure out what happens when the face groups change.
   if (frame_has_been_written_) {
 return;
   }
 
+  usd_mesh.CreateSubdivisionSchemeAttr().Set(pxr::UsdGeomTokens->none);
   assign_materials(context, usd_mesh, usd_mesh_data.face_groups);
 }
 
@@ -297,6 +302,50 @@ void USDGenericMeshWriter::assign_materials(
   }
 }
 
+void USDGenericMeshWriter::write_normals(const Mesh *mesh, pxr::UsdGeomMesh 
usd_mesh)
+{
+  pxr::UsdTimeCode timecode = get_export_time_code();
+  const float(*lnors)[3] = 
static_cast(CustomData_get_layer(&mesh->ldata, CD_NORMAL));
+
+  pxr::VtVec3fArray loop_normals;
+  loop_normals.reserve(mesh->totloop);
+
+  if (lnors != nullptr) {
+/* Export custom loop normals. */
+for (int loop_idx = 0, totloop = mesh->totloop; loop_idx < totloop; 
++loop_idx) {
+  loop_normals.push_back(pxr::GfVec3f(lnors[loop_idx]));
+}
+  }
+  else {
+/* Compute the loop normals based on the 'smooth' flag. */
+float normal[3];
+MPoly *mpoly = mesh->mpoly;
+const MVert *mvert = mesh->mvert;
+for (int poly_idx = 0, totpoly = mesh->totpoly; poly_idx < totpoly; 
++poly_idx, ++mpoly) {
+  MLoop *mloop = mesh->mloop + mpoly->loopstart;
+
+  if ((mpoly->flag & ME_SMOOTH) == 0) {
+/* Flat shaded, use common normal for all verts. */
+BKE_mesh_calc_poly_normal(mpoly, mloop, mvert, normal);
+pxr::GfVec3f pxr_normal(normal);
+for (int loop_idx = 0; loop_idx < mpoly->totloop; ++loop_idx) {
+  loop_normals.push_back(pxr_normal);
+}
+  }
+  else {
+/* Smooth shaded, use individual vert normals. */
+for (int loop_idx = 0; loop_idx < mpoly->totloop; ++loop_idx, ++mloop) 
{
+  normal_short_to_float_v3(normal, mvert[mloop->v].no);
+  loop_normals.push_back(pxr::GfVec3f(normal));
+}
+  }
+}
+  }
+
+  usd_mesh.CreateNormalsAttr().Set(loop_normals, timecode);
+  usd_mesh.SetNormalsInterpolation(pxr::UsdGeomTokens->faceVarying);
+}
+
 USDMeshWriter::USDMeshWriter(const USDExporterContext &ctx) : 
USDGenericMeshWriter(ctx)
 {
 }
diff --git a/source/blender/usd/intern/usd_writer_mesh.h 
b/source/blender/usd/intern/usd_writer_mesh.h
index aea49fe9523..2eddf114bf4 100644
--- a/source/blender/usd/intern/usd_writer_mesh.h
+++ b/source/blender/usd/intern/usd_writer_mesh.h
@@ -26,6 +26,7 @@ class USDGenericMeshWriter : public USDAbstractWriter {
 pxr::UsdGeomMesh usd_mesh,
 const std::map 
&usd_face_groups);
   void write_uv_maps(const Mesh *mesh, pxr::UsdGeomMesh usd_mesh);
+  void write_normals(const Mesh *mesh, pxr::UsdGeomMesh usd_mesh);
 };
 
 class USDMeshWriter : public USDGenericMeshWriter {

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


[Bf-blender-cvs] [a3107a0bb13] sybren-usd: USD: Cleanup, removed unnecessary `struct` keyword

2019-07-25 Thread Sybren A. Stüvel
Commit: a3107a0bb13e8c9b7b8e9d5f5f13319d361d101f
Author: Sybren A. Stüvel
Date:   Thu Jul 25 16:32:12 2019 +0200
Branches: sybren-usd
https://developer.blender.org/rBa3107a0bb13e8c9b7b8e9d5f5f13319d361d101f

USD: Cleanup, removed unnecessary `struct` keyword

No functional changes.

===

M   source/blender/usd/intern/usd_writer_mesh.cc

===

diff --git a/source/blender/usd/intern/usd_writer_mesh.cc 
b/source/blender/usd/intern/usd_writer_mesh.cc
index 752a5a6b7c5..4c2994ea29d 100644
--- a/source/blender/usd/intern/usd_writer_mesh.cc
+++ b/source/blender/usd/intern/usd_writer_mesh.cc
@@ -174,7 +174,7 @@ void USDGenericMeshWriter::write_mesh(HierarchyContext 
&context, Mesh *mesh)
   assign_materials(context, usd_mesh, usd_mesh_data.face_groups);
 }
 
-static void get_vertices(const Mesh *mesh, struct USDMeshData &usd_mesh_data)
+static void get_vertices(const Mesh *mesh, USDMeshData &usd_mesh_data)
 {
   usd_mesh_data.points.reserve(mesh->totvert);
 
@@ -184,7 +184,7 @@ static void get_vertices(const Mesh *mesh, struct 
USDMeshData &usd_mesh_data)
   }
 }
 
-static void get_loops_polys(const Mesh *mesh, struct USDMeshData 
&usd_mesh_data)
+static void get_loops_polys(const Mesh *mesh, USDMeshData &usd_mesh_data)
 {
   /* Only construct face groups (a.k.a. geometry subsets) when we need them 
for material
* assignments. */
@@ -208,7 +208,7 @@ static void get_loops_polys(const Mesh *mesh, struct 
USDMeshData &usd_mesh_data)
   }
 }
 
-static void get_creases(const Mesh *mesh, struct USDMeshData &usd_mesh_data)
+static void get_creases(const Mesh *mesh, USDMeshData &usd_mesh_data)
 {
   const float factor = 1.0f / 255.0f;
 
@@ -233,7 +233,7 @@ static void get_creases(const Mesh *mesh, struct 
USDMeshData &usd_mesh_data)
   }
 }
 
-void USDGenericMeshWriter::get_geometry_data(const Mesh *mesh, struct 
USDMeshData &usd_mesh_data)
+void USDGenericMeshWriter::get_geometry_data(const Mesh *mesh, USDMeshData 
&usd_mesh_data)
 {
   get_vertices(mesh, usd_mesh_data);
   get_loops_polys(mesh, usd_mesh_data);

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


[Bf-blender-cvs] [de2e80a1bfa] sybren-usd: USD: Export vertex velocities for fluid simulations

2019-07-26 Thread Sybren A. Stüvel
Commit: de2e80a1bfaf8fdd9e28f6fb345bc586cd2f5b2d
Author: Sybren A. Stüvel
Date:   Fri Jul 26 11:42:03 2019 +0200
Branches: sybren-usd
https://developer.blender.org/rBde2e80a1bfaf8fdd9e28f6fb345bc586cd2f5b2d

USD: Export vertex velocities for fluid simulations

Currently only fluid simulations have explicit vertex velocities. This
is the most important case for exporting velocities, though, as the
baked mesh changes topology all the time, and thus computing the
velocities at import time in a post-processing step is hard.

===

M   source/blender/usd/intern/usd_writer_mesh.cc
M   source/blender/usd/intern/usd_writer_mesh.h

===

diff --git a/source/blender/usd/intern/usd_writer_mesh.cc 
b/source/blender/usd/intern/usd_writer_mesh.cc
index 4c2994ea29d..8cd7f049a5d 100644
--- a/source/blender/usd/intern/usd_writer_mesh.cc
+++ b/source/blender/usd/intern/usd_writer_mesh.cc
@@ -14,11 +14,14 @@ extern "C" {
 #include "BKE_library.h"
 #include "BKE_material.h"
 #include "BKE_mesh.h"
+#include "BKE_modifier.h"
 
 #include "DEG_depsgraph.h"
 
 #include "DNA_mesh_types.h"
 #include "DNA_meshdata_types.h"
+#include "DNA_modifier_types.h"
+#include "DNA_object_fluidsim_types.h"
 #include "DNA_particle_types.h"
 }
 
@@ -164,6 +167,7 @@ void USDGenericMeshWriter::write_mesh(HierarchyContext 
&context, Mesh *mesh)
 
   write_uv_maps(mesh, usd_mesh);
   write_normals(mesh, usd_mesh);
+  write_surface_velocity(context.object, mesh, usd_mesh);
 
   // TODO(Sybren): figure out what happens when the face groups change.
   if (frame_has_been_written_) {
@@ -346,6 +350,48 @@ void USDGenericMeshWriter::write_normals(const Mesh *mesh, 
pxr::UsdGeomMesh usd_
   usd_mesh.SetNormalsInterpolation(pxr::UsdGeomTokens->faceVarying);
 }
 
+void USDGenericMeshWriter::write_surface_velocity(Object *object,
+  const Mesh *mesh,
+  pxr::UsdGeomMesh usd_mesh)
+{
+  /* Only velocities from the fluid simulation are exported. This is the most 
important case,
+   * though, as the baked mesh changes topology all the time, and thus 
computing the velocities
+   * at import time in a post-processing step is hard. */
+  ModifierData *md = modifiers_findByType(object, eModifierType_Fluidsim);
+  if (md == nullptr) {
+return;
+  }
+
+  /* Check that the fluid sim modifier is enabled and has useful data. */
+  const bool use_render = (DEG_get_mode(depsgraph) == DAG_EVAL_RENDER);
+  const ModifierMode required_mode = use_render ? eModifierMode_Render : 
eModifierMode_Realtime;
+  const Scene *scene = DEG_get_evaluated_scene(depsgraph);
+  if (!modifier_isEnabled(scene, md, required_mode)) {
+return;
+  }
+  FluidsimModifierData *fsmd = reinterpret_cast(md);
+  if (!fsmd->fss || fsmd->fss->type != OB_FLUIDSIM_DOMAIN) {
+return;
+  }
+  FluidsimSettings *fss = fsmd->fss;
+  if (!fss->meshVelocities) {
+return;
+  }
+
+  /* Export per-vertex velocity vectors. */
+  pxr::VtVec3fArray usd_velocities;
+  usd_velocities.reserve(mesh->totvert);
+
+  FluidVertexVelocity *mesh_velocities = fss->meshVelocities;
+  for (int vertex_idx = 0, totvert = mesh->totvert; vertex_idx < totvert;
+   ++vertex_idx, ++mesh_velocities) {
+usd_velocities.push_back(pxr::GfVec3f(mesh_velocities->vel));
+  }
+
+  pxr::UsdTimeCode timecode = get_export_time_code();
+  usd_mesh.CreateVelocitiesAttr().Set(usd_velocities, timecode);
+}
+
 USDMeshWriter::USDMeshWriter(const USDExporterContext &ctx) : 
USDGenericMeshWriter(ctx)
 {
 }
diff --git a/source/blender/usd/intern/usd_writer_mesh.h 
b/source/blender/usd/intern/usd_writer_mesh.h
index 2eddf114bf4..76e91dea522 100644
--- a/source/blender/usd/intern/usd_writer_mesh.h
+++ b/source/blender/usd/intern/usd_writer_mesh.h
@@ -27,6 +27,7 @@ class USDGenericMeshWriter : public USDAbstractWriter {
 const std::map 
&usd_face_groups);
   void write_uv_maps(const Mesh *mesh, pxr::UsdGeomMesh usd_mesh);
   void write_normals(const Mesh *mesh, pxr::UsdGeomMesh usd_mesh);
+  void write_surface_velocity(Object *object, const Mesh *mesh, 
pxr::UsdGeomMesh usd_mesh);
 };
 
 class USDMeshWriter : public USDGenericMeshWriter {

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


[Bf-blender-cvs] [df1c90fed5e] sybren-usd: USD: Allow user to disable export of UV maps and mesh normals

2019-07-26 Thread Sybren A. Stüvel
Commit: df1c90fed5e232c5c5c8d1b047971e6537b2ffb0
Author: Sybren A. Stüvel
Date:   Fri Jul 26 16:46:38 2019 +0200
Branches: sybren-usd
https://developer.blender.org/rBdf1c90fed5e232c5c5c8d1b047971e6537b2ffb0

USD: Allow user to disable export of UV maps and mesh normals

The UV maps and mesh normals take up a significant amount of space, so
it's better to make them optional. They're still enabled by default,
though.

Comparison: a shot of Spring (03_035_A to be exact) is 1.2 GiB  when
exported with UVs and normals, and 262 MiB without. We probably have
room for optimisation of written UVs and normals.

===

M   source/blender/editors/io/io_usd.c
M   source/blender/usd/intern/usd_writer_mesh.cc
M   source/blender/usd/usd.h

===

diff --git a/source/blender/editors/io/io_usd.c 
b/source/blender/editors/io/io_usd.c
index 71c65eef4f6..8d788b52e07 100644
--- a/source/blender/editors/io/io_usd.c
+++ b/source/blender/editors/io/io_usd.c
@@ -34,6 +34,9 @@
 #  include "RNA_access.h"
 #  include "RNA_define.h"
 
+#  include "UI_interface.h"
+#  include "UI_resources.h"
+
 #  include "WM_api.h"
 #  include "WM_types.h"
 
@@ -102,12 +105,18 @@ static int wm_usd_export_exec(bContext *C, wmOperator *op)
   const bool visible_objects_only = RNA_boolean_get(op->ptr, 
"visible_objects_only");
   const bool export_animation = RNA_boolean_get(op->ptr, "export_animation");
   const bool export_hair = RNA_boolean_get(op->ptr, "export_hair");
+  const bool export_uvmaps = RNA_boolean_get(op->ptr, "export_uvmaps");
+  const bool export_normals = RNA_boolean_get(op->ptr, "export_normals");
+  const bool export_materials = RNA_boolean_get(op->ptr, "export_materials");
   const bool use_instancing = RNA_boolean_get(op->ptr, "use_instancing");
   const bool evaluation_mode = RNA_enum_get(op->ptr, "evaluation_mode");
 
   struct USDExportParams params = {
   export_animation,
   export_hair,
+  export_uvmaps,
+  export_normals,
+  export_materials,
   selected_objects_only,
   visible_objects_only,
   use_instancing,
@@ -119,6 +128,30 @@ static int wm_usd_export_exec(bContext *C, wmOperator *op)
   return as_background_job || ok ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
 }
 
+static void wm_usd_export_draw(bContext *UNUSED(C), wmOperator *op)
+{
+  uiLayout *layout = op->layout;
+  uiLayout *col;
+  struct PointerRNA *ptr = op->ptr;
+
+  uiLayoutSetPropSep(layout, true);
+
+  col = uiLayoutColumn(layout, true);
+  uiItemR(col, ptr, "selected_objects_only", 0, NULL, ICON_NONE);
+  uiItemR(col, ptr, "visible_objects_only", 0, NULL, ICON_NONE);
+
+  col = uiLayoutColumn(layout, true);
+  uiItemR(col, ptr, "export_animation", 0, NULL, ICON_NONE);
+  uiItemR(col, ptr, "export_hair", 0, NULL, ICON_NONE);
+  uiItemR(col, ptr, "export_uvmaps", 0, NULL, ICON_NONE);
+  uiItemR(col, ptr, "export_normals", 0, NULL, ICON_NONE);
+  uiItemR(col, ptr, "export_materials", 0, NULL, ICON_NONE);
+  uiItemR(col, ptr, "use_instancing", 0, NULL, ICON_NONE);
+
+  col = uiLayoutColumn(layout, true);
+  uiItemR(col, ptr, "evaluation_mode", 0, NULL, ICON_NONE);
+}
+
 void WM_OT_usd_export(struct wmOperatorType *ot)
 {
   ot->name = "Export USD";
@@ -128,6 +161,7 @@ void WM_OT_usd_export(struct wmOperatorType *ot)
   ot->invoke = wm_usd_export_invoke;
   ot->exec = wm_usd_export_exec;
   ot->poll = WM_operator_winactive;
+  ot->ui = wm_usd_export_draw;
 
   WM_operator_properties_filesel(
   ot, 0, FILE_BLENDER, FILE_SAVE, WM_FILESEL_FILEPATH, 
FILE_DEFAULTDISPLAY, FILE_SORT_ALPHA);
@@ -150,11 +184,29 @@ void WM_OT_usd_export(struct wmOperatorType *ot)
   "export_animation",
   false,
   "Export Animation",
-  "When true, the render frame range is exported. When false, 
only the current "
+  "When checked, the render frame range is exported. When 
false, only the current "
   "frame is exported");
-
-  RNA_def_boolean(
-  ot->srna, "export_hair", false, "Export Hair", "When true, hair is 
exported as USD curves");
+  RNA_def_boolean(ot->srna,
+  "export_hair",
+  false,
+  "Export Hair",
+  "When checked, hair is exported as USD curves");
+  RNA_def_boolean(ot->srna,
+  "export_uvmaps",
+  true,
+  "Export UV Maps",
+  "When checked,

[Bf-blender-cvs] [205125bc3d3] sybren-usd: Merge remote-tracking branch 'origin/master' into sybren-usd

2019-07-30 Thread Sybren A. Stüvel
Commit: 205125bc3d38286ac601a1824e3414a129310b97
Author: Sybren A. Stüvel
Date:   Tue Jul 30 12:35:31 2019 +0200
Branches: sybren-usd
https://developer.blender.org/rB205125bc3d38286ac601a1824e3414a129310b97

Merge remote-tracking branch 'origin/master' into sybren-usd

===



===



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


[Bf-blender-cvs] [0dece50667f] master: Fix T65717: Alembic (camera - also mesh) import scale issue

2019-07-30 Thread Sybren A. Stüvel
Commit: 0dece50667f1c8bc4d2a1fb73f3d4eaa287922df
Author: Sybren A. Stüvel
Date:   Thu Jul 18 15:39:50 2019 +0200
Branches: master
https://developer.blender.org/rB0dece50667f1c8bc4d2a1fb73f3d4eaa287922df

Fix T65717: Alembic (camera - also mesh) import scale issue

The w-component of the translation column of the scaled matrix wasn't
set to 1.0, which, apart from being incorrect, caused drawing problems.

Reviewed By: brecht

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

===

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 54450ce1cb2..7b0d94a2305 100644
--- a/source/blender/alembic/intern/abc_object.cc
+++ b/source/blender/alembic/intern/abc_object.cc
@@ -343,8 +343,7 @@ void AbcObjectReader::read_matrix(float r_mat[4][4],
 /* Only apply scaling to root objects, parenting will propagate it. */
 float scale_mat[4][4];
 scale_m4_fl(scale_mat, scale);
-scale_mat[3][3] = scale; /* scale translations too */
-mul_m4_m4m4(r_mat, r_mat, scale_mat);
+mul_m4_m4m4(r_mat, scale_mat, r_mat);
   }
 
   is_constant = schema.isConstant();

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


[Bf-blender-cvs] [7f552be7d1b] master: Alembic: removal of always-zero parameter

2019-07-30 Thread Sybren A. Stüvel
Commit: 7f552be7d1bd4076263521c76c2aa3cab9b383c1
Author: Sybren A. Stüvel
Date:   Thu Jul 4 11:50:08 2019 +0200
Branches: master
https://developer.blender.org/rB7f552be7d1bd4076263521c76c2aa3cab9b383c1

Alembic: removal of always-zero parameter

The `poly_start` parameter was always 0, so adding it to a poly index
from Alembic is a no-op.

No functional changes.

===

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

===

diff --git a/source/blender/alembic/intern/abc_mesh.cc 
b/source/blender/alembic/intern/abc_mesh.cc
index b0129a358ec..b5d5057a8d1 100644
--- a/source/blender/alembic/intern/abc_mesh.cc
+++ b/source/blender/alembic/intern/abc_mesh.cc
@@ -1085,7 +1085,7 @@ void AbcMeshReader::readObjectData(Main *bmain, const 
Alembic::Abc::ISampleSelec
 BKE_mesh_validate(mesh, false, false);
   }
 
-  readFaceSetsSample(bmain, mesh, 0, sample_sel);
+  readFaceSetsSample(bmain, mesh, sample_sel);
 
   if (has_animations(m_schema, m_settings)) {
 addCacheModifier();
@@ -1189,7 +1189,7 @@ Mesh *AbcMeshReader::read_mesh(Mesh *existing_mesh,
 size_t num_polys = new_mesh->totpoly;
 if (num_polys > 0) {
   std::map mat_map;
-  assign_facesets_to_mpoly(sample_sel, 0, new_mesh->mpoly, num_polys, 
mat_map);
+  assign_facesets_to_mpoly(sample_sel, new_mesh->mpoly, num_polys, 
mat_map);
 }
 
 return new_mesh;
@@ -1203,7 +1203,6 @@ Mesh *AbcMeshReader::read_mesh(Mesh *existing_mesh,
 }
 
 void AbcMeshReader::assign_facesets_to_mpoly(const ISampleSelector &sample_sel,
- size_t poly_start,
  MPoly *mpoly,
  int totpoly,
  std::map 
&r_mat_map)
@@ -1239,7 +1238,7 @@ void AbcMeshReader::assign_facesets_to_mpoly(const 
ISampleSelector &sample_sel,
 const size_t num_group_faces = group_faces->size();
 
 for (size_t l = 0; l < num_group_faces; l++) {
-  size_t pos = (*group_faces)[l] + poly_start;
+  size_t pos = (*group_faces)[l];
 
   if (pos >= totpoly) {
 std::cerr << "Faceset overflow on " << faceset.getName() << '\n';
@@ -1252,13 +1251,10 @@ void AbcMeshReader::assign_facesets_to_mpoly(const 
ISampleSelector &sample_sel,
   }
 }
 
-void AbcMeshReader::readFaceSetsSample(Main *bmain,
-   Mesh *mesh,
-   size_t poly_start,
-   const ISampleSelector &sample_sel)
+void AbcMeshReader::readFaceSetsSample(Main *bmain, Mesh *mesh, const 
ISampleSelector &sample_sel)
 {
   std::map mat_map;
-  assign_facesets_to_mpoly(sample_sel, poly_start, mesh->mpoly, mesh->totpoly, 
mat_map);
+  assign_facesets_to_mpoly(sample_sel, mesh->mpoly, mesh->totpoly, mat_map);
   utils::assign_materials(bmain, m_object, mat_map);
 }
 
diff --git a/source/blender/alembic/intern/abc_mesh.h 
b/source/blender/alembic/intern/abc_mesh.h
index 6cbaeea6536..859ab121eb6 100644
--- a/source/blender/alembic/intern/abc_mesh.h
+++ b/source/blender/alembic/intern/abc_mesh.h
@@ -114,11 +114,9 @@ class AbcMeshReader : public AbcObjectReader {
  private:
   void readFaceSetsSample(Main *bmain,
   Mesh *mesh,
-  size_t poly_start,
   const Alembic::AbcGeom::ISampleSelector &sample_sel);
 
   void assign_facesets_to_mpoly(const Alembic::Abc::ISampleSelector 
&sample_sel,
-size_t poly_start,
 MPoly *mpoly,
 int totpoly,
 std::map &r_mat_map);

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


[Bf-blender-cvs] [d65a4b5990c] master: Alembic: use `r_` prefix for return variables

2019-07-30 Thread Sybren A. Stüvel
Commit: d65a4b5990c28365e89ac0495a31cac4e042704f
Author: Sybren A. Stüvel
Date:   Thu Jul 4 11:51:13 2019 +0200
Branches: master
https://developer.blender.org/rBd65a4b5990c28365e89ac0495a31cac4e042704f

Alembic: use `r_` prefix for return variables

No functional changes.

===

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 b5d5057a8d1..39d9f9d768e 100644
--- a/source/blender/alembic/intern/abc_mesh.cc
+++ b/source/blender/alembic/intern/abc_mesh.cc
@@ -122,7 +122,7 @@ static void get_vertices(struct Mesh *mesh, 
std::vector &points)
 static void get_topology(struct Mesh *mesh,
  std::vector &poly_verts,
  std::vector &loop_counts,
- bool &smooth_normal)
+ bool &r_smooth_normal)
 {
   const int num_poly = mesh->totpoly;
   const int num_loops = mesh->totloop;
@@ -139,7 +139,7 @@ static void get_topology(struct Mesh *mesh,
 MPoly &poly = mpoly[i];
 loop_counts.push_back(poly.totloop);
 
-smooth_normal |= ((poly.flag & ME_SMOOTH) != 0);
+r_smooth_normal |= ((poly.flag & ME_SMOOTH) != 0);
 
 MLoop *loop = mloop + poly.loopstart + (poly.totloop - 1);
 
@@ -995,7 +995,7 @@ static void read_mesh_sample(const std::string 
&iobject_full_name,
  const IPolyMeshSchema &schema,
  const ISampleSelector &selector,
  CDStreamConfig &config,
- bool &do_normals)
+ bool &r_do_normals)
 {
   const IPolyMeshSchema::Sample sample = schema.getValue(selector);
 
@@ -1006,7 +1006,7 @@ static void read_mesh_sample(const std::string 
&iobject_full_name,
 
   read_normals_params(abc_mesh_data, schema.getNormalsParam(), selector);
 
-  do_normals = (abc_mesh_data.face_normals != NULL);
+  r_do_normals = (abc_mesh_data.face_normals != NULL);
 
   get_weight_and_index(config, schema.getTimeSampling(), 
schema.getNumSamples());

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


[Bf-blender-cvs] [3568d56bccc] master: Alembic: transformed chain-of-ifs into switch statement

2019-07-30 Thread Sybren A. Stüvel
Commit: 3568d56bccc556e04c61d8f6ac3f005b0ff838b7
Author: Sybren A. Stüvel
Date:   Thu Jul 4 11:53:17 2019 +0200
Branches: master
https://developer.blender.org/rB3568d56bccc556e04c61d8f6ac3f005b0ff838b7

Alembic: transformed chain-of-ifs into switch statement

By having a switch statement that lists all the values of the enum, it is
clear which cases we're not handling, and it also allows for warnings in
the future when the enum expands.

No functional changes.

===

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 39d9f9d768e..1903b5149c5 100644
--- a/source/blender/alembic/intern/abc_mesh.cc
+++ b/source/blender/alembic/intern/abc_mesh.cc
@@ -919,11 +919,19 @@ ABC_INLINE void read_normals_params(AbcMeshData &abc_data,
 
   IN3fGeomParam::Sample normsamp = normals.getExpandedValue(selector);
 
-  if (normals.getScope() == kFacevaryingScope) {
-abc_data.face_normals = normsamp.getVals();
-  }
-  else if ((normals.getScope() == kVertexScope) || (normals.getScope() == 
kVaryingScope)) {
-abc_data.vertex_normals = N3fArraySamplePtr();
+  Alembic::AbcGeom::GeometryScope scope = normals.getScope();
+  switch (scope) {
+case Alembic::AbcGeom::kFacevaryingScope:
+  abc_data.face_normals = normsamp.getVals();
+  break;
+case Alembic::AbcGeom::kVertexScope:
+case Alembic::AbcGeom::kVaryingScope:
+  abc_data.vertex_normals = N3fArraySamplePtr();
+  break;
+case Alembic::AbcGeom::kConstantScope:
+case Alembic::AbcGeom::kUniformScope:
+case Alembic::AbcGeom::kUnknownScope:
+  break;
   }
 }

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


[Bf-blender-cvs] [e74847e6bb5] master: Alembic: changed 'void *user_data' to 'Mesh *mesh'

2019-07-30 Thread Sybren A. Stüvel
Commit: e74847e6bb5cea24def9e544a3fb2bc90150aeaf
Author: Sybren A. Stüvel
Date:   Thu Jul 4 12:04:39 2019 +0200
Branches: master
https://developer.blender.org/rBe74847e6bb5cea24def9e544a3fb2bc90150aeaf

Alembic: changed 'void *user_data' to 'Mesh *mesh'

The only thing that is stored in this pointer is a `Mesh*`, and casting
it from/to `void*` is unnecessary and confusing. Maybe the entire
CDStreamConfig class could/should be removed at some point.

No functional changes.

===

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

===

diff --git a/source/blender/alembic/intern/abc_customdata.cc 
b/source/blender/alembic/intern/abc_customdata.cc
index 20ca659d32f..63887d36381 100644
--- a/source/blender/alembic/intern/abc_customdata.cc
+++ b/source/blender/alembic/intern/abc_customdata.cc
@@ -353,7 +353,7 @@ static void read_custom_data_mcols(const std::string 
&iobject_full_name,
 
   /* Read the vertex colors */
   void *cd_data = config.add_customdata_cb(
-  config.user_data, prop_header.getName().c_str(), CD_MLOOPCOL);
+  config.mesh, prop_header.getName().c_str(), CD_MLOOPCOL);
   MCol *cfaces = static_cast(cd_data);
   MPoly *mpolys = config.mpoly;
   MLoop *mloops = config.mloop;
@@ -437,8 +437,7 @@ static void read_custom_data_uvs(const ICompoundProperty 
&prop,
 return;
   }
 
-  void *cd_data = config.add_customdata_cb(
-  config.user_data, prop_header.getName().c_str(), CD_MLOOPUV);
+  void *cd_data = config.add_customdata_cb(config.mesh, 
prop_header.getName().c_str(), CD_MLOOPUV);
 
   read_uvs(config, cd_data, sample.getVals(), sample.getIndices());
 }
diff --git a/source/blender/alembic/intern/abc_customdata.h 
b/source/blender/alembic/intern/abc_customdata.h
index c36029d5116..0ffafa8848e 100644
--- a/source/blender/alembic/intern/abc_customdata.h
+++ b/source/blender/alembic/intern/abc_customdata.h
@@ -28,6 +28,7 @@
 #include 
 
 struct CustomData;
+struct Mesh;
 struct MLoop;
 struct MLoopUV;
 struct MPoly;
@@ -60,8 +61,8 @@ struct CDStreamConfig {
   /* TODO(kevin): might need a better way to handle adding and/or updating
* custom datas such that it updates the custom data holder and its pointers
* properly. */
-  void *user_data;
-  void *(*add_customdata_cb)(void *user_data, const char *name, int data_type);
+  Mesh *mesh;
+  void *(*add_customdata_cb)(Mesh *mesh, const char *name, int data_type);
 
   float weight;
   float time;
@@ -75,7 +76,7 @@ struct CDStreamConfig {
 totpoly(0),
 totvert(0),
 pack_uvs(false),
-user_data(NULL),
+mesh(NULL),
 add_customdata_cb(NULL),
 weight(0.0f),
 time(0.0f),
diff --git a/source/blender/alembic/intern/abc_mesh.cc 
b/source/blender/alembic/intern/abc_mesh.cc
index 1903b5149c5..13cc670b7dc 100644
--- a/source/blender/alembic/intern/abc_mesh.cc
+++ b/source/blender/alembic/intern/abc_mesh.cc
@@ -900,7 +900,7 @@ ABC_INLINE void read_uvs_params(CDStreamConfig &config,
   name = uv.getName();
 }
 
-void *cd_ptr = config.add_customdata_cb(config.user_data, name.c_str(), 
CD_MLOOPUV);
+void *cd_ptr = config.add_customdata_cb(config.mesh, name.c_str(), 
CD_MLOOPUV);
 config.mloopuv = static_cast(cd_ptr);
   }
 }
@@ -960,9 +960,8 @@ static void set_smooth_poly_flag(Mesh *mesh)
   }
 }
 
-static void *add_customdata_cb(void *user_data, const char *name, int 
data_type)
+static void *add_customdata_cb(Mesh *mesh, const char *name, int data_type)
 {
-  Mesh *mesh = static_cast(user_data);
   CustomDataType cd_data_type = static_cast(data_type);
   void *cd_ptr;
   CustomData *loopdata;
@@ -1047,7 +1046,7 @@ CDStreamConfig get_config(Mesh *mesh)
 
   BLI_assert(mesh->mvert || mesh->totvert == 0);
 
-  config.user_data = mesh;
+  config.mesh = mesh;
   config.mvert = mesh->mvert;
   config.mloop = mesh->mloop;
   config.mpoly = mesh->mpoly;

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


[Bf-blender-cvs] [dde978d1491] master: Cleanup: Alembic: renamed 'smooth_normals' to 'export_loop_normals'

2019-07-30 Thread Sybren A. Stüvel
Commit: dde978d1491b1ff5a5c01eb29eb6cf46446738f8
Author: Sybren A. Stüvel
Date:   Wed Jul 10 10:35:39 2019 +0200
Branches: master
https://developer.blender.org/rBdde978d1491b1ff5a5c01eb29eb6cf46446738f8

Cleanup: Alembic: renamed 'smooth_normals' to 'export_loop_normals'

The name now indicates what happens when the variable is set to true.

No functional changes.

===

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 13cc670b7dc..e4431bde2f6 100644
--- a/source/blender/alembic/intern/abc_mesh.cc
+++ b/source/blender/alembic/intern/abc_mesh.cc
@@ -122,7 +122,7 @@ static void get_vertices(struct Mesh *mesh, 
std::vector &points)
 static void get_topology(struct Mesh *mesh,
  std::vector &poly_verts,
  std::vector &loop_counts,
- bool &r_smooth_normal)
+ bool &r_export_loop_normals)
 {
   const int num_poly = mesh->totpoly;
   const int num_loops = mesh->totloop;
@@ -139,7 +139,7 @@ static void get_topology(struct Mesh *mesh,
 MPoly &poly = mpoly[i];
 loop_counts.push_back(poly.totloop);
 
-r_smooth_normal |= ((poly.flag & ME_SMOOTH) != 0);
+r_export_loop_normals |= (poly.flag & ME_SMOOTH) != 0;
 
 MLoop *loop = mloop + poly.loopstart + (poly.totloop - 1);
 
@@ -411,10 +411,10 @@ void AbcGenericMeshWriter::writeMesh(struct Mesh *mesh)
   std::vector poly_verts, loop_counts;
   std::vector velocities;
 
-  bool smooth_normal = false;
+  bool export_loop_normals = false;
 
   get_vertices(mesh, points);
-  get_topology(mesh, poly_verts, loop_counts, smooth_normal);
+  get_topology(mesh, poly_verts, loop_counts, export_loop_normals);
 
   if (m_first_frame && m_settings.export_face_sets) {
 writeFaceSets(mesh, m_mesh_schema);
@@ -442,7 +442,7 @@ void AbcGenericMeshWriter::writeMesh(struct Mesh *mesh)
   }
 
   if (m_settings.export_normals) {
-if (smooth_normal) {
+if (export_loop_normals) {
   get_loop_normals(mesh, normals);
 }
 else {
@@ -451,7 +451,7 @@ void AbcGenericMeshWriter::writeMesh(struct Mesh *mesh)
 
 ON3fGeomParam::Sample normals_sample;
 if (!normals.empty()) {
-  normals_sample.setScope((smooth_normal) ? kFacevaryingScope : 
kVertexScope);
+  normals_sample.setScope(export_loop_normals ? kFacevaryingScope : 
kVertexScope);
   normals_sample.setVals(V3fArraySample(normals));
 }
 
@@ -477,10 +477,10 @@ void AbcGenericMeshWriter::writeSubD(struct Mesh *mesh)
   std::vector poly_verts, loop_counts;
   std::vector crease_indices, crease_lengths;
 
-  bool smooth_normal = false;
+  bool export_loop_normals = false;
 
   get_vertices(mesh, points);
-  get_topology(mesh, poly_verts, loop_counts, smooth_normal);
+  get_topology(mesh, poly_verts, loop_counts, export_loop_normals);
   get_creases(mesh, crease_indices, crease_lengths, crease_sharpness);
 
   if (m_first_frame && m_settings.export_face_sets) {

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


[Bf-blender-cvs] [f69e57a53fa] master: Alembic export: fix exporting of loop normals

2019-07-30 Thread Sybren A. Stüvel
Commit: f69e57a53fab92d549a90a0198b86ff766ba0da2
Author: Sybren A. Stüvel
Date:   Tue Jul 30 17:05:37 2019 +0200
Branches: master
https://developer.blender.org/rBf69e57a53fab92d549a90a0198b86ff766ba0da2

Alembic export: fix exporting of loop normals

When the mesh is using custom normals, those should always be exported,
regardless of the `ME_SMOOTH` flag on the invidivual polys.

Also replaced the loop normal writing with the same logic as we use for
reading (less pointer arithmetic, more normal counting).

===

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 1b5ae0b7adc..9e6f2dd6b52 100644
--- a/source/blender/alembic/intern/abc_mesh.cc
+++ b/source/blender/alembic/intern/abc_mesh.cc
@@ -205,17 +205,14 @@ static void get_loop_normals(struct Mesh *mesh, 
std::vector &normals
   normals.clear();
   normals.resize(mesh->totloop);
 
-  unsigned loop_index = 0;
-
   /* NOTE: data needs to be written in the reverse order. */
+  int abc_index = 0;
 
   if (lnors) {
 for (int i = 0, e = mesh->totpoly; i < e; ++i, ++mp) {
-  ml = mloop + mp->loopstart + (mp->totloop - 1);
-
-  for (int j = 0; j < mp->totloop; --ml, ++j, ++loop_index) {
-const int index = ml->v;
-copy_yup_from_zup(normals[loop_index].getValue(), lnors[index]);
+  for (int j = mp->totloop - 1; j >= 0; --j, ++abc_index) {
+int blender_index = mp->loopstart + j;
+copy_yup_from_zup(normals[abc_index].getValue(), lnors[blender_index]);
   }
 }
   }
@@ -229,15 +226,15 @@ static void get_loop_normals(struct Mesh *mesh, 
std::vector &normals
   if ((mp->flag & ME_SMOOTH) == 0) {
 BKE_mesh_calc_poly_normal(mp, ml - (mp->totloop - 1), verts, no);
 
-for (int j = 0; j < mp->totloop; --ml, ++j, ++loop_index) {
-  copy_yup_from_zup(normals[loop_index].getValue(), no);
+for (int j = 0; j < mp->totloop; --ml, ++j, ++abc_index) {
+  copy_yup_from_zup(normals[abc_index].getValue(), no);
 }
   }
   else {
 /* Smooth shaded, use individual vert normals. */
-for (int j = 0; j < mp->totloop; --ml, ++j, ++loop_index) {
+for (int j = 0; j < mp->totloop; --ml, ++j, ++abc_index) {
   normal_short_to_float_v3(no, verts[ml->v].no);
-  copy_yup_from_zup(normals[loop_index].getValue(), no);
+  copy_yup_from_zup(normals[abc_index].getValue(), no);
 }
   }
 }
@@ -413,7 +410,7 @@ void AbcGenericMeshWriter::writeMesh(struct Mesh *mesh)
   std::vector poly_verts, loop_counts;
   std::vector velocities;
 
-  bool export_loop_normals = false;
+  bool export_loop_normals = (mesh->flag & ME_AUTOSMOOTH) != 0;
 
   get_vertices(mesh, points);
   get_topology(mesh, poly_verts, loop_counts, export_loop_normals);

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


[Bf-blender-cvs] [e9c149d911c] master: Alembic import: load face-varying normals

2019-07-30 Thread Sybren A. Stüvel
Commit: e9c149d911c2ec52e02e266767797f09ba088f91
Author: Sybren A. Stüvel
Date:   Fri Jul 5 12:36:30 2019 +0200
Branches: master
https://developer.blender.org/rBe9c149d911c2ec52e02e266767797f09ba088f91

Alembic import: load face-varying normals

Loop normals are called 'Face-varying normals' in Alembic. Before this
commit, the existence of such normals was used to enable smooth shading.
This is incorrect, as the normals could encode flat faces just as well.

This commit adds the loading of these normals as custom loop normals. It
then also enables Auto-Smoothing on the mesh (which is a bit of a
misnomer and indicates to Blender that the custom normals should be
used).

Fixes the glitching described in T65959.

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

===

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 e4431bde2f6..1b5ae0b7adc 100644
--- a/source/blender/alembic/intern/abc_mesh.cc
+++ b/source/blender/alembic/intern/abc_mesh.cc
@@ -46,6 +46,8 @@ extern "C" {
 #include "BKE_modifier.h"
 #include "BKE_object.h"
 
+#include "MEM_guardedalloc.h"
+
 #include "WM_api.h"
 #include "WM_types.h"
 
@@ -758,7 +760,8 @@ struct AbcMeshData {
   P3fArraySamplePtr ceil_positions;
 
   N3fArraySamplePtr vertex_normals;
-  N3fArraySamplePtr face_normals;
+  N3fArraySamplePtr loop_normals;
+  bool poly_flag_smooth;
 
   V2fArraySamplePtr uvs;
   UInt32ArraySamplePtr uvs_indices;
@@ -832,7 +835,6 @@ static void read_mpolys(CDStreamConfig &config, const 
AbcMeshData &mesh_data)
   const size_t uvs_size = uvs == nullptr ? 0 : uvs->size();
 
   const UInt32ArraySamplePtr &uvs_indices = mesh_data.uvs_indices;
-  const N3fArraySamplePtr &normals = mesh_data.face_normals;
 
   const bool do_uvs = (mloopuvs && uvs && uvs_indices) &&
   (uvs_indices->size() == face_indices->size());
@@ -847,9 +849,12 @@ static void read_mpolys(CDStreamConfig &config, const 
AbcMeshData &mesh_data)
 poly.loopstart = loop_index;
 poly.totloop = face_size;
 
-if (normals != NULL) {
+if (mesh_data.poly_flag_smooth) {
   poly.flag |= ME_SMOOTH;
 }
+else {
+  poly.flag &= ~ME_SMOOTH;
+}
 
 /* NOTE: Alembic data is stored in the reverse order. */
 rev_loop_index = loop_index + (face_size - 1);
@@ -873,6 +878,40 @@ static void read_mpolys(CDStreamConfig &config, const 
AbcMeshData &mesh_data)
   }
 }
   }
+
+  BKE_mesh_calc_edges(config.mesh, false, false);
+}
+
+static void process_normals(CDStreamConfig &config, const AbcMeshData 
&mesh_data)
+{
+  Mesh *mesh = config.mesh;
+
+  if (!mesh_data.loop_normals) {
+BKE_mesh_calc_normals(config.mesh);
+config.mesh->flag &= ~ME_AUTOSMOOTH;
+return;
+  }
+
+  config.mesh->flag |= ME_AUTOSMOOTH;
+
+  const Alembic::AbcGeom::N3fArraySample &loop_normals = 
*mesh_data.loop_normals;
+  long int loop_count = loop_normals.size();
+
+  float(*lnors)[3] = static_cast(
+  MEM_malloc_arrayN(loop_count, sizeof(float[3]), "ABC::FaceNormals"));
+
+  MPoly *mpoly = mesh->mpoly;
+  int abc_index = 0;
+  for (int i = 0, e = mesh->totpoly; i < e; ++i, ++mpoly) {
+/* As usual, ABC orders the loops in reverse. */
+for (int j = mpoly->totloop - 1; j >= 0; --j, ++abc_index) {
+  int blender_index = mpoly->loopstart + j;
+  copy_zup_from_yup(lnors[blender_index], 
loop_normals[abc_index].getValue());
+}
+  }
+  BKE_mesh_set_custom_normals(config.mesh, lnors);
+
+  MEM_freeN(lnors);
 }
 
 ABC_INLINE void read_uvs_params(CDStreamConfig &config,
@@ -905,10 +944,6 @@ ABC_INLINE void read_uvs_params(CDStreamConfig &config,
   }
 }
 
-/* TODO(kevin): normals from Alembic files are not read in anymore, this is due
- * to the fact that there are many issues that are not so easy to solve, mainly
- * regarding the way normals are handled in Blender (MPoly.flag vs loop 
normals).
- */
 ABC_INLINE void read_normals_params(AbcMeshData &abc_data,
 const IN3fGeomParam &normals,
 const ISampleSelector &selector)
@@ -922,10 +957,12 @@ ABC_INLINE void read_normals_params(AbcMeshData &abc_data,
   Alembic::AbcGeom::GeometryScope scope = normals.getScope();
   switch (scope) {
 case Alembic::AbcGeom::kFacevaryingScope:
-  abc_data.face_normals = normsamp.getVals();
+  abc_data.loop_normals = normsamp.getVals();
   break;
 case Alembic::AbcGeom::kVertexScope:
 case Alembic::AbcGeom::kVaryingScope:
+  /* Vertex normals from ABC aren't handled for now. */
+  abc_da

[Bf-blender-cvs] [ca0b5529d09] master: FFmpeg: Added writing of WebM containers

2019-07-31 Thread Sybren A. Stüvel
Commit: ca0b5529d09c3d822bf0c7c618732c82ce758d1c
Author: Sybren A. Stüvel
Date:   Wed Jul 31 11:20:21 2019 +0200
Branches: master
https://developer.blender.org/rBca0b5529d09c3d822bf0c7c618732c82ce758d1c

FFmpeg: Added writing of WebM containers

This commit adds support for the WebM container. Previously we only
supported the WebM/VP9 video codec, but still required that it was
stored in a Matroska, MP4, or other compatible container format.

Reviewed By: brecht

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

===

M   release/scripts/startup/bl_ui/properties_output.py
M   source/blender/blenkernel/BKE_writeffmpeg.h
M   source/blender/blenkernel/intern/writeffmpeg.c
M   source/blender/makesrna/intern/rna_scene.c

===

diff --git a/release/scripts/startup/bl_ui/properties_output.py 
b/release/scripts/startup/bl_ui/properties_output.py
index 9a710fd9419..4d230520d11 100644
--- a/release/scripts/startup/bl_ui/properties_output.py
+++ b/release/scripts/startup/bl_ui/properties_output.py
@@ -376,7 +376,7 @@ class RENDER_PT_encoding_video(RenderOutputButtonsPanel, 
Panel):
 layout = self.layout
 ffmpeg = context.scene.render.ffmpeg
 
-needs_codec = ffmpeg.format in {'AVI', 'QUICKTIME', 'MKV', 'OGG', 
'MPEG4'}
+needs_codec = ffmpeg.format in {'AVI', 'QUICKTIME', 'MKV', 'OGG', 
'MPEG4', 'WEBM'}
 if needs_codec:
 layout.prop(ffmpeg, "codec")
 
diff --git a/source/blender/blenkernel/BKE_writeffmpeg.h 
b/source/blender/blenkernel/BKE_writeffmpeg.h
index 4d008f8d249..9da28c849d9 100644
--- a/source/blender/blenkernel/BKE_writeffmpeg.h
+++ b/source/blender/blenkernel/BKE_writeffmpeg.h
@@ -43,6 +43,7 @@ enum {
   FFMPEG_MKV = 9,
   FFMPEG_OGG = 10,
   FFMPEG_INVALID = 11,
+  FFMPEG_WEBM = 12,
 };
 
 enum {
diff --git a/source/blender/blenkernel/intern/writeffmpeg.c 
b/source/blender/blenkernel/intern/writeffmpeg.c
index fcd00837f4f..01a72cbbb9e 100644
--- a/source/blender/blenkernel/intern/writeffmpeg.c
+++ b/source/blender/blenkernel/intern/writeffmpeg.c
@@ -319,6 +319,10 @@ static const char **get_file_extensions(int format)
   static const char *rv[] = {".ogv", ".ogg", NULL};
   return rv;
 }
+case FFMPEG_WEBM: {
+  static const char *rv[] = {".webm", NULL};
+  return rv;
+}
 default:
   return NULL;
   }
diff --git a/source/blender/makesrna/intern/rna_scene.c 
b/source/blender/makesrna/intern/rna_scene.c
index dcbbdd67d7b..1e770f6aa9c 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -5171,6 +5171,7 @@ static void rna_def_scene_ffmpeg_settings(BlenderRNA 
*brna)
   {FFMPEG_OGG, "OGG", 0, "Ogg", ""},
   {FFMPEG_MKV, "MKV", 0, "Matroska", ""},
   {FFMPEG_FLV, "FLASH", 0, "Flash", ""},
+  {FFMPEG_WEBM, "WEBM", 0, "WebM", ""},
   {0, NULL, 0, NULL, NULL},
   };

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


[Bf-blender-cvs] [2ddfd51810e] master: FFmpeg: Added support for writing Opus audio.

2019-07-31 Thread Sybren A. Stüvel
Commit: 2ddfd51810e0cbdb4b617c0fd6d247e9cd78b125
Author: Sybren A. Stüvel
Date:   Wed Jul 31 11:21:24 2019 +0200
Branches: master
https://developer.blender.org/rB2ddfd51810e0cbdb4b617c0fd6d247e9cd78b125

FFmpeg: Added support for writing Opus audio.

This audio format is often used in conjunction with VP9 video in a WebM
container. Opus was created with the intention to replace Vorbis and
Speex ([source](https://en.wikipedia.org/wiki/Opus_(audio_format))).

Reviewed By: brecht

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

===

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

===

diff --git a/source/blender/makesrna/intern/rna_scene.c 
b/source/blender/makesrna/intern/rna_scene.c
index 1e770f6aa9c..fd8791cf193 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -5230,6 +5230,7 @@ static void rna_def_scene_ffmpeg_settings(BlenderRNA 
*brna)
   {AV_CODEC_ID_FLAC, "FLAC", 0, "FLAC", ""},
   {AV_CODEC_ID_MP2, "MP2", 0, "MP2", ""},
   {AV_CODEC_ID_MP3, "MP3", 0, "MP3", ""},
+  {AV_CODEC_ID_OPUS, "OPUS", 0, "Opus", ""},
   {AV_CODEC_ID_PCM_S16LE, "PCM", 0, "PCM", ""},
   {AV_CODEC_ID_VORBIS, "VORBIS", 0, "Vorbis", ""},
   {0, NULL, 0, NULL, NULL},

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


[Bf-blender-cvs] [631d5026c7b] master: Cleanup: Simplification of `BKE_ffmpeg_alpha_channel_is_supported()`

2019-07-31 Thread Sybren A. Stüvel
Commit: 631d5026c7bb34320c5d9b60afa5bc44b40fc5e4
Author: Sybren A. Stüvel
Date:   Wed Jul 31 11:15:14 2019 +0200
Branches: master
https://developer.blender.org/rB631d5026c7bb34320c5d9b60afa5bc44b40fc5e4

Cleanup: Simplification of `BKE_ffmpeg_alpha_channel_is_supported()`

Simplified `BKE_ffmpeg_alpha_channel_is_supported()` to use `ELEM()`
instead of a row consecutive `if`-statements.

No functional changes.

Reviewed By: brecht

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

===

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

===

diff --git a/source/blender/blenkernel/intern/writeffmpeg.c 
b/source/blender/blenkernel/intern/writeffmpeg.c
index f3336adda30..0d4182ff24d 100644
--- a/source/blender/blenkernel/intern/writeffmpeg.c
+++ b/source/blender/blenkernel/intern/writeffmpeg.c
@@ -1835,26 +1835,13 @@ void BKE_ffmpeg_codec_settings_verify(RenderData *rd)
 bool BKE_ffmpeg_alpha_channel_is_supported(RenderData *rd)
 {
   int codec = rd->ffcodecdata.codec;
-
-  if (codec == AV_CODEC_ID_QTRLE) {
-return true;
-  }
-
-  if (codec == AV_CODEC_ID_PNG) {
-return true;
-  }
-
-  if (codec == AV_CODEC_ID_HUFFYUV) {
-return true;
-  }
-
+  return ELEM(codec,
+  AV_CODEC_ID_QTRLE,
+  AV_CODEC_ID_PNG,
 #  ifdef FFMPEG_FFV1_ALPHA_SUPPORTED
-  if (codec == AV_CODEC_ID_FFV1) {
-return true;
-  }
+  AV_CODEC_ID_FFV1,
 #  endif
-
-  return false;
+  AV_CODEC_ID_HUFFYUV);
 }
 
 void *BKE_ffmpeg_context_create(void)

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


[Bf-blender-cvs] [43b7512a59c] master: FFmpeg: Added support for writing alpha values in WebM/VP9 video

2019-07-31 Thread Sybren A. Stüvel
Commit: 43b7512a59c2c4400ab7ccb5783efa707bfa2148
Author: Sybren A. Stüvel
Date:   Wed Jul 31 11:18:55 2019 +0200
Branches: master
https://developer.blender.org/rB43b7512a59c2c4400ab7ccb5783efa707bfa2148

FFmpeg: Added support for writing alpha values in WebM/VP9 video

The VP9 video codec supports writing alpha values; now this is available
in Blender too.

Reviewed By: brecht

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

===

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

===

diff --git a/source/blender/blenkernel/intern/writeffmpeg.c 
b/source/blender/blenkernel/intern/writeffmpeg.c
index 0d4182ff24d..fcd00837f4f 100644
--- a/source/blender/blenkernel/intern/writeffmpeg.c
+++ b/source/blender/blenkernel/intern/writeffmpeg.c
@@ -701,6 +701,12 @@ static AVStream *alloc_video_stream(FFMpegContext *context,
 c->pix_fmt = AV_PIX_FMT_ARGB;
   }
 
+  if (codec_id == AV_CODEC_ID_VP9) {
+if (rd->im_format.planes == R_IMF_PLANES_RGBA) {
+  c->pix_fmt = AV_PIX_FMT_YUVA420P;
+}
+  }
+
   if (codec_id == AV_CODEC_ID_PNG) {
 if (rd->im_format.planes == R_IMF_PLANES_RGBA) {
   c->pix_fmt = AV_PIX_FMT_RGBA;
@@ -1838,6 +1844,7 @@ bool BKE_ffmpeg_alpha_channel_is_supported(RenderData *rd)
   return ELEM(codec,
   AV_CODEC_ID_QTRLE,
   AV_CODEC_ID_PNG,
+  AV_CODEC_ID_VP9,
 #  ifdef FFMPEG_FFV1_ALPHA_SUPPORTED
   AV_CODEC_ID_FFV1,
 #  endif

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


[Bf-blender-cvs] [6d2f9b1dfa9] master: Added BKE_mesh_clear_geometry() function

2019-07-31 Thread Sybren A. Stüvel
Commit: 6d2f9b1dfa98502e9e9f1a73e3dded2ded1f1ce6
Author: Sybren A. Stüvel
Date:   Tue Jul 30 18:38:31 2019 +0200
Branches: master
https://developer.blender.org/rB6d2f9b1dfa98502e9e9f1a73e3dded2ded1f1ce6

Added BKE_mesh_clear_geometry() function

This function makes it possible to clear/remove/nuke all the geometry in
a mesh, allowing functions like `Mesh.from_python()` to construct a new
mesh in its place. Without this function, code like in T67627 have to
allocate a new Mesh datablock, fill that, and swap out the old Mesh for
the new one. This introduces issues when exporting, as the new mesh
could be seen by an exporter as unrelated to the old one.

Shape keys are not freed by this function. Freeing those would require
tagging the depsgraph for relations update, which is an expensive
operation. They should be removed explicitly if necessary.

Material slots are also not cleared by this function, in the same way
that they are not cleared when manually removing all geometry from a
mesh.

The `BKE_mesh_clear_geometry()` function is available in Python as
`mesh.clear_geometry()`.

Reviewed by: mont29, brecht

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

===

M   source/blender/blenkernel/BKE_mesh.h
M   source/blender/blenkernel/intern/mesh.c
M   source/blender/makesrna/intern/rna_mesh_api.c

===

diff --git a/source/blender/blenkernel/BKE_mesh.h 
b/source/blender/blenkernel/BKE_mesh.h
index d6b4fa72281..3b7fe208bb6 100644
--- a/source/blender/blenkernel/BKE_mesh.h
+++ b/source/blender/blenkernel/BKE_mesh.h
@@ -105,6 +105,7 @@ void BKE_mesh_looptri_get_real_edges(const struct Mesh 
*mesh,
 
 void BKE_mesh_free(struct Mesh *me);
 void BKE_mesh_init(struct Mesh *me);
+void BKE_mesh_clear_geometry(struct Mesh *me);
 struct Mesh *BKE_mesh_add(struct Main *bmain, const char *name);
 void BKE_mesh_copy_data(struct Main *bmain,
 struct Mesh *me_dst,
diff --git a/source/blender/blenkernel/intern/mesh.c 
b/source/blender/blenkernel/intern/mesh.c
index 9e01bfe62d6..f38161546e2 100644
--- a/source/blender/blenkernel/intern/mesh.c
+++ b/source/blender/blenkernel/intern/mesh.c
@@ -40,6 +40,7 @@
 #include "BKE_idcode.h"
 #include "BKE_main.h"
 #include "BKE_global.h"
+#include "BKE_key.h"
 #include "BKE_mesh.h"
 #include "BKE_mesh_runtime.h"
 #include "BKE_library.h"
@@ -479,20 +480,38 @@ bool BKE_mesh_has_custom_loop_normals(Mesh *me)
 /** Free (or release) any data used by this mesh (does not free the mesh 
itself). */
 void BKE_mesh_free(Mesh *me)
 {
-  BKE_animdata_free(&me->id, false);
+  BKE_mesh_clear_geometry(me);
+  MEM_SAFE_FREE(me->mat);
+}
 
-  BKE_mesh_runtime_clear_cache(me);
+void BKE_mesh_clear_geometry(Mesh *mesh)
+{
+  BKE_animdata_free(&mesh->id, false);
+  BKE_mesh_runtime_clear_cache(mesh);
 
-  CustomData_free(&me->vdata, me->totvert);
-  CustomData_free(&me->edata, me->totedge);
-  CustomData_free(&me->fdata, me->totface);
-  CustomData_free(&me->ldata, me->totloop);
-  CustomData_free(&me->pdata, me->totpoly);
+  CustomData_free(&mesh->vdata, mesh->totvert);
+  CustomData_free(&mesh->edata, mesh->totedge);
+  CustomData_free(&mesh->fdata, mesh->totface);
+  CustomData_free(&mesh->ldata, mesh->totloop);
+  CustomData_free(&mesh->pdata, mesh->totpoly);
 
-  MEM_SAFE_FREE(me->mat);
-  MEM_SAFE_FREE(me->bb);
-  MEM_SAFE_FREE(me->mselect);
-  MEM_SAFE_FREE(me->edit_mesh);
+  MEM_SAFE_FREE(mesh->bb);
+  MEM_SAFE_FREE(mesh->mselect);
+  MEM_SAFE_FREE(mesh->edit_mesh);
+
+  /* Note that materials and shape keys are not freed here. This is 
intentional, as freeing
+   * shape keys requires tagging the depsgraph for updated relations, which is 
expensive.
+   * Material slots should be kept in sync with the object.*/
+
+  mesh->totvert = 0;
+  mesh->totedge = 0;
+  mesh->totface = 0;
+  mesh->totloop = 0;
+  mesh->totpoly = 0;
+  mesh->act_face = -1;
+  mesh->totselect = 0;
+
+  BKE_mesh_update_customdata_pointers(mesh, false);
 }
 
 static void mesh_tessface_clear_intern(Mesh *mesh, int free_customdata)
diff --git a/source/blender/makesrna/intern/rna_mesh_api.c 
b/source/blender/makesrna/intern/rna_mesh_api.c
index d647c647136..283590fc529 100644
--- a/source/blender/makesrna/intern/rna_mesh_api.c
+++ b/source/blender/makesrna/intern/rna_mesh_api.c
@@ -202,6 +202,14 @@ static void rna_Mesh_count_selected_items(Mesh *mesh, int 
r_count[3])
   BKE_mesh_count_selected_items(mesh, r_count);
 }
 
+static void rna_Mesh_clear_geometry(Mesh *mesh)
+{
+  BKE_mesh_clear_geometry(mesh);
+
+  DEG_id_tag_update(&mesh->id, ID_RECALC_GEOMETRY);
+  WM_main_add_notifier(NC_GEOM | ND_DATA, mesh);
+}
+
 #else
 
 void R

[Bf-blender-cvs] [8b1041d510d] master: Fix Visual Studio compatibility in writeffmpeg.c

2019-07-31 Thread Sybren A. Stüvel
Commit: 8b1041d510dd18fe7d4f4c60856e66e0f4dedff0
Author: Sybren A. Stüvel
Date:   Wed Jul 31 15:26:25 2019 +0200
Branches: master
https://developer.blender.org/rB8b1041d510dd18fe7d4f4c60856e66e0f4dedff0

Fix Visual Studio compatibility in writeffmpeg.c

This fixes an incompatibility with Visual Studio 2019 introduced in
631d5026c7bb34320c5d9b60afa5bc44b40fc5e4. It is likely caused by using
`#  ifdef` inside the use of the `ELEM()` macro.

===

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

===

diff --git a/source/blender/blenkernel/intern/writeffmpeg.c 
b/source/blender/blenkernel/intern/writeffmpeg.c
index 01a72cbbb9e..203cafb75dd 100644
--- a/source/blender/blenkernel/intern/writeffmpeg.c
+++ b/source/blender/blenkernel/intern/writeffmpeg.c
@@ -1845,14 +1845,15 @@ void BKE_ffmpeg_codec_settings_verify(RenderData *rd)
 bool BKE_ffmpeg_alpha_channel_is_supported(RenderData *rd)
 {
   int codec = rd->ffcodecdata.codec;
-  return ELEM(codec,
-  AV_CODEC_ID_QTRLE,
-  AV_CODEC_ID_PNG,
-  AV_CODEC_ID_VP9,
+
 #  ifdef FFMPEG_FFV1_ALPHA_SUPPORTED
-  AV_CODEC_ID_FFV1,
+  /* Visual Studio 2019 doesn't like #ifdef within ELEM(). */
+  if (codec == AV_CODEC_ID_FFV1) {
+return true;
+  }
 #  endif
-  AV_CODEC_ID_HUFFYUV);
+
+  return ELEM(codec, AV_CODEC_ID_QTRLE, AV_CODEC_ID_PNG, AV_CODEC_ID_VP9, 
AV_CODEC_ID_HUFFYUV);
 }
 
 void *BKE_ffmpeg_context_create(void)

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


[Bf-blender-cvs] [92a3995c6d4] master: Fix T67999: calling obj.data.materials.clear() crashes Blender

2019-07-31 Thread Sybren A. Stüvel
Commit: 92a3995c6d4487e5bc0735b35fbef5c34b29421a
Author: Sybren A. Stüvel
Date:   Wed Jul 31 17:18:04 2019 +0200
Branches: master
https://developer.blender.org/rB92a3995c6d4487e5bc0735b35fbef5c34b29421a

Fix T67999: calling obj.data.materials.clear() crashes Blender

The `BKE_material_clear_id()` didn't call `test_all_objects_materials()`,
which caused the object and mesh material slot count to go out of sync.

===

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

===

diff --git a/source/blender/blenkernel/intern/material.c 
b/source/blender/blenkernel/intern/material.c
index 6fdc1995ca5..391af8b96ab 100644
--- a/source/blender/blenkernel/intern/material.c
+++ b/source/blender/blenkernel/intern/material.c
@@ -496,6 +496,7 @@ void BKE_material_clear_id(Main *bmain, ID *id, bool 
update_data)
   MEM_freeN(*matar);
   *matar = NULL;
 }
+test_all_objects_materials(bmain, id);
 
 if (update_data) {
   /* decrease mat_nr index */

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


[Bf-blender-cvs] [5fe840fb6ff] sybren-usd: Merge remote-tracking branch 'origin/master' into sybren-usd

2019-08-01 Thread Sybren A. Stüvel
Commit: 5fe840fb6ff9700bc219b95f50f803ddc1ffc002
Author: Sybren A. Stüvel
Date:   Thu Aug 1 10:21:39 2019 +0200
Branches: sybren-usd
https://developer.blender.org/rB5fe840fb6ff9700bc219b95f50f803ddc1ffc002

Merge remote-tracking branch 'origin/master' into sybren-usd

===



===



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


[Bf-blender-cvs] [6786c336bd5] master: Added FFmpeg preset for WebM + VP9 video + Opus audio

2019-08-01 Thread Sybren A. Stüvel
Commit: 6786c336bd58370e5a37db352975000e60ae5ba5
Author: Sybren A. Stüvel
Date:   Thu Aug 1 11:52:02 2019 +0200
Branches: master
https://developer.blender.org/rB6786c336bd58370e5a37db352975000e60ae5ba5

Added FFmpeg preset for WebM + VP9 video + Opus audio

This is a standard combination (VP9 video, Opus audio, in WebM container),
so it's nice to have as a preset.

===

A   release/scripts/presets/ffmpeg/WebM_(VP9+Opus).py

===

diff --git a/release/scripts/presets/ffmpeg/WebM_(VP9+Opus).py 
b/release/scripts/presets/ffmpeg/WebM_(VP9+Opus).py
new file mode 100644
index 000..9723fc3617c
--- /dev/null
+++ b/release/scripts/presets/ffmpeg/WebM_(VP9+Opus).py
@@ -0,0 +1,9 @@
+# WebM container, VP9 video, Opus audio.
+import bpy
+
+ffmpeg = bpy.context.scene.render.ffmpeg
+ffmpeg.format = "WEBM"
+ffmpeg.codec = "WEBM"
+ffmpeg.audio_codec = "OPUS"
+ffmpeg.constant_rate_factor = 'MEDIUM'
+ffmpeg.use_max_b_frames = False

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


[Bf-blender-cvs] [08a63215018] master: FFmpeg pixel format conversion improvements

2019-08-01 Thread Sybren A. Stüvel
Commit: 08a63215018222062e6d669f9ac4de3980722042
Author: Sybren A. Stüvel
Date:   Thu Aug 1 13:01:53 2019 +0200
Branches: master
https://developer.blender.org/rB08a63215018222062e6d669f9ac4de3980722042

FFmpeg pixel format conversion improvements

FFmpeg expects Blender to feed it pixels in the output pixel format. If
the output pixel format is different than Blender's RGBA, a conversion
is needed (via FFmpeg's `sws_scale()` function). There were a few issues
with this conversion (and surrounding code) that are fixed in this
commit:

- When conversion was necessary a temporary buffer was allocated and
  deallocated for every frame. This is now allocated once and re-used.
- Copying data to the buffer was done byte-for-byte. On little-endian
  machines it is now done line-by-line using `memcpy` for a little speedup.
- The decision whether pixel format conversion is necessary is now
  correctly done based on the pixel format Blender is actually using.
- The pixel format of the buffer sent to FFmpeg is no longer hard-coded
  incorrectly to a fixed pixel format, but uses the actual output pixel
  format. This is fixes T53058 properly, making RGB QTRLE export possible.
- I added some comments to make it clear which pixel format is referred
  to (either Blender's internal format or the FFmpeg output format).

Combined these improvements not only correct a bug (T53058) but also
results in approximately 5% speed improvement (tested with a 117-frame
shot from Spring, loaded as PNGs in the VSE, encoding to h.264 with
preset 'realtime').

Reviewed By: brecht, sergey

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

===

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

===

diff --git a/source/blender/blenkernel/intern/writeffmpeg.c 
b/source/blender/blenkernel/intern/writeffmpeg.c
index 203cafb75dd..5152643aaa1 100644
--- a/source/blender/blenkernel/intern/writeffmpeg.c
+++ b/source/blender/blenkernel/intern/writeffmpeg.c
@@ -54,6 +54,7 @@
  * like M_SQRT1_2 leading to warnings with MSVC */
 #  include 
 #  include 
+#  include 
 #  include 
 #  include 
 #  include 
@@ -80,7 +81,10 @@ typedef struct FFMpegContext {
   AVFormatContext *outfile;
   AVStream *video_stream;
   AVStream *audio_stream;
-  AVFrame *current_frame;
+  AVFrame *current_frame; /* Image frame in output pixel format. */
+
+  /* Image frame in Blender's own pixel format, may need conversion to the 
output pixel format. */
+  AVFrame *img_convert_frame;
   struct SwsContext *img_convert_ctx;
 
   uint8_t *audio_input_buffer;
@@ -264,6 +268,10 @@ static AVFrame *alloc_picture(int pix_fmt, int width, int 
height)
 return NULL;
   }
   avpicture_fill((AVPicture *)f, buf, pix_fmt, width, height);
+  f->format = pix_fmt;
+  f->width = width;
+  f->height = height;
+
   return f;
 }
 
@@ -375,67 +383,52 @@ static int write_video_frame(
 }
 
 /* read and encode a frame of audio from the buffer */
-static AVFrame *generate_video_frame(FFMpegContext *context, uint8_t *pixels, 
ReportList *reports)
+static AVFrame *generate_video_frame(FFMpegContext *context,
+ const uint8_t *pixels,
+ ReportList *reports)
 {
-  uint8_t *rendered_frame;
-
   AVCodecContext *c = context->video_stream->codec;
-  int width = c->width;
   int height = c->height;
   AVFrame *rgb_frame;
 
-  if (c->pix_fmt != AV_PIX_FMT_BGR32) {
-rgb_frame = alloc_picture(AV_PIX_FMT_BGR32, width, height);
-if (!rgb_frame) {
-  BKE_report(reports, RPT_ERROR, "Could not allocate temporary frame");
-  return NULL;
-}
+  if (context->img_convert_frame != NULL) {
+/* Pixel format conversion is needed. */
+rgb_frame = context->img_convert_frame;
   }
   else {
+/* The output pixel format is Blender's internal pixel format. */
 rgb_frame = context->current_frame;
   }
 
-  rendered_frame = pixels;
+  /* Copy the Blender pixels into the FFmpeg datastructure, taking care of 
endianness and flipping
+   * the image vertically. */
+  int linesize = rgb_frame->linesize[0];
+  for (int y = 0; y < height; y++) {
+uint8_t *target = rgb_frame->data[0] + linesize * (height - y - 1);
+const uint8_t *src = pixels + linesize * y;
 
-  /* Do RGBA-conversion and flipping in one step depending
-   * on CPU-Endianess */
+#  if ENDIAN_ORDER == L_ENDIAN
+memcpy(target, src, linesize);
 
-  if (ENDIAN_ORDER == L_ENDIAN) {
-int y;
-for (y = 0; y < height; y++) {
-  uint8_t *target = rgb_frame->data[0] + width * 4 * (height - y - 1);
-  uint8_t *src = rendered_frame + width * 4 * y;
-  uint8_t *end = src + width * 4;
-  while (src != end) {
-target[3] = src[3];
-target[2] = src[2];
-target[1] = src[1];
-t

[Bf-blender-cvs] [2741992f660] master: Fix T61935: load camera transforms from Alembic files written by Meshroom

2019-08-01 Thread Sybren A. Stüvel
Commit: 2741992f6608c0f76e1bc95ca5d6e05a63348c7f
Author: Sybren A. Stüvel
Date:   Thu Aug 1 14:54:22 2019 +0200
Branches: master
https://developer.blender.org/rB2741992f6608c0f76e1bc95ca5d6e05a63348c7f

Fix T61935: load camera transforms from Alembic files written by Meshroom

Meshroom writes two hierarchies to Alembic, one rooted at
`/mvgRoot/mvgCameras` and the other at `/mvgRoot/mvgCamerasUndefined`.
These paths have no schema definition, and thus are ignored by Blender.
The cameras themselves have those schemaless paths as parent, and have
their transforms marked as "inherited", e.g. relative to their parent.
As these cameras have no valid parent, there is no Blender object to use
to convert their local matrices to world matrices, and Blender just
decided to reset them to the unit matrix.

Now "inherited" transforms without a parent in Blender are interpreted
as world transforms. Reparenting those objects to a Blender object will
re-interpret the transforms as local to the parent again.

===

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 7b0d94a2305..f863fe4fee7 100644
--- a/source/blender/alembic/intern/abc_object.cc
+++ b/source/blender/alembic/intern/abc_object.cc
@@ -335,8 +335,10 @@ void AbcObjectReader::read_matrix(float r_mat[4][4],
   mul_m4_m4m4(r_mat, m_object->parent->obmat, r_mat);
 }
 else {
-  /* This can happen if the user deleted the parent object. */
-  unit_m4(r_mat);
+  /* This can happen if the user deleted the parent object, but also if 
the Alembic parent was
+   * not imported (because of unknown/unsupported schema, for example). In 
that case just use
+   * the local matrix as if it is the world matrix. This allows us to 
import Alembic files from
+   * MeshRoom, see T61935. */
 }
   }
   else {

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


[Bf-blender-cvs] [21c039f6ef3] master: Alembic: fix heap-use-after-free error

2019-08-01 Thread Sybren A. Stüvel
Commit: 21c039f6ef3fb10c0439b096ed7e89d59e3997b3
Author: Sybren A. Stüvel
Date:   Thu Aug 1 15:14:57 2019 +0200
Branches: master
https://developer.blender.org/rB21c039f6ef3fb10c0439b096ed7e89d59e3997b3

Alembic: fix heap-use-after-free error

The mesh can be freed by BKE_mesh_nomain_to_mesh(), so we need to get
the `ME_AUTOSMOOTH` flag before that call, and not after.

===

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 9e6f2dd6b52..6647ca83bd6 100644
--- a/source/blender/alembic/intern/abc_mesh.cc
+++ b/source/blender/alembic/intern/abc_mesh.cc
@@ -1093,10 +1093,11 @@ void AbcMeshReader::readObjectData(Main *bmain, const 
Alembic::Abc::ISampleSelec
 
   Mesh *read_mesh = this->read_mesh(mesh, sample_sel, MOD_MESHSEQ_READ_ALL, 
NULL);
   if (read_mesh != mesh) {
-BKE_mesh_nomain_to_mesh(read_mesh, mesh, m_object, &CD_MASK_MESH, true);
-
 /* XXX fixme after 2.80; mesh->flag isn't copied by 
BKE_mesh_nomain_to_mesh() */
-mesh->flag |= (read_mesh->flag & ME_AUTOSMOOTH);
+/* read_mesh can be freed by BKE_mesh_nomain_to_mesh(), so get the flag 
before that happens. */
+short autosmooth = (read_mesh->flag & ME_AUTOSMOOTH);
+BKE_mesh_nomain_to_mesh(read_mesh, mesh, m_object, &CD_MASK_MESH, true);
+mesh->flag |= autosmooth;
   }
 
   if (m_settings->validate_meshes) {

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


[Bf-blender-cvs] [454daf9b6b8] master: Upgrade Python from 3.7.0 to 3.7.4

2019-08-02 Thread Sybren A. Stüvel
Commit: 454daf9b6b87d008e66650927109511f1c1befd2
Author: Sybren A. Stüvel
Date:   Fri Aug 2 16:49:14 2019 +0200
Branches: master
https://developer.blender.org/rB454daf9b6b87d008e66650927109511f1c1befd2

Upgrade Python from 3.7.0 to 3.7.4

===

M   build_files/build_environment/cmake/versions.cmake
M   build_files/build_environment/install_deps.sh

===

diff --git a/build_files/build_environment/cmake/versions.cmake 
b/build_files/build_environment/cmake/versions.cmake
index 609a8926d2b..1d3da863898 100644
--- a/build_files/build_environment/cmake/versions.cmake
+++ b/build_files/build_environment/cmake/versions.cmake
@@ -143,11 +143,11 @@ set(OSL_VERSION 1.9.9)
 set(OSL_URI 
https://github.com/imageworks/OpenShadingLanguage/archive/Release-${OSL_VERSION}.tar.gz)
 set(OSL_HASH 44ad511e424965a10fce051a053b0605)
 
-set(PYTHON_VERSION 3.7.0)
+set(PYTHON_VERSION 3.7.4)
 set(PYTHON_SHORT_VERSION 3.7)
 set(PYTHON_SHORT_VERSION_NO_DOTS 37)
 set(PYTHON_URI 
https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tar.xz)
-set(PYTHON_HASH eb8c2a6b1447d50813c02714af4681f3)
+set(PYTHON_HASH d33e4aae66097051c2eca45ee3604803)
 
 set(TBB_VERSION 2018_U5)
 set(TBB_URI https://github.com/01org/tbb/archive/${TBB_VERSION}.tar.gz)
diff --git a/build_files/build_environment/install_deps.sh 
b/build_files/build_environment/install_deps.sh
index 5cf005d60ce..e4f03480385 100755
--- a/build_files/build_environment/install_deps.sh
+++ b/build_files/build_environment/install_deps.sh
@@ -303,7 +303,7 @@ USE_CXX11=true
 
 CLANG_FORMAT_VERSION_MIN="6.0"
 
-PYTHON_VERSION="3.7.0"
+PYTHON_VERSION="3.7.4"
 PYTHON_VERSION_MIN="3.7"
 PYTHON_FORCE_BUILD=false
 PYTHON_FORCE_REBUILD=false

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


[Bf-blender-cvs] [53ae209d25a] master: make deps: avoid running pdflatex as part of building Theora

2019-08-02 Thread Sybren A. Stüvel
Commit: 53ae209d25a5741fe32fc403a4428966e8fca4dd
Author: Sybren A. Stüvel
Date:   Fri Aug 2 11:12:05 2019 +0200
Branches: master
https://developer.blender.org/rB53ae209d25a5741fe32fc403a4428966e8fca4dd

make deps: avoid running pdflatex as part of building Theora

On machines with pdflatex installed, this is run to build Theora.pdf.
Unfortunately this process breaks, at least on my Ubuntu 18.04 LTS
system. By setting `HAVE_PDFLATEX=no` (or any other value that is not
"yes") this can be avoided. I don't think that it's important to have
this PDF file built anyway, as it's not a dependency of Blender itself.

===

M   build_files/build_environment/cmake/theora.cmake

===

diff --git a/build_files/build_environment/cmake/theora.cmake 
b/build_files/build_environment/cmake/theora.cmake
index e5f94b15b02..6cb69c73948 100644
--- a/build_files/build_environment/cmake/theora.cmake
+++ b/build_files/build_environment/cmake/theora.cmake
@@ -16,20 +16,22 @@
 #
 # * END GPL LICENSE BLOCK *
 
+set(THEORA_CONFIGURE_ENV ${CONFIGURE_ENV} && export HAVE_PDFLATEX=no)
+
 ExternalProject_Add(external_theora
   URL ${THEORA_URI}
   DOWNLOAD_DIR ${DOWNLOAD_DIR}
   URL_HASH SHA256=${THEORA_HASH}
   PREFIX ${BUILD_DIR}/theora
-  CONFIGURE_COMMAND ${CONFIGURE_ENV} && cd 
${BUILD_DIR}/theora/src/external_theora/ && ${CONFIGURE_COMMAND} 
--prefix=${LIBDIR}/theora
+  CONFIGURE_COMMAND ${THEORA_CONFIGURE_ENV} && cd 
${BUILD_DIR}/theora/src/external_theora/ && ${CONFIGURE_COMMAND} 
--prefix=${LIBDIR}/theora
 --disable-shared
 --enable-static
 --with-pic
 --with-ogg=${LIBDIR}/ogg
 --with-vorbis=${LIBDIR}/vorbis
 --disable-examples
-  BUILD_COMMAND ${CONFIGURE_ENV} && cd 
${BUILD_DIR}/theora/src/external_theora/ && make -j${MAKE_THREADS}
-  INSTALL_COMMAND ${CONFIGURE_ENV} && cd 
${BUILD_DIR}/theora/src/external_theora/ && make install
+  BUILD_COMMAND ${THEORA_CONFIGURE_ENV} && cd 
${BUILD_DIR}/theora/src/external_theora/ && make -j${MAKE_THREADS}
+  INSTALL_COMMAND ${THEORA_CONFIGURE_ENV} && cd 
${BUILD_DIR}/theora/src/external_theora/ && make install
   INSTALL_DIR ${LIBDIR}/theora
 )

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


[Bf-blender-cvs] [88a872dd6ea] master: Fix T68227: Pinning the particles system data-block causes error

2019-08-06 Thread Sybren A. Stüvel
Commit: 88a872dd6eac10e99afbd18243d39be68921642a
Author: Sybren A. Stüvel
Date:   Tue Aug 6 15:31:39 2019 +0200
Branches: master
https://developer.blender.org/rB88a872dd6eac10e99afbd18243d39be68921642a

Fix T68227: Pinning the particles system data-block causes error

The 'Seed' setting is not part of the pinned data-block. When pinning,
the local variable `psys` is `None`, and this wasn't properly checked for
when drawing the 'Seed' setting.

===

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

===

diff --git a/release/scripts/startup/bl_ui/properties_particle.py 
b/release/scripts/startup/bl_ui/properties_particle.py
index 02b809cdfb4..ebbf278c5e7 100644
--- a/release/scripts/startup/bl_ui/properties_particle.py
+++ b/release/scripts/startup/bl_ui/properties_particle.py
@@ -272,7 +272,9 @@ class PARTICLE_PT_emission(ParticleButtonsPanel, Panel):
 col = layout.column()
 col.active = part.emit_from == 'VERT' or part.distribution != 'GRID'
 col.prop(part, "count")
-col.prop(psys, "seed")
+
+if psys is not None:
+col.prop(psys, "seed")
 
 if part.type == 'HAIR':
 col.prop(part, "hair_length")

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


[Bf-blender-cvs] [9deb73df3d1] master: Clarify "Save on Exit" tooltip

2019-08-09 Thread Sybren A. Stüvel
Commit: 9deb73df3d1ee219c9a382a1f4ea39c29dd4187c
Author: Sybren A. Stüvel
Date:   Fri Aug 9 14:35:28 2019 +0200
Branches: master
https://developer.blender.org/rB9deb73df3d1ee219c9a382a1f4ea39c29dd4187c

Clarify "Save on Exit" tooltip

The old text, "Save modified preferences on exit" suggests that only the
modified preferences are saved. This is not the case: all preferences
are saved at once. This distinction is especially important after having
loaded factory default settings.

As discussed with @campbellbarton and @JulienKaspar.

===

M   source/blender/makesrna/intern/rna_userdef.c

===

diff --git a/source/blender/makesrna/intern/rna_userdef.c 
b/source/blender/makesrna/intern/rna_userdef.c
index 38cb3e1d222..48eee713fc9 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -5820,7 +5820,7 @@ void RNA_def_userdef(BlenderRNA *brna)
   /* Preferences Flags */
   prop = RNA_def_property(srna, "use_preferences_save", PROP_BOOLEAN, 
PROP_NONE);
   RNA_def_property_boolean_sdna(prop, NULL, "pref_flag", USER_PREF_FLAG_SAVE);
-  RNA_def_property_ui_text(prop, "Save on Exit", "Save modified preferences on 
exit");
+  RNA_def_property_ui_text(prop, "Save on Exit", "Save preferences on exit 
when modified");
 
   prop = RNA_def_property(srna, "is_dirty", PROP_BOOLEAN, PROP_NONE);
   RNA_def_property_boolean_sdna(prop, NULL, "runtime.is_dirty", 0);

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


[Bf-blender-cvs] [e1665905dff] master: Fix T68322: Shear in Dopesheet causes crash

2019-08-09 Thread Sybren A. Stüvel
Commit: e1665905dff1e19c2e40fc1df716de572b1e1fb2
Author: Sybren A. Stüvel
Date:   Thu Aug 8 18:21:40 2019 +0200
Branches: master
https://developer.blender.org/rBe1665905dff1e19c2e40fc1df716de572b1e1fb2

Fix T68322: Shear in Dopesheet causes crash

The Shear transform operator is now disallowed in the timeline and
dopesheet editors.

Reviewers: campbellbarton

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

===

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

===

diff --git a/source/blender/editors/transform/transform_ops.c 
b/source/blender/editors/transform/transform_ops.c
index 5e9add74b42..92add84f596 100644
--- a/source/blender/editors/transform/transform_ops.c
+++ b/source/blender/editors/transform/transform_ops.c
@@ -883,6 +883,18 @@ static void TRANSFORM_OT_bend(struct wmOperatorType *ot)
   Transform_Properties(ot, P_PROPORTIONAL | P_MIRROR | P_SNAP | P_GPENCIL_EDIT 
| P_CENTER);
 }
 
+
+static bool transform_shear_poll(bContext *C)
+{
+  if (!ED_operator_screenactive(C)) {
+return false;
+  }
+
+  ScrArea *sa = CTX_wm_area(C);
+  return sa && !ELEM(sa->spacetype, SPACE_ACTION, SPACE_TIME);
+}
+
+
 static void TRANSFORM_OT_shear(struct wmOperatorType *ot)
 {
   /* identifiers */
@@ -896,7 +908,7 @@ static void TRANSFORM_OT_shear(struct wmOperatorType *ot)
   ot->exec = transform_exec;
   ot->modal = transform_modal;
   ot->cancel = transform_cancel;
-  ot->poll = ED_operator_screenactive;
+  ot->poll = transform_shear_poll;
   ot->poll_property = transform_poll_property;
 
   RNA_def_float(ot->srna, "value", 0, -FLT_MAX, FLT_MAX, "Offset", "", 
-FLT_MAX, FLT_MAX);

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


[Bf-blender-cvs] [42798a5ca16] master: Fix T67516 VSE: Animation evaluated incorrectly when scene strip present

2019-08-13 Thread Sybren A. Stüvel
Commit: 42798a5ca16154c9ecaf5a2359bd0b4fbe9dec94
Author: Sybren A. Stüvel
Date:   Thu Aug 1 14:10:04 2019 +0200
Branches: master
https://developer.blender.org/rB42798a5ca16154c9ecaf5a2359bd0b4fbe9dec94

Fix T67516 VSE: Animation evaluated incorrectly when scene strip present

The calls to `BKE_animsys_evaluate_all_animation()` and
`BKE_mask_evaluate_all_masks()` used the wrong timecode to evaluate the
animation system. This happened:

- Sequencer in scene A was rendered at frame X.
- Scene strip for scene B which should be evaluated at frame Y.
- BKE_animsys_evaluate_all_animation() was called with frame Y, which
  also re-evaluated the animation data in scene A.
- Other sequencer strips with animated values were then evaluated for
  frame Y and not frame X.

Since the depsgraph for rendering the scene strip is already OK and does
its job, it's no longer necessary to re-evaluate all the animation in
this way.

Removed `BKE_mask_evaluate_all_masks()` because it's no longer used.

Reviewers: sergey, brecht, iss

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

===

M   source/blender/blenkernel/BKE_mask.h
M   source/blender/blenkernel/intern/mask.c
M   source/blender/render/intern/source/pipeline.c

===

diff --git a/source/blender/blenkernel/BKE_mask.h 
b/source/blender/blenkernel/BKE_mask.h
index bfdeadc7f60..f87c73e35a2 100644
--- a/source/blender/blenkernel/BKE_mask.h
+++ b/source/blender/blenkernel/BKE_mask.h
@@ -171,7 +171,6 @@ void BKE_mask_coord_to_image(struct Image *image,
 
 /* parenting */
 
-void BKE_mask_evaluate_all_masks(struct Main *bmain, float ctime, const bool 
do_newframe);
 void BKE_mask_evaluate(struct Mask *mask, const float ctime, const bool 
do_newframe);
 void BKE_mask_layer_evaluate(struct MaskLayer *masklay, const float ctime, 
const bool do_newframe);
 void BKE_mask_parent_init(struct MaskParent *parent);
diff --git a/source/blender/blenkernel/intern/mask.c 
b/source/blender/blenkernel/intern/mask.c
index bb93d068bef..8f8150b6a64 100644
--- a/source/blender/blenkernel/intern/mask.c
+++ b/source/blender/blenkernel/intern/mask.c
@@ -1469,15 +1469,6 @@ void BKE_mask_evaluate(Mask *mask, const float ctime, 
const bool do_newframe)
   }
 }
 
-void BKE_mask_evaluate_all_masks(Main *bmain, float ctime, const bool 
do_newframe)
-{
-  Mask *mask;
-
-  for (mask = bmain->masks.first; mask; mask = mask->id.next) {
-BKE_mask_evaluate(mask, ctime, do_newframe);
-  }
-}
-
 void BKE_mask_parent_init(MaskParent *parent)
 {
   parent->id_type = ID_MC;
diff --git a/source/blender/render/intern/source/pipeline.c 
b/source/blender/render/intern/source/pipeline.c
index d620cd38b76..6284fa2d119 100644
--- a/source/blender/render/intern/source/pipeline.c
+++ b/source/blender/render/intern/source/pipeline.c
@@ -1680,7 +1680,6 @@ static void do_render_all_options(Render *re)
 {
   Object *camera;
   bool render_seq = false;
-  int cfra = re->r.cfra;
 
   re->current_scene_update(re->suh, re->scene);
 
@@ -1692,16 +1691,6 @@ static void do_render_all_options(Render *re)
   BKE_image_all_free_anim_ibufs(re->main, re->r.cfra);
   BKE_sequencer_all_free_anim_ibufs(re->scene, re->r.cfra);
 
-  /* Update for sequencer and compositing animation.
-   * TODO: ideally we would create a depsgraph with a copy of the scene
-   * like the render engine, but sequencer and compositing do not (yet?)
-   * work with copy-on-write. */
-  BKE_animsys_evaluate_all_animation(re->main, NULL, re->scene, (float)cfra);
-
-  /* Update for masks
-   * (these do not use animsys but own lighter weight structure to define 
animation). */
-  BKE_mask_evaluate_all_masks(re->main, (float)cfra, true);
-
   if (RE_engine_render(re, 1)) {
 /* in this case external render overrides all */
   }

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


[Bf-blender-cvs] [05417b22206] master: Text editor: syntax highlighting + line numbers on by default

2019-08-14 Thread Sybren A. Stüvel
Commit: 05417b22206c479b5ebe8ac8e7dd73ae154c8c96
Author: Sybren A. Stüvel
Date:   Tue Aug 13 15:35:48 2019 +0200
Branches: master
https://developer.blender.org/rB05417b22206c479b5ebe8ac8e7dd73ae154c8c96

Text editor: syntax highlighting + line numbers on by default

The most common use of the text editor seems to be for scripting. Having
line numbers and syntax highlighting enabled by default seems sensible.

Syntax highlighting is now enabled by default, but is automatically
disabled when the datablock has a non-highlighted extension.
Highlighting is enabled for filenames like:
- Text
- Text.001
- somefile.py
and is automatically disabled when the datablock has an extension for
which Blender has no syntax highlighter registered.

Reviewers: billreynish, campbellbarton

Subscribers: brecht, billreynish

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

===

M   release/scripts/startup/bl_ui/space_text.py
M   source/blender/blenlib/BLI_path_util.h
M   source/blender/blenlib/BLI_string_utils.h
M   source/blender/blenlib/intern/path_util.c
M   source/blender/blenlib/intern/string_utils.c
M   source/blender/editors/include/ED_text.h
M   source/blender/editors/space_text/space_text.c
M   source/blender/editors/space_text/text_draw.c
M   source/blender/editors/space_text/text_format.c
M   source/blender/makesrna/intern/rna_space.c
M   source/blender/makesrna/intern/rna_text.c
M   source/blender/makesrna/intern/rna_text_api.c
M   tests/gtests/blenlib/BLI_path_util_test.cc
M   tests/gtests/blenlib/BLI_string_test.cc

===

diff --git a/release/scripts/startup/bl_ui/space_text.py 
b/release/scripts/startup/bl_ui/space_text.py
index 1ffb181b219..e82c6bc5dc7 100644
--- a/release/scripts/startup/bl_ui/space_text.py
+++ b/release/scripts/startup/bl_ui/space_text.py
@@ -50,7 +50,11 @@ class TEXT_HT_header(Header):
 row = layout.row(align=True)
 row.prop(st, "show_line_numbers", text="")
 row.prop(st, "show_word_wrap", text="")
-row.prop(st, "show_syntax_highlight", text="")
+
+is_syntax_highlight_supported = st.is_syntax_highlight_supported()
+syntax = row.row(align=True)
+syntax.active = is_syntax_highlight_supported
+syntax.prop(st, "show_syntax_highlight", text="")
 
 if text:
 is_osl = text.name.endswith((".osl", ".osl"))
@@ -65,6 +69,7 @@ class TEXT_HT_header(Header):
 row.prop(text, "use_module")
 
 row = layout.row()
+row.active = is_syntax_highlight_supported
 row.operator("text.run_script")
 
 
@@ -226,7 +231,9 @@ class TEXT_MT_view(Menu):
 
 layout.prop(st, "show_line_numbers")
 layout.prop(st, "show_word_wrap")
-layout.prop(st, "show_syntax_highlight")
+syntax = layout.column()
+syntax.active = st.is_syntax_highlight_supported()
+syntax.prop(st, "show_syntax_highlight")
 layout.prop(st, "show_line_highlight")
 
 layout.separator()
diff --git a/source/blender/blenlib/BLI_path_util.h 
b/source/blender/blenlib/BLI_path_util.h
index 31b68204c51..99e86615e50 100644
--- a/source/blender/blenlib/BLI_path_util.h
+++ b/source/blender/blenlib/BLI_path_util.h
@@ -42,6 +42,8 @@ void BLI_split_dirfile(
 const char *string, char *dir, char *file, const size_t dirlen, const 
size_t filelen);
 void BLI_split_dir_part(const char *string, char *dir, const size_t dirlen);
 void BLI_split_file_part(const char *string, char *file, const size_t filelen);
+const char *BLI_path_extension(const char *filepath) ATTR_NONNULL();
+
 void BLI_path_append(char *__restrict dst, const size_t maxlen, const char 
*__restrict file)
 ATTR_NONNULL();
 void BLI_join_dirfile(char *__restrict string,
diff --git a/source/blender/blenlib/BLI_string_utils.h 
b/source/blender/blenlib/BLI_string_utils.h
index 9740629276d..13dbb2de659 100644
--- a/source/blender/blenlib/BLI_string_utils.h
+++ b/source/blender/blenlib/BLI_string_utils.h
@@ -38,6 +38,7 @@ struct ListBase;
 typedef bool (*UniquenameCheckCallback)(void *arg, const char *name);
 
 size_t BLI_split_name_num(char *left, int *nr, const char *name, const char 
delim);
+bool BLI_string_is_decimal(const char *string) ATTR_NONNULL();
 
 void BLI_string_split_suffix(const char *string, char *r_body, char *r_suf, 
const size_t str_len);
 void BLI_string_split_prefix(const char *string, char *r_pre, char *r_body, 
const size_t str_len);
diff --git a/source/blender/blenlib/intern/path_util.c 
b/source/blender/blenlib/intern/path_util.c
index 111b530a527..18acbca00a1 100644
--- a/source/blender/blenli

[Bf-blender-cvs] [72eb70f9332] master: Added missing forward declaration

2019-08-14 Thread Sybren A. Stüvel
Commit: 72eb70f93328e4e19a319aa199f6c46a0c8ab420
Author: Sybren A. Stüvel
Date:   Wed Aug 14 16:45:45 2019 +0200
Branches: master
https://developer.blender.org/rB72eb70f93328e4e19a319aa199f6c46a0c8ab420

Added missing forward declaration

===

M   source/blender/editors/include/ED_text.h

===

diff --git a/source/blender/editors/include/ED_text.h 
b/source/blender/editors/include/ED_text.h
index ed71439bd37..39d0b8b26cb 100644
--- a/source/blender/editors/include/ED_text.h
+++ b/source/blender/editors/include/ED_text.h
@@ -25,6 +25,7 @@
 #define __ED_TEXT_H__
 
 struct ARegion;
+struct bContext;
 struct SpaceText;
 struct UndoStep;
 struct UndoType;

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


[Bf-blender-cvs] [c70f975d5c3] master: Fix T67999: calling Mesh.materials.clear() crashes Blender

2019-08-16 Thread Sybren A. Stüvel
Commit: c70f975d5c3b961e0c77eba3a35c8a892f39214d
Author: Sybren A. Stüvel
Date:   Fri Aug 16 14:36:57 2019 +0200
Branches: master
https://developer.blender.org/rBc70f975d5c3b961e0c77eba3a35c8a892f39214d

Fix T67999: calling Mesh.materials.clear() crashes Blender

The `BKE_material_pop_id()` and `BKE_material_clear_id()` functions had
a parameter `update_data` that, when `false`, would cause the mesh polys
to keep their material index, even when the indexed material slots were
removed. This behaviour was never used in the C code and not supported
by the drawing code, making polygons disappear and causing crashes. The
Python binding in RNA, however, defaulted to `update_data=False`.

This commit removes the `update_data` parameter altogether, and makes
the functions always fix up the material indices.

Reviewed by: mont29, brecht

===

M   source/blender/blenkernel/BKE_material.h
M   source/blender/blenkernel/intern/material.c
M   source/blender/editors/mesh/editmesh_tools.c
M   source/blender/makesrna/intern/rna_ID.c

===

diff --git a/source/blender/blenkernel/BKE_material.h 
b/source/blender/blenkernel/BKE_material.h
index 5bb69c7166e..44a8f98e994 100644
--- a/source/blender/blenkernel/BKE_material.h
+++ b/source/blender/blenkernel/BKE_material.h
@@ -104,9 +104,8 @@ void BKE_material_append_id(struct Main *bmain, struct ID 
*id, struct Material *
 struct Material *BKE_material_pop_id(struct Main *bmain,
  struct ID *id,
  /* index is an int because of RNA. */
- int index,
- bool update_data);
-void BKE_material_clear_id(struct Main *bmain, struct ID *id, bool 
update_data);
+ int index);
+void BKE_material_clear_id(struct Main *bmain, struct ID *id);
 /* rendering */
 
 void ramp_blend(int type, float r_col[3], const float fac, const float col[3]);
diff --git a/source/blender/blenkernel/intern/material.c 
b/source/blender/blenkernel/intern/material.c
index b01c1189fd1..1545ae4f48f 100644
--- a/source/blender/blenkernel/intern/material.c
+++ b/source/blender/blenkernel/intern/material.c
@@ -461,7 +461,7 @@ void BKE_material_append_id(Main *bmain, ID *id, Material 
*ma)
   }
 }
 
-Material *BKE_material_pop_id(Main *bmain, ID *id, int index_i, bool 
update_data)
+Material *BKE_material_pop_id(Main *bmain, ID *id, int index_i)
 {
   short index = (short)index_i;
   Material *ret = NULL;
@@ -489,10 +489,7 @@ Material *BKE_material_pop_id(Main *bmain, ID *id, int 
index_i, bool update_data
 test_all_objects_materials(bmain, id);
   }
 
-  if (update_data) {
-/* decrease mat_nr index */
-material_data_index_remove_id(id, index);
-  }
+  material_data_index_remove_id(id, index);
 
   DEG_id_tag_update(id, ID_RECALC_COPY_ON_WRITE);
   DEG_relations_tag_update(bmain);
@@ -502,7 +499,7 @@ Material *BKE_material_pop_id(Main *bmain, ID *id, int 
index_i, bool update_data
   return ret;
 }
 
-void BKE_material_clear_id(Main *bmain, ID *id, bool update_data)
+void BKE_material_clear_id(Main *bmain, ID *id)
 {
   Material ***matar;
   if ((matar = give_matarar_id(id))) {
@@ -516,12 +513,9 @@ void BKE_material_clear_id(Main *bmain, ID *id, bool 
update_data)
   MEM_freeN(*matar);
   *matar = NULL;
 }
-test_all_objects_materials(bmain, id);
 
-if (update_data) {
-  /* decrease mat_nr index */
-  material_data_index_clear_id(id);
-}
+test_all_objects_materials(bmain, id);
+material_data_index_clear_id(id);
 
 DEG_id_tag_update(id, ID_RECALC_COPY_ON_WRITE);
 DEG_relations_tag_update(bmain);
diff --git a/source/blender/editors/mesh/editmesh_tools.c 
b/source/blender/editors/mesh/editmesh_tools.c
index f57e8141f27..4e58fee61a2 100644
--- a/source/blender/editors/mesh/editmesh_tools.c
+++ b/source/blender/editors/mesh/editmesh_tools.c
@@ -4040,7 +4040,7 @@ static void mesh_separate_material_assign_mat_nr(Main 
*bmain, Object *ob, const
   ma_obdata = NULL;
 }
 
-BKE_material_clear_id(bmain, obdata, true);
+BKE_material_clear_id(bmain, obdata);
 BKE_material_resize_object(bmain, ob, 1, true);
 BKE_material_resize_id(bmain, obdata, 1, true);
 
@@ -4051,7 +4051,7 @@ static void mesh_separate_material_assign_mat_nr(Main 
*bmain, Object *ob, const
 id_us_plus((ID *)ma_obdata);
   }
   else {
-BKE_material_clear_id(bmain, obdata, true);
+BKE_material_clear_id(bmain, obdata);
 BKE_material_resize_object(bmain, ob, 0, true);
 BKE_material_resize_id(bmain, obdata, 0, true);
   }
diff --git a/source/blender/makesrna/intern/rna_ID.c 
b/source/blender/makesrna/intern/rna_ID.c
index 57cdbbadeb8..7996750a1b8 100644
--- a/source/blender/makesrna/intern/rna_ID.c
+++ b/source/blender

[Bf-blender-cvs] [ee8aad79c15] master: Fix T56408: Hair children recalc on every frame on Alembic mesh

2019-08-16 Thread Sybren A. Stüvel
Commit: ee8aad79c1590cd0e98ba67961909ebfa8f6a803
Author: Sybren A. Stüvel
Date:   Fri Aug 16 14:52:08 2019 +0200
Branches: master
https://developer.blender.org/rBee8aad79c1590cd0e98ba67961909ebfa8f6a803

Fix T56408: Hair children recalc on every frame on Alembic mesh

This fixes the glitching hairs described in T56408, T63534, and possibly
also T63534.

The fix consists of returning the original mesh (i.e. as visible in edit
mode) when constructing the ORCO mesh. This allows a static set of
coordinates to be used when computing the child hair positions.

The original mesh is only returned when it has the same topology (at
least same number of vertices, loops, and polys. It's up the author of
the Alembic file to ensure stable geometry when it's desired to be
compatible with Blender's hair system.

Reviewers: mont29, brecht

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

===

M   source/blender/alembic/ABC_alembic.h
M   source/blender/alembic/intern/abc_mesh.cc
M   source/blender/alembic/intern/abc_mesh.h
M   source/blender/alembic/intern/abc_object.cc
M   source/blender/alembic/intern/abc_object.h
M   source/blender/alembic/intern/alembic_capi.cc
M   source/blender/modifiers/intern/MOD_meshsequencecache.c

===

diff --git a/source/blender/alembic/ABC_alembic.h 
b/source/blender/alembic/ABC_alembic.h
index 653382017d6..696e0ff1810 100644
--- a/source/blender/alembic/ABC_alembic.h
+++ b/source/blender/alembic/ABC_alembic.h
@@ -117,6 +117,12 @@ struct Mesh *ABC_read_mesh(struct CacheReader *reader,
const char **err_str,
int flags);
 
+bool ABC_mesh_topology_changed(struct CacheReader *reader,
+   struct Object *ob,
+   struct Mesh *existing_mesh,
+   const float time,
+   const char **err_str);
+
 void CacheReader_incref(struct CacheReader *reader);
 void CacheReader_free(struct CacheReader *reader);
 
diff --git a/source/blender/alembic/intern/abc_mesh.cc 
b/source/blender/alembic/intern/abc_mesh.cc
index 6647ca83bd6..be2793e38f7 100644
--- a/source/blender/alembic/intern/abc_mesh.cc
+++ b/source/blender/alembic/intern/abc_mesh.cc
@@ -1131,6 +1131,31 @@ bool AbcMeshReader::accepts_object_type(
   return true;
 }
 
+bool AbcMeshReader::topology_changed(Mesh *existing_mesh, const 
ISampleSelector &sample_sel)
+{
+  IPolyMeshSchema::Sample sample;
+  try {
+sample = m_schema.getValue(sample_sel);
+  }
+  catch (Alembic::Util::Exception &ex) {
+printf("Alembic: error reading mesh sample for '%s/%s' at time %f: %s\n",
+   m_iobject.getFullName().c_str(),
+   m_schema.getName().c_str(),
+   sample_sel.getRequestedTime(),
+   ex.what());
+// A similar error in read_mesh() would just return existing_mesh.
+return false;
+  }
+
+  const P3fArraySamplePtr &positions = sample.getPositions();
+  const Alembic::Abc::Int32ArraySamplePtr &face_indices = 
sample.getFaceIndices();
+  const Alembic::Abc::Int32ArraySamplePtr &face_counts = 
sample.getFaceCounts();
+
+  return positions->size() != existing_mesh->totvert ||
+ face_counts->size() != existing_mesh->totpoly ||
+ face_indices->size() != existing_mesh->totloop;
+}
+
 Mesh *AbcMeshReader::read_mesh(Mesh *existing_mesh,
const ISampleSelector &sample_sel,
int read_flag,
@@ -1162,10 +1187,7 @@ Mesh *AbcMeshReader::read_mesh(Mesh *existing_mesh,
   ImportSettings settings;
   settings.read_flag |= read_flag;
 
-  bool topology_changed = positions->size() != existing_mesh->totvert ||
-  face_counts->size() != existing_mesh->totpoly ||
-  face_indices->size() != existing_mesh->totloop;
-  if (topology_changed) {
+  if (topology_changed(existing_mesh, sample_sel)) {
 new_mesh = BKE_mesh_new_nomain_from_template(
 existing_mesh, positions->size(), 0, 0, face_indices->size(), 
face_counts->size());
 
diff --git a/source/blender/alembic/intern/abc_mesh.h 
b/source/blender/alembic/intern/abc_mesh.h
index 859ab121eb6..77686a0204e 100644
--- a/source/blender/alembic/intern/abc_mesh.h
+++ b/source/blender/alembic/intern/abc_mesh.h
@@ -110,6 +110,8 @@ class AbcMeshReader : public AbcObjectReader {
  const Alembic::Abc::ISampleSelector &sample_sel,
  int read_flag,
  const char **err_str);
+  bool topology_changed(Mesh *existing_mesh,
+const Alembic::Abc::ISampleSelector &sample_sel) 
override;
 
  private:
   void readFaceSetsSample(Main *bmain,
diff --gi

[Bf-blender-cvs] [078d02f5574] master: User Preferences: Added "Enabled add-ons only" preference

2019-08-16 Thread Sybren A. Stüvel
Commit: 078d02f55743cd34c51c4dd7ca710b22441a12da
Author: Sybren A. Stüvel
Date:   Thu Aug 15 10:21:04 2019 +0200
Branches: master
https://developer.blender.org/rB078d02f55743cd34c51c4dd7ca710b22441a12da

User Preferences: Added "Enabled add-ons only" preference

This checkbox replaces the "Disabled" and "Enabled" entries in the
filter drop-down. As a result, it now takes a single click to limit the
shown entries to enabled add-ons only. This is also an actual flag in
the preferences, and thus its state is saved between runs on Blender (in
contrast to the filter, which is always reset to "All").

Reviewed by: brecht, billreynish

===

M   release/scripts/startup/bl_operators/userpref.py
M   release/scripts/startup/bl_ui/__init__.py
M   release/scripts/startup/bl_ui/space_userpref.py
M   source/blender/makesdna/DNA_userdef_types.h
M   source/blender/makesrna/intern/rna_userdef.c

===

diff --git a/release/scripts/startup/bl_operators/userpref.py 
b/release/scripts/startup/bl_operators/userpref.py
index 034aa9fff6c..6ec6855296c 100644
--- a/release/scripts/startup/bl_operators/userpref.py
+++ b/release/scripts/startup/bl_operators/userpref.py
@@ -667,6 +667,7 @@ class PREFERENCES_OT_addon_install(Operator):
 info = addon_utils.module_bl_info(mod)
 
 # show the newly installed addon.
+context.preferences.view.show_addons_enabled_only = False
 context.window_manager.addon_filter = 'All'
 context.window_manager.addon_search = info["name"]
 break
@@ -796,6 +797,7 @@ class PREFERENCES_OT_addon_show(Operator):
 info["show_expanded"] = True
 
 context.preferences.active_section = 'ADDONS'
+context.preferences.view.show_addons_enabled_only = False
 context.window_manager.addon_filter = 'All'
 context.window_manager.addon_search = info["name"]
 bpy.ops.screen.userpref_show('INVOKE_DEFAULT')
diff --git a/release/scripts/startup/bl_ui/__init__.py 
b/release/scripts/startup/bl_ui/__init__.py
index 690a922b0d5..5daacbb2e44 100644
--- a/release/scripts/startup/bl_ui/__init__.py
+++ b/release/scripts/startup/bl_ui/__init__.py
@@ -126,8 +126,6 @@ def register():
 items = [
 ('All', "All", "All Add-ons"),
 ('User', "User", "All Add-ons Installed by User"),
-('Enabled', "Enabled", "All Enabled Add-ons"),
-('Disabled', "Disabled", "All Disabled Add-ons"),
 ]
 
 items_unique = set()
diff --git a/release/scripts/startup/bl_ui/space_userpref.py 
b/release/scripts/startup/bl_ui/space_userpref.py
index 87baea9cdd8..ce4a6fb835e 100644
--- a/release/scripts/startup/bl_ui/space_userpref.py
+++ b/release/scripts/startup/bl_ui/space_userpref.py
@@ -1744,6 +1744,7 @@ class USERPREF_PT_addons(Panel):
 row.operator("preferences.addon_refresh", icon='FILE_REFRESH', 
text="Refresh")
 
 row = layout.row()
+row.prop(context.preferences.view, "show_addons_enabled_only")
 row.prop(context.window_manager, "addon_filter", text="")
 row.prop(context.window_manager, "addon_search", text="", 
icon='VIEWZOOM')
 
@@ -1770,6 +1771,7 @@ class USERPREF_PT_addons(Panel):
 "(see console for details)",
 )
 
+show_enabled_only = context.preferences.view.show_addons_enabled_only
 filter = context.window_manager.addon_filter
 search = context.window_manager.addon_search.lower()
 support = context.window_manager.addon_support
@@ -1786,13 +1788,15 @@ class USERPREF_PT_addons(Panel):
 continue
 
 # check if addon should be visible with current filters
-if (
-(filter == "All") or
-(filter == info["category"]) or
-(filter == "Enabled" and is_enabled) or
-(filter == "Disabled" and not is_enabled) or
-(filter == "User" and 
(mod.__file__.startswith(addon_user_dirs)))
-):
+is_visible = (
+(filter == "All") or
+(filter == info["category"]) or
+(filter == "User" and 
(mod.__file__.startswith(addon_user_dirs)))
+)
+if show_enabled_only:
+is_visible = is_visible and is_enabled
+
+if is_visible:
 if search and search

[Bf-blender-cvs] [1fc4efd9661] temp-T96710-pbvh-pixels: Cleanup: remove incorrect comment

2022-04-08 Thread Sybren A. Stüvel
Commit: 1fc4efd966121285577accbf7a9a1034b84923bc
Author: Sybren A. Stüvel
Date:   Thu Apr 7 11:01:29 2022 +0200
Branches: temp-T96710-pbvh-pixels
https://developer.blender.org/rB1fc4efd966121285577accbf7a9a1034b84923bc

Cleanup: remove incorrect comment

No functional changes.

===

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

===

diff --git a/release/scripts/modules/bpy/ops.py 
b/release/scripts/modules/bpy/ops.py
index 838bd81c0d2..e19128e41a9 100644
--- a/release/scripts/modules/bpy/ops.py
+++ b/release/scripts/modules/bpy/ops.py
@@ -93,7 +93,6 @@ class _BPyOpsSubModOp:
 return self._module.upper() + "_OT_" + self._func
 
 def idname_py(self):
-# submod.foo -> SUBMOD_OT_foo
 return self._module + "." + self._func
 
 def __call__(self, *args, **kw):

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [e0abad2f6a2] temp-T96710-pbvh-pixels: Pose Library: avoid errors in the legacy panel when the add-on is disabled

2022-04-08 Thread Sybren A. Stüvel
Commit: e0abad2f6a2d416cf8ffc1803b3115870a58d6f4
Author: Sybren A. Stüvel
Date:   Thu Apr 7 11:27:19 2022 +0200
Branches: temp-T96710-pbvh-pixels
https://developer.blender.org/rBe0abad2f6a2d416cf8ffc1803b3115870a58d6f4

Pose Library: avoid errors in the legacy panel when the add-on is disabled

Avoid errors in the legacy Pose Library panel (in Armature properties)
when the Pose Library add-on is disabled.

It's unfortunate that a built-in panel now has knowledge of an add-on.
Then again, it's temporary (one or two Blender releases), and it now uses
feature detection instead of just assuming the add-on is enabled.

===

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

===

diff --git a/release/scripts/startup/bl_ui/properties_data_armature.py 
b/release/scripts/startup/bl_ui/properties_data_armature.py
index 5228c459d8c..6980f07eba4 100644
--- a/release/scripts/startup/bl_ui/properties_data_armature.py
+++ b/release/scripts/startup/bl_ui/properties_data_armature.py
@@ -188,8 +188,12 @@ class DATA_PT_pose_library(ArmatureButtonsPanel, Panel):
 col.template_ID(ob, "pose_library", new="poselib.new", 
unlink="poselib.unlink")
 
 if poselib:
-col.operator('poselib.convert_old_object_poselib',
-text="Convert to Pose Assets", icon="ASSET_MANAGER")
+if hasattr(bpy.types, 'POSELIB_OT_convert_old_object_poselib'):
+col.operator('poselib.convert_old_object_poselib',
+text="Convert to Pose Assets", icon="ASSET_MANAGER")
+else:
+col.label(text="Enable the Pose Library add-on to convert", 
icon="ERROR")
+col.label(text="this legacy pose library to pose assets.", 
icon="BLANK1")
 
 # Put the deprecated stuff in its own sub-layout.
 
@@ -226,7 +230,6 @@ class DATA_PT_pose_library(ArmatureButtonsPanel, Panel):
 ).pose_index = poselib.pose_markers.active_index
 
 col.operator("poselib.action_sanitize", icon='HELP', text="")  # 
XXX: put in menu?
-col.operator("poselib.convert_old_poselib", icon='ASSET_MANAGER', 
text="")
 
 if pose_marker_active is not None:
 col.operator("poselib.pose_move", icon='TRIA_UP', 
text="").direction = 'UP'

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [82c2e61fbdc] temp-T96710-pbvh-pixels: Cleanup: add clarifying comment to `bpy_app_getsets`

2022-04-08 Thread Sybren A. Stüvel
Commit: 82c2e61fbdc4ab05219a64f4aae42067d9c9cb59
Author: Sybren A. Stüvel
Date:   Thu Apr 7 12:51:48 2022 +0200
Branches: temp-T96710-pbvh-pixels
https://developer.blender.org/rB82c2e61fbdc4ab05219a64f4aae42067d9c9cb59

Cleanup: add clarifying comment to `bpy_app_getsets`

No functional changes.

===

M   source/blender/python/intern/bpy_app.c

===

diff --git a/source/blender/python/intern/bpy_app.c 
b/source/blender/python/intern/bpy_app.c
index 84fe27197f9..621cc79a8db 100644
--- a/source/blender/python/intern/bpy_app.c
+++ b/source/blender/python/intern/bpy_app.c
@@ -445,6 +445,8 @@ static PyGetSetDef bpy_app_getsets[] = {
  NULL,
  (void *)G_FLAG_SCRIPT_AUTOEXEC_FAIL_QUIET},
 {"autoexec_fail_message", bpy_app_autoexec_fail_message_get, NULL, NULL, 
NULL},
+
+/* End-of-list marker. */
 {NULL, NULL, NULL, NULL, NULL},
 };

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [9088eac81be] temp-T96710-pbvh-pixels: Pose Library: use the right icon for the "More Info" button

2022-04-08 Thread Sybren A. Stüvel
Commit: 9088eac81be14ead7bb987b75f432983ca275053
Author: Sybren A. Stüvel
Date:   Thu Apr 7 11:24:43 2022 +0200
Branches: temp-T96710-pbvh-pixels
https://developer.blender.org/rB9088eac81be14ead7bb987b75f432983ca275053

Pose Library: use the right icon for the "More Info" button

===

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

===

diff --git a/release/scripts/startup/bl_ui/properties_data_armature.py 
b/release/scripts/startup/bl_ui/properties_data_armature.py
index e436fe0b18d..5228c459d8c 100644
--- a/release/scripts/startup/bl_ui/properties_data_armature.py
+++ b/release/scripts/startup/bl_ui/properties_data_armature.py
@@ -177,7 +177,7 @@ class DATA_PT_pose_library(ArmatureButtonsPanel, Panel):
 col.label(text="which was replaced by the Asset Browser.")
 
 url = self.get_manual_url()
-col.operator('wm.url_open', text="More Info", icon="WORLD").url = url
+col.operator('wm.url_open', text="More Info", icon="URL").url = url
 
 layout.separator()

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [ecc58da] master: Documentation: fixed documented types to match actual types

2015-01-18 Thread Sybren A. Stüvel
Commit: ecc58da8f1d110498e700b804cb44adba1145113
Author: Sybren A. Stüvel
Date:   Sun Jan 18 11:08:33 2015 +0100
Branches: master
https://developer.blender.org/rBecc58da8f1d110498e700b804cb44adba1145113

Documentation: fixed documented types to match actual types

The BGE API uses Vectors, but often this was documented as list.

Maniphest Tasks: T43240

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

===

M   doc/python_api/rst/bge_types/bge.types.KX_CharacterWrapper.rst
M   doc/python_api/rst/bge_types/bge.types.KX_GameObject.rst
M   doc/python_api/rst/bge_types/bge.types.KX_ObjectActuator.rst
M   doc/python_api/rst/bge_types/bge.types.KX_Scene.rst
M   doc/python_api/rst/bge_types/bge.types.KX_VertexProxy.rst
M   doc/python_api/rst/bge_types/bge.types.SCA_PythonMouse.rst

===

diff --git a/doc/python_api/rst/bge_types/bge.types.KX_CharacterWrapper.rst 
b/doc/python_api/rst/bge_types/bge.types.KX_CharacterWrapper.rst
index 4d9dd5b..e326892 100644
--- a/doc/python_api/rst/bge_types/bge.types.KX_CharacterWrapper.rst
+++ b/doc/python_api/rst/bge_types/bge.types.KX_CharacterWrapper.rst
@@ -37,7 +37,7 @@ base class --- :class:`PyObjectPlus`
 
   The speed and direction the character is traveling in using world 
coordinates. This should be used instead of applyMovement() to properly move 
the character.
 
-  :type: list [x, y, z]
+  :type: Vector((x, y, z))
 
.. method:: jump()
 
diff --git a/doc/python_api/rst/bge_types/bge.types.KX_GameObject.rst 
b/doc/python_api/rst/bge_types/bge.types.KX_GameObject.rst
index 09f48fb..8b2edf1 100644
--- a/doc/python_api/rst/bge_types/bge.types.KX_GameObject.rst
+++ b/doc/python_api/rst/bge_types/bge.types.KX_GameObject.rst
@@ -135,7 +135,7 @@ base class --- :class:`SCA_IObject`
 
   the object's inertia vector in local coordinates. Read only.
 
-  :type: list [ix, iy, iz]
+  :type: Vector((ix, iy, iz))
 
.. attribute:: parent
 
@@ -517,7 +517,7 @@ base class --- :class:`SCA_IObject`
  * True: you get the "local" velocity ie: relative to object 
orientation.
   :type local: boolean
   :return: the object's linear velocity.
-  :rtype: list [vx, vy, vz]
+  :rtype: Vector((vx, vy, vz))
 
.. method:: setLinearVelocity(velocity, local=False)
 
@@ -544,7 +544,7 @@ base class --- :class:`SCA_IObject`
  * True: you get the "local" velocity ie: relative to object 
orientation.
   :type local: boolean
   :return: the object's angular velocity.
-  :rtype: list [vx, vy, vz]
+  :rtype: Vector((vx, vy, vz))
 
.. method:: setAngularVelocity(velocity, local=False)
 
@@ -568,7 +568,7 @@ base class --- :class:`SCA_IObject`
   :arg point: optional point to return the velocity for, in local 
coordinates.
   :type point: 3D Vector
   :return: the velocity at the specified point.
-  :rtype: list [vx, vy, vz]
+  :rtype: Vector((vx, vy, vz))
 
.. method:: getReactionForce()
 
@@ -578,7 +578,7 @@ base class --- :class:`SCA_IObject`
   This also includes impulses, eg from collisions.
 
   :return: the reaction force of this object.
-  :rtype: list [fx, fy, fz]
+  :rtype: Vector((fx, fy, fz))
 
   .. note::
 
@@ -906,4 +906,4 @@ base class --- :class:`SCA_IObject`
   :arg name: name of the property that added to the debug list.
   :type name: string
   :arg debug: the debug state.
-  :type debug: boolean
\ No newline at end of file
+  :type debug: boolean
diff --git a/doc/python_api/rst/bge_types/bge.types.KX_ObjectActuator.rst 
b/doc/python_api/rst/bge_types/bge.types.KX_ObjectActuator.rst
index f10f101..347b000 100644
--- a/doc/python_api/rst/bge_types/bge.types.KX_ObjectActuator.rst
+++ b/doc/python_api/rst/bge_types/bge.types.KX_ObjectActuator.rst
@@ -15,7 +15,7 @@ base class --- :class:`SCA_IActuator`
 
   The force applied by the actuator.
 
-  :type: list [x, y, z]
+  :type: Vector((x, y, z))
 
.. attribute:: useLocalForce
 
@@ -27,7 +27,7 @@ base class --- :class:`SCA_IActuator`
 
   The torque applied by the actuator.
 
-  :type: list [x, y, z]
+  :type: Vector((x, y, z))
 
.. attribute:: useLocalTorque
 
@@ -39,7 +39,7 @@ base class --- :class:`SCA_IActuator`
 
   The displacement vector applied by the actuator.
 
-  :type: list [x, y, z]
+  :type: Vector((x, y, z))
 
.. attribute:: useLocalDLoc
 
@@ -51,7 +51,7 @@ base class --- :class:`SCA_IActuator`
 
   The angular displacement vector applied by the actuator
 
-  :type: list [x, y, z]
+  :type: Vector((x, y, z))
   
   .. note::
   
@@ -67,7 +67,7 @@ base class --- :class:`SCA_IActuator`
 
   The linear velocity applied by the actuator.
 
-  :type: list [x, y, z]
+  :type: Vector((x, y, z))
 
.. attrib

[Bf-blender-cvs] [4c74fb2] master: Fix: ActionGroups.new() UI description copy-paste error

2015-01-19 Thread Sybren A. Stüvel
Commit: 4c74fb24a2b2229d11954c70ad8f29b5c943cd1d
Author: Sybren A. Stüvel
Date:   Mon Jan 19 12:58:48 2015 +0100
Branches: master
https://developer.blender.org/rB4c74fb24a2b2229d11954c70ad8f29b5c943cd1d

Fix: ActionGroups.new() UI description copy-paste error

===

M   source/blender/makesrna/intern/rna_action.c

===

diff --git a/source/blender/makesrna/intern/rna_action.c 
b/source/blender/makesrna/intern/rna_action.c
index e256d14..3fed505 100644
--- a/source/blender/makesrna/intern/rna_action.c
+++ b/source/blender/makesrna/intern/rna_action.c
@@ -533,7 +533,7 @@ static void rna_def_action_groups(BlenderRNA *brna, 
PropertyRNA *cprop)
RNA_def_struct_ui_text(srna, "Action Groups", "Collection of action 
groups");
 
func = RNA_def_function(srna, "new", "rna_Action_groups_new");
-   RNA_def_function_ui_description(func, "Add a keyframe to the curve");
+   RNA_def_function_ui_description(func, "Create a new action group and 
add it to the action");
parm = RNA_def_string(func, "name", "Group", 0, "", "New name for the 
action group");
RNA_def_property_flag(parm, PROP_REQUIRED);

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


[Bf-blender-cvs] [7165db5] master: Cleanup of BGE code CcdPhysicsEnvironment::CallbackTriggers()

2015-01-21 Thread Sybren A. Stüvel
Commit: 7165db53f2663b78749019ff791816c36e6182e6
Author: Sybren A. Stüvel
Date:   Wed Jan 21 18:42:24 2015 +0100
Branches: master
https://developer.blender.org/rB7165db53f2663b78749019ff791816c36e6182e6

Cleanup of BGE code CcdPhysicsEnvironment::CallbackTriggers()

Refactored some code to be easier to read. Semantically the code is
identical.

  - Some conditions were negated to be able to return/continue early,
rather than having the majority of the code inside an if-body.
  - Conditions were simplified (!(a == b)) turned into (a != b);
repeated conditions calculated only once.
  - Unnecessary variables and one unnecessary condition were
eliminated.

Reviewers: campbellbarton, lordloki

Reviewed By: lordloki

Projects: #game_physics

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

===

M   source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp

===

diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp 
b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
index 38e7df6..2046ad0 100644
--- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
+++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
@@ -2251,64 +2251,61 @@ bool 
CcdPhysicsEnvironment::RequestCollisionCallback(PHY_IPhysicsController* ctr
 
 void   CcdPhysicsEnvironment::CallbackTriggers()
 {
-   if (m_triggerCallbacks[PHY_OBJECT_RESPONSE] || (m_debugDrawer && 
(m_debugDrawer->getDebugMode() & btIDebugDraw::DBG_DrawContactPoints)))
-   {
-   //walk over all overlapping pairs, and if one of the involved 
bodies is registered for trigger callback, perform callback
-   btDispatcher* dispatcher = m_dynamicsWorld->getDispatcher();
-   int numManifolds = dispatcher->getNumManifolds();
-   for (int i=0;igetManifoldByIndexInternal(i);
-   int numContacts = manifold->getNumContacts();
-   if (numContacts)
-   {
-   const btRigidBody* rb0 = static_cast(manifold->getBody0());
-   const btRigidBody* rb1 = static_cast(manifold->getBody1());
-   if (m_debugDrawer && 
(m_debugDrawer->getDebugMode() & btIDebugDraw::DBG_DrawContactPoints))
-   {
-   for (int j=0;jgetContactPoint(j);
-   if (m_debugDrawer)
-   
m_debugDrawer->drawContactPoint(cp.m_positionWorldOnB,cp.m_normalWorldOnB,cp.getDistance(),cp.getLifeTime(),color);
-   }
-   }
-   const btRigidBody* obj0 = rb0;
-   const btRigidBody* obj1 = rb1;
+   bool draw_contact_points = m_debugDrawer && 
(m_debugDrawer->getDebugMode() & btIDebugDraw::DBG_DrawContactPoints);
 
-   //m_internalOwner is set in 
'addPhysicsController'
-   CcdPhysicsController* ctrl0 = 
static_cast(obj0->getUserPointer());
-   CcdPhysicsController* ctrl1 = 
static_cast(obj1->getUserPointer());
+   if (!m_triggerCallbacks[PHY_OBJECT_RESPONSE] && !draw_contact_points)
+   return;
 
-   std::set::const_iterator 
i = m_triggerControllers.find(ctrl0);
-   if (i == m_triggerControllers.end())
-   {
-   i = m_triggerControllers.find(ctrl1);
-   }
+   //walk over all overlapping pairs, and if one of the involved bodies is 
registered for trigger callback, perform callback
+   btDispatcher* dispatcher = m_dynamicsWorld->getDispatcher();
+   int numManifolds = dispatcher->getNumManifolds();
+   for (int i=0;igetManifoldByIndexInternal(i);
+   int numContacts = manifold->getNumContacts();
+   if (!numContacts) continue;
 
-   if (!(i == m_triggerControllers.end()))
-   {
-   
m_triggerCallbacks[PHY_OBJECT_RESPONSE](m_triggerCallbacksUserPtrs[PHY_OBJECT_RESPONSE],
-   ctrl0,ctrl1,0);
-   }
-   // Bullet does not refresh the manifold contact 
point for object without contact response
-   // may need to remove this when a newer Bullet 
version is integrated
-   if (!dispatcher->needsResponse(rb0, rb1))
-   {
-   

[Bf-blender-cvs] [895fa8b] master: Timeline: Draw keyframe lines at 60% height

2015-01-26 Thread Sybren A. Stüvel
Commit: 895fa8bc791d8c7a87e185b058a7ee647f64d48f
Author: Sybren A. Stüvel
Date:   Mon Jan 26 14:48:51 2015 +0100
Branches: master
https://developer.blender.org/rB895fa8bc791d8c7a87e185b058a7ee647f64d48f

Timeline: Draw keyframe lines at 60% height

This patch updates the timeline editor. Ordinarily, it draws the
yellow keyframe lines at 100% of the available height. This becomes an
issue when there are keyframes for every frame, which can happen when
importing motion capture data or recording animations from the BGE. In
such cases, the green "current frame" indicator becomes very hard to
see.

This patch restricts the drawing to the bottom 60% of the available
space, thereby making the "current frame" indicator more visible.

Reviewers: aligorith

Reviewed By: aligorith

Subscribers: Severin

Projects: #bf_blender

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

===

M   source/blender/editors/space_time/space_time.c

===

diff --git a/source/blender/editors/space_time/space_time.c 
b/source/blender/editors/space_time/space_time.c
index 7709980..c5ac67a 100644
--- a/source/blender/editors/space_time/space_time.c
+++ b/source/blender/editors/space_time/space_time.c
@@ -295,6 +295,8 @@ static void time_draw_idblock_keyframes(View2D *v2d, ID 
*id, short onlysel)
bDopeSheet ads = {NULL};
DLRBT_Tree keys;
ActKeyColumn *ak;
+   float ymin = v2d->tot.ymin;
+   float ymax = v2d->tot.ymax * 0.6f + ymin * 0.4f;

/* init binarytree-list for getting keyframes */
BLI_dlrbTree_init(&keys);
@@ -302,7 +304,7 @@ static void time_draw_idblock_keyframes(View2D *v2d, ID 
*id, short onlysel)
/* init dopesheet settings */
if (onlysel)
ads.filterflag |= ADS_FILTER_ONLYSEL;
-   
+
/* populate tree with keyframe nodes */
switch (GS(id->name)) {
case ID_SCE:
@@ -329,8 +331,8 @@ static void time_draw_idblock_keyframes(View2D *v2d, ID 
*id, short onlysel)
 (ak) && (ak->cfra <= v2d->cur.xmax);
 ak = ak->next)
{
-   glVertex2f(ak->cfra, v2d->tot.ymin);
-   glVertex2f(ak->cfra, v2d->tot.ymax);
+   glVertex2f(ak->cfra, ymin);
+   glVertex2f(ak->cfra, ymax);
}
glEnd(); // GL_LINES

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


[Bf-blender-cvs] [e5a852c] master: BGE: draw contact points as sphere + line indicating the surface normal.

2015-01-28 Thread Sybren A. Stüvel
Commit: e5a852c3f38fc11f0cc2c8e5837a2fcd9721c9f8
Author: Sybren A. Stüvel
Date:   Tue Jan 27 19:05:43 2015 +0100
Branches: master
https://developer.blender.org/rBe5a852c3f38fc11f0cc2c8e5837a2fcd9721c9f8

BGE: draw contact points as sphere + line indicating the surface normal.

A screenshot can be found at http://www.pasteall.org/pic/80766 -- it's the 
yellow balls + lines.

Reviewers: brita_, lordloki, campbellbarton

Reviewed By: lordloki, campbellbarton

Subscribers: lordloki

Projects: #game_physics

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

===

M   source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp

===

diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp 
b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
index 2046ad0..a7fd2e7 100644
--- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
+++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
@@ -2996,7 +2996,8 @@ structBlenderDebugDraw : public btIDebugDraw
 
virtual voiddrawContactPoint(const btVector3& PointOnB,const 
btVector3& normalOnB,float distance,int lifeTime,const btVector3& color)
{
-   //not yet
+   drawLine(PointOnB, PointOnB + normalOnB, color);
+   drawSphere(PointOnB, 0.1, color);
}
 
virtual voidsetDebugMode(int debugMode)

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


[Bf-blender-cvs] [dd67333] master: BGE: draw contact points + normals in yellow

2015-01-28 Thread Sybren A. Stüvel
Commit: dd673337f1e07ea9c593b7182dbb28752da22a87
Author: Sybren A. Stüvel
Date:   Tue Jan 27 19:06:44 2015 +0100
Branches: master
https://developer.blender.org/rBdd673337f1e07ea9c593b7182dbb28752da22a87

BGE: draw contact points + normals in yellow

Red was used with different semantics in the physics visualisation,
switching to yellow to prevent confusion.

A screenshot can be found at http://www.pasteall.org/pic/80766 -- it's
the yellow balls + lines.

Reviewers: brita_, lordloki, campbellbarton

Reviewed By: lordloki, campbellbarton

Subscribers: lordloki

Projects: #game_physics

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

===

M   source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp

===

diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp 
b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
index a7fd2e7..bcdc6f4 100644
--- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
+++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
@@ -2271,7 +2271,7 @@ void  CcdPhysicsEnvironment::CallbackTriggers()
{
for (int j=0;jgetContactPoint(j);

m_debugDrawer->drawContactPoint(cp.m_positionWorldOnB,

cp.m_normalWorldOnB,

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


[Bf-blender-cvs] [6912fe1] master: mathutils: let Vector.normalize() return the original length.

2015-01-29 Thread Sybren A. Stüvel
Commit: 6912fe132fbd37422ab62938cf2e823821cbbb2a
Author: Sybren A. Stüvel
Date:   Thu Jan 29 14:47:20 2015 +0100
Branches: master
https://developer.blender.org/rB6912fe132fbd37422ab62938cf2e823821cbbb2a

mathutils: let Vector.normalize() return the original length.

The length has to be calculated for normalization anyway, and it is already
returned by normalize_vn(vec, size).

===

M   source/blender/python/mathutils/mathutils_Vector.c

===

diff --git a/source/blender/python/mathutils/mathutils_Vector.c 
b/source/blender/python/mathutils/mathutils_Vector.c
index 167fb5b..640a335 100644
--- a/source/blender/python/mathutils/mathutils_Vector.c
+++ b/source/blender/python/mathutils/mathutils_Vector.c
@@ -349,6 +349,9 @@ PyDoc_STRVAR(Vector_normalize_doc,
 "\n"
 "   Normalize the vector, making the length of the vector always 1.0.\n"
 "\n"
+"   :return: the original length of the vector, before normalization\n"
+"   :rtype: float\n"
+"\n"
 "   .. warning:: Normalizing a vector where all values are zero has no 
effect.\n"
 "\n"
 "   .. note:: Normalize works for vectors of all sizes,\n"
@@ -356,14 +359,15 @@ PyDoc_STRVAR(Vector_normalize_doc,
 );
 static PyObject *Vector_normalize(VectorObject *self)
 {
+   float length;
int size = (self->size == 4 ? 3 : self->size);
if (BaseMath_ReadCallback(self) == -1)
return NULL;
 
-   normalize_vn(self->vec, size);
+   length = normalize_vn(self->vec, size);
 
(void)BaseMath_WriteCallback(self);
-   Py_RETURN_NONE;
+   return PyFloat_FromDouble(length);
 }
 PyDoc_STRVAR(Vector_normalized_doc,
 ".. method:: normalized()\n"

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


[Bf-blender-cvs] [8c7e1b6] master: Fix: correctly describing Quaternion.normalize()

2015-02-01 Thread Sybren A. Stüvel
Commit: 8c7e1b648b782542c4906ccb849c39b167265558
Author: Sybren A. Stüvel
Date:   Sat Jan 31 14:34:27 2015 +0100
Branches: master
https://developer.blender.org/rB8c7e1b648b782542c4906ccb849c39b167265558

Fix: correctly describing Quaternion.normalize()

The original comment seems to suggest that only the rotation vector
is normalized, leaving the rotation angle alone. This is not what happens,
though. The new comment matches the actual implementation, and the
implementation matches what is commonly understood as quaternion
normalization.

===

M   source/blender/python/mathutils/mathutils_Quaternion.c

===

diff --git a/source/blender/python/mathutils/mathutils_Quaternion.c 
b/source/blender/python/mathutils/mathutils_Quaternion.c
index d422634..98ee2fb 100644
--- a/source/blender/python/mathutils/mathutils_Quaternion.c
+++ b/source/blender/python/mathutils/mathutils_Quaternion.c
@@ -334,7 +334,8 @@ static PyObject *Quaternion_rotate(QuaternionObject *self, 
PyObject *value)
 }
 
 /* Quaternion.normalize() */
-/* normalize the axis of rotation of [theta, vector] */
+/* Normalize the quaternion. This may change the angle as well as the
+ * rotation axis, as all of (w, x, y, z) are scaled. */
 PyDoc_STRVAR(Quaternion_normalize_doc,
 ".. function:: normalize()\n"
 "\n"

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


[Bf-blender-cvs] [3bce98e] temp-mathutils: mathutils: added exponential map to Quaternion

2015-02-01 Thread Sybren A. Stüvel
Commit: 3bce98ec806b8ccc5d9f12c5b1370edbc0961b53
Author: Sybren A. Stüvel
Date:   Sun Feb 1 11:58:10 2015 +0100
Branches: temp-mathutils
https://developer.blender.org/rB3bce98ec806b8ccc5d9f12c5b1370edbc0961b53

mathutils: added exponential map to Quaternion

Added conversion to and from exponential map representation. This 
representation is useful for interpolation of > 2 quaternions, or in PD 
controllers.

Implementation in C functions `quat_to_expmap(...)` and `expmap_to_quat(...)` 
with Python API, unit tests and documentation.
Added Quaternion.to_exponential_map() and Quaternion(3-vector) to Python API.

Reviewers: campbellbarton

Projects: #bf_blender

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

===

M   doc/python_api/examples/mathutils.Quaternion.py
M   source/blender/blenlib/BLI_math_rotation.h
M   source/blender/blenlib/intern/math_rotation.c
M   source/blender/python/mathutils/mathutils_Quaternion.c
M   tests/python/bl_pyapi_mathutils.py

===

diff --git a/doc/python_api/examples/mathutils.Quaternion.py 
b/doc/python_api/examples/mathutils.Quaternion.py
index d8c696e..7e5538b 100644
--- a/doc/python_api/examples/mathutils.Quaternion.py
+++ b/doc/python_api/examples/mathutils.Quaternion.py
@@ -21,3 +21,12 @@ print(quat_out)
 print("%.2f, %.2f, %.2f" % tuple(math.degrees(a) for a in quat_out.to_euler()))
 print("(%.2f, %.2f, %.2f), %.2f" % (quat_out.axis[:] +
 (math.degrees(quat_out.angle), )))
+
+# multiple rotations can be interpolated using the exponential map
+quat_c = mathutils.Quaternion((1.0, 0.0, 0.0), math.radians(15.0))
+exp_avg = (quat_a.to_exponential_map() +
+   quat_b.to_exponential_map() +
+   quat_c.to_exponential_map()) / 3.0
+quat_avg = mathutils.Quaternion(exp_avg)
+print("Average rotation:")
+print(quat_avg)
diff --git a/source/blender/blenlib/BLI_math_rotation.h 
b/source/blender/blenlib/BLI_math_rotation.h
index 905889a..c1ce6c9 100644
--- a/source/blender/blenlib/BLI_math_rotation.h
+++ b/source/blender/blenlib/BLI_math_rotation.h
@@ -119,6 +119,10 @@ void mat4_to_axis_angle(float axis[3], float *angle, float 
M[4][4]);
 void axis_angle_to_mat3_single(float R[3][3], const char axis, const float 
angle);
 void  angle_to_mat2(float R[2][2], const float angle);
 
+/** Exponential Map **/
+void quat_to_expmap(float expmap[3], const float q[4]);
+void expmap_to_quat(float r[4], const float expmap[3]);
+
 / XYZ Eulers */
 
 void eul_to_quat(float quat[4], const float eul[3]);
diff --git a/source/blender/blenlib/intern/math_rotation.c 
b/source/blender/blenlib/intern/math_rotation.c
index 3ac031d..f13d795 100644
--- a/source/blender/blenlib/intern/math_rotation.c
+++ b/source/blender/blenlib/intern/math_rotation.c
@@ -1016,6 +1016,33 @@ void angle_to_mat2(float mat[2][2], const float angle)
mat[1][1] =  angle_cos;
 }
 
+/** Exponential Map **/
+void quat_to_expmap(float expmap[3], const float q[4])
+{
+   float quat[4];
+   float angle;
+
+   /* Obtain axis/angle representation. */
+   normalize_qt_qt(quat, q);
+   quat_to_axis_angle(expmap, &angle, quat);
+
+   /* Convert to exponential map. */
+   mul_vn_fl(expmap, 3, angle);
+}
+
+void expmap_to_quat(float r[4], const float expmap[3])
+{
+   float angle;
+   float axis[3];
+
+   /* Obtain axis/angle representation. */
+   angle = normalize_v3_v3(axis, expmap);
+   angle = angle_wrap_rad(angle);
+
+   /* Convert to quaternion. */
+   axis_angle_to_quat(r, axis, angle);
+}
+
 / XYZ Eulers */
 
 /* XYZ order */
diff --git a/source/blender/python/mathutils/mathutils_Quaternion.c 
b/source/blender/python/mathutils/mathutils_Quaternion.c
index 98ee2fb..48f8e53 100644
--- a/source/blender/python/mathutils/mathutils_Quaternion.c
+++ b/source/blender/python/mathutils/mathutils_Quaternion.c
@@ -177,6 +177,29 @@ static PyObject *Quaternion_to_axis_angle(QuaternionObject 
*self)
return ret;
 }
 
+PyDoc_STRVAR(Quaternion_to_exponential_map_doc,
+".. method:: to_exponential_map()\n"
+"\n"
+"   Return the exponential map representation of the quaternion.\n"
+"\n"
+"   This representation consist of the rotation axis multiplied by the 
rotation\n"
+"   angle. Such a representation is useful for interpolation between 
multiple\n"
+"   orientations.\n"
+"\n"
+"   :return: exponential map.\n"
+"   :rtype: :class:`Vector` of size 3\n"
+);
+static PyObject *Quaternion_to_exponen

[Bf-blender-cvs] [9fa628f] master: mathutils: added exponential map to Quaternion

2015-02-01 Thread Sybren A. Stüvel
Commit: 9fa628f35be31a18edfdb1e1fca8a6bd3b6b453c
Author: Sybren A. Stüvel
Date:   Sun Feb 1 11:58:10 2015 +0100
Branches: master
https://developer.blender.org/rB9fa628f35be31a18edfdb1e1fca8a6bd3b6b453c

mathutils: added exponential map to Quaternion

Added conversion to and from exponential map representation. This
representation is useful for interpolation of > 2 quaternions, or in
PD controllers.

Implementation in C functions quat_to_expmap,
quat_normalized_to_expmap, and expmap_to_quat with Python API, unit
tests and documentation.

Added Quaternion.to_exponential_map() and Quaternion(3-vector) to
Python API.

Reviewers: campbellbarton

Projects: #bf_blender

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

===

M   doc/python_api/examples/mathutils.Quaternion.py
M   source/blender/blenlib/BLI_math_rotation.h
M   source/blender/blenlib/intern/math_rotation.c
M   source/blender/python/mathutils/mathutils_Quaternion.c
M   tests/python/bl_pyapi_mathutils.py

===

diff --git a/doc/python_api/examples/mathutils.Quaternion.py 
b/doc/python_api/examples/mathutils.Quaternion.py
index d8c696e..7e5538b 100644
--- a/doc/python_api/examples/mathutils.Quaternion.py
+++ b/doc/python_api/examples/mathutils.Quaternion.py
@@ -21,3 +21,12 @@ print(quat_out)
 print("%.2f, %.2f, %.2f" % tuple(math.degrees(a) for a in quat_out.to_euler()))
 print("(%.2f, %.2f, %.2f), %.2f" % (quat_out.axis[:] +
 (math.degrees(quat_out.angle), )))
+
+# multiple rotations can be interpolated using the exponential map
+quat_c = mathutils.Quaternion((1.0, 0.0, 0.0), math.radians(15.0))
+exp_avg = (quat_a.to_exponential_map() +
+   quat_b.to_exponential_map() +
+   quat_c.to_exponential_map()) / 3.0
+quat_avg = mathutils.Quaternion(exp_avg)
+print("Average rotation:")
+print(quat_avg)
diff --git a/source/blender/blenlib/BLI_math_rotation.h 
b/source/blender/blenlib/BLI_math_rotation.h
index 905889a..fbd026f 100644
--- a/source/blender/blenlib/BLI_math_rotation.h
+++ b/source/blender/blenlib/BLI_math_rotation.h
@@ -119,6 +119,11 @@ void mat4_to_axis_angle(float axis[3], float *angle, float 
M[4][4]);
 void axis_angle_to_mat3_single(float R[3][3], const char axis, const float 
angle);
 void  angle_to_mat2(float R[2][2], const float angle);
 
+/** Exponential Map **/
+void quat_to_expmap(float expmap[3], const float q[4]);
+void quat_normalized_to_expmap(float expmap[3], const float q[4]);
+void expmap_to_quat(float r[4], const float expmap[3]);
+
 / XYZ Eulers */
 
 void eul_to_quat(float quat[4], const float eul[3]);
diff --git a/source/blender/blenlib/intern/math_rotation.c 
b/source/blender/blenlib/intern/math_rotation.c
index 3ac031d..3d5d47b 100644
--- a/source/blender/blenlib/intern/math_rotation.c
+++ b/source/blender/blenlib/intern/math_rotation.c
@@ -1016,6 +1016,40 @@ void angle_to_mat2(float mat[2][2], const float angle)
mat[1][1] =  angle_cos;
 }
 
+/** Exponential Map **/
+
+void quat_normalized_to_expmap(float expmap[3], const float q[4])
+{
+   float angle;
+   BLI_ASSERT_UNIT_QUAT(q);
+
+   /* Obtain axis/angle representation. */
+   quat_to_axis_angle(expmap, &angle, q);
+
+   /* Convert to exponential map. */
+   mul_v3_fl(expmap, angle);
+}
+
+void quat_to_expmap(float expmap[3], const float q[4])
+{
+   float q_no[4];
+   normalize_qt_qt(q_no, q);
+   quat_normalized_to_expmap(expmap, q_no);
+}
+
+void expmap_to_quat(float r[4], const float expmap[3])
+{
+   float axis[3];
+   float angle;
+
+   /* Obtain axis/angle representation. */
+   angle = normalize_v3_v3(axis, expmap);
+   angle = angle_wrap_rad(angle);
+
+   /* Convert to quaternion. */
+   axis_angle_to_quat(r, axis, angle);
+}
+
 / XYZ Eulers */
 
 /* XYZ order */
diff --git a/source/blender/python/mathutils/mathutils_Quaternion.c 
b/source/blender/python/mathutils/mathutils_Quaternion.c
index 98ee2fb..786a932 100644
--- a/source/blender/python/mathutils/mathutils_Quaternion.c
+++ b/source/blender/python/mathutils/mathutils_Quaternion.c
@@ -177,6 +177,28 @@ static PyObject *Quaternion_to_axis_angle(QuaternionObject 
*self)
return ret;
 }
 
+PyDoc_STRVAR(Quaternion_to_exponential_map_doc,
+".. method:: to_exponential_map()\n"
+"\n"
+"   Return the exponential map representation of the quaternion.\n"
+"\n"
+"   This representation consist of the rotation axis multiplied by the 
rotation angle."
+"   Such a representation is useful for interpolation be

[Bf-blender-cvs] [2e6e92c] master: Documentation: Support documenting constructors in class __doc__

2015-02-01 Thread Sybren A. Stüvel
Commit: 2e6e92cf50f3f0845757e1bd6afe8814e93d13f7
Author: Sybren A. Stüvel
Date:   Sun Feb 1 14:00:37 2015 +0100
Branches: master
https://developer.blender.org/rB2e6e92cf50f3f0845757e1bd6afe8814e93d13f7

Documentation: Support documenting constructors in class __doc__

Python types defined in C can now start their docstring with a
`.. class:: TypeName(args)` line, to document their constructor.
In that case the documentation writer is responsible for indenting the
remainder of the docstring by 3 spaces, matching the generated
documentation.

===

M   doc/python_api/sphinx_doc_gen.py

===

diff --git a/doc/python_api/sphinx_doc_gen.py b/doc/python_api/sphinx_doc_gen.py
index 7ffb448..344e676 100644
--- a/doc/python_api/sphinx_doc_gen.py
+++ b/doc/python_api/sphinx_doc_gen.py
@@ -937,10 +937,16 @@ def pymodule2sphinx(basepath, module_name, module, title):
 fw(title_string(heading, heading_char))
 
 # May need to be its own function
-fw(".. class:: %s\n\n" % type_name)
 if value.__doc__:
-write_indented_lines("   ", fw, value.__doc__, False)
-fw("\n")
+if value.__doc__.startswith(".. class::"):
+fw(value.__doc__)
+else:
+fw(".. class:: %s\n\n" % type_name)
+write_indented_lines("   ", fw, value.__doc__, False)
+else:
+fw(".. class:: %s\n\n" % type_name)
+fw("\n")
+
 write_example_ref("   ", fw, module_name + "." + type_name)
 
 descr_items = [(key, descr) for key, descr in 
sorted(value.__dict__.items()) if not key.startswith("__")]

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


[Bf-blender-cvs] [dbb06c5] temp-mathutils-doc: Documentation: updated mathutils documentation

2015-02-01 Thread Sybren A. Stüvel
Commit: dbb06c5fe587a23ef4f56b859630e3cd1e254ceb
Author: Sybren A. Stüvel
Date:   Sun Feb 1 16:06:32 2015 +0100
Branches: temp-mathutils-doc
https://developer.blender.org/rBdbb06c5fe587a23ef4f56b859630e3cd1e254ceb

Documentation: updated mathutils documentation

Added descriptions of the constructors, and improved the module-level doc
to link to the classes.

===

M   source/blender/python/mathutils/mathutils.c
M   source/blender/python/mathutils/mathutils_Color.c
M   source/blender/python/mathutils/mathutils_Euler.c
M   source/blender/python/mathutils/mathutils_Matrix.c
M   source/blender/python/mathutils/mathutils_Quaternion.c
M   source/blender/python/mathutils/mathutils_Vector.c

===

diff --git a/source/blender/python/mathutils/mathutils.c 
b/source/blender/python/mathutils/mathutils.c
index ecaaae8..ad73d77 100644
--- a/source/blender/python/mathutils/mathutils.c
+++ b/source/blender/python/mathutils/mathutils.c
@@ -38,7 +38,11 @@
 #endif
 
 PyDoc_STRVAR(M_Mathutils_doc,
-"This module provides access to matrices, eulers, quaternions and vectors."
+"This module provides access to the math classes :class:`Color`,\n"
+":class:`Euler`, :class:`Matrix`, :class:`Quaternion` and :class:`Vector`.\n"
+"\n"
+"Classes and methods that accept Vectors also accept other numeric 
sequences,\n"
+"such as tuples and lists."
 );
 static int mathutils_array_parse_fast(float *array,
   int size,
diff --git a/source/blender/python/mathutils/mathutils_Color.c 
b/source/blender/python/mathutils/mathutils_Color.c
index 8426038..17b36f8 100644
--- a/source/blender/python/mathutils/mathutils_Color.c
+++ b/source/blender/python/mathutils/mathutils_Color.c
@@ -811,7 +811,12 @@ static struct PyMethodDef Color_methods[] = {
 
 /* --PY_OBECT DEFINITION-- */
 PyDoc_STRVAR(color_doc,
-"This object gives access to Colors in Blender."
+".. class:: Color(rgb)\n"
+"\n"
+"   :param rgb: (r, g, b) color values\n"
+"   :type rgb: 3-:class:`Vector`\n"
+"\n"
+"   This object gives access to Colors in Blender.\n"
 );
 PyTypeObject color_Type = {
PyVarObject_HEAD_INIT(NULL, 0)
diff --git a/source/blender/python/mathutils/mathutils_Euler.c 
b/source/blender/python/mathutils/mathutils_Euler.c
index 9c0ced3..b9893b9 100644
--- a/source/blender/python/mathutils/mathutils_Euler.c
+++ b/source/blender/python/mathutils/mathutils_Euler.c
@@ -657,6 +657,13 @@ static struct PyMethodDef Euler_methods[] = {
 
 /* --PY_OBECT DEFINITION-- */
 PyDoc_STRVAR(euler_doc,
+".. class:: Euler(angles, order='XYZ')\n"
+"\n"
+"   :param angles: three angles, in radians\n"
+"   :type angles: 3-:class:`Vector`\n"
+"   :param order: order of the angles, a permutation of 'XYZ'\n"
+"   :type order: str\n"
+"\n"
 "This object gives access to Eulers in Blender."
 );
 PyTypeObject euler_Type = {
diff --git a/source/blender/python/mathutils/mathutils_Matrix.c 
b/source/blender/python/mathutils/mathutils_Matrix.c
index 4706c09..298925e 100644
--- a/source/blender/python/mathutils/mathutils_Matrix.c
+++ b/source/blender/python/mathutils/mathutils_Matrix.c
@@ -2716,7 +2716,14 @@ static struct PyMethodDef Matrix_methods[] = {
 
 /*--PY_OBECT DEFINITION--*/
 PyDoc_STRVAR(matrix_doc,
-"This object gives access to Matrices in Blender."
+".. class:: Matrix([sequence_of_rows])\n"
+"\n"
+"   :param sequence_of_rows: Sequence of rows (which are sequences of 
floats).\n"
+"When ommitted, a 4x4 identity matrix is 
constructed.\n"
+"   :type sequence_of_rows: tuple or list\n"
+"\n"
+"This object gives access to Matrices in Blender, supporting square and 
rectangular\n"
+"matrices from 2x2 up to 4x4.\n"
 );
 PyTypeObject matrix_Type = {
PyVarObject_HEAD_INIT(NULL, 0)
diff --git a/source/blender/python/mathutils/mathutils_Quaternion.c 
b/source/blender/python/mathutils/mathutils_Quaternion.c
index 786a932..2d782e8 100644
--- a/source/blender/python/mathutils/mathutils_Quaternion.c
+++ b/source/blender/python/mathutils/mathutils_Quaternion.c
@@ -187,6 +187,8 @@ PyDoc_STRVAR(Quaternion_to_exponential_map_doc,
 "\n"
 "   :return: exponential map.\n"
 "   :rtype: :class:`Vector` of size 3\n"
+"\n"
+"   To convert back to a quaternion, pass it to the :class:`Quaternion` 
constructor.\n"
 );
 static PyObject *Quaternion_to_exponential_map(QuaternionObject *self)
 {
@@ -1226,7 +1228,30

[Bf-blender-cvs] [baa8b63] master: Documentation: updated mathutils documentation

2015-02-01 Thread Sybren A. Stüvel
Commit: baa8b63111f2ac5439155b6e0807a22f550b40f0
Author: Sybren A. Stüvel
Date:   Sun Feb 1 16:06:32 2015 +0100
Branches: master
https://developer.blender.org/rBbaa8b63111f2ac5439155b6e0807a22f550b40f0

Documentation: updated mathutils documentation

Added descriptions of the constructors, and improved the module-level
documentation.

===

M   source/blender/python/mathutils/mathutils.c
M   source/blender/python/mathutils/mathutils_Color.c
M   source/blender/python/mathutils/mathutils_Euler.c
M   source/blender/python/mathutils/mathutils_Matrix.c
M   source/blender/python/mathutils/mathutils_Quaternion.c
M   source/blender/python/mathutils/mathutils_Vector.c

===

diff --git a/source/blender/python/mathutils/mathutils.c 
b/source/blender/python/mathutils/mathutils.c
index ecaaae8..ca20f83 100644
--- a/source/blender/python/mathutils/mathutils.c
+++ b/source/blender/python/mathutils/mathutils.c
@@ -38,7 +38,18 @@
 #endif
 
 PyDoc_STRVAR(M_Mathutils_doc,
-"This module provides access to matrices, eulers, quaternions and vectors."
+"This module provides access to the math classes:\n"
+"\n"
+"- :class:`Color`,\n"
+"- :class:`Euler`,\n"
+"- :class:`Matrix`,\n"
+"- :class:`Quaternion`,\n"
+"- :class:`Vector`,\n"
+"\n"
+".. note::\n"
+"\n"
+"   Classes, methods and attributes that accept vectors also accept other 
numeric sequences,\n"
+"   such as tuples, lists."
 );
 static int mathutils_array_parse_fast(float *array,
   int size,
diff --git a/source/blender/python/mathutils/mathutils_Color.c 
b/source/blender/python/mathutils/mathutils_Color.c
index 8426038..ce59099 100644
--- a/source/blender/python/mathutils/mathutils_Color.c
+++ b/source/blender/python/mathutils/mathutils_Color.c
@@ -811,7 +811,12 @@ static struct PyMethodDef Color_methods[] = {
 
 /* --PY_OBECT DEFINITION-- */
 PyDoc_STRVAR(color_doc,
-"This object gives access to Colors in Blender."
+".. class:: Color(rgb)\n"
+"\n"
+"   This object gives access to Colors in Blender.\n"
+"\n"
+"   :param rgb: (r, g, b) color values\n"
+"   :type rgb: 3d vector\n"
 );
 PyTypeObject color_Type = {
PyVarObject_HEAD_INIT(NULL, 0)
diff --git a/source/blender/python/mathutils/mathutils_Euler.c 
b/source/blender/python/mathutils/mathutils_Euler.c
index 9c0ced3..edb4af0 100644
--- a/source/blender/python/mathutils/mathutils_Euler.c
+++ b/source/blender/python/mathutils/mathutils_Euler.c
@@ -657,7 +657,14 @@ static struct PyMethodDef Euler_methods[] = {
 
 /* --PY_OBECT DEFINITION-- */
 PyDoc_STRVAR(euler_doc,
-"This object gives access to Eulers in Blender."
+".. class:: Euler(angles, order='XYZ')\n"
+"\n"
+"   This object gives access to Eulers in Blender.\n"
+"\n"
+"   :param angles: Three angles, in radians.\n"
+"   :type angles: 3d vector\n"
+"   :param order: Optional order of the angles, a permutation of ``XYZ``.\n"
+"   :type order: str\n"
 );
 PyTypeObject euler_Type = {
PyVarObject_HEAD_INIT(NULL, 0)
diff --git a/source/blender/python/mathutils/mathutils_Matrix.c 
b/source/blender/python/mathutils/mathutils_Matrix.c
index 4706c09..95b5325 100644
--- a/source/blender/python/mathutils/mathutils_Matrix.c
+++ b/source/blender/python/mathutils/mathutils_Matrix.c
@@ -2716,7 +2716,14 @@ static struct PyMethodDef Matrix_methods[] = {
 
 /*--PY_OBECT DEFINITION--*/
 PyDoc_STRVAR(matrix_doc,
-"This object gives access to Matrices in Blender."
+".. class:: Matrix([rows])\n"
+"\n"
+"   This object gives access to Matrices in Blender, supporting square and 
rectangular\n"
+"   matrices from 2x2 up to 4x4.\n"
+"\n"
+"   :param rows: Sequence of rows.\n"
+"   When ommitted, a 4x4 identity matrix is constructed.\n"
+"   :type rows: 2d number sequence\n"
 );
 PyTypeObject matrix_Type = {
PyVarObject_HEAD_INIT(NULL, 0)
diff --git a/source/blender/python/mathutils/mathutils_Quaternion.c 
b/source/blender/python/mathutils/mathutils_Quaternion.c
index 786a932..42be316 100644
--- a/source/blender/python/mathutils/mathutils_Quaternion.c
+++ b/source/blender/python/mathutils/mathutils_Quaternion.c
@@ -187,6 +187,8 @@ PyDoc_STRVAR(Quaternion_to_exponential_map_doc,
 "\n"
 "   :return: exponential map.\n"
 "   :rtype: :class:`Vector` of size 3\n"
+"\n"
+"   To convert back to a quaternion, pass it to the :class:`Quaternion` 

[Bf-blender-cvs] [32482aa] master: BGE physics: allow higher values for maxlogicstep and maxphystep

2015-02-04 Thread Sybren A. Stüvel
Commit: 32482aadb8ecc4c2d1f2dd73124d1b94f0febe57
Author: Sybren A. Stüvel
Date:   Wed Feb 4 14:15:40 2015 +0100
Branches: master
https://developer.blender.org/rB32482aadb8ecc4c2d1f2dd73124d1b94f0febe57

BGE physics: allow higher values for maxlogicstep and maxphystep

Increasing those values beyond 5 is important for exact physics
simulation. Soft limit is increased to 50, hard limit to 1.

To be able to set different values for hardlimit and softlimit,
RNA_def_property_range needs to precede RNA_def_property_range, hence
the swapped order.

===

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

===

diff --git a/source/blender/makesrna/intern/rna_scene.c 
b/source/blender/makesrna/intern/rna_scene.c
index 7ebbf0b..931c772 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -3623,8 +3623,8 @@ static void rna_def_scene_game_data(BlenderRNA *brna)
 
prop = RNA_def_property(srna, "logic_step_max", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "maxlogicstep");
-   RNA_def_property_ui_range(prop, 1, 5, 1, 1);
-   RNA_def_property_range(prop, 1, 5);
+   RNA_def_property_range(prop, 1, 1);
+   RNA_def_property_ui_range(prop, 1, 50, 1, 1);
RNA_def_property_ui_text(prop, "Max Logic Steps",
 "Maximum number of logic frame per game frame 
if graphics slows down the game, "
 "higher value allows better synchronization 
with physics");
@@ -3632,8 +3632,8 @@ static void rna_def_scene_game_data(BlenderRNA *brna)
 
prop = RNA_def_property(srna, "physics_step_max", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "maxphystep");
-   RNA_def_property_ui_range(prop, 1, 5, 1, 1);
-   RNA_def_property_range(prop, 1, 5);
+   RNA_def_property_range(prop, 1, 1);
+   RNA_def_property_ui_range(prop, 1, 50, 1, 1);
RNA_def_property_ui_text(prop, "Max Physics Steps",
 "Maximum number of physics step per game frame 
if graphics slows down the game, "
 "higher value allows physics to keep up with 
realtime");

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


[Bf-blender-cvs] [dd65a44] master: BGE physics: When colliding, report first contact point to Python

2015-02-08 Thread Sybren A. Stüvel
Commit: dd65a44c9a192d62f7661090682ee0dc99fb0491
Author: Sybren A. Stüvel
Date:   Thu Feb 5 09:39:53 2015 +0100
Branches: master
https://developer.blender.org/rBdd65a44c9a192d62f7661090682ee0dc99fb0491

BGE physics: When colliding, report first contact point to Python

This patch adds two parameters to the functions in the
collisionCallbacks list. The callback function should thus be like
this:

```
def on_colliding(other, point, normal):
print("Colliding with %s at %s with normal %s" % (other, point, normal))

game_ob.collisionCallbacks.append(on_colliding)
```

The `point` parameter will contain the collision point in world
coordinates on the current object, and the `normal` contains the
surface normal at the collision point.

The callback functions are checked for the number of arguments
`co_argcount`. The new `point` and `normal` arguments are only passed
when `co_argcount > 1` or when `co_argcount` cannot be determined.

Reviewers: brita_, campbellbarton

Subscribers: sergey, sybren, agoose77

Projects: #game_physics

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

===

M   doc/python_api/rst/bge_types/bge.types.KX_GameObject.rst
M   source/gameengine/Ketsji/KX_GameObject.cpp
M   source/gameengine/Ketsji/KX_GameObject.h
M   source/gameengine/Ketsji/KX_TouchEventManager.cpp
M   source/gameengine/Ketsji/KX_TouchEventManager.h
M   source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp

===

diff --git a/doc/python_api/rst/bge_types/bge.types.KX_GameObject.rst 
b/doc/python_api/rst/bge_types/bge.types.KX_GameObject.rst
index 8b2edf1..4a9e5da 100644
--- a/doc/python_api/rst/bge_types/bge.types.KX_GameObject.rst
+++ b/doc/python_api/rst/bge_types/bge.types.KX_GameObject.rst
@@ -157,9 +157,46 @@ base class --- :class:`SCA_IObject`
 
.. attribute:: collisionCallbacks
 
-  A list of callables to be run when a collision occurs.
+  A list of functions to be called when a collision occurs.
 
-  :type: list
+  :type: list of functions and/or methods
+
+  Callbacks should either accept one argument `(object)`, or three
+  arguments `(object, point, normal)`. For simplicity, per
+  colliding object only the first collision point is reported.
+
+  .. code-block:: python
+
+# Function form
+def callback_three(object, point, normal):
+print('Hit by %r at %s with normal %s' % (object.name, point, 
normal))
+
+def callback_one(object):
+print('Hit by %r' % object.name)
+
+def register_callback(controller):
+controller.owner.collisionCallbacks.append(callback_three)
+controller.owner.collisionCallbacks.append(callback_one)
+
+
+# Method form
+class YourGameEntity(bge.types.KX_GameObject):
+def __init__(self, old_owner):
+self.collisionCallbacks.append(self.on_collision_three)
+self.collisionCallbacks.append(self.on_collision_one)
+
+def on_collision_three(self, object, point, normal):
+print('Hit by %r at %s with normal %s' % (object.name, point, 
normal))
+
+def on_collision_one(self, object):
+print('Hit by %r' % object.name)
+
+  .. note::
+For backward compatibility, a callback with variable number of
+arguments (using `*args`) will be passed only the `object`
+argument. Only when there is more than one fixed argument (not
+counting `self` for methods) will the three-argument form be
+used.
 
.. attribute:: scene
 
diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp 
b/source/gameengine/Ketsji/KX_GameObject.cpp
index e8b68d2..6d4b556 100644
--- a/source/gameengine/Ketsji/KX_GameObject.cpp
+++ b/source/gameengine/Ketsji/KX_GameObject.cpp
@@ -77,6 +77,8 @@ typedef unsigned long uint_ptr;
 #include "BL_Action.h"
 
 #include "PyObjectPlus.h" /* python stuff */
+#include "BLI_utildefines.h"
+#include "python_utildefines.h"
 
 // This file defines relationships between parents and children
 // in the game engine.
@@ -1498,7 +1500,7 @@ void KX_GameObject::RegisterCollisionCallbacks()
pe->AddSensor(spc);
}
 }
-void KX_GameObject::RunCollisionCallbacks(KX_GameObject *collider)
+void KX_GameObject::RunCollisionCallbacks(KX_GameObject *collider, const 
MT_Vector3 &point, const MT_Vector3 &normal)
 {
#ifdef WITH_PYTHON
Py_ssize_t len;
@@ -1506,15 +1508,50 @@ void KX_GameObject::RunCollisionCallbacks(KX_GameObject 
*collider)
 
if (collision_callbacks && (len=PyList_GET_SIZE(collision_callbacks)))
{
-   PyObject* args = Py_BuildValue("(O)", collider->GetProxy()); // 
save python c

[Bf-blender-cvs] [59c0a1e] master: Typo fix + clarification in mathutils.Vector example

2015-02-10 Thread Sybren A. Stüvel
Commit: 59c0a1e7c8df1c44df1bd0b459e3e17c481c4e76
Author: Sybren A. Stüvel
Date:   Tue Feb 10 21:25:01 2015 +0100
Branches: master
https://developer.blender.org/rB59c0a1e7c8df1c44df1bd0b459e3e17c481c4e76

Typo fix + clarification in mathutils.Vector example

===

M   doc/python_api/examples/mathutils.Vector.py

===

diff --git a/doc/python_api/examples/mathutils.Vector.py 
b/doc/python_api/examples/mathutils.Vector.py
index 14b8829..3f79fde 100644
--- a/doc/python_api/examples/mathutils.Vector.py
+++ b/doc/python_api/examples/mathutils.Vector.py
@@ -18,16 +18,16 @@ matrix = mathutils.Matrix()
 
 # Comparison operators can be done on Vector classes:
 
-# greater and less then test vector length.
+# (In)equality operators == and != test component values, e.g. 1,2,3 != 3,2,1
+vec_a == vec_b
+vec_a != vec_b
+
+# Ordering operators >, >=, > and <= test vector length.
 vec_a > vec_b
 vec_a >= vec_b
 vec_a < vec_b
 vec_a <= vec_b
 
-# ==, != test vector values e.g. 1,2,3 != 3,2,1 even if they are the same 
length
-vec_a == vec_b
-vec_a != vec_b
-
 
 # Math can be performed on Vector classes
 vec_a + vec_b

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


[Bf-blender-cvs] [2b01b71] master: Fix T43565: BGE removed unneeded if/else in BL_KetsjiEmbedStart

2015-02-10 Thread Sybren A. Stüvel
Commit: 2b01b713394ae49bb805c889b65719ac59827b89
Author: Sybren A. Stüvel
Date:   Tue Feb 10 21:28:18 2015 +0100
Branches: master
https://developer.blender.org/rB2b01b713394ae49bb805c889b65719ac59827b89

Fix T43565: BGE removed unneeded if/else in BL_KetsjiEmbedStart

===

M   source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp

===

diff --git a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp 
b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
index 60b8832..6e8c64f 100644
--- a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
+++ b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
@@ -457,14 +457,7 @@ extern "C" void StartKetsjiShell(struct bContext *C, 
struct ARegion *ar, rcti *c

ketsjiengine->SetCameraOverrideUseOrtho((rv3d->persp == RV3D_ORTHO));

ketsjiengine->SetCameraOverrideProjectionMatrix(MT_CmMatrix4x4(rv3d->winmat));

ketsjiengine->SetCameraOverrideViewMatrix(MT_CmMatrix4x4(rv3d->viewmat));
-   if (rv3d->persp == RV3D_ORTHO)
-   {
-   
ketsjiengine->SetCameraOverrideClipping(v3d->near, v3d->far);
-   }
-   else
-   {
-   
ketsjiengine->SetCameraOverrideClipping(v3d->near, v3d->far);
-   }
+   
ketsjiengine->SetCameraOverrideClipping(v3d->near, v3d->far);
ketsjiengine->SetCameraOverrideLens(v3d->lens);
}

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


[Bf-blender-cvs] [bf157ce] master: Fix T42919 & T42218: BGE: Python-driven armature animation got buggy

2015-02-14 Thread Sybren A. Stüvel
Commit: bf157ce9277ba1011a6e317c7629bab0dd8c36a5
Author: Sybren A. Stüvel
Date:   Sun Feb 15 02:00:25 2015 +0100
Branches: master
https://developer.blender.org/rBbf157ce9277ba1011a6e317c7629bab0dd8c36a5

Fix T42919 & T42218: BGE: Python-driven armature animation got buggy

Due to changes in the way animation updates were handled,
BL_ArmatureObjects were no longer registering to KX_Scene as animated.

Moguri says: It might have been relying on the deformer update which
moved rom being called on every object in the render step. Now
armature deformers are only updated if they need to be.

Fix T42919 & Fix T42218

===

M   source/gameengine/Converter/BL_ArmatureObject.cpp

===

diff --git a/source/gameengine/Converter/BL_ArmatureObject.cpp 
b/source/gameengine/Converter/BL_ArmatureObject.cpp
index e01130a..bc2fc01 100644
--- a/source/gameengine/Converter/BL_ArmatureObject.cpp
+++ b/source/gameengine/Converter/BL_ArmatureObject.cpp
@@ -234,6 +234,9 @@ BL_ArmatureObject::BL_ArmatureObject(
 // need this to get iTaSC working ok in the BGE
 m_pose->flag |= POSE_GAME_ENGINE;
memcpy(m_obmat, m_objArma->obmat, sizeof(m_obmat));
+
+   // The side-effect of this method registers this object as "animatable" 
with the KX_Scene.
+   GetActionManager();
 }
 
 BL_ArmatureObject::~BL_ArmatureObject()

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


[Bf-blender-cvs] [9a10b20] master: Ensure CMake finds SDL 2.0

2015-02-16 Thread Sybren A. Stüvel
Commit: 9a10b208bacd4258e528532d400b25aeb33591d9
Author: Sybren A. Stüvel
Date:   Mon Feb 16 08:22:26 2015 +0100
Branches: master
https://developer.blender.org/rB9a10b208bacd4258e528532d400b25aeb33591d9

Ensure CMake finds SDL 2.0

CMake 2.8 doesn't search /usr/include/SDL2, which is the include directory
for SDL 2.x on Ubuntu Linux (and possibly others). This results in SDL 1.2
headers being found when WITH_SDL_DYNLOAD=OFF, and our shipped SDL 2.0
headers when WITH_SDL_DYNLOAD=ON. This patch ensures that in both
cases the correct SDL headers are used.

Reviewers: sergey, campbellbarton

Projects: #bf_blender

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

===

M   CMakeLists.txt
A   build_files/cmake/Modules/FindSDL2.cmake

===

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 29f8c81..561d7f1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -838,17 +838,21 @@ if(UNIX AND NOT APPLE)
 
if(WITH_SDL)
if(WITH_SDL_DYNLOAD)
-   set(SDLMAIN_LIBRARY)
set(SDL_INCLUDE_DIR 
"${CMAKE_CURRENT_SOURCE_DIR}/extern/sdlew/include/SDL2")
set(SDL_LIBRARY)
-   set(SDL_LIBRARY_TEMP)
else()
-   find_package_wrapper(SDL)
+   find_package_wrapper(SDL2)
+   if(SDL2_FOUND)
+   # Use same names for both versions of SDL until 
we move to 2.x.
+   set(SDL_INCLUDE_DIR "${SDL2_INCLUDE_DIR}")
+   set(SDL_LIBRARY "${SDL2_LIBRARY}")
+   set(SDL_FOUND "${SDL2_FOUND}")
+   else()
+   find_package_wrapper(SDL)
+   endif()
mark_as_advanced(
-   SDLMAIN_LIBRARY
SDL_INCLUDE_DIR
SDL_LIBRARY
-   SDL_LIBRARY_TEMP
)
# unset(SDLMAIN_LIBRARY CACHE)
if(NOT SDL_FOUND)
diff --git a/build_files/cmake/Modules/FindSDL2.cmake 
b/build_files/cmake/Modules/FindSDL2.cmake
new file mode 100644
index 000..2a835cf
--- /dev/null
+++ b/build_files/cmake/Modules/FindSDL2.cmake
@@ -0,0 +1,72 @@
+# - Find SDL library
+# Find the native SDL includes and library
+# This module defines
+#  SDL2_INCLUDE_DIRS, where to find SDL.h, Set when SDL2_INCLUDE_DIR is found.
+#  SDL2_LIBRARIES, libraries to link against to use SDL.
+#  SDL2_ROOT_DIR, The base directory to search for SDL.
+#This can also be an environment variable.
+#  SDL2_FOUND, If false, do not try to use SDL.
+#
+# also defined, but not for general use are
+#  SDL2_LIBRARY, where to find the SDL library.
+
+#=
+# Copyright 2015 Blender Foundation.
+#
+# Distributed under the OSI-approved BSD License (the "License");
+# see accompanying file Copyright.txt for details.
+#
+# This software is distributed WITHOUT ANY WARRANTY; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the License for more information.
+#=
+
+# If SDL2_ROOT_DIR was defined in the environment, use it.
+IF(NOT SDL2_ROOT_DIR AND NOT $ENV{SDL2_ROOT_DIR} STREQUAL "")
+  SET(SDL2_ROOT_DIR $ENV{SDL2_ROOT_DIR})
+ENDIF()
+
+SET(_sdl2_SEARCH_DIRS
+  ${SDL2_ROOT_DIR}
+  ~/Library/Frameworks
+  /Library/Frameworks
+  /usr/local
+  /usr
+  /sw # Fink
+  /opt/local # DarwinPorts
+  /opt/csw # Blastwave
+)
+
+FIND_PATH(SDL2_INCLUDE_DIR
+  NAMES
+  SDL.h
+  HINTS
+${_sdl2_SEARCH_DIRS}
+  PATH_SUFFIXES
+include/SDL2 include
+)
+
+FIND_LIBRARY(SDL2_LIBRARY
+  NAMES
+  SDL2
+  HINTS
+${_sdl2_SEARCH_DIRS}
+  PATH_SUFFIXES
+lib64 lib
+  )
+
+# handle the QUIETLY and REQUIRED arguments and set SDL2_FOUND to TRUE if
+# all listed variables are TRUE
+INCLUDE(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2 DEFAULT_MSG
+SDL2_LIBRARY SDL2_INCLUDE_DIR)
+
+IF(SDL2_FOUND)
+  SET(SDL2_LIBRARIES ${SDL2_LIBRARY})
+  SET(SDL2_INCLUDE_DIRS ${SDL2_INCLUDE_DIR})
+ENDIF(SDL2_FOUND)
+
+MARK_AS_ADVANCED(
+  SDL2_INCLUDE_DIR
+  SDL2_LIBRARY
+)

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


  1   2   3   4   5   6   7   8   9   10   >