[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 <leander@1stplayable.com>

Changes Committed:
	modified:   interface/src/Util.cpp
	modified:   libraries/render-utils/src/GeometryCache.cpp
	modified:   libraries/render-utils/src/GeometryCache.h
This commit is contained in:
LaShonda Hopper 2017-10-02 17:47:51 -04:00
parent 789b850846
commit 7f9ce5a4cd
3 changed files with 28 additions and 18 deletions

View file

@ -396,11 +396,18 @@ void runUnitTests() {
} }
void shapeInfoCalculator(const ShapeEntityItem * const shapeEntity, ShapeInfo &shapeInfo) { void shapeInfoCalculator(const ShapeEntityItem * const shapeEntity, ShapeInfo &shapeInfo) {
if (shapeEntity == nullptr) {
//--EARLY EXIT--
return;
}
ShapeInfo::PointCollection pointCollection; ShapeInfo::PointCollection pointCollection;
ShapeInfo::PointList points; ShapeInfo::PointList points;
pointCollection.push_back(points); pointCollection.push_back(points);
GeometryCache::computeSimpleHullPointListForShape(shapeEntity, pointCollection.back()); GeometryCache::computeSimpleHullPointListForShape((int)shapeEntity->getShape(), shapeEntity->getDimensions() * 0.5f, pointCollection.back());
shapeInfo.setPointCollection(pointCollection); shapeInfo.setPointCollection(pointCollection);
} }

View file

@ -23,7 +23,6 @@
#include <FSTReader.h> #include <FSTReader.h>
#include <NumericalConstants.h> #include <NumericalConstants.h>
#include <ShapeEntityItem.h>
#include "TextureCache.h" #include "TextureCache.h"
#include "RenderUtilsLogging.h" #include "RenderUtilsLogging.h"
@ -53,7 +52,12 @@
//#define WANT_DEBUG //#define WANT_DEBUG
static std::array<GeometryCache::Shape, entity::NUM_SHAPES> 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<GeometryCache::Shape, (GeometryCache::NUM_SHAPES - 1)> MAPPING{ {
GeometryCache::Triangle, GeometryCache::Triangle,
GeometryCache::Quad, GeometryCache::Quad,
GeometryCache::Hexagon, 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_VERTEX_STRIDE = sizeof(glm::vec3) * 2; // vertices and normals
static const uint SHAPE_NORMALS_OFFSET = sizeof(glm::vec3); static const uint SHAPE_NORMALS_OFFSET = sizeof(glm::vec3);
void GeometryCache::computeSimpleHullPointListForShape(const ShapeEntityItem * const shapePtr, QVector<glm::vec3> &outPointList){ void GeometryCache::computeSimpleHullPointListForShape(const int entityShape, const glm::vec3 &entityHalfExtents, QVector<glm::vec3> &outPointList) {
if (shapePtr == nullptr){
//--EARLY EXIT--
return;
}
auto geometryCache = DependencyManager::get<GeometryCache>(); auto geometryCache = DependencyManager::get<GeometryCache>();
const GeometryCache::Shape entityGeometryShape = GeometryCache::getShapeForEntityShape(shapePtr->getShape()); const GeometryCache::Shape geometryShape = GeometryCache::getShapeForEntityShape( entityShape );
const GeometryCache::ShapeData * shapeData = geometryCache->getShapeData( entityGeometryShape ); const GeometryCache::ShapeData * shapeData = geometryCache->getShapeData( geometryShape );
if (!shapeData){ if (!shapeData){
//--EARLY EXIT--( data isn't ready for some reason... ) //--EARLY EXIT--( data isn't ready for some reason... )
return; return;
@ -107,12 +106,11 @@ void GeometryCache::computeSimpleHullPointListForShape(const ShapeEntityItem * c
assert(shapeVerts._size == shapeNorms._size); assert(shapeVerts._size == shapeNorms._size);
const gpu::BufferView::Size numItems = shapeVerts.getNumElements(); const gpu::BufferView::Size numItems = shapeVerts.getNumElements();
const glm::vec3 halfExtents = shapePtr->getDimensions() * 0.5f;
outPointList.reserve((int)numItems); outPointList.reserve((int)numItems);
for (gpu::BufferView::Index i = 0; i < (gpu::BufferView::Index)numItems; ++i) { for (gpu::BufferView::Index i = 0; i < (gpu::BufferView::Index)numItems; ++i) {
const geometry::Vec &curNorm = shapeNorms.get<geometry::Vec>(i); const geometry::Vec &curNorm = shapeNorms.get<geometry::Vec>(i);
outPointList.push_back(curNorm * halfExtents); outPointList.push_back(curNorm * entityHalfExtents);
} }
} }
@ -488,7 +486,7 @@ void GeometryCache::buildShapes() {
extrudePolygon<64>(_shapes[Cone], _shapeVertices, _shapeIndices, true); extrudePolygon<64>(_shapes[Cone], _shapeVertices, _shapeIndices, true);
//Circle //Circle
drawCircle(_shapes[Circle], _shapeVertices, _shapeIndices); drawCircle(_shapes[Circle], _shapeVertices, _shapeIndices);
// Not implememented yet: // Not implemented yet:
//Quad, //Quad,
//Torus, //Torus,
@ -496,6 +494,9 @@ void GeometryCache::buildShapes() {
const GeometryCache::ShapeData * GeometryCache::getShapeData(const Shape shape) const { 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; return nullptr;
} }
@ -504,6 +505,9 @@ const GeometryCache::ShapeData * GeometryCache::getShapeData(const Shape shape)
GeometryCache::Shape GeometryCache::getShapeForEntityShape(int entityShape) { 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; return GeometryCache::Sphere;
} }

View file

@ -32,7 +32,6 @@
#include <model/Asset.h> #include <model/Asset.h>
class SimpleProgramKey; class SimpleProgramKey;
class ShapeEntityItem;
typedef QPair<glm::vec2, float> Vec2FloatPair; typedef QPair<glm::vec2, float> Vec2FloatPair;
typedef QPair<Vec2FloatPair, Vec2FloatPair> Vec2FloatPairPair; typedef QPair<Vec2FloatPair, Vec2FloatPair> Vec2FloatPairPair;
@ -155,7 +154,7 @@ public:
/// specified entityShapeEnum /// specified entityShapeEnum
static GeometryCache::Shape getShapeForEntityShape(int entityShapeEnum); static GeometryCache::Shape getShapeForEntityShape(int entityShapeEnum);
static void computeSimpleHullPointListForShape(const ShapeEntityItem * const shapePtr, QVector<glm::vec3> &outPointList); static void computeSimpleHullPointListForShape(int entityShape, const glm::vec3 &entityHalfExtents, QVector<glm::vec3> &outPointList);
static uint8_t CUSTOM_PIPELINE_NUMBER; static uint8_t CUSTOM_PIPELINE_NUMBER;
static render::ShapePipelinePointer shapePipelineFactory(const render::ShapePlumber& plumber, const render::ShapeKey& key); static render::ShapePipelinePointer shapePipelineFactory(const render::ShapePlumber& plumber, const render::ShapeKey& key);