mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 12:17:45 +02:00
Merge pull request #8569 from jherico/gli
Stuttering: Upgrade GLM & add GLI integration
This commit is contained in:
commit
dbf29ba79d
25 changed files with 262 additions and 69 deletions
|
@ -74,6 +74,13 @@ else ()
|
||||||
endif ()
|
endif ()
|
||||||
endif(WIN32)
|
endif(WIN32)
|
||||||
|
|
||||||
|
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||||
|
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "5.3")
|
||||||
|
# GLM 0.9.8 on Ubuntu 14 (gcc 4.4) has issues with the simd declarations
|
||||||
|
add_definitions(-DGLM_FORCE_PURE)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
if (NOT ANDROID)
|
if (NOT ANDROID)
|
||||||
if ((NOT MSVC12) AND (NOT MSVC14))
|
if ((NOT MSVC12) AND (NOT MSVC14))
|
||||||
include(CheckCXXCompilerFlag)
|
include(CheckCXXCompilerFlag)
|
||||||
|
|
21
cmake/externals/gli/CMakeLists.txt
vendored
Normal file
21
cmake/externals/gli/CMakeLists.txt
vendored
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
set(EXTERNAL_NAME gli)
|
||||||
|
|
||||||
|
include(ExternalProject)
|
||||||
|
ExternalProject_Add(
|
||||||
|
${EXTERNAL_NAME}
|
||||||
|
URL https://hifi-public.s3.amazonaws.com/dependencies/gli-0.8.1.0.zip
|
||||||
|
URL_MD5 00c990f59c12bbf367956ef399d6f798
|
||||||
|
BINARY_DIR ${EXTERNAL_PROJECT_PREFIX}/build
|
||||||
|
CONFIGURE_COMMAND ""
|
||||||
|
BUILD_COMMAND ""
|
||||||
|
INSTALL_COMMAND ""
|
||||||
|
LOG_DOWNLOAD 1
|
||||||
|
)
|
||||||
|
|
||||||
|
# Hide this external target (for ide users)
|
||||||
|
set_target_properties(${EXTERNAL_NAME} PROPERTIES FOLDER "hidden/externals")
|
||||||
|
|
||||||
|
ExternalProject_Get_Property(${EXTERNAL_NAME} SOURCE_DIR)
|
||||||
|
|
||||||
|
string(TOUPPER ${EXTERNAL_NAME} EXTERNAL_NAME_UPPER)
|
||||||
|
set(${EXTERNAL_NAME_UPPER}_INCLUDE_DIRS ${SOURCE_DIR} CACHE PATH "List of gli include directories")
|
4
cmake/externals/glm/CMakeLists.txt
vendored
4
cmake/externals/glm/CMakeLists.txt
vendored
|
@ -3,8 +3,8 @@ set(EXTERNAL_NAME glm)
|
||||||
include(ExternalProject)
|
include(ExternalProject)
|
||||||
ExternalProject_Add(
|
ExternalProject_Add(
|
||||||
${EXTERNAL_NAME}
|
${EXTERNAL_NAME}
|
||||||
URL http://hifi-public.s3.amazonaws.com/dependencies/glm-0.9.5.4.zip
|
URL https://hifi-public.s3.amazonaws.com/dependencies/glm-0.9.8.zip
|
||||||
URL_MD5 fab76fc982b256b46208e5c750ed456a
|
URL_MD5 579ac77a3110befa3244d68c0ceb7281
|
||||||
BINARY_DIR ${EXTERNAL_PROJECT_PREFIX}/build
|
BINARY_DIR ${EXTERNAL_PROJECT_PREFIX}/build
|
||||||
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
|
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
|
||||||
LOG_DOWNLOAD 1
|
LOG_DOWNLOAD 1
|
||||||
|
|
12
cmake/macros/TargetGli.cmake
Normal file
12
cmake/macros/TargetGli.cmake
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
#
|
||||||
|
# Copyright 2015 High Fidelity, Inc.
|
||||||
|
# Created by Bradley Austin Davis on 2015/10/10
|
||||||
|
#
|
||||||
|
# Distributed under the Apache License, Version 2.0.
|
||||||
|
# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
#
|
||||||
|
macro(TARGET_GLI)
|
||||||
|
add_dependency_external_projects(gli)
|
||||||
|
find_package(GLI REQUIRED)
|
||||||
|
target_include_directories(${TARGET_NAME} PUBLIC ${GLI_INCLUDE_DIRS})
|
||||||
|
endmacro()
|
26
cmake/modules/FindGLI.cmake
Normal file
26
cmake/modules/FindGLI.cmake
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
#
|
||||||
|
# FindGLI.cmake
|
||||||
|
#
|
||||||
|
# Try to find GLI include path.
|
||||||
|
# Once done this will define
|
||||||
|
#
|
||||||
|
# GLI_INCLUDE_DIRS
|
||||||
|
#
|
||||||
|
# Created on 2016/09/03 by Bradley Austin Davis
|
||||||
|
# Copyright 2013-2016 High Fidelity, Inc.
|
||||||
|
#
|
||||||
|
# Distributed under the Apache License, Version 2.0.
|
||||||
|
# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
#
|
||||||
|
|
||||||
|
# setup hints for GLI search
|
||||||
|
include("${MACRO_DIR}/HifiLibrarySearchHints.cmake")
|
||||||
|
hifi_library_search_hints("gli")
|
||||||
|
|
||||||
|
# locate header
|
||||||
|
find_path(GLI_INCLUDE_DIRS "gli/gli.hpp" HINTS ${GLI_SEARCH_DIRS})
|
||||||
|
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
find_package_handle_standard_args(GLI DEFAULT_MSG GLI_INCLUDE_DIRS)
|
||||||
|
|
||||||
|
mark_as_advanced(GLI_INCLUDE_DIRS GLI_SEARCH_DIRS)
|
|
@ -3288,7 +3288,7 @@ void Application::init() {
|
||||||
|
|
||||||
getEntities()->setEntityLoadingPriorityFunction([this](const EntityItem& item) {
|
getEntities()->setEntityLoadingPriorityFunction([this](const EntityItem& item) {
|
||||||
auto dims = item.getDimensions();
|
auto dims = item.getDimensions();
|
||||||
auto maxSize = glm::max(dims.x, dims.y, dims.z);
|
auto maxSize = glm::compMax(dims);
|
||||||
|
|
||||||
if (maxSize <= 0.0f) {
|
if (maxSize <= 0.0f) {
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
|
|
|
@ -55,7 +55,7 @@ void SoftAttachmentModel::updateClusterMatrices(glm::vec3 modelPosition, glm::qu
|
||||||
|
|
||||||
// TODO: cache these look ups as an optimization
|
// TODO: cache these look ups as an optimization
|
||||||
int jointIndexOverride = getJointIndexOverride(cluster.jointIndex);
|
int jointIndexOverride = getJointIndexOverride(cluster.jointIndex);
|
||||||
glm::mat4 jointMatrix(glm::mat4::_null);
|
glm::mat4 jointMatrix;
|
||||||
if (jointIndexOverride >= 0 && jointIndexOverride < _rigOverride->getJointStateCount()) {
|
if (jointIndexOverride >= 0 && jointIndexOverride < _rigOverride->getJointStateCount()) {
|
||||||
jointMatrix = _rigOverride->getJointTransform(jointIndexOverride);
|
jointMatrix = _rigOverride->getJointTransform(jointIndexOverride);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1093,7 +1093,7 @@ void Rig::updateFromHandParameters(const HandParameters& params, float dt) {
|
||||||
|
|
||||||
// prevent the hand IK targets from intersecting the body capsule
|
// prevent the hand IK targets from intersecting the body capsule
|
||||||
glm::vec3 handPosition = params.leftPosition;
|
glm::vec3 handPosition = params.leftPosition;
|
||||||
glm::vec3 displacement(glm::vec3::_null);
|
glm::vec3 displacement;
|
||||||
if (findSphereCapsulePenetration(handPosition, HAND_RADIUS, bodyCapsuleStart, bodyCapsuleEnd, bodyCapsuleRadius, displacement)) {
|
if (findSphereCapsulePenetration(handPosition, HAND_RADIUS, bodyCapsuleStart, bodyCapsuleEnd, bodyCapsuleRadius, displacement)) {
|
||||||
handPosition -= displacement;
|
handPosition -= displacement;
|
||||||
}
|
}
|
||||||
|
@ -1111,7 +1111,7 @@ void Rig::updateFromHandParameters(const HandParameters& params, float dt) {
|
||||||
|
|
||||||
// prevent the hand IK targets from intersecting the body capsule
|
// prevent the hand IK targets from intersecting the body capsule
|
||||||
glm::vec3 handPosition = params.rightPosition;
|
glm::vec3 handPosition = params.rightPosition;
|
||||||
glm::vec3 displacement(glm::vec3::_null);
|
glm::vec3 displacement;
|
||||||
if (findSphereCapsulePenetration(handPosition, HAND_RADIUS, bodyCapsuleStart, bodyCapsuleEnd, bodyCapsuleRadius, displacement)) {
|
if (findSphereCapsulePenetration(handPosition, HAND_RADIUS, bodyCapsuleStart, bodyCapsuleEnd, bodyCapsuleRadius, displacement)) {
|
||||||
handPosition -= displacement;
|
handPosition -= displacement;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
#include "SoundCache.h"
|
#include "SoundCache.h"
|
||||||
#include "AudioSRC.h"
|
#include "AudioSRC.h"
|
||||||
|
|
||||||
int audioInjectorPtrMetaTypeId = qRegisterMetaType<AudioInjector*>();
|
//int audioInjectorPtrMetaTypeId = qRegisterMetaType<AudioInjector*>();
|
||||||
|
|
||||||
AudioInjectorState operator& (AudioInjectorState lhs, AudioInjectorState rhs) {
|
AudioInjectorState operator& (AudioInjectorState lhs, AudioInjectorState rhs) {
|
||||||
return static_cast<AudioInjectorState>(static_cast<uint8_t>(lhs) & static_cast<uint8_t>(rhs));
|
return static_cast<AudioInjectorState>(static_cast<uint8_t>(lhs) & static_cast<uint8_t>(rhs));
|
||||||
|
|
|
@ -33,7 +33,7 @@ void RenderableLightEntityItem::render(RenderArgs* args) {
|
||||||
glm::vec3 position = getPosition();
|
glm::vec3 position = getPosition();
|
||||||
glm::vec3 dimensions = getDimensions();
|
glm::vec3 dimensions = getDimensions();
|
||||||
glm::quat rotation = getRotation();
|
glm::quat rotation = getRotation();
|
||||||
float largestDiameter = glm::max(dimensions.x, dimensions.y, dimensions.z);
|
float largestDiameter = glm::compMax(dimensions);
|
||||||
|
|
||||||
glm::vec3 color = toGlm(getXColor());
|
glm::vec3 color = toGlm(getXColor());
|
||||||
|
|
||||||
|
|
|
@ -299,7 +299,7 @@ bool RenderableModelEntityItem::getAnimationFrame() {
|
||||||
if (index < translations.size()) {
|
if (index < translations.size()) {
|
||||||
translationMat = glm::translate(translations[index]);
|
translationMat = glm::translate(translations[index]);
|
||||||
}
|
}
|
||||||
glm::mat4 rotationMat(glm::mat4::_null);
|
glm::mat4 rotationMat;
|
||||||
if (index < rotations.size()) {
|
if (index < rotations.size()) {
|
||||||
rotationMat = glm::mat4_cast(fbxJoints[index].preRotation * rotations[index] * fbxJoints[index].postRotation);
|
rotationMat = glm::mat4_cast(fbxJoints[index].preRotation * rotations[index] * fbxJoints[index].postRotation);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -447,7 +447,7 @@ bool RenderablePolyVoxEntityItem::findDetailedRayIntersection(const glm::vec3& o
|
||||||
// set ray cast length to long enough to cover all of the voxel space
|
// set ray cast length to long enough to cover all of the voxel space
|
||||||
float distanceToEntity = glm::distance(origin, getPosition());
|
float distanceToEntity = glm::distance(origin, getPosition());
|
||||||
glm::vec3 dimensions = getDimensions();
|
glm::vec3 dimensions = getDimensions();
|
||||||
float largestDimension = glm::max(dimensions.x, dimensions.y, dimensions.z) * 2.0f;
|
float largestDimension = glm::compMax(dimensions) * 2.0f;
|
||||||
glm::vec3 farPoint = origin + normDirection * (distanceToEntity + largestDimension);
|
glm::vec3 farPoint = origin + normDirection * (distanceToEntity + largestDimension);
|
||||||
|
|
||||||
glm::vec4 originInVoxel = wtvMatrix * glm::vec4(origin, 1.0f);
|
glm::vec4 originInVoxel = wtvMatrix * glm::vec4(origin, 1.0f);
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
#include <glm/gtx/extented_min_max.hpp>
|
|
||||||
|
|
||||||
#include <QtScript/QScriptEngine>
|
#include <QtScript/QScriptEngine>
|
||||||
#include <QtCore/QObject>
|
#include <QtCore/QObject>
|
||||||
|
@ -221,7 +220,7 @@ public:
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
float getMaxDimension() const { return glm::max(_dimensions.x, _dimensions.y, _dimensions.z); }
|
float getMaxDimension() const { return glm::compMax(_dimensions); }
|
||||||
|
|
||||||
float getAge() const { return (float)(usecTimestampNow() - _created) / (float)USECS_PER_SECOND; }
|
float getAge() const { return (float)(usecTimestampNow() - _created) / (float)USECS_PER_SECOND; }
|
||||||
bool hasCreatedTime() const { return (_created != UNKNOWN_CREATED_TIME); }
|
bool hasCreatedTime() const { return (_created != UNKNOWN_CREATED_TIME); }
|
||||||
|
|
|
@ -49,7 +49,7 @@ void LightEntityItem::setDimensions(const glm::vec3& value) {
|
||||||
const float width = length * glm::sin(glm::radians(_cutoff));
|
const float width = length * glm::sin(glm::radians(_cutoff));
|
||||||
EntityItem::setDimensions(glm::vec3(width, width, length));
|
EntityItem::setDimensions(glm::vec3(width, width, length));
|
||||||
} else {
|
} else {
|
||||||
float maxDimension = glm::max(value.x, value.y, value.z);
|
float maxDimension = glm::compMax(value);
|
||||||
EntityItem::setDimensions(glm::vec3(maxDimension, maxDimension, maxDimension));
|
EntityItem::setDimensions(glm::vec3(maxDimension, maxDimension, maxDimension));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -82,7 +82,7 @@ void LightEntityItem::setIsSpotlight(bool value) {
|
||||||
const float width = length * glm::sin(glm::radians(_cutoff));
|
const float width = length * glm::sin(glm::radians(_cutoff));
|
||||||
setDimensions(glm::vec3(width, width, length));
|
setDimensions(glm::vec3(width, width, length));
|
||||||
} else {
|
} else {
|
||||||
float maxDimension = glm::max(dimensions.x, dimensions.y, dimensions.z);
|
float maxDimension = glm::compMax(dimensions);
|
||||||
setDimensions(glm::vec3(maxDimension, maxDimension, maxDimension));
|
setDimensions(glm::vec3(maxDimension, maxDimension, maxDimension));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,12 +18,15 @@
|
||||||
#include <QRunnable>
|
#include <QRunnable>
|
||||||
#include <QThreadPool>
|
#include <QThreadPool>
|
||||||
#include <QImageReader>
|
#include <QImageReader>
|
||||||
|
#include <QtCore/QFile>
|
||||||
|
#include <QtCore/QFileInfo>
|
||||||
|
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
#include <glm/gtc/random.hpp>
|
#include <glm/gtc/random.hpp>
|
||||||
|
|
||||||
#include <gpu/Batch.h>
|
#include <gpu/Batch.h>
|
||||||
|
|
||||||
|
#include <NumericalConstants.h>
|
||||||
#include <shared/NsightHelpers.h>
|
#include <shared/NsightHelpers.h>
|
||||||
|
|
||||||
#include <Finally.h>
|
#include <Finally.h>
|
||||||
|
@ -307,6 +310,24 @@ ImageReader::ImageReader(const QWeakPointer<Resource>& resource, const QByteArra
|
||||||
_url(url),
|
_url(url),
|
||||||
_content(data)
|
_content(data)
|
||||||
{
|
{
|
||||||
|
#if DEBUG_DUMP_TEXTURE_LOADS
|
||||||
|
static auto start = usecTimestampNow() / USECS_PER_MSEC;
|
||||||
|
auto now = usecTimestampNow() / USECS_PER_MSEC - start;
|
||||||
|
QString urlStr = _url.toString();
|
||||||
|
auto dot = urlStr.lastIndexOf(".");
|
||||||
|
QString outFileName = QString(QCryptographicHash::hash(urlStr.toLocal8Bit(), QCryptographicHash::Md5).toHex()) + urlStr.right(urlStr.length() - dot);
|
||||||
|
QFile loadRecord("h:/textures/loads.txt");
|
||||||
|
loadRecord.open(QFile::Text | QFile::Append | QFile::ReadWrite);
|
||||||
|
loadRecord.write(QString("%1 %2\n").arg(now).arg(outFileName).toLocal8Bit());
|
||||||
|
outFileName = "h:/textures/" + outFileName;
|
||||||
|
QFileInfo outInfo(outFileName);
|
||||||
|
if (!outInfo.exists()) {
|
||||||
|
QFile outFile(outFileName);
|
||||||
|
outFile.open(QFile::WriteOnly | QFile::Truncate);
|
||||||
|
outFile.write(data);
|
||||||
|
outFile.close();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImageReader::listSupportedImageFormats() {
|
void ImageReader::listSupportedImageFormats() {
|
||||||
|
|
|
@ -46,7 +46,7 @@ inline btTransform glmToBullet(const glm::mat4& m) {
|
||||||
}
|
}
|
||||||
|
|
||||||
inline glm::mat4 bulletToGLM(const btTransform& t) {
|
inline glm::mat4 bulletToGLM(const btTransform& t) {
|
||||||
glm::mat4 m(glm::mat4::_null);
|
glm::mat4 m;
|
||||||
|
|
||||||
const btMatrix3x3& basis = t.getBasis();
|
const btMatrix3x3& basis = t.getBasis();
|
||||||
// copy over 3x3 part
|
// copy over 3x3 part
|
||||||
|
|
|
@ -8,4 +8,4 @@ if (WIN32)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_zlib()
|
target_zlib()
|
||||||
target_nsight()
|
target_nsight()
|
|
@ -9,8 +9,6 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
#include <glm/gtx/extented_min_max.hpp>
|
|
||||||
|
|
||||||
#include "AABox.h"
|
#include "AABox.h"
|
||||||
#include "AACube.h"
|
#include "AACube.h"
|
||||||
#include "Extents.h"
|
#include "Extents.h"
|
||||||
|
@ -25,7 +23,7 @@ AACube::AACube(const Extents& other) :
|
||||||
_corner(other.minimum)
|
_corner(other.minimum)
|
||||||
{
|
{
|
||||||
glm::vec3 dimensions = other.maximum - other.minimum;
|
glm::vec3 dimensions = other.maximum - other.minimum;
|
||||||
_scale = glm::max(dimensions.x, dimensions.y, dimensions.z);
|
_scale = glm::compMax(dimensions);
|
||||||
}
|
}
|
||||||
|
|
||||||
AACube::AACube(const glm::vec3& corner, float size) :
|
AACube::AACube(const glm::vec3& corner, float size) :
|
||||||
|
@ -479,8 +477,8 @@ AACube& AACube::operator += (const glm::vec3& point) {
|
||||||
|
|
||||||
glm::vec3 scaleOld = oldMaximumPoint - _corner;
|
glm::vec3 scaleOld = oldMaximumPoint - _corner;
|
||||||
glm::vec3 scalePoint = point - _corner;
|
glm::vec3 scalePoint = point - _corner;
|
||||||
_scale = glm::max(_scale, scalePoint.x, scalePoint.y, scalePoint.z);
|
_scale = std::max(_scale, glm::compMax(scalePoint));
|
||||||
_scale = glm::max(_scale, scaleOld.x, scaleOld.y, scaleOld.z);
|
_scale = std::max(_scale, glm::compMax(scaleOld));
|
||||||
|
|
||||||
return (*this);
|
return (*this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
#define hifi_Extents_h
|
#define hifi_Extents_h
|
||||||
|
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
#include <glm/gtx/extented_min_max.hpp>
|
#include <glm/gtx/component_wise.hpp>
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include "StreamUtils.h"
|
#include "StreamUtils.h"
|
||||||
|
@ -67,7 +67,7 @@ public:
|
||||||
void transform(const Transform& transform);
|
void transform(const Transform& transform);
|
||||||
|
|
||||||
glm::vec3 size() const { return maximum - minimum; }
|
glm::vec3 size() const { return maximum - minimum; }
|
||||||
float largestDimension() const {glm::vec3 s = size(); return glm::max(s[0], s[1], s[2]); }
|
float largestDimension() const { return glm::compMax(size()); }
|
||||||
|
|
||||||
/// \return new Extents which is original rotated around orign by rotation
|
/// \return new Extents which is original rotated around orign by rotation
|
||||||
Extents getRotated(const glm::quat& rotation) const {
|
Extents getRotated(const glm::quat& rotation) const {
|
||||||
|
|
|
@ -203,19 +203,19 @@ inline float lerp(float x, float y, float a) {
|
||||||
|
|
||||||
// vec2 lerp - linear interpolate
|
// vec2 lerp - linear interpolate
|
||||||
template<typename T, glm::precision P>
|
template<typename T, glm::precision P>
|
||||||
glm::detail::tvec2<T, P> lerp(const glm::detail::tvec2<T, P>& x, const glm::detail::tvec2<T, P>& y, T a) {
|
glm::tvec2<T, P> lerp(const glm::tvec2<T, P>& x, const glm::tvec2<T, P>& y, T a) {
|
||||||
return x * (T(1) - a) + (y * a);
|
return x * (T(1) - a) + (y * a);
|
||||||
}
|
}
|
||||||
|
|
||||||
// vec3 lerp - linear interpolate
|
// vec3 lerp - linear interpolate
|
||||||
template<typename T, glm::precision P>
|
template<typename T, glm::precision P>
|
||||||
glm::detail::tvec3<T, P> lerp(const glm::detail::tvec3<T, P>& x, const glm::detail::tvec3<T, P>& y, T a) {
|
glm::tvec3<T, P> lerp(const glm::tvec3<T, P>& x, const glm::tvec3<T, P>& y, T a) {
|
||||||
return x * (T(1) - a) + (y * a);
|
return x * (T(1) - a) + (y * a);
|
||||||
}
|
}
|
||||||
|
|
||||||
// vec4 lerp - linear interpolate
|
// vec4 lerp - linear interpolate
|
||||||
template<typename T, glm::precision P>
|
template<typename T, glm::precision P>
|
||||||
glm::detail::tvec4<T, P> lerp(const glm::detail::tvec4<T, P>& x, const glm::detail::tvec4<T, P>& y, T a) {
|
glm::tvec4<T, P> lerp(const glm::tvec4<T, P>& x, const glm::tvec4<T, P>& y, T a) {
|
||||||
return x * (T(1) - a) + (y * a);
|
return x * (T(1) - a) + (y * a);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -797,7 +797,7 @@ void SpatiallyNestable::setLocalOrientation(const glm::quat& orientation) {
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::vec3 SpatiallyNestable::getLocalVelocity() const {
|
glm::vec3 SpatiallyNestable::getLocalVelocity() const {
|
||||||
glm::vec3 result(glm::vec3::_null);
|
glm::vec3 result;
|
||||||
_velocityLock.withReadLock([&] {
|
_velocityLock.withReadLock([&] {
|
||||||
result = _velocity;
|
result = _velocity;
|
||||||
});
|
});
|
||||||
|
@ -811,7 +811,7 @@ void SpatiallyNestable::setLocalVelocity(const glm::vec3& velocity) {
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::vec3 SpatiallyNestable::getLocalAngularVelocity() const {
|
glm::vec3 SpatiallyNestable::getLocalAngularVelocity() const {
|
||||||
glm::vec3 result(glm::vec3::_null);
|
glm::vec3 result;
|
||||||
_angularVelocityLock.withReadLock([&] {
|
_angularVelocityLock.withReadLock([&] {
|
||||||
result = _angularVelocity;
|
result = _angularVelocity;
|
||||||
});
|
});
|
||||||
|
|
|
@ -14,6 +14,9 @@ link_hifi_libraries(shared octree gl gpu gpu-gl render model model-networking ne
|
||||||
|
|
||||||
package_libraries_for_deployment()
|
package_libraries_for_deployment()
|
||||||
|
|
||||||
|
target_gli()
|
||||||
|
target_glm()
|
||||||
|
|
||||||
target_zlib()
|
target_zlib()
|
||||||
add_dependency_external_projects(quazip)
|
add_dependency_external_projects(quazip)
|
||||||
find_package(QuaZip REQUIRED)
|
find_package(QuaZip REQUIRED)
|
||||||
|
|
70
tests/render-texture-load/src/GLIHelpers.cpp
Normal file
70
tests/render-texture-load/src/GLIHelpers.cpp
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
//
|
||||||
|
// Created by Bradley Austin Davis on 2016/09/03
|
||||||
|
// Copyright 2013-2016 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
#include "GLIHelpers.h"
|
||||||
|
|
||||||
|
#include <QtCore/QFileInfo>
|
||||||
|
#include <QtGui/QImage>
|
||||||
|
|
||||||
|
#include <gli/texture2d.hpp>
|
||||||
|
#include <gli/convert.hpp>
|
||||||
|
#include <gli/generate_mipmaps.hpp>
|
||||||
|
#include <gpu/Texture.h>
|
||||||
|
|
||||||
|
gli::format fromQImageFormat(QImage::Format format) {
|
||||||
|
switch (format) {
|
||||||
|
case QImage::Format_RGB32:
|
||||||
|
return gli::format::FORMAT_BGRA8_UNORM_PACK8;
|
||||||
|
|
||||||
|
case QImage::Format_ARGB32:
|
||||||
|
return gli::format::FORMAT_BGRA8_UNORM_PACK8;
|
||||||
|
|
||||||
|
case QImage::Format_Grayscale8:
|
||||||
|
return gli::format::FORMAT_L8_UNORM_PACK8;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return gli::format::FORMAT_UNDEFINED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QString getKtxFileName(const QString& sourceFileName) {
|
||||||
|
QFileInfo fileInfo(sourceFileName);
|
||||||
|
QString name = fileInfo.completeBaseName();
|
||||||
|
QString ext = fileInfo.suffix();
|
||||||
|
QString path = fileInfo.absolutePath();
|
||||||
|
return path + "/" + name + ".ktx";
|
||||||
|
}
|
||||||
|
|
||||||
|
QString convertTexture(const QString& sourceFile) {
|
||||||
|
if (sourceFile.endsWith(".ktx") || sourceFile.endsWith(".dds")) {
|
||||||
|
return sourceFile;
|
||||||
|
}
|
||||||
|
QImage sourceImage(sourceFile);
|
||||||
|
gli::texture2d workTexture(
|
||||||
|
fromQImageFormat(sourceImage.format()),
|
||||||
|
gli::extent2d(sourceImage.width(), sourceImage.height()));
|
||||||
|
auto sourceSize = sourceImage.byteCount();
|
||||||
|
assert(sourceSize == workTexture[workTexture.base_level()].size());
|
||||||
|
memcpy(workTexture[workTexture.base_level()].data(), sourceImage.constBits(), sourceSize);
|
||||||
|
|
||||||
|
QString resultFile = getKtxFileName(sourceFile) ;
|
||||||
|
gli::texture2d TextureMipmaped = gli::generate_mipmaps(workTexture, gli::FILTER_LINEAR);
|
||||||
|
gli::save(TextureMipmaped, resultFile.toLocal8Bit().data());
|
||||||
|
gli::texture loaded = gli::load(resultFile.toLocal8Bit().data());
|
||||||
|
return sourceFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
gpu::TexturePointer processTexture(const QString& sourceFile) {
|
||||||
|
auto ktxFile = convertTexture(sourceFile);
|
||||||
|
gli::texture texture = gli::load(ktxFile.toLocal8Bit().data());
|
||||||
|
if (texture.empty()) {
|
||||||
|
return gpu::TexturePointer();
|
||||||
|
}
|
||||||
|
// FIXME load the actual KTX texture
|
||||||
|
return gpu::TexturePointer();
|
||||||
|
}
|
47
tests/render-texture-load/src/GLIHelpers.h
Normal file
47
tests/render-texture-load/src/GLIHelpers.h
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
//
|
||||||
|
// Created by Bradley Austin Davis on 2016/09/03
|
||||||
|
// Copyright 2013-2016 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
#pragma once
|
||||||
|
#ifndef _GLIHelpers_H_
|
||||||
|
#define _GLIHelpers_H_
|
||||||
|
|
||||||
|
#include <qglobal.h>
|
||||||
|
#include <QtCore/QString>
|
||||||
|
|
||||||
|
// Work around for a bug in the MSVC compiler that chokes when you use GLI and Qt headers together.
|
||||||
|
#define gli glm
|
||||||
|
|
||||||
|
#ifdef Q_OS_MAC
|
||||||
|
#pragma clang diagnostic push
|
||||||
|
#pragma clang diagnostic ignored "-Wunused-variable"
|
||||||
|
#pragma clang diagnostic ignored "-Wignored-qualifiers"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__GNUC__) && !defined(__clang__)
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wempty-body"
|
||||||
|
#pragma GCC diagnostic ignored "-Wunused-variable"
|
||||||
|
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
|
||||||
|
#pragma GCC diagnostic ignored "-Wunused-result"
|
||||||
|
#pragma GCC diagnostic ignored "-Wignored-qualifiers"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <gli/gli.hpp>
|
||||||
|
|
||||||
|
#ifdef Q_OS_MAC
|
||||||
|
#pragma clang diagnostic pop
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__GNUC__) && !defined(__clang__)
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <gpu/Forward.h>
|
||||||
|
|
||||||
|
gpu::TexturePointer processTexture(const QString& file);
|
||||||
|
|
||||||
|
#endif
|
|
@ -11,9 +11,6 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
#include <gl/Config.h>
|
|
||||||
#include <gl/Context.h>
|
|
||||||
|
|
||||||
#include <QtCore/QDir>
|
#include <QtCore/QDir>
|
||||||
#include <QtCore/QElapsedTimer>
|
#include <QtCore/QElapsedTimer>
|
||||||
#include <QtCore/QLoggingCategory>
|
#include <QtCore/QLoggingCategory>
|
||||||
|
@ -41,6 +38,7 @@
|
||||||
#include <quazip5/JlCompress.h>
|
#include <quazip5/JlCompress.h>
|
||||||
|
|
||||||
|
|
||||||
|
#include "GLIHelpers.h"
|
||||||
#include <shared/RateCounter.h>
|
#include <shared/RateCounter.h>
|
||||||
#include <AssetClient.h>
|
#include <AssetClient.h>
|
||||||
#include <PathUtils.h>
|
#include <PathUtils.h>
|
||||||
|
@ -55,15 +53,15 @@
|
||||||
#include <TextureCache.h>
|
#include <TextureCache.h>
|
||||||
#include <FramebufferCache.h>
|
#include <FramebufferCache.h>
|
||||||
#include <GeometryCache.h>
|
#include <GeometryCache.h>
|
||||||
#include <DeferredLightingEffect.h>
|
|
||||||
#include <RenderShadowTask.h>
|
#include <gl/Config.h>
|
||||||
#include <RenderDeferredTask.h>
|
#include <gl/Context.h>
|
||||||
|
|
||||||
extern QThread* RENDER_THREAD;
|
extern QThread* RENDER_THREAD;
|
||||||
|
|
||||||
static const QString DATA_SET = "https://hifi-content.s3.amazonaws.com/austin/textures.zip";
|
static const QString DATA_SET = "https://hifi-content.s3.amazonaws.com/austin/textures.zip";
|
||||||
static const QTemporaryDir DATA_DIR;
|
static QDir DATA_DIR = QDir(QString("h:/textures"));
|
||||||
|
static QTemporaryDir* DOWNLOAD_DIR = nullptr;
|
||||||
|
|
||||||
class FileDownloader : public QObject {
|
class FileDownloader : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -81,7 +79,7 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void fileDownloaded(QNetworkReply* pReply) {
|
void fileDownloaded(QNetworkReply* pReply) {
|
||||||
_handler(pReply->readAll());
|
_handler(pReply->readAll());
|
||||||
pReply->deleteLater();
|
pReply->deleteLater();
|
||||||
|
@ -132,8 +130,6 @@ public:
|
||||||
_gpuContext = std::make_shared<gpu::Context>();
|
_gpuContext = std::make_shared<gpu::Context>();
|
||||||
_backend = _gpuContext->getBackend();
|
_backend = _gpuContext->getBackend();
|
||||||
_context.makeCurrent();
|
_context.makeCurrent();
|
||||||
DependencyManager::get<DeferredLightingEffect>()->init();
|
|
||||||
_context.makeCurrent();
|
|
||||||
initContext.create();
|
initContext.create();
|
||||||
_context.doneCurrent();
|
_context.doneCurrent();
|
||||||
std::unique_lock<std::mutex> lock(_mutex);
|
std::unique_lock<std::mutex> lock(_mutex);
|
||||||
|
@ -191,7 +187,7 @@ public:
|
||||||
_gpuContext->executeFrame(frame);
|
_gpuContext->executeFrame(frame);
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
auto geometryCache = DependencyManager::get<GeometryCache>();
|
auto geometryCache = DependencyManager::get<GeometryCache>();
|
||||||
gpu::Batch presentBatch;
|
gpu::Batch presentBatch;
|
||||||
presentBatch.setViewportTransform({ 0, 0, _size.width(), _size.height() });
|
presentBatch.setViewportTransform({ 0, 0, _size.width(), _size.height() });
|
||||||
|
@ -277,16 +273,6 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
QString fileForPath(const QString& name) {
|
|
||||||
QCryptographicHash hash(QCryptographicHash::Md5);
|
|
||||||
hash.addData(name.toLocal8Bit().data(), name.length());
|
|
||||||
QString hashStr = QString(hash.result().toHex());
|
|
||||||
auto dot = name.lastIndexOf('.');
|
|
||||||
QString extension = name.right(name.length() - dot);
|
|
||||||
QString result = DATA_DIR.path() + "/" + hashStr + extension;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create a simple OpenGL window that renders text in various ways
|
// Create a simple OpenGL window that renders text in various ways
|
||||||
class QTestWindow : public QWindow {
|
class QTestWindow : public QWindow {
|
||||||
public:
|
public:
|
||||||
|
@ -296,7 +282,6 @@ public:
|
||||||
//DependencyManager::registerInheritance<SpatialParentFinder, ParentFinder>();
|
//DependencyManager::registerInheritance<SpatialParentFinder, ParentFinder>();
|
||||||
DependencyManager::set<AddressManager>();
|
DependencyManager::set<AddressManager>();
|
||||||
DependencyManager::set<NodeList>(NodeType::Agent);
|
DependencyManager::set<NodeList>(NodeType::Agent);
|
||||||
DependencyManager::set<DeferredLightingEffect>();
|
|
||||||
DependencyManager::set<ResourceCacheSharedItems>();
|
DependencyManager::set<ResourceCacheSharedItems>();
|
||||||
DependencyManager::set<TextureCache>();
|
DependencyManager::set<TextureCache>();
|
||||||
DependencyManager::set<FramebufferCache>();
|
DependencyManager::set<FramebufferCache>();
|
||||||
|
@ -316,7 +301,7 @@ public:
|
||||||
_currentTexture = _textures.end();
|
_currentTexture = _textures.end();
|
||||||
{
|
{
|
||||||
QStringList stringList;
|
QStringList stringList;
|
||||||
QFile textFile("h:/textures/loads.txt");
|
QFile textFile(DATA_DIR.path() + "/loads.txt");
|
||||||
textFile.open(QFile::ReadOnly);
|
textFile.open(QFile::ReadOnly);
|
||||||
//... (open the file for reading, etc.)
|
//... (open the file for reading, etc.)
|
||||||
QTextStream textStream(&textFile);
|
QTextStream textStream(&textFile);
|
||||||
|
@ -332,8 +317,7 @@ public:
|
||||||
auto index = s.indexOf(" ");
|
auto index = s.indexOf(" ");
|
||||||
QString timeStr = s.left(index);
|
QString timeStr = s.left(index);
|
||||||
auto time = timeStr.toUInt();
|
auto time = timeStr.toUInt();
|
||||||
QString path = s.right(s.length() - index).trimmed();
|
QString path = DATA_DIR.path() + "/" + s.right(s.length() - index).trimmed();
|
||||||
path = fileForPath(path);
|
|
||||||
qDebug() << "Path " << path;
|
qDebug() << "Path " << path;
|
||||||
if (!QFileInfo(path).exists()) {
|
if (!QFileInfo(path).exists()) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -341,7 +325,7 @@ public:
|
||||||
_textureLoads.push({ time, path, s });
|
_textureLoads.push({ time, path, s });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
installEventFilter(this);
|
installEventFilter(this);
|
||||||
QThreadPool::globalInstance()->setMaxThreadCount(2);
|
QThreadPool::globalInstance()->setMaxThreadCount(2);
|
||||||
QThread::currentThread()->setPriority(QThread::HighestPriority);
|
QThread::currentThread()->setPriority(QThread::HighestPriority);
|
||||||
|
@ -436,7 +420,7 @@ private:
|
||||||
QSize windowSize = _size;
|
QSize windowSize = _size;
|
||||||
auto framebufferCache = DependencyManager::get<FramebufferCache>();
|
auto framebufferCache = DependencyManager::get<FramebufferCache>();
|
||||||
framebufferCache->setFrameBufferSize(windowSize);
|
framebufferCache->setFrameBufferSize(windowSize);
|
||||||
|
|
||||||
// Final framebuffer that will be handled to the display-plugin
|
// Final framebuffer that will be handled to the display-plugin
|
||||||
render();
|
render();
|
||||||
|
|
||||||
|
@ -462,8 +446,9 @@ private:
|
||||||
qDebug() << "Missing file " << front.file;
|
qDebug() << "Missing file " << front.file;
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "Loading " << front.src;
|
qDebug() << "Loading " << front.src;
|
||||||
|
auto file = front.file.toLocal8Bit().toStdString();
|
||||||
|
processTexture(file.c_str());
|
||||||
_textures.push_back(DependencyManager::get<TextureCache>()->getImageTexture(front.file));
|
_textures.push_back(DependencyManager::get<TextureCache>()->getImageTexture(front.file));
|
||||||
_currentTexture = _textures.begin();
|
|
||||||
}
|
}
|
||||||
_textureLoads.pop();
|
_textureLoads.pop();
|
||||||
if (_textureLoads.empty()) {
|
if (_textureLoads.empty()) {
|
||||||
|
@ -481,7 +466,7 @@ private:
|
||||||
});
|
});
|
||||||
PROFILE_RANGE(__FUNCTION__);
|
PROFILE_RANGE(__FUNCTION__);
|
||||||
auto framebuffer = DependencyManager::get<FramebufferCache>()->getFramebuffer();
|
auto framebuffer = DependencyManager::get<FramebufferCache>()->getFramebuffer();
|
||||||
|
|
||||||
gpu::doInBatch(gpuContext, [&](gpu::Batch& batch) {
|
gpu::doInBatch(gpuContext, [&](gpu::Batch& batch) {
|
||||||
batch.enableStereo(false);
|
batch.enableStereo(false);
|
||||||
batch.setFramebuffer(framebuffer);
|
batch.setFramebuffer(framebuffer);
|
||||||
|
@ -494,8 +479,7 @@ private:
|
||||||
}
|
}
|
||||||
if (_currentTexture == _textures.end()) {
|
if (_currentTexture == _textures.end()) {
|
||||||
_currentTexture = _textures.begin();
|
_currentTexture = _textures.begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_currentTexture != _textures.end()) {
|
if (_currentTexture != _textures.end()) {
|
||||||
batch.setResourceTexture(0, *_currentTexture);
|
batch.setResourceTexture(0, *_currentTexture);
|
||||||
}
|
}
|
||||||
|
@ -505,7 +489,7 @@ private:
|
||||||
|
|
||||||
auto frame = gpuContext->endFrame();
|
auto frame = gpuContext->endFrame();
|
||||||
frame->framebuffer = framebuffer;
|
frame->framebuffer = framebuffer;
|
||||||
frame->framebufferRecycler = [](const gpu::FramebufferPointer& framebuffer){
|
frame->framebufferRecycler = [](const gpu::FramebufferPointer& framebuffer) {
|
||||||
DependencyManager::get<FramebufferCache>()->releaseFramebuffer(framebuffer);
|
DependencyManager::get<FramebufferCache>()->releaseFramebuffer(framebuffer);
|
||||||
};
|
};
|
||||||
_renderThread.submitFrame(frame);
|
_renderThread.submitFrame(frame);
|
||||||
|
@ -546,20 +530,23 @@ hifi.gpu=true
|
||||||
)V0G0N";
|
)V0G0N";
|
||||||
|
|
||||||
void unzipTestData(const QByteArray& zipData) {
|
void unzipTestData(const QByteArray& zipData) {
|
||||||
|
DOWNLOAD_DIR = new QTemporaryDir();
|
||||||
|
QTemporaryDir& tempDir = *DOWNLOAD_DIR;
|
||||||
QTemporaryFile zipFile;
|
QTemporaryFile zipFile;
|
||||||
|
|
||||||
if (zipFile.open()) {
|
if (zipFile.open()) {
|
||||||
zipFile.write(zipData);
|
zipFile.write(zipData);
|
||||||
zipFile.close();
|
zipFile.close();
|
||||||
}
|
}
|
||||||
qDebug() << zipFile.fileName();
|
qDebug() << zipFile.fileName();
|
||||||
if (!DATA_DIR.isValid()) {
|
if (!tempDir.isValid()) {
|
||||||
qFatal("Unable to create temp dir");
|
qFatal("Unable to create temp dir");
|
||||||
}
|
}
|
||||||
|
DATA_DIR = QDir(tempDir.path());
|
||||||
|
|
||||||
//auto files = JlCompress::getFileList(zipData);
|
//auto files = JlCompress::getFileList(zipData);
|
||||||
auto files = JlCompress::extractDir(zipFile.fileName(), DATA_DIR.path());
|
auto files = JlCompress::extractDir(zipFile.fileName(), DATA_DIR.path());
|
||||||
qDebug() << DATA_DIR.path();
|
qDebug() << DATA_DIR.path();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
|
@ -570,12 +557,14 @@ int main(int argc, char** argv) {
|
||||||
qInstallMessageHandler(messageHandler);
|
qInstallMessageHandler(messageHandler);
|
||||||
QLoggingCategory::setFilterRules(LOG_FILTER_RULES);
|
QLoggingCategory::setFilterRules(LOG_FILTER_RULES);
|
||||||
|
|
||||||
|
if (!DATA_DIR.exists()) {
|
||||||
|
FileDownloader(DATA_SET, [&](const QByteArray& data) {
|
||||||
|
qDebug() << "Fetched size " << data.size();
|
||||||
|
unzipTestData(data);
|
||||||
|
}).waitForDownload();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
FileDownloader(DATA_SET, [&](const QByteArray& data) {
|
|
||||||
qDebug() << "Fetched size " << data.size();
|
|
||||||
unzipTestData(data);
|
|
||||||
}).waitForDownload();
|
|
||||||
|
|
||||||
QTestWindow::setup();
|
QTestWindow::setup();
|
||||||
QTestWindow window;
|
QTestWindow window;
|
||||||
app.exec();
|
app.exec();
|
||||||
|
|
Loading…
Reference in a new issue