Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Courses
Scotty3D
Commits
9bc17c6e
Commit
9bc17c6e
authored
Oct 08, 2020
by
TheNumbat
Browse files
add halfedge element viz min size
parent
bac3824a
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/gui/manager.cpp
View file @
9bc17c6e
...
...
@@ -561,9 +561,10 @@ void Manager::UInew_light(Scene &scene, Undo &undo) {
unsigned
int
idx
=
0
;
ImGui
::
SetNextWindowSizeConstraints
({
200.0
f
,
0.0
f
},
{
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.0
f
);
static
float
intensity
=
1.0
f
;
...
...
@@ -705,6 +706,7 @@ void Manager::UInew_obj(Undo &undo) {
new_obj_window
=
false
;
};
ImGui
::
SetNextWindowSizeConstraints
({
200.0
f
,
0.0
f
},
{
FLT_MAX
,
FLT_MAX
});
ImGui
::
Begin
(
"New Object"
,
&
new_obj_window
,
ImGuiWindowFlags_NoResize
|
ImGuiWindowFlags_NoScrollbar
|
ImGuiWindowFlags_NoCollapse
|
ImGuiWindowFlags_AlwaysAutoResize
);
...
...
src/gui/model.cpp
View file @
9bc17c6e
...
...
@@ -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.0
f
;
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.0
f
?
d
:
2.0
f
;
avg
=
avg
/
d
;
size
=
clamp
(
min
,
avg
/
10.0
f
,
avg
);
transform
=
Mat4
{
Vec4
{
size
,
0.0
f
,
0.0
f
,
0.0
f
},
Vec4
{
0.0
f
,
size
,
0.0
f
,
0.0
f
},
Vec4
{
0.0
f
,
0.0
f
,
size
,
0.0
f
},
Vec4
{
v
->
pos
,
1.0
f
}};
}
...
...
@@ -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
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment