Merge remote-tracking branch 'upstream/master' into plugins_pt1

Conflicts:
	libraries/render-utils/src/TextureCache.cpp
This commit is contained in:
Brad Davis 2015-05-02 00:51:50 -07:00
commit e72756ab99
20 changed files with 198 additions and 71 deletions

View file

@ -22,6 +22,7 @@
const QString ASSIGNMENT_CLIENT_MONITOR_TARGET_NAME = "assignment-client-monitor";
const int WAIT_FOR_CHILD_MSECS = 500;
AssignmentClientMonitor::AssignmentClientMonitor(const unsigned int numAssignmentClientForks,
const unsigned int minAssignmentClientForks,
@ -91,7 +92,26 @@ void AssignmentClientMonitor::stopChildProcesses() {
});
// try to give all the children time to shutdown
waitOnChildren(15000);
waitOnChildren(WAIT_FOR_CHILD_MSECS);
// ask more firmly
QMutableListIterator<QProcess*> i(_childProcesses);
while (i.hasNext()) {
QProcess* childProcess = i.next();
childProcess->terminate();
}
// try to give all the children time to shutdown
waitOnChildren(WAIT_FOR_CHILD_MSECS);
// ask even more firmly
QMutableListIterator<QProcess*> j(_childProcesses);
while (j.hasNext()) {
QProcess* childProcess = j.next();
childProcess->kill();
}
waitOnChildren(WAIT_FOR_CHILD_MSECS);
}
void AssignmentClientMonitor::aboutToQuit() {

View file

@ -208,8 +208,8 @@ var toolBar = (function () {
visible: false
});
newZoneButton = toolBar.addTool({
imageURL: toolIconUrl + "zonecube3.svg",
subImage: { x: 0, y: Tool.IMAGE_WIDTH + 208, width: 256, height: 256 },
imageURL: toolIconUrl + "zonecube_text.svg",
subImage: { x: 0, y: 128, width: 128, height: 128 },
width: toolWidth,
height: toolHeight,
alpha: 0.9,

View file

@ -1470,6 +1470,9 @@ void Application::mouseMoveEvent(QMouseEvent* event, unsigned int deviceID) {
}
void Application::mousePressEvent(QMouseEvent* event, unsigned int deviceID) {
// Inhibit the menu if the user is using alt-mouse dragging
_altPressed = false;
if (!_aboutToQuit) {
_entities.mousePressEvent(event, deviceID);
}
@ -1544,6 +1547,7 @@ void Application::mouseReleaseEvent(QMouseEvent* event, unsigned int deviceID) {
}
void Application::touchUpdateEvent(QTouchEvent* event) {
_altPressed = false;
if (event->type() == QEvent::TouchUpdate) {
TouchEvent thisEvent(*event, _lastTouchEvent);
_controllerScriptingInterface.emitTouchUpdateEvent(thisEvent); // send events to any registered scripts
@ -1579,6 +1583,7 @@ void Application::touchUpdateEvent(QTouchEvent* event) {
}
void Application::touchBeginEvent(QTouchEvent* event) {
_altPressed = false;
TouchEvent thisEvent(*event); // on touch begin, we don't compare to last event
_controllerScriptingInterface.emitTouchBeginEvent(thisEvent); // send events to any registered scripts
@ -1593,6 +1598,7 @@ void Application::touchBeginEvent(QTouchEvent* event) {
}
void Application::touchEndEvent(QTouchEvent* event) {
_altPressed = false;
TouchEvent thisEvent(*event, _lastTouchEvent);
_controllerScriptingInterface.emitTouchEndEvent(thisEvent); // send events to any registered scripts
_lastTouchEvent = thisEvent;
@ -1609,7 +1615,7 @@ void Application::touchEndEvent(QTouchEvent* event) {
}
void Application::wheelEvent(QWheelEvent* event) {
_altPressed = false;
_controllerScriptingInterface.emitWheelEvent(event); // send events to any registered scripts
// if one of our scripts have asked to capture this event, then stop processing it

View file

@ -1,6 +1,6 @@
//
// RenderableBoxEntityItem.cpp
// interface/src
// libraries/entities-renderer/src/
//
// Created by Brad Hefta-Gaub on 8/6/14.
// Copyright 2014 High Fidelity, Inc.
@ -36,8 +36,9 @@ void RenderableBoxEntityItem::render(RenderArgs* args) {
getColor()[BLUE_INDEX] / MAX_COLOR, getLocalRenderAlpha());
bool debugSimulationOwnership = args->_debugFlags & RenderArgs::RENDER_DEBUG_SIMULATION_OWNERSHIP;
bool highlightSimulationOwnership = false;
if (args->_debugFlags & RenderArgs::RENDER_DEBUG_SIMULATION_OWNERSHIP) {
if (debugSimulationOwnership) {
auto nodeList = DependencyManager::get<NodeList>();
const QUuid& myNodeID = nodeList->getSessionUUID();
highlightSimulationOwnership = (getSimulatorID() == myNodeID);
@ -58,4 +59,6 @@ void RenderableBoxEntityItem::render(RenderArgs* args) {
}
glPopMatrix();
glPopMatrix();
RenderableDebugableEntityItem::render(this, args);
};

View file

@ -1,6 +1,6 @@
//
// RenderableBoxEntityItem.h
// interface/src/entities
// libraries/entities-renderer/src/
//
// Created by Brad Hefta-Gaub on 8/6/14.
// Copyright 2014 High Fidelity, Inc.
@ -13,8 +13,9 @@
#define hifi_RenderableBoxEntityItem_h
#include <BoxEntityItem.h>
#include "RenderableDebugableEntityItem.h"
class RenderableBoxEntityItem : public BoxEntityItem {
class RenderableBoxEntityItem : public BoxEntityItem {
public:
static EntityItem* factory(const EntityItemID& entityID, const EntityItemProperties& properties);

View file

@ -0,0 +1,55 @@
//
// RenderableDebugableEntityItem.cpp
// libraries/entities-renderer/src/
//
// Created by Seth Alves on 5/1/15.
// Copyright 2014 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 <glm/gtx/quaternion.hpp>
#include <gpu/GPUConfig.h>
#include <DeferredLightingEffect.h>
#include "RenderableDebugableEntityItem.h"
void RenderableDebugableEntityItem::renderBoundingBox(EntityItem* entity, RenderArgs* args, bool puffedOut) {
glm::vec3 position = entity->getPosition();
glm::vec3 center = entity->getCenter();
glm::vec3 dimensions = entity->getDimensions();
glm::quat rotation = entity->getRotation();
glm::vec4 greenColor(0.0f, 1.0f, 0.0f, 1.0f);
glPushMatrix();
glTranslatef(position.x, position.y, position.z);
glm::vec3 axis = glm::axis(rotation);
glRotatef(glm::degrees(glm::angle(rotation)), axis.x, axis.y, axis.z);
glPushMatrix();
glm::vec3 positionToCenter = center - position;
glTranslatef(positionToCenter.x, positionToCenter.y, positionToCenter.z);
glScalef(dimensions.x, dimensions.y, dimensions.z);
if (puffedOut) {
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(1.2f, greenColor);
} else {
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(1.0f, greenColor);
}
glPopMatrix();
glPopMatrix();
}
void RenderableDebugableEntityItem::render(EntityItem* entity, RenderArgs* args) {
bool debugSimulationOwnership = args->_debugFlags & RenderArgs::RENDER_DEBUG_SIMULATION_OWNERSHIP;
if (debugSimulationOwnership) {
quint64 now = usecTimestampNow();
if (now - entity->getLastEditedFromRemote() < 0.1f * USECS_PER_SECOND) {
renderBoundingBox(entity, args, true);
}
}
}

View file

@ -0,0 +1,23 @@
//
// RenderableDebugableEntityItem.h
// libraries/entities-renderer/src/
//
// Created by Seth Alves on 5/1/15.
// Copyright 2014 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
//
#ifndef hifi_RenderableDebugableEntityItem_h
#define hifi_RenderableDebugableEntityItem_h
#include <EntityItem.h>
class RenderableDebugableEntityItem {
public:
static void renderBoundingBox(EntityItem* entity, RenderArgs* args, bool puffedOut);
static void render(EntityItem* entity, RenderArgs* args);
};
#endif // hifi_RenderableDebugableEntityItem_h

View file

@ -108,34 +108,6 @@ void RenderableModelEntityItem::remapTextures() {
_currentTextures = _textures;
}
void RenderableModelEntityItem::renderBoundingBox(RenderArgs* args) {
glm::vec3 position = getPosition();
glm::vec3 center = getCenter();
glm::vec3 dimensions = getDimensions();
glm::quat rotation = getRotation();
// float size = glm::length(dimensions) / 2.0f;
const float MAX_COLOR = 255.0f;
glm::vec4 cubeColor(getColor()[RED_INDEX] / MAX_COLOR,
getColor()[GREEN_INDEX] / MAX_COLOR,
getColor()[BLUE_INDEX] / MAX_COLOR,
getLocalRenderAlpha());
glPushMatrix();
glTranslatef(position.x, position.y, position.z);
glm::vec3 axis = glm::axis(rotation);
glRotatef(glm::degrees(glm::angle(rotation)), axis.x, axis.y, axis.z);
glPushMatrix();
glm::vec3 positionToCenter = center - position;
glTranslatef(positionToCenter.x, positionToCenter.y, positionToCenter.z);
glScalef(dimensions.x, dimensions.y, dimensions.z);
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(1.0f, cubeColor);
glPopMatrix();
glPopMatrix();
}
void RenderableModelEntityItem::render(RenderArgs* args) {
PerformanceTimer perfTimer("RMEIrender");
assert(getType() == EntityTypes::Model);
@ -145,8 +117,9 @@ void RenderableModelEntityItem::render(RenderArgs* args) {
glm::vec3 position = getPosition();
glm::vec3 dimensions = getDimensions();
bool debugSimulationOwnership = args->_debugFlags & RenderArgs::RENDER_DEBUG_SIMULATION_OWNERSHIP;
bool highlightSimulationOwnership = false;
if (args->_debugFlags & RenderArgs::RENDER_DEBUG_SIMULATION_OWNERSHIP) {
if (debugSimulationOwnership) {
auto nodeList = DependencyManager::get<NodeList>();
const QUuid& myNodeID = nodeList->getSessionUUID();
highlightSimulationOwnership = (getSimulatorID() == myNodeID);
@ -219,8 +192,10 @@ void RenderableModelEntityItem::render(RenderArgs* args) {
}
if (!didDraw) {
renderBoundingBox(args);
RenderableDebugableEntityItem::renderBoundingBox(this, args, false);
}
RenderableDebugableEntityItem::render(this, args);
}
Model* RenderableModelEntityItem::getModel(EntityTreeRenderer* renderer) {

View file

@ -16,11 +16,12 @@
#include <QStringList>
#include <ModelEntityItem.h>
#include "RenderableDebugableEntityItem.h"
class Model;
class EntityTreeRenderer;
class RenderableModelEntityItem : public ModelEntityItem {
class RenderableModelEntityItem : public ModelEntityItem {
public:
static EntityItem* factory(const EntityItemID& entityID, const EntityItemProperties& properties);
@ -42,7 +43,6 @@ public:
virtual void somethingChangedNotification() { _needsInitialSimulation = true; }
void renderBoundingBox(RenderArgs* args);
virtual void render(RenderArgs* args);
virtual bool supportsDetailedRayIntersection() const { return true; }
virtual bool findDetailedRayIntersection(const glm::vec3& origin, const glm::vec3& direction,

View file

@ -74,6 +74,12 @@ void RenderableZoneEntityItem::initialSimulation() {
_needsInitialSimulation = false;
}
void RenderableZoneEntityItem::render(RenderArgs* args) {
if (_drawZoneBoundaries) {
// TODO: Draw the zone boundaries...
}
}
bool RenderableZoneEntityItem::contains(const glm::vec3& point) const {
if (getShapeType() != SHAPE_TYPE_COMPOUND) {
return EntityItem::contains(point);
@ -92,4 +98,4 @@ bool RenderableZoneEntityItem::contains(const glm::vec3& point) const {
}
return false;
}
}

View file

@ -32,6 +32,7 @@ public:
ReadBitstreamToTreeParams& args,
EntityPropertyFlags& propertyFlags, bool overwriteLocalData);
virtual void render(RenderArgs* args);
virtual bool contains(const glm::vec3& point) const;
private:
@ -45,4 +46,4 @@ private:
bool _needsInitialSimulation;
};
#endif // hifi_RenderableZoneEntityItem_h
#endif // hifi_RenderableZoneEntityItem_h

View file

@ -307,7 +307,9 @@ public:
glm::mat4 getWorldToEntityMatrix() const;
glm::vec3 worldToEntity(const glm::vec3& point) const;
glm::vec3 entityToWorld(const glm::vec3& point) const;
quint64 getLastEditedFromRemote() { return _lastEditedFromRemote; }
protected:
static bool _sendPhysicsUpdates;

View file

@ -324,6 +324,14 @@ bool EntityScriptingInterface::getZonesArePickable() const {
return ZoneEntityItem::getZonesArePickable();
}
void EntityScriptingInterface::setDrawZoneBoundaries(bool value) {
ZoneEntityItem::setDrawZoneBoundaries(value);
}
bool EntityScriptingInterface::getDrawZoneBoundaries() const {
return ZoneEntityItem::getDrawZoneBoundaries();
}
void EntityScriptingInterface::setSendPhysicsUpdates(bool value) {
EntityItem::setSendPhysicsUpdates(value);
}

View file

@ -114,6 +114,9 @@ public slots:
Q_INVOKABLE void setZonesArePickable(bool value);
Q_INVOKABLE bool getZonesArePickable() const;
Q_INVOKABLE void setDrawZoneBoundaries(bool value);
Q_INVOKABLE bool getDrawZoneBoundaries() const;
Q_INVOKABLE void setSendPhysicsUpdates(bool value);
Q_INVOKABLE bool getSendPhysicsUpdates() const;

View file

@ -20,6 +20,7 @@
#include "EntityTreeElement.h"
bool ZoneEntityItem::_zonesArePickable = false;
bool ZoneEntityItem::_drawZoneBoundaries = false;
const xColor ZoneEntityItem::DEFAULT_KEYLIGHT_COLOR = { 255, 255, 255 };
const float ZoneEntityItem::DEFAULT_KEYLIGHT_INTENSITY = 1.0f;

View file

@ -91,6 +91,9 @@ public:
static bool getZonesArePickable() { return _zonesArePickable; }
static void setZonesArePickable(bool value) { _zonesArePickable = value; }
static bool getDrawZoneBoundaries() { return _drawZoneBoundaries; }
static void setDrawZoneBoundaries(bool value) { _drawZoneBoundaries = value; }
virtual bool isReadyToComputeShape() { return false; }
void updateShapeType(ShapeType type) { _shapeType = type; }
@ -136,6 +139,7 @@ protected:
ShapeType _shapeType = SHAPE_TYPE_NONE;
QString _compoundShapeURL;
static bool _drawZoneBoundaries;
static bool _zonesArePickable;
};

View file

@ -1746,8 +1746,12 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping,
material.id = getID(object.properties);
material._material = model::MaterialPointer(new model::Material());
material._material->setEmissive(material.emissive);
material._material->setDiffuse(material.diffuse);
material._material->setEmissive(material.emissive);
if (glm::all(glm::equal(material.diffuse, glm::vec3(0.0f)))) {
material._material->setDiffuse(material.diffuse);
} else {
material._material->setDiffuse(material.diffuse);
}
material._material->setSpecular(material.specular);
material._material->setShininess(material.shininess);

View file

@ -75,7 +75,7 @@ GLBackend::GLFramebuffer* GLBackend::syncGPUObject(const Framebuffer& framebuffe
}
}
#if (GPU_FEATURE_PROFILE == GPU_LEGACY)
// for reasons that i don;t understand yet, it seems that on mac gl, a fbo must have a color buffer...
// for reasons that i don't understand yet, it seems that on mac gl, a fbo must have a color buffer...
else {
GLuint renderBuffer = 0;
glGenRenderbuffers(1, &renderBuffer);

View file

@ -376,11 +376,14 @@ void PhysicsEngine::doOwnershipInfection(const btCollisionObject* objectA, const
auto nodeList = DependencyManager::get<NodeList>();
QUuid myNodeID = nodeList->getSessionUUID();
if (myNodeID.isNull()) {
return;
}
const btCollisionObject* characterCollisionObject =
_characterController ? _characterController->getCollisionObject() : NULL;
assert(!myNodeID.isNull());
ObjectMotionState* a = static_cast<ObjectMotionState*>(objectA->getUserPointer());
ObjectMotionState* b = static_cast<ObjectMotionState*>(objectB->getUserPointer());
EntityItem* entityA = a ? a->getEntity() : NULL;

View file

@ -19,7 +19,7 @@
#include <QResizeEvent>
#include <QRunnable>
#include <QThreadPool>
#include <QOpenGLContext>
#include <qimagereader.h>
#include <glm/glm.hpp>
#include <glm/gtc/random.hpp>
@ -29,6 +29,8 @@
#include "gpu/GLBackend.h"
#include <mutex>
TextureCache::TextureCache() :
_permutationNormalTexture(0),
_whiteTexture(0),
@ -335,27 +337,7 @@ NetworkTexture::NetworkTexture(const QUrl& url, TextureType type, const QByteArr
_loaded = true;
}
// default to white/blue/black
/* glBindTexture(GL_TEXTURE_2D, getID());
switch (type) {
case NORMAL_TEXTURE:
loadSingleColorTexture(OPAQUE_BLUE);
break;
case SPECULAR_TEXTURE:
loadSingleColorTexture(OPAQUE_BLACK);
break;
case SPLAT_TEXTURE:
loadSingleColorTexture(TRANSPARENT_WHITE);
break;
default:
loadSingleColorTexture(OPAQUE_WHITE);
break;
}
glBindTexture(GL_TEXTURE_2D, 0);
*/
std::string theName = url.toString().toStdString();
// if we have content, load it after we have our self pointer
if (!content.isEmpty()) {
_startedLoading = true;
@ -387,6 +369,18 @@ ImageReader::ImageReader(const QWeakPointer<Resource>& texture, QNetworkReply* r
_content(content) {
}
std::once_flag onceListSuppoertedFormatsflag;
void listSupportedImageFormats() {
std::call_once(onceListSuppoertedFormatsflag, [](){
auto supportedFormats = QImageReader::supportedImageFormats();
QString formats;
foreach(const QByteArray& f, supportedFormats) {
formats += QString(f) + ",";
}
qCDebug(renderutils) << "List of supported Image formats:" << formats;
});
}
void ImageReader::run() {
QSharedPointer<Resource> texture = _texture.toStrongRef();
if (texture.isNull()) {
@ -400,11 +394,29 @@ void ImageReader::run() {
_content = _reply->readAll();
_reply->deleteLater();
}
QImage image = QImage::fromData(_content);
listSupportedImageFormats();
// try to help the QImage loader by extracting the image file format from the url filename ext
// Some tga are not created properly for example without it
auto filename = _url.fileName().toStdString();
auto filenameExtension = filename.substr(filename.find_last_of('.') + 1);
QImage image = QImage::fromData(_content, filenameExtension.c_str());
// Note that QImage.format is the pixel format which is different from the "format" of the image file...
auto imageFormat = image.format();
int originalWidth = image.width();
int originalHeight = image.height();
if (originalWidth == 0 || originalHeight == 0 || imageFormat == QImage::Format_Invalid) {
if (filenameExtension.empty()) {
qCDebug(renderutils) << "QImage failed to create from content, no file extension:" << _url;
} else {
qCDebug(renderutils) << "QImage failed to create from content" << _url;
}
return;
}
// enforce a fixed maximum area (1024 * 2048)
const int MAXIMUM_AREA_SIZE = 2097152;
int imageArea = image.width() * image.height();