mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-17 13:19:59 +01:00
BugFix Update linked sources and Texture view on Source change
When source change stream (e.g. change pattern), Texture view was not updated, and sources with mask texture were not adapted.
This commit is contained in:
@@ -1471,6 +1471,8 @@ void ImGuiVisitor::visit (PatternSource& s)
|
|||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
oss << s.name() << ": Pattern " << Pattern::get(p).label;
|
oss << s.name() << ": Pattern " << Pattern::get(p).label;
|
||||||
Action::manager().store(oss.str());
|
Action::manager().store(oss.str());
|
||||||
|
// ensure all sources are updated after the texture change of this one
|
||||||
|
Mixer::manager().session()->execute([](Source *so) { so->touch(Source::SourceUpdate_Mask); });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ImGui::EndCombo();
|
ImGui::EndCombo();
|
||||||
@@ -1527,6 +1529,8 @@ void ImGuiVisitor::visit (DeviceSource& s)
|
|||||||
oss << s.name() << " Device " << namedev;
|
oss << s.name() << " Device " << namedev;
|
||||||
Action::manager().store(oss.str());
|
Action::manager().store(oss.str());
|
||||||
}
|
}
|
||||||
|
// ensure all sources are updated after the texture change of this one
|
||||||
|
Mixer::manager().session()->execute([](Source *so) { so->touch(Source::SourceUpdate_Mask); });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ImGui::EndCombo();
|
ImGui::EndCombo();
|
||||||
@@ -1594,6 +1598,8 @@ void ImGuiVisitor::visit (ScreenCaptureSource& s)
|
|||||||
oss << s.name() << " Window " << namedev;
|
oss << s.name() << " Window " << namedev;
|
||||||
Action::manager().store(oss.str());
|
Action::manager().store(oss.str());
|
||||||
}
|
}
|
||||||
|
// ensure all sources are updated after the texture change of this one
|
||||||
|
Mixer::manager().session()->execute([](Source *so) { so->touch(Source::SourceUpdate_Mask); });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ImGui::EndCombo();
|
ImGui::EndCombo();
|
||||||
@@ -1778,11 +1784,7 @@ void ImGuiVisitor::visit (GenericStreamSource& s)
|
|||||||
|
|
||||||
// Editor
|
// Editor
|
||||||
std::string _description = s.description();
|
std::string _description = s.description();
|
||||||
if ( ImGuiToolkit::InputCodeMultiline("Pipeline", &_description, fieldsize, &numlines) ) {
|
bool changed = ImGuiToolkit::InputCodeMultiline("Pipeline", &_description, fieldsize, &numlines);
|
||||||
info.reset();
|
|
||||||
s.setDescription(_description);
|
|
||||||
Action::manager().store( s.name() + ": Change pipeline");
|
|
||||||
}
|
|
||||||
ImVec2 botom = ImGui::GetCursorPos();
|
ImVec2 botom = ImGui::GetCursorPos();
|
||||||
|
|
||||||
// Actions on the pipeline
|
// Actions on the pipeline
|
||||||
@@ -1792,9 +1794,15 @@ void ImGuiVisitor::visit (GenericStreamSource& s)
|
|||||||
ImGui::SetCursorPos( ImVec2(top.x + 0.9 * ImGui::GetFrameHeight(), botom.y - ImGui::GetFrameHeight()));
|
ImGui::SetCursorPos( ImVec2(top.x + 0.9 * ImGui::GetFrameHeight(), botom.y - ImGui::GetFrameHeight()));
|
||||||
if (ImGuiToolkit::IconButton(ICON_FA_PASTE, "Paste")) {
|
if (ImGuiToolkit::IconButton(ICON_FA_PASTE, "Paste")) {
|
||||||
_description = std::string ( ImGui::GetClipboardText() );
|
_description = std::string ( ImGui::GetClipboardText() );
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (changed) {
|
||||||
info.reset();
|
info.reset();
|
||||||
s.setDescription(_description);
|
s.setDescription(_description);
|
||||||
Action::manager().store( s.name() + ": Change pipeline");
|
Action::manager().store( s.name() + ": Change pipeline");
|
||||||
|
// ensure all sources are updated after the texture change of this one
|
||||||
|
Mixer::manager().session()->execute([](Source *so) { so->touch(Source::SourceUpdate_Mask); });
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !s.failed() ) {
|
if ( !s.failed() ) {
|
||||||
|
|||||||
@@ -1005,3 +1005,11 @@ void Session::applySnapshot(uint64_t key)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Session::execute(void (*func)(Source *))
|
||||||
|
{
|
||||||
|
for (SourceList::const_iterator it = sources_.cbegin(); it != sources_.cend(); ++it) {
|
||||||
|
func(*it);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@@ -72,19 +72,18 @@ public:
|
|||||||
// management of list of sources
|
// management of list of sources
|
||||||
bool empty() const;
|
bool empty() const;
|
||||||
uint size() const;
|
uint size() const;
|
||||||
|
SourceList getDepthSortedList () const;
|
||||||
|
SourceIdList getIdList() const;
|
||||||
|
std::list<std::string> getNameList(uint64_t exceptid=0) const;
|
||||||
SourceList::iterator begin ();
|
SourceList::iterator begin ();
|
||||||
SourceList::iterator end ();
|
SourceList::iterator end ();
|
||||||
SourceList::iterator find (Source *s);
|
SourceList::iterator find (Source *s);
|
||||||
SourceList::iterator find (std::string name);
|
SourceList::iterator find (std::string name);
|
||||||
SourceList::iterator find (Node *node);
|
SourceList::iterator find (Node *node);
|
||||||
SourceList::iterator find (float depth_from, float depth_to);
|
SourceList::iterator find (float depth_from, float depth_to);
|
||||||
SourceList getDepthSortedList () const;
|
|
||||||
|
|
||||||
SourceList::iterator find (uint64_t id);
|
SourceList::iterator find (uint64_t id);
|
||||||
SourceIdList getIdList() const;
|
|
||||||
|
|
||||||
std::list<std::string> getNameList(uint64_t exceptid=0) const;
|
|
||||||
|
|
||||||
|
// manage sources by #id (ordered index)
|
||||||
SourceList::iterator at (int index);
|
SourceList::iterator at (int index);
|
||||||
int index (SourceList::iterator it) const;
|
int index (SourceList::iterator it) const;
|
||||||
void move (int current_index, int target_index);
|
void move (int current_index, int target_index);
|
||||||
@@ -97,6 +96,8 @@ public:
|
|||||||
void update (float dt);
|
void update (float dt);
|
||||||
uint64_t runtime() const;
|
uint64_t runtime() const;
|
||||||
|
|
||||||
|
void execute(void (*func)(Source *));
|
||||||
|
|
||||||
// update mode (active or not)
|
// update mode (active or not)
|
||||||
void setActive (bool on);
|
void setActive (bool on);
|
||||||
inline bool active () { return active_; }
|
inline bool active () { return active_; }
|
||||||
|
|||||||
@@ -243,9 +243,10 @@ void TextureView::update(float dt)
|
|||||||
View::update(dt);
|
View::update(dt);
|
||||||
|
|
||||||
// a more complete update is requested (e.g. after switching to view)
|
// a more complete update is requested (e.g. after switching to view)
|
||||||
if (View::need_deep_update_ > 0 || edit_source_ != Mixer::manager().currentSource()) {
|
if (View::need_deep_update_ > 0 ||
|
||||||
|
(Mixer::manager().currentSource() != nullptr && edit_source_ != Mixer::manager().currentSource() )) {
|
||||||
|
// request update
|
||||||
need_edit_update_ = true;
|
need_edit_update_ = true;
|
||||||
|
|
||||||
// change grid color
|
// change grid color
|
||||||
const ImVec4 c = ImGuiToolkit::HighlightColor();
|
const ImVec4 c = ImGuiToolkit::HighlightColor();
|
||||||
translation_grid_->setColor( glm::vec4(c.x, c.y, c.z, 0.3) );
|
translation_grid_->setColor( glm::vec4(c.x, c.y, c.z, 0.3) );
|
||||||
@@ -505,8 +506,10 @@ std::pair<Node *, glm::vec2> TextureView::pick(glm::vec2 P)
|
|||||||
return pick;
|
return pick;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextureView::adjustBackground()
|
bool TextureView::adjustBackground()
|
||||||
{
|
{
|
||||||
|
bool ret = false;
|
||||||
|
|
||||||
// by default consider edit source is null
|
// by default consider edit source is null
|
||||||
mask_node_->visible_ = false;
|
mask_node_->visible_ = false;
|
||||||
float image_original_width = 1.f;
|
float image_original_width = 1.f;
|
||||||
@@ -515,7 +518,8 @@ void TextureView::adjustBackground()
|
|||||||
preview_surface_->setTextureIndex( Resource::getTextureTransparent() );
|
preview_surface_->setTextureIndex( Resource::getTextureTransparent() );
|
||||||
|
|
||||||
// if its a valid index
|
// if its a valid index
|
||||||
if (edit_source_ != nullptr && edit_source_->ready()) {
|
if (edit_source_ != nullptr) {
|
||||||
|
if (edit_source_->ready()) {
|
||||||
// update rendering frame to match edit source AR
|
// update rendering frame to match edit source AR
|
||||||
image_original_width = edit_source_->frame()->aspectRatio();
|
image_original_width = edit_source_->frame()->aspectRatio();
|
||||||
scale_crop_.x = (edit_source_->group(View::GEOMETRY)->crop_[1]
|
scale_crop_.x = (edit_source_->group(View::GEOMETRY)->crop_[1]
|
||||||
@@ -529,13 +533,14 @@ void TextureView::adjustBackground()
|
|||||||
scale_crop_.x *= edit_source_->frame()->aspectRatio();
|
scale_crop_.x *= edit_source_->frame()->aspectRatio();
|
||||||
shift_crop_.x *= edit_source_->frame()->aspectRatio();
|
shift_crop_.x *= edit_source_->frame()->aspectRatio();
|
||||||
|
|
||||||
preview_surface_->setTextureIndex( edit_source_->frame()->texture() );
|
preview_surface_->setTextureIndex(edit_source_->frame()->texture());
|
||||||
preview_shader_->mask_texture = edit_source_->blendingShader()->mask_texture;
|
preview_shader_->mask_texture = edit_source_->blendingShader()->mask_texture;
|
||||||
preview_surface_->scale_ = scale_crop_;
|
preview_surface_->scale_ = scale_crop_;
|
||||||
preview_surface_->translation_ = shift_crop_;
|
preview_surface_->translation_ = shift_crop_;
|
||||||
|
|
||||||
// mask appearance
|
// mask appearance
|
||||||
mask_node_->visible_ = edit_source_->maskShader()->mode == MaskShader::SHAPE && mask_cursor_shape_ > 0;
|
mask_node_->visible_ = edit_source_->maskShader()->mode == MaskShader::SHAPE
|
||||||
|
&& mask_cursor_shape_ > 0;
|
||||||
|
|
||||||
int shape = edit_source_->maskShader()->shape;
|
int shape = edit_source_->maskShader()->shape;
|
||||||
mask_circle_->visible_ = shape == MaskShader::ELLIPSE;
|
mask_circle_->visible_ = shape == MaskShader::ELLIPSE;
|
||||||
@@ -544,23 +549,31 @@ void TextureView::adjustBackground()
|
|||||||
mask_vertical_->visible_ = shape == MaskShader::VERTICAL;
|
mask_vertical_->visible_ = shape == MaskShader::VERTICAL;
|
||||||
|
|
||||||
// symetrical shapes
|
// symetrical shapes
|
||||||
if ( shape < MaskShader::HORIZONTAL){
|
if (shape < MaskShader::HORIZONTAL) {
|
||||||
mask_node_->scale_ = scale_crop_ * glm::vec3(edit_source_->maskShader()->size, 1.f);
|
mask_node_->scale_ = scale_crop_ * glm::vec3(edit_source_->maskShader()->size, 1.f);
|
||||||
mask_node_->translation_ = glm::vec3(0.f);
|
mask_node_->translation_ = glm::vec3(0.f);
|
||||||
}
|
}
|
||||||
// vertical
|
// vertical
|
||||||
else if ( shape > MaskShader::HORIZONTAL ) {
|
else if (shape > MaskShader::HORIZONTAL) {
|
||||||
mask_node_->scale_ = glm::vec3(1.f, scale_crop_.y, 1.f);
|
mask_node_->scale_ = glm::vec3(1.f, scale_crop_.y, 1.f);
|
||||||
mask_node_->translation_ = glm::vec3(edit_source_->maskShader()->size.x * scale_crop_.x, 0.f, 0.f);
|
mask_node_->translation_ = glm::vec3(edit_source_->maskShader()->size.x
|
||||||
|
* scale_crop_.x,
|
||||||
|
0.f,
|
||||||
|
0.f);
|
||||||
}
|
}
|
||||||
// horizontal
|
// horizontal
|
||||||
else {
|
else {
|
||||||
mask_node_->scale_ = glm::vec3(scale_crop_.x, 1.f, 1.f);
|
mask_node_->scale_ = glm::vec3(scale_crop_.x, 1.f, 1.f);
|
||||||
mask_node_->translation_ = glm::vec3(0.f, edit_source_->maskShader()->size.y * scale_crop_.y, 0.f);
|
mask_node_->translation_ = glm::vec3(0.f,
|
||||||
|
edit_source_->maskShader()->size.y
|
||||||
|
* scale_crop_.y,
|
||||||
|
0.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
mask_node_->translation_ += shift_crop_;
|
mask_node_->translation_ += shift_crop_;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ret = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// background scene
|
// background scene
|
||||||
@@ -576,6 +589,7 @@ void TextureView::adjustBackground()
|
|||||||
static glm::mat4 Tra = glm::scale(glm::translate(glm::identity<glm::mat4>(), glm::vec3( -32.f, -32.f, 0.f)), glm::vec3( 64.f, 64.f, 1.f));
|
static glm::mat4 Tra = glm::scale(glm::translate(glm::identity<glm::mat4>(), glm::vec3( -32.f, -32.f, 0.f)), glm::vec3( 64.f, 64.f, 1.f));
|
||||||
preview_checker_->shader()->iTransform = Ar * Tra;
|
preview_checker_->shader()->iTransform = Ar * Tra;
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
Source *TextureView::getEditOrCurrentSource()
|
Source *TextureView::getEditOrCurrentSource()
|
||||||
@@ -607,16 +621,14 @@ Source *TextureView::getEditOrCurrentSource()
|
|||||||
void TextureView::draw()
|
void TextureView::draw()
|
||||||
{
|
{
|
||||||
// edit view needs to be updated (source changed)
|
// edit view needs to be updated (source changed)
|
||||||
if ( need_edit_update_ )
|
if (need_edit_update_) {
|
||||||
{
|
|
||||||
need_edit_update_ = false;
|
|
||||||
|
|
||||||
// now, follow the change of current source
|
// now, follow the change of current source
|
||||||
// & remember source to edit
|
// & remember source to edit
|
||||||
edit_source_ = getEditOrCurrentSource();
|
edit_source_ = getEditOrCurrentSource();
|
||||||
|
|
||||||
// update background and frame to match editsource
|
// update background and frame to match editsource
|
||||||
adjustBackground();
|
// & return true if still needs to edit update
|
||||||
|
need_edit_update_ = adjustBackground();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Display grid
|
// Display grid
|
||||||
@@ -1121,9 +1133,8 @@ View::Cursor TextureView::grab (Source *s, glm::vec2 from, glm::vec2 to, std::pa
|
|||||||
edit_source_->maskShader()->size.x = val.x;
|
edit_source_->maskShader()->size.x = val.x;
|
||||||
else
|
else
|
||||||
edit_source_->maskShader()->size = glm::max(glm::abs(glm::vec2(val)), glm::vec2(0.2));
|
edit_source_->maskShader()->size = glm::max(glm::abs(glm::vec2(val)), glm::vec2(0.2));
|
||||||
// edit_source_->maskShader()->size = glm::max( glm::min( glm::vec2(val), glm::vec2(2.f)), glm::vec2(hv?-2.f:0.2f));
|
|
||||||
edit_source_->touch(Source::SourceUpdate_Mask);
|
|
||||||
// update
|
// update
|
||||||
|
edit_source_->touch(Source::SourceUpdate_Mask);
|
||||||
need_edit_update_ = true;
|
need_edit_update_ = true;
|
||||||
// action label
|
// action label
|
||||||
info << "Texture Mask " << std::fixed << std::setprecision(3) << edit_source_->maskShader()->size.x;
|
info << "Texture Mask " << std::fixed << std::setprecision(3) << edit_source_->maskShader()->size.x;
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ private:
|
|||||||
Source *edit_source_;
|
Source *edit_source_;
|
||||||
bool need_edit_update_;
|
bool need_edit_update_;
|
||||||
Source *getEditOrCurrentSource();
|
Source *getEditOrCurrentSource();
|
||||||
void adjustBackground();
|
bool adjustBackground();
|
||||||
glm::vec3 scale_crop_;
|
glm::vec3 scale_crop_;
|
||||||
glm::vec3 shift_crop_;
|
glm::vec3 shift_crop_;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user