From 4c150efc1155960b702cf3e89806159ed6d3ae02 Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Thu, 11 Aug 2016 11:55:08 -0700 Subject: [PATCH 1/9] Categorize some debug logging in FBX parsing --- libraries/fbx/src/FBXReader_Material.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/libraries/fbx/src/FBXReader_Material.cpp b/libraries/fbx/src/FBXReader_Material.cpp index eb25f1d8a2..8c0f4b34ac 100644 --- a/libraries/fbx/src/FBXReader_Material.cpp +++ b/libraries/fbx/src/FBXReader_Material.cpp @@ -9,7 +9,11 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "FBXReader.h" + #include +#include + #include #include #include @@ -20,9 +24,8 @@ #include #include #include -#include "FBXReader.h" -#include +#include "ModelFormatLogging.h" bool FBXMaterial::needTangentSpace() const { return !normalTexture.isNull(); @@ -258,11 +261,11 @@ void FBXReader::consolidateFBXMaterials(const QVariantHash& mapping) { } } } - qDebug() << " fbx material Name:" << material.name; + qCDebug(modelformat) << " fbx material Name:" << material.name; if (materialMap.contains(material.name)) { QJsonObject materialOptions = materialMap.value(material.name).toObject(); - qDebug() << "Mapping fbx material:" << material.name << " with HifiMaterial: " << materialOptions; + qCDebug(modelformat) << "Mapping fbx material:" << material.name << " with HifiMaterial: " << materialOptions; if (materialOptions.contains("scattering")) { float scattering = (float) materialOptions.value("scattering").toDouble(); From 1632f4cb3d448281bd6ca5134b286bbec67bf581 Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Tue, 16 Aug 2016 10:52:05 -0700 Subject: [PATCH 2/9] better create locations --- scripts/system/edit.js | 53 +++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/scripts/system/edit.js b/scripts/system/edit.js index 19460b409b..e1360e2398 100644 --- a/scripts/system/edit.js +++ b/scripts/system/edit.js @@ -1129,36 +1129,37 @@ function handeMenuEvent(menuItem) { tooltip.show(false); } -// This function tries to find a reasonable position to place a new entity based on the camera -// position. If a reasonable position within the world bounds can't be found, `null` will -// be returned. The returned position will also take into account grid snapping settings. function getPositionToCreateEntity() { - var distance = cameraManager.enabled ? cameraManager.zoomDistance : DEFAULT_ENTITY_DRAG_DROP_DISTANCE; - var direction = Quat.getFront(Camera.orientation); - var offset = Vec3.multiply(distance, direction); - var placementPosition = Vec3.sum(Camera.position, offset); - - var cameraPosition = Camera.position; - var HALF_TREE_SCALE = 16384; - - var cameraOutOfBounds = Math.abs(cameraPosition.x) > HALF_TREE_SCALE || Math.abs(cameraPosition.y) > HALF_TREE_SCALE || - Math.abs(cameraPosition.z) > HALF_TREE_SCALE; - var placementOutOfBounds = Math.abs(placementPosition.x) > HALF_TREE_SCALE || - Math.abs(placementPosition.y) > HALF_TREE_SCALE || - Math.abs(placementPosition.z) > HALF_TREE_SCALE; - - if (cameraOutOfBounds && placementOutOfBounds) { - return null; + var direction = Quat.getFront(MyAvatar.orientation); + var distance = 1; + var position = Vec3.sum(MyAvatar.position, Vec3.multiply(direction, distance)); + position.y +=0.5; + if (position.x > HALF_TREE_SCALE || position.y > HALF_TREE_SCALE || position.z > HALF_TREE_SCALE) { + return null } - - placementPosition.x = Math.min(HALF_TREE_SCALE, Math.max(-HALF_TREE_SCALE, placementPosition.x)); - placementPosition.y = Math.min(HALF_TREE_SCALE, Math.max(-HALF_TREE_SCALE, placementPosition.y)); - placementPosition.z = Math.min(HALF_TREE_SCALE, Math.max(-HALF_TREE_SCALE, placementPosition.z)); - - return placementPosition; + return position; } +function getPositionToImportEntity() { + var dimensions = Clipboard.getContentsDimensions(); + var HALF_TREE_SCALE = 16384; + var direction = Quat.getFront(MyAvatar.orientation); + var distance = 1; + if (dimensions.x > distance) { + distance = dimensions.x + } + if (dimensions.z > distance) { + distance = dimensions.z + } + var position = Vec3.sum(MyAvatar.position, Vec3.multiply(direction, distance)); + + if (position.x > HALF_TREE_SCALE || position.y > HALF_TREE_SCALE || position.z > HALF_TREE_SCALE) { + return null + } + + return position; +} function importSVO(importURL) { print("Import URL requested: " + importURL); if (!Entities.canAdjustLocks()) { @@ -1183,7 +1184,7 @@ function importSVO(importURL) { z: 0 }; if (Clipboard.getClipboardContentsLargestDimension() < VERY_LARGE) { - position = getPositionToCreateEntity(); + position = getPositionToImportEntity(); } if (position !== null && position !== undefined) { var pastedEntityIDs = Clipboard.pasteEntities(position); From dae84617739a52c444b12dfde2eb7f6a0cb14c25 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Tue, 16 Aug 2016 15:42:17 -0700 Subject: [PATCH 3/9] Fix transparency on procedural shapes --- .../entities-renderer/src/RenderableShapeEntityItem.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libraries/entities-renderer/src/RenderableShapeEntityItem.cpp b/libraries/entities-renderer/src/RenderableShapeEntityItem.cpp index e14def114d..c3e097382c 100644 --- a/libraries/entities-renderer/src/RenderableShapeEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableShapeEntityItem.cpp @@ -91,6 +91,11 @@ void RenderableShapeEntityItem::render(RenderArgs* args) { _procedural.reset(new Procedural(getUserData())); _procedural->_vertexSource = simple_vert; _procedural->_fragmentSource = simple_frag; + _procedural->_opaqueState->setCullMode(gpu::State::CULL_NONE); + _procedural->_opaqueState->setDepthTest(true, true, gpu::LESS_EQUAL); + _procedural->_opaqueState->setBlendFunction(false, + gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA, + gpu::State::FACTOR_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ONE); } gpu::Batch& batch = *args->_batch; From 7bc1235c546e76f1b58959660c881e9643afcfc9 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Tue, 16 Aug 2016 16:47:13 -0700 Subject: [PATCH 4/9] local velocity and angular velocity in scripts is now handled the way local position and rotation are --- .../entities/src/EntityItemProperties.cpp | 12 ++- libraries/entities/src/EntityItemProperties.h | 2 + libraries/entities/src/EntityPropertyFlags.h | 3 + .../entities/src/EntityScriptingInterface.cpp | 34 ++++++++- libraries/shared/src/SpatiallyNestable.cpp | 76 +++++++++++++++++++ libraries/shared/src/SpatiallyNestable.h | 11 ++- .../system/controllers/handControllerGrab.js | 29 +------ 7 files changed, 136 insertions(+), 31 deletions(-) diff --git a/libraries/entities/src/EntityItemProperties.cpp b/libraries/entities/src/EntityItemProperties.cpp index dcd7e25bc1..b3d810c0eb 100644 --- a/libraries/entities/src/EntityItemProperties.cpp +++ b/libraries/entities/src/EntityItemProperties.cpp @@ -325,6 +325,8 @@ EntityPropertyFlags EntityItemProperties::getChangedProperties() const { CHECK_PROPERTY_CHANGE(PROP_QUERY_AA_CUBE, queryAACube); CHECK_PROPERTY_CHANGE(PROP_LOCAL_POSITION, localPosition); CHECK_PROPERTY_CHANGE(PROP_LOCAL_ROTATION, localRotation); + CHECK_PROPERTY_CHANGE(PROP_LOCAL_VELOCITY, localVelocity); + CHECK_PROPERTY_CHANGE(PROP_LOCAL_ANGULAR_VELOCITY, localAngularVelocity); CHECK_PROPERTY_CHANGE(PROP_FLYING_ALLOWED, flyingAllowed); CHECK_PROPERTY_CHANGE(PROP_GHOSTING_ALLOWED, ghostingAllowed); @@ -570,6 +572,8 @@ QScriptValue EntityItemProperties::copyToScriptValue(QScriptEngine* engine, bool COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_LOCAL_POSITION, localPosition); COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_LOCAL_ROTATION, localRotation); + COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_LOCAL_VELOCITY, localVelocity); + COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_LOCAL_ANGULAR_VELOCITY, localAngularVelocity); COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_CLIENT_ONLY, clientOnly); COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_OWNING_AVATAR_ID, owningAvatarID); @@ -707,6 +711,8 @@ void EntityItemProperties::copyFromScriptValue(const QScriptValue& object, bool COPY_PROPERTY_FROM_QSCRIPTVALUE(localPosition, glmVec3, setLocalPosition); COPY_PROPERTY_FROM_QSCRIPTVALUE(localRotation, glmQuat, setLocalRotation); + COPY_PROPERTY_FROM_QSCRIPTVALUE(localVelocity, glmVec3, setLocalVelocity); + COPY_PROPERTY_FROM_QSCRIPTVALUE(localAngularVelocity, glmVec3, setLocalAngularVelocity); COPY_PROPERTY_FROM_QSCRIPTVALUE(jointRotationsSet, qVectorBool, setJointRotationsSet); COPY_PROPERTY_FROM_QSCRIPTVALUE(jointRotations, qVectorQuat, setJointRotations); @@ -864,6 +870,8 @@ void EntityItemProperties::entityPropertyFlagsFromScriptValue(const QScriptValue ADD_PROPERTY_TO_MAP(PROP_LOCAL_POSITION, LocalPosition, localPosition, glm::vec3); ADD_PROPERTY_TO_MAP(PROP_LOCAL_ROTATION, LocalRotation, localRotation, glm::quat); + ADD_PROPERTY_TO_MAP(PROP_LOCAL_VELOCITY, LocalVelocity, localVelocity, glm::vec3); + ADD_PROPERTY_TO_MAP(PROP_LOCAL_ANGULAR_VELOCITY, LocalAngularVelocity, localAngularVelocity, glm::vec3); ADD_PROPERTY_TO_MAP(PROP_JOINT_ROTATIONS_SET, JointRotationsSet, jointRotationsSet, QVector); ADD_PROPERTY_TO_MAP(PROP_JOINT_ROTATIONS, JointRotations, jointRotations, QVector); @@ -1982,7 +1990,9 @@ QList EntityItemProperties::listChangedProperties() { } bool EntityItemProperties::parentDependentPropertyChanged() const { - return localPositionChanged() || positionChanged() || localRotationChanged() || rotationChanged(); + return localPositionChanged() || positionChanged() || + localRotationChanged() || rotationChanged() || + localVelocityChanged() || localAngularVelocityChanged(); } bool EntityItemProperties::parentRelatedPropertyChanged() const { diff --git a/libraries/entities/src/EntityItemProperties.h b/libraries/entities/src/EntityItemProperties.h index 6018ba793f..22d740e0dd 100644 --- a/libraries/entities/src/EntityItemProperties.h +++ b/libraries/entities/src/EntityItemProperties.h @@ -201,6 +201,8 @@ public: // these are used when bouncing location data into and out of scripts DEFINE_PROPERTY_REF(PROP_LOCAL_POSITION, LocalPosition, localPosition, glmVec3, ENTITY_ITEM_ZERO_VEC3); DEFINE_PROPERTY_REF(PROP_LOCAL_ROTATION, LocalRotation, localRotation, glmQuat, ENTITY_ITEM_DEFAULT_ROTATION); + DEFINE_PROPERTY_REF(PROP_LOCAL_VELOCITY, LocalVelocity, localVelocity, glmVec3, ENTITY_ITEM_ZERO_VEC3); + DEFINE_PROPERTY_REF(PROP_LOCAL_ANGULAR_VELOCITY, LocalAngularVelocity, localAngularVelocity, glmVec3, ENTITY_ITEM_ZERO_VEC3); DEFINE_PROPERTY_REF(PROP_JOINT_ROTATIONS_SET, JointRotationsSet, jointRotationsSet, QVector, QVector()); DEFINE_PROPERTY_REF(PROP_JOINT_ROTATIONS, JointRotations, jointRotations, QVector, QVector()); diff --git a/libraries/entities/src/EntityPropertyFlags.h b/libraries/entities/src/EntityPropertyFlags.h index 36bb37c8f3..0baef0fa25 100644 --- a/libraries/entities/src/EntityPropertyFlags.h +++ b/libraries/entities/src/EntityPropertyFlags.h @@ -177,6 +177,9 @@ enum EntityPropertyList { PROP_SHAPE, + PROP_LOCAL_VELOCITY, // only used to convert values to and from scripts + PROP_LOCAL_ANGULAR_VELOCITY, // only used to convert values to and from scripts + //////////////////////////////////////////////////////////////////////////////////////////////////// // ATTENTION: add new properties to end of list just ABOVE this line PROP_AFTER_LAST_ITEM, diff --git a/libraries/entities/src/EntityScriptingInterface.cpp b/libraries/entities/src/EntityScriptingInterface.cpp index 653b37c3bb..232b952a93 100644 --- a/libraries/entities/src/EntityScriptingInterface.cpp +++ b/libraries/entities/src/EntityScriptingInterface.cpp @@ -78,6 +78,8 @@ EntityItemProperties convertLocationToScriptSemantics(const EntityItemProperties EntityItemProperties scriptSideProperties = entitySideProperties; scriptSideProperties.setLocalPosition(entitySideProperties.getPosition()); scriptSideProperties.setLocalRotation(entitySideProperties.getRotation()); + scriptSideProperties.setLocalVelocity(entitySideProperties.getLocalVelocity()); + scriptSideProperties.setLocalAngularVelocity(entitySideProperties.getLocalAngularVelocity()); bool success; glm::vec3 worldPosition = SpatiallyNestable::localToWorld(entitySideProperties.getPosition(), @@ -88,10 +90,19 @@ EntityItemProperties convertLocationToScriptSemantics(const EntityItemProperties entitySideProperties.getParentID(), entitySideProperties.getParentJointIndex(), success); - // TODO -- handle velocity and angularVelocity + glm::vec3 worldVelocity = SpatiallyNestable::localToWorldVelocity(entitySideProperties.getVelocity(), + entitySideProperties.getParentID(), + entitySideProperties.getParentJointIndex(), + success); + glm::vec3 worldAngularVelocity = SpatiallyNestable::localToWorldAngularVelocity(entitySideProperties.getAngularVelocity(), + entitySideProperties.getParentID(), + entitySideProperties.getParentJointIndex(), + success); scriptSideProperties.setPosition(worldPosition); scriptSideProperties.setRotation(worldRotation); + scriptSideProperties.setVelocity(worldVelocity); + scriptSideProperties.setAngularVelocity(worldAngularVelocity); return scriptSideProperties; } @@ -125,6 +136,27 @@ EntityItemProperties convertLocationFromScriptSemantics(const EntityItemProperti entitySideProperties.setRotation(localRotation); } + if (scriptSideProperties.localVelocityChanged()) { + entitySideProperties.setVelocity(scriptSideProperties.getLocalVelocity()); + } else if (scriptSideProperties.velocityChanged()) { + glm::vec3 localVelocity = SpatiallyNestable::worldToLocalVelocity(entitySideProperties.getVelocity(), + entitySideProperties.getParentID(), + entitySideProperties.getParentJointIndex(), + success); + entitySideProperties.setVelocity(localVelocity); + } + + if (scriptSideProperties.localAngularVelocityChanged()) { + entitySideProperties.setAngularVelocity(scriptSideProperties.getLocalAngularVelocity()); + } else if (scriptSideProperties.angularVelocityChanged()) { + glm::vec3 localAngularVelocity = + SpatiallyNestable::worldToLocalAngularVelocity(entitySideProperties.getAngularVelocity(), + entitySideProperties.getParentID(), + entitySideProperties.getParentJointIndex(), + success); + entitySideProperties.setAngularVelocity(localAngularVelocity); + } + return entitySideProperties; } diff --git a/libraries/shared/src/SpatiallyNestable.cpp b/libraries/shared/src/SpatiallyNestable.cpp index c3dbafa0d9..453035de0f 100644 --- a/libraries/shared/src/SpatiallyNestable.cpp +++ b/libraries/shared/src/SpatiallyNestable.cpp @@ -224,6 +224,38 @@ glm::quat SpatiallyNestable::worldToLocal(const glm::quat& orientation, return result.getRotation(); } +glm::vec3 SpatiallyNestable::worldToLocalVelocity(const glm::vec3& velocity, const QUuid& parentID, + int parentJointIndex, bool& success) { + SpatiallyNestablePointer parent = SpatiallyNestable::findByID(parentID, success); + if (!success || !parent) { + return velocity; + } + Transform parentTransform = parent->getTransform(success); + if (!success) { + return velocity; + } + glm::vec3 parentVelocity = parent->getVelocity(success); + if (!success) { + return velocity; + } + + return glm::inverse(parentTransform.getRotation()) * (velocity - parentVelocity); +} + +glm::vec3 SpatiallyNestable::worldToLocalAngularVelocity(const glm::vec3& angularVelocity, const QUuid& parentID, + int parentJointIndex, bool& success) { + SpatiallyNestablePointer parent = SpatiallyNestable::findByID(parentID, success); + if (!success || !parent) { + return angularVelocity; + } + Transform parentTransform = parent->getTransform(success); + if (!success) { + return angularVelocity; + } + + return glm::inverse(parentTransform.getRotation()) * angularVelocity; +} + glm::vec3 SpatiallyNestable::localToWorld(const glm::vec3& position, const QUuid& parentID, int parentJointIndex, bool& success) { @@ -298,6 +330,38 @@ glm::quat SpatiallyNestable::localToWorld(const glm::quat& orientation, return result.getRotation(); } +glm::vec3 SpatiallyNestable::localToWorldVelocity(const glm::vec3& velocity, const QUuid& parentID, + int parentJointIndex, bool& success) { + SpatiallyNestablePointer parent = SpatiallyNestable::findByID(parentID, success); + if (!success || !parent) { + return velocity; + } + Transform parentTransform = parent->getTransform(success); + if (!success) { + return velocity; + } + glm::vec3 parentVelocity = parent->getVelocity(success); + if (!success) { + return velocity; + } + + return parentVelocity + parentTransform.getRotation() * velocity; +} + +glm::vec3 SpatiallyNestable::localToWorldAngularVelocity(const glm::vec3& angularVelocity, const QUuid& parentID, + int parentJointIndex, bool& success) { + SpatiallyNestablePointer parent = SpatiallyNestable::findByID(parentID, success); + if (!success || !parent) { + return angularVelocity; + } + Transform parentTransform = parent->getTransform(success); + if (!success) { + return angularVelocity; + } + + return parentTransform.getRotation() * angularVelocity; +} + glm::vec3 SpatiallyNestable::getPosition(bool& success) const { return getTransform(success).getTranslation(); } @@ -1004,3 +1068,15 @@ void SpatiallyNestable::setLocalTransformAndVelocities( locationChanged(false); } } + +SpatiallyNestablePointer SpatiallyNestable::findByID(QUuid id, bool& success) { + QSharedPointer parentFinder = DependencyManager::get(); + if (!parentFinder) { + return nullptr; + } + SpatiallyNestableWeakPointer parentWP = parentFinder->find(id, success); + if (!success) { + return nullptr; + } + return parentWP.lock(); +} diff --git a/libraries/shared/src/SpatiallyNestable.h b/libraries/shared/src/SpatiallyNestable.h index 391f13cc27..5605cc0031 100644 --- a/libraries/shared/src/SpatiallyNestable.h +++ b/libraries/shared/src/SpatiallyNestable.h @@ -48,9 +48,17 @@ public: static glm::vec3 worldToLocal(const glm::vec3& position, const QUuid& parentID, int parentJointIndex, bool& success); static glm::quat worldToLocal(const glm::quat& orientation, const QUuid& parentID, int parentJointIndex, bool& success); + static glm::vec3 worldToLocalVelocity(const glm::vec3& velocity, const QUuid& parentID, + int parentJointIndex, bool& success); + static glm::vec3 worldToLocalAngularVelocity(const glm::vec3& angularVelocity, const QUuid& parentID, + int parentJointIndex, bool& success); static glm::vec3 localToWorld(const glm::vec3& position, const QUuid& parentID, int parentJointIndex, bool& success); static glm::quat localToWorld(const glm::quat& orientation, const QUuid& parentID, int parentJointIndex, bool& success); + static glm::vec3 localToWorldVelocity(const glm::vec3& velocity, + const QUuid& parentID, int parentJointIndex, bool& success); + static glm::vec3 localToWorldAngularVelocity(const glm::vec3& angularVelocity, + const QUuid& parentID, int parentJointIndex, bool& success); // world frame virtual const Transform getTransform(bool& success, int depth = 0) const; @@ -151,6 +159,8 @@ public: virtual SpatialParentTree* getParentTree() const { return nullptr; } bool hasAncestorOfType(NestableType nestableType); + SpatiallyNestablePointer getParentPointer(bool& success) const; + static SpatiallyNestablePointer findByID(QUuid id, bool& success); void getLocalTransformAndVelocities(Transform& localTransform, glm::vec3& localVelocity, @@ -166,7 +176,6 @@ protected: QUuid _id; QUuid _parentID; // what is this thing's transform relative to? quint16 _parentJointIndex { 0 }; // which joint of the parent is this relative to? - SpatiallyNestablePointer getParentPointer(bool& success) const; mutable SpatiallyNestableWeakPointer _parent; diff --git a/scripts/system/controllers/handControllerGrab.js b/scripts/system/controllers/handControllerGrab.js index 929cd7d12a..1264502aa7 100644 --- a/scripts/system/controllers/handControllerGrab.js +++ b/scripts/system/controllers/handControllerGrab.js @@ -2204,28 +2204,13 @@ function MyController(hand) { var props = Entities.getEntityProperties(entityID, ["parentID", "velocity", "dynamic", "shapeType"]); var parentID = props.parentID; - var doSetVelocity = false; - if (parentID != NULL_UUID && deactiveProps.parentID == NULL_UUID && propsArePhysical(props)) { - // TODO: EntityScriptingInterface::convertLocationToScriptSemantics should be setting up - // props.velocity to be a world-frame velocity and localVelocity to be vs parent. Until that - // is done, we use a measured velocity here so that things held via a bumper-grab / parenting-grab - // can be thrown. - doSetVelocity = true; - } - if (!noVelocity && - !doSetVelocity && parentID == MyAvatar.sessionUUID && Vec3.length(data["gravity"]) > 0.0 && data["dynamic"] && data["parentID"] == NULL_UUID && !data["collisionless"]) { - deactiveProps["velocity"] = { - x: 0.0, - y: 0.1, - z: 0.0 - }; - doSetVelocity = false; + deactiveProps["velocity"] = this.currentVelocity; } if (noVelocity) { deactiveProps["velocity"] = { @@ -2238,21 +2223,9 @@ function MyController(hand) { y: 0.0, z: 0.0 }; - doSetVelocity = false; } Entities.editEntity(entityID, deactiveProps); - - if (doSetVelocity) { - // this is a continuation of the TODO above -- we shouldn't need to set this here. - // do this after the parent has been reset. setting this at the same time as - // the parent causes it to go off in the wrong direction. This is a bug that should - // be fixed. - Entities.editEntity(entityID, { - velocity: this.currentVelocity - // angularVelocity: this.currentAngularVelocity - }); - } data = null; } else if (this.shouldResetParentOnRelease) { // we parent-grabbed this from another parent grab. try to put it back where we found it. From 06787029b75abf97e5677dd5908a34de8ea66168 Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Tue, 16 Aug 2016 17:58:35 -0700 Subject: [PATCH 5/9] small --- scripts/system/edit.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/scripts/system/edit.js b/scripts/system/edit.js index e1360e2398..5139425b85 100644 --- a/scripts/system/edit.js +++ b/scripts/system/edit.js @@ -1128,13 +1128,16 @@ function handeMenuEvent(menuItem) { } tooltip.show(false); } - function getPositionToCreateEntity() { var HALF_TREE_SCALE = 16384; var direction = Quat.getFront(MyAvatar.orientation); var distance = 1; var position = Vec3.sum(MyAvatar.position, Vec3.multiply(direction, distance)); - position.y +=0.5; + + if (Camera.mode === "entity" || Camera.mode === "independent") { + position = Vec3.sum(Camera.position, Vec3.multiply(Quat.getFront(Camera.orientation), distance)) + } + position.y += 0.5; if (position.x > HALF_TREE_SCALE || position.y > HALF_TREE_SCALE || position.z > HALF_TREE_SCALE) { return null } @@ -1145,15 +1148,21 @@ function getPositionToImportEntity() { var dimensions = Clipboard.getContentsDimensions(); var HALF_TREE_SCALE = 16384; var direction = Quat.getFront(MyAvatar.orientation); - var distance = 1; + var distance = 1.5; if (dimensions.x > distance) { - distance = dimensions.x + distance = dimensions.x / 2 } if (dimensions.z > distance) { - distance = dimensions.z + distance = dimensions.z / 2 } var position = Vec3.sum(MyAvatar.position, Vec3.multiply(direction, distance)); + print('distance is:: ' + distance); + + if (Camera.mode === "entity" || Camera.mode === "independent") { + position = Vec3.sum(Camera.position, Vec3.multiply(Quat.getFront(Camera.orientation), distance)) + } + if (position.x > HALF_TREE_SCALE || position.y > HALF_TREE_SCALE || position.z > HALF_TREE_SCALE) { return null } From e9c2a1d509671769247949e83f3d72d23ed25614 Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Tue, 16 Aug 2016 18:03:34 -0700 Subject: [PATCH 6/9] cleanup prints --- scripts/system/edit.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/scripts/system/edit.js b/scripts/system/edit.js index 5139425b85..3b623e6271 100644 --- a/scripts/system/edit.js +++ b/scripts/system/edit.js @@ -1157,8 +1157,6 @@ function getPositionToImportEntity() { } var position = Vec3.sum(MyAvatar.position, Vec3.multiply(direction, distance)); - print('distance is:: ' + distance); - if (Camera.mode === "entity" || Camera.mode === "independent") { position = Vec3.sum(Camera.position, Vec3.multiply(Quat.getFront(Camera.orientation), distance)) } From 0810ad0e7b0f66bb7cf53d9131cfb068fd5ff169 Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Tue, 16 Aug 2016 18:13:42 -0700 Subject: [PATCH 7/9] use square of sides --- scripts/system/edit.js | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/scripts/system/edit.js b/scripts/system/edit.js index 3b623e6271..a3e5476bf9 100644 --- a/scripts/system/edit.js +++ b/scripts/system/edit.js @@ -1148,17 +1148,12 @@ function getPositionToImportEntity() { var dimensions = Clipboard.getContentsDimensions(); var HALF_TREE_SCALE = 16384; var direction = Quat.getFront(MyAvatar.orientation); - var distance = 1.5; - if (dimensions.x > distance) { - distance = dimensions.x / 2 - } - if (dimensions.z > distance) { - distance = dimensions.z / 2 - } - var position = Vec3.sum(MyAvatar.position, Vec3.multiply(direction, distance)); + var longest = 1; + longest = Math.sqrt(Math.pow(dimensions.x, 2) + Math.pow(dimensions.z, 2)); + var position = Vec3.sum(MyAvatar.position, Vec3.multiply(direction, longest)); if (Camera.mode === "entity" || Camera.mode === "independent") { - position = Vec3.sum(Camera.position, Vec3.multiply(Quat.getFront(Camera.orientation), distance)) + position = Vec3.sum(Camera.position, Vec3.multiply(Quat.getFront(Camera.orientation), longest)) } if (position.x > HALF_TREE_SCALE || position.y > HALF_TREE_SCALE || position.z > HALF_TREE_SCALE) { From 0e259dcd299ae06ff249f4337a97a473e6ee310d Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Wed, 17 Aug 2016 09:29:45 -0700 Subject: [PATCH 8/9] Add open log dir button to server-console --- server-console/src/log.html | 1 + server-console/src/log.js | 2 ++ server-console/src/main.js | 5 +++++ 3 files changed, 8 insertions(+) diff --git a/server-console/src/log.html b/server-console/src/log.html index f704f3e35f..3ccf8112e8 100644 --- a/server-console/src/log.html +++ b/server-console/src/log.html @@ -8,6 +8,7 @@
    diff --git a/server-console/src/log.js b/server-console/src/log.js index 3634eaeaa7..c739f210b7 100644 --- a/server-console/src/log.js +++ b/server-console/src/log.js @@ -218,6 +218,8 @@ ready = function() { appendLogMessages('ac'); } + $('#view-logs').on('click', remote.openLogDirectory); + // handle filtering of table rows on input change $('#search-input').on('input', function() { filter = $(this).val().toLowerCase(); diff --git a/server-console/src/main.js b/server-console/src/main.js index 8f85872d0b..c47308aed6 100644 --- a/server-console/src/main.js +++ b/server-console/src/main.js @@ -285,6 +285,10 @@ function openFileBrowser(path) { } } +function openLogDirectory() { + openFileBrowser(logPath); +} + // NOTE: this looks like it does nothing, but it's very important. // Without it the default behaviour is to quit the app once all windows closed // which is absolutely not what we want for a taskbar application. @@ -309,6 +313,7 @@ global.homeServer = null; global.domainServer = null; global.acMonitor = null; global.userConfig = userConfig; +global.openLogDirectory = openLogDirectory; var LogWindow = function(ac, ds) { this.ac = ac; From 8ba105d1e418973f3e93f25e8c564343929b5563 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Wed, 17 Aug 2016 09:36:42 -0700 Subject: [PATCH 9/9] Fix open-log-dir button handler --- server-console/src/log.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/server-console/src/log.js b/server-console/src/log.js index c739f210b7..455b6828d8 100644 --- a/server-console/src/log.js +++ b/server-console/src/log.js @@ -43,6 +43,7 @@ ready = function() { var domainServer = remote.getGlobal('domainServer'); var acMonitor = remote.getGlobal('acMonitor'); + var openLogDirectory = remote.getGlobal('openLogDirectory'); var pendingLines = { 'ds': new Array(), @@ -218,7 +219,11 @@ ready = function() { appendLogMessages('ac'); } - $('#view-logs').on('click', remote.openLogDirectory); + // Binding a remote function directly does not work, so bind to a function + // that calls the remote function. + $('#view-logs').on('click', function() { + openLogDirectory(); + }); // handle filtering of table rows on input change $('#search-input').on('input', function() {