USD Import: USD Shapes Support #104707

Merged
Hans Goudey merged 6 commits from CharlesWardlaw/blender:D16344-usd-shapes-export into main 2023-02-13 19:49:35 +01:00
1 changed files with 7 additions and 4 deletions
Showing only changes of commit bf96c97b8f - Show all commits

View File

@ -144,7 +144,7 @@ Mesh *USDShapeReader::read_mesh(struct Mesh *existing_mesh,
const char should_smooth = prim_.IsA<pxr::UsdGeomCube>() ? 0 : ME_SMOOTH;
CharlesWardlaw marked this conversation as resolved
Review

Declare loop_index at the smallest scope possible, right above the for (int i = 0; i < face_counts.size(); i++) { loop.

Declare `loop_index` at the smallest scope possible, right above the `for (int i = 0; i < face_counts.size(); i++) {` loop.
CharlesWardlaw marked this conversation as resolved
Review

Same here with the unused arguments

Same here with the unused arguments
Review

Changed.

Changed.
if (active_mesh != existing_mesh) {
int loop_index = 0;
int loop_index = 0;
for (int i = 0; i < face_counts.size(); i++) {
const int face_size = face_counts[i];
@ -172,20 +172,23 @@ Mesh *USDShapeReader::mesh_from_prim(Mesh *existing_mesh,
{
pxr::VtVec3fArray positions;
CharlesWardlaw marked this conversation as resolved
Review

Why do you need to calculate the edges if you didn't change anything above?

Why do you need to calculate the edges if you didn't change anything above?
Review

mesh_from_prim() does not calculate edges; I deferred their calculation to this spot.

mesh_from_prim() does not calculate edges; I deferred their calculation to this spot.
Review

Yes, but my point is, shouldn't it be in the if (active_mesh != existing_mesh) { where the corner vertices are actually set? Otherwise it looks like it's calculating edges unnecessarily.

Yes, but my point is, shouldn't it be in the `if (active_mesh != existing_mesh) {` where the corner vertices are actually set? Otherwise it looks like it's calculating edges unnecessarily.
Review

No, because active_mesh was created by mesh_from_prim() which does not calculate the edges. They need to be calculated either way.

No, because `active_mesh` was created by `mesh_from_prim()` which does not calculate the edges. They need to be calculated either way.
Mesh *active_mesh = existing_mesh;
if (!read_mesh_values(motionSampleTime, positions, face_indices, face_counts)) {
CharlesWardlaw marked this conversation as resolved
Review

No need to tag normals dirty on a new mesh. You aren't changing the positions here anyway, so it's not the correct update tag if any was actually needed.

No need to tag normals dirty on a new mesh. You aren't changing the positions here anyway, so it's not the correct update tag if any was actually needed.
Review

Seems to be fine now without-- removed.

Seems to be fine now without-- removed.
return active_mesh;
return existing_mesh;
}
const bool poly_counts_match = existing_mesh ? face_counts.size() == existing_mesh->totpoly :
false;
const bool position_counts_match = existing_mesh ? positions.size() == existing_mesh->totvert :
CharlesWardlaw marked this conversation as resolved
Review

Clang format!

Clang format!
Review

Reformatted file.

Reformatted file.
false;
Mesh *active_mesh = nullptr;
if (!position_counts_match || !poly_counts_match) {
active_mesh = BKE_mesh_new_nomain_from_template(
existing_mesh, positions.size(), 0, 0, face_indices.size(), face_counts.size());
}
else {
active_mesh = existing_mesh;
}
MutableSpan<float3> vert_positions = active_mesh->vert_positions_for_write();