mirror of
https://github.com/lubosz/overte.git
synced 2025-04-24 03:53:52 +02:00
Merge branch 'master' of github.com:highfidelity/hifi into fix-ac-agent-sees-others
This commit is contained in:
commit
f34f0f51ec
31 changed files with 404 additions and 150 deletions
|
@ -130,6 +130,11 @@ Var AR_RegFlags
|
|||
SectionSetFlags ${${SecName}} $AR_SecFlags
|
||||
|
||||
"default_${SecName}:"
|
||||
; The client is always selected by default
|
||||
${If} ${SecName} == @CLIENT_COMPONENT_NAME@
|
||||
SectionSetFlags ${${SecName}} 17
|
||||
${EndIf}
|
||||
|
||||
!insertmacro LoadSectionSelectedIntoVar ${SecName} ${SecName}_selected
|
||||
!macroend
|
||||
|
||||
|
@ -243,6 +248,12 @@ FunctionEnd
|
|||
|
||||
;--------------------------------
|
||||
; Installation types
|
||||
|
||||
Section "-Previous Install Cleanup"
|
||||
; Remove the resources folder so we don't end up including removed QML files
|
||||
RMDir /r "$INSTDIR\resources"
|
||||
SectionEnd
|
||||
|
||||
@CPACK_NSIS_INSTALLATION_TYPES@
|
||||
|
||||
;--------------------------------
|
||||
|
|
|
@ -556,14 +556,13 @@ ModelPointer EntityTreeRenderer::allocateModel(const QString& url, float loading
|
|||
return model;
|
||||
}
|
||||
|
||||
ModelPointer EntityTreeRenderer::updateModel(ModelPointer model, const QString& newUrl, const QString& collisionUrl) {
|
||||
ModelPointer EntityTreeRenderer::updateModel(ModelPointer model, const QString& newUrl) {
|
||||
// Only create and delete models on the thread that owns the EntityTreeRenderer
|
||||
if (QThread::currentThread() != thread()) {
|
||||
QMetaObject::invokeMethod(this, "updateModel", Qt::BlockingQueuedConnection,
|
||||
Q_RETURN_ARG(ModelPointer, model),
|
||||
Q_ARG(ModelPointer, model),
|
||||
Q_ARG(const QString&, newUrl),
|
||||
Q_ARG(const QString&, collisionUrl));
|
||||
Q_ARG(const QString&, newUrl));
|
||||
|
||||
return model;
|
||||
}
|
||||
|
|
|
@ -76,7 +76,7 @@ public:
|
|||
Q_INVOKABLE ModelPointer allocateModel(const QString& url, float loadingPriority = 0.0f);
|
||||
|
||||
/// if a renderable entity item needs to update the URL of a model, we will handle that for the entity
|
||||
Q_INVOKABLE ModelPointer updateModel(ModelPointer original, const QString& newUrl, const QString& collisionUrl);
|
||||
Q_INVOKABLE ModelPointer updateModel(ModelPointer original, const QString& newUrl);
|
||||
|
||||
/// if a renderable entity item is done with a model, it should return it to us
|
||||
void releaseModel(ModelPointer model);
|
||||
|
|
|
@ -548,6 +548,15 @@ EntityItemProperties RenderableModelEntityItem::getProperties(EntityPropertyFlag
|
|||
if (_originalTexturesRead) {
|
||||
properties.setTextureNames(_originalTextures);
|
||||
}
|
||||
|
||||
if (_model) {
|
||||
properties.setRenderInfoVertexCount(_model->getRenderInfoVertexCount());
|
||||
properties.setRenderInfoTextureCount(_model->getRenderInfoTextureCount());
|
||||
properties.setRenderInfoTextureSize(_model->getRenderInfoTextureSize());
|
||||
properties.setRenderInfoDrawCalls(_model->getRenderInfoDrawCalls());
|
||||
properties.setRenderInfoHasTransparent(_model->getRenderInfoHasTransparent());
|
||||
}
|
||||
|
||||
return properties;
|
||||
}
|
||||
|
||||
|
|
|
@ -580,6 +580,24 @@ QScriptValue EntityItemProperties::copyToScriptValue(QScriptEngine* engine, bool
|
|||
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_CLIENT_ONLY, clientOnly);
|
||||
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_OWNING_AVATAR_ID, owningAvatarID);
|
||||
|
||||
// Rendering info
|
||||
if (!skipDefaults) {
|
||||
QScriptValue renderInfo = engine->newObject();
|
||||
|
||||
// currently only supported by models
|
||||
if (_type == EntityTypes::Model) {
|
||||
renderInfo.setProperty("verticesCount", (int)getRenderInfoVertexCount()); // FIXME - theoretically the number of vertex could be > max int
|
||||
renderInfo.setProperty("texturesSize", (int)getRenderInfoTextureSize()); // FIXME - theoretically the size of textures could be > max int
|
||||
renderInfo.setProperty("hasTransparent", getRenderInfoHasTransparent());
|
||||
renderInfo.setProperty("drawCalls", getRenderInfoDrawCalls());
|
||||
}
|
||||
|
||||
if (_type == EntityTypes::Model || _type == EntityTypes::PolyLine || _type == EntityTypes::ParticleEffect) {
|
||||
renderInfo.setProperty("texturesCount", QScriptValue(_textureNames.count()));
|
||||
}
|
||||
COPY_PROPERTY_TO_QSCRIPTVALUE_GETTER_NO_SKIP(renderInfo, renderInfo); // Gettable but not settable
|
||||
}
|
||||
|
||||
properties.setProperty("clientOnly", convertScriptValue(engine, getClientOnly()));
|
||||
properties.setProperty("owningAvatarID", convertScriptValue(engine, getOwningAvatarID()));
|
||||
|
||||
|
|
|
@ -285,6 +285,19 @@ public:
|
|||
void setJointRotationsDirty() { _jointRotationsSetChanged = true; _jointRotationsChanged = true; }
|
||||
void setJointTranslationsDirty() { _jointTranslationsSetChanged = true; _jointTranslationsChanged = true; }
|
||||
|
||||
// render info related items
|
||||
size_t getRenderInfoVertexCount() const { return _renderInfoVertexCount; }
|
||||
void setRenderInfoVertexCount(size_t value) { _renderInfoVertexCount = value; }
|
||||
int getRenderInfoTextureCount() const { return _renderInfoTextureCount; }
|
||||
void setRenderInfoTextureCount(int value) { _renderInfoTextureCount = value; }
|
||||
size_t getRenderInfoTextureSize() const { return _renderInfoTextureSize; }
|
||||
void setRenderInfoTextureSize(size_t value) { _renderInfoTextureSize = value; }
|
||||
int getRenderInfoDrawCalls() const { return _renderInfoDrawCalls; }
|
||||
void setRenderInfoDrawCalls(int value) { _renderInfoDrawCalls = value; }
|
||||
bool getRenderInfoHasTransparent() const { return _renderInfoHasTransparent; }
|
||||
void setRenderInfoHasTransparent(bool value) { _renderInfoHasTransparent = value; }
|
||||
|
||||
|
||||
protected:
|
||||
QString getCollisionMaskAsString() const;
|
||||
void setCollisionMaskFromString(const QString& maskString);
|
||||
|
@ -308,6 +321,12 @@ private:
|
|||
glm::vec3 _naturalDimensions;
|
||||
glm::vec3 _naturalPosition;
|
||||
|
||||
size_t _renderInfoVertexCount { 0 };
|
||||
int _renderInfoTextureCount { 0 };
|
||||
size_t _renderInfoTextureSize { 0 };
|
||||
int _renderInfoDrawCalls { 0 };
|
||||
bool _renderInfoHasTransparent { false };
|
||||
|
||||
EntityPropertyFlags _desiredProperties; // if set will narrow scopes of copy/to/from to just these properties
|
||||
};
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ void GLBackend::do_beginQuery(const Batch& batch, size_t paramOffset) {
|
|||
auto query = batch._queries.get(batch._params[paramOffset]._uint);
|
||||
GLQuery* glquery = syncGPUObject(*query);
|
||||
if (glquery) {
|
||||
glGetInteger64v(GL_TIMESTAMP, (GLint64*)&glquery->_batchElapsedTime);
|
||||
if (timeElapsed) {
|
||||
glBeginQuery(GL_TIME_ELAPSED, glquery->_endqo);
|
||||
} else {
|
||||
|
@ -43,6 +44,10 @@ void GLBackend::do_endQuery(const Batch& batch, size_t paramOffset) {
|
|||
} else {
|
||||
glQueryCounter(glquery->_endqo, GL_TIMESTAMP);
|
||||
}
|
||||
GLint64 now;
|
||||
glGetInteger64v(GL_TIMESTAMP, &now);
|
||||
glquery->_batchElapsedTime = now - glquery->_batchElapsedTime;
|
||||
|
||||
(void)CHECK_GL_ERROR();
|
||||
}
|
||||
}
|
||||
|
@ -61,7 +66,7 @@ void GLBackend::do_getQuery(const Batch& batch, size_t paramOffset) {
|
|||
glGetQueryObjectui64v(glquery->_endqo, GL_QUERY_RESULT, &end);
|
||||
glquery->_result = end - start;
|
||||
}
|
||||
query->triggerReturnHandler(glquery->_result);
|
||||
query->triggerReturnHandler(glquery->_result, glquery->_batchElapsedTime);
|
||||
}
|
||||
(void)CHECK_GL_ERROR();
|
||||
}
|
||||
|
|
|
@ -48,6 +48,7 @@ public:
|
|||
const GLuint& _endqo = { _id };
|
||||
const GLuint _beginqo = { 0 };
|
||||
GLuint64 _result { (GLuint64)-1 };
|
||||
GLuint64 _batchElapsedTime { (GLuint64) 0 };
|
||||
|
||||
protected:
|
||||
GLQuery(const std::weak_ptr<GLBackend>& backend, const Query& query, GLuint endId, GLuint beginId) : Parent(backend, query, endId), _beginqo(beginId) {}
|
||||
|
|
|
@ -104,7 +104,7 @@ bool GLTextureTransferHelper::processQueueItems(const Queue& messages) {
|
|||
QThread::usleep(1);
|
||||
result = glClientWaitSync(fence, 0, 0);
|
||||
}
|
||||
glDeleteSync(package.fence);
|
||||
glDeleteSync(fence);
|
||||
}
|
||||
|
||||
object->_contentStamp = texturePointer->getDataStamp();
|
||||
|
|
|
@ -24,12 +24,16 @@ Query::~Query()
|
|||
{
|
||||
}
|
||||
|
||||
double Query::getElapsedTime() const {
|
||||
double Query::getGPUElapsedTime() const {
|
||||
return ((double)_queryResult) / 1000000.0;
|
||||
}
|
||||
double Query::getBatchElapsedTime() const {
|
||||
return ((double)_usecBatchElapsedTime) / 1000000.0;
|
||||
}
|
||||
|
||||
void Query::triggerReturnHandler(uint64_t queryResult) {
|
||||
void Query::triggerReturnHandler(uint64_t queryResult, uint64_t batchElapsedTime) {
|
||||
_queryResult = queryResult;
|
||||
_usecBatchElapsedTime = batchElapsedTime;
|
||||
if (_returnHandler) {
|
||||
_returnHandler(*this);
|
||||
}
|
||||
|
@ -40,8 +44,8 @@ RangeTimer::RangeTimer() {
|
|||
for (int i = 0; i < QUERY_QUEUE_SIZE; i++) {
|
||||
_timerQueries.push_back(std::make_shared<gpu::Query>([&, i] (const Query& query) {
|
||||
_tailIndex ++;
|
||||
auto elapsedTime = query.getElapsedTime();
|
||||
_movingAverage.addSample(elapsedTime);
|
||||
_movingAverageGPU.addSample(query.getGPUElapsedTime());
|
||||
_movingAverageBatch.addSample(query.getBatchElapsedTime());
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
@ -66,6 +70,10 @@ void RangeTimer::end(gpu::Batch& batch) {
|
|||
}
|
||||
}
|
||||
|
||||
double RangeTimer::getAverage() const {
|
||||
return _movingAverage.average;
|
||||
double RangeTimer::getGPUAverage() const {
|
||||
return _movingAverageGPU.average;
|
||||
}
|
||||
|
||||
double RangeTimer::getBatchAverage() const {
|
||||
return _movingAverageBatch.average;
|
||||
}
|
|
@ -30,14 +30,17 @@ namespace gpu {
|
|||
Query(const Handler& returnHandler);
|
||||
~Query();
|
||||
|
||||
double getElapsedTime() const;
|
||||
double getGPUElapsedTime() const;
|
||||
double getBatchElapsedTime() const;
|
||||
|
||||
// Only for gpu::Context
|
||||
const GPUObjectPointer gpuObject {};
|
||||
void triggerReturnHandler(uint64_t queryResult);
|
||||
void triggerReturnHandler(uint64_t queryResult, uint64_t batchElapsedTime);
|
||||
protected:
|
||||
Handler _returnHandler;
|
||||
|
||||
uint64_t _queryResult = 0;
|
||||
uint64_t _queryResult { 0 };
|
||||
uint64_t _usecBatchElapsedTime { 0 };
|
||||
};
|
||||
|
||||
typedef std::shared_ptr<Query> QueryPointer;
|
||||
|
@ -53,7 +56,8 @@ namespace gpu {
|
|||
void begin(gpu::Batch& batch);
|
||||
void end(gpu::Batch& batch);
|
||||
|
||||
double getAverage() const;
|
||||
double getGPUAverage() const;
|
||||
double getBatchAverage() const;
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -62,7 +66,8 @@ namespace gpu {
|
|||
gpu::Queries _timerQueries;
|
||||
int _headIndex = -1;
|
||||
int _tailIndex = -1;
|
||||
MovingAverage<double, QUERY_QUEUE_SIZE * 2> _movingAverage;
|
||||
MovingAverage<double, QUERY_QUEUE_SIZE * 2> _movingAverageGPU;
|
||||
MovingAverage<double, QUERY_QUEUE_SIZE * 2> _movingAverageBatch;
|
||||
|
||||
int rangeIndex(int index) const { return (index % QUERY_QUEUE_SIZE); }
|
||||
};
|
||||
|
|
|
@ -59,6 +59,7 @@ public:
|
|||
TextureMap() {}
|
||||
|
||||
void setTextureSource(gpu::TextureSourcePointer& textureSource);
|
||||
gpu::TextureSourcePointer getTextureSource() const { return _textureSource; }
|
||||
|
||||
bool isDefined() const;
|
||||
gpu::TextureView getTextureView() const;
|
||||
|
|
|
@ -432,7 +432,8 @@ void AmbientOcclusionEffect::run(const render::SceneContextPointer& sceneContext
|
|||
});
|
||||
|
||||
// Update the timer
|
||||
std::static_pointer_cast<Config>(renderContext->jobConfig)->gpuTime = _gpuTimer.getAverage();
|
||||
auto config = std::static_pointer_cast<Config>(renderContext->jobConfig);
|
||||
config->setGPUBatchRunTime(_gpuTimer.getGPUAverage(), _gpuTimer.getBatchAverage());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ protected:
|
|||
|
||||
using AmbientOcclusionFramebufferPointer = std::shared_ptr<AmbientOcclusionFramebuffer>;
|
||||
|
||||
class AmbientOcclusionEffectConfig : public render::Job::Config::Persistent {
|
||||
class AmbientOcclusionEffectConfig : public render::GPUJobConfig::Persistent {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(bool enabled MEMBER enabled NOTIFY dirty)
|
||||
Q_PROPERTY(bool ditheringEnabled MEMBER ditheringEnabled NOTIFY dirty)
|
||||
|
@ -68,9 +68,9 @@ class AmbientOcclusionEffectConfig : public render::Job::Config::Persistent {
|
|||
Q_PROPERTY(int numSamples MEMBER numSamples WRITE setNumSamples)
|
||||
Q_PROPERTY(int resolutionLevel MEMBER resolutionLevel WRITE setResolutionLevel)
|
||||
Q_PROPERTY(int blurRadius MEMBER blurRadius WRITE setBlurRadius)
|
||||
Q_PROPERTY(double gpuTime READ getGpuTime)
|
||||
|
||||
public:
|
||||
AmbientOcclusionEffectConfig() : render::Job::Config::Persistent("Ambient Occlusion", false) {}
|
||||
AmbientOcclusionEffectConfig() : render::GPUJobConfig::Persistent("Ambient Occlusion", false) {}
|
||||
|
||||
const int MAX_RESOLUTION_LEVEL = 4;
|
||||
const int MAX_BLUR_RADIUS = 6;
|
||||
|
@ -84,7 +84,6 @@ public:
|
|||
void setNumSamples(int samples) { numSamples = std::max(1.0f, (float)samples); emit dirty(); }
|
||||
void setResolutionLevel(int level) { resolutionLevel = std::max(0, std::min(level, MAX_RESOLUTION_LEVEL)); emit dirty(); }
|
||||
void setBlurRadius(int radius) { blurRadius = std::max(0, std::min(MAX_BLUR_RADIUS, radius)); emit dirty(); }
|
||||
double getGpuTime() { return gpuTime; }
|
||||
|
||||
float radius{ 0.5f };
|
||||
float perspectiveScale{ 1.0f };
|
||||
|
@ -99,7 +98,6 @@ public:
|
|||
bool ditheringEnabled{ true }; // randomize the distribution of taps per pixel, should always be true
|
||||
bool borderingEnabled{ true }; // avoid evaluating information from non existing pixels out of the frame, should always be true
|
||||
bool fetchMipsEnabled{ true }; // fetch taps in sub mips to otpimize cache, should always be true
|
||||
double gpuTime{ 0.0 };
|
||||
|
||||
signals:
|
||||
void dirty();
|
||||
|
|
|
@ -714,5 +714,5 @@ void RenderDeferred::run(const SceneContextPointer& sceneContext, const RenderCo
|
|||
});
|
||||
|
||||
auto config = std::static_pointer_cast<Config>(renderContext->jobConfig);
|
||||
config->gpuTime = _gpuTimer.getAverage();
|
||||
config->setGPUBatchRunTime(_gpuTimer.getGPUAverage(), _gpuTimer.getBatchAverage());
|
||||
}
|
||||
|
|
|
@ -161,21 +161,7 @@ public:
|
|||
void run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext);
|
||||
};
|
||||
|
||||
|
||||
class RenderDeferredConfig : public render::Job::Config {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(double gpuTime READ getGpuTime)
|
||||
public:
|
||||
RenderDeferredConfig() : render::Job::Config(true) {}
|
||||
|
||||
double getGpuTime() { return gpuTime; }
|
||||
|
||||
double gpuTime{ 0.0 };
|
||||
|
||||
signals:
|
||||
void dirty();
|
||||
};
|
||||
|
||||
using RenderDeferredConfig = render::GPUJobConfig;
|
||||
|
||||
class RenderDeferred {
|
||||
public:
|
||||
|
|
|
@ -71,8 +71,37 @@ void MeshPartPayload::updateTransform(const Transform& transform, const Transfor
|
|||
|
||||
void MeshPartPayload::updateMaterial(model::MaterialPointer drawMaterial) {
|
||||
_drawMaterial = drawMaterial;
|
||||
calculateMaterialSize();
|
||||
}
|
||||
|
||||
bool MeshPartPayload::calculateMaterialSize() {
|
||||
bool allTextures = true; // assume we got this...
|
||||
_materialTextureSize = 0;
|
||||
auto textureMaps = _drawMaterial->getTextureMaps();
|
||||
for (auto const &textureMapItem : textureMaps) {
|
||||
auto textureMap = textureMapItem.second;
|
||||
if (textureMap) {
|
||||
auto textureSoure = textureMap->getTextureSource();
|
||||
if (textureSoure) {
|
||||
auto texture = textureSoure->getGPUTexture();
|
||||
if (texture) {
|
||||
//auto storedSize = texture->getStoredSize();
|
||||
auto size = texture->getSize();
|
||||
_materialTextureSize += size;
|
||||
} else {
|
||||
allTextures = false;
|
||||
}
|
||||
} else {
|
||||
allTextures = false;
|
||||
}
|
||||
} else {
|
||||
allTextures = false;
|
||||
}
|
||||
}
|
||||
return allTextures;
|
||||
}
|
||||
|
||||
|
||||
ItemKey MeshPartPayload::getKey() const {
|
||||
ItemKey::Builder builder;
|
||||
builder.withTypeShape();
|
||||
|
@ -347,8 +376,8 @@ void ModelMeshPartPayload::initCache() {
|
|||
auto networkMaterial = _model->getGeometry()->getShapeMaterial(_shapeID);
|
||||
if (networkMaterial) {
|
||||
_drawMaterial = networkMaterial;
|
||||
};
|
||||
|
||||
calculateMaterialSize();
|
||||
}
|
||||
}
|
||||
|
||||
void ModelMeshPartPayload::notifyLocationChanged() {
|
||||
|
|
|
@ -64,6 +64,13 @@ public:
|
|||
mutable model::Box _worldBound;
|
||||
|
||||
bool _hasColorAttrib = false;
|
||||
|
||||
size_t getVerticesCount() const { return _drawMesh ? _drawMesh->getNumVertices() : 0; }
|
||||
size_t getMaterialTextureSize() { return _materialTextureSize; }
|
||||
bool calculateMaterialSize();
|
||||
|
||||
protected:
|
||||
size_t _materialTextureSize { 0 };
|
||||
};
|
||||
|
||||
namespace render {
|
||||
|
|
|
@ -161,6 +161,23 @@ void Model::setOffset(const glm::vec3& offset) {
|
|||
_snappedToRegistrationPoint = false;
|
||||
}
|
||||
|
||||
size_t Model::getRenderInfoTextureSize() {
|
||||
if (!_hasCalculatedTextureSize && isLoaded() && getGeometry()->areTexturesLoaded()) {
|
||||
size_t textureSize = 0;
|
||||
bool allTexturesLoaded = true;
|
||||
foreach(auto renderItem, _modelMeshRenderItemsSet) {
|
||||
auto meshPart = renderItem.get();
|
||||
bool allTexturesForThisMesh = meshPart->calculateMaterialSize();
|
||||
allTexturesLoaded = allTexturesLoaded & allTexturesForThisMesh;
|
||||
textureSize += meshPart->getMaterialTextureSize();
|
||||
}
|
||||
_renderInfoTextureSize = textureSize;
|
||||
_hasCalculatedTextureSize = allTexturesLoaded; // only do this once
|
||||
}
|
||||
return _renderInfoTextureSize;
|
||||
}
|
||||
|
||||
|
||||
void Model::updateRenderItems() {
|
||||
if (!_addedToScene) {
|
||||
return;
|
||||
|
@ -615,16 +632,26 @@ bool Model::addToScene(std::shared_ptr<render::Scene> scene,
|
|||
}
|
||||
} else {
|
||||
if (_modelMeshRenderItems.empty()) {
|
||||
foreach (auto renderItem, _modelMeshRenderItemsSet) {
|
||||
|
||||
bool hasTransparent = false;
|
||||
size_t verticesCount = 0;
|
||||
foreach(auto renderItem, _modelMeshRenderItemsSet) {
|
||||
auto item = scene->allocateID();
|
||||
auto renderPayload = std::make_shared<ModelMeshPartPayload::Payload>(renderItem);
|
||||
if (statusGetters.size()) {
|
||||
renderPayload->addStatusGetters(statusGetters);
|
||||
}
|
||||
pendingChanges.resetItem(item, renderPayload);
|
||||
|
||||
hasTransparent = hasTransparent || renderItem.get()->getShapeKey().isTranslucent();
|
||||
verticesCount += renderItem.get()->getVerticesCount();
|
||||
_modelMeshRenderItems.insert(item, renderPayload);
|
||||
}
|
||||
somethingAdded = !_modelMeshRenderItems.empty();
|
||||
|
||||
_renderInfoVertexCount = verticesCount;
|
||||
_renderInfoDrawCalls = _modelMeshRenderItems.count();
|
||||
_renderInfoHasTransparent = hasTransparent;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -650,6 +677,11 @@ void Model::removeFromScene(std::shared_ptr<render::Scene> scene, render::Pendin
|
|||
_collisionRenderItems.clear();
|
||||
_collisionRenderItemsSet.clear();
|
||||
_addedToScene = false;
|
||||
|
||||
_renderInfoVertexCount = 0;
|
||||
_renderInfoDrawCalls = 0;
|
||||
_renderInfoTextureSize = 0;
|
||||
_renderInfoHasTransparent = false;
|
||||
}
|
||||
|
||||
void Model::renderDebugMeshBoxes(gpu::Batch& batch) {
|
||||
|
@ -1332,13 +1364,21 @@ bool Model::initWhenReady(render::ScenePointer scene) {
|
|||
}
|
||||
addedPendingChanges = !_collisionRenderItems.empty();
|
||||
} else {
|
||||
bool hasTransparent = false;
|
||||
size_t verticesCount = 0;
|
||||
foreach (auto renderItem, _modelMeshRenderItemsSet) {
|
||||
auto item = scene->allocateID();
|
||||
auto renderPayload = std::make_shared<ModelMeshPartPayload::Payload>(renderItem);
|
||||
|
||||
hasTransparent = hasTransparent || renderItem.get()->getShapeKey().isTranslucent();
|
||||
verticesCount += renderItem.get()->getVerticesCount();
|
||||
_modelMeshRenderItems.insert(item, renderPayload);
|
||||
pendingChanges.resetItem(item, renderPayload);
|
||||
}
|
||||
addedPendingChanges = !_modelMeshRenderItems.empty();
|
||||
_renderInfoVertexCount = verticesCount;
|
||||
_renderInfoDrawCalls = _modelMeshRenderItems.count();
|
||||
_renderInfoHasTransparent = hasTransparent;
|
||||
}
|
||||
_addedToScene = addedPendingChanges;
|
||||
if (addedPendingChanges) {
|
||||
|
|
|
@ -232,6 +232,12 @@ public:
|
|||
|
||||
void setLoadingPriority(float priority) { _loadingPriority = priority; }
|
||||
|
||||
size_t getRenderInfoVertexCount() const { return _renderInfoVertexCount; }
|
||||
int getRenderInfoTextureCount() const { return _renderInfoTextureCount; }
|
||||
size_t getRenderInfoTextureSize();
|
||||
int getRenderInfoDrawCalls() const { return _renderInfoDrawCalls; }
|
||||
bool getRenderInfoHasTransparent() const { return _renderInfoHasTransparent; }
|
||||
|
||||
public slots:
|
||||
void loadURLFinished(bool success);
|
||||
|
||||
|
@ -400,6 +406,13 @@ protected:
|
|||
|
||||
bool _renderItemsNeedUpdate { false };
|
||||
|
||||
size_t _renderInfoVertexCount { 0 };
|
||||
int _renderInfoTextureCount { 0 };
|
||||
size_t _renderInfoTextureSize { 0 };
|
||||
bool _hasCalculatedTextureSize { false };
|
||||
int _renderInfoDrawCalls { 0 };
|
||||
int _renderInfoHasTransparent { false };
|
||||
|
||||
private:
|
||||
float _loadingPriority { 0.0f };
|
||||
|
||||
|
|
|
@ -245,7 +245,7 @@ void EndGPURangeTimer::run(const render::SceneContextPointer& sceneContext, cons
|
|||
});
|
||||
|
||||
auto config = std::static_pointer_cast<Config>(renderContext->jobConfig);
|
||||
config->gpuTime = timer->getAverage();
|
||||
config->setGPUBatchRunTime(timer->getGPUAverage(), timer->getBatchAverage());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -29,18 +29,8 @@ protected:
|
|||
gpu::RangeTimerPointer _gpuTimer;
|
||||
};
|
||||
|
||||
using GPURangeTimerConfig = render::GPUJobConfig;
|
||||
|
||||
class GPURangeTimerConfig : public render::Job::Config {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(double gpuTime READ getGpuTime)
|
||||
public:
|
||||
double getGpuTime() { return gpuTime; }
|
||||
|
||||
protected:
|
||||
friend class EndGPURangeTimer;
|
||||
double gpuTime;
|
||||
};
|
||||
|
||||
class EndGPURangeTimer {
|
||||
public:
|
||||
using Config = GPURangeTimerConfig;
|
||||
|
@ -143,16 +133,7 @@ protected:
|
|||
gpu::PipelinePointer getOpaquePipeline();
|
||||
};
|
||||
|
||||
class DrawBackgroundDeferredConfig : public render::Job::Config {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(double gpuTime READ getGpuTime)
|
||||
public:
|
||||
double getGpuTime() { return gpuTime; }
|
||||
|
||||
protected:
|
||||
friend class DrawBackgroundDeferred;
|
||||
double gpuTime;
|
||||
};
|
||||
using DrawBackgroundDeferredConfig = render::GPUJobConfig;
|
||||
|
||||
class DrawBackgroundDeferred {
|
||||
public:
|
||||
|
@ -211,16 +192,7 @@ public:
|
|||
void run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext, const gpu::FramebufferPointer& srcFramebuffer);
|
||||
};
|
||||
|
||||
class RenderDeferredTaskConfig : public render::Task::Config {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(double gpuTime READ getGpuTime)
|
||||
public:
|
||||
double getGpuTime() { return gpuTime; }
|
||||
|
||||
protected:
|
||||
friend class RenderDeferredTask;
|
||||
double gpuTime;
|
||||
};
|
||||
using RenderDeferredTaskConfig = render::GPUTaskConfig;
|
||||
|
||||
class RenderDeferredTask : public render::Task {
|
||||
public:
|
||||
|
|
|
@ -201,7 +201,7 @@ void LinearDepthPass::run(const render::SceneContextPointer& sceneContext, const
|
|||
});
|
||||
|
||||
auto config = std::static_pointer_cast<Config>(renderContext->jobConfig);
|
||||
config->gpuTime = _gpuTimer.getAverage();
|
||||
config->setGPUBatchRunTime(_gpuTimer.getGPUAverage(), _gpuTimer.getBatchAverage());
|
||||
}
|
||||
|
||||
|
||||
|
@ -524,7 +524,7 @@ void SurfaceGeometryPass::run(const render::SceneContextPointer& sceneContext, c
|
|||
|
||||
|
||||
auto config = std::static_pointer_cast<Config>(renderContext->jobConfig);
|
||||
config->gpuTime = _gpuTimer.getAverage();
|
||||
config->setGPUBatchRunTime(_gpuTimer.getGPUAverage(), _gpuTimer.getBatchAverage());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -62,20 +62,7 @@ protected:
|
|||
|
||||
using LinearDepthFramebufferPointer = std::shared_ptr<LinearDepthFramebuffer>;
|
||||
|
||||
|
||||
class LinearDepthPassConfig : public render::Job::Config {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(double gpuTime READ getGpuTime)
|
||||
public:
|
||||
LinearDepthPassConfig() : render::Job::Config(true) {}
|
||||
|
||||
double getGpuTime() { return gpuTime; }
|
||||
|
||||
double gpuTime{ 0.0 };
|
||||
|
||||
signals:
|
||||
void dirty();
|
||||
};
|
||||
using LinearDepthPassConfig = render::GPUJobConfig;
|
||||
|
||||
class LinearDepthPass {
|
||||
public:
|
||||
|
@ -148,7 +135,7 @@ protected:
|
|||
|
||||
using SurfaceGeometryFramebufferPointer = std::shared_ptr<SurfaceGeometryFramebuffer>;
|
||||
|
||||
class SurfaceGeometryPassConfig : public render::Job::Config {
|
||||
class SurfaceGeometryPassConfig : public render::GPUJobConfig {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(float depthThreshold MEMBER depthThreshold NOTIFY dirty)
|
||||
Q_PROPERTY(float basisScale MEMBER basisScale NOTIFY dirty)
|
||||
|
@ -158,9 +145,8 @@ class SurfaceGeometryPassConfig : public render::Job::Config {
|
|||
Q_PROPERTY(float diffuseFilterScale MEMBER diffuseFilterScale NOTIFY dirty)
|
||||
Q_PROPERTY(float diffuseDepthThreshold MEMBER diffuseDepthThreshold NOTIFY dirty)
|
||||
|
||||
Q_PROPERTY(double gpuTime READ getGpuTime)
|
||||
public:
|
||||
SurfaceGeometryPassConfig() : render::Job::Config(true) {}
|
||||
SurfaceGeometryPassConfig() : render::GPUJobConfig(true) {}
|
||||
|
||||
float depthThreshold{ 5.0f }; // centimeters
|
||||
float basisScale{ 1.0f };
|
||||
|
@ -169,10 +155,6 @@ public:
|
|||
float diffuseFilterScale{ 0.2f };
|
||||
float diffuseDepthThreshold{ 1.0f };
|
||||
|
||||
double getGpuTime() { return gpuTime; }
|
||||
|
||||
double gpuTime{ 0.0 };
|
||||
|
||||
signals:
|
||||
void dirty();
|
||||
};
|
||||
|
|
|
@ -334,9 +334,9 @@ protected:
|
|||
// A default Config is always on; to create an enableable Config, use the ctor JobConfig(bool enabled)
|
||||
class JobConfig : public QObject {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(quint64 cpuRunTime READ getCPUTRunTime NOTIFY newStats())
|
||||
Q_PROPERTY(double cpuRunTime READ getCPURunTime NOTIFY newStats()) //ms
|
||||
|
||||
quint64 _CPURunTime{ 0 };
|
||||
double _msCPURunTime{ 0.0 };
|
||||
public:
|
||||
using Persistent = PersistentConfig<JobConfig>;
|
||||
|
||||
|
@ -364,8 +364,8 @@ public:
|
|||
|
||||
// Running Time measurement
|
||||
// The new stats signal is emitted once per run time of a job when stats (cpu runtime) are updated
|
||||
void setCPURunTime(quint64 ustime) { _CPURunTime = ustime; emit newStats(); }
|
||||
quint64 getCPUTRunTime() const { return _CPURunTime; }
|
||||
void setCPURunTime(double mstime) { _msCPURunTime = mstime; emit newStats(); }
|
||||
double getCPURunTime() const { return _msCPURunTime; }
|
||||
|
||||
public slots:
|
||||
void load(const QJsonObject& val) { qObjectFromJsonValue(val, *this); emit loaded(); }
|
||||
|
@ -418,6 +418,46 @@ template <class T, class I, class O> void jobRun(T& data, const SceneContextPoin
|
|||
data.run(sceneContext, renderContext, input, output);
|
||||
}
|
||||
|
||||
class GPUJobConfig : public JobConfig {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(double gpuRunTime READ getGPURunTime)
|
||||
Q_PROPERTY(double batchRunTime READ getBatchRunTime)
|
||||
|
||||
double _msGPURunTime { 0.0 };
|
||||
double _msBatchRunTime { 0.0 };
|
||||
public:
|
||||
using Persistent = PersistentConfig<GPUJobConfig>;
|
||||
|
||||
GPUJobConfig() = default;
|
||||
GPUJobConfig(bool enabled) : JobConfig(enabled) {}
|
||||
|
||||
// Running Time measurement on GPU and for Batch execution
|
||||
void setGPUBatchRunTime(double msGpuTime, double msBatchTime) { _msGPURunTime = msGpuTime; _msBatchRunTime = msBatchTime; }
|
||||
double getGPURunTime() const { return _msGPURunTime; }
|
||||
double getBatchRunTime() const { return _msBatchRunTime; }
|
||||
};
|
||||
|
||||
class GPUTaskConfig : public TaskConfig {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(double gpuRunTime READ getGPURunTime)
|
||||
Q_PROPERTY(double batchRunTime READ getBatchRunTime)
|
||||
|
||||
double _msGPURunTime { 0.0 };
|
||||
double _msBatchRunTime { 0.0 };
|
||||
public:
|
||||
|
||||
using Persistent = PersistentConfig<GPUTaskConfig>;
|
||||
|
||||
|
||||
GPUTaskConfig() = default;
|
||||
GPUTaskConfig(bool enabled) : TaskConfig(enabled) {}
|
||||
|
||||
// Running Time measurement on GPU and for Batch execution
|
||||
void setGPUBatchRunTime(double msGpuTime, double msBatchTime) { _msGPURunTime = msGpuTime; _msBatchRunTime = msBatchTime; }
|
||||
double getGPURunTime() const { return _msGPURunTime; }
|
||||
double getBatchRunTime() const { return _msBatchRunTime; }
|
||||
};
|
||||
|
||||
class Job {
|
||||
public:
|
||||
using Config = JobConfig;
|
||||
|
@ -439,7 +479,7 @@ public:
|
|||
virtual void run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext) = 0;
|
||||
|
||||
protected:
|
||||
void setCPURunTime(quint64 ustime) { std::static_pointer_cast<Config>(_config)->setCPURunTime(ustime); }
|
||||
void setCPURunTime(double mstime) { std::static_pointer_cast<Config>(_config)->setCPURunTime(mstime); }
|
||||
|
||||
QConfigPointer _config;
|
||||
|
||||
|
@ -502,7 +542,7 @@ public:
|
|||
|
||||
_concept->run(sceneContext, renderContext);
|
||||
|
||||
_concept->setCPURunTime(usecTimestampNow() - start);
|
||||
_concept->setCPURunTime((double)(usecTimestampNow() - start) / 1000.0);
|
||||
}
|
||||
|
||||
protected:
|
||||
|
|
|
@ -37,49 +37,92 @@ var DEFAULT_SCRIPTS = [
|
|||
// add a menu item for debugging
|
||||
var MENU_CATEGORY = "Developer";
|
||||
var MENU_ITEM = "Debug defaultScripts.js";
|
||||
var debuggingDefaultScripts = false;
|
||||
|
||||
var SETTINGS_KEY = '_debugDefaultScriptsIsChecked';
|
||||
var previousSetting = Settings.getValue(SETTINGS_KEY);
|
||||
|
||||
if (previousSetting === '' || previousSetting === false || previousSetting === 'false') {
|
||||
previousSetting = false;
|
||||
}
|
||||
|
||||
if (previousSetting === true || previousSetting === 'true') {
|
||||
previousSetting = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if (Menu.menuExists(MENU_CATEGORY) && !Menu.menuItemExists(MENU_CATEGORY, MENU_ITEM)) {
|
||||
Menu.addMenuItem({
|
||||
menuName: MENU_CATEGORY,
|
||||
menuItemName: MENU_ITEM,
|
||||
isCheckable: true,
|
||||
isChecked: false,
|
||||
isChecked: previousSetting,
|
||||
grouping: "Advanced"
|
||||
});
|
||||
}
|
||||
|
||||
// start all scripts
|
||||
if (Menu.isOptionChecked(MENU_ITEM)) {
|
||||
// we're debugging individual default scripts
|
||||
// so we load each into its own ScriptEngine instance
|
||||
debuggingDefaultScripts = true;
|
||||
for (var i in DEFAULT_SCRIPTS) {
|
||||
Script.load(DEFAULT_SCRIPTS[i]);
|
||||
}
|
||||
} else {
|
||||
// include all default scripts into this ScriptEngine
|
||||
function runDefaultsTogether() {
|
||||
for (var j in DEFAULT_SCRIPTS) {
|
||||
Script.include(DEFAULT_SCRIPTS[j]);
|
||||
}
|
||||
}
|
||||
|
||||
function stopLoadedScripts() {
|
||||
if (debuggingDefaultScripts) {
|
||||
// remove debug script loads
|
||||
var runningScripts = ScriptDiscoveryService.getRunning();
|
||||
for (var i in runningScripts) {
|
||||
var scriptName = runningScripts[i].name;
|
||||
for (var j in DEFAULT_SCRIPTS) {
|
||||
if (DEFAULT_SCRIPTS[j].slice(-scriptName.length) === scriptName) {
|
||||
ScriptDiscoveryService.stopScript(runningScripts[i].url);
|
||||
}
|
||||
}
|
||||
function runDefaultsSeparately() {
|
||||
for (var i in DEFAULT_SCRIPTS) {
|
||||
Script.load(DEFAULT_SCRIPTS[i]);
|
||||
}
|
||||
}
|
||||
// start all scripts
|
||||
if (Menu.isOptionChecked(MENU_ITEM)) {
|
||||
// we're debugging individual default scripts
|
||||
// so we load each into its own ScriptEngine instance
|
||||
debuggingDefaultScripts = true;
|
||||
runDefaultsSeparately();
|
||||
} else {
|
||||
// include all default scripts into this ScriptEngine
|
||||
runDefaultsTogether();
|
||||
}
|
||||
|
||||
function menuItemEvent(menuItem) {
|
||||
if (menuItem == MENU_ITEM) {
|
||||
|
||||
isChecked = Menu.isOptionChecked(MENU_ITEM);
|
||||
if (isChecked === true) {
|
||||
Settings.setValue(SETTINGS_KEY, true);
|
||||
} else if (isChecked === false) {
|
||||
Settings.setValue(SETTINGS_KEY, false);
|
||||
}
|
||||
if (!Menu.isOptionChecked(MENU_ITEM)) {
|
||||
Menu.removeMenuItem(MENU_CATEGORY, MENU_ITEM);
|
||||
Window.alert('You must reload all scripts for this to take effect.')
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function stopLoadedScripts() {
|
||||
// remove debug script loads
|
||||
var runningScripts = ScriptDiscoveryService.getRunning();
|
||||
for (var i in runningScripts) {
|
||||
var scriptName = runningScripts[i].name;
|
||||
for (var j in DEFAULT_SCRIPTS) {
|
||||
if (DEFAULT_SCRIPTS[j].slice(-scriptName.length) === scriptName) {
|
||||
ScriptDiscoveryService.stopScript(runningScripts[i].url);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Script.scriptEnding.connect(stopLoadedScripts);
|
||||
function removeMenuItem() {
|
||||
if (!Menu.isOptionChecked(MENU_ITEM)) {
|
||||
Menu.removeMenuItem(MENU_CATEGORY, MENU_ITEM);
|
||||
}
|
||||
}
|
||||
|
||||
Script.scriptEnding.connect(function() {
|
||||
stopLoadedScripts();
|
||||
removeMenuItem();
|
||||
});
|
||||
|
||||
Menu.menuItemEvent.connect(menuItemEvent);
|
|
@ -75,10 +75,10 @@ Column {
|
|||
object: Render.getConfig("AmbientOcclusion")
|
||||
valueUnit: "ms"
|
||||
valueScale: 1
|
||||
valueNumDigits: "4"
|
||||
valueNumDigits: "3"
|
||||
plots: [
|
||||
{
|
||||
prop: "gpuTime",
|
||||
prop: "gpuRunTime",
|
||||
label: "gpu",
|
||||
color: "#FFFFFF"
|
||||
}
|
||||
|
|
|
@ -213,8 +213,8 @@ Item {
|
|||
height: parent.evalEvenHeight()
|
||||
object: parent.drawOpaqueConfig
|
||||
valueUnit: "ms"
|
||||
valueScale: 1000
|
||||
valueNumDigits: "1"
|
||||
valueScale: 1
|
||||
valueNumDigits: "2"
|
||||
plots: [
|
||||
{
|
||||
object: Render.getConfig("DrawOpaqueDeferred"),
|
||||
|
|
|
@ -30,7 +30,7 @@ Item {
|
|||
|
||||
|
||||
PlotPerf {
|
||||
title: "Timing"
|
||||
title: "GPU Timing"
|
||||
height: parent.evalEvenHeight()
|
||||
object: parent.drawOpaqueConfig
|
||||
valueUnit: "ms"
|
||||
|
@ -39,31 +39,71 @@ Item {
|
|||
plots: [
|
||||
{
|
||||
object: Render.getConfig("OpaqueRangeTimer"),
|
||||
prop: "gpuTime",
|
||||
prop: "gpuRunTime",
|
||||
label: "Opaque",
|
||||
color: "#FFFFFF"
|
||||
},
|
||||
{
|
||||
object: Render.getConfig("LinearDepth"),
|
||||
prop: "gpuTime",
|
||||
prop: "gpuRunTime",
|
||||
label: "LinearDepth",
|
||||
color: "#00FF00"
|
||||
},{
|
||||
object: Render.getConfig("SurfaceGeometry"),
|
||||
prop: "gpuTime",
|
||||
prop: "gpuRunTime",
|
||||
label: "SurfaceGeometry",
|
||||
color: "#00FFFF"
|
||||
},
|
||||
{
|
||||
object: Render.getConfig("RenderDeferred"),
|
||||
prop: "gpuTime",
|
||||
prop: "gpuRunTime",
|
||||
label: "DeferredLighting",
|
||||
color: "#FF00FF"
|
||||
}
|
||||
,
|
||||
{
|
||||
object: Render.getConfig("ToneAndPostRangeTimer"),
|
||||
prop: "gpuTime",
|
||||
prop: "gpuRunTime",
|
||||
label: "tone and post",
|
||||
color: "#FF0000"
|
||||
}
|
||||
]
|
||||
}
|
||||
PlotPerf {
|
||||
title: "Batch Timing"
|
||||
height: parent.evalEvenHeight()
|
||||
object: parent.drawOpaqueConfig
|
||||
valueUnit: "ms"
|
||||
valueScale: 1
|
||||
valueNumDigits: "3"
|
||||
plots: [
|
||||
{
|
||||
object: Render.getConfig("OpaqueRangeTimer"),
|
||||
prop: "batchRunTime",
|
||||
label: "Opaque",
|
||||
color: "#FFFFFF"
|
||||
},
|
||||
{
|
||||
object: Render.getConfig("LinearDepth"),
|
||||
prop: "batchRunTime",
|
||||
label: "LinearDepth",
|
||||
color: "#00FF00"
|
||||
},{
|
||||
object: Render.getConfig("SurfaceGeometry"),
|
||||
prop: "batchRunTime",
|
||||
label: "SurfaceGeometry",
|
||||
color: "#00FFFF"
|
||||
},
|
||||
{
|
||||
object: Render.getConfig("RenderDeferred"),
|
||||
prop: "batchRunTime",
|
||||
label: "DeferredLighting",
|
||||
color: "#FF00FF"
|
||||
}
|
||||
,
|
||||
{
|
||||
object: Render.getConfig("ToneAndPostRangeTimer"),
|
||||
prop: "batchRunTime",
|
||||
label: "tone and post",
|
||||
color: "#FF0000"
|
||||
}
|
||||
|
|
|
@ -125,6 +125,12 @@ var ZERO_VEC = {
|
|||
z: 0
|
||||
};
|
||||
|
||||
var ONE_VEC = {
|
||||
x: 1,
|
||||
y: 1,
|
||||
z: 1
|
||||
};
|
||||
|
||||
var NULL_UUID = "{00000000-0000-0000-0000-000000000000}";
|
||||
|
||||
// these control how long an abandoned pointer line or action will hang around
|
||||
|
@ -232,6 +238,25 @@ CONTROLLER_STATE_MACHINE[STATE_ENTITY_TOUCHING] = {
|
|||
updateMethod: "entityTouching"
|
||||
};
|
||||
|
||||
function distanceBetweenPointAndEntityBoundingBox(point, entityProps) {
|
||||
var entityXform = new Xform(entityProps.rotation, entityProps.position);
|
||||
var localPoint = entityXform.inv().xformPoint(point);
|
||||
var minOffset = Vec3.multiplyVbyV(entityProps.registrationPoint, entityProps.dimensions);
|
||||
var maxOffset = Vec3.multiplyVbyV(Vec3.subtract(ONE_VEC, entityProps.registrationPoint), entityProps.dimensions);
|
||||
var localMin = Vec3.subtract(entityXform.trans, minOffset);
|
||||
var localMax = Vec3.sum(entityXform.trans, maxOffset);
|
||||
|
||||
var v = {x: localPoint.x, y: localPoint.y, z: localPoint.z};
|
||||
v.x = Math.max(v.x, localMin.x);
|
||||
v.x = Math.min(v.x, localMax.x);
|
||||
v.y = Math.max(v.y, localMin.y);
|
||||
v.y = Math.min(v.y, localMax.y);
|
||||
v.z = Math.max(v.z, localMin.z);
|
||||
v.z = Math.min(v.z, localMax.z);
|
||||
|
||||
return Vec3.distance(v, localPoint);
|
||||
}
|
||||
|
||||
function angleBetween(a, b) {
|
||||
return Math.acos(Vec3.dot(Vec3.normalize(a), Vec3.normalize(b)));
|
||||
}
|
||||
|
@ -1960,7 +1985,8 @@ function MyController(hand) {
|
|||
this.heartBeat(this.grabbedEntity);
|
||||
|
||||
var props = Entities.getEntityProperties(this.grabbedEntity, ["localPosition", "parentID",
|
||||
"position", "rotation", "dimensions"]);
|
||||
"position", "rotation", "dimensions",
|
||||
"registrationPoint"]);
|
||||
if (!props.position) {
|
||||
// server may have reset, taking our equipped entity with it. move back to "off" stte
|
||||
this.callEntityMethodOnGrabbed("releaseGrab");
|
||||
|
@ -1974,14 +2000,12 @@ function MyController(hand) {
|
|||
|
||||
if (props.parentID == MyAvatar.sessionUUID) {
|
||||
var handPosition = this.getHandPosition();
|
||||
// the center of the equipped object being far from the hand isn't enough to auto-unequip -- we also
|
||||
// need to fail the findEntities test.
|
||||
var TEAR_AWAY_DISTANCE = 0.04;
|
||||
var nearPickedCandidateEntities = Entities.findEntities(handPosition, NEAR_GRAB_RADIUS + TEAR_AWAY_DISTANCE);
|
||||
if (nearPickedCandidateEntities.indexOf(this.grabbedEntity) == -1) {
|
||||
// for whatever reason, the held/equipped entity has been pulled away. ungrab or unequip.
|
||||
|
||||
var TEAR_AWAY_DISTANCE = 0.1;
|
||||
var dist = distanceBetweenPointAndEntityBoundingBox(handPosition, props);
|
||||
if (dist > TEAR_AWAY_DISTANCE) {
|
||||
print("handControllerGrab -- autoreleasing held or equipped item because it is far from hand." +
|
||||
props.parentID + " " + vec3toStr(props.position));
|
||||
props.parentID + ", dist = " + dist);
|
||||
|
||||
if (this.state == STATE_NEAR_GRABBING) {
|
||||
this.callEntityMethodOnGrabbed("releaseGrab");
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
var RAD_TO_DEG = 180 / Math.PI;
|
||||
var X_AXIS = {x: 1, y: 0, z: 0};
|
||||
var Y_AXIS = {x: 0, y: 1, z: 0};
|
||||
var DEFAULT_DPI = 30;
|
||||
var DEFAULT_WIDTH = 0.5;
|
||||
|
||||
var TABLET_URL = "https://s3.amazonaws.com/hifi-public/tony/tablet.fbx";
|
||||
|
||||
|
@ -37,12 +39,13 @@ function calcSpawnInfo() {
|
|||
}
|
||||
|
||||
// ctor
|
||||
WebTablet = function (url) {
|
||||
WebTablet = function (url, width, dpi) {
|
||||
|
||||
var ASPECT = 4.0 / 3.0;
|
||||
var WIDTH = 0.4;
|
||||
var WIDTH = width || DEFAULT_WIDTH;
|
||||
var HEIGHT = WIDTH * ASPECT;
|
||||
var DEPTH = 0.025;
|
||||
var DPI = dpi || DEFAULT_DPI;
|
||||
|
||||
var spawnInfo = calcSpawnInfo();
|
||||
|
||||
|
@ -78,7 +81,7 @@ WebTablet = function (url) {
|
|||
position: webEntityPosition,
|
||||
rotation: webEntityRotation,
|
||||
shapeType: "box",
|
||||
dpi: 45,
|
||||
dpi: DPI,
|
||||
parentID: this.tabletEntityID,
|
||||
parentJointIndex: -1
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue