Fix a bunch of warnings

This commit is contained in:
samcake 2016-02-10 12:18:46 -08:00
parent 51bacdebdd
commit b295a3732e
3 changed files with 35 additions and 36 deletions

View file

@ -136,7 +136,6 @@ void FetchItems::configure(const Config& config) {
void FetchItems::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, ItemBounds& outItems) { void FetchItems::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, ItemBounds& outItems) {
assert(renderContext->args); assert(renderContext->args);
assert(renderContext->args->_viewFrustum); assert(renderContext->args->_viewFrustum);
RenderArgs* args = renderContext->args;
auto& scene = sceneContext->_scene; auto& scene = sceneContext->_scene;
outItems.clear(); outItems.clear();
@ -199,7 +198,6 @@ void CullSpatialSelection::run(const SceneContextPointer& sceneContext, const Re
assert(renderContext->args->_viewFrustum); assert(renderContext->args->_viewFrustum);
RenderArgs* args = renderContext->args; RenderArgs* args = renderContext->args;
auto& scene = sceneContext->_scene; auto& scene = sceneContext->_scene;
ViewFrustum* frustum = args->_viewFrustum;
auto& details = args->_details.edit(_detailType); auto& details = args->_details.edit(_detailType);
details._considered += inSelection.numItems(); details._considered += inSelection.numItems();
@ -300,7 +298,6 @@ void FilterItemSelection::configure(const Config& config) {
void FilterItemSelection::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, const ItemBounds& inItems, ItemBounds& outItems) { void FilterItemSelection::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, const ItemBounds& inItems, ItemBounds& outItems) {
assert(renderContext->args); assert(renderContext->args);
assert(renderContext->args->_viewFrustum); assert(renderContext->args->_viewFrustum);
RenderArgs* args = renderContext->args;
auto& scene = sceneContext->_scene; auto& scene = sceneContext->_scene;
// Now we have a selection of items to render // Now we have a selection of items to render

View file

@ -16,23 +16,23 @@
using namespace render; using namespace render;
const double Octree::INV_DEPTH_DIM[] = { const float Octree::INV_DEPTH_DIM[] = {
1.0, 1.0f,
1.0 / 2.0, 1.0f / 2.0f,
1.0 / 4.0, 1.0f / 4.0f,
1.0 / 8.0, 1.0f / 8.0f,
1.0 / 16.0, 1.0f / 16.0f,
1.0 / 32.0, 1.0f / 32.0f,
1.0 / 64.0, 1.0f / 64.0f,
1.0 / 128.0, 1.0f / 128.0f,
1.0 / 256.0, 1.0f / 256.0f,
1.0 / 512.0, 1.0f / 512.0f,
1.0 / 1024.0, 1.0f / 1024.0f,
1.0 / 2048.0, 1.0f / 2048.0f,
1.0 / 4096.0, 1.0f / 4096.0f,
1.0 / 8192.0, 1.0f / 8192.0f,
1.0 / 16384.0, 1.0f / 16384.0f,
1.0 / 32768.0 }; 1.0f / 32768.0f };
/* /*
const float Octree::COORD_SUBCELL_WIDTH[] = { // 2 ^ MAX_DEPTH / 2 ^ (depth + 1) const float Octree::COORD_SUBCELL_WIDTH[] = { // 2 ^ MAX_DEPTH / 2 ^ (depth + 1)
@ -92,8 +92,7 @@ Octree::Indices Octree::indexConcreteCellPath(const Locations& path) const {
Index currentIndex = ROOT_CELL; Index currentIndex = ROOT_CELL;
Indices cellPath(1, currentIndex); Indices cellPath(1, currentIndex);
for (int l = 1; l < path.size(); l++) { for (auto& location : path) {
auto& location = path[l];
auto nextIndex = getConcreteCell(currentIndex).child(location.octant()); auto nextIndex = getConcreteCell(currentIndex).child(location.octant());
if (nextIndex == INVALID_CELL) { if (nextIndex == INVALID_CELL) {
break; break;
@ -233,7 +232,7 @@ Octree::Index Octree::allocateBrick() {
void Octree::freeBrick(Index index) { void Octree::freeBrick(Index index) {
if (checkBrickIndex(index)) { if (checkBrickIndex(index)) {
auto & brick = _bricks[index]; auto & brick = _bricks[index];
// brick.free(); brick.free();
_freeBricks.push_back(index); _freeBricks.push_back(index);
} }
} }
@ -280,7 +279,7 @@ Octree::Locations ItemSpatialTree::evalLocations(const ItemBounds& bounds) const
ItemSpatialTree::Index ItemSpatialTree::insertItem(Index cellIdx, const ItemKey& key, const ItemID& item) { ItemSpatialTree::Index ItemSpatialTree::insertItem(Index cellIdx, const ItemKey& key, const ItemID& item) {
// Add the item to the brick (and a brick if needed) // Add the item to the brick (and a brick if needed)
auto brickID = accessCellBrick(cellIdx, [&](Cell& cell, Brick& brick, Octree::Index cellID) { accessCellBrick(cellIdx, [&](Cell& cell, Brick& brick, Octree::Index cellID) {
auto& itemIn = (key.isSmall() ? brick.subcellItems : brick.items); auto& itemIn = (key.isSmall() ? brick.subcellItems : brick.items);
itemIn.push_back(item); itemIn.push_back(item);
@ -302,7 +301,7 @@ bool ItemSpatialTree::updateItem(Index cellIdx, const ItemKey& oldKey, const Ite
assert(oldKey != key); assert(oldKey != key);
// Get to the brick where the item is and update where it s stored // Get to the brick where the item is and update where it s stored
auto brickID = accessCellBrick(cellIdx, [&](Cell& cell, Brick& brick, Octree::Index cellID) { accessCellBrick(cellIdx, [&](Cell& cell, Brick& brick, Octree::Index cellID) {
auto& itemIn = (key.isSmall() ? brick.subcellItems : brick.items); auto& itemIn = (key.isSmall() ? brick.subcellItems : brick.items);
auto& itemOut = (oldKey.isSmall() ? brick.subcellItems : brick.items); auto& itemOut = (oldKey.isSmall() ? brick.subcellItems : brick.items);
@ -417,9 +416,9 @@ Octree::Location::Intersection Octree::Location::intersectCell(const Location& c
struct Tool { struct Tool {
static int normalToIndex(const Coord3f& n) { static int normalToIndex(const Coord3f& n) {
int index = 0; int index = 0;
if (n.x >= 0.0) index |= 1; if (n.x >= 0.0f) index |= 1;
if (n.y >= 0.0) index |= 2; if (n.y >= 0.0f) index |= 2;
if (n.z >= 0.0) index |= 4; if (n.z >= 0.0f) index |= 4;
return index; return index;
} }
@ -484,7 +483,7 @@ int Octree::selectTraverse(Index cellID, CellSelection& selection, const Frustum
// Test for lod // Test for lod
auto cellLocation = cell.getlocation(); auto cellLocation = cell.getlocation();
float lod = selector.testSolidAngle(cellLocation.getCenter(), Octree::getCoordSubcellWidth(cellLocation.depth)); float lod = selector.testSolidAngle(cellLocation.getCenter(), Octree::getCoordSubcellWidth(cellLocation.depth));
if (lod < 0.0) { if (lod < 0.0f) {
return 0; return 0;
break; break;
} }
@ -512,7 +511,7 @@ int Octree::selectBranch(Index cellID, CellSelection& selection, const FrustumS
auto cellLocation = cell.getlocation(); auto cellLocation = cell.getlocation();
float lod = selector.testSolidAngle(cellLocation.getCenter(), Octree::getCoordSubcellWidth(cellLocation.depth)); float lod = selector.testSolidAngle(cellLocation.getCenter(), Octree::getCoordSubcellWidth(cellLocation.depth));
if (lod < 0.0) { if (lod < 0.0f) {
return 0; return 0;
} }

View file

@ -31,6 +31,8 @@ namespace render {
public: public:
std::vector<ItemID> items; std::vector<ItemID> items;
std::vector<ItemID> subcellItems; std::vector<ItemID> subcellItems;
void free() {};
}; };
class Octree { class Octree {
@ -90,11 +92,12 @@ namespace render {
static const Depth ROOT_DEPTH{ 0 }; static const Depth ROOT_DEPTH{ 0 };
static const Depth MAX_DEPTH{ 15 }; static const Depth MAX_DEPTH{ 15 };
static const Depth METRIC_COORD_DEPTH{ 15 }; static const Depth METRIC_COORD_DEPTH{ 15 };
static const double INV_DEPTH_DIM[Octree::MAX_DEPTH + 1]; static const float INV_DEPTH_DIM[Octree::MAX_DEPTH + 1];
static int getDepthDimension(Depth depth) { return 1 << depth; } static int getDepthDimension(Depth depth) { return 1 << depth; }
static double getInvDepthDimension(Depth depth) { return INV_DEPTH_DIM[depth]; } static float getDepthDimensionf(Depth depth) { return (float) getDepthDimension(depth); }
static float getCoordSubcellWidth(Depth depth) { return (float) (1.7320 * getInvDepthDimension(depth) * 0.5); } static float getInvDepthDimension(Depth depth) { return INV_DEPTH_DIM[depth]; }
static float getCoordSubcellWidth(Depth depth) { return (1.7320f * getInvDepthDimension(depth) * 0.5f); }
// Need 16bits integer coordinates on each axes: 32768 cell positions // Need 16bits integer coordinates on each axes: 32768 cell positions
using Coord = int16_t; using Coord = int16_t;
@ -363,7 +366,7 @@ namespace render {
// The octree only cares about the bound & the key of an item to store it a the right cell location // The octree only cares about the bound & the key of an item to store it a the right cell location
class ItemSpatialTree : public Octree { class ItemSpatialTree : public Octree {
float _size{ 32768.0f }; float _size{ 32768.0f };
double _invSize{ 1.0 / _size }; float _invSize{ 1.0f / _size };
glm::vec3 _origin{ -16384.0f }; glm::vec3 _origin{ -16384.0f };
public: public:
ItemSpatialTree() {} ItemSpatialTree() {}
@ -371,8 +374,8 @@ namespace render {
float getSize() const { return _size; } float getSize() const { return _size; }
const glm::vec3& getOrigin() const { return _origin; } const glm::vec3& getOrigin() const { return _origin; }
float getCellWidth(Depth depth) const { return (float) _size * getInvDepthDimension(depth); } float getCellWidth(Depth depth) const { return _size * getInvDepthDimension(depth); }
float getInvCellWidth(Depth depth) const { return (float) getDepthDimension(depth) * _invSize; } float getInvCellWidth(Depth depth) const { return getDepthDimensionf(depth) * _invSize; }
float getCellHalfDiagonalSquare(Depth depth) const { float getCellHalfDiagonalSquare(Depth depth) const {
float cellHalfWidth = 0.5f * getCellWidth(depth); float cellHalfWidth = 0.5f * getCellWidth(depth);