Merging with upstream

This commit is contained in:
samcake 2015-10-20 10:13:47 -07:00
commit 07aac6b2c7
20 changed files with 260 additions and 237 deletions

View file

@ -181,15 +181,33 @@ Item {
color: root.fontColor; color: root.fontColor;
font.pixelSize: root.fontSize font.pixelSize: root.fontSize
visible: root.expanded; visible: root.expanded;
text: "\tMesh Parts Rendered Opaque: " + root.meshOpaque + text: "\tItems Rendered Opaque: " + root.opaqueRendered +
" / Translucent: " + root.meshTranslucent; " / Translucent: " + root.translucentRendered +
" / Other: " + root.otherRendered;
} }
Text { Text {
color: root.fontColor; color: root.fontColor;
font.pixelSize: root.fontSize font.pixelSize: root.fontSize
visible: root.expanded; visible: root.expanded;
text: "\tOpaque considered: " + root.opaqueConsidered + text: "\tOpaque considered: " + root.opaqueConsidered +
" / Out of view: " + root.opaqueOutOfView + " / Too small: " + root.opaqueTooSmall; " / Out of view: " + root.opaqueOutOfView +
" / Too small: " + root.opaqueTooSmall;
}
Text {
color: root.fontColor;
font.pixelSize: root.fontSize
visible: root.expanded;
text: "\tTranslucent considered: " + root.translucentConsidered +
" / Out of view: " + root.translucentOutOfView +
" / Too small: " + root.translucentTooSmall;
}
Text {
color: root.fontColor;
font.pixelSize: root.fontSize
visible: root.expanded;
text: "\tOther considered: " + root.otherConsidered +
" / Out of view: " + root.otherOutOfView +
" / Too small: " + root.otherTooSmall;
} }
Text { Text {
color: root.fontColor; color: root.fontColor;

View file

@ -229,7 +229,6 @@ bool LODManager::shouldRender(const RenderArgs* args, const AABox& bounds) {
static bool shouldRenderTableNeedsBuilding = true; static bool shouldRenderTableNeedsBuilding = true;
static QMap<float, float> shouldRenderTable; static QMap<float, float> shouldRenderTable;
if (shouldRenderTableNeedsBuilding) { if (shouldRenderTableNeedsBuilding) {
float SMALLEST_SCALE_IN_TABLE = 0.001f; // 1mm is plenty small float SMALLEST_SCALE_IN_TABLE = 0.001f; // 1mm is plenty small
float scale = maxScale; float scale = maxScale;
float factor = 1.0f; float factor = 1.0f;

View file

@ -154,7 +154,7 @@ controller::InputController::Pointer ControllerScriptingInterface::createInputCo
if (trackerID >= 0) { if (trackerID >= 0) {
controller::InputController::Pointer inputController = std::make_shared<InputController>(deviceID, trackerID, this); controller::InputController::Pointer inputController = std::make_shared<InputController>(deviceID, trackerID, this);
controller::InputController::Key key = inputController->getKey(); controller::InputController::Key key = inputController->getKey();
_inputControllers.insert(InputControllerMap::value_type(inputController->getKey(), inputController)); _inputControllers.insert(InputControllerMap::value_type(key, inputController));
return inputController; return inputController;
} }
} }

View file

@ -342,14 +342,18 @@ void Stats::setRenderDetails(const RenderDetails& details) {
STAT_UPDATE(triangles, details._trianglesRendered); STAT_UPDATE(triangles, details._trianglesRendered);
STAT_UPDATE(materialSwitches, details._materialSwitches); STAT_UPDATE(materialSwitches, details._materialSwitches);
if (_expanded) { if (_expanded) {
STAT_UPDATE(meshOpaque, details._opaque._rendered);
STAT_UPDATE(meshTranslucent, details._opaque._rendered);
STAT_UPDATE(opaqueConsidered, details._opaque._considered); STAT_UPDATE(opaqueConsidered, details._opaque._considered);
STAT_UPDATE(opaqueOutOfView, details._opaque._outOfView); STAT_UPDATE(opaqueOutOfView, details._opaque._outOfView);
STAT_UPDATE(opaqueTooSmall, details._opaque._tooSmall); STAT_UPDATE(opaqueTooSmall, details._opaque._tooSmall);
STAT_UPDATE(opaqueRendered, details._opaque._rendered);
STAT_UPDATE(translucentConsidered, details._translucent._considered); STAT_UPDATE(translucentConsidered, details._translucent._considered);
STAT_UPDATE(translucentOutOfView, details._translucent._outOfView); STAT_UPDATE(translucentOutOfView, details._translucent._outOfView);
STAT_UPDATE(translucentTooSmall, details._translucent._tooSmall); STAT_UPDATE(translucentTooSmall, details._translucent._tooSmall);
STAT_UPDATE(translucentRendered, details._translucent._rendered);
STAT_UPDATE(otherConsidered, details._other._considered);
STAT_UPDATE(otherOutOfView, details._other._outOfView);
STAT_UPDATE(otherTooSmall, details._other._tooSmall);
STAT_UPDATE(otherRendered, details._other._rendered);
} }
} }

View file

@ -58,14 +58,18 @@ class Stats : public QQuickItem {
STATS_PROPERTY(int, triangles, 0) STATS_PROPERTY(int, triangles, 0)
STATS_PROPERTY(int, quads, 0) STATS_PROPERTY(int, quads, 0)
STATS_PROPERTY(int, materialSwitches, 0) STATS_PROPERTY(int, materialSwitches, 0)
STATS_PROPERTY(int, meshOpaque, 0)
STATS_PROPERTY(int, meshTranslucent, 0)
STATS_PROPERTY(int, opaqueConsidered, 0) STATS_PROPERTY(int, opaqueConsidered, 0)
STATS_PROPERTY(int, opaqueOutOfView, 0) STATS_PROPERTY(int, opaqueOutOfView, 0)
STATS_PROPERTY(int, opaqueTooSmall, 0) STATS_PROPERTY(int, opaqueTooSmall, 0)
STATS_PROPERTY(int, opaqueRendered, 0)
STATS_PROPERTY(int, translucentConsidered, 0) STATS_PROPERTY(int, translucentConsidered, 0)
STATS_PROPERTY(int, translucentOutOfView, 0) STATS_PROPERTY(int, translucentOutOfView, 0)
STATS_PROPERTY(int, translucentTooSmall, 0) STATS_PROPERTY(int, translucentTooSmall, 0)
STATS_PROPERTY(int, translucentRendered, 0)
STATS_PROPERTY(int, otherConsidered, 0)
STATS_PROPERTY(int, otherOutOfView, 0)
STATS_PROPERTY(int, otherTooSmall, 0)
STATS_PROPERTY(int, otherRendered, 0)
STATS_PROPERTY(QString, sendingMode, QString()) STATS_PROPERTY(QString, sendingMode, QString())
STATS_PROPERTY(QString, packetStats, QString()) STATS_PROPERTY(QString, packetStats, QString())
STATS_PROPERTY(QString, lodStatus, QString()) STATS_PROPERTY(QString, lodStatus, QString())
@ -135,14 +139,18 @@ signals:
void trianglesChanged(); void trianglesChanged();
void quadsChanged(); void quadsChanged();
void materialSwitchesChanged(); void materialSwitchesChanged();
void meshOpaqueChanged();
void meshTranslucentChanged();
void opaqueConsideredChanged(); void opaqueConsideredChanged();
void opaqueOutOfViewChanged(); void opaqueOutOfViewChanged();
void opaqueTooSmallChanged(); void opaqueTooSmallChanged();
void opaqueRenderedChanged();
void translucentConsideredChanged(); void translucentConsideredChanged();
void translucentOutOfViewChanged(); void translucentOutOfViewChanged();
void translucentTooSmallChanged(); void translucentTooSmallChanged();
void translucentRenderedChanged();
void otherConsideredChanged();
void otherOutOfViewChanged();
void otherTooSmallChanged();
void otherRenderedChanged();
void sendingModeChanged(); void sendingModeChanged();
void packetStatsChanged(); void packetStatsChanged();
void lodStatusChanged(); void lodStatusChanged();

View file

@ -72,7 +72,7 @@ DeadZoneFilter::FactoryEntryBuilder DeadZoneFilter::_factoryEntryBuilder;
float DeadZoneFilter::apply(float value) const { float DeadZoneFilter::apply(float value) const {
float scale = 1.0f / (1.0f - _min); float scale = 1.0f / (1.0f - _min);
if (abs(value) < _min) { if (std::abs(value) < _min) {
return 0.0f; return 0.0f;
} }
return (value - _min) * scale; return (value - _min) * scale;
@ -89,9 +89,9 @@ PulseFilter::FactoryEntryBuilder PulseFilter::_factoryEntryBuilder;
float PulseFilter::apply(float value) const { float PulseFilter::apply(float value) const {
float result = 0.0; float result = 0.0f;
if (0.0 != value) { if (0.0f != value) {
float now = secTimestampNow(); float now = secTimestampNow();
float delta = now - _lastEmitTime; float delta = now - _lastEmitTime;
if (delta >= _interval) { if (delta >= _interval) {

View file

@ -6,32 +6,5 @@
// 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
// //
#pragma once
#ifndef hifi_Controllers_Route_h
#define hifi_Controllers_Route_h
#include "Endpoint.h" #include "Route.h"
#include "Filter.h"
#include "Logging.h"
class QJsonObject;
namespace controller {
/*
* encapsulates a source, destination and filters to apply
*/
class Route {
public:
Endpoint::Pointer _source;
Endpoint::Pointer _destination;
Filter::List _filters;
using Pointer = std::shared_ptr<Route>;
using List = std::list<Pointer>;
void parse(const QJsonObject& json);
};
}
#endif

View file

@ -102,7 +102,7 @@ namespace controller {
: Endpoint(UserInputMapper::Input(UserInputMapper::Input::INVALID_INPUT)), Pair(first, second) { } : Endpoint(UserInputMapper::Input(UserInputMapper::Input::INVALID_INPUT)), Pair(first, second) { }
virtual float value() { virtual float value() {
float result = first->value() * -1.0 + second->value(); float result = first->value() * -1.0f + second->value();
return result; return result;
} }
@ -408,8 +408,7 @@ namespace controller {
// Fetch the value, may have been overriden by previous loopback routes // Fetch the value, may have been overriden by previous loopback routes
if (source->isPose()) { if (source->isPose()) {
Pose value = getPoseValue(source); Pose value = getPoseValue(source);
// no filters yet for pose
destination->apply(value, Pose(), source); destination->apply(value, Pose(), source);
} else { } else {
float value = getValue(source); float value = getValue(source);
@ -498,7 +497,7 @@ namespace controller {
} }
bool ScriptingInterface::isButtonPressed(int buttonIndex) const { bool ScriptingInterface::isButtonPressed(int buttonIndex) const {
return getButtonValue((StandardButtonChannel)buttonIndex) == 0.0 ? false : true; return getButtonValue((StandardButtonChannel)buttonIndex) == 0.0f ? false : true;
} }
int ScriptingInterface::getNumberOfTriggers() const { int ScriptingInterface::getNumberOfTriggers() const {

View file

@ -15,8 +15,6 @@
#include "StandardController.h" #include "StandardController.h"
const float CONTROLLER_THRESHOLD = 0.3f;
StandardController::~StandardController() { StandardController::~StandardController() {
} }

View file

@ -52,10 +52,9 @@ class RouteBuilderProxy : public QObject {
void to(const Endpoint::Pointer& destination); void to(const Endpoint::Pointer& destination);
void addFilter(Filter::Lambda lambda); void addFilter(Filter::Lambda lambda);
void addFilter(Filter::Pointer filter); void addFilter(Filter::Pointer filter);
ScriptingInterface& _parent;
Mapping::Pointer _mapping; Mapping::Pointer _mapping;
Route::Pointer _route; Route::Pointer _route;
ScriptingInterface& _parent;
}; };
} }

View file

@ -745,10 +745,18 @@ FBXGeometry* FBXReader::extractFBXGeometry(const QVariantHash& mapping, const QS
// see FBX documentation, http://download.autodesk.com/us/fbx/20112/FBX_SDK_HELP/index.html // see FBX documentation, http://download.autodesk.com/us/fbx/20112/FBX_SDK_HELP/index.html
model.translation = translation; model.translation = translation;
model.preTransform = glm::translate(rotationOffset) * glm::translate(rotationPivot); model.preTransform = glm::translate(rotationOffset) * glm::translate(rotationPivot);
model.preRotation = glm::quat(glm::radians(preRotation)); model.preRotation = glm::quat(glm::radians(preRotation));
model.rotation = glm::quat(glm::radians(rotation)); model.rotation = glm::quat(glm::radians(rotation));
model.postRotation = glm::quat(glm::radians(postRotation)); model.postRotation = glm::quat(glm::radians(postRotation));
if (geometry.applicationName.startsWith("Blender")) {
// blender puts the jointOffset in the wrong place.
model.preRotation = model.rotation;
model.rotation = glm::quat();
}
model.postTransform = glm::translate(-rotationPivot) * glm::translate(scaleOffset) * model.postTransform = glm::translate(-rotationPivot) * glm::translate(scaleOffset) *
glm::translate(scalePivot) * glm::scale(scale) * glm::translate(-scalePivot); glm::translate(scalePivot) * glm::scale(scale) * glm::translate(-scalePivot);
// NOTE: angles from the FBX file are in degrees // NOTE: angles from the FBX file are in degrees

View file

@ -32,10 +32,6 @@
Q_DECLARE_LOGGING_CATEGORY(inputplugins) Q_DECLARE_LOGGING_CATEGORY(inputplugins)
Q_LOGGING_CATEGORY(inputplugins, "hifi.inputplugins") Q_LOGGING_CATEGORY(inputplugins, "hifi.inputplugins")
// These bits aren't used for buttons, so they can be used as masks:
const unsigned int LEFT_MASK = 0;
const unsigned int RIGHT_MASK = 1U << 1;
#ifdef HAVE_SIXENSE #ifdef HAVE_SIXENSE
const int CALIBRATION_STATE_IDLE = 0; const int CALIBRATION_STATE_IDLE = 0;

View file

@ -186,6 +186,8 @@ double mapComponent(double sobelValue) {
gpu::Texture* TextureUsage::createNormalTextureFromBumpImage(const QImage& srcImage, const std::string& srcImageName) { gpu::Texture* TextureUsage::createNormalTextureFromBumpImage(const QImage& srcImage, const std::string& srcImageName) {
QImage image = srcImage; QImage image = srcImage;
#if 0
// PR 5540 by AlessandroSigna // PR 5540 by AlessandroSigna
// integrated here as a specialized TextureLoader for bumpmaps // integrated here as a specialized TextureLoader for bumpmaps
// The conversion is done using the Sobel Filter to calculate the derivatives from the grayscale image // The conversion is done using the Sobel Filter to calculate the derivatives from the grayscale image
@ -236,6 +238,7 @@ gpu::Texture* TextureUsage::createNormalTextureFromBumpImage(const QImage& srcIm
result.setPixel(i, j, qRgbValue); result.setPixel(i, j, qRgbValue);
} }
} }
#endif
gpu::Texture* theTexture = nullptr; gpu::Texture* theTexture = nullptr;
if ((image.width() > 0) && (image.height() > 0)) { if ((image.width() > 0) && (image.height() > 0)) {

View file

@ -89,11 +89,9 @@ render::ItemKey MeshPartPayload::getKey() const {
} }
render::Item::Bound MeshPartPayload::getBound() const { render::Item::Bound MeshPartPayload::getBound() const {
if (_isBoundInvalid) { // NOTE: we can't cache this bounds because we need to handle the case of a moving
model->getPartBounds(meshIndex, partIndex); // entity or mesh part.
_isBoundInvalid = false; return model->getPartBounds(meshIndex, partIndex);
}
return _bound;
} }
void MeshPartPayload::drawCall(gpu::Batch& batch) const { void MeshPartPayload::drawCall(gpu::Batch& batch) const {

View file

@ -55,9 +55,6 @@ public:
bool _hasColorAttrib = false; bool _hasColorAttrib = false;
bool _isSkinned = false; bool _isSkinned = false;
bool _isBlendShaped = false; bool _isBlendShaped = false;
mutable render::Item::Bound _bound;
mutable bool _isBoundInvalid = true;
}; };
namespace render { namespace render {

View file

@ -76,7 +76,7 @@ RenderDeferredTask::RenderDeferredTask() : Task() {
} }
) )
))); )));
_jobs.push_back(Job(new CullItems::JobModel("CullOpaque", _jobs.back().getOutput()))); _jobs.push_back(Job(new CullItemsOpaque::JobModel("CullOpaque", _jobs.back().getOutput())));
_jobs.push_back(Job(new DepthSortItems::JobModel("DepthSortOpaque", _jobs.back().getOutput()))); _jobs.push_back(Job(new DepthSortItems::JobModel("DepthSortOpaque", _jobs.back().getOutput())));
auto& renderedOpaques = _jobs.back().getOutput(); auto& renderedOpaques = _jobs.back().getOutput();
_jobs.push_back(Job(new DrawOpaqueDeferred::JobModel("DrawOpaqueDeferred", _jobs.back().getOutput()))); _jobs.push_back(Job(new DrawOpaqueDeferred::JobModel("DrawOpaqueDeferred", _jobs.back().getOutput())));
@ -105,7 +105,9 @@ RenderDeferredTask::RenderDeferredTask() : Task() {
} }
) )
))); )));
_jobs.push_back(Job(new CullItems::JobModel("CullTransparent", _jobs.back().getOutput()))); _jobs.push_back(Job(new CullItemsTransparent::JobModel("CullTransparent", _jobs.back().getOutput())));
_jobs.push_back(Job(new DepthSortItems::JobModel("DepthSortTransparent", _jobs.back().getOutput(), DepthSortItems(false)))); _jobs.push_back(Job(new DepthSortItems::JobModel("DepthSortTransparent", _jobs.back().getOutput(), DepthSortItems(false))));
_jobs.push_back(Job(new DrawTransparentDeferred::JobModel("TransparentDeferred", _jobs.back().getOutput()))); _jobs.push_back(Job(new DrawTransparentDeferred::JobModel("TransparentDeferred", _jobs.back().getOutput())));

View file

@ -115,6 +115,26 @@ void CullItems::run(const SceneContextPointer& sceneContext, const RenderContext
outItems.clear(); outItems.clear();
outItems.reserve(inItems.size()); outItems.reserve(inItems.size());
RenderArgs* args = renderContext->args;
args->_details.pointTo(RenderDetails::OTHER_ITEM);
cullItems(sceneContext, renderContext, inItems, outItems);
}
void CullItemsOpaque::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, const ItemIDsBounds& inItems, ItemIDsBounds& outItems) {
outItems.clear();
outItems.reserve(inItems.size());
RenderArgs* args = renderContext->args;
args->_details.pointTo(RenderDetails::OPAQUE_ITEM);
cullItems(sceneContext, renderContext, inItems, outItems);
}
void CullItemsTransparent::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, const ItemIDsBounds& inItems, ItemIDsBounds& outItems) {
outItems.clear();
outItems.reserve(inItems.size());
RenderArgs* args = renderContext->args;
args->_details.pointTo(RenderDetails::TRANSLUCENT_ITEM);
cullItems(sceneContext, renderContext, inItems, outItems); cullItems(sceneContext, renderContext, inItems, outItems);
} }
@ -233,9 +253,10 @@ void DrawLight::run(const SceneContextPointer& sceneContext, const RenderContext
ItemIDsBounds culledItems; ItemIDsBounds culledItems;
culledItems.reserve(inItems.size()); culledItems.reserve(inItems.size());
RenderArgs* args = renderContext->args;
args->_details.pointTo(RenderDetails::OTHER_ITEM);
cullItems(sceneContext, renderContext, inItems, culledItems); cullItems(sceneContext, renderContext, inItems, culledItems);
RenderArgs* args = renderContext->args;
gpu::doInBatch(args->_context, [=](gpu::Batch& batch) { gpu::doInBatch(args->_context, [=](gpu::Batch& batch) {
args->_batch = &batch; args->_batch = &batch;
renderItems(sceneContext, renderContext, culledItems); renderItems(sceneContext, renderContext, culledItems);

View file

@ -231,10 +231,21 @@ public:
class CullItems { class CullItems {
public: public:
void run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, const ItemIDsBounds& inItems, ItemIDsBounds& outItems); void run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, const ItemIDsBounds& inItems, ItemIDsBounds& outItems);
typedef Job::ModelIO<CullItems, ItemIDsBounds, ItemIDsBounds> JobModel; typedef Job::ModelIO<CullItems, ItemIDsBounds, ItemIDsBounds> JobModel;
}; };
class CullItemsOpaque {
public:
void run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, const ItemIDsBounds& inItems, ItemIDsBounds& outItems);
typedef Job::ModelIO<CullItemsOpaque, ItemIDsBounds, ItemIDsBounds> JobModel;
};
class CullItemsTransparent {
public:
void run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, const ItemIDsBounds& inItems, ItemIDsBounds& outItems);
typedef Job::ModelIO<CullItemsTransparent, ItemIDsBounds, ItemIDsBounds> JobModel;
};
class DepthSortItems { class DepthSortItems {
public: public:
bool _frontToBack = true; bool _frontToBack = true;

View file

@ -156,29 +156,18 @@ void vhacd::VHACDUtil::fattenMeshes(const FBXMesh& mesh, FBXMesh& result,
AABox getAABoxForMeshPart(const FBXMesh& mesh, const FBXMeshPart &meshPart) { AABox getAABoxForMeshPart(const FBXMesh& mesh, const FBXMeshPart &meshPart) {
AABox aaBox; AABox aaBox;
unsigned int triangleCount = meshPart.triangleIndices.size() / 3; unsigned int triangleCount = meshPart.triangleIndices.size() / 3;
for (unsigned int i = 0; i < triangleCount; i++) { for (unsigned int i = 0; i < triangleCount; ++i) {
glm::vec3 p0 = mesh.vertices[meshPart.triangleIndices[i * 3]]; aaBox += mesh.vertices[meshPart.triangleIndices[i * 3]];
glm::vec3 p1 = mesh.vertices[meshPart.triangleIndices[i * 3 + 1]]; aaBox += mesh.vertices[meshPart.triangleIndices[i * 3 + 1]];
glm::vec3 p2 = mesh.vertices[meshPart.triangleIndices[i * 3 + 2]]; aaBox += mesh.vertices[meshPart.triangleIndices[i * 3 + 2]];
aaBox += p0;
aaBox += p1;
aaBox += p2;
} }
unsigned int quadCount = meshPart.quadIndices.size() / 4; unsigned int quadCount = meshPart.quadIndices.size() / 4;
for (unsigned int i = 0; i < quadCount; i++) { for (unsigned int i = 0; i < quadCount; ++i) {
unsigned int p0Index = meshPart.quadIndices[i * 4]; aaBox += mesh.vertices[meshPart.quadIndices[i * 4]];
unsigned int p1Index = meshPart.quadIndices[i * 4 + 1]; aaBox += mesh.vertices[meshPart.quadIndices[i * 4 + 1]];
unsigned int p2Index = meshPart.quadIndices[i * 4 + 2]; aaBox += mesh.vertices[meshPart.quadIndices[i * 4 + 2]];
unsigned int p3Index = meshPart.quadIndices[i * 4 + 3]; aaBox += mesh.vertices[meshPart.quadIndices[i * 4 + 3]];
glm::vec3 p0 = mesh.vertices[p0Index];
glm::vec3 p1 = mesh.vertices[p1Index + 1];
glm::vec3 p2 = mesh.vertices[p2Index + 2];
glm::vec3 p3 = mesh.vertices[p3Index + 3];
aaBox += p0;
aaBox += p1;
aaBox += p2;
aaBox += p3;
} }
return aaBox; return aaBox;