Merge branch 'master' into master

pull/4693/head
vkaytsanov 2022-08-17 12:01:44 +03:00 committed by GitHub
commit 4c143eb581
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 14 deletions

View File

@ -54,7 +54,7 @@ macro(clear_if_changed TESTVAR)
set(${var} "NOTFOUND" CACHE STRING "x" FORCE) set(${var} "NOTFOUND" CACHE STRING "x" FORCE)
endforeach(var) endforeach(var)
endif () endif ()
set(${TESTVAR}_INT_CHECK ${${TESTVAR}} CACHE INTERNAL "x" FORCE) set(${TESTVAR}_INT_CHECK "${${TESTVAR}}" CACHE INTERNAL "x" FORCE)
endmacro(clear_if_changed) endmacro(clear_if_changed)
# Try to get some hints from pkg-config, if available # Try to get some hints from pkg-config, if available

View File

@ -970,8 +970,10 @@ static void BuildVertexWeightMapping(Mesh::Primitive &primitive, std::vector<std
struct Weights { struct Weights {
float values[4]; float values[4];
}; };
Weights *weights = nullptr; Weights **weights = new Weights*[attr.weight.size()];
attr.weight[0]->ExtractData(weights); for (size_t w = 0; w < attr.weight.size(); ++w) {
attr.weight[w]->ExtractData(weights[w]);
}
struct Indices8 { struct Indices8 {
uint8_t values[4]; uint8_t values[4];
@ -979,12 +981,18 @@ static void BuildVertexWeightMapping(Mesh::Primitive &primitive, std::vector<std
struct Indices16 { struct Indices16 {
uint16_t values[4]; uint16_t values[4];
}; };
Indices8 *indices8 = nullptr; Indices8 **indices8 = nullptr;
Indices16 *indices16 = nullptr; Indices16 **indices16 = nullptr;
if (attr.joint[0]->GetElementSize() == 4) { if (attr.joint[0]->GetElementSize() == 4) {
attr.joint[0]->ExtractData(indices8); indices8 = new Indices8*[attr.joint.size()];
for (size_t j = 0; j < attr.joint.size(); ++j) {
attr.joint[j]->ExtractData(indices8[j]);
}
} else { } else {
attr.joint[0]->ExtractData(indices16); indices16 = new Indices16 *[attr.joint.size()];
for (size_t j = 0; j < attr.joint.size(); ++j) {
attr.joint[j]->ExtractData(indices16[j]);
}
} }
// //
if (nullptr == indices8 && nullptr == indices16) { if (nullptr == indices8 && nullptr == indices16) {
@ -993,17 +1001,26 @@ static void BuildVertexWeightMapping(Mesh::Primitive &primitive, std::vector<std
return; return;
} }
for (size_t i = 0; i < num_vertices; ++i) { for (size_t w = 0; w < attr.weight.size(); ++w) {
for (int j = 0; j < 4; ++j) { for (size_t i = 0; i < num_vertices; ++i) {
const unsigned int bone = (indices8 != nullptr) ? indices8[i].values[j] : indices16[i].values[j]; for (int j = 0; j < 4; ++j) {
const float weight = weights[i].values[j]; const unsigned int bone = (indices8 != nullptr) ? indices8[w][i].values[j] : indices16[w][i].values[j];
if (weight > 0 && bone < map.size()) { const float weight = weights[w][i].values[j];
map[bone].reserve(8); if (weight > 0 && bone < map.size()) {
map[bone].emplace_back(static_cast<unsigned int>(i), weight); map[bone].reserve(8);
map[bone].emplace_back(static_cast<unsigned int>(i), weight);
}
} }
} }
} }
for (size_t w = 0; w < attr.weight.size(); ++w) {
delete[] weights[w];
if(indices8)
delete[] indices8[w];
if (indices16)
delete[] indices16[w];
}
delete[] weights; delete[] weights;
delete[] indices8; delete[] indices8;
delete[] indices16; delete[] indices16;