moved gizmo discovery to distinct function outside of renderfunctions

This commit is contained in:
itsmattkc
2019-03-02 10:30:50 -08:00
parent f19eded768
commit 2e400c7c55
7 changed files with 60 additions and 27 deletions
+41
View File
@@ -113,6 +113,47 @@ QVector<int> Sequence::SelectedClipIndexes()
return selected_clips; return selected_clips;
} }
Effect *Sequence::GetSelectedGizmo()
{
Effect* gizmo_ptr = nullptr;
for (int i=0;i<clips.size();i++) {
Clip* c = clips.at(i).get();
if (c != nullptr
&& c->IsActiveAt(playhead)
&& IsClipSelected(c, true)) {
// This clip is selected and currently active - we'll use this for gizmos
if (!c->effects.isEmpty()) {
// find which effect has gizmos selected, or default to the first gizmo effect we find if there is
// none selected
for (int j=0;j<c->effects.size();j++) {
Effect* e = c->effects.at(j).get();
// retrieve gizmo data from effect
if (e->are_gizmos_enabled()) {
if (gizmo_ptr == nullptr) {
gizmo_ptr = e;
}
if (e->container->selected) {
gizmo_ptr = e;
break;
}
}
}
}
if (gizmo_ptr != nullptr) {
break;
}
}
}
return gizmo_ptr;
}
bool Sequence::IsClipSelected(int clip_index, bool containing) bool Sequence::IsClipSelected(int clip_index, bool containing)
{ {
return IsClipSelected(clips.at(clip_index).get(), containing); return IsClipSelected(clips.at(clip_index).get(), containing);
+2
View File
@@ -47,6 +47,8 @@ public:
QVector<Clip*> SelectedClips(); QVector<Clip*> SelectedClips();
QVector<int> SelectedClipIndexes(); QVector<int> SelectedClipIndexes();
Effect* GetSelectedGizmo();
bool IsClipSelected(int clip_index, bool containing); bool IsClipSelected(int clip_index, bool containing);
bool IsClipSelected(Clip* clip, bool containing); bool IsClipSelected(Clip* clip, bool containing);
+9 -19
View File
@@ -107,7 +107,7 @@ GLuint draw_clip(QOpenGLFramebufferObject* fbo, GLuint texture, bool clear) {
} }
void process_effect(Clip* c, void process_effect(Clip* c,
EffectPtr e, Effect* e,
double timecode, double timecode,
GLTextureCoords& coords, GLTextureCoords& coords,
GLuint& composite_texture, GLuint& composite_texture,
@@ -415,34 +415,22 @@ GLuint compose_sequence(ComposeSequenceParams &params) {
// get current sequence time in seconds (used for effects) // get current sequence time in seconds (used for effects)
double timecode = get_timecode(c, playhead); double timecode = get_timecode(c, playhead);
// set up variables for gizmos later
EffectPtr first_gizmo_effect = nullptr;
EffectPtr selected_effect = nullptr;
// run through all of the clip's effects // run through all of the clip's effects
for (int j=0;j<c->effects.size();j++) { for (int j=0;j<c->effects.size();j++) {
EffectPtr e = c->effects.at(j); Effect* e = c->effects.at(j).get();
process_effect(c, e, timecode, coords, textureID, fbo_switcher, params.texture_failed, kTransitionNone); process_effect(c, e, timecode, coords, textureID, fbo_switcher, params.texture_failed, kTransitionNone);
// retrieve gizmo data from effect if (e == params.gizmos) {
if (e->are_gizmos_enabled()) { e->gizmo_draw(timecode, coords); // set correct gizmo coords
if (first_gizmo_effect == nullptr) first_gizmo_effect = e; e->gizmo_world_to_screen(); // convert gizmo coords to screen coords
if (e->container->selected) selected_effect = e;
} }
} }
// using gizmo data, set definitive gizmo
if (selected_effect != nullptr) {
(*params.gizmos) = selected_effect;
} else if (s->IsClipSelected(c, true)) {
(*params.gizmos) = first_gizmo_effect;
}
// if the clip has an opening transition, process that now // if the clip has an opening transition, process that now
if (c->opening_transition != nullptr) { if (c->opening_transition != nullptr) {
int transition_progress = playhead - c->timeline_in(true); int transition_progress = playhead - c->timeline_in(true);
if (transition_progress < c->opening_transition->get_length()) { if (transition_progress < c->opening_transition->get_length()) {
process_effect(c, c->opening_transition, double(transition_progress)/double(c->opening_transition->get_length()), coords, textureID, fbo_switcher, params.texture_failed, kTransitionOpening); process_effect(c, c->opening_transition.get(), double(transition_progress)/double(c->opening_transition->get_length()), coords, textureID, fbo_switcher, params.texture_failed, kTransitionOpening);
} }
} }
@@ -450,7 +438,7 @@ GLuint compose_sequence(ComposeSequenceParams &params) {
if (c->closing_transition != nullptr) { if (c->closing_transition != nullptr) {
int transition_progress = playhead - (c->timeline_out(true) - c->closing_transition->get_length()); int transition_progress = playhead - (c->timeline_out(true) - c->closing_transition->get_length());
if (transition_progress >= 0 && transition_progress < c->closing_transition->get_length()) { if (transition_progress >= 0 && transition_progress < c->closing_transition->get_length()) {
process_effect(c, c->closing_transition, double(transition_progress)/double(c->closing_transition->get_length()), coords, textureID, fbo_switcher, params.texture_failed, kTransitionClosing); process_effect(c, c->closing_transition.get(), double(transition_progress)/double(c->closing_transition->get_length()), coords, textureID, fbo_switcher, params.texture_failed, kTransitionClosing);
} }
} }
@@ -596,6 +584,7 @@ GLuint compose_sequence(ComposeSequenceParams &params) {
} }
// prepare gizmos // prepare gizmos
/*
if ((*params.gizmos) != nullptr if ((*params.gizmos) != nullptr
&& params.nests.isEmpty() && params.nests.isEmpty()
&& ((*params.gizmos) == first_gizmo_effect && ((*params.gizmos) == first_gizmo_effect
@@ -603,6 +592,7 @@ GLuint compose_sequence(ComposeSequenceParams &params) {
(*params.gizmos)->gizmo_draw(timecode, coords); // set correct gizmo coords (*params.gizmos)->gizmo_draw(timecode, coords); // set correct gizmo coords
(*params.gizmos)->gizmo_world_to_screen(); // convert gizmo coords to screen coords (*params.gizmos)->gizmo_world_to_screen(); // convert gizmo coords to screen coords
} }
*/
glPopMatrix(); glPopMatrix();
} }
+2 -3
View File
@@ -79,10 +79,9 @@ struct ComposeSequenceParams {
/** /**
* @brief Set to the Effect whose gizmos were chosen to be drawn on screen * @brief Set to the Effect whose gizmos were chosen to be drawn on screen
* *
* A pointer to a pointer that will be set to the Effect whose gizmos are being rendered and should therefore * The currently active Effect that compose_sequence() will update the gizmos of.
* be interacted with if the user uses them.
*/ */
EffectPtr* gizmos; Effect* gizmos;
/** /**
* @brief A variable that compose_sequence() will set to **TRUE** if any of the clips couldn't be shown. * @brief A variable that compose_sequence() will set to **TRUE** if any of the clips couldn't be shown.
+4 -3
View File
@@ -192,7 +192,6 @@ void RenderThread::paint() {
params.seq = seq; params.seq = seq;
params.video = true; params.video = true;
params.texture_failed = false; params.texture_failed = false;
params.gizmos = &gizmos;
params.wait_for_mutexes = true; params.wait_for_mutexes = true;
params.playback_speed = 1; params.playback_speed = 1;
params.blend_mode_program = blend_mode_program; params.blend_mode_program = blend_mode_program;
@@ -204,6 +203,10 @@ void RenderThread::paint() {
params.main_buffer = front_buffer_switcher ? front_buffer1 : front_buffer2; params.main_buffer = front_buffer_switcher ? front_buffer1 : front_buffer2;
params.main_attachment = front_buffer_switcher ? front_texture1 : front_texture2; params.main_attachment = front_buffer_switcher ? front_texture1 : front_texture2;
// get currently selected gizmos
gizmos = seq->GetSelectedGizmo();
params.gizmos = gizmos;
QMutex& active_mutex = front_buffer_switcher ? front_mutex1 : front_mutex2; QMutex& active_mutex = front_buffer_switcher ? front_mutex1 : front_mutex2;
active_mutex.lock(); active_mutex.lock();
@@ -221,8 +224,6 @@ void RenderThread::paint() {
glEnable(GL_BLEND); glEnable(GL_BLEND);
glEnable(GL_DEPTH); glEnable(GL_DEPTH);
gizmos = nullptr;
compose_sequence(params); compose_sequence(params);
// flush changes // flush changes
+1 -1
View File
@@ -48,7 +48,7 @@ public:
QMutex* get_texture_mutex(); QMutex* get_texture_mutex();
const GLuint& get_texture(); const GLuint& get_texture();
EffectPtr gizmos; Effect* gizmos;
void paint(); void paint();
void start_render(QOpenGLContext* share, void start_render(QOpenGLContext* share,
SequencePtr s, SequencePtr s,
+1 -1
View File
@@ -81,7 +81,7 @@ private:
void move_gizmos(QMouseEvent *event, bool done); void move_gizmos(QMouseEvent *event, bool done);
bool dragging; bool dragging;
void seek_from_click(int x); void seek_from_click(int x);
EffectPtr gizmos; Effect* gizmos;
int drag_start_x; int drag_start_x;
int drag_start_y; int drag_start_y;
int gizmo_x_mvmt; int gizmo_x_mvmt;