From ccde247f2a4912b0a477cd0c13e17961abc10786 Mon Sep 17 00:00:00 2001 From: omigamedev Date: Sat, 30 Sep 2017 22:45:35 +0100 Subject: [PATCH] init brush settings at startup --- engine/app_layout.cpp | 12 ++++++++++++ engine/brush.h | 22 +++++++++++----------- engine/node_panel_stroke.cpp | 2 +- engine/node_stroke_preview.cpp | 3 ++- 4 files changed, 26 insertions(+), 13 deletions(-) diff --git a/engine/app_layout.cpp b/engine/app_layout.cpp index da4229e..fe93052 100644 --- a/engine/app_layout.cpp +++ b/engine/app_layout.cpp @@ -493,6 +493,18 @@ void App::initLayout() init_menu_edit(); init_menu_layer(); + Brush b; + b.m_tex_id = brushes->get_texture_id(0); + b.id = brushes->get_brush_id(0); + b.m_tip_size = .1f; + b.m_tip_flow = .5f; + b.m_tip_spacing = .1f; + b.m_tip_opacity = 1.f; + stroke->m_canvas->m_brush = b; + canvas->m_brush = b; + + brush_update(); + // hacky thing to make the toolbar buttons not steal events when moving cursor fast if (auto* toolbar = layout[main_id]->find("toolbar")) toolbar->m_flood_events = true; diff --git a/engine/brush.h b/engine/brush.h index 3551955..58d5e59 100644 --- a/engine/brush.h +++ b/engine/brush.h @@ -7,22 +7,22 @@ NS_START class Brush { public: - int id; + int id = 0; std::string m_name; - uint16_t m_tex_id; + uint16_t m_tex_id = 0; glm::vec4 m_tip_color; - float m_tip_size; - float m_tip_spacing; - float m_tip_flow; - float m_tip_opacity; - float m_tip_angle; + float m_tip_size = 0; + float m_tip_spacing = 0; + float m_tip_flow = 0; + float m_tip_opacity = 0; + float m_tip_angle = 0; bool m_tip_angle_follow = false; bool m_tip_flow_pressure = false; bool m_tip_size_pressure = false; - float m_jitter_scale; - float m_jitter_angle; - float m_jitter_spread; - float m_jitter_flow; + float m_jitter_scale = 0; + float m_jitter_angle = 0; + float m_jitter_spread = 0; + float m_jitter_flow = 0; }; struct StrokeSample diff --git a/engine/node_panel_stroke.cpp b/engine/node_panel_stroke.cpp index b82f2cb..cea44c0 100644 --- a/engine/node_panel_stroke.cpp +++ b/engine/node_panel_stroke.cpp @@ -66,7 +66,7 @@ void NodePanelStroke::init_slider(NodeSliderH*& target, const char* id, float ui target = find(id); target->on_value_changed = std::bind(&NodePanelStroke::handle_slide, this, prop, std::placeholders::_1, std::placeholders::_2); - m_canvas->m_brush.*prop = target->m_value.x; + //m_canvas->m_brush.*prop = target->m_value.x; } void NodePanelStroke::handle_slide(float ui::Brush::* prop, Node* target, float value) diff --git a/engine/node_stroke_preview.cpp b/engine/node_stroke_preview.cpp index ab5786b..b32123f 100644 --- a/engine/node_stroke_preview.cpp +++ b/engine/node_stroke_preview.cpp @@ -30,7 +30,8 @@ void NodeStrokePreview::init_controls() { m_mesh.create(); m_sampler.create(); - m_sampler_brush.create(GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR); + m_sampler_brush.create(); + m_sampler_brush.set_filter(GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR); TextureManager::load("data/Icons/Round-Hard.png"); m_brush.m_tex_id = const_hash("data/Icons/Round-Hard.png"); }