Skip to content

Commit

Permalink
mirroring for normals and bone weights
Browse files Browse the repository at this point in the history
  • Loading branch information
i-saint committed Dec 28, 2017
1 parent 863924b commit 191a44a
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Plugin/MeshSync/msSceneGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1253,6 +1253,19 @@ void Mesh::applyMirror(const float3 & plane_n, float plane_d, bool /*welding*/)
mu::MirrorTopology(counts.data() + num_faces, indices.data() + num_indices,
IArray<int>{counts.data(), num_faces}, IArray<int>{indices.data(), num_indices}, IArray<int>{indirect.data(), indirect.size()});

if (normals.data()) {
if (normals.size() == num_points) {
normals.resize(points.size());
mu::CopyWithIndices(&normals[num_points], &normals[0], copylist);
}
else if (normals.size() == num_indices) {
normals.resize(indices.size());
auto dst = &normals[num_indices];
mu::EnumerateReverseFaceIndices(IArray<int>{counts.data(), num_faces}, [dst, this](int, int idx, int ridx) {
dst[idx] = normals[ridx];
});
}
}
if (uv.data()) {
if (uv.size() == num_points) {
uv.resize(points.size());
Expand Down Expand Up @@ -1284,6 +1297,11 @@ void Mesh::applyMirror(const float3 & plane_n, float plane_d, bool /*welding*/)
materialIDs.resize(n * 2);
memcpy(materialIDs.data() + n, materialIDs.data(), sizeof(int) * n);
}
for (auto& bone : bones) {
auto& weights = bone->weights;
weights.resize(points.size());
mu::CopyWithIndices(&weights[num_points], &weights[0], copylist);
}
}


Expand Down

0 comments on commit 191a44a

Please sign in to comment.