fix presets save and restore
This commit is contained in:
@@ -236,7 +236,7 @@ std::vector<StrokeSample> Stroke::compute_samples()
|
|||||||
}
|
}
|
||||||
else if (m_brush->m_tip_angle_init)
|
else if (m_brush->m_tip_angle_init)
|
||||||
{
|
{
|
||||||
s.angle = m_dir_init;
|
s.angle += m_dir_init;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_prev_sample = s;
|
m_prev_sample = s;
|
||||||
@@ -351,7 +351,10 @@ bool Brush::load_tip(const std::string& path, const std::string& thumb)
|
|||||||
{
|
{
|
||||||
m_tip_texture = std::make_shared<Texture2D>();
|
m_tip_texture = std::make_shared<Texture2D>();
|
||||||
if (!m_tip_texture->load(path))
|
if (!m_tip_texture->load(path))
|
||||||
|
{
|
||||||
|
m_tip_texture = nullptr;
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
m_tip_texture->create_mipmaps();
|
m_tip_texture->create_mipmaps();
|
||||||
m_tip_texture->auto_destroy = true;
|
m_tip_texture->auto_destroy = true;
|
||||||
m_brush_path = path;
|
m_brush_path = path;
|
||||||
@@ -365,7 +368,10 @@ bool Brush::load_dual(const std::string& path, const std::string& thumb)
|
|||||||
{
|
{
|
||||||
m_dual_texture = std::make_shared<Texture2D>();
|
m_dual_texture = std::make_shared<Texture2D>();
|
||||||
if (!m_dual_texture->load(path))
|
if (!m_dual_texture->load(path))
|
||||||
|
{
|
||||||
|
m_dual_texture = nullptr;
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
m_dual_texture->create_mipmaps();
|
m_dual_texture->create_mipmaps();
|
||||||
m_dual_texture->auto_destroy = true;
|
m_dual_texture->auto_destroy = true;
|
||||||
m_dual_path = path;
|
m_dual_path = path;
|
||||||
@@ -377,7 +383,10 @@ bool Brush::load_pattern(const std::string& path, const std::string& thumb)
|
|||||||
{
|
{
|
||||||
m_pattern_texture = std::make_shared<Texture2D>();
|
m_pattern_texture = std::make_shared<Texture2D>();
|
||||||
if (!m_pattern_texture->load(path))
|
if (!m_pattern_texture->load(path))
|
||||||
|
{
|
||||||
|
m_pattern_texture = nullptr;
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
m_pattern_texture->create_mipmaps();
|
m_pattern_texture->create_mipmaps();
|
||||||
m_pattern_texture->auto_destroy = true;
|
m_pattern_texture->auto_destroy = true;
|
||||||
m_pattern_path = path;
|
m_pattern_path = path;
|
||||||
|
|||||||
@@ -481,10 +481,10 @@ bool NodePanelBrushPreset::save()
|
|||||||
i.m_name_len = b->m_name.size();
|
i.m_name_len = b->m_name.size();
|
||||||
i.m_brush_path_len = b->m_brush_path.size();
|
i.m_brush_path_len = b->m_brush_path.size();
|
||||||
i.m_brush_thumb_path_len = b->m_brush_thumb_path.size();
|
i.m_brush_thumb_path_len = b->m_brush_thumb_path.size();
|
||||||
i.m_dual_path_len = b->m_brush_path.size();
|
i.m_dual_path_len = b->m_dual_path.size();
|
||||||
i.m_dual_thumb_path_len = b->m_brush_thumb_path.size();
|
i.m_dual_thumb_path_len = b->m_dual_thumb_path.size();
|
||||||
i.m_stencil_path_len = b->m_pattern_path.size();
|
i.m_pattern_path_len = b->m_pattern_path.size();
|
||||||
i.m_stencil_thumb_path_len = b->m_pattern_thumb_path.size();
|
i.m_pattern_thumb_path_len = b->m_pattern_thumb_path.size();
|
||||||
i.m_tip_color = b->m_tip_color;
|
i.m_tip_color = b->m_tip_color;
|
||||||
i.m_tip_scale = b->m_tip_scale;
|
i.m_tip_scale = b->m_tip_scale;
|
||||||
i.m_tip_size = b->m_tip_size;
|
i.m_tip_size = b->m_tip_size;
|
||||||
@@ -556,8 +556,8 @@ bool NodePanelBrushPreset::save()
|
|||||||
fwrite(b->m_name.c_str(), 1, b->m_name.size(), fp);
|
fwrite(b->m_name.c_str(), 1, b->m_name.size(), fp);
|
||||||
fwrite(b->m_brush_path.c_str(), 1, b->m_brush_path.size(), fp);
|
fwrite(b->m_brush_path.c_str(), 1, b->m_brush_path.size(), fp);
|
||||||
fwrite(b->m_brush_thumb_path.c_str(), 1, b->m_brush_thumb_path.size(), fp);
|
fwrite(b->m_brush_thumb_path.c_str(), 1, b->m_brush_thumb_path.size(), fp);
|
||||||
fwrite(b->m_dual_path.c_str(), 1, b->m_brush_path.size(), fp);
|
fwrite(b->m_dual_path.c_str(), 1, b->m_dual_path.size(), fp);
|
||||||
fwrite(b->m_dual_thumb_path.c_str(), 1, b->m_brush_thumb_path.size(), fp);
|
fwrite(b->m_dual_thumb_path.c_str(), 1, b->m_dual_thumb_path.size(), fp);
|
||||||
fwrite(b->m_pattern_path.c_str(), 1, b->m_pattern_path.size(), fp);
|
fwrite(b->m_pattern_path.c_str(), 1, b->m_pattern_path.size(), fp);
|
||||||
fwrite(b->m_pattern_thumb_path.c_str(), 1, b->m_pattern_thumb_path.size(), fp);
|
fwrite(b->m_pattern_thumb_path.c_str(), 1, b->m_pattern_thumb_path.size(), fp);
|
||||||
}
|
}
|
||||||
@@ -638,6 +638,8 @@ bool NodePanelBrushPreset::restore()
|
|||||||
b->m_dual_invert = i.m_dual_invert;
|
b->m_dual_invert = i.m_dual_invert;
|
||||||
b->m_dual_flipx = i.m_dual_flipx;
|
b->m_dual_flipx = i.m_dual_flipx;
|
||||||
b->m_dual_flipy = i.m_dual_flipy;
|
b->m_dual_flipy = i.m_dual_flipy;
|
||||||
|
b->m_tip_randflipx = i.m_tip_randflipx;
|
||||||
|
b->m_tip_randflipy = i.m_tip_randflipy;
|
||||||
b->m_tip_aspect = i.m_tip_aspect;
|
b->m_tip_aspect = i.m_tip_aspect;
|
||||||
b->m_dual_flow = i.m_dual_flow;
|
b->m_dual_flow = i.m_dual_flow;
|
||||||
b->m_dual_opacity = i.m_dual_opacity;
|
b->m_dual_opacity = i.m_dual_opacity;
|
||||||
@@ -660,15 +662,15 @@ bool NodePanelBrushPreset::restore()
|
|||||||
b->m_name.resize(i.m_name_len);
|
b->m_name.resize(i.m_name_len);
|
||||||
b->m_brush_path.resize(i.m_brush_path_len);
|
b->m_brush_path.resize(i.m_brush_path_len);
|
||||||
b->m_brush_thumb_path.resize(i.m_brush_thumb_path_len);
|
b->m_brush_thumb_path.resize(i.m_brush_thumb_path_len);
|
||||||
b->m_dual_path.resize(i.m_brush_path_len);
|
b->m_dual_path.resize(i.m_dual_path_len);
|
||||||
b->m_dual_thumb_path.resize(i.m_brush_thumb_path_len);
|
b->m_dual_thumb_path.resize(i.m_dual_thumb_path_len);
|
||||||
b->m_pattern_path.resize(i.m_stencil_path_len);
|
b->m_pattern_path.resize(i.m_pattern_path_len);
|
||||||
b->m_pattern_thumb_path.resize(i.m_stencil_thumb_path_len);
|
b->m_pattern_thumb_path.resize(i.m_pattern_thumb_path_len);
|
||||||
fread((char*)b->m_name.c_str(), 1, b->m_name.size(), fp);
|
fread((char*)b->m_name.c_str(), 1, b->m_name.size(), fp);
|
||||||
fread((char*)b->m_brush_path.c_str(), 1, b->m_brush_path.size(), fp);
|
fread((char*)b->m_brush_path.c_str(), 1, b->m_brush_path.size(), fp);
|
||||||
fread((char*)b->m_brush_thumb_path.c_str(), 1, b->m_brush_thumb_path.size(), fp);
|
fread((char*)b->m_brush_thumb_path.c_str(), 1, b->m_brush_thumb_path.size(), fp);
|
||||||
fread((char*)b->m_dual_path.c_str(), 1, b->m_brush_path.size(), fp);
|
fread((char*)b->m_dual_path.c_str(), 1, b->m_dual_path.size(), fp);
|
||||||
fread((char*)b->m_dual_thumb_path.c_str(), 1, b->m_brush_thumb_path.size(), fp);
|
fread((char*)b->m_dual_thumb_path.c_str(), 1, b->m_dual_thumb_path.size(), fp);
|
||||||
fread((char*)b->m_pattern_path.c_str(), 1, b->m_pattern_path.size(), fp);
|
fread((char*)b->m_pattern_path.c_str(), 1, b->m_pattern_path.size(), fp);
|
||||||
fread((char*)b->m_pattern_thumb_path.c_str(), 1, b->m_pattern_thumb_path.size(), fp);
|
fread((char*)b->m_pattern_thumb_path.c_str(), 1, b->m_pattern_thumb_path.size(), fp);
|
||||||
|
|
||||||
|
|||||||
@@ -100,8 +100,8 @@ class NodePanelBrushPreset : public Node
|
|||||||
int m_dual_path_len = 0;
|
int m_dual_path_len = 0;
|
||||||
int m_dual_thumb_path_len = 0;
|
int m_dual_thumb_path_len = 0;
|
||||||
|
|
||||||
int m_stencil_path_len = 0;
|
int m_pattern_path_len = 0;
|
||||||
int m_stencil_thumb_path_len = 0;
|
int m_pattern_thumb_path_len = 0;
|
||||||
|
|
||||||
glm::vec4 m_tip_color{ 0, 0, 0, 1 };
|
glm::vec4 m_tip_color{ 0, 0, 0, 1 };
|
||||||
glm::vec2 m_tip_scale = { 1.f, 1.f };
|
glm::vec2 m_tip_scale = { 1.f, 1.f };
|
||||||
|
|||||||
Reference in New Issue
Block a user