From c058dd1371028638afdfcba3cdabd25b8ec4ad35 Mon Sep 17 00:00:00 2001 From: Helge Norberg Date: Mon, 13 Feb 2017 16:16:18 +0100 Subject: [PATCH] [scene_producer] Added scene_width and scene_height variables that can be used from expressions --- core/producer/scene/scene.xsd | 5 +++-- core/producer/scene/scene_producer.cpp | 8 +++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/core/producer/scene/scene.xsd b/core/producer/scene/scene.xsd index ea0f78151..b6008fafe 100644 --- a/core/producer/scene/scene.xsd +++ b/core/producer/scene/scene.xsd @@ -10,8 +10,9 @@ Public variables are accessible as CG parameters and by the parent scene when nested inside another. There are some variables that are always defined like "frame" which stores the number of frames that have gone by since the scene producer started, - "mouse_x" and "mouse_y" which reflect the X and Y position of the mouse at all times relative to the scene coordinate system (requires interaction aware consumer like screen_consumer) and - "timeline_frame" which differs from "frame" in that it can rewind and jump, depending on where the timeline is at the moment. + "mouse_x" and "mouse_y" which reflect the X and Y position of the mouse at all times relative to the scene coordinate system (requires interaction aware consumer like screen_consumer), + "timeline_frame" which differs from "frame" in that it can rewind and jump, depending on where the timeline is at the moment and + "scene_width" and "scene_height" which contains the dimensions of the scene coordinate system. diff --git a/core/producer/scene/scene_producer.cpp b/core/producer/scene/scene_producer.cpp index f5f2a625e..935fb577a 100644 --- a/core/producer/scene/scene_producer.cpp +++ b/core/producer/scene/scene_producer.cpp @@ -142,7 +142,6 @@ struct scene_producer::impl impl(std::wstring producer_name, int width, int height, const video_format_desc& format_desc) : producer_name_(std::move(producer_name)) - , pixel_constraints_(width, height) , format_desc_(format_desc) , aggregator_([=] (double x, double y) { return collission_detect(x, y); }) { @@ -166,6 +165,13 @@ struct scene_producer::impl mouse_y_ = mouse_y_variable->value(); m_x_ = 0; m_y_ = 0; + + auto scene_width = std::make_shared>(boost::lexical_cast(width), false, width); + auto scene_height = std::make_shared>(boost::lexical_cast(height), false, height); + store_variable(L"scene_width", scene_width); + store_variable(L"scene_height", scene_height); + pixel_constraints_.width = scene_width->value(); + pixel_constraints_.height = scene_height->value(); } layer& create_layer( -- 2.39.2