Skip to content

Commit d39d1dc

Browse files
committed
cleanup normal gen and export face_normals
1 parent d679449 commit d39d1dc

File tree

3 files changed

+4
-15
lines changed

3 files changed

+4
-15
lines changed

src/GeometryBasics.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export AbstractFace, TriangleFace, QuadFace, GLTriangleFace
4141
export OffsetInteger, ZeroIndex, OneIndex, GLIndex
4242
export decompose, coordinates, faces, normals, decompose_uv, decompose_normals,
4343
texturecoordinates, vertex_attributes
44+
export face_normals
4445
export Tesselation, Normal, UV, UVW
4546
export AbstractMesh, Mesh, MetaMesh, FaceView
4647

src/geometry_primitives.jl

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,6 @@ function normals(vertices::AbstractVector{Point{3,T}}, faces::AbstractVector{F};
160160
return normals(vertices, faces, normaltype)
161161
end
162162

163-
function normals(primitive::GeometryPrimitive{3, T}; normaltype=Vec{3,T}) where {T}
164-
return normals(coordinates(primitive), faces(primitive), normaltype)
165-
end
166-
167163
function normals(vertices::AbstractVector{<:Point{3}}, faces::AbstractVector{F},
168164
::Type{NormalType}) where {F<:NgonFace,NormalType}
169165

@@ -185,17 +181,9 @@ end
185181
"""
186182
face_normals(positions::Vector{Point3{T}}, faces::Vector{<: NgonFace}[, target_type = Vec3{T}])
187183
188-
Compute vertex normals from the given `positions` and `faces`.
189-
190-
This runs through all faces, computing a face normal each and adding it to every
191-
involved vertex. The direction of the face normal is based on winding direction
192-
and assumed counter-clockwise faces. At the end the summed face normals are
193-
normalized again to produce a vertex normal.
184+
Compute face normals from the given `positions` and `faces` and returns an
185+
appropriate `FaceView`.
194186
"""
195-
function face_normals(primitive::GeometryPrimitive{3, T}; normaltype = Vec{3, T}) where {T}
196-
return face_normals(coordinates(primitive), faces(primitive), normaltype)
197-
end
198-
199187
function face_normals(
200188
positions::AbstractVector{<:Point3{T}}, fs::AbstractVector{<: AbstractFace};
201189
normaltype = Vec3{T}) where {T}

test/runtests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ end
298298
@testset "Face normals" begin
299299
r = Rect3f(Point3f(0), Vec3f(1))
300300
ns = normals(r)
301-
@test GeometryBasics.face_normals(r) == ns
301+
@test GeometryBasics.face_normals(coordinates(r), faces(r)) == ns
302302
end
303303

304304
@testset "Tests from GeometryTypes" begin

0 commit comments

Comments
 (0)