[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
This commit is contained in:
LaShonda Hopper 2017-09-11 13:27:59 -04:00
parent d2350974b5
commit 070c664ff2

View file

@ -96,7 +96,8 @@ void GeometryCache::computeSimpleHullPointListForShape(const ShapeEntityItem * c
}
auto geometryCache = DependencyManager::get<GeometryCache>();
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];