From: Helge Norberg Date: Tue, 19 Jan 2016 12:56:03 +0000 (+0100) Subject: Changed meaning of frame variable in scene to a continously animating variable. The... X-Git-Tag: 2.1.0_Beta1~116 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=ff80d200060c9a2bb574dea979c0d688269c6d2a;p=casparcg Changed meaning of frame variable in scene to a continously animating variable. The previous meaning was renamed to timeline_frame and will pause when the timeline is paused. This allows animations to continue even though the timeline is not moving. --- diff --git a/core/producer/scene/expression_parser.cpp b/core/producer/scene/expression_parser.cpp index 2fb5b42cc..8d55ef767 100644 --- a/core/producer/scene/expression_parser.cpp +++ b/core/producer/scene/expression_parser.cpp @@ -118,7 +118,7 @@ boost::any create_animate_function(const std::vector& params, const << msg_info(L"animate() function requires three parameters: to_animate, duration, tweener")); auto to_animate = require(params.at(0)); - auto frame_counter = var_repo(L"frame").as().as(); + auto frame_counter = var_repo(L"frame").as(); auto duration = require(params.at(1)); auto tw = require(params.at(2)).transformed([](const std::wstring& s) { return tweener(s); }); diff --git a/core/producer/scene/scene_producer.cpp b/core/producer/scene/scene_producer.cpp index 84161ad1c..fd99bb96b 100644 --- a/core/producer/scene/scene_producer.cpp +++ b/core/producer/scene/scene_producer.cpp @@ -123,7 +123,8 @@ struct scene_producer::impl video_format_desc format_desc_; std::list layers_; interaction_aggregator aggregator_; - binding frame_number_; + binding frame_number_; + binding timeline_frame_number_; binding speed_; mutable tbb::atomic m_x_; mutable tbb::atomic m_y_; @@ -149,10 +150,14 @@ struct scene_producer::impl store_variable(L"scene_speed", speed_variable); speed_ = speed_variable->value(); - auto frame_variable = std::make_shared>(L"-1", true, -1); + auto frame_variable = std::make_shared>(L"-1", true, -1); store_variable(L"frame", frame_variable); frame_number_ = frame_variable->value(); + auto timeline_frame_variable = std::make_shared>(L"-1", false, -1); + store_variable(L"timeline_frame", timeline_frame_variable); + timeline_frame_number_ = timeline_frame_variable->value(); + auto mouse_x_variable = std::make_shared>(L"0", false, 0); auto mouse_y_variable = std::make_shared>(L"0", false, 0); store_variable(L"mouse_x", mouse_x_variable); @@ -212,9 +217,9 @@ struct scene_producer::impl return variable_names_; } - binding frame() + binding timeline_frame() { - return frame_number_; + return timeline_frame_number_; } frame_transform get_transform(const layer& layer) const @@ -329,8 +334,8 @@ struct scene_producer::impl if (std::abs(frame_fraction_) >= 1.0) { int64_t delta = static_cast(frame_fraction_); - auto previous_frame = frame_number_.get(); - auto next_frame = frame_number_.get() + delta; + auto previous_frame = timeline_frame_number_.get(); + auto next_frame = timeline_frame_number_.get() + delta; auto marker = find_first_stop_or_jump_or_remove(previous_frame + 1, next_frame); if (marker && marker->second.action == mark_action::remove) @@ -341,7 +346,7 @@ struct scene_producer::impl { if (marker->second.action == mark_action::stop) { - frame_number_.set(marker->first); + timeline_frame_number_.set(marker->first); frame_fraction_ = 0.0; paused_ = true; } @@ -352,7 +357,7 @@ struct scene_producer::impl } else { - frame_number_.set(next_frame); + timeline_frame_number_.set(next_frame); frame_fraction_ -= delta; } @@ -365,14 +370,16 @@ struct scene_producer::impl if (removed_) return draw_frame::empty(); + mouse_x_.set(m_x_); + mouse_y_.set(m_y_); + if (!paused_) advance(); - for (auto& timeline : timelines_) - timeline.second.on_frame(frame_number_.get()); + frame_number_.set(frame_number_.get() + speed_.get()); - mouse_x_.set(m_x_); - mouse_y_.set(m_y_); + for (auto& timeline : timelines_) + timeline.second.on_frame(timeline_frame_number_.get()); std::vector frames; @@ -470,11 +477,11 @@ struct scene_producer::impl void next() { - auto marker = find_first_start(frame_number_.get() + 1); + auto marker = find_first_start(timeline_frame_number_.get() + 1); if (marker) { - frame_number_.set(marker->first - 1); + timeline_frame_number_.set(marker->first - 1); frame_fraction_ = 0.0; paused_ = false; going_to_mark_ = true; @@ -491,7 +498,7 @@ struct scene_producer::impl { if (marker.second.label_argument == marker_name && marker.second.action == mark_action::start) { - frame_number_.set(marker.first + offset); + timeline_frame_number_.set(marker.first + offset); frame_fraction_ = 0.0; paused_ = false; going_to_mark_ = true; @@ -502,7 +509,7 @@ struct scene_producer::impl if (marker_name == L"intro") { - frame_number_.set(offset); + timeline_frame_number_.set(offset); frame_fraction_ = 0.0; paused_ = false; going_to_mark_ = true; @@ -531,6 +538,7 @@ struct scene_producer::impl info.add(L"type", L"scene"); info.add(L"producer-name", name()); info.add(L"frame-number", frame_number_.get()); + info.add(L"timeline-frame-number", timeline_frame_number_.get()); for (auto& var : variables_) { @@ -591,9 +599,9 @@ void scene_producer::reverse_layers() { impl_->reverse_layers(); } -binding scene_producer::frame() +binding scene_producer::timeline_frame() { - return impl_->frame(); + return impl_->timeline_frame(); } draw_frame scene_producer::receive_impl() diff --git a/core/producer/scene/scene_producer.h b/core/producer/scene/scene_producer.h index 074bc97a9..ccfad7fe9 100644 --- a/core/producer/scene/scene_producer.h +++ b/core/producer/scene/scene_producer.h @@ -130,7 +130,7 @@ public: const spl::shared_ptr& producer, const std::wstring& name); void reverse_layers(); - binding frame(); + binding timeline_frame(); binding speed(); template binding& create_variable( diff --git a/core/producer/scene/xml_scene_producer.cpp b/core/producer/scene/xml_scene_producer.cpp index 1fe9e3829..5eacb6c36 100644 --- a/core/producer/scene/xml_scene_producer.cpp +++ b/core/producer/scene/xml_scene_producer.cpp @@ -206,26 +206,29 @@ spl::shared_ptr create_xml_scene_producer( } } - for (auto& elem : root | witerate_children(L"scene.timelines") | welement_context_iteration) + if (root.get_child_optional(L"scene.timelines")) { - ptree_verify_element_name(elem, L"timeline"); + for (auto& elem : root | witerate_children(L"scene.timelines") | welement_context_iteration) + { + ptree_verify_element_name(elem, L"timeline"); - auto& variable = scene->get_variable(ptree_get(elem.second, L".variable")); + auto& variable = scene->get_variable(ptree_get(elem.second, L".variable")); - for (auto& k : elem.second) - { - if (k.first == L"") - continue; + for (auto& k : elem.second) + { + if (k.first == L"") + continue; - ptree_verify_element_name(k, L"keyframe"); + ptree_verify_element_name(k, L"keyframe"); - auto easing = k.second.get(L".easing", L""); - auto at = ptree_get(k.second, L".at"); + auto easing = k.second.get(L".easing", L""); + auto at = ptree_get(k.second, L".at"); - if (variable.is()) - scene->add_keyframe(variable.as(), ptree_get_value(k.second), at, easing); - else if (variable.is()) - scene->add_keyframe(variable.as(), ptree_get_value(k.second), at, easing); + if (variable.is()) + scene->add_keyframe(variable.as(), ptree_get_value(k.second), at, easing); + else if (variable.is()) + scene->add_keyframe(variable.as(), ptree_get_value(k.second), at, easing); + } } } diff --git a/modules/psd/psd_scene_producer.cpp b/modules/psd/psd_scene_producer.cpp index f372419b5..577ee790e 100644 --- a/modules/psd/psd_scene_producer.cpp +++ b/modules/psd/psd_scene_producer.cpp @@ -283,7 +283,7 @@ void create_timelines( auto start_frame = get_frame_number(format_desc, start); auto end_frame = get_frame_number(format_desc, end); - layer.hidden = scene->frame() < start_frame || scene->frame() > end_frame; + layer.hidden = scene->timeline_frame() < start_frame || scene->timeline_frame() > end_frame; auto tracklist = timeline.get_child_optional(L"trackList");