From 6a90beb4aac31e2b397f6de1aa8db828eaec7505 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Tue, 10 Oct 2017 15:22:32 -0700 Subject: [PATCH 01/26] Fix .fst texdir not being followed Although the texdir was being acknowledged and used as the _textureBaseURL inside of the Geometry* classes, it was being overwritten in code meant to handle redirects. Basically, when a geometry resource request is redirected (via ATP, HTTP, etc.), we needed to update the _textureBaseURL to take the new location into account. Previously we were overwriting the _textureBaseURL all the time, even when not being redirected, but this updates it to only be overwritten when the request is redirected. There is at least 1 known case that this does not handle: a .fst with its `texdir` set, that points at an fbx that gets redirected. --- .../src/model-networking/ModelCache.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libraries/model-networking/src/model-networking/ModelCache.cpp b/libraries/model-networking/src/model-networking/ModelCache.cpp index 2756334a1a..b62ad7b366 100644 --- a/libraries/model-networking/src/model-networking/ModelCache.cpp +++ b/libraries/model-networking/src/model-networking/ModelCache.cpp @@ -71,14 +71,14 @@ void GeometryMappingResource::downloadFinished(const QByteArray& data) { } else { QUrl url = _url.resolved(filename); - QString texdir = mapping.value("texdir").toString(); + QString texdir = mapping.value(TEXDIR_FIELD).toString(); if (!texdir.isNull()) { if (!texdir.endsWith('/')) { texdir += '/'; } _textureBaseUrl = resolveTextureBaseUrl(url, _url.resolved(texdir)); } else { - _textureBaseUrl = _effectiveBaseURL; + _textureBaseUrl = url.resolved(QUrl(".")); } auto animGraphVariant = mapping.value("animGraphUrl"); @@ -241,8 +241,10 @@ private: }; void GeometryDefinitionResource::downloadFinished(const QByteArray& data) { - _url = _effectiveBaseURL; - _textureBaseUrl = _effectiveBaseURL; + if (_url != _effectiveBaseURL) { + _url = _effectiveBaseURL; + _textureBaseUrl = _effectiveBaseURL; + } QThreadPool::globalInstance()->start(new GeometryReader(_self, _effectiveBaseURL, _mapping, data, _combineParts)); } From 9981a44b710974457d8150f8e039b38783689ce3 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Thu, 7 Sep 2017 09:29:04 -0700 Subject: [PATCH 02/26] add hook for ShapeInfo calculator --- libraries/entities/src/ShapeEntityItem.cpp | 18 ++++++++++++++++-- libraries/entities/src/ShapeEntityItem.h | 4 +++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/libraries/entities/src/ShapeEntityItem.cpp b/libraries/entities/src/ShapeEntityItem.cpp index 6e3bdc27a4..6f3025881b 100644 --- a/libraries/entities/src/ShapeEntityItem.cpp +++ b/libraries/entities/src/ShapeEntityItem.cpp @@ -51,6 +51,14 @@ namespace entity { } } +// shapeCalculator is a hook for external code that knows how to configure a ShapeInfo +// for given entity::Shape and dimensions +ShapeEntityItem::ShapeInfoCalculator shapeCalculator = nullptr; + +void ShapeEntityItem::setShapeInfoCalulator(ShapeEntityItem::ShapeInfoCalculator callback) { + shapeCalculator = callback; +} + ShapeEntityItem::Pointer ShapeEntityItem::baseFactory(const EntityItemID& entityID, const EntityItemProperties& properties) { Pointer entity(new ShapeEntityItem(entityID), [](EntityItem* ptr) { ptr->deleteLater(); }); entity->setProperties(properties); @@ -278,8 +286,14 @@ void ShapeEntityItem::computeShapeInfo(ShapeInfo& info) { case entity::Shape::Icosahedron: case entity::Shape::Cone: { - //TODO WL21389: SHAPE_TYPE_SIMPLE_HULL and pointCollection (later) - _collisionShapeType = SHAPE_TYPE_ELLIPSOID; + if (shapeCalculator) { + shapeCalculator(info, _shape, getDimensions()); + // shapeCalculator only supports convex shapes (e.g. SHAPE_TYPE_HULL) + // TODO: figure out how to support concave shapes + _collisionShapeType = SHAPE_TYPE_HULL; + } else { + _collisionShapeType = SHAPE_TYPE_ELLIPSOID; + } } break; case entity::Shape::Torus: diff --git a/libraries/entities/src/ShapeEntityItem.h b/libraries/entities/src/ShapeEntityItem.h index a20cecb60b..0f8197787b 100644 --- a/libraries/entities/src/ShapeEntityItem.h +++ b/libraries/entities/src/ShapeEntityItem.h @@ -34,7 +34,6 @@ namespace entity { ::QString stringFromShape(Shape shape); } - class ShapeEntityItem : public EntityItem { using Pointer = std::shared_ptr; static Pointer baseFactory(const EntityItemID& entityID, const EntityItemProperties& properties); @@ -43,6 +42,9 @@ public: static EntityItemPointer sphereFactory(const EntityItemID& entityID, const EntityItemProperties& properties); static EntityItemPointer boxFactory(const EntityItemID& entityID, const EntityItemProperties& properties); + using ShapeInfoCalculator = std::function; + static void setShapeInfoCalulator(ShapeInfoCalculator callback); + ShapeEntityItem(const EntityItemID& entityItemID); void pureVirtualFunctionPlaceHolder() override { }; From 5b50b362f14dd30b36d9e5aff707b1a0fd1ee622 Mon Sep 17 00:00:00 2001 From: LaShonda Hopper Date: Fri, 8 Sep 2017 15:49:18 -0400 Subject: [PATCH 03/26] [WL21389] WL21389 PR2: Representation of collision shapes need updating (details below). This commit adds support for the polyhedrons and polygons sans Torus and Quad which aren't currently supported within GeometryCache. * Moves GeometryCache::_shapes from public to private scope * Nothing aside from the class should be directly altering this, only querying * Updated instances of direct referencing which looks to have been limited to prior testing of instancing and shapes. * Adds an accessor function for ShapeData to GeometryCache * Consolidates point list generation to helper function * GeometryCache::computeSimpleHullPointListForShape * Moves GeometryCache::Shape to entity::Shape mapping to GeometryCache from RenderableShapeEntityItem * Adds conversion accessor to GeometryCache, GeometryCache::Shape getShapeForEntityShape * Sets ShapeEntityItem::ShapeInfoCalculator callback committed earlier. * This helps circumvent the issue with library inclusion. entity-render knows about entity; however, entity doesn't know about entity-renderer; however, GeometryCache data is needed within entity::ShapeEntityItem to compose the ShapeInfo point list data. * This callback is set up within Application::init of the Interface as it knows about both halves of the equation, and the callback needs to be setup prior to any entities collision data getting generated. * Removes _type reset within ShapeInfo::setPointCollection * This should avoid any issues due to subversively setting the type or incorrectly setting the type as a tangential operation. * Audited instances of ShapeInfo::setPointCollection and all seemed to be calling the function immediately after having set the type via ShapeInfo::setParams * Adds new ShapeType: SHAPE_TYPE_CIRCLE * This type is reserved for the circle which is now treated as a special type of Cylinder_Y with regard to collision as opposed to a simple hull. * Fixes the issue where jumping on a circle, at times, would result in the avatar sliding off towards an edge as if atop a squished cone. * Also updates ShapeInfo::getType() to return ShapeType as opposed to int * Auditing calls showed that majority of places were comparing against ShapeType * ShapeType::_type is a ShapeType so returning the type explicitly is more consistent. * ShapeInfo file houses ShapeType enum so any file aware of ShapeInfo is aware of ShapeType enumeration. * entity::Quad defaults to SHAPE_TYPE_ELLIPSOID * Like entity::Shape::Torus, entity::Shape::Quad is currently unsupported within GeometryCache::buildShapes. * Also it appears that a Quad shape can't be created within world via the creation menu. * There's no explicit option at present to create one. * Trying subvert the Cube/Box creation option to generate one results in an enforced stubby box as opposed to a quad. * Given the aforementioned points, entity::Shape::Quad will default to SHAPE_TYPE_ELLIPSOID as opposed to SHAPE_TYPE_BOX. * Added Todo regarding the shape being unsupported along with a notation to create a special ShapeType, SHAPE_TYPE_QUAD, for it should it be added in the future. * Adds some comments and has some minor clean up. Reviewed-by: Leander Hasty Changes Committed: modified: interface/src/Application.cpp modified: interface/src/Util.cpp modified: interface/src/Util.h modified: libraries/entities-renderer/src/RenderableShapeEntityItem.cpp modified: libraries/entities/src/ShapeEntityItem.cpp modified: libraries/entities/src/ShapeEntityItem.h modified: libraries/physics/src/ShapeFactory.cpp modified: libraries/render-utils/src/GeometryCache.cpp modified: libraries/render-utils/src/GeometryCache.h modified: libraries/shared/src/ShapeInfo.cpp modified: libraries/shared/src/ShapeInfo.h modified: tests/gpu-test/src/TestInstancedShapes.cpp --- interface/src/Application.cpp | 5 + interface/src/Util.cpp | 11 ++ interface/src/Util.h | 5 + .../src/RenderableShapeEntityItem.cpp | 27 +--- libraries/entities/src/ShapeEntityItem.cpp | 130 ++++++++++-------- libraries/entities/src/ShapeEntityItem.h | 2 +- libraries/physics/src/ShapeFactory.cpp | 1 + libraries/render-utils/src/GeometryCache.cpp | 81 +++++++++++ libraries/render-utils/src/GeometryCache.h | 18 ++- libraries/shared/src/ShapeInfo.cpp | 8 +- libraries/shared/src/ShapeInfo.h | 5 +- tests/gpu-test/src/TestInstancedShapes.cpp | 25 ++-- 12 files changed, 221 insertions(+), 97 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 6e7a405181..87d4db9936 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -120,6 +120,7 @@ #include #include #include +#include #include #include #include @@ -4228,6 +4229,10 @@ void Application::init() { // fire off an immediate domain-server check in now that settings are loaded DependencyManager::get()->sendDomainServerCheckIn(); + // This allows collision to be set up properly for shape entities supported by GeometryCache. + // This is before entity setup to ensure that it's ready for whenever instance collision is initialized. + ShapeEntityItem::setShapeInfoCalulator(ShapeEntityItem::ShapeInfoCalculator(&shapeInfoCalculator)); + getEntities()->init(); getEntities()->setEntityLoadingPriorityFunction([this](const EntityItem& item) { auto dims = item.getDimensions(); diff --git a/interface/src/Util.cpp b/interface/src/Util.cpp index 7822b78244..3e3f514117 100644 --- a/interface/src/Util.cpp +++ b/interface/src/Util.cpp @@ -28,6 +28,8 @@ #include #include #include +#include +#include #include "InterfaceLogging.h" #include "world.h" @@ -393,4 +395,13 @@ void runUnitTests() { } } +void shapeInfoCalculator(const ShapeEntityItem * const shapeEntity, ShapeInfo &shapeInfo) { + ShapeInfo::PointCollection pointCollection; + ShapeInfo::PointList points; + + GeometryCache::computeSimpleHullPointListForShape(shapeEntity, points); + pointCollection.push_back(points); + shapeInfo.setPointCollection(pointCollection); +} + diff --git a/interface/src/Util.h b/interface/src/Util.h index 48acb53936..976a26ce82 100644 --- a/interface/src/Util.h +++ b/interface/src/Util.h @@ -18,6 +18,9 @@ #include #include +class ShapeEntityItem; +class ShapeInfo; + void renderWorldBox(RenderArgs* args, gpu::Batch& batch); void runTimingTests(); @@ -28,4 +31,6 @@ bool rayIntersectsSphere(const glm::vec3& rayStarting, const glm::vec3& rayNorma bool pointInSphere(glm::vec3& point, glm::vec3& sphereCenter, double sphereRadius); +void shapeInfoCalculator(const ShapeEntityItem * const shapeEntity, ShapeInfo &shapeInfo); + #endif // hifi_Util_h diff --git a/libraries/entities-renderer/src/RenderableShapeEntityItem.cpp b/libraries/entities-renderer/src/RenderableShapeEntityItem.cpp index 7d7de0c08f..a72320fda0 100644 --- a/libraries/entities-renderer/src/RenderableShapeEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableShapeEntityItem.cpp @@ -30,23 +30,6 @@ using namespace render::entities; // is a half unit sphere. However, the geometry cache renders a UNIT sphere, so we need to scale down. static const float SPHERE_ENTITY_SCALE = 0.5f; -static std::array MAPPING { { - GeometryCache::Triangle, - GeometryCache::Quad, - GeometryCache::Hexagon, - GeometryCache::Octagon, - GeometryCache::Circle, - GeometryCache::Cube, - GeometryCache::Sphere, - GeometryCache::Tetrahedron, - GeometryCache::Octahedron, - GeometryCache::Dodecahedron, - GeometryCache::Icosahedron, - GeometryCache::Torus, - GeometryCache::Cone, - GeometryCache::Cylinder, -} }; - ShapeEntityRenderer::ShapeEntityRenderer(const EntityItemPointer& entity) : Parent(entity) { _procedural._vertexSource = simple_vert; @@ -137,11 +120,12 @@ void ShapeEntityRenderer::doRender(RenderArgs* args) { gpu::Batch& batch = *args->_batch; + auto geometryCache = DependencyManager::get(); GeometryCache::Shape geometryShape; bool proceduralRender = false; glm::vec4 outColor; withReadLock([&] { - geometryShape = MAPPING[_shape]; + geometryShape = geometryCache->getShapeForEntityShape(_shape); batch.setModelTransform(_renderTransform); // use a transform with scale, rotation, registration point and translation outColor = _color; if (_procedural.isReady()) { @@ -155,14 +139,13 @@ void ShapeEntityRenderer::doRender(RenderArgs* args) { if (proceduralRender) { batch._glColor4f(outColor.r, outColor.g, outColor.b, outColor.a); if (render::ShapeKey(args->_globalShapeKey).isWireframe()) { - DependencyManager::get()->renderWireShape(batch, geometryShape); + geometryCache->renderWireShape(batch, geometryShape); } else { - DependencyManager::get()->renderShape(batch, geometryShape); + geometryCache->renderShape(batch, geometryShape); } } else { // FIXME, support instanced multi-shape rendering using multidraw indirect outColor.a *= _isFading ? Interpolate::calculateFadeRatio(_fadeStartTime) : 1.0f; - auto geometryCache = DependencyManager::get(); auto pipeline = outColor.a < 1.0f ? geometryCache->getTransparentShapePipeline() : geometryCache->getOpaqueShapePipeline(); if (render::ShapeKey(args->_globalShapeKey).isWireframe()) { geometryCache->renderWireShapeInstance(args, batch, geometryShape, outColor, pipeline); @@ -171,6 +154,6 @@ void ShapeEntityRenderer::doRender(RenderArgs* args) { } } - static const auto triCount = DependencyManager::get()->getShapeTriangleCount(geometryShape); + static const auto triCount = geometryCache->getShapeTriangleCount(geometryShape); args->_details._trianglesRendered += (int)triCount; } diff --git a/libraries/entities/src/ShapeEntityItem.cpp b/libraries/entities/src/ShapeEntityItem.cpp index 6f3025881b..655283a601 100644 --- a/libraries/entities/src/ShapeEntityItem.cpp +++ b/libraries/entities/src/ShapeEntityItem.cpp @@ -241,79 +241,95 @@ void ShapeEntityItem::computeShapeInfo(ShapeInfo& info) { const glm::vec3 entityDimensions = getDimensions(); - switch (_shape) { - case entity::Shape::Quad: - case entity::Shape::Cube: - { - _collisionShapeType = SHAPE_TYPE_BOX; + switch (_shape){ + case entity::Shape::Quad: { + // Not in GeometryCache::buildShapes, unsupported. + _collisionShapeType = SHAPE_TYPE_ELLIPSOID; + //TODO WL21389: Add a SHAPE_TYPE_QUAD ShapeType and treat + // as a special box (later if desired support) + } + break; + case entity::Shape::Cube: { + _collisionShapeType = SHAPE_TYPE_BOX; + } + break; + case entity::Shape::Sphere: { + + float diameter = entityDimensions.x; + const float MIN_DIAMETER = 0.001f; + const float MIN_RELATIVE_SPHERICAL_ERROR = 0.001f; + if (diameter > MIN_DIAMETER + && fabsf(diameter - entityDimensions.y) / diameter < MIN_RELATIVE_SPHERICAL_ERROR + && fabsf(diameter - entityDimensions.z) / diameter < MIN_RELATIVE_SPHERICAL_ERROR) { + + _collisionShapeType = SHAPE_TYPE_SPHERE; + } else { + _collisionShapeType = SHAPE_TYPE_ELLIPSOID; } - break; - case entity::Shape::Sphere: - { + } + break; + case entity::Shape::Circle: { + _collisionShapeType = SHAPE_TYPE_CIRCLE; + } + break; + case entity::Shape::Cylinder: { + _collisionShapeType = SHAPE_TYPE_CYLINDER_Y; + // TODO WL21389: determine if rotation is axis-aligned + //const Transform::Quat & rot = _transform.getRotation(); - float diameter = entityDimensions.x; - const float MIN_DIAMETER = 0.001f; - const float MIN_RELATIVE_SPHERICAL_ERROR = 0.001f; - if (diameter > MIN_DIAMETER - && fabsf(diameter - entityDimensions.y) / diameter < MIN_RELATIVE_SPHERICAL_ERROR - && fabsf(diameter - entityDimensions.z) / diameter < MIN_RELATIVE_SPHERICAL_ERROR) { + // TODO WL21389: some way to tell apart SHAPE_TYPE_CYLINDER_Y, _X, _Z based on rotation and + // hull ( or dimensions, need circular cross section) + // Should allow for minor variance along axes? - _collisionShapeType = SHAPE_TYPE_SPHERE; - } else { - _collisionShapeType = SHAPE_TYPE_ELLIPSOID; - } - } - break; - case entity::Shape::Cylinder: - { - _collisionShapeType = SHAPE_TYPE_CYLINDER_Y; - // TODO WL21389: determine if rotation is axis-aligned - //const Transform::Quat & rot = _transform.getRotation(); - - // TODO WL21389: some way to tell apart SHAPE_TYPE_CYLINDER_Y, _X, _Z based on rotation and - // hull ( or dimensions, need circular cross section) - // Should allow for minor variance along axes? - - } - break; + } + break; + // gons, ones, & angles built via GeometryCache::extrudePolygon case entity::Shape::Triangle: case entity::Shape::Hexagon: case entity::Shape::Octagon: - case entity::Shape::Circle: + case entity::Shape::Cone: { + if (shapeCalculator) { + shapeCalculator(this, info); + // shapeCalculator only supports convex shapes (e.g. SHAPE_TYPE_HULL) + // TODO: figure out how to support concave shapes + _collisionShapeType = SHAPE_TYPE_SIMPLE_HULL; + } else { + _collisionShapeType = SHAPE_TYPE_ELLIPSOID; + } + } + break; + // hedrons built via GeometryCache::setUpFlatShapes case entity::Shape::Tetrahedron: case entity::Shape::Octahedron: case entity::Shape::Dodecahedron: - case entity::Shape::Icosahedron: - case entity::Shape::Cone: - { - if (shapeCalculator) { - shapeCalculator(info, _shape, getDimensions()); - // shapeCalculator only supports convex shapes (e.g. SHAPE_TYPE_HULL) - // TODO: figure out how to support concave shapes - _collisionShapeType = SHAPE_TYPE_HULL; - } else { - _collisionShapeType = SHAPE_TYPE_ELLIPSOID; - } - } - break; - case entity::Shape::Torus: - { - // Not in GeometryCache::buildShapes, unsupported. - _collisionShapeType = SHAPE_TYPE_ELLIPSOID; - //TODO WL21389: SHAPE_TYPE_SIMPLE_HULL and pointCollection (later if desired support) - } - break; - default: - { + case entity::Shape::Icosahedron: { + if ( shapeCalculator ) { + shapeCalculator(this, info); + // shapeCalculator only supports convex shapes (e.g. SHAPE_TYPE_HULL) + // TODO: figure out how to support concave shapes + _collisionShapeType = SHAPE_TYPE_SIMPLE_HULL; + } else { _collisionShapeType = SHAPE_TYPE_ELLIPSOID; } - break; + + } + break; + case entity::Shape::Torus: { + // Not in GeometryCache::buildShapes, unsupported. + _collisionShapeType = SHAPE_TYPE_ELLIPSOID; + //TODO WL21389: SHAPE_TYPE_SIMPLE_HULL and pointCollection (later if desired support) + } + break; + default: { + _collisionShapeType = SHAPE_TYPE_ELLIPSOID; + } + break; } EntityItem::computeShapeInfo(info); } -// This value specifes how the shape should be treated by physics calculations. +// This value specifies how the shape should be treated by physics calculations. ShapeType ShapeEntityItem::getShapeType() const { return _collisionShapeType; } diff --git a/libraries/entities/src/ShapeEntityItem.h b/libraries/entities/src/ShapeEntityItem.h index 0f8197787b..a88a2098e9 100644 --- a/libraries/entities/src/ShapeEntityItem.h +++ b/libraries/entities/src/ShapeEntityItem.h @@ -42,7 +42,7 @@ public: static EntityItemPointer sphereFactory(const EntityItemID& entityID, const EntityItemProperties& properties); static EntityItemPointer boxFactory(const EntityItemID& entityID, const EntityItemProperties& properties); - using ShapeInfoCalculator = std::function; + using ShapeInfoCalculator = std::function; static void setShapeInfoCalulator(ShapeInfoCalculator callback); ShapeEntityItem(const EntityItemID& entityItemID); diff --git a/libraries/physics/src/ShapeFactory.cpp b/libraries/physics/src/ShapeFactory.cpp index 18dfd2317e..cd0fba848a 100644 --- a/libraries/physics/src/ShapeFactory.cpp +++ b/libraries/physics/src/ShapeFactory.cpp @@ -314,6 +314,7 @@ const btCollisionShape* ShapeFactory::createShapeFromInfo(const ShapeInfo& info) shape = new btCylinderShapeZ(btHalfExtents); } break; + case SHAPE_TYPE_CIRCLE: case SHAPE_TYPE_CYLINDER_Y: { const glm::vec3 halfExtents = info.getHalfExtents(); const btVector3 btHalfExtents(halfExtents.x, halfExtents.y, halfExtents.z); diff --git a/libraries/render-utils/src/GeometryCache.cpp b/libraries/render-utils/src/GeometryCache.cpp index cf8e268681..38994cfa02 100644 --- a/libraries/render-utils/src/GeometryCache.cpp +++ b/libraries/render-utils/src/GeometryCache.cpp @@ -23,6 +23,7 @@ #include #include +#include #include "TextureCache.h" #include "RenderUtilsLogging.h" @@ -52,6 +53,24 @@ //#define WANT_DEBUG +static std::array MAPPING{ { + GeometryCache::Triangle, + GeometryCache::Quad, + GeometryCache::Hexagon, + GeometryCache::Octagon, + GeometryCache::Circle, + GeometryCache::Cube, + GeometryCache::Sphere, + GeometryCache::Tetrahedron, + GeometryCache::Octahedron, + GeometryCache::Dodecahedron, + GeometryCache::Icosahedron, + GeometryCache::Torus, + GeometryCache::Cone, + GeometryCache::Cylinder, +} }; + + const int GeometryCache::UNKNOWN_ID = -1; @@ -69,6 +88,52 @@ static gpu::Stream::FormatPointer INSTANCED_SOLID_FADE_STREAM_FORMAT; static const uint SHAPE_VERTEX_STRIDE = sizeof(glm::vec3) * 2; // vertices and normals static const uint SHAPE_NORMALS_OFFSET = sizeof(glm::vec3); +void GeometryCache::computeSimpleHullPointListForShape(const ShapeEntityItem * const shapePtr, QVector &outPointList){ + + if (shapePtr == nullptr){ + //--EARLY EXIT-- + return; + } + + auto geometryCache = DependencyManager::get(); + const GeometryCache::ShapeData * shapeData = geometryCache->getShapeData(MAPPING[shapePtr->getShape()]); + if (!shapeData){ + //--EARLY EXIT--( data isn't ready for some reason... ) + return; + } + const gpu::BufferView & shapeVerts = shapeData->_positionView; + const gpu::BufferView & shapeNorms = shapeData->_normalView; + assert(shapeVerts._size == shapeNorms._size); + + const gpu::BufferView::Size numItems = shapeVerts.getNumElements(); + const glm::vec3 halfExtents = shapePtr->getDimensions() * 0.5f; +#if DEBUG_SIMPLE_HULL_POINT_GENERATION + shapePtr->debugDump(); + qCDebug(entities) << "------------------ Begin Vert Info( ComputeShapeInfo )[FlatShapes] -----------------------------"; + qCDebug(entities) << " name:" << shapePtr->getName() << ": has " << numItems << " vert info pairs."; +#endif + outPointList.reserve(numItems); + for (gpu::BufferView::Index i = 0; i < (gpu::BufferView::Index)numItems; ++i) { + const geometry::Vec &curNorm = shapeNorms.get(i); +#if DEBUG_SIMPLE_HULL_POINT_GENERATION + const geometry::Vec &curVert = shapeVerts.get(i); + qCDebug(entities) << " --------------------"; + qCDebug(entities) << " Vert( " << i << " ): " << debugTreeVector(curVert); + qCDebug(entities) << " Norm( " << i << " ): " << debugTreeVector(curNorm); +#endif + outPointList.push_back(curNorm * halfExtents); + +#if DEBUG_SIMPLE_HULL_POINT_GENERATION + qCDebug(entities) << " Point( " << i << " ): " << debugTreeVector((curNorm * halfExtents)); +#endif + } + +#if DEBUG_SIMPLE_HULL_POINT_GENERATION + qCDebug(entities) << "-------------------- End Vert Info( ComputeShapeInfo ) -----------------------------"; +#endif + +} + template std::vector polygon() { std::vector result; @@ -447,6 +512,22 @@ void GeometryCache::buildShapes() { } +const GeometryCache::ShapeData * GeometryCache::getShapeData(const Shape shape) const { + if (((int)shape < 0) || ((int)shape >= _shapes.size())){ + return nullptr; + } + + return &_shapes[shape]; +} + +GeometryCache::Shape GeometryCache::getShapeForEntityShape(int entityShape) { + if ((entityShape < 0) || (entityShape >= MAPPING.size())){ + return NUM_SHAPES; + } + + return MAPPING[entityShape]; +} + gpu::Stream::FormatPointer& getSolidStreamFormat() { if (!SOLID_STREAM_FORMAT) { SOLID_STREAM_FORMAT = std::make_shared(); // 1 for everyone diff --git a/libraries/render-utils/src/GeometryCache.h b/libraries/render-utils/src/GeometryCache.h index 5a437cf5e9..867c4bc3ee 100644 --- a/libraries/render-utils/src/GeometryCache.h +++ b/libraries/render-utils/src/GeometryCache.h @@ -32,6 +32,7 @@ #include class SimpleProgramKey; +class ShapeEntityItem; typedef QPair Vec2FloatPair; typedef QPair Vec2FloatPairPair; @@ -147,6 +148,15 @@ public: NUM_SHAPES, }; + /// @param entityShapeEnum: The entity::Shape enumeration for the shape + /// whose GeometryCache::Shape is desired. + /// @return GeometryCache::NUM_SHAPES in the event of an error; otherwise, + /// the GeometryCache::Shape enum which aligns with the + /// specified entityShapeEnum + static GeometryCache::Shape getShapeForEntityShape(int entityShapeEnum); + + static void computeSimpleHullPointListForShape(const ShapeEntityItem * const shapePtr, QVector &outPointList); + static uint8_t CUSTOM_PIPELINE_NUMBER; static render::ShapePipelinePointer shapePipelineFactory(const render::ShapePlumber& plumber, const render::ShapeKey& key); static void registerShapePipeline() { @@ -355,15 +365,21 @@ public: using VShape = std::array; - VShape _shapes; + /// returns ShapeData associated with the specified shape, + /// otherwise nullptr in the event of an error. + const ShapeData * getShapeData(Shape shape) const; private: + GeometryCache(); virtual ~GeometryCache(); void buildShapes(); typedef QPair IntPair; typedef QPair VerticesIndices; + + + VShape _shapes; gpu::PipelinePointer _standardDrawPipeline; gpu::PipelinePointer _standardDrawPipelineNoBlend; diff --git a/libraries/shared/src/ShapeInfo.cpp b/libraries/shared/src/ShapeInfo.cpp index a556548b25..c56b722b61 100644 --- a/libraries/shared/src/ShapeInfo.cpp +++ b/libraries/shared/src/ShapeInfo.cpp @@ -45,6 +45,10 @@ void ShapeInfo::setParams(ShapeType type, const glm::vec3& halfExtents, QString _halfExtents = glm::vec3(radius); } break; + case SHAPE_TYPE_CIRCLE: { + _halfExtents = glm::vec3(_halfExtents.x, MIN_HALF_EXTENT, _halfExtents.z); + } + break; case SHAPE_TYPE_COMPOUND: case SHAPE_TYPE_STATIC_MESH: _url = QUrl(url); @@ -75,9 +79,7 @@ void ShapeInfo::setSphere(float radius) { } void ShapeInfo::setPointCollection(const ShapeInfo::PointCollection& pointCollection) { - //TODO WL21389: May need to skip resetting type here. _pointCollection = pointCollection; - _type = (_pointCollection.size() > 0) ? SHAPE_TYPE_COMPOUND : SHAPE_TYPE_NONE; _doubleHashKey.clear(); } @@ -124,7 +126,7 @@ int ShapeInfo::getLargestSubshapePointCount() const { } float ShapeInfo::computeVolume() const { - //TODO WL21389: Add support for other ShapeTypes( CYLINDER_X, CYLINDER_Y, etc). + //TODO WL21389: Add support for other ShapeTypes( CYLINDER_X, CYLINDER_Z, etc). const float DEFAULT_VOLUME = 1.0f; float volume = DEFAULT_VOLUME; switch(_type) { diff --git a/libraries/shared/src/ShapeInfo.h b/libraries/shared/src/ShapeInfo.h index 0ffdf1310d..cab487e07a 100644 --- a/libraries/shared/src/ShapeInfo.h +++ b/libraries/shared/src/ShapeInfo.h @@ -46,7 +46,8 @@ enum ShapeType { SHAPE_TYPE_SIMPLE_HULL, SHAPE_TYPE_SIMPLE_COMPOUND, SHAPE_TYPE_STATIC_MESH, - SHAPE_TYPE_ELLIPSOID + SHAPE_TYPE_ELLIPSOID, + SHAPE_TYPE_CIRCLE }; class ShapeInfo { @@ -66,7 +67,7 @@ public: void setCapsuleY(float radius, float halfHeight); void setOffset(const glm::vec3& offset); - int getType() const { return _type; } + ShapeType getType() const { return _type; } const glm::vec3& getHalfExtents() const { return _halfExtents; } const glm::vec3& getOffset() const { return _offset; } diff --git a/tests/gpu-test/src/TestInstancedShapes.cpp b/tests/gpu-test/src/TestInstancedShapes.cpp index 6a98ee58b9..da50f8521f 100644 --- a/tests/gpu-test/src/TestInstancedShapes.cpp +++ b/tests/gpu-test/src/TestInstancedShapes.cpp @@ -10,18 +10,18 @@ gpu::Stream::FormatPointer& getInstancedSolidStreamFormat(); -static const size_t TYPE_COUNT = 4; -static const size_t ITEM_COUNT = 50; -static const float SHAPE_INTERVAL = (PI * 2.0f) / ITEM_COUNT; -static const float ITEM_INTERVAL = SHAPE_INTERVAL / TYPE_COUNT; - -static GeometryCache::Shape SHAPE[TYPE_COUNT] = { +static GeometryCache::Shape SHAPE[] = { GeometryCache::Icosahedron, GeometryCache::Cube, GeometryCache::Sphere, GeometryCache::Tetrahedron, }; +static const size_t TYPE_COUNT = (sizeof(SHAPE) / sizeof((SHAPE)[0])); +static const size_t ITEM_COUNT = 50; +static const float SHAPE_INTERVAL = (PI * 2.0f) / ITEM_COUNT; +static const float ITEM_INTERVAL = SHAPE_INTERVAL / TYPE_COUNT; + const gpu::Element POSITION_ELEMENT { gpu::VEC3, gpu::FLOAT, gpu::XYZ }; const gpu::Element NORMAL_ELEMENT { gpu::VEC3, gpu::FLOAT, gpu::XYZ }; const gpu::Element COLOR_ELEMENT { gpu::VEC4, gpu::NUINT8, gpu::RGBA }; @@ -34,8 +34,6 @@ TestInstancedShapes::TestInstancedShapes() { static const float ITEM_RADIUS = 20; static const vec3 ITEM_TRANSLATION { 0, 0, -ITEM_RADIUS }; for (size_t i = 0; i < TYPE_COUNT; ++i) { - GeometryCache::Shape shape = SHAPE[i]; - GeometryCache::ShapeData shapeData = geometryCache->_shapes[shape]; //indirectCommand._count float startingInterval = ITEM_INTERVAL * i; std::vector typeTransforms; @@ -62,7 +60,12 @@ void TestInstancedShapes::renderTest(size_t testId, RenderArgs* args) { batch.setInputFormat(getInstancedSolidStreamFormat()); for (size_t i = 0; i < TYPE_COUNT; ++i) { GeometryCache::Shape shape = SHAPE[i]; - GeometryCache::ShapeData shapeData = geometryCache->_shapes[shape]; + const GeometryCache::ShapeData *shapeData = geometryCache->getShapeData( shape ); + if (!shapeData) { + + //--EARLY ITERATION EXIT--( didn't have shape data yet ) + continue; + } std::string namedCall = __FUNCTION__ + std::to_string(i); @@ -71,13 +74,13 @@ void TestInstancedShapes::renderTest(size_t testId, RenderArgs* args) { batch.setModelTransform(transforms[i][j]); batch.setupNamedCalls(namedCall, [=](gpu::Batch& batch, gpu::Batch::NamedBatchData&) { batch.setInputBuffer(gpu::Stream::COLOR, gpu::BufferView(colorBuffer, i * ITEM_COUNT * 4, colorBuffer->getSize(), COLOR_ELEMENT)); - shapeData.drawInstances(batch, ITEM_COUNT); + shapeData->drawInstances(batch, ITEM_COUNT); }); } //for (size_t j = 0; j < ITEM_COUNT; ++j) { // batch.setModelTransform(transforms[j + i * ITEM_COUNT]); - // shapeData.draw(batch); + // shapeData->draw(batch); //} } } From d2350974b5e80291206f3869d04a23b9b8cd7471 Mon Sep 17 00:00:00 2001 From: LaShonda Hopper Date: Mon, 11 Sep 2017 13:16:11 -0400 Subject: [PATCH 04/26] [WL21389] Avoid vector copy within shapeInfoCalculator. Reviewed-by: Leander Hasty Changes Committed: modified: interface/src/Util.cpp --- interface/src/Util.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/src/Util.cpp b/interface/src/Util.cpp index 3e3f514117..6077c8ec42 100644 --- a/interface/src/Util.cpp +++ b/interface/src/Util.cpp @@ -398,9 +398,9 @@ void runUnitTests() { void shapeInfoCalculator(const ShapeEntityItem * const shapeEntity, ShapeInfo &shapeInfo) { ShapeInfo::PointCollection pointCollection; ShapeInfo::PointList points; - - GeometryCache::computeSimpleHullPointListForShape(shapeEntity, points); pointCollection.push_back(points); + + GeometryCache::computeSimpleHullPointListForShape(shapeEntity, pointCollection.back()); shapeInfo.setPointCollection(pointCollection); } From 070c664ff2a9d3a7c65a48709ee63e62d0db1391 Mon Sep 17 00:00:00 2001 From: LaShonda Hopper Date: Mon, 11 Sep 2017 13:27:59 -0400 Subject: [PATCH 05/26] [WL21389] Add out of bounds safeguard to computeShapeInfo helper (details below). * Switched direct map indexing to helper function which has out of bounds safeguard. * Also updated GeometryCache::getShapeForEntityShape default fallback return from GeometryCache::NUM_SHAPES to GeometryCache::Sphere inline with general preference to act as if a shape is a sphere in the event of an error. Changes Committed: modified: libraries/render-utils/src/GeometryCache.cpp --- libraries/render-utils/src/GeometryCache.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libraries/render-utils/src/GeometryCache.cpp b/libraries/render-utils/src/GeometryCache.cpp index 38994cfa02..492a492bf9 100644 --- a/libraries/render-utils/src/GeometryCache.cpp +++ b/libraries/render-utils/src/GeometryCache.cpp @@ -96,7 +96,8 @@ void GeometryCache::computeSimpleHullPointListForShape(const ShapeEntityItem * c } auto geometryCache = DependencyManager::get(); - const GeometryCache::ShapeData * shapeData = geometryCache->getShapeData(MAPPING[shapePtr->getShape()]); + const GeometryCache::Shape entityGeometryShape = GeometryCache::getShapeForEntityShape(shapePtr->getShape()); + const GeometryCache::ShapeData * shapeData = geometryCache->getShapeData( entityGeometryShape ); if (!shapeData){ //--EARLY EXIT--( data isn't ready for some reason... ) return; @@ -522,7 +523,7 @@ const GeometryCache::ShapeData * GeometryCache::getShapeData(const Shape shape) GeometryCache::Shape GeometryCache::getShapeForEntityShape(int entityShape) { if ((entityShape < 0) || (entityShape >= MAPPING.size())){ - return NUM_SHAPES; + return GeometryCache::Sphere; } return MAPPING[entityShape]; From 8a4ac9ebc4b86e6a62abf6b9ca6084bab4c97411 Mon Sep 17 00:00:00 2001 From: LaShonda Hopper Date: Mon, 11 Sep 2017 15:10:56 -0400 Subject: [PATCH 06/26] [WL21389] Resolves size_t vs int warnings in GeometryCache. Reviewed-by: Kris Pivin Changes Committed: modified: libraries/render-utils/src/GeometryCache.cpp --- libraries/render-utils/src/GeometryCache.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libraries/render-utils/src/GeometryCache.cpp b/libraries/render-utils/src/GeometryCache.cpp index 492a492bf9..004f33cd1c 100644 --- a/libraries/render-utils/src/GeometryCache.cpp +++ b/libraries/render-utils/src/GeometryCache.cpp @@ -113,7 +113,7 @@ void GeometryCache::computeSimpleHullPointListForShape(const ShapeEntityItem * c qCDebug(entities) << "------------------ Begin Vert Info( ComputeShapeInfo )[FlatShapes] -----------------------------"; qCDebug(entities) << " name:" << shapePtr->getName() << ": has " << numItems << " vert info pairs."; #endif - outPointList.reserve(numItems); + outPointList.reserve((int)numItems); for (gpu::BufferView::Index i = 0; i < (gpu::BufferView::Index)numItems; ++i) { const geometry::Vec &curNorm = shapeNorms.get(i); #if DEBUG_SIMPLE_HULL_POINT_GENERATION @@ -514,7 +514,7 @@ void GeometryCache::buildShapes() { } const GeometryCache::ShapeData * GeometryCache::getShapeData(const Shape shape) const { - if (((int)shape < 0) || ((int)shape >= _shapes.size())){ + if (((int)shape < 0) || ((int)shape >= (int)_shapes.size())){ return nullptr; } @@ -522,7 +522,7 @@ const GeometryCache::ShapeData * GeometryCache::getShapeData(const Shape shape) } GeometryCache::Shape GeometryCache::getShapeForEntityShape(int entityShape) { - if ((entityShape < 0) || (entityShape >= MAPPING.size())){ + if ((entityShape < 0) || (entityShape >= (int)MAPPING.size())){ return GeometryCache::Sphere; } From 789b850846f9f3d9f61e3c8df50ff3acf09ccffe Mon Sep 17 00:00:00 2001 From: LaShonda Hopper Date: Tue, 12 Sep 2017 12:26:15 -0400 Subject: [PATCH 07/26] [WL21389] Addresses feedback from PR #11336. * Removes todos from ShapeEntityItem::shapeCalculator stub commit. * Removes defined out debugging, as requested, from GeometryCache::computeSimpleHullPointListForShape. * Moves cone handling to its own section for better contextual flow. Changes Committed: modified: libraries/entities/src/ShapeEntityItem.cpp modified: libraries/render-utils/src/GeometryCache.cpp --- libraries/entities/src/ShapeEntityItem.cpp | 20 ++++++++++++------- libraries/render-utils/src/GeometryCache.cpp | 21 +------------------- 2 files changed, 14 insertions(+), 27 deletions(-) diff --git a/libraries/entities/src/ShapeEntityItem.cpp b/libraries/entities/src/ShapeEntityItem.cpp index 655283a601..8d68e0ab00 100644 --- a/libraries/entities/src/ShapeEntityItem.cpp +++ b/libraries/entities/src/ShapeEntityItem.cpp @@ -283,15 +283,23 @@ void ShapeEntityItem::computeShapeInfo(ShapeInfo& info) { } break; - // gons, ones, & angles built via GeometryCache::extrudePolygon - case entity::Shape::Triangle: - case entity::Shape::Hexagon: - case entity::Shape::Octagon: case entity::Shape::Cone: { if (shapeCalculator) { shapeCalculator(this, info); // shapeCalculator only supports convex shapes (e.g. SHAPE_TYPE_HULL) - // TODO: figure out how to support concave shapes + _collisionShapeType = SHAPE_TYPE_SIMPLE_HULL; + } else { + _collisionShapeType = SHAPE_TYPE_ELLIPSOID; + } + } + break; + // gons, ones, & angles built via GeometryCache::extrudePolygon + case entity::Shape::Triangle: + case entity::Shape::Hexagon: + case entity::Shape::Octagon: { + if (shapeCalculator) { + shapeCalculator(this, info); + // shapeCalculator only supports convex shapes (e.g. SHAPE_TYPE_HULL) _collisionShapeType = SHAPE_TYPE_SIMPLE_HULL; } else { _collisionShapeType = SHAPE_TYPE_ELLIPSOID; @@ -306,12 +314,10 @@ void ShapeEntityItem::computeShapeInfo(ShapeInfo& info) { if ( shapeCalculator ) { shapeCalculator(this, info); // shapeCalculator only supports convex shapes (e.g. SHAPE_TYPE_HULL) - // TODO: figure out how to support concave shapes _collisionShapeType = SHAPE_TYPE_SIMPLE_HULL; } else { _collisionShapeType = SHAPE_TYPE_ELLIPSOID; } - } break; case entity::Shape::Torus: { diff --git a/libraries/render-utils/src/GeometryCache.cpp b/libraries/render-utils/src/GeometryCache.cpp index 004f33cd1c..8164a54a57 100644 --- a/libraries/render-utils/src/GeometryCache.cpp +++ b/libraries/render-utils/src/GeometryCache.cpp @@ -108,31 +108,12 @@ void GeometryCache::computeSimpleHullPointListForShape(const ShapeEntityItem * c const gpu::BufferView::Size numItems = shapeVerts.getNumElements(); const glm::vec3 halfExtents = shapePtr->getDimensions() * 0.5f; -#if DEBUG_SIMPLE_HULL_POINT_GENERATION - shapePtr->debugDump(); - qCDebug(entities) << "------------------ Begin Vert Info( ComputeShapeInfo )[FlatShapes] -----------------------------"; - qCDebug(entities) << " name:" << shapePtr->getName() << ": has " << numItems << " vert info pairs."; -#endif + outPointList.reserve((int)numItems); for (gpu::BufferView::Index i = 0; i < (gpu::BufferView::Index)numItems; ++i) { const geometry::Vec &curNorm = shapeNorms.get(i); -#if DEBUG_SIMPLE_HULL_POINT_GENERATION - const geometry::Vec &curVert = shapeVerts.get(i); - qCDebug(entities) << " --------------------"; - qCDebug(entities) << " Vert( " << i << " ): " << debugTreeVector(curVert); - qCDebug(entities) << " Norm( " << i << " ): " << debugTreeVector(curNorm); -#endif outPointList.push_back(curNorm * halfExtents); - -#if DEBUG_SIMPLE_HULL_POINT_GENERATION - qCDebug(entities) << " Point( " << i << " ): " << debugTreeVector((curNorm * halfExtents)); -#endif } - -#if DEBUG_SIMPLE_HULL_POINT_GENERATION - qCDebug(entities) << "-------------------- End Vert Info( ComputeShapeInfo ) -----------------------------"; -#endif - } template From 7f9ce5a4cd3749482a9e7446aa0a3a064620b51d Mon Sep 17 00:00:00 2001 From: LaShonda Hopper Date: Mon, 2 Oct 2017 17:47:51 -0400 Subject: [PATCH 08/26] [WL21389][BuildFix] Minor refactor due to render-utils lib change (details below). As of Commit b93e91b9, render-utils no longer knows about entity lib. This commit adjusts for that by altering the signature of GeometryCache::computeSimpleHullPointListForShape to take in portions of ShapeEntityItem data as opposed to the entity pointer. Fixes build failure mentioned in: https://github.com/highfidelity/hifi/pull/11336#issuecomment-333635794 Reviewed-by: Leander Hasty Changes Committed: modified: interface/src/Util.cpp modified: libraries/render-utils/src/GeometryCache.cpp modified: libraries/render-utils/src/GeometryCache.h --- interface/src/Util.cpp | 9 +++++- libraries/render-utils/src/GeometryCache.cpp | 34 +++++++++++--------- libraries/render-utils/src/GeometryCache.h | 3 +- 3 files changed, 28 insertions(+), 18 deletions(-) diff --git a/interface/src/Util.cpp b/interface/src/Util.cpp index 6077c8ec42..9fdd5e4b76 100644 --- a/interface/src/Util.cpp +++ b/interface/src/Util.cpp @@ -396,11 +396,18 @@ void runUnitTests() { } void shapeInfoCalculator(const ShapeEntityItem * const shapeEntity, ShapeInfo &shapeInfo) { + + if (shapeEntity == nullptr) { + + //--EARLY EXIT-- + return; + } + ShapeInfo::PointCollection pointCollection; ShapeInfo::PointList points; pointCollection.push_back(points); - GeometryCache::computeSimpleHullPointListForShape(shapeEntity, pointCollection.back()); + GeometryCache::computeSimpleHullPointListForShape((int)shapeEntity->getShape(), shapeEntity->getDimensions() * 0.5f, pointCollection.back()); shapeInfo.setPointCollection(pointCollection); } diff --git a/libraries/render-utils/src/GeometryCache.cpp b/libraries/render-utils/src/GeometryCache.cpp index 8164a54a57..6a624e2cd8 100644 --- a/libraries/render-utils/src/GeometryCache.cpp +++ b/libraries/render-utils/src/GeometryCache.cpp @@ -23,7 +23,6 @@ #include #include -#include #include "TextureCache.h" #include "RenderUtilsLogging.h" @@ -53,7 +52,12 @@ //#define WANT_DEBUG -static std::array MAPPING{ { +// @note: Originally size entity::NUM_SHAPES +// As of Commit b93e91b9, render-utils no longer retains knowledge of +// entity lib, and thus doesn't know about entity::NUM_SHAPES. Should +// the enumerations be altered, this will need to be updated. +// @see ShapeEntityItem.h +static std::array MAPPING{ { GeometryCache::Triangle, GeometryCache::Quad, GeometryCache::Hexagon, @@ -88,16 +92,11 @@ static gpu::Stream::FormatPointer INSTANCED_SOLID_FADE_STREAM_FORMAT; static const uint SHAPE_VERTEX_STRIDE = sizeof(glm::vec3) * 2; // vertices and normals static const uint SHAPE_NORMALS_OFFSET = sizeof(glm::vec3); -void GeometryCache::computeSimpleHullPointListForShape(const ShapeEntityItem * const shapePtr, QVector &outPointList){ - - if (shapePtr == nullptr){ - //--EARLY EXIT-- - return; - } +void GeometryCache::computeSimpleHullPointListForShape(const int entityShape, const glm::vec3 &entityHalfExtents, QVector &outPointList) { auto geometryCache = DependencyManager::get(); - const GeometryCache::Shape entityGeometryShape = GeometryCache::getShapeForEntityShape(shapePtr->getShape()); - const GeometryCache::ShapeData * shapeData = geometryCache->getShapeData( entityGeometryShape ); + const GeometryCache::Shape geometryShape = GeometryCache::getShapeForEntityShape( entityShape ); + const GeometryCache::ShapeData * shapeData = geometryCache->getShapeData( geometryShape ); if (!shapeData){ //--EARLY EXIT--( data isn't ready for some reason... ) return; @@ -107,12 +106,11 @@ void GeometryCache::computeSimpleHullPointListForShape(const ShapeEntityItem * c assert(shapeVerts._size == shapeNorms._size); const gpu::BufferView::Size numItems = shapeVerts.getNumElements(); - const glm::vec3 halfExtents = shapePtr->getDimensions() * 0.5f; outPointList.reserve((int)numItems); for (gpu::BufferView::Index i = 0; i < (gpu::BufferView::Index)numItems; ++i) { const geometry::Vec &curNorm = shapeNorms.get(i); - outPointList.push_back(curNorm * halfExtents); + outPointList.push_back(curNorm * entityHalfExtents); } } @@ -488,14 +486,17 @@ void GeometryCache::buildShapes() { extrudePolygon<64>(_shapes[Cone], _shapeVertices, _shapeIndices, true); //Circle drawCircle(_shapes[Circle], _shapeVertices, _shapeIndices); - // Not implememented yet: + // Not implemented yet: //Quad, //Torus, } const GeometryCache::ShapeData * GeometryCache::getShapeData(const Shape shape) const { - if (((int)shape < 0) || ((int)shape >= (int)_shapes.size())){ + if (((int)shape < 0) || ((int)shape >= (int)_shapes.size())) { + qCWarning(renderutils) << "GeometryCache::getShapeData - Invalid shape " << shape << " specified. Returning default fallback."; + + //--EARLY EXIT--( No valid shape data for shape ) return nullptr; } @@ -503,7 +504,10 @@ const GeometryCache::ShapeData * GeometryCache::getShapeData(const Shape shape) } GeometryCache::Shape GeometryCache::getShapeForEntityShape(int entityShape) { - if ((entityShape < 0) || (entityShape >= (int)MAPPING.size())){ + if ((entityShape < 0) || (entityShape >= (int)MAPPING.size())) { + qCWarning(renderutils) << "GeometryCache::getShapeForEntityShape - Invalid shape " << entityShape << " specified. Returning default fallback."; + + //--EARLY EXIT--( fall back to default assumption ) return GeometryCache::Sphere; } diff --git a/libraries/render-utils/src/GeometryCache.h b/libraries/render-utils/src/GeometryCache.h index 867c4bc3ee..2e81c825be 100644 --- a/libraries/render-utils/src/GeometryCache.h +++ b/libraries/render-utils/src/GeometryCache.h @@ -32,7 +32,6 @@ #include class SimpleProgramKey; -class ShapeEntityItem; typedef QPair Vec2FloatPair; typedef QPair Vec2FloatPairPair; @@ -155,7 +154,7 @@ public: /// specified entityShapeEnum static GeometryCache::Shape getShapeForEntityShape(int entityShapeEnum); - static void computeSimpleHullPointListForShape(const ShapeEntityItem * const shapePtr, QVector &outPointList); + static void computeSimpleHullPointListForShape(int entityShape, const glm::vec3 &entityHalfExtents, QVector &outPointList); static uint8_t CUSTOM_PIPELINE_NUMBER; static render::ShapePipelinePointer shapePipelineFactory(const render::ShapePlumber& plumber, const render::ShapeKey& key); From dbd1a800467ccdf171ecba39144a120856114c04 Mon Sep 17 00:00:00 2001 From: LaShonda Hopper Date: Mon, 9 Oct 2017 17:49:13 -0400 Subject: [PATCH 09/26] [WL21389] Set Simulation::DIRTY_SHAPE flag when entity::Shape changes (details below). * Fixes an issue where ShapeEntityItem's collisionShapeType wasn't updated when its entity::Shape type was changed. * Adds getNameForShapeType static method to ShapeInfo. ** Moves shapeTypeNames[] from EntityItemProperties.cpp to ShapeInfo.cpp * Adds collisionShapeType to ShapeEntityItem::debugDump * Tested creating shapes within the Creation Menu: ** Create Menu -> (Box/Sphere) *** Observe Properties tab auto-focus ** From Properties tab elect alternate shape type from the Shape Dropdown list. NOTE: While this fixes an issue with the collision shape, it doesn't completely resolve the issues seen with the polyhedra or polygonal shapes noticed on RELEASE-7130 rebase. Reviewed-by: Leander Hasty Changes Committed: modified: libraries/entities/src/EntityItemProperties.cpp modified: libraries/entities/src/ShapeEntityItem.cpp modified: libraries/shared/src/ShapeInfo.cpp modified: libraries/shared/src/ShapeInfo.h --- .../entities/src/EntityItemProperties.cpp | 23 ++------------- libraries/entities/src/ShapeEntityItem.cpp | 7 +++++ libraries/shared/src/ShapeInfo.cpp | 29 +++++++++++++++++++ libraries/shared/src/ShapeInfo.h | 2 ++ 4 files changed, 40 insertions(+), 21 deletions(-) diff --git a/libraries/entities/src/EntityItemProperties.cpp b/libraries/entities/src/EntityItemProperties.cpp index 51ed66bb23..3bbd6ce8e6 100644 --- a/libraries/entities/src/EntityItemProperties.cpp +++ b/libraries/entities/src/EntityItemProperties.cpp @@ -84,28 +84,11 @@ void EntityItemProperties::setLastEdited(quint64 usecTime) { _lastEdited = usecTime > _created ? usecTime : _created; } -const char* shapeTypeNames[] = { - "none", - "box", - "sphere", - "capsule-x", - "capsule-y", - "capsule-z", - "cylinder-x", - "cylinder-y", - "cylinder-z", - "hull", - "plane", - "compound", - "simple-hull", - "simple-compound", - "static-mesh" -}; QHash stringToShapeTypeLookup; void addShapeType(ShapeType type) { - stringToShapeTypeLookup[shapeTypeNames[type]] = type; + stringToShapeTypeLookup[ShapeInfo::getNameForShapeType(type)] = type; } void buildStringToShapeTypeLookup() { @@ -180,9 +163,7 @@ void EntityItemProperties::setCollisionMaskFromString(const QString& maskString) } QString EntityItemProperties::getShapeTypeAsString() const { - if (_shapeType < sizeof(shapeTypeNames) / sizeof(char *)) - return QString(shapeTypeNames[_shapeType]); - return QString(shapeTypeNames[SHAPE_TYPE_NONE]); + return ShapeInfo::getNameForShapeType(_shapeType); } void EntityItemProperties::setShapeTypeFromString(const QString& shapeName) { diff --git a/libraries/entities/src/ShapeEntityItem.cpp b/libraries/entities/src/ShapeEntityItem.cpp index 8d68e0ab00..9a1a500a54 100644 --- a/libraries/entities/src/ShapeEntityItem.cpp +++ b/libraries/entities/src/ShapeEntityItem.cpp @@ -95,6 +95,7 @@ EntityItemProperties ShapeEntityItem::getProperties(EntityPropertyFlags desiredP } void ShapeEntityItem::setShape(const entity::Shape& shape) { + const entity::Shape prevShape = _shape; _shape = shape; switch (_shape) { case entity::Shape::Cube: @@ -107,6 +108,11 @@ void ShapeEntityItem::setShape(const entity::Shape& shape) { _type = EntityTypes::Shape; break; } + + if (_shape != prevShape) { + // Internally grabs writeLock + markDirtyFlags(Simulation::DIRTY_SHAPE); + } } bool ShapeEntityItem::setProperties(const EntityItemProperties& properties) { @@ -227,6 +233,7 @@ void ShapeEntityItem::debugDump() const { qCDebug(entities) << "SHAPE EntityItem id:" << getEntityItemID() << "---------------------------------------------"; qCDebug(entities) << " name:" << _name; qCDebug(entities) << " shape:" << stringFromShape(_shape) << " (EnumId: " << _shape << " )"; + qCDebug(entities) << " collisionShapeType:" << ShapeInfo::getNameForShapeType(getShapeType()); qCDebug(entities) << " color:" << _color[0] << "," << _color[1] << "," << _color[2]; qCDebug(entities) << " position:" << debugTreeVector(getPosition()); qCDebug(entities) << " dimensions:" << debugTreeVector(getDimensions()); diff --git a/libraries/shared/src/ShapeInfo.cpp b/libraries/shared/src/ShapeInfo.cpp index c56b722b61..592f692f5a 100644 --- a/libraries/shared/src/ShapeInfo.cpp +++ b/libraries/shared/src/ShapeInfo.cpp @@ -15,9 +15,38 @@ #include "NumericalConstants.h" // for MILLIMETERS_PER_METER +// Originally within EntityItemProperties.cpp +const char* shapeTypeNames[] = { + "none", + "box", + "sphere", + "capsule-x", + "capsule-y", + "capsule-z", + "cylinder-x", + "cylinder-y", + "cylinder-z", + "hull", + "plane", + "compound", + "simple-hull", + "simple-compound", + "static-mesh" +}; + +static const size_t SHAPETYPE_NAME_COUNT = (sizeof(shapeTypeNames) / sizeof((shapeTypeNames)[0])); + // Bullet doesn't support arbitrarily small shapes const float MIN_HALF_EXTENT = 0.005f; // 0.5 cm +QString ShapeInfo::getNameForShapeType(ShapeType type) { + if (((int)type <= 0) || ((int)type >= SHAPETYPE_NAME_COUNT)) { + type = (ShapeType)0; + } + + return shapeTypeNames[(int)type]; +} + void ShapeInfo::clear() { _url.clear(); _pointCollection.clear(); diff --git a/libraries/shared/src/ShapeInfo.h b/libraries/shared/src/ShapeInfo.h index cab487e07a..d658b936a3 100644 --- a/libraries/shared/src/ShapeInfo.h +++ b/libraries/shared/src/ShapeInfo.h @@ -58,6 +58,8 @@ public: using PointCollection = QVector; using TriangleIndices = QVector; + static QString getNameForShapeType(ShapeType type); + void clear(); void setParams(ShapeType type, const glm::vec3& halfExtents, QString url=""); From a9fea4c7d326b770cb639cc979497c575deb5d72 Mon Sep 17 00:00:00 2001 From: LaShonda Hopper Date: Tue, 10 Oct 2017 15:36:45 -0400 Subject: [PATCH 10/26] [WL21389] Minor fix to RenderableShapeEntityItem::doRender (details below). Shape isn't guaranteed to be permanent and thus the triangle count isn't guaranteed to be the same since inception, so grab it each time. Changes to be committed: modified: libraries/entities-renderer/src/RenderableShapeEntityItem.cpp --- libraries/entities-renderer/src/RenderableShapeEntityItem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/entities-renderer/src/RenderableShapeEntityItem.cpp b/libraries/entities-renderer/src/RenderableShapeEntityItem.cpp index a72320fda0..332d87f930 100644 --- a/libraries/entities-renderer/src/RenderableShapeEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableShapeEntityItem.cpp @@ -154,6 +154,6 @@ void ShapeEntityRenderer::doRender(RenderArgs* args) { } } - static const auto triCount = geometryCache->getShapeTriangleCount(geometryShape); + const auto triCount = geometryCache->getShapeTriangleCount(geometryShape); args->_details._trianglesRendered += (int)triCount; } From 8cc20e6b7155f682a2fcc4961cb3c0d65687cc6a Mon Sep 17 00:00:00 2001 From: LaShonda Hopper Date: Tue, 10 Oct 2017 15:39:49 -0400 Subject: [PATCH 11/26] Minor: Fixes comment typo. Changes to be committed: modified: libraries/physics/src/ObjectMotionState.h --- libraries/physics/src/ObjectMotionState.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/physics/src/ObjectMotionState.h b/libraries/physics/src/ObjectMotionState.h index 81bfbc72b4..0b91ede574 100644 --- a/libraries/physics/src/ObjectMotionState.h +++ b/libraries/physics/src/ObjectMotionState.h @@ -66,7 +66,7 @@ class PhysicsEngine; class ObjectMotionState : public btMotionState { public: - // These poroperties of the PhysicsEngine are "global" within the context of all ObjectMotionStates + // These properties of the PhysicsEngine are "global" within the context of all ObjectMotionStates // (assuming just one PhysicsEngine). They are cached as statics for fast calculations in the // ObjectMotionState context. static void setWorldOffset(const glm::vec3& offset); From 9d64a3b9916eab5f008a7f6964f59529ad91a36e Mon Sep 17 00:00:00 2001 From: LaShonda Hopper Date: Wed, 11 Oct 2017 13:13:07 -0400 Subject: [PATCH 12/26] [WL21389] Fixes warnings from last commit (details below). * Fixes int vs size_t comparison warning within ShapeInfo. * Fixes unused var warning for shapeVerts local var within GeometryCache. This should fix the mac & ubuntu builds. Changes Committed: modified: libraries/render-utils/src/GeometryCache.cpp modified: libraries/shared/src/ShapeInfo.cpp --- libraries/render-utils/src/GeometryCache.cpp | 5 +++-- libraries/shared/src/ShapeInfo.cpp | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/libraries/render-utils/src/GeometryCache.cpp b/libraries/render-utils/src/GeometryCache.cpp index 6a624e2cd8..5cced0fcaa 100644 --- a/libraries/render-utils/src/GeometryCache.cpp +++ b/libraries/render-utils/src/GeometryCache.cpp @@ -101,13 +101,14 @@ void GeometryCache::computeSimpleHullPointListForShape(const int entityShape, co //--EARLY EXIT--( data isn't ready for some reason... ) return; } - const gpu::BufferView & shapeVerts = shapeData->_positionView; + const gpu::BufferView & shapeNorms = shapeData->_normalView; - assert(shapeVerts._size == shapeNorms._size); + assert(shapeData->_positionView._size == shapeNorms._size); const gpu::BufferView::Size numItems = shapeVerts.getNumElements(); outPointList.reserve((int)numItems); + for (gpu::BufferView::Index i = 0; i < (gpu::BufferView::Index)numItems; ++i) { const geometry::Vec &curNorm = shapeNorms.get(i); outPointList.push_back(curNorm * entityHalfExtents); diff --git a/libraries/shared/src/ShapeInfo.cpp b/libraries/shared/src/ShapeInfo.cpp index 592f692f5a..d93b70e98c 100644 --- a/libraries/shared/src/ShapeInfo.cpp +++ b/libraries/shared/src/ShapeInfo.cpp @@ -40,7 +40,7 @@ static const size_t SHAPETYPE_NAME_COUNT = (sizeof(shapeTypeNames) / sizeof((sha const float MIN_HALF_EXTENT = 0.005f; // 0.5 cm QString ShapeInfo::getNameForShapeType(ShapeType type) { - if (((int)type <= 0) || ((int)type >= SHAPETYPE_NAME_COUNT)) { + if (((int)type <= 0) || ((int)type >= (int)SHAPETYPE_NAME_COUNT)) { type = (ShapeType)0; } From e74ebd53c62f725837f8a74c83bb4c00a84ad71e Mon Sep 17 00:00:00 2001 From: LaShonda Hopper Date: Wed, 11 Oct 2017 17:11:15 -0400 Subject: [PATCH 13/26] [WL21389] Add SHAPE_TYPE_SIMPLE_HULL case to ShapeInfo::getHash (details below). Generates hashes for Simple Hull instances by incorporating their point list into the hash as opposed to the extents. Reviewed-by: Leander Hasty Changes Committed: modified: libraries/shared/src/ShapeInfo.cpp --- libraries/shared/src/ShapeInfo.cpp | 92 +++++++++++++++++++++--------- 1 file changed, 66 insertions(+), 26 deletions(-) diff --git a/libraries/shared/src/ShapeInfo.cpp b/libraries/shared/src/ShapeInfo.cpp index d93b70e98c..9397f834f9 100644 --- a/libraries/shared/src/ShapeInfo.cpp +++ b/libraries/shared/src/ShapeInfo.cpp @@ -234,7 +234,6 @@ bool ShapeInfo::contains(const glm::vec3& point) const { } const DoubleHashKey& ShapeInfo::getHash() const { - //TODO WL21389: Need to include the pointlist for SIMPLE_HULL in hash // NOTE: we cache the key so we only ever need to compute it once for any valid ShapeInfo instance. if (_doubleHashKey.isNull() && _type != SHAPE_TYPE_NONE) { bool useOffset = glm::length2(_offset) > MIN_SHAPE_OFFSET * MIN_SHAPE_OFFSET; @@ -245,41 +244,82 @@ const DoubleHashKey& ShapeInfo::getHash() const { uint32_t primeIndex = 0; _doubleHashKey.computeHash((uint32_t)_type, primeIndex++); - // compute hash1 - uint32_t hash = _doubleHashKey.getHash(); - for (int j = 0; j < 3; ++j) { - // NOTE: 0.49f is used to bump the float up almost half a millimeter - // so the cast to int produces a round() effect rather than a floor() - hash ^= DoubleHashKey::hashFunction( + if (_type != SHAPE_TYPE_SIMPLE_HULL) { + // compute hash1 + uint32_t hash = _doubleHashKey.getHash(); + for (int j = 0; j < 3; ++j) { + // NOTE: 0.49f is used to bump the float up almost half a millimeter + // so the cast to int produces a round() effect rather than a floor() + hash ^= DoubleHashKey::hashFunction( (uint32_t)(_halfExtents[j] * MILLIMETERS_PER_METER + copysignf(1.0f, _halfExtents[j]) * 0.49f), primeIndex++); - if (useOffset) { - hash ^= DoubleHashKey::hashFunction( + if (useOffset) { + hash ^= DoubleHashKey::hashFunction( (uint32_t)(_offset[j] * MILLIMETERS_PER_METER + copysignf(1.0f, _offset[j]) * 0.49f), primeIndex++); + } } - } - _doubleHashKey.setHash(hash); + _doubleHashKey.setHash(hash); - // compute hash2 - hash = _doubleHashKey.getHash2(); - for (int j = 0; j < 3; ++j) { - // NOTE: 0.49f is used to bump the float up almost half a millimeter - // so the cast to int produces a round() effect rather than a floor() - uint32_t floatHash = DoubleHashKey::hashFunction2( + // compute hash2 + hash = _doubleHashKey.getHash2(); + for (int j = 0; j < 3; ++j) { + // NOTE: 0.49f is used to bump the float up almost half a millimeter + // so the cast to int produces a round() effect rather than a floor() + uint32_t floatHash = DoubleHashKey::hashFunction2( (uint32_t)(_halfExtents[j] * MILLIMETERS_PER_METER + copysignf(1.0f, _halfExtents[j]) * 0.49f)); - if (useOffset) { - floatHash ^= DoubleHashKey::hashFunction2( + if (useOffset) { + floatHash ^= DoubleHashKey::hashFunction2( (uint32_t)(_offset[j] * MILLIMETERS_PER_METER + copysignf(1.0f, _offset[j]) * 0.49f)); + } + hash += ~(floatHash << 17); + hash ^= (floatHash >> 11); + hash += (floatHash << 4); + hash ^= (floatHash >> 7); + hash += ~(floatHash << 10); + hash = (hash << 16) | (hash >> 16); } - hash += ~(floatHash << 17); - hash ^= (floatHash >> 11); - hash += (floatHash << 4); - hash ^= (floatHash >> 7); - hash += ~(floatHash << 10); - hash = (hash << 16) | (hash >> 16); + _doubleHashKey.setHash2(hash); + } else { + + assert(_pointCollection.size() == (size_t)1); + const PointList & points = _pointCollection.back(); + const size_t numPoints = points.size(); + uint32_t hash = _doubleHashKey.getHash(); + uint32_t hash2 = _doubleHashKey.getHash2(); + + for (int pointIndex = 0; pointIndex < numPoints; ++pointIndex) { + // compute hash1 & 2 + const glm::vec3 &curPoint = points[pointIndex]; + for (int vecCompIndex = 0; vecCompIndex < 3; ++vecCompIndex) { + + // NOTE: 0.49f is used to bump the float up almost half a millimeter + // so the cast to int produces a round() effect rather than a floor() + uint32_t valueToHash = (uint32_t)(curPoint[vecCompIndex] * MILLIMETERS_PER_METER + copysignf(1.0f, curPoint[vecCompIndex]) * 0.49f); + + hash ^= DoubleHashKey::hashFunction(valueToHash, primeIndex++); + uint32_t floatHash = DoubleHashKey::hashFunction2(valueToHash); + + if (useOffset) { + + const uint32_t offsetValToHash = (uint32_t)(_offset[vecCompIndex] * MILLIMETERS_PER_METER + copysignf(1.0f, _offset[vecCompIndex])* 0.49f); + + hash ^= DoubleHashKey::hashFunction(offsetValToHash, primeIndex++); + floatHash ^= DoubleHashKey::hashFunction2(offsetValToHash); + } + + hash2 += ~(floatHash << 17); + hash2 ^= (floatHash >> 11); + hash2 += (floatHash << 4); + hash2 ^= (floatHash >> 7); + hash2 += ~(floatHash << 10); + hash2 = (hash2 << 16) | (hash2 >> 16); + } + } + + _doubleHashKey.setHash(hash); + _doubleHashKey.setHash2(hash2); } - _doubleHashKey.setHash2(hash); if (_type == SHAPE_TYPE_COMPOUND || _type == SHAPE_TYPE_STATIC_MESH) { QString url = _url.toString(); From 0ad95806e3868cb21616b2deb481b79f19702320 Mon Sep 17 00:00:00 2001 From: LaShonda Hopper Date: Thu, 12 Oct 2017 16:51:03 -0400 Subject: [PATCH 14/26] [WL21389] Update point list function in line with GeometryCache::ShapeData update. Changes Committed: modified: libraries/render-utils/src/GeometryCache.cpp --- libraries/render-utils/src/GeometryCache.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/render-utils/src/GeometryCache.cpp b/libraries/render-utils/src/GeometryCache.cpp index 5cced0fcaa..1cbb33252a 100644 --- a/libraries/render-utils/src/GeometryCache.cpp +++ b/libraries/render-utils/src/GeometryCache.cpp @@ -105,7 +105,7 @@ void GeometryCache::computeSimpleHullPointListForShape(const int entityShape, co const gpu::BufferView & shapeNorms = shapeData->_normalView; assert(shapeData->_positionView._size == shapeNorms._size); - const gpu::BufferView::Size numItems = shapeVerts.getNumElements(); + const gpu::BufferView::Size numItems = shapeNorms.getNumElements(); outPointList.reserve((int)numItems); From 5c8e73bb54023a0930967df5e1b183517e5dd39b Mon Sep 17 00:00:00 2001 From: LaShonda Hopper Date: Thu, 12 Oct 2017 16:57:07 -0400 Subject: [PATCH 15/26] [WL21389] Minor: Fix size_t vs int comparison warning. Changes Committed: modified: libraries/shared/src/ShapeInfo.cpp --- libraries/shared/src/ShapeInfo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/shared/src/ShapeInfo.cpp b/libraries/shared/src/ShapeInfo.cpp index 9397f834f9..d9931abbd5 100644 --- a/libraries/shared/src/ShapeInfo.cpp +++ b/libraries/shared/src/ShapeInfo.cpp @@ -284,7 +284,7 @@ const DoubleHashKey& ShapeInfo::getHash() const { assert(_pointCollection.size() == (size_t)1); const PointList & points = _pointCollection.back(); - const size_t numPoints = points.size(); + const int numPoints = (int)points.size(); uint32_t hash = _doubleHashKey.getHash(); uint32_t hash2 = _doubleHashKey.getHash2(); From d3e4d22ce1aad0841e6374b1292a09745f62cfaf Mon Sep 17 00:00:00 2001 From: LaShonda Hopper Date: Fri, 13 Oct 2017 14:34:24 -0400 Subject: [PATCH 16/26] [WL21389] Resolve ShapeInfo todos (details below). * Added remaining cylinder/capsule shapes to computeVolume * Point lists are generated during computeShapeInfo, so shouldn't need to be cleared within setParams. ** setSphere/setBox appear to be clear as they're used in tests or in local scopes without using point data. Reviewed-by: Leander Hasty Changes Committed: modified: libraries/shared/src/ShapeInfo.cpp --- libraries/shared/src/ShapeInfo.cpp | 52 +++++++++++++++++++++--------- 1 file changed, 37 insertions(+), 15 deletions(-) diff --git a/libraries/shared/src/ShapeInfo.cpp b/libraries/shared/src/ShapeInfo.cpp index d9931abbd5..59ce859790 100644 --- a/libraries/shared/src/ShapeInfo.cpp +++ b/libraries/shared/src/ShapeInfo.cpp @@ -58,7 +58,6 @@ void ShapeInfo::clear() { } void ShapeInfo::setParams(ShapeType type, const glm::vec3& halfExtents, QString url) { - //TODO WL21389: Does this need additional cases and handling added? _url = ""; _type = type; setHalfExtents(halfExtents); @@ -67,6 +66,8 @@ void ShapeInfo::setParams(ShapeType type, const glm::vec3& halfExtents, QString _halfExtents = glm::vec3(0.0f); break; case SHAPE_TYPE_BOX: + case SHAPE_TYPE_HULL: + case SHAPE_TYPE_SIMPLE_HULL: break; case SHAPE_TYPE_SPHERE: { float radius = glm::length(halfExtents) / SQUARE_ROOT_OF_3; @@ -89,9 +90,6 @@ void ShapeInfo::setParams(ShapeType type, const glm::vec3& halfExtents, QString } void ShapeInfo::setBox(const glm::vec3& halfExtents) { - //TODO WL21389: Should this pointlist clearance added in case - // this is a re-purposed instance? - // See https://github.com/highfidelity/hifi/pull/11024#discussion_r128885491 _url = ""; _type = SHAPE_TYPE_BOX; setHalfExtents(halfExtents); @@ -99,7 +97,6 @@ void ShapeInfo::setBox(const glm::vec3& halfExtents) { } void ShapeInfo::setSphere(float radius) { - //TODO WL21389: See comment in setBox regarding clearance _url = ""; _type = SHAPE_TYPE_SPHERE; radius = glm::max(radius, MIN_HALF_EXTENT); @@ -113,7 +110,6 @@ void ShapeInfo::setPointCollection(const ShapeInfo::PointCollection& pointCollec } void ShapeInfo::setCapsuleY(float radius, float halfHeight) { - //TODO WL21389: See comment in setBox regarding clearance _url = ""; _type = SHAPE_TYPE_CAPSULE_Y; radius = glm::max(radius, MIN_HALF_EXTENT); @@ -154,8 +150,15 @@ int ShapeInfo::getLargestSubshapePointCount() const { return numPoints; } +float computeCylinderVolume(const float radius, const float height) { + return PI * radius * radius * 2.0f * height; +} + +float computeCapsuleVolume(const float radius, const float cylinderHeight) { + return PI * radius * radius * (cylinderHeight + 4.0f * radius / 3.0f); +} + float ShapeInfo::computeVolume() const { - //TODO WL21389: Add support for other ShapeTypes( CYLINDER_X, CYLINDER_Z, etc). const float DEFAULT_VOLUME = 1.0f; float volume = DEFAULT_VOLUME; switch(_type) { @@ -168,17 +171,37 @@ float ShapeInfo::computeVolume() const { volume = 4.0f * PI * _halfExtents.x * _halfExtents.y * _halfExtents.z / 3.0f; break; } + case SHAPE_TYPE_CYLINDER_X: { + volume = computeCylinderVolume(_halfExtents.y, _halfExtents.x); + break; + } case SHAPE_TYPE_CYLINDER_Y: { - float radius = _halfExtents.x; - volume = PI * radius * radius * 2.0f * _halfExtents.y; + volume = computeCylinderVolume(_halfExtents.x, _halfExtents.y); + break; + } + case SHAPE_TYPE_CYLINDER_Z: { + volume = computeCylinderVolume(_halfExtents.x, _halfExtents.z); + break; + } + case SHAPE_TYPE_CAPSULE_X: { + // Need to offset halfExtents.x by y to account for the system treating + // the x extent of the capsule as the cylindrical height + spherical radius. + const float cylinderHeight = 2.0f * (_halfExtents.x - _halfExtents.y); + volume = computeCapsuleVolume(_halfExtents.y, cylinderHeight); break; } case SHAPE_TYPE_CAPSULE_Y: { - float radius = _halfExtents.x; // Need to offset halfExtents.y by x to account for the system treating // the y extent of the capsule as the cylindrical height + spherical radius. - float cylinderHeight = 2.0f * (_halfExtents.y - _halfExtents.x); - volume = PI * radius * radius * (cylinderHeight + 4.0f * radius / 3.0f); + const float cylinderHeight = 2.0f * (_halfExtents.y - _halfExtents.x); + volume = computeCapsuleVolume(_halfExtents.x, cylinderHeight); + break; + } + case SHAPE_TYPE_CAPSULE_Z: { + // Need to offset halfExtents.z by x to account for the system treating + // the z extent of the capsule as the cylindrical height + spherical radius. + const float cylinderHeight = 2.0f * (_halfExtents.z - _halfExtents.x); + volume = computeCapsuleVolume(_halfExtents.x, cylinderHeight); break; } default: @@ -189,7 +212,6 @@ float ShapeInfo::computeVolume() const { } bool ShapeInfo::contains(const glm::vec3& point) const { - //TODO WL21389: Add support for other ShapeTypes like Ellipsoid/Compound. switch(_type) { case SHAPE_TYPE_SPHERE: return glm::length(point) <= _halfExtents.x; @@ -296,7 +318,7 @@ const DoubleHashKey& ShapeInfo::getHash() const { // NOTE: 0.49f is used to bump the float up almost half a millimeter // so the cast to int produces a round() effect rather than a floor() uint32_t valueToHash = (uint32_t)(curPoint[vecCompIndex] * MILLIMETERS_PER_METER + copysignf(1.0f, curPoint[vecCompIndex]) * 0.49f); - + hash ^= DoubleHashKey::hashFunction(valueToHash, primeIndex++); uint32_t floatHash = DoubleHashKey::hashFunction2(valueToHash); @@ -307,7 +329,7 @@ const DoubleHashKey& ShapeInfo::getHash() const { hash ^= DoubleHashKey::hashFunction(offsetValToHash, primeIndex++); floatHash ^= DoubleHashKey::hashFunction2(offsetValToHash); } - + hash2 += ~(floatHash << 17); hash2 ^= (floatHash >> 11); hash2 += (floatHash << 4); From 070660eb04328813168c938ed410e51a5de759b2 Mon Sep 17 00:00:00 2001 From: LaShonda Hopper Date: Tue, 17 Oct 2017 18:18:10 -0400 Subject: [PATCH 17/26] [WL21389] Switch to _positionView & filter dupe verts for ShapeInfo (details below). * Adjusts GeometryCache::computeSimpleHullPointListForShape to utilize ShapeData::_positionView as opposed to _normalView. ** Also filters out duplicate points or points close enough to be considered duplicate vertices. This provides ShapeFactory with better point data and should reduce hits to the dedupe pass within createConvexHull. Tested: * Octagon & Tetrahedron ** They looked better than the prior commit, behaved closer to their shape as opposed to cone or narrow cylinder like. Note: * These changes are based on debug info observations using the Octagon and discussion with Andrew Meadows via Slack & https://github.com/highfidelity/hifi/pull/11336#pullrequestreview-69939120 Changes Committed: modified: libraries/render-utils/src/GeometryCache.cpp modified: libraries/render-utils/src/GeometryCache.h --- libraries/render-utils/src/GeometryCache.cpp | 63 ++++++++++++++++++-- libraries/render-utils/src/GeometryCache.h | 1 + 2 files changed, 58 insertions(+), 6 deletions(-) diff --git a/libraries/render-utils/src/GeometryCache.cpp b/libraries/render-utils/src/GeometryCache.cpp index 1cbb33252a..f83e8ae14f 100644 --- a/libraries/render-utils/src/GeometryCache.cpp +++ b/libraries/render-utils/src/GeometryCache.cpp @@ -74,6 +74,23 @@ static std::array MAPPING GeometryCache::Cylinder, } }; +static const std::array GEOCACHE_SHAPE_STRINGS{ { + "Line", + "Triangle", + "Quad", + "Hexagon", + "Octagon", + "Circle", + "Cube", + "Sphere", + "Tetrahedron", + "Octahedron", + "Dodecahedron", + "Icosahedron", + "Torus", + "Cone", + "Cylinder" + } }; const int GeometryCache::UNKNOWN_ID = -1; @@ -102,16 +119,38 @@ void GeometryCache::computeSimpleHullPointListForShape(const int entityShape, co return; } - const gpu::BufferView & shapeNorms = shapeData->_normalView; - assert(shapeData->_positionView._size == shapeNorms._size); - - const gpu::BufferView::Size numItems = shapeNorms.getNumElements(); + const gpu::BufferView & shapeVerts = shapeData->_positionView; + const gpu::BufferView::Size numItems = shapeVerts.getNumElements(); outPointList.reserve((int)numItems); + QVector uniqueVerts; + uniqueVerts.reserve((int)numItems); + const float SQUARED_MAX_INCLUSIVE_FILTER_DISTANCE = 0.0025f; for (gpu::BufferView::Index i = 0; i < (gpu::BufferView::Index)numItems; ++i) { - const geometry::Vec &curNorm = shapeNorms.get(i); - outPointList.push_back(curNorm * entityHalfExtents); + const int numUniquePoints = (int)uniqueVerts.size(); + const geometry::Vec &curVert = shapeVerts.get(i); + bool isUniquePoint = true; + + for (int uniqueIndex = 0; uniqueIndex < numUniquePoints; ++uniqueIndex) { + const geometry::Vec knownVert = uniqueVerts[uniqueIndex]; + const float distToKnownPoint = glm::length2(knownVert - curVert); + + if (fabsf(distToKnownPoint) <= SQUARED_MAX_INCLUSIVE_FILTER_DISTANCE) { + isUniquePoint = false; + break; + } + } + + if (!isUniquePoint) { + + //--EARLY ITERATION EXIT-- + continue; + } + + + uniqueVerts.push_back(curVert); + outPointList.push_back(curVert * entityHalfExtents); } } @@ -515,6 +554,18 @@ GeometryCache::Shape GeometryCache::getShapeForEntityShape(int entityShape) { return MAPPING[entityShape]; } +QString GeometryCache::stringFromShape(GeometryCache::Shape geoShape) +{ + if (((int)geoShape < 0) || ((int)geoShape >= (int)GeometryCache::NUM_SHAPES)) { + qCWarning(renderutils) << "GeometryCache::stringFromShape - Invalid shape " << geoShape << " specified."; + + //--EARLY EXIT-- + return "INVALID_GEOCACHE_SHAPE"; + } + + return GEOCACHE_SHAPE_STRINGS[geoShape]; +} + gpu::Stream::FormatPointer& getSolidStreamFormat() { if (!SOLID_STREAM_FORMAT) { SOLID_STREAM_FORMAT = std::make_shared(); // 1 for everyone diff --git a/libraries/render-utils/src/GeometryCache.h b/libraries/render-utils/src/GeometryCache.h index 2e81c825be..5ee627bb93 100644 --- a/libraries/render-utils/src/GeometryCache.h +++ b/libraries/render-utils/src/GeometryCache.h @@ -153,6 +153,7 @@ public: /// the GeometryCache::Shape enum which aligns with the /// specified entityShapeEnum static GeometryCache::Shape getShapeForEntityShape(int entityShapeEnum); + static QString stringFromShape(GeometryCache::Shape geoShape); static void computeSimpleHullPointListForShape(int entityShape, const glm::vec3 &entityHalfExtents, QVector &outPointList); From d027993ac0a8040088765144bb79a636a6f933dd Mon Sep 17 00:00:00 2001 From: LaShonda Hopper Date: Wed, 18 Oct 2017 12:11:42 -0400 Subject: [PATCH 18/26] [WL21389] Address code review feedback (details below). * Renamed squared var to be consistent with format of others in the code base. * Removed fabsf() that was accidentally left in. * Reduced squared distance filter within GeometryCache::computeSimpleHullPointListForShape as suggested from 0.0025f to recommended 1.0e-6f (1mm^2). Feedback Link: https://github.com/highfidelity/hifi/pull/11336#pullrequestreview-70060918 Changes Committed: modified: libraries/render-utils/src/GeometryCache.cpp --- libraries/render-utils/src/GeometryCache.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/render-utils/src/GeometryCache.cpp b/libraries/render-utils/src/GeometryCache.cpp index f83e8ae14f..3014fe9593 100644 --- a/libraries/render-utils/src/GeometryCache.cpp +++ b/libraries/render-utils/src/GeometryCache.cpp @@ -126,7 +126,7 @@ void GeometryCache::computeSimpleHullPointListForShape(const int entityShape, co QVector uniqueVerts; uniqueVerts.reserve((int)numItems); - const float SQUARED_MAX_INCLUSIVE_FILTER_DISTANCE = 0.0025f; + const float MAX_INCLUSIVE_FILTER_DISTANCE_SQUARED = 1.0e-6f; //< 1mm^2 for (gpu::BufferView::Index i = 0; i < (gpu::BufferView::Index)numItems; ++i) { const int numUniquePoints = (int)uniqueVerts.size(); const geometry::Vec &curVert = shapeVerts.get(i); @@ -136,7 +136,7 @@ void GeometryCache::computeSimpleHullPointListForShape(const int entityShape, co const geometry::Vec knownVert = uniqueVerts[uniqueIndex]; const float distToKnownPoint = glm::length2(knownVert - curVert); - if (fabsf(distToKnownPoint) <= SQUARED_MAX_INCLUSIVE_FILTER_DISTANCE) { + if (distToKnownPoint <= MAX_INCLUSIVE_FILTER_DISTANCE_SQUARED) { isUniquePoint = false; break; } From 226d51b8f52e9b2d5fa74eca55f162ceedc91cb7 Mon Sep 17 00:00:00 2001 From: LaShonda Hopper Date: Mon, 23 Oct 2017 16:44:33 -0400 Subject: [PATCH 19/26] [WL21389] Fix scaling issue when computing hull point list (details below). The entity dimensions should be scaled by 1 as opposed to 0.5. Changes Committed: modified: interface/src/Util.cpp modified: libraries/render-utils/src/GeometryCache.cpp modified: libraries/render-utils/src/GeometryCache.h --- interface/src/Util.cpp | 2 +- libraries/render-utils/src/GeometryCache.cpp | 4 ++-- libraries/render-utils/src/GeometryCache.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/interface/src/Util.cpp b/interface/src/Util.cpp index 9fdd5e4b76..aad7768b99 100644 --- a/interface/src/Util.cpp +++ b/interface/src/Util.cpp @@ -407,7 +407,7 @@ void shapeInfoCalculator(const ShapeEntityItem * const shapeEntity, ShapeInfo &s ShapeInfo::PointList points; pointCollection.push_back(points); - GeometryCache::computeSimpleHullPointListForShape((int)shapeEntity->getShape(), shapeEntity->getDimensions() * 0.5f, pointCollection.back()); + GeometryCache::computeSimpleHullPointListForShape((int)shapeEntity->getShape(), shapeEntity->getDimensions(), pointCollection.back()); shapeInfo.setPointCollection(pointCollection); } diff --git a/libraries/render-utils/src/GeometryCache.cpp b/libraries/render-utils/src/GeometryCache.cpp index 3014fe9593..9b73b371f7 100644 --- a/libraries/render-utils/src/GeometryCache.cpp +++ b/libraries/render-utils/src/GeometryCache.cpp @@ -109,7 +109,7 @@ static gpu::Stream::FormatPointer INSTANCED_SOLID_FADE_STREAM_FORMAT; static const uint SHAPE_VERTEX_STRIDE = sizeof(glm::vec3) * 2; // vertices and normals static const uint SHAPE_NORMALS_OFFSET = sizeof(glm::vec3); -void GeometryCache::computeSimpleHullPointListForShape(const int entityShape, const glm::vec3 &entityHalfExtents, QVector &outPointList) { +void GeometryCache::computeSimpleHullPointListForShape(const int entityShape, const glm::vec3 &entityExtents, QVector &outPointList) { auto geometryCache = DependencyManager::get(); const GeometryCache::Shape geometryShape = GeometryCache::getShapeForEntityShape( entityShape ); @@ -150,7 +150,7 @@ void GeometryCache::computeSimpleHullPointListForShape(const int entityShape, co uniqueVerts.push_back(curVert); - outPointList.push_back(curVert * entityHalfExtents); + outPointList.push_back(curVert * entityExtents); } } diff --git a/libraries/render-utils/src/GeometryCache.h b/libraries/render-utils/src/GeometryCache.h index 5ee627bb93..cd8c43f1df 100644 --- a/libraries/render-utils/src/GeometryCache.h +++ b/libraries/render-utils/src/GeometryCache.h @@ -155,7 +155,7 @@ public: static GeometryCache::Shape getShapeForEntityShape(int entityShapeEnum); static QString stringFromShape(GeometryCache::Shape geoShape); - static void computeSimpleHullPointListForShape(int entityShape, const glm::vec3 &entityHalfExtents, QVector &outPointList); + static void computeSimpleHullPointListForShape(int entityShape, const glm::vec3 &entityExtents, QVector &outPointList); static uint8_t CUSTOM_PIPELINE_NUMBER; static render::ShapePipelinePointer shapePipelineFactory(const render::ShapePlumber& plumber, const render::ShapeKey& key); From d1ab1c5e2632fe0db8a761b16978c60b6bfa770c Mon Sep 17 00:00:00 2001 From: LaShonda Hopper Date: Mon, 23 Oct 2017 16:47:23 -0400 Subject: [PATCH 20/26] [WL21389] Fixes issue with the ShapeData vert buffer offset (details below). When computing the buffer view offset for ShapeData the vertex vector size should be scaled by a single vec3 size as opposed to 2. This fix is taken from PR discussion: https://github.com/1P-Cusack/hifi/pull/10 Proposed by: Andrew Meadows Changes Committed: modified: libraries/render-utils/src/GeometryCache.cpp --- libraries/render-utils/src/GeometryCache.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/render-utils/src/GeometryCache.cpp b/libraries/render-utils/src/GeometryCache.cpp index 9b73b371f7..f35fb9f830 100644 --- a/libraries/render-utils/src/GeometryCache.cpp +++ b/libraries/render-utils/src/GeometryCache.cpp @@ -170,7 +170,7 @@ void GeometryCache::ShapeData::setupVertices(gpu::BufferPointer& vertexBuffer, c gpu::Buffer::Size offset = vertexBuffer->getSize(); vertexBuffer->append(vertices); - gpu::Buffer::Size viewSize = vertices.size() * 2 * sizeof(glm::vec3); + gpu::Buffer::Size viewSize = vertices.size() * sizeof(glm::vec3); _positionView = gpu::BufferView(vertexBuffer, offset, viewSize, SHAPE_VERTEX_STRIDE, POSITION_ELEMENT); From 39b2c0f83a6588d317dac179fe12525117a4548e Mon Sep 17 00:00:00 2001 From: beholder Date: Wed, 25 Oct 2017 01:59:56 +0300 Subject: [PATCH 21/26] fix for FB 8553 & FB 8380 --- .../src/display-plugins/CompositorHelper.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libraries/display-plugins/src/display-plugins/CompositorHelper.cpp b/libraries/display-plugins/src/display-plugins/CompositorHelper.cpp index 2f57cc29d0..7b639e8308 100644 --- a/libraries/display-plugins/src/display-plugins/CompositorHelper.cpp +++ b/libraries/display-plugins/src/display-plugins/CompositorHelper.cpp @@ -234,7 +234,8 @@ void CompositorHelper::handleLeaveEvent() { bool CompositorHelper::handleRealMouseMoveEvent(bool sendFakeEvent) { // If the mouse move came from a capture mouse related move, we completely ignore it. - if (_ignoreMouseMove) { + // Note: if not going to synthesize event - do not touch _ignoreMouseMove flag + if (_ignoreMouseMove && sendFakeEvent) { _ignoreMouseMove = false; return true; // swallow the event } @@ -246,7 +247,12 @@ bool CompositorHelper::handleRealMouseMoveEvent(bool sendFakeEvent) { auto changeInRealMouse = newPosition - _lastKnownRealMouse; auto newReticlePosition = _reticlePositionInHMD + toGlm(changeInRealMouse); setReticlePosition(newReticlePosition, sendFakeEvent); - _ignoreMouseMove = true; + + // Note: if not going to synthesize event - do not touch _ignoreMouseMove flag + if (sendFakeEvent) { + _ignoreMouseMove = true; + } + QCursor::setPos(QPoint(_lastKnownRealMouse.x(), _lastKnownRealMouse.y())); // move cursor back to where it was return true; // swallow the event } else { From ff0af9f5ccf627117b82d4547072a82617ab2b17 Mon Sep 17 00:00:00 2001 From: utkarshgautamnyu Date: Tue, 24 Oct 2017 20:14:02 -0700 Subject: [PATCH 22/26] Fixed issue with QTextStream --- libraries/baking/src/JSBaker.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/baking/src/JSBaker.cpp b/libraries/baking/src/JSBaker.cpp index 75811bea49..a97a7fe5b3 100644 --- a/libraries/baking/src/JSBaker.cpp +++ b/libraries/baking/src/JSBaker.cpp @@ -72,7 +72,7 @@ void JSBaker::bake() { bool JSBaker::bakeJS(const QByteArray& inputFile, QByteArray& outputFile) { // Read from inputFile and write to outputFile per character QTextStream in(inputFile, QIODevice::ReadOnly); - QTextStream out(outputFile, QIODevice::WriteOnly); + QTextStream out(&outputFile, QIODevice::WriteOnly); // Algorithm requires the knowledge of previous and next character for each character read QChar currentCharacter; From 9b94f3330411474d6092793686dedcd8a974977f Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Tue, 24 Oct 2017 20:48:59 -0700 Subject: [PATCH 23/26] fix ray pick in cases where origin is inside of outer bounding box --- libraries/shared/src/TriangleSet.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libraries/shared/src/TriangleSet.cpp b/libraries/shared/src/TriangleSet.cpp index 68c99a9753..ce7dd18921 100644 --- a/libraries/shared/src/TriangleSet.cpp +++ b/libraries/shared/src/TriangleSet.cpp @@ -104,8 +104,9 @@ bool TriangleSet::TriangleOctreeCell::findRayIntersectionInternal(const glm::vec if (_bounds.findRayIntersection(origin, direction, boxDistance, face, surfaceNormal)) { // if our bounding box intersects at a distance greater than the current known - // best distance, than we can safely not check any of our triangles - if (boxDistance > bestDistance) { + // best distance, and our origin isn't inside the boounds, then we can safely + // not check any of our triangles + if (boxDistance > bestDistance && !_bounds.contains(origin)) { return false; } From 2ec8f3f62556840ea0439fe6ae686e86b8cad002 Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Wed, 25 Oct 2017 11:29:32 -0700 Subject: [PATCH 24/26] made non-dynamic entities collisionless during far-grab --- .../controllers/controllerModules/farActionGrabEntity.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/system/controllers/controllerModules/farActionGrabEntity.js b/scripts/system/controllers/controllerModules/farActionGrabEntity.js index ee2db6f6e0..e34855d521 100644 --- a/scripts/system/controllers/controllerModules/farActionGrabEntity.js +++ b/scripts/system/controllers/controllerModules/farActionGrabEntity.js @@ -119,6 +119,7 @@ Script.include("/~/system/libraries/controllers.js"); this.actionID = null; // action this script created... this.entityWithContextOverlay = false; this.contextOverlayTimer = false; + this.previousCollisionStatus = false; this.reticleMinX = MARGIN; this.reticleMaxX; this.reticleMinY = MARGIN; @@ -342,7 +343,9 @@ Script.include("/~/system/libraries/controllers.js"); if (this.madeDynamic) { var props = {}; props.dynamic = false; + props.collisionless = this.previousCollisionStatus; props.localVelocity = {x: 0, y: 0, z: 0}; + props.localRotation = {x: 0, y: 0, z: 0}; Entities.editEntity(this.grabbedThingID, props); this.madeDynamic = false; } @@ -507,10 +510,12 @@ Script.include("/~/system/libraries/controllers.js"); if (entityIsGrabbable(targetProps)) { if (!entityIsDistanceGrabbable(targetProps)) { targetProps.dynamic = true; + this.previousCollisionStatus = targetProps.collisionless; + targetProps.collisionless = true; Entities.editEntity(entityID, targetProps); this.madeDynamic = true; } - + if (!this.distanceRotating) { this.grabbedThingID = entityID; this.grabbedDistance = rayPickInfo.distance; From c14bbb76e63d5ae159ddf27afc16b7511fe52a3b Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Wed, 25 Oct 2017 11:57:44 -0700 Subject: [PATCH 25/26] fix compile errors after merge --- libraries/shared/src/ShapeInfo.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libraries/shared/src/ShapeInfo.cpp b/libraries/shared/src/ShapeInfo.cpp index fd14a9c251..36ce38335a 100644 --- a/libraries/shared/src/ShapeInfo.cpp +++ b/libraries/shared/src/ShapeInfo.cpp @@ -67,7 +67,6 @@ void ShapeInfo::setParams(ShapeType type, const glm::vec3& halfExtents, QString break; case SHAPE_TYPE_BOX: case SHAPE_TYPE_HULL: - case SHAPE_TYPE_SIMPLE_HULL: break; case SHAPE_TYPE_SPHERE: { float radius = glm::length(halfExtents) / SQUARE_ROOT_OF_3; @@ -361,7 +360,7 @@ const DoubleHashKey& ShapeInfo::getHash() const { numHulls = 1; } if (numHulls > 0) { - hash = DoubleHashKey::hashFunction(numHulls, primeIndex++); + uint32_t hash = DoubleHashKey::hashFunction(numHulls, primeIndex++); _doubleHashKey.setHash(_doubleHashKey.getHash() ^ hash); hash = DoubleHashKey::hashFunction2(numHulls); _doubleHashKey.setHash2(_doubleHashKey.getHash2() ^ hash); From 226b974ce8672084b43d6e7e7f7f0f4d5c103a04 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Wed, 25 Oct 2017 11:59:29 -0700 Subject: [PATCH 26/26] DPI is not a decimal --- scripts/system/html/js/entityProperties.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/system/html/js/entityProperties.js b/scripts/system/html/js/entityProperties.js index b1e5599dc6..a015eed714 100644 --- a/scripts/system/html/js/entityProperties.js +++ b/scripts/system/html/js/entityProperties.js @@ -1373,7 +1373,7 @@ function loaded() { elShape.addEventListener('change', createEmitTextPropertyUpdateFunction('shape')); elWebSourceURL.addEventListener('change', createEmitTextPropertyUpdateFunction('sourceUrl')); - elWebDPI.addEventListener('change', createEmitNumberPropertyUpdateFunction('dpi')); + elWebDPI.addEventListener('change', createEmitNumberPropertyUpdateFunction('dpi', 0)); elModelURL.addEventListener('change', createEmitTextPropertyUpdateFunction('modelURL')); elShapeType.addEventListener('change', createEmitTextPropertyUpdateFunction('shapeType'));