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
5941405e
Commit
5941405e
authored
Mar 25, 2021
by
allai5
Browse files
Merge branch 'master' of
https://github.com/CMU-Graphics/Scotty3D
parents
519bc2c1
8ddfb4bf
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/geometry/halfedge.cpp
View file @
5941405e
...
...
@@ -557,7 +557,7 @@ bool Halfedge_Mesh::subdivide(SubD strategy) {
Index
idx
=
0
;
size_t
nV
=
vertices
.
size
();
size_t
nE
=
edges
.
size
();
size_t
nF
=
faces
.
size
();
size_t
nF
=
faces
.
size
()
-
n_boundaries
()
;
verts
.
resize
(
nV
+
nE
+
nF
);
for
(
VertexRef
v
=
vertices_begin
();
v
!=
vertices_end
();
v
++
,
idx
++
)
{
...
...
@@ -568,12 +568,15 @@ bool Halfedge_Mesh::subdivide(SubD strategy) {
verts
[
idx
]
=
e
->
new_pos
;
layout
[
e
->
id
()]
=
idx
;
}
for
(
FaceRef
f
=
faces_begin
();
f
!=
faces_end
();
f
++
,
idx
++
)
{
for
(
FaceRef
f
=
faces_begin
();
f
!=
faces_end
();
f
++
)
{
if
(
f
->
is_boundary
())
continue
;
verts
[
idx
]
=
f
->
new_pos
;
layout
[
f
->
id
()]
=
idx
;
idx
++
;
}
for
(
auto
f
=
faces_begin
();
f
!=
faces_end
();
f
++
)
{
if
(
f
->
is_boundary
())
continue
;
Index
i
=
layout
[
f
->
id
()];
HalfedgeRef
h
=
f
->
halfedge
();
do
{
...
...
src/geometry/util.cpp
View file @
5941405e
...
...
@@ -200,24 +200,32 @@ Data cone(float bradius, float tradius, float height, int sides, bool caps) {
size_t
vert
=
0
;
vertices
[
vert
++
]
=
Vec3
(
0.0
f
,
0.0
f
,
0.0
f
);
float
t
=
0.0
f
;
float
step
=
_2pi
/
n_sides
;
while
(
vert
<=
n_sides
)
{
float
rad
=
(
float
)
vert
/
n_sides
*
_2pi
;
vertices
[
vert
]
=
Vec3
(
std
::
cos
(
rad
)
*
bradius
,
0.0
f
,
std
::
sin
(
rad
)
*
bradius
);
vertices
[
vert
]
=
Vec3
(
std
::
cos
(
t
)
*
bradius
,
0.0
f
,
std
::
sin
(
t
)
*
bradius
);
vert
++
;
t
+=
step
;
}
vertices
[
vert
++
]
=
Vec3
(
0.0
f
,
height
,
0.0
f
);
t
=
0.0
f
;
while
(
vert
<=
n_sides
*
2
+
1
)
{
float
rad
=
(
float
)(
vert
-
n_sides
-
1
)
/
n_sides
*
_2pi
;
vertices
[
vert
]
=
Vec3
(
std
::
cos
(
rad
)
*
tradius
,
height
,
std
::
sin
(
rad
)
*
tradius
);
vertices
[
vert
]
=
Vec3
(
std
::
cos
(
t
)
*
tradius
,
height
,
std
::
sin
(
t
)
*
tradius
);
vert
++
;
t
+=
step
;
}
size_t
v
=
0
;
t
=
0.0
f
;
while
(
vert
<=
vertices
.
size
()
-
4
)
{
float
rad
=
(
float
)
v
/
n_sides
*
_2pi
;
vertices
[
vert
]
=
Vec3
(
std
::
cos
(
rad
)
*
tradius
,
height
,
std
::
sin
(
rad
)
*
tradius
);
vertices
[
vert
+
1
]
=
Vec3
(
std
::
cos
(
rad
)
*
bradius
,
0.0
f
,
std
::
sin
(
rad
)
*
bradius
);
vertices
[
vert
]
=
Vec3
(
std
::
cos
(
t
)
*
tradius
,
height
,
std
::
sin
(
t
)
*
tradius
);
vertices
[
vert
+
1
]
=
Vec3
(
std
::
cos
(
t
)
*
bradius
,
0.0
f
,
std
::
sin
(
t
)
*
bradius
);
vert
+=
2
;
v
++
;
t
+=
step
;
}
vertices
[
vert
]
=
vertices
[
n_sides
*
2
+
2
];
vertices
[
vert
+
1
]
=
vertices
[
n_sides
*
2
+
3
];
...
...
src/gui/model.cpp
View file @
5941405e
...
...
@@ -253,7 +253,7 @@ void Model::edge_viz(Halfedge_Mesh::EdgeRef e, Mat4& transform) {
float
v0s
=
vert_sizes
[
v_0
->
id
()],
v1s
=
vert_sizes
[
v_1
->
id
()];
float
s
=
0.5
f
*
std
::
min
(
v0s
,
v1s
);
if
(
dir
.
y
==
1.0
f
||
dir
.
y
==
-
1.0
f
)
{
if
(
1.0
f
-
std
::
abs
(
dir
.
y
)
<
EPS_F
)
{
l
*=
sign
(
dir
.
y
);
transform
=
Mat4
{
Vec4
{
s
,
0.0
f
,
0.0
f
,
0.0
f
},
Vec4
{
0.0
f
,
l
,
0.0
f
,
0.0
f
},
Vec4
{
0.0
f
,
0.0
f
,
s
,
0.0
f
},
Vec4
{
v0
,
1.0
f
}};
...
...
@@ -381,6 +381,16 @@ void Model::rebuild() {
// Create cylinder for each edge
cylinders
.
clear
();
for
(
auto
e
=
mesh
.
edges_begin
();
e
!=
mesh
.
edges_end
();
e
++
)
{
// We don't want to render edges between two boundary faces, since the boundaries
// should look contiguous
if
(
e
->
halfedge
()
->
is_boundary
()
&&
e
->
halfedge
()
->
twin
()
->
is_boundary
())
{
// Unless both surrounding boundaries are the same face, in which case we should
// render this edge to show that the next vertex is connected
if
(
e
->
halfedge
()
->
face
()
!=
e
->
halfedge
()
->
twin
()
->
face
())
continue
;
}
Mat4
transform
;
edge_viz
(
e
,
transform
);
...
...
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