mirror of
https://github.com/lubosz/overte.git
synced 2025-08-07 16:41:02 +02:00
Merge branch 'master' of https://github.com/highfidelity/hifi into hdr
This commit is contained in:
commit
7b68f1439f
13 changed files with 191 additions and 18 deletions
|
@ -130,6 +130,11 @@ Var AR_RegFlags
|
||||||
SectionSetFlags ${${SecName}} $AR_SecFlags
|
SectionSetFlags ${${SecName}} $AR_SecFlags
|
||||||
|
|
||||||
"default_${SecName}:"
|
"default_${SecName}:"
|
||||||
|
; The client is always selected by default
|
||||||
|
${If} ${SecName} == @CLIENT_COMPONENT_NAME@
|
||||||
|
SectionSetFlags ${${SecName}} 17
|
||||||
|
${EndIf}
|
||||||
|
|
||||||
!insertmacro LoadSectionSelectedIntoVar ${SecName} ${SecName}_selected
|
!insertmacro LoadSectionSelectedIntoVar ${SecName} ${SecName}_selected
|
||||||
!macroend
|
!macroend
|
||||||
|
|
||||||
|
@ -243,6 +248,12 @@ FunctionEnd
|
||||||
|
|
||||||
;--------------------------------
|
;--------------------------------
|
||||||
; Installation types
|
; 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@
|
@CPACK_NSIS_INSTALLATION_TYPES@
|
||||||
|
|
||||||
;--------------------------------
|
;--------------------------------
|
||||||
|
|
|
@ -556,14 +556,13 @@ ModelPointer EntityTreeRenderer::allocateModel(const QString& url, float loading
|
||||||
return model;
|
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
|
// Only create and delete models on the thread that owns the EntityTreeRenderer
|
||||||
if (QThread::currentThread() != thread()) {
|
if (QThread::currentThread() != thread()) {
|
||||||
QMetaObject::invokeMethod(this, "updateModel", Qt::BlockingQueuedConnection,
|
QMetaObject::invokeMethod(this, "updateModel", Qt::BlockingQueuedConnection,
|
||||||
Q_RETURN_ARG(ModelPointer, model),
|
Q_RETURN_ARG(ModelPointer, model),
|
||||||
Q_ARG(ModelPointer, model),
|
Q_ARG(ModelPointer, model),
|
||||||
Q_ARG(const QString&, newUrl),
|
Q_ARG(const QString&, newUrl));
|
||||||
Q_ARG(const QString&, collisionUrl));
|
|
||||||
|
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,7 +76,7 @@ public:
|
||||||
Q_INVOKABLE ModelPointer allocateModel(const QString& url, float loadingPriority = 0.0f);
|
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
|
/// 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
|
/// if a renderable entity item is done with a model, it should return it to us
|
||||||
void releaseModel(ModelPointer model);
|
void releaseModel(ModelPointer model);
|
||||||
|
|
|
@ -548,6 +548,15 @@ EntityItemProperties RenderableModelEntityItem::getProperties(EntityPropertyFlag
|
||||||
if (_originalTexturesRead) {
|
if (_originalTexturesRead) {
|
||||||
properties.setTextureNames(_originalTextures);
|
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;
|
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_CLIENT_ONLY, clientOnly);
|
||||||
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_OWNING_AVATAR_ID, owningAvatarID);
|
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("clientOnly", convertScriptValue(engine, getClientOnly()));
|
||||||
properties.setProperty("owningAvatarID", convertScriptValue(engine, getOwningAvatarID()));
|
properties.setProperty("owningAvatarID", convertScriptValue(engine, getOwningAvatarID()));
|
||||||
|
|
||||||
|
|
|
@ -285,6 +285,19 @@ public:
|
||||||
void setJointRotationsDirty() { _jointRotationsSetChanged = true; _jointRotationsChanged = true; }
|
void setJointRotationsDirty() { _jointRotationsSetChanged = true; _jointRotationsChanged = true; }
|
||||||
void setJointTranslationsDirty() { _jointTranslationsSetChanged = true; _jointTranslationsChanged = 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:
|
protected:
|
||||||
QString getCollisionMaskAsString() const;
|
QString getCollisionMaskAsString() const;
|
||||||
void setCollisionMaskFromString(const QString& maskString);
|
void setCollisionMaskFromString(const QString& maskString);
|
||||||
|
@ -308,6 +321,12 @@ private:
|
||||||
glm::vec3 _naturalDimensions;
|
glm::vec3 _naturalDimensions;
|
||||||
glm::vec3 _naturalPosition;
|
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
|
EntityPropertyFlags _desiredProperties; // if set will narrow scopes of copy/to/from to just these properties
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -59,6 +59,7 @@ public:
|
||||||
TextureMap() {}
|
TextureMap() {}
|
||||||
|
|
||||||
void setTextureSource(gpu::TextureSourcePointer& textureSource);
|
void setTextureSource(gpu::TextureSourcePointer& textureSource);
|
||||||
|
gpu::TextureSourcePointer getTextureSource() const { return _textureSource; }
|
||||||
|
|
||||||
bool isDefined() const;
|
bool isDefined() const;
|
||||||
gpu::TextureView getTextureView() const;
|
gpu::TextureView getTextureView() const;
|
||||||
|
|
|
@ -71,8 +71,37 @@ void MeshPartPayload::updateTransform(const Transform& transform, const Transfor
|
||||||
|
|
||||||
void MeshPartPayload::updateMaterial(model::MaterialPointer drawMaterial) {
|
void MeshPartPayload::updateMaterial(model::MaterialPointer drawMaterial) {
|
||||||
_drawMaterial = 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 MeshPartPayload::getKey() const {
|
||||||
ItemKey::Builder builder;
|
ItemKey::Builder builder;
|
||||||
builder.withTypeShape();
|
builder.withTypeShape();
|
||||||
|
@ -347,8 +376,8 @@ void ModelMeshPartPayload::initCache() {
|
||||||
auto networkMaterial = _model->getGeometry()->getShapeMaterial(_shapeID);
|
auto networkMaterial = _model->getGeometry()->getShapeMaterial(_shapeID);
|
||||||
if (networkMaterial) {
|
if (networkMaterial) {
|
||||||
_drawMaterial = networkMaterial;
|
_drawMaterial = networkMaterial;
|
||||||
};
|
calculateMaterialSize();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelMeshPartPayload::notifyLocationChanged() {
|
void ModelMeshPartPayload::notifyLocationChanged() {
|
||||||
|
|
|
@ -64,6 +64,13 @@ public:
|
||||||
mutable model::Box _worldBound;
|
mutable model::Box _worldBound;
|
||||||
|
|
||||||
bool _hasColorAttrib = false;
|
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 {
|
namespace render {
|
||||||
|
|
|
@ -161,6 +161,23 @@ void Model::setOffset(const glm::vec3& offset) {
|
||||||
_snappedToRegistrationPoint = false;
|
_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() {
|
void Model::updateRenderItems() {
|
||||||
if (!_addedToScene) {
|
if (!_addedToScene) {
|
||||||
return;
|
return;
|
||||||
|
@ -615,16 +632,26 @@ bool Model::addToScene(std::shared_ptr<render::Scene> scene,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (_modelMeshRenderItems.empty()) {
|
if (_modelMeshRenderItems.empty()) {
|
||||||
foreach (auto renderItem, _modelMeshRenderItemsSet) {
|
|
||||||
|
bool hasTransparent = false;
|
||||||
|
size_t verticesCount = 0;
|
||||||
|
foreach(auto renderItem, _modelMeshRenderItemsSet) {
|
||||||
auto item = scene->allocateID();
|
auto item = scene->allocateID();
|
||||||
auto renderPayload = std::make_shared<ModelMeshPartPayload::Payload>(renderItem);
|
auto renderPayload = std::make_shared<ModelMeshPartPayload::Payload>(renderItem);
|
||||||
if (statusGetters.size()) {
|
if (statusGetters.size()) {
|
||||||
renderPayload->addStatusGetters(statusGetters);
|
renderPayload->addStatusGetters(statusGetters);
|
||||||
}
|
}
|
||||||
pendingChanges.resetItem(item, renderPayload);
|
pendingChanges.resetItem(item, renderPayload);
|
||||||
|
|
||||||
|
hasTransparent = hasTransparent || renderItem.get()->getShapeKey().isTranslucent();
|
||||||
|
verticesCount += renderItem.get()->getVerticesCount();
|
||||||
_modelMeshRenderItems.insert(item, renderPayload);
|
_modelMeshRenderItems.insert(item, renderPayload);
|
||||||
}
|
}
|
||||||
somethingAdded = !_modelMeshRenderItems.empty();
|
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();
|
_collisionRenderItems.clear();
|
||||||
_collisionRenderItemsSet.clear();
|
_collisionRenderItemsSet.clear();
|
||||||
_addedToScene = false;
|
_addedToScene = false;
|
||||||
|
|
||||||
|
_renderInfoVertexCount = 0;
|
||||||
|
_renderInfoDrawCalls = 0;
|
||||||
|
_renderInfoTextureSize = 0;
|
||||||
|
_renderInfoHasTransparent = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Model::renderDebugMeshBoxes(gpu::Batch& batch) {
|
void Model::renderDebugMeshBoxes(gpu::Batch& batch) {
|
||||||
|
@ -1332,13 +1364,21 @@ bool Model::initWhenReady(render::ScenePointer scene) {
|
||||||
}
|
}
|
||||||
addedPendingChanges = !_collisionRenderItems.empty();
|
addedPendingChanges = !_collisionRenderItems.empty();
|
||||||
} else {
|
} else {
|
||||||
|
bool hasTransparent = false;
|
||||||
|
size_t verticesCount = 0;
|
||||||
foreach (auto renderItem, _modelMeshRenderItemsSet) {
|
foreach (auto renderItem, _modelMeshRenderItemsSet) {
|
||||||
auto item = scene->allocateID();
|
auto item = scene->allocateID();
|
||||||
auto renderPayload = std::make_shared<ModelMeshPartPayload::Payload>(renderItem);
|
auto renderPayload = std::make_shared<ModelMeshPartPayload::Payload>(renderItem);
|
||||||
|
|
||||||
|
hasTransparent = hasTransparent || renderItem.get()->getShapeKey().isTranslucent();
|
||||||
|
verticesCount += renderItem.get()->getVerticesCount();
|
||||||
_modelMeshRenderItems.insert(item, renderPayload);
|
_modelMeshRenderItems.insert(item, renderPayload);
|
||||||
pendingChanges.resetItem(item, renderPayload);
|
pendingChanges.resetItem(item, renderPayload);
|
||||||
}
|
}
|
||||||
addedPendingChanges = !_modelMeshRenderItems.empty();
|
addedPendingChanges = !_modelMeshRenderItems.empty();
|
||||||
|
_renderInfoVertexCount = verticesCount;
|
||||||
|
_renderInfoDrawCalls = _modelMeshRenderItems.count();
|
||||||
|
_renderInfoHasTransparent = hasTransparent;
|
||||||
}
|
}
|
||||||
_addedToScene = addedPendingChanges;
|
_addedToScene = addedPendingChanges;
|
||||||
if (addedPendingChanges) {
|
if (addedPendingChanges) {
|
||||||
|
|
|
@ -232,6 +232,12 @@ public:
|
||||||
|
|
||||||
void setLoadingPriority(float priority) { _loadingPriority = priority; }
|
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:
|
public slots:
|
||||||
void loadURLFinished(bool success);
|
void loadURLFinished(bool success);
|
||||||
|
|
||||||
|
@ -400,6 +406,13 @@ protected:
|
||||||
|
|
||||||
bool _renderItemsNeedUpdate { false };
|
bool _renderItemsNeedUpdate { false };
|
||||||
|
|
||||||
|
size_t _renderInfoVertexCount { 0 };
|
||||||
|
int _renderInfoTextureCount { 0 };
|
||||||
|
size_t _renderInfoTextureSize { 0 };
|
||||||
|
bool _hasCalculatedTextureSize { false };
|
||||||
|
int _renderInfoDrawCalls { 0 };
|
||||||
|
int _renderInfoHasTransparent { false };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
float _loadingPriority { 0.0f };
|
float _loadingPriority { 0.0f };
|
||||||
|
|
||||||
|
|
|
@ -125,6 +125,12 @@ var ZERO_VEC = {
|
||||||
z: 0
|
z: 0
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var ONE_VEC = {
|
||||||
|
x: 1,
|
||||||
|
y: 1,
|
||||||
|
z: 1
|
||||||
|
};
|
||||||
|
|
||||||
var NULL_UUID = "{00000000-0000-0000-0000-000000000000}";
|
var NULL_UUID = "{00000000-0000-0000-0000-000000000000}";
|
||||||
|
|
||||||
// these control how long an abandoned pointer line or action will hang around
|
// 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"
|
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) {
|
function angleBetween(a, b) {
|
||||||
return Math.acos(Vec3.dot(Vec3.normalize(a), Vec3.normalize(b)));
|
return Math.acos(Vec3.dot(Vec3.normalize(a), Vec3.normalize(b)));
|
||||||
}
|
}
|
||||||
|
@ -1960,7 +1985,8 @@ function MyController(hand) {
|
||||||
this.heartBeat(this.grabbedEntity);
|
this.heartBeat(this.grabbedEntity);
|
||||||
|
|
||||||
var props = Entities.getEntityProperties(this.grabbedEntity, ["localPosition", "parentID",
|
var props = Entities.getEntityProperties(this.grabbedEntity, ["localPosition", "parentID",
|
||||||
"position", "rotation", "dimensions"]);
|
"position", "rotation", "dimensions",
|
||||||
|
"registrationPoint"]);
|
||||||
if (!props.position) {
|
if (!props.position) {
|
||||||
// server may have reset, taking our equipped entity with it. move back to "off" stte
|
// server may have reset, taking our equipped entity with it. move back to "off" stte
|
||||||
this.callEntityMethodOnGrabbed("releaseGrab");
|
this.callEntityMethodOnGrabbed("releaseGrab");
|
||||||
|
@ -1974,14 +2000,12 @@ function MyController(hand) {
|
||||||
|
|
||||||
if (props.parentID == MyAvatar.sessionUUID) {
|
if (props.parentID == MyAvatar.sessionUUID) {
|
||||||
var handPosition = this.getHandPosition();
|
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.1;
|
||||||
var TEAR_AWAY_DISTANCE = 0.04;
|
var dist = distanceBetweenPointAndEntityBoundingBox(handPosition, props);
|
||||||
var nearPickedCandidateEntities = Entities.findEntities(handPosition, NEAR_GRAB_RADIUS + TEAR_AWAY_DISTANCE);
|
if (dist > TEAR_AWAY_DISTANCE) {
|
||||||
if (nearPickedCandidateEntities.indexOf(this.grabbedEntity) == -1) {
|
|
||||||
// for whatever reason, the held/equipped entity has been pulled away. ungrab or unequip.
|
|
||||||
print("handControllerGrab -- autoreleasing held or equipped item because it is far from hand." +
|
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) {
|
if (this.state == STATE_NEAR_GRABBING) {
|
||||||
this.callEntityMethodOnGrabbed("releaseGrab");
|
this.callEntityMethodOnGrabbed("releaseGrab");
|
||||||
|
|
|
@ -11,6 +11,8 @@
|
||||||
var RAD_TO_DEG = 180 / Math.PI;
|
var RAD_TO_DEG = 180 / Math.PI;
|
||||||
var X_AXIS = {x: 1, y: 0, z: 0};
|
var X_AXIS = {x: 1, y: 0, z: 0};
|
||||||
var Y_AXIS = {x: 0, y: 1, 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";
|
var TABLET_URL = "https://s3.amazonaws.com/hifi-public/tony/tablet.fbx";
|
||||||
|
|
||||||
|
@ -37,12 +39,13 @@ function calcSpawnInfo() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ctor
|
// ctor
|
||||||
WebTablet = function (url) {
|
WebTablet = function (url, width, dpi) {
|
||||||
|
|
||||||
var ASPECT = 4.0 / 3.0;
|
var ASPECT = 4.0 / 3.0;
|
||||||
var WIDTH = 0.4;
|
var WIDTH = width || DEFAULT_WIDTH;
|
||||||
var HEIGHT = WIDTH * ASPECT;
|
var HEIGHT = WIDTH * ASPECT;
|
||||||
var DEPTH = 0.025;
|
var DEPTH = 0.025;
|
||||||
|
var DPI = dpi || DEFAULT_DPI;
|
||||||
|
|
||||||
var spawnInfo = calcSpawnInfo();
|
var spawnInfo = calcSpawnInfo();
|
||||||
|
|
||||||
|
@ -78,7 +81,7 @@ WebTablet = function (url) {
|
||||||
position: webEntityPosition,
|
position: webEntityPosition,
|
||||||
rotation: webEntityRotation,
|
rotation: webEntityRotation,
|
||||||
shapeType: "box",
|
shapeType: "box",
|
||||||
dpi: 45,
|
dpi: DPI,
|
||||||
parentID: this.tabletEntityID,
|
parentID: this.tabletEntityID,
|
||||||
parentJointIndex: -1
|
parentJointIndex: -1
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue