mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 13:03:55 +02:00
Merge branch 'master' of github.com:highfidelity/hifi into brown
This commit is contained in:
commit
f9e827afa5
2 changed files with 26 additions and 40 deletions
|
@ -13,6 +13,17 @@
|
|||
|
||||
#include "ModelMath.h"
|
||||
|
||||
bool needTangents(const hfm::Mesh& mesh, const QHash<QString, hfm::Material>& materials) {
|
||||
// Check if we actually need to calculate the tangents
|
||||
for (const auto& meshPart : mesh.parts) {
|
||||
auto materialIt = materials.find(meshPart.materialID);
|
||||
if (materialIt != materials.end() && (*materialIt).needTangentSpace()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void CalculateMeshTangentsTask::run(const baker::BakeContextPointer& context, const Input& input, Output& output) {
|
||||
const auto& normalsPerMesh = input.get0();
|
||||
const std::vector<hfm::Mesh>& meshes = input.get1();
|
||||
|
@ -28,38 +39,20 @@ void CalculateMeshTangentsTask::run(const baker::BakeContextPointer& context, co
|
|||
auto& tangentsOut = tangentsPerMeshOut[tangentsPerMeshOut.size()-1];
|
||||
|
||||
// Check if we already have tangents and therefore do not need to do any calculation
|
||||
// Otherwise confirm if we have the normals needed, and need to calculate the tangents
|
||||
if (!tangentsIn.empty()) {
|
||||
tangentsOut = tangentsIn.toStdVector();
|
||||
continue;
|
||||
} else if (!normals.empty() && needTangents(mesh, materials)) {
|
||||
tangentsOut.resize(normals.size());
|
||||
baker::calculateTangents(mesh,
|
||||
[&mesh, &normals, &tangentsOut](int firstIndex, int secondIndex, glm::vec3* outVertices, glm::vec2* outTexCoords, glm::vec3& outNormal) {
|
||||
outVertices[0] = mesh.vertices[firstIndex];
|
||||
outVertices[1] = mesh.vertices[secondIndex];
|
||||
outNormal = normals[firstIndex];
|
||||
outTexCoords[0] = mesh.texCoords[firstIndex];
|
||||
outTexCoords[1] = mesh.texCoords[secondIndex];
|
||||
return &(tangentsOut[firstIndex]);
|
||||
});
|
||||
}
|
||||
|
||||
// Check if we have normals, and if not then tangents can't be calculated
|
||||
if (normals.empty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check if we actually need to calculate the tangents
|
||||
bool needTangents = false;
|
||||
for (const auto& meshPart : mesh.parts) {
|
||||
auto materialIt = materials.find(meshPart.materialID);
|
||||
if (materialIt != materials.end() && (*materialIt).needTangentSpace()) {
|
||||
needTangents = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (needTangents) {
|
||||
continue;
|
||||
}
|
||||
|
||||
tangentsOut.resize(normals.size());
|
||||
baker::calculateTangents(mesh,
|
||||
[&mesh, &normals, &tangentsOut](int firstIndex, int secondIndex, glm::vec3* outVertices, glm::vec2* outTexCoords, glm::vec3& outNormal) {
|
||||
outVertices[0] = mesh.vertices[firstIndex];
|
||||
outVertices[1] = mesh.vertices[secondIndex];
|
||||
outNormal = normals[firstIndex];
|
||||
outTexCoords[0] = mesh.texCoords[firstIndex];
|
||||
outTexCoords[1] = mesh.texCoords[secondIndex];
|
||||
return &(tangentsOut[firstIndex]);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -112,8 +112,8 @@ foreach(EXTERNAL ${OPTIONAL_EXTERNALS})
|
|||
# perform the system include hack for OS X to ignore warnings
|
||||
if (APPLE)
|
||||
foreach(EXTERNAL_INCLUDE_DIR ${${${EXTERNAL}_UPPERCASE}_INCLUDE_DIRS})
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem ${EXTERNAL_INCLUDE_DIR}")
|
||||
endforeach()
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem ${EXTERNAL_INCLUDE_DIR}")
|
||||
endforeach()
|
||||
endif ()
|
||||
|
||||
if (NOT ${${EXTERNAL}_UPPERCASE}_LIBRARIES)
|
||||
|
@ -148,7 +148,7 @@ if (WIN32)
|
|||
POST_BUILD
|
||||
COMMAND "${CMAKE_COMMAND}" -E copy_directory "${CMAKE_CURRENT_SOURCE_DIR}/AppDataHighFidelity" "$<TARGET_FILE_DIR:${TARGET_NAME}>/AppDataHighFidelity"
|
||||
)
|
||||
|
||||
|
||||
if (RELEASE_TYPE STREQUAL "DEV")
|
||||
# This to enable running from the IDE
|
||||
add_custom_command(
|
||||
|
@ -157,13 +157,6 @@ if (WIN32)
|
|||
COMMAND "${CMAKE_COMMAND}" -E copy_directory "${CMAKE_CURRENT_SOURCE_DIR}/AppDataHighFidelity" "AppDataHighFidelity"
|
||||
)
|
||||
endif ()
|
||||
|
||||
# add a custom command to copy the SSL DLLs
|
||||
add_custom_command(
|
||||
TARGET ${TARGET_NAME}
|
||||
POST_BUILD
|
||||
COMMAND "${CMAKE_COMMAND}" -E copy_directory "$ENV{VCPKG_ROOT}/installed/x64-windows/bin" "$<TARGET_FILE_DIR:${TARGET_NAME}>"
|
||||
)
|
||||
elseif (APPLE)
|
||||
add_custom_command(
|
||||
TARGET ${TARGET_NAME}
|
||||
|
|
Loading…
Reference in a new issue