ENH:If triangular facets count is small,it donot enable lod

jira: none
Change-Id: Ie87b4b07d928760e04e9ef271224ffc5e6f41957
This commit is contained in:
zhou.xu 2024-09-27 17:49:41 +08:00 committed by Lane.Wei
parent 0c772105f9
commit 71e6705ce9
1 changed files with 6 additions and 1 deletions

View File

@ -424,7 +424,7 @@ float GLVolume::LAST_CAMERA_ZOOM_VALUE = 0.0f;
const float ZOOM_THRESHOLD = 0.3f; const float ZOOM_THRESHOLD = 0.3f;
const unsigned char LOD_UPDATE_FREQUENCY = 20; const unsigned char LOD_UPDATE_FREQUENCY = 20;
const Vec2i LOD_SCREEN_MIN = Vec2i(45, 35); const Vec2i LOD_SCREEN_MIN = Vec2i(45, 35);
const Vec2i LOD_SCREEN_MAX = Vec2i(70, 55); const Vec2i LOD_SCREEN_MAX = Vec2i(65, 55);
Vec2f calc_pt_in_screen(const Vec3d &pt, const Transform3d &world_tran, const Matrix4d &view_proj_mat, int window_width, int window_height) Vec2f calc_pt_in_screen(const Vec3d &pt, const Transform3d &world_tran, const Matrix4d &view_proj_mat, int window_width, int window_height)
{ {
@ -672,6 +672,7 @@ bool GLVolume::simplify_mesh(const indexed_triangle_set &_its, GLIndexedVertexAr
state->result.reset(); state->result.reset();
state->status = State::Status::running; state->status = State::Status::running;
} }
int init_face_count = its->indices.size();
TriangleMesh origin_mesh(*its); TriangleMesh origin_mesh(*its);
try { // Start the actual calculation. try { // Start the actual calculation.
its_quadric_edge_collapse(*its, triangle_count, &max_error, throw_on_cancel, statusfn); its_quadric_edge_collapse(*its, triangle_count, &max_error, throw_on_cancel, statusfn);
@ -684,6 +685,10 @@ bool GLVolume::simplify_mesh(const indexed_triangle_set &_its, GLIndexedVertexAr
state->result = std::move(its); state->result = std::move(its);
} }
if (state->result) { if (state->result) {
int end_face_count = (*state->result).indices.size();
if (init_face_count < 200 || (init_face_count < 1000 && end_face_count < init_face_count * 0.5)) {
return;
}
TriangleMesh mesh(*state->result); TriangleMesh mesh(*state->result);
float eps = 1.0f; float eps = 1.0f;
Vec3f origin_min = origin_mesh.stats().min - Vec3f(eps, eps, eps); Vec3f origin_min = origin_mesh.stats().min - Vec3f(eps, eps, eps);