Merge branch 'master' of https://github.com/highfidelity/hifi into modelSceneRendering

This commit is contained in:
ZappoMan 2014-11-12 13:20:27 -08:00
commit 50bf5db50f
7 changed files with 56 additions and 32 deletions

View file

@ -61,7 +61,7 @@
const float LOUDNESS_TO_DISTANCE_RATIO = 0.00001f; const float LOUDNESS_TO_DISTANCE_RATIO = 0.00001f;
const float DEFAULT_ATTENUATION_PER_DOUBLING_IN_DISTANCE = 0.18; const float DEFAULT_ATTENUATION_PER_DOUBLING_IN_DISTANCE = 0.18;
const float DEFAULT_NOISE_MUTING_THRESHOLD = 0.001f; const float DEFAULT_NOISE_MUTING_THRESHOLD = 0.003f;
const QString AUDIO_MIXER_LOGGING_TARGET_NAME = "audio-mixer"; const QString AUDIO_MIXER_LOGGING_TARGET_NAME = "audio-mixer";
const QString AUDIO_ENV_GROUP_KEY = "audio_env"; const QString AUDIO_ENV_GROUP_KEY = "audio_env";
const QString AUDIO_BUFFER_GROUP_KEY = "audio_buffer"; const QString AUDIO_BUFFER_GROUP_KEY = "audio_buffer";

View file

@ -93,8 +93,8 @@
"name": "noise_muting_threshold", "name": "noise_muting_threshold",
"label": "Noise Muting Threshold", "label": "Noise Muting Threshold",
"help": "Loudness value for noise background between 0 and 1.0 (0: mute everyone, 1.0: never mute)", "help": "Loudness value for noise background between 0 and 1.0 (0: mute everyone, 1.0: never mute)",
"placeholder": "0.001", "placeholder": "0.003",
"default": "0.001", "default": "0.003",
"advanced": false "advanced": false
}, },
{ {

View file

@ -837,14 +837,12 @@ void Application::controlledBroadcastToNodes(const QByteArray& packet, const Nod
} }
bool Application::event(QEvent* event) { bool Application::event(QEvent* event) {
// handle custom URL // handle custom URL
if (event->type() == QEvent::FileOpen) { if (event->type() == QEvent::FileOpen) {
QFileOpenEvent* fileEvent = static_cast<QFileOpenEvent*>(event); QFileOpenEvent* fileEvent = static_cast<QFileOpenEvent*>(event);
if (fileEvent->url().isValid()) {
if (!fileEvent->url().isEmpty()) { openUrl(fileEvent->url());
AddressManager::getInstance().handleLookupString(fileEvent->url().toLocalFile());
} }
return false; return false;

View file

@ -547,7 +547,8 @@ NetworkGeometry::NetworkGeometry(const QUrl& url, const QSharedPointer<NetworkGe
Resource(url, delayLoad), Resource(url, delayLoad),
_mapping(mapping), _mapping(mapping),
_textureBase(textureBase.isValid() ? textureBase : url), _textureBase(textureBase.isValid() ? textureBase : url),
_fallback(fallback) { _fallback(fallback)
{
if (url.isEmpty()) { if (url.isEmpty()) {
// make the minimal amount of dummy geometry to satisfy Model // make the minimal amount of dummy geometry to satisfy Model
@ -562,6 +563,8 @@ NetworkGeometry::NetworkGeometry(const QUrl& url, const QSharedPointer<NetworkGe
_geometry.leftHandJointIndex = -1; _geometry.leftHandJointIndex = -1;
_geometry.rightHandJointIndex = -1; _geometry.rightHandJointIndex = -1;
} }
connect(this, &Resource::loaded, this, &NetworkGeometry::replaceTexturesWithPendingChanges);
} }
bool NetworkGeometry::isLoadedWithTextures() const { bool NetworkGeometry::isLoadedWithTextures() const {
@ -710,27 +713,33 @@ void NetworkGeometry::clearLoadPriority(const QPointer<QObject>& owner) {
} }
void NetworkGeometry::setTextureWithNameToURL(const QString& name, const QUrl& url) { void NetworkGeometry::setTextureWithNameToURL(const QString& name, const QUrl& url) {
for (int i = 0; i < _meshes.size(); i++) { if (_meshes.size() > 0) {
NetworkMesh& mesh = _meshes[i]; for (int i = 0; i < _meshes.size(); i++) {
for (int j = 0; j < mesh.parts.size(); j++) { NetworkMesh& mesh = _meshes[i];
NetworkMeshPart& part = mesh.parts[j]; for (int j = 0; j < mesh.parts.size(); j++) {
NetworkMeshPart& part = mesh.parts[j];
QSharedPointer<NetworkTexture> matchingTexture = QSharedPointer<NetworkTexture>();
if (part.diffuseTextureName == name) { QSharedPointer<NetworkTexture> matchingTexture = QSharedPointer<NetworkTexture>();
part.diffuseTexture = if (part.diffuseTextureName == name) {
part.diffuseTexture =
Application::getInstance()->getTextureCache()->getTexture(url, DEFAULT_TEXTURE, Application::getInstance()->getTextureCache()->getTexture(url, DEFAULT_TEXTURE,
_geometry.meshes[i].isEye, QByteArray()); _geometry.meshes[i].isEye, QByteArray());
part.diffuseTexture->setLoadPriorities(_loadPriorities); part.diffuseTexture->setLoadPriorities(_loadPriorities);
} else if (part.normalTextureName == name) { } else if (part.normalTextureName == name) {
part.normalTexture = Application::getInstance()->getTextureCache()->getTexture(url, DEFAULT_TEXTURE, part.normalTexture = Application::getInstance()->getTextureCache()->getTexture(url, DEFAULT_TEXTURE,
false, QByteArray()); false, QByteArray());
part.normalTexture->setLoadPriorities(_loadPriorities); part.normalTexture->setLoadPriorities(_loadPriorities);
} else if (part.specularTextureName == name) { } else if (part.specularTextureName == name) {
part.specularTexture = Application::getInstance()->getTextureCache()->getTexture(url, DEFAULT_TEXTURE, part.specularTexture = Application::getInstance()->getTextureCache()->getTexture(url, DEFAULT_TEXTURE,
false, QByteArray()); false, QByteArray());
part.specularTexture->setLoadPriorities(_loadPriorities); part.specularTexture->setLoadPriorities(_loadPriorities);
}
} }
} }
} else {
qDebug() << "Adding a name url pair to pending" << name << url;
// we don't have meshes downloaded yet, so hold this texture as pending
_pendingTextureChanges.insert(name, url);
} }
} }
@ -760,6 +769,15 @@ QStringList NetworkGeometry::getTextureNames() const {
return result; return result;
} }
void NetworkGeometry::replaceTexturesWithPendingChanges() {
QHash<QString, QUrl>::Iterator it = _pendingTextureChanges.begin();
while (it != _pendingTextureChanges.end()) {
setTextureWithNameToURL(it.key(), it.value());
it = _pendingTextureChanges.erase(it);
}
}
/// Reads geometry in a worker thread. /// Reads geometry in a worker thread.
class GeometryReader : public QRunnable { class GeometryReader : public QRunnable {
public: public:
@ -807,6 +825,7 @@ void NetworkGeometry::init() {
_geometry = FBXGeometry(); _geometry = FBXGeometry();
_meshes.clear(); _meshes.clear();
_lods.clear(); _lods.clear();
_pendingTextureChanges.clear();
_request.setUrl(_url); _request.setUrl(_url);
Resource::init(); Resource::init();
} }

View file

@ -113,7 +113,7 @@ public:
void setTextureWithNameToURL(const QString& name, const QUrl& url); void setTextureWithNameToURL(const QString& name, const QUrl& url);
QStringList getTextureNames() const; QStringList getTextureNames() const;
protected: protected:
virtual void init(); virtual void init();
@ -122,6 +122,8 @@ protected:
Q_INVOKABLE void setGeometry(const FBXGeometry& geometry); Q_INVOKABLE void setGeometry(const FBXGeometry& geometry);
private slots:
void replaceTexturesWithPendingChanges();
private: private:
friend class GeometryCache; friend class GeometryCache;
@ -139,6 +141,8 @@ private:
QWeakPointer<NetworkGeometry> _lodParent; QWeakPointer<NetworkGeometry> _lodParent;
QHash<QWeakPointer<Animation>, QVector<int> > _jointMappings; QHash<QWeakPointer<Animation>, QVector<int> > _jointMappings;
QHash<QString, QUrl> _pendingTextureChanges;
}; };
/// The state associated with a single mesh part. /// The state associated with a single mesh part.

View file

@ -52,9 +52,12 @@ JoystickScriptingInterface::JoystickScriptingInterface() :
for (int i = 0; i < joystickCount; i++) { for (int i = 0; i < joystickCount; i++) {
SDL_GameController* controller = SDL_GameControllerOpen(i); SDL_GameController* controller = SDL_GameControllerOpen(i);
SDL_JoystickID id = getInstanceId(controller);
Joystick* joystick = new Joystick(id, SDL_GameControllerName(controller), controller); if (controller) {
_openJoysticks[id] = joystick; SDL_JoystickID id = getInstanceId(controller);
Joystick* joystick = new Joystick(id, SDL_GameControllerName(controller), controller);
_openJoysticks[id] = joystick;
}
} }
_isInitialized = true; _isInitialized = true;

View file

@ -145,14 +145,14 @@ public:
float getLargestDimension() const { return glm::length(_dimensions); } /// get the largest possible dimension float getLargestDimension() const { return glm::length(_dimensions); } /// get the largest possible dimension
/// set dimensions in domain scale units (0.0 - 1.0) this will also reset radius appropriately /// set dimensions in domain scale units (0.0 - 1.0) this will also reset radius appropriately
void setDimensions(const glm::vec3& value) { _dimensions = value; ; recalculateCollisionShape(); } void setDimensions(const glm::vec3& value) { _dimensions = value; recalculateCollisionShape(); }
/// set dimensions in meter units (0.0 - TREE_SCALE) this will also reset radius appropriately /// set dimensions in meter units (0.0 - TREE_SCALE) this will also reset radius appropriately
void setDimensionsInMeters(const glm::vec3& value) { setDimensions(value / (float) TREE_SCALE); } void setDimensionsInMeters(const glm::vec3& value) { setDimensions(value / (float) TREE_SCALE); }
static const glm::quat DEFAULT_ROTATION; static const glm::quat DEFAULT_ROTATION;
const glm::quat& getRotation() const { return _rotation; } const glm::quat& getRotation() const { return _rotation; }
void setRotation(const glm::quat& rotation) { _rotation = rotation; ; recalculateCollisionShape(); } void setRotation(const glm::quat& rotation) { _rotation = rotation; recalculateCollisionShape(); }
static const float DEFAULT_GLOW_LEVEL; static const float DEFAULT_GLOW_LEVEL;
float getGlowLevel() const { return _glowLevel; } float getGlowLevel() const { return _glowLevel; }
@ -169,7 +169,7 @@ public:
static const glm::vec3 DEFAULT_VELOCITY; static const glm::vec3 DEFAULT_VELOCITY;
static const glm::vec3 NO_VELOCITY; static const glm::vec3 NO_VELOCITY;
static const float EPSILON_VELOCITY_LENGTH; static const float EPSILON_VELOCITY_LENGTH;
const glm::vec3 getVelocity() const { return _velocity; } /// velocity in domain scale units (0.0-1.0) per second const glm::vec3& getVelocity() const { return _velocity; } /// velocity in domain scale units (0.0-1.0) per second
glm::vec3 getVelocityInMeters() const { return _velocity * (float) TREE_SCALE; } /// get velocity in meters glm::vec3 getVelocityInMeters() const { return _velocity * (float) TREE_SCALE; } /// get velocity in meters
void setVelocity(const glm::vec3& value) { _velocity = value; } /// velocity in domain scale units (0.0-1.0) per second void setVelocity(const glm::vec3& value) { _velocity = value; } /// velocity in domain scale units (0.0-1.0) per second
void setVelocityInMeters(const glm::vec3& value) { _velocity = value / (float) TREE_SCALE; } /// velocity in meters void setVelocityInMeters(const glm::vec3& value) { _velocity = value / (float) TREE_SCALE; } /// velocity in meters