diff --git a/rhubarb/CMakeLists.txt b/rhubarb/CMakeLists.txt index 2bad0e4..a0f481e 100644 --- a/rhubarb/CMakeLists.txt +++ b/rhubarb/CMakeLists.txt @@ -321,26 +321,23 @@ set_target_properties(vorbis PROPERTIES FOLDER lib) include_directories("src") # ... rhubarb-animation -add_library( +add_library(rhubarb-animation) +target_sources( rhubarb-animation - src/animation/animation-rules.cpp - src/animation/animation-rules.h - src/animation/mouth-animation.cpp - src/animation/mouth-animation.h - src/animation/pause-animation.cpp - src/animation/pause-animation.h - src/animation/rough-animation.cpp - src/animation/rough-animation.h - src/animation/shape-rule.cpp - src/animation/shape-rule.h - src/animation/static-segments.cpp - src/animation/static-segments.h - src/animation/target-shape-set.cpp - src/animation/target-shape-set.h - src/animation/timing-optimization.cpp - src/animation/timing-optimization.h - src/animation/tweening.cpp - src/animation/tweening.h + PUBLIC + FILE_SET publicModules + TYPE CXX_MODULES + FILES + src/animation/animation.cppm + src/animation/animation-rules.cppm + src/animation/mouth-animation.cppm + src/animation/pause-animation.cppm + src/animation/rough-animation.cppm + src/animation/shape-rule.cppm + src/animation/static-segments.cppm + src/animation/target-shape-set.cppm + src/animation/timing-optimization.cppm + src/animation/tweening.cppm ) target_include_directories(rhubarb-animation PRIVATE "src/animation") target_link_libraries(rhubarb-animation rhubarb-core rhubarb-logging rhubarb-time) diff --git a/rhubarb/src/animation/animation-rules.cpp b/rhubarb/src/animation/animation-rules.cppm similarity index 86% rename from rhubarb/src/animation/animation-rules.cpp rename to rhubarb/src/animation/animation-rules.cppm index d3cbaae..dcb8791 100644 --- a/rhubarb/src/animation/animation-rules.cpp +++ b/rhubarb/src/animation/animation-rules.cppm @@ -1,10 +1,14 @@ -#include "animation-rules.h" +module; #include #include +#include +#include "core/phone.h" #include "core/shape.h" -#include "time/continuous-timeline.h" +#include "time/timeline.h" + +export module rhubarb.animation:animation_rules; using boost::optional; using boost::algorithm::clamp; @@ -18,18 +22,21 @@ using enum Shape; constexpr size_t shapeValueCount = static_cast(Shape::EndSentinel); +// Returns the basic shape (A-F) that most closely resembles the specified shape. Shape getBasicShape(Shape shape) { static constexpr array basicShapes = to_array({A, B, C, D, E, F, A, C, A}); return basicShapes[static_cast(shape)]; } +// Returns the mouth shape that results from relaxing the specified shape. Shape relax(Shape shape) { static constexpr array relaxedShapes = to_array({A, B, B, C, C, B, X, B, X}); return relaxedShapes[static_cast(shape)]; } +// Gets the shape from a non-empty set of shapes that most closely resembles a reference shape. Shape getClosestShape(Shape reference, ShapeSet shapes) { if (shapes.empty()) { throw std::invalid_argument("Cannot select from empty set of shapes."); @@ -59,6 +66,19 @@ Shape getClosestShape(Shape reference, ShapeSet shapes) { throw std::invalid_argument("Unable to find closest shape."); } +// Indicates how to time a tween between two mouth shapes +enum class TweenTiming { + // Tween should end at the original transition + Early, + + // Tween should overlap both original mouth shapes equally + Centered, + + // Tween should begin at the original transition + Late +}; + +// Returns the tween shape and timing to use to transition between the specified two mouth shapes. optional> getTween(Shape first, Shape second) { // Note that most of the following rules work in one direction only. // That's because in animation, the mouth should usually "pop" open without inbetweens, @@ -78,6 +98,10 @@ optional> getTween(Shape first, Shape second) { return it != lookup.end() ? it->second : optional>(); } +// Returns the shape set(s) to use for a given phone. +// The resulting timeline will always cover the entire duration of the phone (starting at 0 cs). +// It may extend into the negative time range if animation is required prior to the sound being +// heard. Timeline getShapeSets(Phone phone, centiseconds duration, centiseconds previousDuration) { // Returns a timeline with a single shape set const auto single = [duration](ShapeSet value) { diff --git a/rhubarb/src/animation/animation-rules.h b/rhubarb/src/animation/animation-rules.h deleted file mode 100644 index 51a492c..0000000 --- a/rhubarb/src/animation/animation-rules.h +++ /dev/null @@ -1,37 +0,0 @@ -#pragma once - -#include - -#include "core/phone.h" -#include "core/shape.h" -#include "time/timeline.h" - -// Returns the basic shape (A-F) that most closely resembles the specified shape. -Shape getBasicShape(Shape shape); - -// Returns the mouth shape that results from relaxing the specified shape. -Shape relax(Shape shape); - -// Gets the shape from a non-empty set of shapes that most closely resembles a reference shape. -Shape getClosestShape(Shape reference, ShapeSet shapes); - -// Indicates how to time a tween between two mouth shapes -enum class TweenTiming { - // Tween should end at the original transition - Early, - - // Tween should overlap both original mouth shapes equally - Centered, - - // Tween should begin at the original transition - Late -}; - -// Returns the tween shape and timing to use to transition between the specified two mouth shapes. -boost::optional> getTween(Shape first, Shape second); - -// Returns the shape set(s) to use for a given phone. -// The resulting timeline will always cover the entire duration of the phone (starting at 0 cs). -// It may extend into the negative time range if animation is required prior to the sound being -// heard. -Timeline getShapeSets(Phone phone, centiseconds duration, centiseconds previousDuration); diff --git a/rhubarb/src/animation/animation.cppm b/rhubarb/src/animation/animation.cppm new file mode 100644 index 0000000..e2a4df2 --- /dev/null +++ b/rhubarb/src/animation/animation.cppm @@ -0,0 +1,7 @@ +export module rhubarb.animation; + +import :target_shape_set; +import :mouth_animation; + +export using ::convertToTargetShapeSet; +export using ::animate; diff --git a/rhubarb/src/animation/mouth-animation.cpp b/rhubarb/src/animation/mouth-animation.cppm similarity index 76% rename from rhubarb/src/animation/mouth-animation.cpp rename to rhubarb/src/animation/mouth-animation.cppm index fdc1bf4..086dcb7 100644 --- a/rhubarb/src/animation/mouth-animation.cpp +++ b/rhubarb/src/animation/mouth-animation.cppm @@ -1,15 +1,21 @@ -#include "mouth-animation.h" +module; -#include "pause-animation.h" -#include "rough-animation.h" -#include "shape-rule.h" -#include "static-segments.h" -#include "target-shape-set.h" +#include "core/phone.h" +#include "core/shape.h" +#include "time/continuous-timeline.h" #include "time/timed-logging.h" -#include "timing-optimization.h" -#include "tweening.h" -JoiningContinuousTimeline animate( +export module rhubarb.animation:mouth_animation; + +import :pause_animation; +import :rough_animation; +import :shape_rule; +import :static_segments; +import :target_shape_set; +import :timing_optimization; +import :tweening; + +export JoiningContinuousTimeline animate( const BoundedTimeline& phones, const ShapeSet& targetShapeSet ) { // Create timeline of shape rules diff --git a/rhubarb/src/animation/mouth-animation.h b/rhubarb/src/animation/mouth-animation.h deleted file mode 100644 index 013ed21..0000000 --- a/rhubarb/src/animation/mouth-animation.h +++ /dev/null @@ -1,10 +0,0 @@ -#pragma once - -#include "core/phone.h" -#include "core/shape.h" -#include "target-shape-set.h" -#include "time/continuous-timeline.h" - -JoiningContinuousTimeline animate( - const BoundedTimeline& phones, const ShapeSet& targetShapeSet -); diff --git a/rhubarb/src/animation/pause-animation.cpp b/rhubarb/src/animation/pause-animation.cppm similarity index 80% rename from rhubarb/src/animation/pause-animation.cpp rename to rhubarb/src/animation/pause-animation.cppm index 28e5677..767bca4 100644 --- a/rhubarb/src/animation/pause-animation.cpp +++ b/rhubarb/src/animation/pause-animation.cppm @@ -1,6 +1,11 @@ -#include "pause-animation.h" +module; -#include "animation-rules.h" +#include "core/shape.h" +#include "time/continuous-timeline.h" + +export module rhubarb.animation:pause_animation; + +import :animation_rules; Shape getPauseShape(Shape previous, Shape next, centiseconds duration) { // For very short pauses: Just hold the previous shape @@ -29,7 +34,10 @@ Shape getPauseShape(Shape previous, Shape next, centiseconds duration) { return Shape::X; } -JoiningContinuousTimeline animatePauses(const JoiningContinuousTimeline& animation) { +// Takes an existing animation and modifies the pauses (X shapes) to look better. +export JoiningContinuousTimeline animatePauses( + const JoiningContinuousTimeline& animation +) { JoiningContinuousTimeline result(animation); for_each_adjacent( diff --git a/rhubarb/src/animation/pause-animation.h b/rhubarb/src/animation/pause-animation.h deleted file mode 100644 index 9569db4..0000000 --- a/rhubarb/src/animation/pause-animation.h +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once - -#include "core/shape.h" -#include "time/continuous-timeline.h" - -// Takes an existing animation and modifies the pauses (X shapes) to look better. -JoiningContinuousTimeline animatePauses(const JoiningContinuousTimeline& animation); diff --git a/rhubarb/src/animation/rough-animation.cpp b/rhubarb/src/animation/rough-animation.cppm similarity index 91% rename from rhubarb/src/animation/rough-animation.cpp rename to rhubarb/src/animation/rough-animation.cppm index 057100e..60369ff 100644 --- a/rhubarb/src/animation/rough-animation.cpp +++ b/rhubarb/src/animation/rough-animation.cppm @@ -1,8 +1,17 @@ -#include "rough-animation.h" +module; #include -// Create timeline of shapes using a bidirectional algorithm. +#include "core/phone.h" +#include "core/shape.h" +#include "time/continuous-timeline.h" + +export module rhubarb.animation:rough_animation; + +import :shape_rule; + +// Does a rough animation (no tweening, special pause animation, etc.) using a bidirectional +// algorithm. // Here's a rough sketch: // // * Most consonants result in shape sets with multiple options; most vowels have only one shape diff --git a/rhubarb/src/animation/rough-animation.h b/rhubarb/src/animation/rough-animation.h deleted file mode 100644 index 102cd33..0000000 --- a/rhubarb/src/animation/rough-animation.h +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once - -#include "shape-rule.h" - -// Does a rough animation (no tweening, special pause animation, etc.) using a bidirectional -// algorithm. -JoiningContinuousTimeline animateRough(const ContinuousTimeline& shapeRules); diff --git a/rhubarb/src/animation/shape-rule.cpp b/rhubarb/src/animation/shape-rule.cppm similarity index 62% rename from rhubarb/src/animation/shape-rule.cpp rename to rhubarb/src/animation/shape-rule.cppm index d93ab8c..c814c23 100644 --- a/rhubarb/src/animation/shape-rule.cpp +++ b/rhubarb/src/animation/shape-rule.cppm @@ -1,9 +1,16 @@ -#include "shape-rule.h" +module; #include -#include +#include "core/phone.h" +#include "core/shape.h" +#include "time/bounded-timeline.h" #include "time/continuous-timeline.h" +#include "time/time-range.h" + +export module rhubarb.animation:shape_rule; + +import :animation_rules; using boost::optional; using boost::adaptors::transformed; @@ -21,30 +28,37 @@ ContinuousTimeline, AutoJoin> boundedTimelinetoContinuousOptional( }; } -ShapeRule::ShapeRule(ShapeSet shapeSet, optional phone, TimeRange phoneTiming) : - shapeSet(std::move(shapeSet)), - phone(std::move(phone)), - phoneTiming(phoneTiming) {} +export struct ShapeRule { + ShapeSet shapeSet; + optional phone; + TimeRange phoneTiming; -ShapeRule ShapeRule::getInvalid() { - return {{}, boost::none, {0_cs, 0_cs}}; -} + ShapeRule(ShapeSet shapeSet, optional phone, TimeRange phoneTiming) : + shapeSet(std::move(shapeSet)), + phone(std::move(phone)), + phoneTiming(phoneTiming) {} -bool ShapeRule::operator==(const ShapeRule& rhs) const { - return shapeSet == rhs.shapeSet && phone == rhs.phone && phoneTiming == rhs.phoneTiming; -} + static ShapeRule getInvalid() { + return {{}, boost::none, {0_cs, 0_cs}}; + } -bool ShapeRule::operator!=(const ShapeRule& rhs) const { - return !operator==(rhs); -} + bool operator==(const ShapeRule& rhs) const { + return shapeSet == rhs.shapeSet && phone == rhs.phone && phoneTiming == rhs.phoneTiming; + } -bool ShapeRule::operator<(const ShapeRule& rhs) const { - return shapeSet < rhs.shapeSet - || phone < rhs.phone - || phoneTiming.getStart() < rhs.phoneTiming.getStart() - || phoneTiming.getEnd() < rhs.phoneTiming.getEnd(); -} + bool operator!=(const ShapeRule& rhs) const { + return !operator==(rhs); + } + bool operator<(const ShapeRule& rhs) const { + return shapeSet < rhs.shapeSet + || phone < rhs.phone + || phoneTiming.getStart() < rhs.phoneTiming.getStart() + || phoneTiming.getEnd() < rhs.phoneTiming.getEnd(); + } +}; + +// Returns shape rules for an entire timeline of phones. ContinuousTimeline getShapeRules(const BoundedTimeline& phones) { // Convert to continuous timeline so that silences aren't skipped when iterating auto continuousPhones = boundedTimelinetoContinuousOptional(phones); diff --git a/rhubarb/src/animation/shape-rule.h b/rhubarb/src/animation/shape-rule.h deleted file mode 100644 index 470916f..0000000 --- a/rhubarb/src/animation/shape-rule.h +++ /dev/null @@ -1,24 +0,0 @@ -#pragma once - -#include "animation-rules.h" -#include "core/phone.h" -#include "time/bounded-timeline.h" -#include "time/continuous-timeline.h" -#include "time/time-range.h" - -struct ShapeRule { - ShapeSet shapeSet; - boost::optional phone; - TimeRange phoneTiming; - - ShapeRule(ShapeSet shapeSet, boost::optional phone, TimeRange phoneTiming); - - static ShapeRule getInvalid(); - - bool operator==(const ShapeRule&) const; - bool operator!=(const ShapeRule&) const; - bool operator<(const ShapeRule&) const; -}; - -// Returns shape rules for an entire timeline of phones. -ContinuousTimeline getShapeRules(const BoundedTimeline& phones); diff --git a/rhubarb/src/animation/shape-shorthands.cppm b/rhubarb/src/animation/shape-shorthands.cppm new file mode 100644 index 0000000..ce84a77 --- /dev/null +++ b/rhubarb/src/animation/shape-shorthands.cppm @@ -0,0 +1,15 @@ +module; + +#include "core/shape.h" + +export module rhubarb.animation:shape_shorthands; + +export constexpr Shape B = Shape::B; +export constexpr Shape A = Shape::A; +export constexpr Shape C = Shape::C; +export constexpr Shape D = Shape::D; +export constexpr Shape E = Shape::E; +export constexpr Shape F = Shape::F; +export constexpr Shape G = Shape::G; +export constexpr Shape H = Shape::H; +export constexpr Shape X = Shape::X; diff --git a/rhubarb/src/animation/static-segments.cpp b/rhubarb/src/animation/static-segments.cppm similarity index 92% rename from rhubarb/src/animation/static-segments.cpp rename to rhubarb/src/animation/static-segments.cppm index 784ce91..c9be947 100644 --- a/rhubarb/src/animation/static-segments.cpp +++ b/rhubarb/src/animation/static-segments.cppm @@ -1,12 +1,23 @@ -#include "static-segments.h" +module; +#include #include #include +#include "core/phone.h" +#include "core/shape.h" +#include "time/continuous-timeline.h" #include "tools/next-combination.h" +export module rhubarb.animation:static_segments; + +import :shape_rule; + using std::vector; +export using AnimationFunction = + std::function(const ContinuousTimeline&)>; + int getSyllableCount(const ContinuousTimeline& shapeRules, TimeRange timeRange) { if (timeRange.empty()) return 0; @@ -210,7 +221,13 @@ TimeRange extendToFixedRules( return {first->getStart(), last->getEnd()}; } -JoiningContinuousTimeline avoidStaticSegments( +// Calls the specified animation function with the specified shape rules. +// If the resulting animation contains long static segments, the shape rules are tweaked and +// animated again. +// Static segments happen rather often. +// See +// http://animateducated.blogspot.de/2016/10/lip-sync-animation-2.html?showComment=1478861729702#c2940729096183546458. +export JoiningContinuousTimeline avoidStaticSegments( const ContinuousTimeline& shapeRules, const AnimationFunction& animate ) { const auto animation = animate(shapeRules); diff --git a/rhubarb/src/animation/static-segments.h b/rhubarb/src/animation/static-segments.h deleted file mode 100644 index 864f53e..0000000 --- a/rhubarb/src/animation/static-segments.h +++ /dev/null @@ -1,20 +0,0 @@ -#pragma once - -#include - -#include "core/shape.h" -#include "shape-rule.h" -#include "time/continuous-timeline.h" - -using AnimationFunction = - std::function(const ContinuousTimeline&)>; - -// Calls the specified animation function with the specified shape rules. -// If the resulting animation contains long static segments, the shape rules are tweaked and -// animated again. -// Static segments happen rather often. -// See -// http://animateducated.blogspot.de/2016/10/lip-sync-animation-2.html?showComment=1478861729702#c2940729096183546458. -JoiningContinuousTimeline avoidStaticSegments( - const ContinuousTimeline& shapeRules, const AnimationFunction& animate -); diff --git a/rhubarb/src/animation/target-shape-set.cpp b/rhubarb/src/animation/target-shape-set.cppm similarity index 60% rename from rhubarb/src/animation/target-shape-set.cpp rename to rhubarb/src/animation/target-shape-set.cppm index 37d12d0..eb340ee 100644 --- a/rhubarb/src/animation/target-shape-set.cpp +++ b/rhubarb/src/animation/target-shape-set.cppm @@ -1,6 +1,14 @@ -#include "target-shape-set.h" +module; -Shape convertToTargetShapeSet(Shape shape, const ShapeSet& targetShapeSet) { +#include "core/shape.h" +#include "time/continuous-timeline.h" + +export module rhubarb.animation:target_shape_set; + +import :shape_rule; + +// Returns the closest shape to the specified one that occurs in the target shape set. +export Shape convertToTargetShapeSet(Shape shape, const ShapeSet& targetShapeSet) { if (targetShapeSet.find(shape) != targetShapeSet.end()) { return shape; } @@ -13,7 +21,9 @@ Shape convertToTargetShapeSet(Shape shape, const ShapeSet& targetShapeSet) { return basicShape; } -ShapeSet convertToTargetShapeSet(const ShapeSet& shapes, const ShapeSet& targetShapeSet) { +// Replaces each shape in the specified set with the closest shape that occurs in the target shape +// set. +export ShapeSet convertToTargetShapeSet(const ShapeSet& shapes, const ShapeSet& targetShapeSet) { ShapeSet result; for (Shape shape : shapes) { result.insert(convertToTargetShapeSet(shape, targetShapeSet)); @@ -21,7 +31,8 @@ ShapeSet convertToTargetShapeSet(const ShapeSet& shapes, const ShapeSet& targetS return result; } -ContinuousTimeline convertToTargetShapeSet( +// Replaces each shape in each rule with the closest shape that occurs in the target shape set. +export ContinuousTimeline convertToTargetShapeSet( const ContinuousTimeline& shapeRules, const ShapeSet& targetShapeSet ) { ContinuousTimeline result(shapeRules); @@ -33,7 +44,9 @@ ContinuousTimeline convertToTargetShapeSet( return result; } -JoiningContinuousTimeline convertToTargetShapeSet( +// Replaces each shape in the specified animation with the closest shape that occurs in the target +// shape set. +export JoiningContinuousTimeline convertToTargetShapeSet( const JoiningContinuousTimeline& animation, const ShapeSet& targetShapeSet ) { JoiningContinuousTimeline result(animation); diff --git a/rhubarb/src/animation/target-shape-set.h b/rhubarb/src/animation/target-shape-set.h deleted file mode 100644 index 2fbc413..0000000 --- a/rhubarb/src/animation/target-shape-set.h +++ /dev/null @@ -1,22 +0,0 @@ -#pragma once - -#include "core/shape.h" -#include "shape-rule.h" - -// Returns the closest shape to the specified one that occurs in the target shape set. -Shape convertToTargetShapeSet(Shape shape, const ShapeSet& targetShapeSet); - -// Replaces each shape in the specified set with the closest shape that occurs in the target shape -// set. -ShapeSet convertToTargetShapeSet(const ShapeSet& shapes, const ShapeSet& targetShapeSet); - -// Replaces each shape in each rule with the closest shape that occurs in the target shape set. -ContinuousTimeline convertToTargetShapeSet( - const ContinuousTimeline& shapeRules, const ShapeSet& targetShapeSet -); - -// Replaces each shape in the specified animation with the closest shape that occurs in the target -// shape set. -JoiningContinuousTimeline convertToTargetShapeSet( - const JoiningContinuousTimeline& animation, const ShapeSet& targetShapeSet -); diff --git a/rhubarb/src/animation/timing-optimization.cpp b/rhubarb/src/animation/timing-optimization.cppm similarity index 96% rename from rhubarb/src/animation/timing-optimization.cpp rename to rhubarb/src/animation/timing-optimization.cppm index 46a4bec..227fa4c 100644 --- a/rhubarb/src/animation/timing-optimization.cpp +++ b/rhubarb/src/animation/timing-optimization.cppm @@ -1,12 +1,17 @@ -#include "timing-optimization.h" +module; #include #include #include -#include "shape-rule.h" +#include "core/shape.h" +#include "time/continuous-timeline.h" #include "time/timed-logging.h" +export module rhubarb.animation:timing_optimization; + +import :shape_rule; + using std::map; using std::string; @@ -177,7 +182,12 @@ JoiningContinuousTimeline retime( enum class MouthState { Idle, Closed, Open }; -JoiningContinuousTimeline optimizeTiming(const JoiningContinuousTimeline& animation) { +// Changes the timing of an existing animation to reduce jitter and to make sure all shapes register +// visually. +// In some cases, shapes may be omitted. +export JoiningContinuousTimeline optimizeTiming( + const JoiningContinuousTimeline& animation +) { // Identify segments with idle, closed, and open mouth shapes JoiningContinuousTimeline segments(animation.getRange(), MouthState::Idle); for (const auto& timedShape : animation) { diff --git a/rhubarb/src/animation/timing-optimization.h b/rhubarb/src/animation/timing-optimization.h deleted file mode 100644 index 9fb654c..0000000 --- a/rhubarb/src/animation/timing-optimization.h +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once - -#include "core/shape.h" -#include "time/continuous-timeline.h" - -// Changes the timing of an existing animation to reduce jitter and to make sure all shapes register -// visually. -// In some cases, shapes may be omitted. -JoiningContinuousTimeline optimizeTiming(const JoiningContinuousTimeline& animation); diff --git a/rhubarb/src/animation/tweening.cpp b/rhubarb/src/animation/tweening.cppm similarity index 85% rename from rhubarb/src/animation/tweening.cpp rename to rhubarb/src/animation/tweening.cppm index c6efa4b..15fcca8 100644 --- a/rhubarb/src/animation/tweening.cpp +++ b/rhubarb/src/animation/tweening.cppm @@ -1,8 +1,16 @@ -#include "tweening.h" +module; -#include "animation-rules.h" +#include "core/shape.h" +#include "time/continuous-timeline.h" -JoiningContinuousTimeline insertTweens(const JoiningContinuousTimeline& animation) { +export module rhubarb.animation:tweening; + +import :animation_rules; + +// Takes an existing animation and inserts inbetween shapes for smoother results. +export JoiningContinuousTimeline insertTweens( + const JoiningContinuousTimeline& animation +) { const centiseconds minTweenDuration = 4_cs; const centiseconds maxTweenDuration = 8_cs; diff --git a/rhubarb/src/animation/tweening.h b/rhubarb/src/animation/tweening.h deleted file mode 100644 index d0e1f37..0000000 --- a/rhubarb/src/animation/tweening.h +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once - -#include "core/shape.h" -#include "time/continuous-timeline.h" - -// Takes an existing animation and inserts inbetween shapes for smoother results. -JoiningContinuousTimeline insertTweens(const JoiningContinuousTimeline& animation); diff --git a/rhubarb/src/exporters/dat-exporter.cpp b/rhubarb/src/exporters/dat-exporter.cpp index f73a813..1dd71c8 100644 --- a/rhubarb/src/exporters/dat-exporter.cpp +++ b/rhubarb/src/exporters/dat-exporter.cpp @@ -2,7 +2,7 @@ #include -#include "animation/target-shape-set.h" +import rhubarb.animation; using std::string; using std::chrono::duration; diff --git a/rhubarb/src/exporters/exporter-tools.cpp b/rhubarb/src/exporters/exporter-tools.cpp index ade4926..1f331a2 100644 --- a/rhubarb/src/exporters/exporter-tools.cpp +++ b/rhubarb/src/exporters/exporter-tools.cpp @@ -1,6 +1,6 @@ #include "exporter-tools.h" -#include "animation/target-shape-set.h" +import rhubarb.animation; // Makes sure there is at least one mouth shape std::vector> dummyShapeIfEmpty( diff --git a/rhubarb/src/exporters/tsv-exporter.cpp b/rhubarb/src/exporters/tsv-exporter.cpp index 50d92bd..9c3b872 100644 --- a/rhubarb/src/exporters/tsv-exporter.cpp +++ b/rhubarb/src/exporters/tsv-exporter.cpp @@ -1,6 +1,6 @@ #include "tsv-exporter.h" -#include "animation/target-shape-set.h" +import rhubarb.animation; void TsvExporter::exportAnimation(const ExporterInput& input, std::ostream& outputStream) { // Output shapes with start times diff --git a/rhubarb/src/lib/rhubarb-lib.cpp b/rhubarb/src/lib/rhubarb-lib.cpp index 01ff8fd..d62940c 100644 --- a/rhubarb/src/lib/rhubarb-lib.cpp +++ b/rhubarb/src/lib/rhubarb-lib.cpp @@ -1,9 +1,8 @@ #include "rhubarb-lib.h" -#include "animation/mouth-animation.h" #include "audio/audio-file-reading.h" -#include "core/phone.h" -#include "tools/text-files.h" + +import rhubarb.animation; using boost::optional; using std::string; diff --git a/rhubarb/src/lib/rhubarb-lib.h b/rhubarb/src/lib/rhubarb-lib.h index c94ff99..681a3ea 100644 --- a/rhubarb/src/lib/rhubarb-lib.h +++ b/rhubarb/src/lib/rhubarb-lib.h @@ -2,7 +2,6 @@ #include -#include "animation/target-shape-set.h" #include "audio/audio-clip.h" #include "core/shape.h" #include "recognition/recognizer.h" diff --git a/rhubarb/src/rhubarb/main.cpp b/rhubarb/src/rhubarb/main.cpp index 22a33fe..a5de940 100644 --- a/rhubarb/src/rhubarb/main.cpp +++ b/rhubarb/src/rhubarb/main.cpp @@ -7,7 +7,6 @@ #include #include -#include "animation/target-shape-set.h" #include "core/app-info.h" #include "export-format.h" #include "exporters/dat-exporter.h" diff --git a/rhubarb/src/time/bounded-timeline.h b/rhubarb/src/time/bounded-timeline.h index d830605..1e8b4fd 100644 --- a/rhubarb/src/time/bounded-timeline.h +++ b/rhubarb/src/time/bounded-timeline.h @@ -2,6 +2,15 @@ #include "timeline.h" +// FIXME: Remove this workaround once we're using modules exclusively +inline centiseconds _min(centiseconds a, centiseconds b) { + return a < b ? a : b; +} + +inline centiseconds _max(centiseconds a, centiseconds b) { + return a > b ? a : b; +} + template class BoundedTimeline : public Timeline { using typename Timeline::time_type; @@ -48,7 +57,7 @@ public: // Clip the value's range to bounds TimeRange& valueRange = timedValue.getTimeRange(); valueRange.resize( - max(range.getStart(), valueRange.getStart()), min(range.getEnd(), valueRange.getEnd()) + _max(range.getStart(), valueRange.getStart()), _min(range.getEnd(), valueRange.getEnd()) ); return Timeline::set(timedValue); diff --git a/rhubarb/src/time/timeline.h b/rhubarb/src/time/timeline.h index fa2fb7e..9f29f6d 100644 --- a/rhubarb/src/time/timeline.h +++ b/rhubarb/src/time/timeline.h @@ -3,9 +3,15 @@ #include #include +#include "centiseconds.h" #include "timed.h" #include "tools/tools.h" +using std::chrono::operator<; +using std::chrono::operator>; +using std::chrono::operator>=; +using std::chrono::operator<=; + enum class FindMode { SampleLeft, SampleRight, SearchLeft, SearchRight }; namespace internal {