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-08 06:04:52 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2018-03-10 08:27:19 +0300
commitdb333d9ea4881d9f48e3cc4b1ec59b4dafb27cc0 (patch)
tree6ac02ba4a284e6196ed345be775cbad6436f5d7f /intern/cycles/blender
parent78c2063685cb6e0d0bcb895cf4eb70686455d596 (diff)
Cycles: support arbitrary number of motion blur steps for objects.
Diffstat (limited to 'intern/cycles/blender')
-rw-r--r--intern/cycles/blender/addon/properties.py2
-rw-r--r--intern/cycles/blender/blender_camera.cpp4
-rw-r--r--intern/cycles/blender/blender_object.cpp49
-rw-r--r--intern/cycles/blender/blender_util.h41
4 files changed, 47 insertions, 49 deletions
diff --git a/intern/cycles/blender/addon/properties.py b/intern/cycles/blender/addon/properties.py
index 62aea8790af..1b95c365616 100644
--- a/intern/cycles/blender/addon/properties.py
+++ b/intern/cycles/blender/addon/properties.py
@@ -1088,7 +1088,7 @@ class CyclesObjectSettings(bpy.types.PropertyGroup):
cls.motion_steps = IntProperty(
name="Motion Steps",
- description="Control accuracy of deformation motion blur, more steps gives more memory usage (actual number of steps is 2^(steps - 1))",
+ description="Control accuracy of motion blur, more steps gives more memory usage (actual number of steps is 2^(steps - 1))",
min=1, soft_max=8,
default=1,
)
diff --git a/intern/cycles/blender/blender_camera.cpp b/intern/cycles/blender/blender_camera.cpp
index 909db8d9449..f00ade320e7 100644
--- a/intern/cycles/blender/blender_camera.cpp
+++ b/intern/cycles/blender/blender_camera.cpp
@@ -229,9 +229,7 @@ static void blender_camera_from_object(BlenderCamera *bcam,
else
bcam->sensor_fit = BlenderCamera::VERTICAL;
- if(object_use_motion(b_ob, b_ob)) {
- bcam->motion_steps = object_motion_steps(b_ob);
- }
+ bcam->motion_steps = object_motion_steps(b_ob, b_ob);
}
else {
/* from lamp not implemented yet */
diff --git a/intern/cycles/blender/blender_object.cpp b/intern/cycles/blender/blender_object.cpp
index 45309292f0b..4b40f4d458b 100644
--- a/intern/cycles/blender/blender_object.cpp
+++ b/intern/cycles/blender/blender_object.cpp
@@ -327,22 +327,11 @@ Object *BlenderSync::sync_object(BL::Object& b_parent,
if(motion) {
object = object_map.find(key);
- if(object && (scene->need_motion() == Scene::MOTION_PASS ||
- object_use_motion(b_parent, b_ob)))
- {
- /* object transformation */
- if(tfm != object->tfm) {
- VLOG(1) << "Object " << b_ob.name() << " motion detected.";
- if(motion_time == -1.0f || motion_time == 1.0f) {
- object->use_motion = true;
- }
- }
-
- if(motion_time == -1.0f) {
- object->motion.pre = tfm;
- }
- else if(motion_time == 1.0f) {
- object->motion.post = tfm;
+ if(object && object->use_motion()) {
+ /* Set transform at matching motion time step. */
+ int time_index = object->motion_step(motion_time);
+ if(time_index >= 0) {
+ object->motion[time_index] = tfm;
}
/* mesh deformation */
@@ -389,24 +378,34 @@ Object *BlenderSync::sync_object(BL::Object& b_parent,
object->name = b_ob.name().c_str();
object->pass_id = b_ob.pass_index();
object->tfm = tfm;
- object->motion.pre = transform_empty();
- object->motion.post = transform_empty();
- object->use_motion = false;
+ object->motion.clear();
/* motion blur */
- if(scene->need_motion() == Scene::MOTION_BLUR && object->mesh) {
+ Scene::MotionType need_motion = scene->need_motion();
+ if(need_motion != Scene::MOTION_NONE && object->mesh) {
Mesh *mesh = object->mesh;
mesh->use_motion_blur = false;
+ mesh->motion_steps = 0;
- if(object_use_motion(b_parent, b_ob)) {
+ uint motion_steps;
+
+ if(scene->need_motion() == Scene::MOTION_BLUR) {
+ motion_steps = object_motion_steps(b_parent, b_ob);
if(object_use_deform_motion(b_parent, b_ob)) {
- mesh->motion_steps = object_motion_steps(b_ob);
+ mesh->motion_steps = motion_steps;
mesh->use_motion_blur = true;
}
+ }
+ else {
+ motion_steps = 3;
+ mesh->motion_steps = motion_steps;
+ }
- for(size_t step = 0; step < mesh->motion_steps - 1; step++) {
- motion_times.insert(mesh->motion_time(step));
- }
+ object->motion.resize(motion_steps, transform_empty());
+ object->motion[motion_steps/2] = tfm;
+
+ for(size_t step = 0; step < motion_steps; step++) {
+ motion_times.insert(object->motion_time(step));
}
}
diff --git a/intern/cycles/blender/blender_util.h b/intern/cycles/blender/blender_util.h
index c4c45035b5a..c418b19a637 100644
--- a/intern/cycles/blender/blender_util.h
+++ b/intern/cycles/blender/blender_util.h
@@ -484,33 +484,34 @@ static inline void mesh_texture_space(BL::Mesh& b_mesh,
loc = loc*size - make_float3(0.5f, 0.5f, 0.5f);
}
-/* object used for motion blur */
-static inline bool object_use_motion(BL::Object& b_parent, BL::Object& b_ob)
+/* Object motion steps, returns 0 if no motion blur needed. */
+static inline uint object_motion_steps(BL::Object& b_parent, BL::Object& b_ob)
{
+ /* Get motion enabled and steps from object itself. */
PointerRNA cobject = RNA_pointer_get(&b_ob.ptr, "cycles");
bool use_motion = get_boolean(cobject, "use_motion_blur");
- /* If motion blur is enabled for the object we also check
- * whether it's enabled for the parent object as well.
- *
- * This way we can control motion blur from the dupligroup
- * duplicator much easier.
- */
- if(use_motion && b_parent.ptr.data != b_ob.ptr.data) {
+ if(!use_motion) {
+ return 0;
+ }
+
+ uint steps = max(1, get_int(cobject, "motion_steps"));
+
+ /* Also check parent object, so motion blur and steps can be
+ * controlled by dupligroup duplicator for linked groups. */
+ if(b_parent.ptr.data != b_ob.ptr.data) {
PointerRNA parent_cobject = RNA_pointer_get(&b_parent.ptr, "cycles");
use_motion &= get_boolean(parent_cobject, "use_motion_blur");
- }
- return use_motion;
-}
-/* object motion steps */
-static inline uint object_motion_steps(BL::Object& b_ob)
-{
- PointerRNA cobject = RNA_pointer_get(&b_ob.ptr, "cycles");
- uint steps = get_int(cobject, "motion_steps");
+ if(!use_motion) {
+ return 0;
+ }
+
+ steps = max(steps, get_int(parent_cobject, "motion_steps"));
+ }
- /* use uneven number of steps so we get one keyframe at the current frame,
- * and ue 2^(steps - 1) so objects with more/fewer steps still have samples
- * at the same times, to avoid sampling at many different times */
+ /* Use uneven number of steps so we get one keyframe at the current frame,
+ * and use 2^(steps - 1) so objects with more/fewer steps still have samples
+ * at the same times, to avoid sampling at many different times. */
return (2 << (steps - 1)) + 1;
}