fix action history with frames
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
void ActionStroke::undo()
|
||||
{
|
||||
if (clear_layer)
|
||||
m_canvas->m_layers[m_layer_idx]->clear({ 0, 0, 0, 0 });
|
||||
m_canvas->m_layers[m_layer_idx]->clear({ 0, 0, 0, 0 }, m_frame_idx);
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
// empty data
|
||||
@@ -17,18 +17,18 @@ void ActionStroke::undo()
|
||||
|
||||
LOG("undo box %d dirty=%s [%d,%d,%d,%d] to dirty=%s [%d,%d,%d,%d]",
|
||||
i,
|
||||
m_canvas->m_layers[m_layer_idx]->face(i) ? "true" : "false",
|
||||
(int)m_canvas->m_layers[m_layer_idx]->box(i).x,
|
||||
(int)m_canvas->m_layers[m_layer_idx]->box(i).y,
|
||||
(int)m_canvas->m_layers[m_layer_idx]->box(i).z,
|
||||
(int)m_canvas->m_layers[m_layer_idx]->box(i).w,
|
||||
m_canvas->m_layers[m_layer_idx]->face(i, m_frame_idx) ? "true" : "false",
|
||||
(int)m_canvas->m_layers[m_layer_idx]->box(i, m_frame_idx).x,
|
||||
(int)m_canvas->m_layers[m_layer_idx]->box(i, m_frame_idx).y,
|
||||
(int)m_canvas->m_layers[m_layer_idx]->box(i, m_frame_idx).z,
|
||||
(int)m_canvas->m_layers[m_layer_idx]->box(i, m_frame_idx).w,
|
||||
m_old_dirty[i] ? "true" : "false",
|
||||
(int)m_old_box[i].x,
|
||||
(int)m_old_box[i].y,
|
||||
(int)m_old_box[i].z,
|
||||
(int)m_old_box[i].w);
|
||||
m_canvas->m_layers[m_layer_idx]->box(i) = m_old_box[i];
|
||||
m_canvas->m_layers[m_layer_idx]->face(i) = m_old_dirty[i];
|
||||
m_canvas->m_layers[m_layer_idx]->box(i, m_frame_idx) = m_old_box[i];
|
||||
m_canvas->m_layers[m_layer_idx]->face(i, m_frame_idx) = m_old_dirty[i];
|
||||
|
||||
|
||||
glm::vec2 box_sz = zw(m_box[i]) - xy(m_box[i]);
|
||||
@@ -36,9 +36,9 @@ void ActionStroke::undo()
|
||||
{
|
||||
App::I->render_task([&]
|
||||
{
|
||||
m_canvas->m_layers[m_layer_idx]->rtt(i).bindTexture();
|
||||
m_canvas->m_layers[m_layer_idx]->rtt(i, m_frame_idx).bindTexture();
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, (int)m_box[i].x, (int)m_box[i].y, (int)box_sz.x, (int)box_sz.y, GL_RGBA, GL_UNSIGNED_BYTE, m_image[i].get());
|
||||
m_canvas->m_layers[m_layer_idx]->rtt(i).unbindTexture();
|
||||
m_canvas->m_layers[m_layer_idx]->rtt(i, m_frame_idx).unbindTexture();
|
||||
});
|
||||
}
|
||||
else
|
||||
@@ -65,7 +65,7 @@ Action* ActionStroke::get_redo()
|
||||
auto& layer = m_canvas->m_layers[m_layer_idx];
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
if (!layer->face(i) && !m_image[i])
|
||||
if (!layer->face(i, m_frame_idx) && !m_image[i])
|
||||
continue; // no stroke on this face, skip it
|
||||
|
||||
|
||||
@@ -79,9 +79,9 @@ Action* ActionStroke::get_redo()
|
||||
action->m_image[i] = std::make_unique<uint8_t[]>(box_sz.x * box_sz.y * 4);
|
||||
App::I->render_task([&]
|
||||
{
|
||||
layer->rtt(i).bindFramebuffer();
|
||||
layer->rtt(i, m_frame_idx).bindFramebuffer();
|
||||
glReadPixels(box_or.x, box_or.y, box_sz.x, box_sz.y, GL_RGBA, GL_UNSIGNED_BYTE, action->m_image[i].get());
|
||||
layer->rtt(i).unbindFramebuffer();
|
||||
layer->rtt(i, m_frame_idx).unbindFramebuffer();
|
||||
});
|
||||
}
|
||||
else
|
||||
@@ -90,11 +90,12 @@ Action* ActionStroke::get_redo()
|
||||
}
|
||||
|
||||
action->m_box[i] = box;
|
||||
action->m_old_box[i] = layer->box(i);
|
||||
action->m_old_dirty[i] = layer->face(i);
|
||||
action->m_old_box[i] = layer->box(i, m_frame_idx);
|
||||
action->m_old_dirty[i] = layer->face(i, m_frame_idx);
|
||||
}
|
||||
// save history
|
||||
action->m_layer_idx = m_layer_idx;
|
||||
action->m_frame_idx = m_frame_idx;
|
||||
action->m_canvas = m_canvas;
|
||||
//action->m_stroke = std::move(m_stroke);
|
||||
action->clear_layer = false;
|
||||
@@ -109,6 +110,7 @@ Action* ActionLayerClear::get_redo()
|
||||
a->m_direction = reverse_direction();
|
||||
a->m_snap = m_snap;
|
||||
a->m_layer = m_layer;
|
||||
a->m_frame = m_frame;
|
||||
a->m_color = m_color;
|
||||
return a;
|
||||
}
|
||||
@@ -117,11 +119,11 @@ void ActionLayerClear::undo()
|
||||
{
|
||||
if (m_direction == Direction::Undo)
|
||||
{
|
||||
m_layer->restore(*m_snap);
|
||||
m_layer->restore(*m_snap, m_frame);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_layer->clear(m_color);
|
||||
m_layer->clear(m_color, m_frame);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,22 +131,27 @@ void ActionLayerClear::undo()
|
||||
|
||||
Action* ActionImportEquirect::get_redo()
|
||||
{
|
||||
auto a = new ActionImportEquirect;
|
||||
a->m_direction = reverse_direction();
|
||||
a->m_snap = m_snap;
|
||||
a->m_layer = m_layer;
|
||||
a->m_path = m_path;
|
||||
return a;
|
||||
if (m_direction == Direction::Undo)
|
||||
{
|
||||
auto a = new ActionImportEquirect;
|
||||
a->m_direction = reverse_direction();
|
||||
a->m_snap = m_snap;
|
||||
a->m_layer = m_layer;
|
||||
a->m_frame = m_frame;
|
||||
a->m_path = m_path;
|
||||
return a;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void ActionImportEquirect::undo()
|
||||
{
|
||||
if (m_direction == Direction::Undo)
|
||||
{
|
||||
m_layer->restore(*m_snap);
|
||||
m_layer->restore(*m_snap, m_frame);
|
||||
}
|
||||
else
|
||||
{
|
||||
Canvas::I->import_equirectangular_thread(m_path, m_layer);
|
||||
Canvas::I->import_equirectangular_thread(m_path, m_layer, m_frame);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user