Skip to content

Commit efadf6a

Browse files
committed
v1.xのデータの読み込み処理を修正
1 parent 47a2781 commit efadf6a

File tree

9 files changed

+40
-26
lines changed

9 files changed

+40
-26
lines changed

curve_editor/constants.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ namespace cved {
2121
inline constexpr auto PLUGIN_VERSION = mkaul::Version{
2222
mkaul::VersionNumber{2},
2323
mkaul::PreviewType{mkaul::PreviewType::Type::Alpha},
24-
mkaul::VersionNumber{2}
24+
mkaul::VersionNumber{2, 0, 1}
2525
};
2626
inline constexpr auto PLUGIN_DEVELOPER = "mimaraka";
2727
inline constexpr auto PLUGIN_TRANSLATOR = "Deepdive";

curve_editor/curve_editor_graph.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,11 @@ namespace cved {
178178
vec_tmp.emplace_back(std::move(curve));
179179
}
180180
}
181-
vec_tmp.reserve(vec_tmp.capacity());
182-
curves_normal_ = std::move(vec_tmp);
181+
curves_normal_.clear();
182+
for (auto it = vec_tmp.rbegin(); it != vec_tmp.rend(); it++) {
183+
curves_normal_.emplace_back(std::move(*it));
184+
}
185+
183186
// インデックスをリセット
184187
idx_normal_ = 0;
185188
return true;

curve_editor/curve_graph.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,24 @@ namespace cved {
2121
}
2222
}
2323

24-
void GraphCurve::set_anchor_start(double x, double y) noexcept {
25-
if (anchor_fixed_ or !prev_) {
24+
void GraphCurve::set_anchor_start(double x, double y, bool forced) noexcept {
25+
if ((anchor_fixed_ or !prev_) and !forced) {
2626
return;
2727
}
2828
auto ret = mkaul::Point{
29-
mkaul::clamp(x, prev_->anchor_start_.x, anchor_end_.x),
29+
mkaul::clamp(x, prev_ ? prev_->anchor_start_.x : 0., anchor_end_.x),
3030
y
3131
};
3232
anchor_start_ = ret;
3333
//prev_->anchor_end_ = ret;
3434
}
3535

36-
void GraphCurve::set_anchor_end(double x, double y) noexcept {
37-
if (anchor_fixed_ or !next_) {
36+
void GraphCurve::set_anchor_end(double x, double y, bool forced) noexcept {
37+
if ((anchor_fixed_ or !next_) and !forced) {
3838
return;
3939
}
4040
auto ret = mkaul::Point{
41-
mkaul::clamp(x, anchor_start_.x, next_->anchor_end_.x),
41+
mkaul::clamp(x, anchor_start_.x, next_ ? next_->anchor_end_.x : 1.),
4242
y
4343
};
4444
anchor_end_ = ret;

curve_editor/curve_graph.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,10 @@ namespace cved {
9292
double get_anchor_start_y() const noexcept { return anchor_start_.y; }
9393
double get_anchor_end_x() const noexcept { return anchor_end_.x; }
9494
double get_anchor_end_y() const noexcept { return anchor_end_.y; }
95-
void set_anchor_start(double x, double y) noexcept;
96-
void set_anchor_start(const mkaul::Point<double>& pt) noexcept { set_anchor_start(pt.x, pt.y); }
97-
void set_anchor_end(double x, double y) noexcept;
98-
void set_anchor_end(const mkaul::Point<double>& pt) noexcept { set_anchor_end(pt.x, pt.y); }
95+
void set_anchor_start(double x, double y, bool forced = false) noexcept;
96+
void set_anchor_start(const mkaul::Point<double>& pt, bool forced = false) noexcept { set_anchor_start(pt.x, pt.y, forced); }
97+
void set_anchor_end(double x, double y, bool forced = false) noexcept;
98+
void set_anchor_end(const mkaul::Point<double>& pt, bool forced = false) noexcept { set_anchor_end(pt.x, pt.y, forced); }
9999

100100
virtual void reverse(bool fix_pt = false) noexcept;
101101

curve_editor/curve_normal.cpp

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -173,28 +173,29 @@ namespace cved {
173173
return false;
174174
}
175175

176-
std::unique_ptr<GraphCurve> new_curve = std::make_unique<BezierCurve>();
176+
auto new_curve = std::make_unique<BezierCurve>();
177177
// ポイントの移動
178178
new_curve->set_anchor_start(
179179
pts[i].pt_center.x / (double)GRAPH_RESOLUTION,
180-
pts[i].pt_center.y / (double)GRAPH_RESOLUTION
180+
pts[i].pt_center.y / (double)GRAPH_RESOLUTION,
181+
true
181182
);
182183
new_curve->set_anchor_end(
183184
pts[i + 1u].pt_center.x / (double)GRAPH_RESOLUTION,
184-
pts[i + 1u].pt_center.y / (double)GRAPH_RESOLUTION
185+
pts[i + 1u].pt_center.y / (double)GRAPH_RESOLUTION,
186+
true
185187
);
186188

187189
// ハンドルの移動
188-
auto p_curve_bezier = dynamic_cast<BezierCurve*>(new_curve.get());
189-
p_curve_bezier->set_handle_left(
190-
(pts[i].pt_right.x - pts[i].pt_center.x) / (double)GRAPH_RESOLUTION,
191-
(pts[i].pt_right.y - pts[i].pt_center.y) / (double)GRAPH_RESOLUTION
190+
new_curve->set_handle_left(
191+
new_curve->anchor_start().x + (pts[i].pt_right.x - pts[i].pt_center.x) / (double)GRAPH_RESOLUTION,
192+
new_curve->anchor_start().y + (pts[i].pt_right.y - pts[i].pt_center.y) / (double)GRAPH_RESOLUTION
192193
);
193-
p_curve_bezier->set_handle_right(
194-
(pts[i + 1u].pt_left.x - pts[i + 1u].pt_center.x) / (double)GRAPH_RESOLUTION,
195-
(pts[i + 1u].pt_left.y - pts[i + 1u].pt_center.y) / (double)GRAPH_RESOLUTION
194+
new_curve->set_handle_right(
195+
new_curve->anchor_end().x + (pts[i + 1u].pt_left.x - pts[i + 1u].pt_center.x) / (double)GRAPH_RESOLUTION,
196+
new_curve->anchor_end().y + (pts[i + 1u].pt_left.y - pts[i + 1u].pt_center.y) / (double)GRAPH_RESOLUTION
196197
);
197-
198+
// prev, nextの設定
198199
if (!vec_tmp.empty()) {
199200
new_curve->set_prev(vec_tmp.back().get());
200201
vec_tmp.back()->set_next(new_curve.get());

curve_editor/filter_project_load.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ namespace cved {
4646
}
4747
}
4848
// ウィンドウの更新
49-
//global::window_main.send_command((WPARAM)WindowCommand::Update);
49+
global::webview_main.post_message(L"panel-editor", L"updateEditor");
5050
}
5151
return ret;
5252
}

curve_editor/ui/js/editor_graph.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ window.addEventListener('message', function(event) {
131131
updateVelocityPath();
132132
break;
133133

134+
case 'updateEditor':
134135
case 'updateHandles':
135136
updateHandles();
136137
updateCurvePath();

curve_editor/ui/js/editor_text.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ window.editor.getModel().onDidChangeContent(event => {
1515
});
1616

1717
window.addEventListener('message', event => {
18-
if (event.data.command == 'changeId') {
18+
switch (event.data.command) {
19+
case 'updateEditor':
20+
case 'changeId':
1921
window.editor.setValue(scriptEditor.script);
22+
break;
2023
}
2124
});

curve_editor/ui/js/panel_editor.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ window.addEventListener('message', event => {
99
updateParamButton();
1010
break;
1111

12+
case 'updateEditor':
13+
$('#editor')[0].contentWindow.postMessage(event.data, '*');
14+
updateIdButtons();
15+
updateParamButton();
16+
break;
17+
1218
case 'goBackId':
1319
goBackId();
1420
break;

0 commit comments

Comments
 (0)