Merge branch 'master' into collada_cleanup
commit
bbac168ced
|
@ -353,7 +353,7 @@ ELSE()
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
# Only generate this target if no higher-level project already has
|
# Only generate this target if no higher-level project already has
|
||||||
IF (NOT TARGET uninstall)
|
IF (NOT TARGET uninstall AND ASSIMP_INSTALL)
|
||||||
# add make uninstall capability
|
# add make uninstall capability
|
||||||
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/cmake-modules/cmake_uninstall.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" IMMEDIATE @ONLY)
|
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/cmake-modules/cmake_uninstall.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" IMMEDIATE @ONLY)
|
||||||
ADD_CUSTOM_TARGET(uninstall "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
|
ADD_CUSTOM_TARGET(uninstall "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
|
||||||
|
|
|
@ -16,5 +16,5 @@ set(RT_LIBRARIES ${RT_LIBRARY})
|
||||||
# handle the QUIETLY and REQUIRED arguments and set
|
# handle the QUIETLY and REQUIRED arguments and set
|
||||||
# RT_FOUND to TRUE if all listed variables are TRUE
|
# RT_FOUND to TRUE if all listed variables are TRUE
|
||||||
include(FindPackageHandleStandardArgs)
|
include(FindPackageHandleStandardArgs)
|
||||||
find_package_handle_standard_args(rt DEFAULT_MSG RT_LIBRARY)
|
find_package_handle_standard_args(RT DEFAULT_MSG RT_LIBRARY)
|
||||||
mark_as_advanced(RT_LIBRARY)
|
mark_as_advanced(RT_LIBRARY)
|
||||||
|
|
|
@ -8,6 +8,7 @@ find_package(openddlparser CONFIG REQUIRED)
|
||||||
find_package(poly2tri CONFIG REQUIRED)
|
find_package(poly2tri CONFIG REQUIRED)
|
||||||
find_package(polyclipping CONFIG REQUIRED)
|
find_package(polyclipping CONFIG REQUIRED)
|
||||||
find_package(zip CONFIG REQUIRED)
|
find_package(zip CONFIG REQUIRED)
|
||||||
|
find_package(pugixml CONFIG REQUIRED)
|
||||||
|
|
||||||
include("${CMAKE_CURRENT_LIST_DIR}/@TARGETS_EXPORT_NAME@.cmake")
|
include("${CMAKE_CURRENT_LIST_DIR}/@TARGETS_EXPORT_NAME@.cmake")
|
||||||
check_required_components("@PROJECT_NAME@")
|
check_required_components("@PROJECT_NAME@")
|
||||||
|
|
|
@ -598,7 +598,7 @@ bool XGLImporter::ReadMesh(XmlNode &node, TempScope &scope) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// finally extract output meshes and add them to the scope
|
// finally extract output meshes and add them to the scope
|
||||||
typedef std::pair<unsigned int, TempMaterialMesh> pairt;
|
typedef std::pair<const unsigned int, TempMaterialMesh> pairt;
|
||||||
for (const pairt &p : bymat) {
|
for (const pairt &p : bymat) {
|
||||||
aiMesh *const m = ToOutputMesh(p.second);
|
aiMesh *const m = ToOutputMesh(p.second);
|
||||||
scope.meshes_linear.push_back(m);
|
scope.meshes_linear.push_back(m);
|
||||||
|
|
|
@ -1060,7 +1060,7 @@ inline void Mesh::Decode_O3DGC(const SCompression_Open3DGC &pCompression_Open3DG
|
||||||
inline void Camera::Read(Value &obj, Asset & /*r*/) {
|
inline void Camera::Read(Value &obj, Asset & /*r*/) {
|
||||||
type = MemberOrDefault(obj, "type", Camera::Perspective);
|
type = MemberOrDefault(obj, "type", Camera::Perspective);
|
||||||
|
|
||||||
const char *subobjId = (type == Camera::Orthographic) ? "ortographic" : "perspective";
|
const char *subobjId = (type == Camera::Orthographic) ? "orthographic" : "perspective";
|
||||||
|
|
||||||
Value *it = FindObject(obj, subobjId);
|
Value *it = FindObject(obj, subobjId);
|
||||||
if (!it) throw DeadlyImportError("GLTF: Camera missing its parameters");
|
if (!it) throw DeadlyImportError("GLTF: Camera missing its parameters");
|
||||||
|
@ -1071,10 +1071,10 @@ inline void Camera::Read(Value &obj, Asset & /*r*/) {
|
||||||
perspective.zfar = MemberOrDefault(*it, "zfar", 100.f);
|
perspective.zfar = MemberOrDefault(*it, "zfar", 100.f);
|
||||||
perspective.znear = MemberOrDefault(*it, "znear", 0.01f);
|
perspective.znear = MemberOrDefault(*it, "znear", 0.01f);
|
||||||
} else {
|
} else {
|
||||||
ortographic.xmag = MemberOrDefault(obj, "xmag", 1.f);
|
ortographic.xmag = MemberOrDefault(*it, "xmag", 1.f);
|
||||||
ortographic.ymag = MemberOrDefault(obj, "ymag", 1.f);
|
ortographic.ymag = MemberOrDefault(*it, "ymag", 1.f);
|
||||||
ortographic.zfar = MemberOrDefault(obj, "zfar", 100.f);
|
ortographic.zfar = MemberOrDefault(*it, "zfar", 100.f);
|
||||||
ortographic.znear = MemberOrDefault(obj, "znear", 0.01f);
|
ortographic.znear = MemberOrDefault(*it, "znear", 0.01f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -928,14 +928,7 @@ aiNode *ImportNode(aiScene *pScene, glTF2::Asset &r, std::vector<unsigned int> &
|
||||||
std::vector<std::vector<aiVertexWeight>> weighting(numBones);
|
std::vector<std::vector<aiVertexWeight>> weighting(numBones);
|
||||||
BuildVertexWeightMapping(node.meshes[0]->primitives[primitiveNo], weighting);
|
BuildVertexWeightMapping(node.meshes[0]->primitives[primitiveNo], weighting);
|
||||||
|
|
||||||
unsigned int realNumBones = 0;
|
mesh->mNumBones = static_cast<unsigned int>(numBones);
|
||||||
for (uint32_t i = 0; i < numBones; ++i) {
|
|
||||||
if (weighting[i].size() > 0) {
|
|
||||||
realNumBones++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
mesh->mNumBones = static_cast<unsigned int>(realNumBones);
|
|
||||||
mesh->mBones = new aiBone *[mesh->mNumBones];
|
mesh->mBones = new aiBone *[mesh->mNumBones];
|
||||||
|
|
||||||
// GLTF and Assimp choose to store bone weights differently.
|
// GLTF and Assimp choose to store bone weights differently.
|
||||||
|
@ -951,10 +944,8 @@ aiNode *ImportNode(aiScene *pScene, glTF2::Asset &r, std::vector<unsigned int> &
|
||||||
mat4 *pbindMatrices = nullptr;
|
mat4 *pbindMatrices = nullptr;
|
||||||
node.skin->inverseBindMatrices->ExtractData(pbindMatrices);
|
node.skin->inverseBindMatrices->ExtractData(pbindMatrices);
|
||||||
|
|
||||||
int cb = 0;
|
|
||||||
for (uint32_t i = 0; i < numBones; ++i) {
|
for (uint32_t i = 0; i < numBones; ++i) {
|
||||||
const std::vector<aiVertexWeight> &weights = weighting[i];
|
const std::vector<aiVertexWeight> &weights = weighting[i];
|
||||||
if (weights.size() > 0) {
|
|
||||||
aiBone *bone = new aiBone();
|
aiBone *bone = new aiBone();
|
||||||
|
|
||||||
Ref<Node> joint = node.skin->jointNames[i];
|
Ref<Node> joint = node.skin->jointNames[i];
|
||||||
|
@ -970,10 +961,18 @@ aiNode *ImportNode(aiScene *pScene, glTF2::Asset &r, std::vector<unsigned int> &
|
||||||
GetNodeTransform(bone->mOffsetMatrix, *joint);
|
GetNodeTransform(bone->mOffsetMatrix, *joint);
|
||||||
CopyValue(pbindMatrices[i], bone->mOffsetMatrix);
|
CopyValue(pbindMatrices[i], bone->mOffsetMatrix);
|
||||||
bone->mNumWeights = static_cast<uint32_t>(weights.size());
|
bone->mNumWeights = static_cast<uint32_t>(weights.size());
|
||||||
|
|
||||||
|
if (bone->mNumWeights > 0) {
|
||||||
bone->mWeights = new aiVertexWeight[bone->mNumWeights];
|
bone->mWeights = new aiVertexWeight[bone->mNumWeights];
|
||||||
memcpy(bone->mWeights, weights.data(), bone->mNumWeights * sizeof(aiVertexWeight));
|
memcpy(bone->mWeights, weights.data(), bone->mNumWeights * sizeof(aiVertexWeight));
|
||||||
mesh->mBones[cb++] = bone;
|
} else {
|
||||||
|
// Assimp expects all bones to have at least 1 weight.
|
||||||
|
bone->mWeights = new aiVertexWeight[1];
|
||||||
|
bone->mNumWeights = 1;
|
||||||
|
bone->mWeights->mVertexId = 0;
|
||||||
|
bone->mWeights->mWeight = 0.f;
|
||||||
}
|
}
|
||||||
|
mesh->mBones[i] = bone;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pbindMatrices) {
|
if (pbindMatrices) {
|
||||||
|
|
Loading…
Reference in New Issue