mirror of
https://git.mirrors.martin98.com/https://github.com/bambulab/BambuStudio.git
synced 2025-09-20 05:43:14 +08:00
FIX:Maintain good perspective effect
Non user versions can view debugging information through shortcut keys jira: none Change-Id: I251a6189e8909f4c52752827e359a7287bd15f7f
This commit is contained in:
parent
70a7e837d4
commit
5925b220d5
@ -11,7 +11,7 @@
|
||||
// Renders a small sphere in the center of the bounding box of the current selection when no gizmo is active
|
||||
#define ENABLE_RENDER_SELECTION_CENTER 0
|
||||
// Shows an imgui dialog with camera related data
|
||||
#define ENABLE_CAMERA_STATISTICS 0
|
||||
//#define ENABLE_CAMERA_STATISTICS 0// by ctrl +shift +space quick key
|
||||
// Render the picking pass instead of the main scene (use [T] key to toggle between regular rendering and picking pass only rendering)
|
||||
#define ENABLE_RENDER_PICKING_PASS 0
|
||||
// Enable extracting thumbnails from selected gcode and save them as png files
|
||||
@ -22,7 +22,7 @@
|
||||
#define ENABLE_NONCUSTOM_DATA_VIEW_RENDERING 0
|
||||
// Enable G-Code viewer statistics imgui dialog
|
||||
#define ENABLE_GCODE_VIEWER_STATISTICS 0
|
||||
// Enable G-Code viewer comparison between toolpaths height and width detected from gcode and calculated at gcode generation
|
||||
// Enable G-Code viewer comparison between toolpaths height and width detected from gcode and calculated at gcode generation
|
||||
#define ENABLE_GCODE_VIEWER_DATA_CHECKING 0
|
||||
// Enable project dirty state manager debug window
|
||||
#define ENABLE_PROJECT_DIRTY_STATE_DEBUG_WINDOW 0
|
||||
|
@ -3,10 +3,9 @@
|
||||
|
||||
#include "Camera.hpp"
|
||||
#include "GUI_App.hpp"
|
||||
#if ENABLE_CAMERA_STATISTICS
|
||||
|
||||
#include "Mouse3DController.hpp"
|
||||
#include "Plater.hpp"
|
||||
#endif // ENABLE_CAMERA_STATISTICS
|
||||
|
||||
#include <GL/glew.h>
|
||||
|
||||
@ -380,7 +379,6 @@ void Camera::zoom_to_volumes(const GLVolumePtrs& volumes, double margin_factor)
|
||||
}
|
||||
}
|
||||
|
||||
#if ENABLE_CAMERA_STATISTICS
|
||||
void Camera::debug_render()
|
||||
{
|
||||
ImGuiWrapper& imgui = *wxGetApp().imgui();
|
||||
@ -435,7 +433,6 @@ void Camera::debug_render()
|
||||
ImGui::InputFloat("GUI scale", &gui_scale, 0.0f, 0.0f, "%.6f", ImGuiInputTextFlags_ReadOnly);
|
||||
imgui.end();
|
||||
}
|
||||
#endif // ENABLE_CAMERA_STATISTICS
|
||||
|
||||
void Camera::rotate_on_sphere_with_target(double delta_azimut_rad, double delta_zenit_rad, bool apply_limits, Vec3d target)
|
||||
{
|
||||
@ -524,7 +521,7 @@ std::pair<double, double> Camera::calc_tight_frustrum_zs_around(const BoundingBo
|
||||
{
|
||||
std::pair<double, double> ret;
|
||||
auto& [near_z, far_z] = ret;
|
||||
|
||||
m_scene_box_radius = box.radius();
|
||||
// box in eye space
|
||||
const BoundingBoxf3 eye_box = box.transformed(m_view_matrix);
|
||||
near_z = -eye_box.max(2);
|
||||
@ -544,8 +541,15 @@ std::pair<double, double> Camera::calc_tight_frustrum_zs_around(const BoundingBo
|
||||
|
||||
if (near_z < FrustrumMinNearZ) {
|
||||
const double delta = FrustrumMinNearZ - near_z;
|
||||
set_distance(m_distance + delta);
|
||||
m_last_scene_box_radius = m_scene_box_radius;
|
||||
near_z += delta;
|
||||
far_z += delta;
|
||||
} else {
|
||||
if (abs(m_last_scene_box_radius - m_scene_box_radius) > 1) {
|
||||
m_last_scene_box_radius = m_scene_box_radius;
|
||||
set_distance(DefaultDistance);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
@ -608,6 +612,16 @@ double Camera::calc_zoom_to_bounding_box_factor(const BoundingBoxf3& box, double
|
||||
return std::min((double)m_viewport[2] / dx, (double)m_viewport[3] / dy);
|
||||
}
|
||||
|
||||
void Camera::set_distance(double distance)
|
||||
{
|
||||
if (m_distance != distance) {
|
||||
m_view_matrix.translate((distance - m_distance) * get_dir_forward());
|
||||
m_distance = distance;
|
||||
|
||||
update_target();
|
||||
}
|
||||
}
|
||||
|
||||
double Camera::calc_zoom_to_volumes_factor(const GLVolumePtrs& volumes, Vec3d& center, double margin_factor) const
|
||||
{
|
||||
if (volumes.empty())
|
||||
|
@ -56,6 +56,8 @@ private:
|
||||
std::pair<double, double> m_frustrum_zs;
|
||||
|
||||
BoundingBoxf3 m_scene_box;
|
||||
float m_scene_box_radius{0};
|
||||
float m_last_scene_box_radius{0};
|
||||
Frustum m_frustum;
|
||||
Vec3f m_last_eye, m_last_center, m_last_up;
|
||||
float m_last_near, m_last_far, m_last_aspect, m_last_fov,m_last_zoom;
|
||||
@ -122,9 +124,7 @@ public:
|
||||
void zoom_to_box(const BoundingBoxf3& box, double margin_factor = DefaultZoomToBoxMarginFactor);
|
||||
void zoom_to_volumes(const GLVolumePtrs& volumes, double margin_factor = DefaultZoomToVolumesMarginFactor);
|
||||
void debug_frustum();
|
||||
#if ENABLE_CAMERA_STATISTICS
|
||||
void debug_render();
|
||||
#endif // ENABLE_CAMERA_STATISTICS
|
||||
|
||||
// translate the camera in world space
|
||||
void translate_world(const Vec3d& displacement) { set_target(m_target + displacement); }
|
||||
@ -164,6 +164,7 @@ private:
|
||||
std::pair<double, double> calc_tight_frustrum_zs_around(const BoundingBoxf3& box);
|
||||
double calc_zoom_to_bounding_box_factor(const BoundingBoxf3& box, double margin_factor = DefaultZoomToBoxMarginFactor) const;
|
||||
double calc_zoom_to_volumes_factor(const GLVolumePtrs& volumes, Vec3d& center, double margin_factor = DefaultZoomToVolumesMarginFactor) const;
|
||||
void set_distance(double distance);
|
||||
|
||||
void set_default_orientation();
|
||||
void set_iso_orientation();
|
||||
|
@ -2037,9 +2037,10 @@ void GLCanvas3D::render(bool only_init)
|
||||
wxGetApp().plater()->render_project_state_debug_window();
|
||||
#endif // ENABLE_PROJECT_DIRTY_STATE_DEBUG_WINDOW
|
||||
|
||||
#if ENABLE_CAMERA_STATISTICS
|
||||
camera.debug_render();
|
||||
#endif // ENABLE_CAMERA_STATISTICS
|
||||
if (wxGetApp().plater()->is_render_statistic_dialog_visible()) {
|
||||
camera.debug_render();
|
||||
camera.debug_frustum();
|
||||
}
|
||||
|
||||
#if ENABLE_IMGUI_STYLE_EDITOR
|
||||
if (wxGetApp().get_mode() == ConfigOptionMode::comDevelop)
|
||||
|
Loading…
x
Reference in New Issue
Block a user