Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/io/usd/intern/usd_writer_mesh.cc')
-rw-r--r--source/blender/io/usd/intern/usd_writer_mesh.cc10
1 files changed, 4 insertions, 6 deletions
diff --git a/source/blender/io/usd/intern/usd_writer_mesh.cc b/source/blender/io/usd/intern/usd_writer_mesh.cc
index 61b14155dd0..b21dd8ac1fd 100644
--- a/source/blender/io/usd/intern/usd_writer_mesh.cc
+++ b/source/blender/io/usd/intern/usd_writer_mesh.cc
@@ -378,16 +378,15 @@ void USDGenericMeshWriter::write_normals(const Mesh *mesh, pxr::UsdGeomMesh usd_
}
else {
/* Compute the loop normals based on the 'smooth' flag. */
- float normal[3];
+ const float(*vert_normals)[3] = BKE_mesh_vertex_normals_ensure(mesh);
+ const float(*face_normals)[3] = BKE_mesh_poly_normals_ensure(mesh);
MPoly *mpoly = mesh->mpoly;
- const MVert *mvert = mesh->mvert;
for (int poly_idx = 0, totpoly = mesh->totpoly; poly_idx < totpoly; ++poly_idx, ++mpoly) {
MLoop *mloop = mesh->mloop + mpoly->loopstart;
if ((mpoly->flag & ME_SMOOTH) == 0) {
/* Flat shaded, use common normal for all verts. */
- BKE_mesh_calc_poly_normal(mpoly, mloop, mvert, normal);
- pxr::GfVec3f pxr_normal(normal);
+ pxr::GfVec3f pxr_normal(face_normals[poly_idx]);
for (int loop_idx = 0; loop_idx < mpoly->totloop; ++loop_idx) {
loop_normals.push_back(pxr_normal);
}
@@ -395,8 +394,7 @@ void USDGenericMeshWriter::write_normals(const Mesh *mesh, pxr::UsdGeomMesh usd_
else {
/* Smooth shaded, use individual vert normals. */
for (int loop_idx = 0; loop_idx < mpoly->totloop; ++loop_idx, ++mloop) {
- normal_short_to_float_v3(normal, mvert[mloop->v].no);
- loop_normals.push_back(pxr::GfVec3f(normal));
+ loop_normals.push_back(pxr::GfVec3f(vert_normals[mloop->v]));
}
}
}