From 3278113954205d82eb6d5b0f10ddae852e72444f Mon Sep 17 00:00:00 2001 From: Helge Norberg Date: Wed, 23 Dec 2015 00:19:38 +0100 Subject: [PATCH] mouse hover position exposed as mouse_x and mouse_y variable in scene_producers for rudimental interaction support. --- core/producer/scene/scene_producer.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/core/producer/scene/scene_producer.cpp b/core/producer/scene/scene_producer.cpp index b684f372a..84161ad1c 100644 --- a/core/producer/scene/scene_producer.cpp +++ b/core/producer/scene/scene_producer.cpp @@ -125,6 +125,10 @@ struct scene_producer::impl interaction_aggregator aggregator_; binding frame_number_; binding speed_; + mutable tbb::atomic m_x_; + mutable tbb::atomic m_y_; + binding mouse_x_; + binding mouse_y_; double frame_fraction_ = 0.0; std::map timelines_; std::map> variables_; @@ -144,9 +148,19 @@ struct scene_producer::impl auto speed_variable = std::make_shared>(L"1.0", true, 1.0); store_variable(L"scene_speed", speed_variable); speed_ = speed_variable->value(); + auto frame_variable = std::make_shared>(L"-1", true, -1); store_variable(L"frame", frame_variable); frame_number_ = 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); + store_variable(L"mouse_y", mouse_y_variable); + mouse_x_ = mouse_x_variable->value(); + mouse_y_ = mouse_y_variable->value(); + m_x_ = 0; + m_y_ = 0; } layer& create_layer( @@ -357,6 +371,9 @@ struct scene_producer::impl for (auto& timeline : timelines_) timeline.second.on_frame(frame_number_.get()); + mouse_x_.set(m_x_); + mouse_y_.set(m_y_); + std::vector frames; for (auto& layer : layers_) @@ -379,6 +396,9 @@ struct scene_producer::impl bool collides(double x, double y) const { + m_x_ = static_cast(x * pixel_constraints_.width.get()); + m_y_ = static_cast(y * pixel_constraints_.height.get()); + return static_cast((collission_detect(x, y))); } -- 2.39.2