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

add halfedge element viz min size

parent bac3824a
......@@ -561,9 +561,10 @@ void Manager::UInew_light(Scene &scene, Undo &undo) {
unsigned int idx = 0;
ImGui::SetNextWindowSizeConstraints({200.0f, 0.0f}, {FLT_MAX,FLT_MAX});
ImGui::Begin("New Light", &new_light_window,
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoScrollbar |
ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_AlwaysAutoResize);
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoScrollbar |
ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_AlwaysAutoResize);
static Spectrum color = Spectrum(1.0f);
static float intensity = 1.0f;
......@@ -705,6 +706,7 @@ void Manager::UInew_obj(Undo &undo) {
new_obj_window = false;
};
ImGui::SetNextWindowSizeConstraints({200.0f, 0.0f}, {FLT_MAX,FLT_MAX});
ImGui::Begin("New Object", &new_obj_window,
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoScrollbar |
ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_AlwaysAutoResize);
......
......@@ -220,17 +220,23 @@ void Model::unset_mesh() { my_mesh = nullptr; }
void Model::vertex_viz(Halfedge_Mesh::VertexRef v, float &size, Mat4 &transform) {
// 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();
do {
Vec3 n = he->twin()->vertex()->pos;
float e = (n - v->pos).norm_squared();
d = d < e ? d : e;
float len = he->edge()->length();
min = std::min(min, len);
avg += len;
d++;
he = he->twin()->next();
} while (he != v->halfedge());
d = std::sqrt(d);
size = d < 2.0f ? d : 2.0f;
avg = avg / d;
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},
Vec4{0.0f, 0.0f, size, 0.0f}, Vec4{v->pos, 1.0f}};
}
......@@ -361,7 +367,7 @@ void Model::rebuild() {
std::vector<GL::Mesh::Vert> verts;
std::vector<GL::Mesh::Index> idxs;
for (auto f = mesh.faces_begin(); f != mesh.faces_end(); f++) {
face_viz(f, verts, idxs, verts.size());
}
......@@ -864,6 +870,7 @@ std::string Model::select(Widgets &widgets, Scene_ID click, Vec3 cam, Vec2 spos,
return err;
} else {
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) {
......
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