mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-15 02:37:51 -06:00
Tech ENABLE_GIZMO_GRABBER_REFACTOR - Refactoring of GLGizmoBase::Grabber to have a single static instance of the cube and cone models to be shared by all grabbers
(cherry picked from commit prusa3d/PrusaSlicer@f504236734)
This commit is contained in:
parent
b2f94e16aa
commit
02f83f29c7
6 changed files with 83 additions and 142 deletions
|
@ -69,9 +69,16 @@ void GLGizmoBase::load_render_colors()
|
||||||
RenderColor::colors[RenderCol_Flatten_Plane_Hover] = ImGuiWrapper::to_ImVec4(GLGizmoBase::FLATTEN_HOVER_COLOR);
|
RenderColor::colors[RenderCol_Flatten_Plane_Hover] = ImGuiWrapper::to_ImVec4(GLGizmoBase::FLATTEN_HOVER_COLOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLGizmoBase::Grabber::render(bool hover, float size)
|
GLModel GLGizmoBase::Grabber::s_cube;
|
||||||
|
GLModel GLGizmoBase::Grabber::s_cone;
|
||||||
|
|
||||||
|
GLGizmoBase::Grabber::~Grabber()
|
||||||
{
|
{
|
||||||
render(size, hover ? hover_color : color, false);
|
if (s_cube.is_initialized())
|
||||||
|
s_cube.reset();
|
||||||
|
|
||||||
|
if (s_cone.is_initialized())
|
||||||
|
s_cone.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
float GLGizmoBase::Grabber::get_half_size(float size) const
|
float GLGizmoBase::Grabber::get_half_size(float size) const
|
||||||
|
@ -86,14 +93,14 @@ float GLGizmoBase::Grabber::get_dragging_half_size(float size) const
|
||||||
|
|
||||||
GLModel& GLGizmoBase::Grabber::get_cube()
|
GLModel& GLGizmoBase::Grabber::get_cube()
|
||||||
{
|
{
|
||||||
if (!m_cube.is_initialized()) {
|
if (!s_cube.is_initialized()) {
|
||||||
// This cannot be done in constructor, OpenGL is not yet
|
// This cannot be done in constructor, OpenGL is not yet
|
||||||
// initialized at that point (on Linux at least).
|
// initialized at that point (on Linux at least).
|
||||||
indexed_triangle_set its = its_make_cube(1., 1., 1.);
|
indexed_triangle_set its = its_make_cube(1.0, 1.0, 1.0);
|
||||||
its_translate(its, Vec3f(-0.5, -0.5, -0.5));
|
its_translate(its, -0.5f * Vec3f::Ones());
|
||||||
m_cube.init_from(its);
|
s_cube.init_from(its);
|
||||||
}
|
}
|
||||||
return m_cube;
|
return s_cube;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLGizmoBase::Grabber::render(float size, const ColorRGBA& render_color, bool picking)
|
void GLGizmoBase::Grabber::render(float size, const ColorRGBA& render_color, bool picking)
|
||||||
|
@ -102,34 +109,63 @@ void GLGizmoBase::Grabber::render(float size, const ColorRGBA& render_color, boo
|
||||||
if (shader == nullptr)
|
if (shader == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!m_cube.is_initialized()) {
|
if (!s_cube.is_initialized()) {
|
||||||
// This cannot be done in constructor, OpenGL is not yet
|
// This cannot be done in constructor, OpenGL is not yet
|
||||||
// initialized at that point (on Linux at least).
|
// initialized at that point (on Linux at least).
|
||||||
indexed_triangle_set its = its_make_cube(1., 1., 1.);
|
indexed_triangle_set its = its_make_cube(1.0, 1.0, 1.0);
|
||||||
its_translate(its, -0.5f * Vec3f::Ones());
|
its_translate(its, -0.5f * Vec3f::Ones());
|
||||||
m_cube.init_from(its);
|
s_cube.init_from(its);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!s_cone.is_initialized())
|
||||||
|
s_cone.init_from(its_make_cone(1.0, 1.0, double(PI) / 18.0));
|
||||||
|
|
||||||
//BBS set to fixed size grabber
|
//BBS set to fixed size grabber
|
||||||
//float fullsize = 2 * (dragging ? get_dragging_half_size(size) : get_half_size(size));
|
const float grabber_size = FixedGrabberSize * INV_ZOOM;
|
||||||
float fullsize = 8.0f;
|
const double extension_size = 0.75 * FixedGrabberSize * INV_ZOOM;
|
||||||
if (GLGizmoBase::INV_ZOOM > 0) {
|
|
||||||
fullsize = FixedGrabberSize * GLGizmoBase::INV_ZOOM;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
s_cube.set_color(render_color);
|
||||||
m_cube.set_color(render_color);
|
s_cone.set_color(render_color);
|
||||||
|
|
||||||
const Camera& camera = wxGetApp().plater()->get_camera();
|
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||||
const Transform3d& view_matrix = camera.get_view_matrix();
|
const Transform3d& view_matrix = camera.get_view_matrix();
|
||||||
const Transform3d model_matrix = matrix * Geometry::assemble_transform(center, angles, fullsize * Vec3d::Ones());
|
|
||||||
const Transform3d view_model_matrix = view_matrix * model_matrix;
|
|
||||||
|
|
||||||
shader->set_uniform("view_model_matrix", view_model_matrix);
|
|
||||||
shader->set_uniform("projection_matrix", camera.get_projection_matrix());
|
shader->set_uniform("projection_matrix", camera.get_projection_matrix());
|
||||||
const Matrix3d view_normal_matrix = view_matrix.matrix().block(0, 0, 3, 3) * model_matrix.matrix().block(0, 0, 3, 3).inverse().transpose();
|
|
||||||
shader->set_uniform("view_normal_matrix", view_normal_matrix);
|
auto render_extension = [&view_matrix, shader](GLModel &model, const Transform3d &model_matrix) {
|
||||||
m_cube.render();
|
shader->set_uniform("view_model_matrix", view_matrix * model_matrix);
|
||||||
|
const Matrix3d view_normal_matrix = view_matrix.matrix().block(0, 0, 3, 3) * model_matrix.matrix().block(0, 0, 3, 3).inverse().transpose();
|
||||||
|
shader->set_uniform("view_normal_matrix", view_normal_matrix);
|
||||||
|
model.render();
|
||||||
|
};
|
||||||
|
|
||||||
|
if (extensions == EGrabberExtension::PosZ) {
|
||||||
|
const Transform3d model_matrix = matrix * Geometry::assemble_transform(center, angles, Vec3d(0.75 * extension_size, 0.75 * extension_size, 2.0 * extension_size));
|
||||||
|
render_extension(s_cone, model_matrix);
|
||||||
|
} else {
|
||||||
|
const Transform3d model_matrix = matrix * Geometry::assemble_transform(center, angles, grabber_size * Vec3d::Ones());
|
||||||
|
render_extension(s_cube, model_matrix);
|
||||||
|
|
||||||
|
const Transform3d extension_model_matrix_base = matrix * Geometry::assemble_transform(center, angles);
|
||||||
|
const Vec3d extension_scale(0.75 * extension_size, 0.75 * extension_size, 3.0 * extension_size);
|
||||||
|
if ((int(extensions) & int(GLGizmoBase::EGrabberExtension::PosX)) != 0) {
|
||||||
|
render_extension(s_cone, extension_model_matrix_base * Geometry::assemble_transform(2.0 * extension_size * Vec3d::UnitX(), Vec3d(0.0, 0.5 * double(PI), 0.0), extension_scale));
|
||||||
|
}
|
||||||
|
if ((int(extensions) & int(GLGizmoBase::EGrabberExtension::NegX)) != 0) {
|
||||||
|
render_extension(s_cone, extension_model_matrix_base * Geometry::assemble_transform(-2.0 * extension_size * Vec3d::UnitX(), Vec3d(0.0, -0.5 * double(PI), 0.0), extension_scale));
|
||||||
|
}
|
||||||
|
if ((int(extensions) & int(GLGizmoBase::EGrabberExtension::PosY)) != 0) {
|
||||||
|
render_extension(s_cone, extension_model_matrix_base * Geometry::assemble_transform(2.0 * extension_size * Vec3d::UnitY(), Vec3d(-0.5 * double(PI), 0.0, 0.0), extension_scale));
|
||||||
|
}
|
||||||
|
if ((int(extensions) & int(GLGizmoBase::EGrabberExtension::NegY)) != 0) {
|
||||||
|
render_extension(s_cone, extension_model_matrix_base * Geometry::assemble_transform(-2.0 * extension_size * Vec3d::UnitY(), Vec3d(0.5 * double(PI), 0.0, 0.0), extension_scale));
|
||||||
|
}
|
||||||
|
if ((int(extensions) & int(GLGizmoBase::EGrabberExtension::PosZ)) != 0) {
|
||||||
|
render_extension(s_cone, extension_model_matrix_base * Geometry::assemble_transform(2.0 * extension_size * Vec3d::UnitZ(), Vec3d::Zero(), extension_scale));
|
||||||
|
}
|
||||||
|
if ((int(extensions) & int(GLGizmoBase::EGrabberExtension::NegZ)) != 0) {
|
||||||
|
render_extension(s_cone, extension_model_matrix_base * Geometry::assemble_transform(-2.0 * extension_size * Vec3d::UnitZ(), Vec3d(double(PI), 0.0, 0.0), extension_scale));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GLGizmoBase::GLGizmoBase(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id)
|
GLGizmoBase::GLGizmoBase(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id)
|
||||||
|
|
|
@ -55,6 +55,17 @@ public:
|
||||||
static void update_render_colors();
|
static void update_render_colors();
|
||||||
static void load_render_colors();
|
static void load_render_colors();
|
||||||
|
|
||||||
|
enum class EGrabberExtension
|
||||||
|
{
|
||||||
|
None = 0,
|
||||||
|
PosX = 1 << 0,
|
||||||
|
NegX = 1 << 1,
|
||||||
|
PosY = 1 << 2,
|
||||||
|
NegY = 1 << 3,
|
||||||
|
PosZ = 1 << 4,
|
||||||
|
NegZ = 1 << 5,
|
||||||
|
};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
struct Grabber
|
struct Grabber
|
||||||
{
|
{
|
||||||
|
@ -71,10 +82,12 @@ protected:
|
||||||
Transform3d matrix{ Transform3d::Identity() };
|
Transform3d matrix{ Transform3d::Identity() };
|
||||||
ColorRGBA color{GRABBER_NORMAL_COL};
|
ColorRGBA color{GRABBER_NORMAL_COL};
|
||||||
ColorRGBA hover_color{GRABBER_HOVER_COL};
|
ColorRGBA hover_color{GRABBER_HOVER_COL};
|
||||||
|
EGrabberExtension extensions{ EGrabberExtension::None };
|
||||||
|
|
||||||
Grabber() = default;
|
Grabber() = default;
|
||||||
|
~Grabber();
|
||||||
|
|
||||||
void render(bool hover, float size);
|
void render(bool hover, float size) { render(size, hover ? hover_color : color, false); }
|
||||||
void render_for_picking(float size) { render(size, color, true); }
|
void render_for_picking(float size) { render(size, color, true); }
|
||||||
|
|
||||||
float get_half_size(float size) const;
|
float get_half_size(float size) const;
|
||||||
|
@ -84,7 +97,8 @@ protected:
|
||||||
private:
|
private:
|
||||||
void render(float size, const ColorRGBA& render_color, bool picking);
|
void render(float size, const ColorRGBA& render_color, bool picking);
|
||||||
|
|
||||||
GLModel m_cube;
|
static GLModel s_cube;
|
||||||
|
static GLModel s_cone;
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -107,7 +121,6 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
GLCanvas3D& m_parent;
|
GLCanvas3D& m_parent;
|
||||||
|
|
||||||
int m_group_id;
|
int m_group_id;
|
||||||
EState m_state;
|
EState m_state;
|
||||||
int m_shortcut_key;
|
int m_shortcut_key;
|
||||||
|
|
|
@ -47,8 +47,12 @@ bool GLGizmoMove3D::on_init()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 3; ++i) {
|
for (int i = 0; i < 3; ++i) {
|
||||||
m_grabbers.push_back(Grabber());
|
m_grabbers.push_back(Grabber());
|
||||||
|
m_grabbers.back().extensions = GLGizmoBase::EGrabberExtension::PosZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_grabbers[0].angles = { 0.0, 0.5 * double(PI), 0.0 };
|
||||||
|
m_grabbers[1].angles = { -0.5 * double(PI), 0.0, 0.0 };
|
||||||
|
|
||||||
m_shortcut_key = WXK_CONTROL_M;
|
m_shortcut_key = WXK_CONTROL_M;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -93,9 +97,6 @@ void GLGizmoMove3D::on_update(const UpdateData& data)
|
||||||
|
|
||||||
void GLGizmoMove3D::on_render()
|
void GLGizmoMove3D::on_render()
|
||||||
{
|
{
|
||||||
if (!m_cone.is_initialized())
|
|
||||||
m_cone.init_from(its_make_cone(1.0, 1.0, double(PI) / 18.0));
|
|
||||||
|
|
||||||
const Selection& selection = m_parent.get_selection();
|
const Selection& selection = m_parent.get_selection();
|
||||||
|
|
||||||
glsafe(::glClear(GL_DEPTH_BUFFER_BIT));
|
glsafe(::glClear(GL_DEPTH_BUFFER_BIT));
|
||||||
|
@ -178,10 +179,7 @@ void GLGizmoMove3D::on_render()
|
||||||
}
|
}
|
||||||
|
|
||||||
// draw grabbers
|
// draw grabbers
|
||||||
for (unsigned int i = 0; i < 3; ++i) {
|
render_grabbers(box);
|
||||||
if (m_grabbers[i].enabled)
|
|
||||||
render_grabber_extension((Axis) i, box, false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLGizmoMove3D::on_render_for_picking()
|
void GLGizmoMove3D::on_render_for_picking()
|
||||||
|
@ -189,20 +187,7 @@ void GLGizmoMove3D::on_render_for_picking()
|
||||||
glsafe(::glDisable(GL_DEPTH_TEST));
|
glsafe(::glDisable(GL_DEPTH_TEST));
|
||||||
|
|
||||||
const BoundingBoxf3& box = m_parent.get_selection().get_bounding_box();
|
const BoundingBoxf3& box = m_parent.get_selection().get_bounding_box();
|
||||||
//BBS donot render base grabber for picking
|
render_grabbers_for_picking(box);
|
||||||
//render_grabbers_for_picking(box);
|
|
||||||
|
|
||||||
//get picking colors only
|
|
||||||
for (unsigned int i = 0; i < (unsigned int) m_grabbers.size(); ++i) {
|
|
||||||
if (m_grabbers[i].enabled) {
|
|
||||||
ColorRGBA color = picking_color_component(i);
|
|
||||||
m_grabbers[i].color = color;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
render_grabber_extension(X, box, true);
|
|
||||||
render_grabber_extension(Y, box, true);
|
|
||||||
render_grabber_extension(Z, box, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//BBS: add input window for move
|
//BBS: add input window for move
|
||||||
|
@ -238,49 +223,5 @@ double GLGizmoMove3D::calc_projection(const UpdateData& data) const
|
||||||
|
|
||||||
return projection;
|
return projection;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLGizmoMove3D::render_grabber_extension(Axis axis, const BoundingBoxf3& box, bool picking)
|
|
||||||
{
|
|
||||||
#if ENABLE_FIXED_GRABBER
|
|
||||||
const float mean_size = (float)(GLGizmoBase::Grabber::FixedGrabberSize);
|
|
||||||
#else
|
|
||||||
const float mean_size = (float)((box.size().x() + box.size().y() + box.size().z()) / 3.0);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
const double size = 0.75 * GLGizmoBase::Grabber::FixedGrabberSize * GLGizmoBase::INV_ZOOM;
|
|
||||||
|
|
||||||
ColorRGBA color = m_grabbers[axis].color;
|
|
||||||
if (!picking && m_hover_id != -1) {
|
|
||||||
if (m_hover_id == axis) {
|
|
||||||
color = m_grabbers[axis].hover_color;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
GLShaderProgram* shader = wxGetApp().get_shader(picking ? "flat" : "gouraud_light");
|
|
||||||
if (shader == nullptr)
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_cone.set_color(color);
|
|
||||||
shader->start_using();
|
|
||||||
shader->set_uniform("emission_factor", 0.1f);
|
|
||||||
|
|
||||||
const Camera& camera = wxGetApp().plater()->get_camera();
|
|
||||||
const Transform3d& view_matrix = camera.get_view_matrix();
|
|
||||||
Transform3d model_matrix = Geometry::assemble_transform(m_grabbers[axis].center);
|
|
||||||
if (axis == X)
|
|
||||||
model_matrix = model_matrix * Geometry::assemble_transform(Vec3d::Zero(), 0.5 * PI * Vec3d::UnitY());
|
|
||||||
else if (axis == Y)
|
|
||||||
model_matrix = model_matrix * Geometry::assemble_transform(Vec3d::Zero(), -0.5 * PI * Vec3d::UnitX());
|
|
||||||
model_matrix = model_matrix * Geometry::assemble_transform(Vec3d::Zero(), Vec3d::Zero(), Vec3d(0.75 * size, 0.75 * size, 2.0 * size));
|
|
||||||
|
|
||||||
shader->set_uniform("view_model_matrix", view_matrix * model_matrix);
|
|
||||||
shader->set_uniform("projection_matrix", camera.get_projection_matrix());
|
|
||||||
const Matrix3d view_normal_matrix = view_matrix.matrix().block(0, 0, 3, 3) * model_matrix.matrix().block(0, 0, 3, 3).inverse().transpose();
|
|
||||||
shader->set_uniform("view_normal_matrix", view_normal_matrix);
|
|
||||||
m_cone.render();
|
|
||||||
|
|
||||||
shader->stop_using();
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace GUI
|
} // namespace GUI
|
||||||
} // namespace Slic3r
|
} // namespace Slic3r
|
||||||
|
|
|
@ -21,7 +21,6 @@ class GLGizmoMove3D : public GLGizmoBase
|
||||||
Vec3d m_starting_box_center{ Vec3d::Zero() };
|
Vec3d m_starting_box_center{ Vec3d::Zero() };
|
||||||
Vec3d m_starting_box_bottom_center{ Vec3d::Zero() };
|
Vec3d m_starting_box_bottom_center{ Vec3d::Zero() };
|
||||||
|
|
||||||
GLModel m_cone;
|
|
||||||
struct GrabberConnection
|
struct GrabberConnection
|
||||||
{
|
{
|
||||||
GLModel model;
|
GLModel model;
|
||||||
|
@ -59,7 +58,6 @@ protected:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
double calc_projection(const UpdateData& data) const;
|
double calc_projection(const UpdateData& data) const;
|
||||||
void render_grabber_extension(Axis axis, const BoundingBoxf3& box, bool picking);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -53,8 +53,8 @@ std::string GLGizmoRotate::get_tooltip() const
|
||||||
|
|
||||||
bool GLGizmoRotate::on_init()
|
bool GLGizmoRotate::on_init()
|
||||||
{
|
{
|
||||||
m_cone.init_from(its_make_cone(1., 1., 2 * PI / 24));
|
|
||||||
m_grabbers.push_back(Grabber());
|
m_grabbers.push_back(Grabber());
|
||||||
|
m_grabbers.back().extensions = (GLGizmoBase::EGrabberExtension)(int(GLGizmoBase::EGrabberExtension::PosY) | int(GLGizmoBase::EGrabberExtension::NegY));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,7 +159,6 @@ void GLGizmoRotate::on_render()
|
||||||
}
|
}
|
||||||
|
|
||||||
render_grabber(box);
|
render_grabber(box);
|
||||||
render_grabber_extension(box, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLGizmoRotate::on_render_for_picking()
|
void GLGizmoRotate::on_render_for_picking()
|
||||||
|
@ -172,7 +171,6 @@ void GLGizmoRotate::on_render_for_picking()
|
||||||
|
|
||||||
const BoundingBoxf3& box = selection.get_bounding_box();
|
const BoundingBoxf3& box = selection.get_bounding_box();
|
||||||
render_grabbers_for_picking(box);
|
render_grabbers_for_picking(box);
|
||||||
render_grabber_extension(box, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//BBS: add input window for move
|
//BBS: add input window for move
|
||||||
|
@ -390,49 +388,6 @@ void GLGizmoRotate::render_grabber(const BoundingBoxf3& box)
|
||||||
render_grabbers(box);
|
render_grabbers(box);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLGizmoRotate::render_grabber_extension(const BoundingBoxf3& box, bool picking)
|
|
||||||
{
|
|
||||||
const double size = 0.75 * GLGizmoBase::Grabber::FixedGrabberSize * GLGizmoBase::INV_ZOOM;
|
|
||||||
//float mean_size = (float)((box.size()(0) + box.size()(1) + box.size()(2)) / 3.0);
|
|
||||||
//double size = m_dragging ? (double)m_grabbers[0].get_dragging_half_size(mean_size) : (double)m_grabbers[0].get_half_size(mean_size);
|
|
||||||
|
|
||||||
ColorRGBA color = m_grabbers.front().color;
|
|
||||||
if (!picking && m_hover_id != -1)
|
|
||||||
color = m_grabbers.front().hover_color;
|
|
||||||
|
|
||||||
GLShaderProgram* shader = wxGetApp().get_shader(picking ? "flat" : "gouraud_light");
|
|
||||||
if (shader == nullptr)
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_cone.set_color(color);
|
|
||||||
|
|
||||||
shader->start_using();
|
|
||||||
shader->set_uniform("emission_factor", 0.1f);
|
|
||||||
|
|
||||||
const Vec3d& center = m_grabbers.front().center;
|
|
||||||
|
|
||||||
const Camera& camera = wxGetApp().plater()->get_camera();
|
|
||||||
const Transform3d& view_matrix = camera.get_view_matrix();
|
|
||||||
shader->set_uniform("projection_matrix", camera.get_projection_matrix());
|
|
||||||
|
|
||||||
Transform3d model_matrix = m_grabbers.front().matrix * Geometry::assemble_transform(center, Vec3d(0.5 * PI, 0.0, m_angle)) *
|
|
||||||
Geometry::assemble_transform(2.0 * size * Vec3d::UnitZ(), Vec3d::Zero(), Vec3d(0.75 * size, 0.75 * size, 3.0 * size));
|
|
||||||
|
|
||||||
shader->set_uniform("view_model_matrix", view_matrix * model_matrix);
|
|
||||||
Matrix3d view_normal_matrix = view_matrix.matrix().block(0, 0, 3, 3) * model_matrix.matrix().block(0, 0, 3, 3).inverse().transpose();
|
|
||||||
shader->set_uniform("view_normal_matrix", view_normal_matrix);
|
|
||||||
m_cone.render();
|
|
||||||
model_matrix = m_grabbers.front().matrix * Geometry::assemble_transform(center, Vec3d(-0.5 * PI, 0.0, m_angle)) *
|
|
||||||
Geometry::assemble_transform(2.0 * size * Vec3d::UnitZ(), Vec3d::Zero(), Vec3d(0.75 * size, 0.75 * size, 3.0 * size));
|
|
||||||
|
|
||||||
shader->set_uniform("view_model_matrix", view_matrix * model_matrix);
|
|
||||||
view_normal_matrix = view_matrix.matrix().block(0, 0, 3, 3) * model_matrix.matrix().block(0, 0, 3, 3).inverse().transpose();
|
|
||||||
shader->set_uniform("view_normal_matrix", view_normal_matrix);
|
|
||||||
m_cone.render();
|
|
||||||
|
|
||||||
shader->stop_using();
|
|
||||||
}
|
|
||||||
|
|
||||||
Transform3d GLGizmoRotate::local_transform(const Selection& selection) const
|
Transform3d GLGizmoRotate::local_transform(const Selection& selection) const
|
||||||
{
|
{
|
||||||
Transform3d ret;
|
Transform3d ret;
|
||||||
|
|
|
@ -40,7 +40,6 @@ private:
|
||||||
float m_snap_fine_in_radius{ 0.0f };
|
float m_snap_fine_in_radius{ 0.0f };
|
||||||
float m_snap_fine_out_radius{ 0.0f };
|
float m_snap_fine_out_radius{ 0.0f };
|
||||||
|
|
||||||
GLModel m_cone;
|
|
||||||
GLModel m_circle;
|
GLModel m_circle;
|
||||||
GLModel m_scale;
|
GLModel m_scale;
|
||||||
GLModel m_snap_radii;
|
GLModel m_snap_radii;
|
||||||
|
@ -83,7 +82,6 @@ private:
|
||||||
void render_angle_arc(const ColorRGBA& color, bool radius_changed);
|
void render_angle_arc(const ColorRGBA& color, bool radius_changed);
|
||||||
void render_grabber_connection(const ColorRGBA& color, bool radius_changed);
|
void render_grabber_connection(const ColorRGBA& color, bool radius_changed);
|
||||||
void render_grabber(const BoundingBoxf3& box);
|
void render_grabber(const BoundingBoxf3& box);
|
||||||
void render_grabber_extension(const BoundingBoxf3& box, bool picking);
|
|
||||||
|
|
||||||
Transform3d local_transform(const Selection& selection) const;
|
Transform3d local_transform(const Selection& selection) const;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue