Overte C++ Documentation
OctreeConstants.h
1 //
2 // OctreeConstants.h
3 // libraries/octree/src
4 //
5 // Created by Brad Hefta-Gaub on 4/29/13.
6 // Copyright 2013 High Fidelity, Inc.
7 //
8 // Distributed under the Apache License, Version 2.0.
9 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
10 //
11 
12 #ifndef hifi_OctreeConstants_h
13 #define hifi_OctreeConstants_h
14 
15 #include <QtCore/QString> // for quint64/QString
16 #include <glm/glm.hpp>
17 
18 const quint64 CHANGE_FUDGE = 1000 * 200; // useconds of fudge in determining if we want to resend changed voxels
19 
20 const int TREE_SCALE = 32768; // ~20 miles.. This is the number of meters of the 0.0 to 1.0 voxel universe
21 const int HALF_TREE_SCALE = TREE_SCALE / 2;
22 
23 // This controls the LOD. Larger number will make smaller voxels visible at greater distance.
24 const float DEFAULT_VISIBILITY_DISTANCE_FOR_UNIT_ELEMENT = 400.0f; // max distance where a 1x1x1 cube is visible for 20:20 vision
25 const float UNIT_ELEMENT_MAX_EXTENT = sqrtf(3.0f) / 2.0f; // A unit cube tilted on its edge will have its edge jutting out sqrt(3)/2 units from the center
26 const float DEFAULT_OCTREE_SIZE_SCALE = TREE_SCALE * DEFAULT_VISIBILITY_DISTANCE_FOR_UNIT_ELEMENT;
27 
28 // Since entities like models live inside of octree cells, and they themselves can have very small mesh parts,
29 // we want to have some constant that controls have big a mesh part must be to render even if the octree cell itself
30 // would be visible. This constanct controls that. It basically means you must be this many times closer to a mesh
31 // than an octree cell to see the mesh.
32 const float OCTREE_TO_MESH_RATIO = 4.0f;
33 
34 // This is used in the LOD Tools to translate between the size scale slider and the values used to set the OctreeSizeScale
35 const float MAX_LOD_SIZE_MULTIPLIER = 4000.0f;
36 
37 const int NUMBER_OF_CHILDREN = 8;
38 
39 const int MAX_TREE_SLICE_BYTES = 26;
40 
41 // The oversend below is 20 degrees because that is the minimum oversend necessary to prevent missing entities
42 // near the edge of the view. The value here is determined by hard-coded values in ViewFrsutum::isVerySimilar().
43 // TODO: move this parameter to the OctreeQueryNode context.
44 const float VIEW_FRUSTUM_FOV_OVERSEND = 20.0f;
45 
46 // These are guards to prevent our voxel tree recursive routines from spinning out of control
47 const int UNREASONABLY_DEEP_RECURSION = 29; // use this for something that you want to be shallow, but not spin out
48 const int DANGEROUSLY_DEEP_RECURSION = 200; // use this for something that needs to go deeper
49 const float SCALE_AT_UNREASONABLY_DEEP_RECURSION = (TREE_SCALE / powf(2.0f, UNREASONABLY_DEEP_RECURSION));
50 const float SCALE_AT_DANGEROUSLY_DEEP_RECURSION = (TREE_SCALE / powf(2.0f, DANGEROUSLY_DEEP_RECURSION));
51 const float SMALLEST_REASONABLE_OCTREE_ELEMENT_SCALE = SCALE_AT_UNREASONABLY_DEEP_RECURSION * 2.0f; // 0.00001525878 meter ~1/10,0000th
52 
53 const int DEFAULT_MAX_OCTREE_PPS = 600; // the default maximum PPS we think any octree based server should send to a client
54 
55 #endif // hifi_OctreeConstants_h