[Bf-blender-cvs] [ce78586] master: Fix compile errors for when WITH_ALEMBIC is OFF.

2016-10-29 Thread Kévin Dietrich
Commit: ce785868a56a1446750f5af1779f7623ca462ec2
Author: Kévin Dietrich
Date:   Sun Oct 30 03:42:46 2016 +0100
Branches: master
https://developer.blender.org/rBce785868a56a1446750f5af1779f7623ca462ec2

Fix compile errors for when WITH_ALEMBIC is OFF.

===

M   source/blender/blenkernel/intern/cachefile.c
M   source/blender/blenkernel/intern/constraint.c
M   source/blender/makesrna/intern/rna_constraint.c
M   source/blender/makesrna/intern/rna_modifier.c
M   source/blender/modifiers/intern/MOD_meshsequencecache.c

===

diff --git a/source/blender/blenkernel/intern/cachefile.c 
b/source/blender/blenkernel/intern/cachefile.c
index 2a2699f..6a08673 100644
--- a/source/blender/blenkernel/intern/cachefile.c
+++ b/source/blender/blenkernel/intern/cachefile.c
@@ -212,7 +212,9 @@ void BKE_cachefile_clean(Scene *scene, CacheFile 
*cache_file)
MeshSeqCacheModifierData *mcmd = 
(MeshSeqCacheModifierData *)md;
 
if (cache_file == mcmd->cache_file) {
+#ifdef WITH_ALEMBIC
CacheReader_free(mcmd->reader);
+#endif
mcmd->reader = NULL;
mcmd->object_path[0] = '\0';
}
@@ -226,7 +228,9 @@ void BKE_cachefile_clean(Scene *scene, CacheFile 
*cache_file)
bTransformCacheConstraint *data = con->data;
 
if (cache_file == data->cache_file) {
+#ifdef WITH_ALEMBIC
CacheReader_free(data->reader);
+#endif
data->reader = NULL;
data->object_path[0] = '\0';
}
diff --git a/source/blender/blenkernel/intern/constraint.c 
b/source/blender/blenkernel/intern/constraint.c
index c775070..b85f1b8 100644
--- a/source/blender/blenkernel/intern/constraint.c
+++ b/source/blender/blenkernel/intern/constraint.c
@@ -4401,7 +4401,9 @@ static void transformcache_free(bConstraint *con)
}
 
if (data->reader) {
+#ifdef WITH_ALEMBIC
CacheReader_free(data->reader);
+#endif
}
 }
 
diff --git a/source/blender/makesrna/intern/rna_constraint.c 
b/source/blender/makesrna/intern/rna_constraint.c
index ad037af..de1a0f2 100644
--- a/source/blender/makesrna/intern/rna_constraint.c
+++ b/source/blender/makesrna/intern/rna_constraint.c
@@ -478,6 +478,7 @@ static void 
rna_Constraint_objectSolver_camera_set(PointerRNA *ptr, PointerRNA v
 
 static void rna_Constraint_transformCache_object_path_update(Main *bmain, 
Scene *scene, PointerRNA *ptr)
 {
+#ifdef WITH_ALEMBIC
bConstraint *con = (bConstraint *)ptr->data;
bTransformCacheConstraint *data = (bTransformCacheConstraint 
*)con->data;
Object *ob = (Object *)ptr->id.data;
@@ -486,6 +487,7 @@ static void 
rna_Constraint_transformCache_object_path_update(Main *bmain, Scene
   data->reader,
   ob,
   data->object_path);
+#endif
 
rna_Constraint_update(bmain, scene, ptr);
 }
diff --git a/source/blender/makesrna/intern/rna_modifier.c 
b/source/blender/makesrna/intern/rna_modifier.c
index b30c156..c4f0db3 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -1133,6 +1133,7 @@ static int 
rna_CorrectiveSmoothModifier_is_bind_get(PointerRNA *ptr)
 
 static void rna_MeshSequenceCache_object_path_update(Main *bmain, Scene 
*scene, PointerRNA *ptr)
 {
+#ifdef WITH_ALEMBIC
MeshSeqCacheModifierData *mcmd = (MeshSeqCacheModifierData *)ptr->data;
Object *ob = (Object *)ptr->id.data;
 
@@ -1140,6 +1141,7 @@ static void rna_MeshSequenceCache_object_path_update(Main 
*bmain, Scene *scene,
   mcmd->reader,
   ob,
   mcmd->object_path);
+#endif
 
rna_Modifier_update(bmain, scene, ptr);
 }
diff --git a/source/blender/modifiers/intern/MOD_meshsequencecache.c 
b/source/blender/modifiers/intern/MOD_meshsequencecache.c
index cf13778..d25e8e3 100644
--- a/source/blender/modifiers/intern/MOD_meshsequencecache.c
+++ b/source/blender/modifiers/intern/MOD_meshsequencecache.c
@@ -78,7 +78,9 @@ static void freeData(ModifierData *md)
}
 
if (mcmd->reader) {
+#ifdef WITH_ALEMBIC
CacheReader_free(mcmd->reader);
+#endif
}
 }

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


[Bf-blender-cvs] [b2974d7] master: Cycles: Add smoothing option to the Brick Texture

2016-10-29 Thread Lukas Stockner
Commit: b2974d7ab79a257f8628c24c05d43da25791018d
Author: Lukas Stockner
Date:   Sun Oct 30 01:33:10 2016 +0200
Branches: master
https://developer.blender.org/rBb2974d7ab79a257f8628c24c05d43da25791018d

Cycles: Add smoothing option to the Brick Texture

This option allows to create a smoother transition between Bricks and Mortar - 
0 applies no smoothing, and 1 smooths across the whole mortar width.
Mainly useful for displacement textures.

The new default value for the smoothing option is 0.1 to give some smoothing 
that helps with antialiasing, but existing nodes are loaded with smoothing 0 to 
preserve compatibility.

Reviewers: sergey, dingto, juicyfruit, brecht

Reviewed By: brecht

Subscribers: Blendify, nutel

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

===

M   intern/cycles/kernel/shaders/node_brick_texture.osl
M   intern/cycles/kernel/svm/svm_brick.h
M   intern/cycles/render/nodes.cpp
M   intern/cycles/render/nodes.h
M   source/blender/nodes/shader/nodes/node_shader_tex_brick.c

===

diff --git a/intern/cycles/kernel/shaders/node_brick_texture.osl 
b/intern/cycles/kernel/shaders/node_brick_texture.osl
index d5e0a7d..c303594 100644
--- a/intern/cycles/kernel/shaders/node_brick_texture.osl
+++ b/intern/cycles/kernel/shaders/node_brick_texture.osl
@@ -28,7 +28,7 @@ float brick_noise(int n) /* fast integer noise */
return 0.5 * ((float)nn / 1073741824.0);
 }
 
-float brick(point p, float mortar_size, float bias,
+float brick(point p, float mortar_size, float mortar_smooth, float bias,
float BrickWidth, float row_height, float offset_amount, int 
offset_frequency,
float squash_amount, int squash_frequency, float tint)
 {
@@ -51,9 +51,17 @@ float brick(point p, float mortar_size, float bias,
 
tint = clamp((brick_noise((rownum << 16) + (bricknum & 65535)) + bias), 
0.0, 1.0);
 
-   return (x < mortar_size || y < mortar_size ||
-   x > (brick_width - mortar_size) ||
-   y > (row_height - mortar_size)) ? 1.0 : 0.0;
+   float min_dist = min(min(x, y), min(brick_width - x, row_height - y));
+   if(min_dist >= mortar_size) {
+   return 0.0;
+   }
+   else if(mortar_smooth == 0.0) {
+   return 1.0;
+   }
+   else {
+   min_dist = 1.0 - min_dist/mortar_size;
+   return smoothstep(0.0, mortar_smooth, min_dist);
+   }
 }
 
 shader node_brick_texture(
@@ -69,6 +77,7 @@ shader node_brick_texture(
color Mortar = 0.0,
float Scale = 5.0,
float MortarSize = 0.02,
+   float MortarSmooth = 0.0,
float Bias = 0.0,
float BrickWidth = 0.5,
float RowHeight = 0.25,
@@ -83,7 +92,7 @@ shader node_brick_texture(
float tint = 0.0;
color Col = Color1;

-   Fac = brick(p * Scale, MortarSize, Bias, BrickWidth, RowHeight,
+   Fac = brick(p * Scale, MortarSize, MortarSmooth, Bias, BrickWidth, 
RowHeight,
offset, offset_frequency, squash, squash_frequency, tint);

if (Fac != 1.0) {
@@ -91,6 +100,6 @@ shader node_brick_texture(
Col = facm * Color1 + tint * Color2;
}

-   Color = (Fac == 1.0) ? Mortar : Col;
+   Color = mix(Col, Mortar, Fac);
 }
 
diff --git a/intern/cycles/kernel/svm/svm_brick.h 
b/intern/cycles/kernel/svm/svm_brick.h
index 9b0cf5a..47e1ba2 100644
--- a/intern/cycles/kernel/svm/svm_brick.h
+++ b/intern/cycles/kernel/svm/svm_brick.h
@@ -27,7 +27,7 @@ ccl_device_noinline float brick_noise(int n) /* fast integer 
noise */
return 0.5f * ((float)nn / 1073741824.0f);
 }
 
-ccl_device_noinline float2 svm_brick(float3 p, float mortar_size, float bias,
+ccl_device_noinline float2 svm_brick(float3 p, float mortar_size, float 
mortar_smooth, float bias,
float brick_width, float row_height, float offset_amount, int 
offset_frequency,
float squash_amount, int squash_frequency)
 {
@@ -47,30 +47,41 @@ ccl_device_noinline float2 svm_brick(float3 p, float 
mortar_size, float bias,
x = (p.x+offset) - brick_width*bricknum;
y = p.y - row_height*rownum;
 
-   return make_float2(
-   saturate((brick_noise((rownum << 16) + (bricknum & 0x)) + 
bias)),
+   float tint = saturate((brick_noise((rownum << 16) + (bricknum & 
0x)) + bias));
+   float min_dist = min(min(x, y), min(brick_width - x, row_height - y));
 
-   (x < mortar_size || y < mortar_size ||
-   x > (brick_width - mortar_size) ||
-   y > (row_height - mortar_size)) ? 1.0f : 0.0f);
+   float mortar;
+   if(min_dist >= mortar_size) {
+   mortar = 0.0f;
+   }
+   else if(mortar_smooth == 0.0f) {
+   mortar = 1.0f;
+   }
+   else {
+   min_dist = 1.0f - 

[Bf-blender-cvs] [47ac6aa] fluid-mantaflow: Mantaflow: Fix typo in smoke_export_low script.

2016-10-29 Thread lazydodo
Commit: 47ac6aa864adc6e286261ecf4a636b6c2fdcdd60
Author: lazydodo
Date:   Sat Oct 29 13:26:29 2016 -0600
Branches: fluid-mantaflow
https://developer.blender.org/rB47ac6aa864adc6e286261ecf4a636b6c2fdcdd60

Mantaflow: Fix typo in smoke_export_low script.

===

M   intern/mantaflow/intern/strings/smoke_script.h

===

diff --git a/intern/mantaflow/intern/strings/smoke_script.h 
b/intern/mantaflow/intern/strings/smoke_script.h
index 661d638..b23e360 100644
--- a/intern/mantaflow/intern/strings/smoke_script.h
+++ b/intern/mantaflow/intern/strings/smoke_script.h
@@ -379,7 +379,7 @@ def load_smoke_data_high(path):\n\
 const std::string smoke_export_low = "\n\
 def save_smoke_data_low(path):\n\
 path = Path(path)\n\
-density.save(path / 'density.uni'))\n\
+density.save(path / 'density.uni')\n\
 flags.save(path / 'flags.uni')\n\
 vel.save(path / 'vel.uni')\n\
 forces.save(path / 'forces.uni')\n\

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


[Bf-blender-cvs] [5aa6a2e] master: Fix T49846: OpenCL rendering compilation failure

2016-10-29 Thread Lukas Stockner
Commit: 5aa6a2ec06bbfa9ddd255c90ee02da5f9be36f30
Author: Lukas Stockner
Date:   Sat Oct 29 20:06:52 2016 +0200
Branches: master
https://developer.blender.org/rB5aa6a2ec06bbfa9ddd255c90ee02da5f9be36f30

Fix T49846: OpenCL rendering compilation failure

===

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

===

diff --git a/intern/cycles/kernel/kernel_projection.h 
b/intern/cycles/kernel/kernel_projection.h
index ba714b6..9a2b088 100644
--- a/intern/cycles/kernel/kernel_projection.h
+++ b/intern/cycles/kernel/kernel_projection.h
@@ -235,7 +235,7 @@ ccl_device_inline void 
spherical_stereo_transform(KernelGlobals *kg, float3 *P,
if(kernel_data.cam.pole_merge_angle_to > 0.0f) {
const float pole_merge_angle_from = 
kernel_data.cam.pole_merge_angle_from,
pole_merge_angle_to = 
kernel_data.cam.pole_merge_angle_to;
-   float altitude = fabsf(safe_asinf(D->z));
+   float altitude = fabsf(safe_asinf((*D).z));
if(altitude > pole_merge_angle_to) {
interocular_offset = 0.0f;
}
diff --git a/intern/cycles/kernel/kernel_shader.h 
b/intern/cycles/kernel/kernel_shader.h
index 6480975..a8070a1 100644
--- a/intern/cycles/kernel/kernel_shader.h
+++ b/intern/cycles/kernel/kernel_shader.h
@@ -276,7 +276,7 @@ ccl_device_inline void 
shader_setup_from_sample(KernelGlobals *kg,
 
 #ifdef __OBJECT_MOTION__
shader_setup_object_transforms(kg, sd, time);
-#else
+#endif
}
else if(lamp != LAMP_NONE) {
ccl_fetch(sd, ob_tfm)  = lamp_fetch_transform(kg, lamp, false);

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


[Bf-blender-cvs] [1272ee4] master: Cycles: Implement texture coordinates for Point, Spot and Area Lamps

2016-10-29 Thread Lukas Stockner
Commit: 1272ee455e7aeed3f6acb0b8a8366af5ad6aec99
Author: Lukas Stockner
Date:   Sat Oct 29 18:54:42 2016 +0200
Branches: master
https://developer.blender.org/rB1272ee455e7aeed3f6acb0b8a8366af5ad6aec99

Cycles: Implement texture coordinates for Point, Spot and Area Lamps

When using the Normal output of the Texture Coordinate node on Point and Spot 
lamps, the coordinates now depend on the rotation of the lamp.
On Area lamps, the Parametric output of the Geometry node now returns UV 
coordinates on the area lamp.

Credit for the Area lamp part goes to Stefan Werner (from D1995).

===

M   intern/cycles/blender/blender_object.cpp
M   intern/cycles/kernel/geom/geom_object.h
M   intern/cycles/kernel/kernel_bake.h
M   intern/cycles/kernel/kernel_emission.h
M   intern/cycles/kernel/kernel_light.h
M   intern/cycles/kernel/kernel_shader.h
M   intern/cycles/kernel/kernel_types.h
M   intern/cycles/kernel/osl/osl_services.cpp
M   intern/cycles/kernel/svm/svm_tex_coord.h
M   intern/cycles/render/light.cpp
M   intern/cycles/render/light.h
M   intern/cycles/util/util_math.h

===

diff --git a/intern/cycles/blender/blender_object.cpp 
b/intern/cycles/blender/blender_object.cpp
index f7f77df..0d961c5 100644
--- a/intern/cycles/blender/blender_object.cpp
+++ b/intern/cycles/blender/blender_object.cpp
@@ -153,6 +153,7 @@ void BlenderSync::sync_light(BL::Object& b_parent,
/* location and (inverted!) direction */
light->co = transform_get_column(, 3);
light->dir = -transform_get_column(, 2);
+   light->tfm = tfm;
 
/* shader */
vector used_shaders;
diff --git a/intern/cycles/kernel/geom/geom_object.h 
b/intern/cycles/kernel/geom/geom_object.h
index 32900f7..6b42f66 100644
--- a/intern/cycles/kernel/geom/geom_object.h
+++ b/intern/cycles/kernel/geom/geom_object.h
@@ -55,6 +55,21 @@ ccl_device_inline Transform 
object_fetch_transform(KernelGlobals *kg, int object
return tfm;
 }
 
+/* Lamp to world space transformation */
+
+ccl_device_inline Transform lamp_fetch_transform(KernelGlobals *kg, int lamp, 
bool inverse)
+{
+   int offset = lamp*LIGHT_SIZE + (inverse? 8 : 5);
+
+   Transform tfm;
+   tfm.x = kernel_tex_fetch(__light_data, offset + 0);
+   tfm.y = kernel_tex_fetch(__light_data, offset + 1);
+   tfm.z = kernel_tex_fetch(__light_data, offset + 2);
+   tfm.w = make_float4(0.0f, 0.0f, 0.0f, 1.0f);
+
+   return tfm;
+}
+
 /* Object to world space transformation for motion vectors */
 
 ccl_device_inline Transform object_fetch_vector_transform(KernelGlobals *kg, 
int object, enum ObjectVectorTransform type)
diff --git a/intern/cycles/kernel/kernel_bake.h 
b/intern/cycles/kernel/kernel_bake.h
index fd9207f..84575d3 100644
--- a/intern/cycles/kernel/kernel_bake.h
+++ b/intern/cycles/kernel/kernel_bake.h
@@ -320,7 +320,8 @@ ccl_device void kernel_bake_evaluate(KernelGlobals *kg, 
ccl_global uint4 *input,
 P, Ng, Ng,
 shader, object, prim,
 u, v, 1.0f, 0.5f,
-!(kernel_tex_fetch(__object_flag, object) & 
SD_TRANSFORM_APPLIED));
+!(kernel_tex_fetch(__object_flag, object) & 
SD_TRANSFORM_APPLIED),
+LAMP_NONE);
sd.I = sd.N;
 
/* update differentials */
diff --git a/intern/cycles/kernel/kernel_emission.h 
b/intern/cycles/kernel/kernel_emission.h
index ac498ba..9e4a631 100644
--- a/intern/cycles/kernel/kernel_emission.h
+++ b/intern/cycles/kernel/kernel_emission.h
@@ -65,7 +65,7 @@ ccl_device_noinline float3 direct_emissive_eval(KernelGlobals 
*kg,
shader_setup_from_sample(kg, emission_sd,
 ls->P, ls->Ng, I,
 ls->shader, ls->object, ls->prim,
-ls->u, ls->v, t, time, false);
+ls->u, ls->v, t, time, false, 
ls->lamp);
 
ls->Ng = ccl_fetch(emission_sd, Ng);
 
diff --git a/intern/cycles/kernel/kernel_light.h 
b/intern/cycles/kernel/kernel_light.h
index fffa9af..d4cc36d 100644
--- a/intern/cycles/kernel/kernel_light.h
+++ b/intern/cycles/kernel/kernel_light.h
@@ -297,7 +297,7 @@ ccl_device_inline float background_portal_pdf(KernelGlobals 
*kg,
float3 axisu = make_float3(data1.y, data1.z, data1.w);
float3 axisv = make_float3(data2.y, data2.z, data2.w);
 
-   if(!ray_quad_intersect(P, direction, 1e-4f, FLT_MAX, lightpos, 
axisu, axisv, dir, NULL, NULL))
+   if(!ray_quad_intersect(P, direction, 1e-4f, FLT_MAX, lightpos, 
axisu, axisv, dir, NULL, NULL, NULL, NULL))
continue;
 
portal_pdf += 

[Bf-blender-cvs] [ce4f04f] HMD_viewport: Fixed cmake option for htc vive in OpenHMD

2016-10-29 Thread TheOnlyJoey
Commit: ce4f04f268eca6d8f51a0840c23d33dc02ab22a5
Author: TheOnlyJoey
Date:   Sat Oct 29 16:58:09 2016 +0200
Branches: HMD_viewport
https://developer.blender.org/rBce4f04f268eca6d8f51a0840c23d33dc02ab22a5

Fixed cmake option for htc vive in OpenHMD

===

M   extern/openhmd/CMakeLists.txt

===

diff --git a/extern/openhmd/CMakeLists.txt b/extern/openhmd/CMakeLists.txt
index 398d9c9..7792c6f 100644
--- a/extern/openhmd/CMakeLists.txt
+++ b/extern/openhmd/CMakeLists.txt
@@ -38,7 +38,7 @@ set(SRC
 # TODO: Either remove this or move to main CMakeLists.txt
 OPTION(OPENHMD_DRIVER_OCULUS_RIFT "Oculus Rift DK1, DK2 and CV1" ON)
 OPTION(OPENHMD_DRIVER_DEEPOON "Deepoon E2 support" ON)
-OPTION(OPENHMD_DRIVER_DEEPOON "HTC Vive support" ON)
+OPTION(OPENHMD_DRIVER_HTC_VIVE "HTC Vive support" ON)
 OPTION(OPENHMD_DRIVER_EXTERNAL "External sensor driver" OFF)
 OPTION(OPENHMD_DRIVER_ANDROID "General Android driver" OFF)

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


[Bf-blender-cvs] [e7670e9] HMD_viewport: - Added initial HTC Vive support, still uses complimentary sensor fusion, could drift a bit

2016-10-29 Thread TheOnlyJoey
Commit: e7670e9bb08194bf2008672b63ffdbf60303e22f
Author: TheOnlyJoey
Date:   Sat Oct 29 16:21:56 2016 +0200
Branches: HMD_viewport
https://developer.blender.org/rBe7670e9bb08194bf2008672b63ffdbf60303e22f

- Added initial HTC Vive support, still uses complimentary sensor fusion, could 
drift a bit

===

M   extern/openhmd/CMakeLists.txt
A   extern/openhmd/src/drv_htc_vive/magic.h
A   extern/openhmd/src/drv_htc_vive/packet.c
A   extern/openhmd/src/drv_htc_vive/vive.c
A   extern/openhmd/src/drv_htc_vive/vive.h
M   extern/openhmd/src/openhmd.c
M   extern/openhmd/src/openhmdi.h

===

diff --git a/extern/openhmd/CMakeLists.txt b/extern/openhmd/CMakeLists.txt
index 32dfc28..398d9c9 100644
--- a/extern/openhmd/CMakeLists.txt
+++ b/extern/openhmd/CMakeLists.txt
@@ -38,6 +38,7 @@ set(SRC
 # TODO: Either remove this or move to main CMakeLists.txt
 OPTION(OPENHMD_DRIVER_OCULUS_RIFT "Oculus Rift DK1, DK2 and CV1" ON)
 OPTION(OPENHMD_DRIVER_DEEPOON "Deepoon E2 support" ON)
+OPTION(OPENHMD_DRIVER_DEEPOON "HTC Vive support" ON)
 OPTION(OPENHMD_DRIVER_EXTERNAL "External sensor driver" OFF)
 OPTION(OPENHMD_DRIVER_ANDROID "General Android driver" OFF)
 
@@ -68,6 +69,17 @@ if(OPENHMD_DRIVER_DEEPOON)
list(APPEND INC_SYS ${HIDAPI_INCLUDE_DIRS})
 endif()
 
+if(OPENHMD_HTC_VIVE)
+   list(APPEND SRC
+   src/drv_htc_vive/vive.c
+   src/drv_htc_vive/packet.c
+   )
+   add_definitions(-DDRIVER_HTC_VIVE)
+
+   find_package(HIDAPI REQUIRED)
+   list(APPEND INC_SYS ${HIDAPI_INCLUDE_DIRS})
+endif()
+
 if(OPENHMD_DRIVER_EXTERNAL)
list(APPEND SRC
src/drv_external/external.c
diff --git a/extern/openhmd/src/drv_htc_vive/magic.h 
b/extern/openhmd/src/drv_htc_vive/magic.h
new file mode 100644
index 000..3464dd6
--- /dev/null
+++ b/extern/openhmd/src/drv_htc_vive/magic.h
@@ -0,0 +1,27 @@
+static const unsigned char vive_magic_power_on[64] = {
+   0x04, 0x78, 0x29, 0x38, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 
0x01,
+   0xa8, 0x0d, 0x76, 0x00, 0x40, 0xfc, 0x01, 0x05, 0xfa, 0xec, 0xd1, 0x6d, 
0x00,
+   0x00, 0x6c, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa8, 0x0d, 0x76, 0x00, 0x68, 
0xfc,
+   0x01, 0x05, 0x2c, 0xb0, 0x2e, 0x65, 0x7a, 0x0d, 0x76, 0x00, 0x68, 0x54, 
0x72,
+   0x00, 0x18, 0x54, 0x72, 0x00, 0x00, 0x6a, 0x72, 0x00, 0x00, 0x00, 0x00,
+};
+
+static const unsigned char vive_magic_power_off1[64] = {
+   0x04, 0x78, 0x29, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 
0x00,
+   0x30, 0x05, 0x77, 0x00, 0x30, 0x05, 0x77, 0x00, 0x6c, 0x4d, 0x37, 0x65, 
0x40,
+   0xf9, 0x33, 0x00, 0x04, 0xf8, 0xa3, 0x04, 0x04, 0x00, 0x00, 0x00, 0x70, 
0xb0,
+   0x72, 0x00, 0xf4, 0xf7, 0xa3, 0x04, 0x7c, 0xf8, 0x33, 0x00, 0x0c, 0xf8, 
0xa3,
+   0x04, 0x0a, 0x6e, 0x29, 0x65, 0x24, 0xf9, 0x33, 0x00, 0x00, 0x00, 0x00,
+};
+
+static const unsigned char vive_magic_power_off2[64] = {
+   0x04, 0x78, 0x29, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 
0x00,
+   0x30, 0x05, 0x77, 0x00, 0xe4, 0xf7, 0x33, 0x00, 0xe4, 0xf7, 0x33, 0x00, 
0x60,
+   0x6e, 0x72, 0x00, 0xb4, 0xf7, 0x33, 0x00, 0x04, 0x00, 0x00, 0x00, 0x70, 
0xb0,
+   0x72, 0x00, 0x90, 0xf7, 0x33, 0x00, 0x7c, 0xf8, 0x33, 0x00, 0xd0, 0xf7, 
0x33,
+   0x00, 0x3c, 0x68, 0x29, 0x65, 0x24, 0xf9, 0x33, 0x00, 0x00, 0x00, 0x00,
+};
+
+static const unsigned char vive_magic_enable_lighthouse[5] = {
+   0x04
+};
diff --git a/extern/openhmd/src/drv_htc_vive/packet.c 
b/extern/openhmd/src/drv_htc_vive/packet.c
new file mode 100644
index 000..2192948
--- /dev/null
+++ b/extern/openhmd/src/drv_htc_vive/packet.c
@@ -0,0 +1,62 @@
+#include "vive.h"
+
+/* Suppress the warnings for this include, since we don't care about them for 
external dependencies
+/* Requires at least GCC 4.6 or higher
+*/
+
+inline static uint8_t read8(const unsigned char** buffer)
+{
+   uint8_t ret = **buffer;
+   *buffer += 1;
+   return ret;
+}
+
+inline static int16_t read16(const unsigned char** buffer)
+{
+   int16_t ret = **buffer | (*(*buffer + 1) << 8);
+   *buffer += 2;
+   return ret;
+}
+
+inline static uint32_t read32(const unsigned char** buffer)
+{
+   uint32_t ret = **buffer | (*(*buffer + 1) << 8) | (*(*buffer + 2) << 
16) | (*(*buffer + 3) << 24);
+   *buffer += 4;
+   return ret;
+}
+
+bool vive_decode_sensor_packet(vive_sensor_packet* pkt, const unsigned char* 
buffer, int size)
+{
+   if(size != 52){
+   LOGE("invalid vive sensor packet size (expected 52 but got 
%d)", size);
+   return false;
+   }
+
+   pkt->report_id = read8();
+
+   for(int j = 0; j < 3; j++){
+   // acceleration
+   for(int i = 0; i < 3; i++){
+   pkt->samples[j].acc[i] = read16();
+   }
+
+   // rotation
+  

[Bf-blender-cvs] [46bc9bc] HMD_viewport: - Updated Oculus CV1 support

2016-10-29 Thread TheOnlyJoey
Commit: 46bc9bcbba679aefbd601e96d234870ca2670daf
Author: TheOnlyJoey
Date:   Sat Oct 29 16:01:03 2016 +0200
Branches: HMD_viewport
https://developer.blender.org/rB46bc9bcbba679aefbd601e96d234870ca2670daf

- Updated Oculus CV1 support

===

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

===

diff --git a/extern/openhmd/src/drv_oculus_rift/packet.c 
b/extern/openhmd/src/drv_oculus_rift/packet.c
index ad57bfd..1bf4743 100644
--- a/extern/openhmd/src/drv_oculus_rift/packet.c
+++ b/extern/openhmd/src/drv_oculus_rift/packet.c
@@ -200,7 +200,7 @@ int encode_enable_components(unsigned char* buffer, bool 
display, bool audio)
flags |= 1;
if (audio)
flags |= 2;
-   flags |= 4; // I don't know what it is. Wireless?
+// flags |= 4; // I don't know what it is. Wireless?
WRITE8(flags);
return 4;
 }
diff --git a/extern/openhmd/src/drv_oculus_rift/rift.c 
b/extern/openhmd/src/drv_oculus_rift/rift.c
index 5fb62da..f6399d6 100644
--- a/extern/openhmd/src/drv_oculus_rift/rift.c
+++ b/extern/openhmd/src/drv_oculus_rift/rift.c
@@ -141,7 +141,8 @@ static void update_device(ohmd_device* device)
// send keep alive message
pkt_keep_alive keep_alive = { 0, 
priv->sensor_config.keep_alive_interval };
int ka_size = encode_keep_alive(buffer, _alive);
-   send_feature_report(priv, buffer, ka_size);
+   if (send_feature_report(priv, buffer, ka_size) == -1)
+   LOGE("error sending keepalive");
 
// Update the time of the last keep alive we have sent.
priv->last_keep_alive = t;
@@ -276,13 +277,15 @@ static ohmd_device* open_device(ohmd_driver* driver, 
ohmd_device_desc* desc)
if (desc->revision == REV_CV1)
{
size = encode_enable_components(buf, true, true);
-   send_feature_report(priv, buf, size);
+   if (send_feature_report(priv, buf, size) == -1)
+   LOGE("error turning the screens on");
}
 
// set keep alive interval to n seconds
pkt_keep_alive keep_alive = { 0, KEEP_ALIVE_VALUE };
size = encode_keep_alive(buf, _alive);
-   send_feature_report(priv, buf, size);
+   if (send_feature_report(priv, buf, size) == -1)
+   LOGE("error setting up keepalive");
 
// Update the time of the last keep alive we have sent.
priv->last_keep_alive = ohmd_get_tick();

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


[Bf-blender-cvs] [d3b0977] master: Fix T49878: Alembic crash with long object name

2016-10-29 Thread Kévin Dietrich
Commit: d3b0977a354d91c363d7128f3e0ef2c5eea977e7
Author: Kévin Dietrich
Date:   Sat Oct 29 16:22:33 2016 +0200
Branches: master
https://developer.blender.org/rBd3b0977a354d91c363d7128f3e0ef2c5eea977e7

Fix T49878: Alembic crash with long object name

Crash comes from writing to char array (ID::name) out its bound and thus
overriding memory in the ID struct.

===

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

===

diff --git a/source/blender/alembic/intern/abc_camera.cc 
b/source/blender/alembic/intern/abc_camera.cc
index 5c34ec1..d5271e3 100644
--- a/source/blender/alembic/intern/abc_camera.cc
+++ b/source/blender/alembic/intern/abc_camera.cc
@@ -119,7 +119,7 @@ bool AbcCameraReader::valid() const
 
 void AbcCameraReader::readObjectData(Main *bmain, float time)
 {
-   Camera *bcam = static_cast(BKE_camera_add(bmain, 
"abc_camera"));
+   Camera *bcam = static_cast(BKE_camera_add(bmain, 
m_data_name.c_str()));
 
ISampleSelector sample_sel(time);
CameraSample cam_sample;
@@ -155,8 +155,6 @@ void AbcCameraReader::readObjectData(Main *bmain, float 
time)
bcam->gpu_dof.focus_distance = cam_sample.getFocusDistance();
bcam->gpu_dof.fstop = cam_sample.getFStop();
 
-   BLI_strncpy(bcam->id.name + 2, m_data_name.c_str(), m_data_name.size() 
+ 1);
-
m_object = BKE_object_add_only_object(bmain, OB_CAMERA, 
m_object_name.c_str());
m_object->data = bcam;
 }

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


[Bf-blender-cvs] [0c13792] master: Alembic export: fix frame range values being reset at every update, draw call.

2016-10-29 Thread Kévin Dietrich
Commit: 0c13792437b3e501c06605876a0396e187c0f7da
Author: Kévin Dietrich
Date:   Sat Oct 29 11:04:51 2016 +0200
Branches: master
https://developer.blender.org/rB0c13792437b3e501c06605876a0396e187c0f7da

Alembic export: fix frame range values being reset at every update, draw
call.

===

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

===

diff --git a/source/blender/editors/io/io_alembic.c 
b/source/blender/editors/io/io_alembic.c
index 65af052..a991f59 100644
--- a/source/blender/editors/io/io_alembic.c
+++ b/source/blender/editors/io/io_alembic.c
@@ -68,6 +68,8 @@
 
 static int wm_alembic_export_invoke(bContext *C, wmOperator *op, const wmEvent 
*event)
 {
+   RNA_boolean_set(op->ptr, "init_scene_frame_range", true);
+
if (!RNA_struct_property_is_set(op->ptr, "filepath")) {
Main *bmain = CTX_data_main(C);
char filepath[FILE_MAX];
@@ -240,9 +242,11 @@ static void wm_alembic_export_draw(bContext *C, wmOperator 
*op)
/* Conveniently set start and end frame to match the scene's frame 
range. */
Scene *scene = CTX_data_scene(C);
 
-   if (scene != NULL) {
+   if (scene != NULL && RNA_boolean_get(, "init_scene_frame_range")) {
RNA_int_set(, "start", SFRA);
RNA_int_set(, "end", EFRA);
+
+   RNA_boolean_set(, "init_scene_frame_range", false);
}
 
ui_alembic_export_settings(op->layout, );
@@ -343,6 +347,11 @@ void WM_OT_alembic_export(wmOperatorType *ot)
 
RNA_def_enum(ot->srna, "ngon_method", 
rna_enum_modifier_triangulate_quad_method_items,
 MOD_TRIANGULATE_NGON_BEAUTY, "Polygon Method", "Method for 
splitting the polygons into triangles");
+
+   /* This dummy prop is used to check whether we need to init the start 
and
+ * end frame values to that of the scene's, otherwise they are reset at
+ * every change, draw update. */
+   RNA_def_boolean(ot->srna, "init_scene_frame_range", false, "", "");
 }
 
 /* ** 
*/

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


[Bf-blender-cvs] [753edaf] master: Alembic: store a pointer to the object reader in the cache modifiers and constraints.

2016-10-29 Thread Kévin Dietrich
Commit: 753edafcb77d9aaf07fe869372319b841dd80681
Author: Kévin Dietrich
Date:   Sat Oct 29 12:23:09 2016 +0200
Branches: master
https://developer.blender.org/rB753edafcb77d9aaf07fe869372319b841dd80681

Alembic: store a pointer to the object reader in the cache modifiers and
constraints.

This avoids traversing the archive everytime object data is needed and
gives an overall consistent ~2x speedup here with files containing
between 136 and 500 Alembic objects. Also this somewhat nicely de-
duplicates code between data creation (upon import) and data streaming
(modifiers and constraints).

The only worying part is what happens when a CacheFile is deleted and/or
has its path changed. For now, we traverse the whole scene and for each
object using the CacheFile we free the pointer and NULL-ify it (see
BKE_cachefile_clean), but at some point this should be re-considered and
make use of the dependency graph.

===

M   source/blender/alembic/ABC_alembic.h
M   source/blender/alembic/intern/abc_curves.cc
M   source/blender/alembic/intern/abc_curves.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/abc_points.cc
M   source/blender/alembic/intern/abc_points.h
M   source/blender/alembic/intern/abc_util.cc
M   source/blender/alembic/intern/abc_util.h
M   source/blender/alembic/intern/alembic_capi.cc
M   source/blender/blenkernel/BKE_cachefile.h
M   source/blender/blenkernel/intern/cachefile.c
M   source/blender/blenkernel/intern/constraint.c
M   source/blender/makesdna/DNA_cachefile_types.h
M   source/blender/makesdna/DNA_constraint_types.h
M   source/blender/makesdna/DNA_modifier_types.h
M   source/blender/makesrna/intern/rna_cachefile.c
M   source/blender/makesrna/intern/rna_constraint.c
M   source/blender/makesrna/intern/rna_modifier.c
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 e62713f..e92d5f2 100644
--- a/source/blender/alembic/ABC_alembic.h
+++ b/source/blender/alembic/ABC_alembic.h
@@ -28,6 +28,7 @@ extern "C" {
 #endif
 
 struct bContext;
+struct CacheReader;
 struct DerivedMesh;
 struct ListBase;
 struct Object;
@@ -92,21 +93,25 @@ AbcArchiveHandle *ABC_create_handle(const char *filename, 
struct ListBase *objec
 
 void ABC_free_handle(AbcArchiveHandle *handle);
 
-void ABC_get_transform(AbcArchiveHandle *handle,
-   struct Object *ob,
-   const char *object_path,
+void ABC_get_transform(struct CacheReader *reader,
float r_mat[4][4],
float time,
float scale);
 
-struct DerivedMesh *ABC_read_mesh(AbcArchiveHandle *handle,
+struct DerivedMesh *ABC_read_mesh(struct CacheReader *reader,
   struct Object *ob,
   struct DerivedMesh *dm,
-  const char *object_path,
   const float time,
   const char **err_str,
   int flags);
 
+void CacheReader_free(struct CacheReader *reader);
+
+struct CacheReader *CacheReader_open_alembic_object(struct AbcArchiveHandle 
*handle,
+struct CacheReader *reader,
+struct Object *object,
+const char *object_path);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/source/blender/alembic/intern/abc_curves.cc 
b/source/blender/alembic/intern/abc_curves.cc
index 2b54741..7e5ea3b 100644
--- a/source/blender/alembic/intern/abc_curves.cc
+++ b/source/blender/alembic/intern/abc_curves.cc
@@ -37,6 +37,7 @@ extern "C" {
 
 #include "BLI_listbase.h"
 
+#include "BKE_cdderivedmesh.h"
 #include "BKE_curve.h"
 #include "BKE_object.h"
 
@@ -353,3 +354,54 @@ void read_curve_sample(Curve *cu, const ICurvesSchema 
, const float time)
BLI_addtail(BKE_curve_nurbs_get(cu), nu);
}
 }
+
+/* NOTE: Alembic only stores data about control points, but the DerivedMesh
+ * passed from the cache modifier contains the displist, which has more data
+ * than the control points, so to avoid corrupting the displist we modify the
+ * object directly and create a new DerivedMesh from that. Also we might need 
to
+ * create new or delete existing NURBS in the curve.
+ */
+DerivedMesh *AbcCurveReader::read_derivedmesh(DerivedMesh */*dm*/, const float 
time, int /*read_flag*/)
+{
+   ISampleSelector sample_sel(time);
+   const ICurvesSchema::Sample