REnamed Octree.h/cpp to SpatialTree and fixing some coding guidelines

This commit is contained in:
samcake 2016-02-15 11:08:12 -08:00
parent 545f276fdf
commit 0c0089f736
5 changed files with 34 additions and 23 deletions

View file

@ -479,7 +479,7 @@ private:
quint64 _lastFaceTrackerUpdate;
render::ScenePointer _main3DScene{ new render::Scene() };
render::ScenePointer _main3DScene{ new render::Scene(glm::vec3(-0.5f * (float)TREE_SCALE), (float)TREE_SCALE) };
render::EnginePointer _renderEngine{ new render::Engine() };
gpu::ContextPointer _gpuContext; // initialized during window creation

View file

@ -79,7 +79,9 @@ void PendingChanges::merge(PendingChanges& changes) {
_updateFunctors.insert(_updateFunctors.end(), changes._updateFunctors.begin(), changes._updateFunctors.end());
}
Scene::Scene() {
Scene::Scene(glm::vec3 origin, float size) :
_masterSpatialTree(origin, size)
{
_items.push_back(Item()); // add the itemID #0 to nothing
_masterBucketMap.allocateStandardOpaqueTranparentBuckets();
}

View file

@ -13,7 +13,7 @@
#define hifi_render_Scene_h
#include "Item.h"
#include "Octree.h"
#include "SpatialTree.h"
namespace render {
@ -68,7 +68,7 @@ typedef std::queue<PendingChanges> PendingChangesQueue;
// Items are notified accordingly on any update message happening
class Scene {
public:
Scene();
Scene(glm::vec3 origin, float size);
~Scene() {}
/// This call is thread safe, can be called from anywhere to allocate a new ID

View file

@ -1,5 +1,5 @@
//
// Octree.h
// SpatialTree.h
// render/src/render
//
// Created by Sam Gateau on 1/25/16.
@ -8,7 +8,7 @@
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#include "Octree.h"
#include "SpatialTree.h"
#include <ViewFrustum.h>

View file

@ -1,5 +1,5 @@
//
// Octree.h
// SpatialTree.h
// render/src/render
//
// Created by Sam Gateau on 1/25/16.
@ -109,12 +109,12 @@ namespace render {
static Coord depthBitmask(Depth depth) { return Coord(1 << (MAX_DEPTH - depth)); }
static Depth coordToDepth(Coord length) {
Depth d = MAX_DEPTH;
Depth depth = MAX_DEPTH;
while (length) {
length >>= 1;
d--;
depth--;
}
return d;
return depth;
}
@ -139,7 +139,7 @@ namespace render {
return center;
}
bool operator== (const Location& right) const { return pos == right.pos && depth == right.depth; }
bool operator== (const Location& other) const { return pos == other.pos && depth == other.depth; }
// Eval the octant of this cell relative to its parent
Octant octant() const { return Octant((pos.x & 1) | ((pos.y & 1) << 1) | ((pos.z & 1) << 2)); }
@ -316,9 +316,11 @@ namespace render {
float angle;
float squareTanAlpha;
const float MAX_LOD_ANGLE = glm::radians(45.0f);
const float MIN_LOD_ANGLE = glm::radians(1.0f / 60.0f);
void setAngle(float a) {
angle = std::min(glm::radians(45.0f), a); // no worse than 45 degrees
angle = std::max(glm::radians(1.0f/60.0f), a); // no better than 1 minute of degree
angle = std::max(MIN_LOD_ANGLE, std::min(MAX_LOD_ANGLE, a));
auto tanAlpha = tan(angle);
squareTanAlpha = (float)(tanAlpha * tanAlpha);
}
@ -368,8 +370,15 @@ namespace render {
float _size { 32768.0f };
float _invSize { 1.0f / _size };
glm::vec3 _origin { -16384.0f };
void init(glm::vec3 origin, float size) {
_size = size;
_invSize = 1.0f / _size;
_origin = origin;
}
public:
ItemSpatialTree() {}
// THe overall size and origin of the tree are defined at creation
ItemSpatialTree(glm::vec3 origin, float size) { init(origin, size); }
float getSize() const { return _size; }
const glm::vec3& getOrigin() const { return _origin; }