Commit 9bc17c6e authored by TheNumbat's avatar TheNumbat
Browse files

add halfedge element viz min size

parent bac3824a
...@@ -561,6 +561,7 @@ void Manager::UInew_light(Scene &scene, Undo &undo) { ...@@ -561,6 +561,7 @@ void Manager::UInew_light(Scene &scene, Undo &undo) {
unsigned int idx = 0; unsigned int idx = 0;
ImGui::SetNextWindowSizeConstraints({200.0f, 0.0f}, {FLT_MAX,FLT_MAX});
ImGui::Begin("New Light", &new_light_window, ImGui::Begin("New Light", &new_light_window,
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoScrollbar |
ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_AlwaysAutoResize); ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_AlwaysAutoResize);
...@@ -705,6 +706,7 @@ void Manager::UInew_obj(Undo &undo) { ...@@ -705,6 +706,7 @@ void Manager::UInew_obj(Undo &undo) {
new_obj_window = false; new_obj_window = false;
}; };
ImGui::SetNextWindowSizeConstraints({200.0f, 0.0f}, {FLT_MAX,FLT_MAX});
ImGui::Begin("New Object", &new_obj_window, ImGui::Begin("New Object", &new_obj_window,
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoScrollbar |
ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_AlwaysAutoResize); ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_AlwaysAutoResize);
......
...@@ -220,17 +220,23 @@ void Model::unset_mesh() { my_mesh = nullptr; } ...@@ -220,17 +220,23 @@ void Model::unset_mesh() { my_mesh = nullptr; }
void Model::vertex_viz(Halfedge_Mesh::VertexRef v, float &size, Mat4 &transform) { void Model::vertex_viz(Halfedge_Mesh::VertexRef v, float &size, Mat4 &transform) {
// Sphere size ~ 0.05 * min incident edge length // Sphere size ~ 0.05 * min incident edge length
float d = FLT_MAX; float min = FLT_MAX;
float avg = 0.0f;
size_t d = 0;
auto he = v->halfedge(); auto he = v->halfedge();
do { do {
Vec3 n = he->twin()->vertex()->pos; Vec3 n = he->twin()->vertex()->pos;
float e = (n - v->pos).norm_squared(); float len = he->edge()->length();
d = d < e ? d : e; min = std::min(min, len);
avg += len;
d++;
he = he->twin()->next(); he = he->twin()->next();
} while (he != v->halfedge()); } while (he != v->halfedge());
d = std::sqrt(d); avg = avg / d;
size = d < 2.0f ? d : 2.0f; size = clamp(min, avg / 10.0f, avg);
transform = Mat4{Vec4{size, 0.0f, 0.0f, 0.0f}, Vec4{0.0f, size, 0.0f, 0.0f}, transform = Mat4{Vec4{size, 0.0f, 0.0f, 0.0f}, Vec4{0.0f, size, 0.0f, 0.0f},
Vec4{0.0f, 0.0f, size, 0.0f}, Vec4{v->pos, 1.0f}}; Vec4{0.0f, 0.0f, size, 0.0f}, Vec4{v->pos, 1.0f}};
} }
...@@ -864,6 +870,7 @@ std::string Model::select(Widgets &widgets, Scene_ID click, Vec3 cam, Vec2 spos, ...@@ -864,6 +870,7 @@ std::string Model::select(Widgets &widgets, Scene_ID click, Vec3 cam, Vec2 spos,
return err; return err;
} else { } else {
widgets.start_drag(Halfedge_Mesh::center_of(selected_element().value()), cam, spos, dir); widgets.start_drag(Halfedge_Mesh::center_of(selected_element().value()), cam, spos, dir);
apply_transform(widgets);
} }
} else if (!widgets.is_dragging() && click >= n_Widget_IDs) { } else if (!widgets.is_dragging() && click >= n_Widget_IDs) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment