Tech ENABLE_GLBEGIN_GLEND_REMOVAL - GLGizmoPainterBase circle
This commit is contained in:
parent
0a177d0e06
commit
0e3a3aa522
13 changed files with 101 additions and 20 deletions
|
@ -5231,7 +5231,11 @@ void GLCanvas3D::_render_objects(GLVolumeCollection::ERenderType type)
|
|||
// before transparent objects are rendered. Otherwise they would not be
|
||||
// visible when inside modifier meshes etc.
|
||||
{
|
||||
#if ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||
GLGizmosManager& gm = get_gizmos_manager();
|
||||
#else
|
||||
const GLGizmosManager& gm = get_gizmos_manager();
|
||||
#endif // ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||
// GLGizmosManager::EType type = gm.get_current_type();
|
||||
if (dynamic_cast<GLGizmoPainterBase*>(gm.get_current())) {
|
||||
shader->stop_using();
|
||||
|
|
|
@ -69,9 +69,11 @@ bool GLGizmoFdmSupports::on_init()
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#if ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||
void GLGizmoFdmSupports::render_painter_gizmo()
|
||||
#else
|
||||
void GLGizmoFdmSupports::render_painter_gizmo() const
|
||||
#endif // ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||
{
|
||||
const Selection& selection = m_parent.get_selection();
|
||||
|
||||
|
|
|
@ -11,7 +11,11 @@ public:
|
|||
GLGizmoFdmSupports(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id)
|
||||
: GLGizmoPainterBase(parent, icon_filename, sprite_id) {}
|
||||
|
||||
#if ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||
void render_painter_gizmo() override;
|
||||
#else
|
||||
void render_painter_gizmo() const override;
|
||||
#endif // ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||
|
||||
protected:
|
||||
void on_render_input_window(float x, float y, float bottom_limit) override;
|
||||
|
|
|
@ -130,7 +130,11 @@ bool GLGizmoMmuSegmentation::on_init()
|
|||
return true;
|
||||
}
|
||||
|
||||
#if ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||
void GLGizmoMmuSegmentation::render_painter_gizmo()
|
||||
#else
|
||||
void GLGizmoMmuSegmentation::render_painter_gizmo() const
|
||||
#endif // ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||
{
|
||||
const Selection& selection = m_parent.get_selection();
|
||||
|
||||
|
|
|
@ -85,7 +85,11 @@ public:
|
|||
: GLGizmoPainterBase(parent, icon_filename, sprite_id) {}
|
||||
~GLGizmoMmuSegmentation() override = default;
|
||||
|
||||
#if ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||
void render_painter_gizmo() override;
|
||||
#else
|
||||
void render_painter_gizmo() const override;
|
||||
#endif // ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||
|
||||
void set_painter_gizmo_data(const Selection& selection) override;
|
||||
|
||||
|
|
|
@ -113,8 +113,11 @@ void GLGizmoPainterBase::render_triangles(const Selection& selection) const
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
#if ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||
void GLGizmoPainterBase::render_cursor()
|
||||
#else
|
||||
void GLGizmoPainterBase::render_cursor() const
|
||||
#endif // ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||
{
|
||||
// First check that the mouse pointer is on an object.
|
||||
const ModelObject* mo = m_c->selection_info()->model_object();
|
||||
|
@ -141,26 +144,30 @@ void GLGizmoPainterBase::render_cursor() const
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#if ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||
void GLGizmoPainterBase::render_cursor_circle()
|
||||
#else
|
||||
void GLGizmoPainterBase::render_cursor_circle() const
|
||||
#endif // ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||
{
|
||||
const Camera &camera = wxGetApp().plater()->get_camera();
|
||||
auto zoom = (float) camera.get_zoom();
|
||||
float inv_zoom = (zoom != 0.0f) ? 1.0f / zoom : 0.0f;
|
||||
const float zoom = float(camera.get_zoom());
|
||||
const float inv_zoom = (zoom != 0.0f) ? 1.0f / zoom : 0.0f;
|
||||
|
||||
Size cnv_size = m_parent.get_canvas_size();
|
||||
float cnv_half_width = 0.5f * (float) cnv_size.get_width();
|
||||
float cnv_half_height = 0.5f * (float) cnv_size.get_height();
|
||||
if ((cnv_half_width == 0.0f) || (cnv_half_height == 0.0f))
|
||||
const Size cnv_size = m_parent.get_canvas_size();
|
||||
const float cnv_half_width = 0.5f * float(cnv_size.get_width());
|
||||
const float cnv_half_height = 0.5f * float(cnv_size.get_height());
|
||||
if (cnv_half_width == 0.0f || cnv_half_height == 0.0f)
|
||||
return;
|
||||
Vec2d mouse_pos(m_parent.get_local_mouse_position()(0), m_parent.get_local_mouse_position()(1));
|
||||
Vec2d center(mouse_pos(0) - cnv_half_width, cnv_half_height - mouse_pos(1));
|
||||
const Vec2d mouse_pos(m_parent.get_local_mouse_position().x(), m_parent.get_local_mouse_position().y());
|
||||
Vec2d center(mouse_pos.x() - cnv_half_width, cnv_half_height - mouse_pos.y());
|
||||
center = center * inv_zoom;
|
||||
|
||||
glsafe(::glLineWidth(1.5f));
|
||||
static const std::array<float, 3> color = {0.f, 1.f, 0.3f};
|
||||
#if !ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||
static const std::array<float, 3> color = { 0.f, 1.f, 0.3f };
|
||||
glsafe(::glColor3fv(color.data()));
|
||||
#endif // !ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||
glsafe(::glDisable(GL_DEPTH_TEST));
|
||||
|
||||
glsafe(::glPushMatrix());
|
||||
|
@ -168,17 +175,46 @@ void GLGizmoPainterBase::render_cursor_circle() const
|
|||
// ensure that the circle is renderered inside the frustrum
|
||||
glsafe(::glTranslated(0.0, 0.0, -(camera.get_near_z() + 0.5)));
|
||||
// ensure that the overlay fits the frustrum near z plane
|
||||
double gui_scale = camera.get_gui_scale();
|
||||
const double gui_scale = camera.get_gui_scale();
|
||||
glsafe(::glScaled(gui_scale, gui_scale, 1.0));
|
||||
|
||||
glsafe(::glPushAttrib(GL_ENABLE_BIT));
|
||||
glsafe(::glLineStipple(4, 0xAAAA));
|
||||
glsafe(::glEnable(GL_LINE_STIPPLE));
|
||||
|
||||
#if ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||
if (!m_circle.is_initialized() || !m_old_center.isApprox(center) || std::abs(m_old_cursor_radius - m_cursor_radius) > EPSILON) {
|
||||
m_old_center = center;
|
||||
m_old_cursor_radius = m_cursor_radius;
|
||||
m_circle.reset();
|
||||
|
||||
GLModel::InitializationData init_data;
|
||||
GLModel::InitializationData::Entity entity;
|
||||
entity.type = GLModel::PrimitiveType::LineLoop;
|
||||
static const unsigned int StepsCount = 32;
|
||||
static const float StepSize = 2.0f * float(PI) / float(StepsCount);
|
||||
entity.positions.reserve(StepsCount);
|
||||
entity.normals.reserve(StepsCount);
|
||||
entity.indices.reserve(StepsCount);
|
||||
for (unsigned int i = 0; i < StepsCount; ++i) {
|
||||
const float angle = float(i * StepSize);
|
||||
entity.positions.emplace_back(center.x() + ::cos(angle) * m_cursor_radius, center.y() + ::sin(angle) * m_cursor_radius, 0.0f);
|
||||
entity.normals.emplace_back(Vec3f::UnitZ());
|
||||
entity.indices.emplace_back(i);
|
||||
}
|
||||
|
||||
init_data.entities.emplace_back(entity);
|
||||
m_circle.init_from(init_data);
|
||||
}
|
||||
|
||||
m_circle.set_color(-1, { 0.0f, 1.0f, 0.3f, 1.0f });
|
||||
m_circle.render();
|
||||
#else
|
||||
::glBegin(GL_LINE_LOOP);
|
||||
for (double angle=0; angle<2*M_PI; angle+=M_PI/20.)
|
||||
::glVertex2f(GLfloat(center.x()+m_cursor_radius*cos(angle)), GLfloat(center.y()+m_cursor_radius*sin(angle)));
|
||||
glsafe(::glEnd());
|
||||
#endif // ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||
|
||||
glsafe(::glPopAttrib());
|
||||
glsafe(::glPopMatrix());
|
||||
|
|
|
@ -121,7 +121,11 @@ public:
|
|||
// from usual on_render method allows to render them before transparent
|
||||
// objects, so they can be seen inside them. The usual on_render is called
|
||||
// after all volumes (including transparent ones) are rendered.
|
||||
#if ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||
virtual void render_painter_gizmo() = 0;
|
||||
#else
|
||||
virtual void render_painter_gizmo() const = 0;
|
||||
#endif // ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||
|
||||
virtual const float get_cursor_radius_min() const { return CursorRadiusMin; }
|
||||
virtual const float get_cursor_radius_max() const { return CursorRadiusMax; }
|
||||
|
@ -129,8 +133,13 @@ public:
|
|||
|
||||
protected:
|
||||
virtual void render_triangles(const Selection& selection) const;
|
||||
#if ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||
void render_cursor();
|
||||
void render_cursor_circle();
|
||||
#else
|
||||
void render_cursor() const;
|
||||
void render_cursor_circle() const;
|
||||
#endif // ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||
void render_cursor_sphere(const Transform3d& trafo) const;
|
||||
virtual void update_model_object() const = 0;
|
||||
virtual void update_from_model_object() = 0;
|
||||
|
@ -171,6 +180,12 @@ protected:
|
|||
bool m_paint_on_overhangs_only = false;
|
||||
float m_highlight_by_angle_threshold_deg = 0.f;
|
||||
|
||||
#if ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||
GLModel m_circle;
|
||||
Vec2d m_old_center{ Vec2d::Zero() };
|
||||
float m_old_cursor_radius{ 0.0f };
|
||||
#endif // ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||
|
||||
static constexpr float SmartFillAngleMin = 0.0f;
|
||||
static constexpr float SmartFillAngleMax = 90.f;
|
||||
static constexpr float SmartFillAngleStep = 1.f;
|
||||
|
|
|
@ -17,10 +17,9 @@ namespace GUI {
|
|||
|
||||
|
||||
const float GLGizmoRotate::Offset = 5.0f;
|
||||
const unsigned int GLGizmoRotate::CircleResolution = 64;
|
||||
const unsigned int GLGizmoRotate::AngleResolution = 64;
|
||||
const unsigned int GLGizmoRotate::ScaleStepsCount = 72;
|
||||
const float GLGizmoRotate::ScaleStepRad = 2.0f * (float)PI / GLGizmoRotate::ScaleStepsCount;
|
||||
const float GLGizmoRotate::ScaleStepRad = 2.0f * float(PI) / GLGizmoRotate::ScaleStepsCount;
|
||||
const unsigned int GLGizmoRotate::ScaleLongEvery = 2;
|
||||
const float GLGizmoRotate::ScaleLongTooth = 0.1f; // in percent of radius
|
||||
const unsigned int GLGizmoRotate::SnapRegionsCount = 8;
|
||||
|
|
|
@ -9,7 +9,6 @@ namespace GUI {
|
|||
class GLGizmoRotate : public GLGizmoBase
|
||||
{
|
||||
static const float Offset;
|
||||
static const unsigned int CircleResolution;
|
||||
static const unsigned int AngleResolution;
|
||||
static const unsigned int ScaleStepsCount;
|
||||
static const float ScaleStepRad;
|
||||
|
|
|
@ -52,9 +52,11 @@ std::string GLGizmoSeam::on_get_name() const
|
|||
return _u8L("Seam painting");
|
||||
}
|
||||
|
||||
|
||||
|
||||
#if ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||
void GLGizmoSeam::render_painter_gizmo()
|
||||
#else
|
||||
void GLGizmoSeam::render_painter_gizmo() const
|
||||
#endif // ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||
{
|
||||
const Selection& selection = m_parent.get_selection();
|
||||
|
||||
|
|
|
@ -11,7 +11,11 @@ public:
|
|||
GLGizmoSeam(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id)
|
||||
: GLGizmoPainterBase(parent, icon_filename, sprite_id) {}
|
||||
|
||||
#if ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||
void render_painter_gizmo() override;
|
||||
#else
|
||||
void render_painter_gizmo() const override;
|
||||
#endif // ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||
|
||||
protected:
|
||||
void on_render_input_window(float x, float y, float bottom_limit) override;
|
||||
|
|
|
@ -475,7 +475,11 @@ void GLGizmosManager::render_current_gizmo() const
|
|||
m_gizmos[m_current]->render();
|
||||
}
|
||||
|
||||
#if ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||
void GLGizmosManager::render_painter_gizmo()
|
||||
#else
|
||||
void GLGizmosManager::render_painter_gizmo() const
|
||||
#endif // ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||
{
|
||||
// This function shall only be called when current gizmo is
|
||||
// derived from GLGizmoPainterBase.
|
||||
|
|
|
@ -222,7 +222,11 @@ public:
|
|||
|
||||
void render_current_gizmo() const;
|
||||
void render_current_gizmo_for_picking_pass() const;
|
||||
#if ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||
void render_painter_gizmo();
|
||||
#else
|
||||
void render_painter_gizmo() const;
|
||||
#endif // ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||
|
||||
void render_overlay() const;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue