Small optimizations in rendering functions
This commit is contained in:
parent
a167d43c1d
commit
aa83b20b8e
@ -385,8 +385,10 @@ void GLVolume::render()
|
||||
GLShaderProgram* shader = GUI::wxGetApp().get_current_shader();
|
||||
if (shader == nullptr)
|
||||
return;
|
||||
|
||||
const bool is_left_handed = this->is_left_handed();
|
||||
|
||||
if (this->is_left_handed())
|
||||
if (is_left_handed)
|
||||
glsafe(::glFrontFace(GL_CW));
|
||||
glsafe(::glCullFace(GL_BACK));
|
||||
|
||||
@ -395,7 +397,7 @@ void GLVolume::render()
|
||||
else
|
||||
model.render(this->tverts_range);
|
||||
|
||||
if (this->is_left_handed())
|
||||
if (is_left_handed)
|
||||
glsafe(::glFrontFace(GL_CCW));
|
||||
}
|
||||
|
||||
@ -793,6 +795,7 @@ void GLVolumeCollection::render(GLVolumeCollection::ERenderType type, bool disab
|
||||
glsafe(::glDisable(GL_CULL_FACE));
|
||||
|
||||
for (GLVolumeWithIdAndZ& volume : to_render) {
|
||||
const Transform3d& world_matrix = volume.first->world_matrix();
|
||||
volume.first->set_render_color(true);
|
||||
|
||||
// render sinking contours of non-hovered volumes
|
||||
@ -814,9 +817,9 @@ void GLVolumeCollection::render(GLVolumeCollection::ERenderType type, bool disab
|
||||
shader->set_uniform("print_volume.type", static_cast<int>(m_print_volume.type));
|
||||
shader->set_uniform("print_volume.xy_data", m_print_volume.data);
|
||||
shader->set_uniform("print_volume.z_data", m_print_volume.zs);
|
||||
shader->set_uniform("volume_world_matrix", volume.first->world_matrix());
|
||||
shader->set_uniform("volume_world_matrix", world_matrix);
|
||||
shader->set_uniform("slope.actived", m_slope.active && !volume.first->is_modifier && !volume.first->is_wipe_tower);
|
||||
shader->set_uniform("slope.volume_world_normal_matrix", static_cast<Matrix3f>(volume.first->world_matrix().matrix().block(0, 0, 3, 3).inverse().transpose().cast<float>()));
|
||||
shader->set_uniform("slope.volume_world_normal_matrix", static_cast<Matrix3f>(world_matrix.matrix().block(0, 0, 3, 3).inverse().transpose().cast<float>()));
|
||||
shader->set_uniform("slope.normal_z", m_slope.normal_z);
|
||||
|
||||
#if ENABLE_ENVIRONMENT_MAP
|
||||
@ -829,7 +832,7 @@ void GLVolumeCollection::render(GLVolumeCollection::ERenderType type, bool disab
|
||||
glcheck();
|
||||
|
||||
volume.first->model.set_color(volume.first->render_color);
|
||||
const Transform3d model_matrix = volume.first->world_matrix();
|
||||
const Transform3d model_matrix = world_matrix;
|
||||
shader->set_uniform("view_model_matrix", view_matrix * model_matrix);
|
||||
shader->set_uniform("projection_matrix", 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();
|
||||
|
@ -818,8 +818,11 @@ static float get_cursor_height()
|
||||
void GLCanvas3D::Tooltip::set_text(const std::string& text)
|
||||
{
|
||||
// If the mouse is inside an ImGUI dialog, then the tooltip is suppressed.
|
||||
m_text = m_in_imgui ? std::string() : text;
|
||||
m_cursor_height = get_cursor_height();
|
||||
const std::string& new_text = m_in_imgui ? std::string() : text;
|
||||
if (m_text != new_text) { // To avoid calling the expensive call to get_cursor_height.
|
||||
m_text = new_text;
|
||||
m_cursor_height = get_cursor_height();
|
||||
}
|
||||
}
|
||||
|
||||
void GLCanvas3D::Tooltip::render(const Vec2d& mouse_position, GLCanvas3D& canvas)
|
||||
|
Loading…
Reference in New Issue
Block a user