Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2018-03-10 02:37:07 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2018-03-10 06:54:05 +0300
commit267d8923265a284c5d9a462e1d86305d613fcad8 (patch)
tree7e0bd31d403a4d878ec65aaac3883bbfea67cc20 /intern/cycles/blender
parent6c4ddfc5d9833b6c4f0ae3da93645556fee97caf (diff)
Code refactor: motion blur cleanups, preparing for next commit.
Diffstat (limited to 'intern/cycles/blender')
-rw-r--r--intern/cycles/blender/blender_curves.cpp18
-rw-r--r--intern/cycles/blender/blender_mesh.cpp52
-rw-r--r--intern/cycles/blender/blender_object.cpp12
-rw-r--r--intern/cycles/blender/blender_sync.h2
4 files changed, 31 insertions, 53 deletions
diff --git a/intern/cycles/blender/blender_curves.cpp b/intern/cycles/blender/blender_curves.cpp
index f7cb0b66d29..daccb89f5a2 100644
--- a/intern/cycles/blender/blender_curves.cpp
+++ b/intern/cycles/blender/blender_curves.cpp
@@ -633,10 +633,10 @@ static void ExportCurveSegments(Scene *scene, Mesh *mesh, ParticleCurveData *CDa
}
}
-static void ExportCurveSegmentsMotion(Mesh *mesh, ParticleCurveData *CData, int time_index)
+static void ExportCurveSegmentsMotion(Mesh *mesh, ParticleCurveData *CData, int motion_step)
{
VLOG(1) << "Exporting curve motion segments for mesh " << mesh->name
- << ", time index " << time_index;
+ << ", motion step " << motion_step;
/* find attribute */
Attribute *attr_mP = mesh->curve_attributes.find(ATTR_STD_MOTION_VERTEX_POSITION);
@@ -651,7 +651,7 @@ static void ExportCurveSegmentsMotion(Mesh *mesh, ParticleCurveData *CData, int
/* export motion vectors for curve keys */
size_t numkeys = mesh->curve_keys.size();
- float4 *mP = attr_mP->data_float4() + time_index*numkeys;
+ float4 *mP = attr_mP->data_float4() + motion_step*numkeys;
bool have_motion = false;
int i = 0;
@@ -702,12 +702,12 @@ static void ExportCurveSegmentsMotion(Mesh *mesh, ParticleCurveData *CData, int
}
mesh->curve_attributes.remove(ATTR_STD_MOTION_VERTEX_POSITION);
}
- else if(time_index > 0) {
- VLOG(1) << "Filling in new motion vertex position for time_index "
- << time_index;
+ else if(motion_step > 0) {
+ VLOG(1) << "Filling in new motion vertex position for motion_step "
+ << motion_step;
/* motion, fill up previous steps that we might have skipped because
* they had no motion, but we need them anyway now */
- for(int step = 0; step < time_index; step++) {
+ for(int step = 0; step < motion_step; step++) {
float4 *mP = attr_mP->data_float4() + step*numkeys;
for(int key = 0; key < numkeys; key++) {
@@ -888,7 +888,7 @@ void BlenderSync::sync_curves(Mesh *mesh,
BL::Mesh& b_mesh,
BL::Object& b_ob,
bool motion,
- int time_index)
+ int motion_step)
{
if(!motion) {
/* Clear stored curve data */
@@ -951,7 +951,7 @@ void BlenderSync::sync_curves(Mesh *mesh,
}
else {
if(motion)
- ExportCurveSegmentsMotion(mesh, &CData, time_index);
+ ExportCurveSegmentsMotion(mesh, &CData, motion_step);
else
ExportCurveSegments(scene, mesh, &CData);
}
diff --git a/intern/cycles/blender/blender_mesh.cpp b/intern/cycles/blender/blender_mesh.cpp
index 998390e92a9..7d6ca18b074 100644
--- a/intern/cycles/blender/blender_mesh.cpp
+++ b/intern/cycles/blender/blender_mesh.cpp
@@ -1248,36 +1248,10 @@ void BlenderSync::sync_mesh_motion(BL::Object& b_ob,
if(mesh_synced.find(mesh) == mesh_synced.end())
return;
- /* for motion pass always compute, for motion blur it can be disabled */
- int time_index = 0;
-
- if(scene->need_motion() == Scene::MOTION_BLUR) {
- if(!mesh->use_motion_blur)
- return;
-
- /* see if this mesh needs motion data at this time */
- vector<float> object_times = object->motion_times();
- bool found = false;
-
- foreach(float object_time, object_times) {
- if(motion_time == object_time) {
- found = true;
- break;
- }
- else
- time_index++;
- }
-
- if(!found)
- return;
- }
- else {
- if(motion_time == -1.0f)
- time_index = 0;
- else if(motion_time == 1.0f)
- time_index = 1;
- else
- return;
+ /* Find time matching motion step required by mesh. */
+ int motion_step = mesh->motion_step(motion_time);
+ if(motion_step < 0) {
+ return;
}
/* skip empty meshes */
@@ -1319,9 +1293,9 @@ void BlenderSync::sync_mesh_motion(BL::Object& b_ob,
float3 *P = &mesh->verts[0];
float3 *N = (attr_N)? attr_N->data_float3(): NULL;
- memcpy(attr_mP->data_float3() + time_index*numverts, P, sizeof(float3)*numverts);
+ memcpy(attr_mP->data_float3() + motion_step*numverts, P, sizeof(float3)*numverts);
if(attr_mN)
- memcpy(attr_mN->data_float3() + time_index*numverts, N, sizeof(float3)*numverts);
+ memcpy(attr_mN->data_float3() + motion_step*numverts, N, sizeof(float3)*numverts);
}
}
@@ -1331,7 +1305,7 @@ void BlenderSync::sync_mesh_motion(BL::Object& b_ob,
if(attr_mP) {
float3 *keys = &mesh->curve_keys[0];
- memcpy(attr_mP->data_float3() + time_index*numkeys, keys, sizeof(float3)*numkeys);
+ memcpy(attr_mP->data_float3() + motion_step*numkeys, keys, sizeof(float3)*numkeys);
}
}
@@ -1354,8 +1328,8 @@ void BlenderSync::sync_mesh_motion(BL::Object& b_ob,
new_attribute = true;
}
/* Load vertex data from mesh. */
- float3 *mP = attr_mP->data_float3() + time_index*numverts;
- float3 *mN = (attr_mN)? attr_mN->data_float3() + time_index*numverts: NULL;
+ float3 *mP = attr_mP->data_float3() + motion_step*numverts;
+ float3 *mN = (attr_mN)? attr_mN->data_float3() + motion_step*numverts: NULL;
/* NOTE: We don't copy more that existing amount of vertices to prevent
* possible memory corruption.
*/
@@ -1384,13 +1358,13 @@ void BlenderSync::sync_mesh_motion(BL::Object& b_ob,
if(attr_mN)
mesh->attributes.remove(ATTR_STD_MOTION_VERTEX_NORMAL);
}
- else if(time_index > 0) {
+ else if(motion_step > 0) {
VLOG(1) << "Filling deformation motion for object " << b_ob.name();
/* motion, fill up previous steps that we might have skipped because
* they had no motion, but we need them anyway now */
float3 *P = &mesh->verts[0];
float3 *N = (attr_N)? attr_N->data_float3(): NULL;
- for(int step = 0; step < time_index; step++) {
+ for(int step = 0; step < motion_step; step++) {
memcpy(attr_mP->data_float3() + step*numverts, P, sizeof(float3)*numverts);
if(attr_mN)
memcpy(attr_mN->data_float3() + step*numverts, N, sizeof(float3)*numverts);
@@ -1400,7 +1374,7 @@ void BlenderSync::sync_mesh_motion(BL::Object& b_ob,
else {
if(b_mesh.vertices.length() != numverts) {
VLOG(1) << "Topology differs, discarding motion blur for object "
- << b_ob.name() << " at time " << time_index;
+ << b_ob.name() << " at time " << motion_step;
memcpy(mP, &mesh->verts[0], sizeof(float3)*numverts);
if(mN != NULL) {
memcpy(mN, attr_N->data_float3(), sizeof(float3)*numverts);
@@ -1411,7 +1385,7 @@ void BlenderSync::sync_mesh_motion(BL::Object& b_ob,
/* hair motion */
if(numkeys)
- sync_curves(mesh, b_mesh, b_ob, true, time_index);
+ sync_curves(mesh, b_mesh, b_ob, true, motion_step);
/* free derived mesh */
b_data.meshes.remove(b_mesh, false, true, false);
diff --git a/intern/cycles/blender/blender_object.cpp b/intern/cycles/blender/blender_object.cpp
index 38ef1bc5249..45309292f0b 100644
--- a/intern/cycles/blender/blender_object.cpp
+++ b/intern/cycles/blender/blender_object.cpp
@@ -396,7 +396,6 @@ Object *BlenderSync::sync_object(BL::Object& b_parent,
/* motion blur */
if(scene->need_motion() == Scene::MOTION_BLUR && object->mesh) {
Mesh *mesh = object->mesh;
-
mesh->use_motion_blur = false;
if(object_use_motion(b_parent, b_ob)) {
@@ -405,9 +404,9 @@ Object *BlenderSync::sync_object(BL::Object& b_parent,
mesh->use_motion_blur = true;
}
- vector<float> times = object->motion_times();
- foreach(float time, times)
- motion_times.insert(time);
+ for(size_t step = 0; step < mesh->motion_steps - 1; step++) {
+ motion_times.insert(mesh->motion_time(step));
+ }
}
}
@@ -694,6 +693,11 @@ void BlenderSync::sync_motion(BL::RenderSettings& b_render,
/* note iteration over motion_times set happens in sorted order */
foreach(float relative_time, motion_times) {
+ /* center time is already handled. */
+ if(relative_time == 0.0f) {
+ continue;
+ }
+
VLOG(1) << "Synchronizing motion for the relative time "
<< relative_time << ".";
diff --git a/intern/cycles/blender/blender_sync.h b/intern/cycles/blender/blender_sync.h
index e7b71ae9310..1e7b0b32518 100644
--- a/intern/cycles/blender/blender_sync.h
+++ b/intern/cycles/blender/blender_sync.h
@@ -118,7 +118,7 @@ private:
BL::Mesh& b_mesh,
BL::Object& b_ob,
bool motion,
- int time_index = 0);
+ int motion_step = 0);
Object *sync_object(BL::Object& b_parent,
int persistent_id[OBJECT_PERSISTENT_ID_SIZE],
BL::DupliObject& b_dupli_ob,