Commit: 3e13b9db2749c376bfe1a0ec714f2cb00b709c99
Author: Kévin Dietrich
Date:   Fri Jul 8 11:42:05 2016 +0200
Branches: alembic_basic_io
https://developer.blender.org/rB3e13b9db2749c376bfe1a0ec714f2cb00b709c99

Velocity vectors:
- Avoid reading vectors twice.
- Scale by the FPS.

===================================================================

M       intern/cycles/blender/blender_mesh.cpp
M       source/blender/alembic/intern/alembic_capi.cc

===================================================================

diff --git a/intern/cycles/blender/blender_mesh.cpp 
b/intern/cycles/blender/blender_mesh.cpp
index 1db6e91..23fd144 100644
--- a/intern/cycles/blender/blender_mesh.cpp
+++ b/intern/cycles/blender/blender_mesh.cpp
@@ -1000,19 +1000,22 @@ void BlenderSync::sync_mesh_motion(BL::Object& b_ob,
 
                        int step = 0;
 
+//                     fprintf(stderr, "%s, vertices: %lu\n", __func__, 
numverts);
+
+                       float3 *buffer = new float3[numverts];
+
+                       
MeshSequenceCacheModifier_velocity_cache_get(&mesh_cache.ptr, &buffer[0].x);
+
                        /* Generate motion data for all motion times in one go, 
so that
                         * vertices and velocities coincide. */
                        foreach(float relative_time, this->motion_times) {
                                float3 *mP = attr_mP->data_float3() + 
step*numverts;
                                float3 *mN = (attr_mN) ? attr_mN->data_float3() 
+ step*numverts : NULL;
 
-//                             printf("Setting velocity for relative time: 
%f\n", (double)relative_time);
-
-                               
MeshSequenceCacheModifier_velocity_cache_get(&mesh_cache.ptr, &mP[0].x);
+//                             fprintf(stderr, "Setting velocity for relative 
time: %f\n", (double)relative_time);
 
                                for (int i = 0; i < numverts; ++i) {
-                                       float3 nPos = P[i] + 
mP[i]*relative_time*shuttertime*0.5f;
-                                       mP[i] = nPos;
+                                       mP[i] = P[i] + 
buffer[i]*relative_time*shuttertime*0.5f;
 
                                        if(mN) {
                                                mN[i] = N[i];
@@ -1021,6 +1024,8 @@ void BlenderSync::sync_mesh_motion(BL::Object& b_ob,
 
                                ++step;
                        }
+
+                       delete [] buffer;
                }
                else {
                        /* load vertex data from mesh */
diff --git a/source/blender/alembic/intern/alembic_capi.cc 
b/source/blender/alembic/intern/alembic_capi.cc
index ec62248..e8cf6e2 100644
--- a/source/blender/alembic/intern/alembic_capi.cc
+++ b/source/blender/alembic/intern/alembic_capi.cc
@@ -1016,8 +1016,11 @@ void ABC_get_velocity_cache(AbcArchiveHandle *handle, 
const char *object_path, f
                }
        }
 
+       float fps = 1.0f / 24.0f;
        float vel[3];
 
+       std::cerr << __func__ << ", velocity vectors: " << velocities->size() 
<< '\n';
+
 //#define DEBUG_VELOCITY
 
 #ifdef DEBUG_VELOCITY
@@ -1044,9 +1047,8 @@ void ABC_get_velocity_cache(AbcArchiveHandle *handle, 
const char *object_path, f
                }
 #endif
 
-               (*values++) = vel[0];
-               (*values++) = vel[1];
-               (*values++) = vel[2];
+               mul_v3_fl(vel, fps);
+               copy_v3_v3(values + i * 3, vel);
        }
 
 #ifdef DEBUG_VELOCITY

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to