Applied default Visual Studio formatting to most files. This is a quick fix for the tabs vs spaces issue that messes up the formatting in any editor (esp. Linux) which handles tabs/spaces differently to Visual Studio. Some parts of the formatting look a bit worse but overall it should be better (or at least more consistent).

I didn't apply the changes to a few macro-heavy files as Visual Studio removes all indentation from macros, whereas the indentation can be handy to see nesting.
This commit is contained in:
David Williams
2015-12-26 23:11:27 +00:00
parent b3ca051878
commit e89a55d154
58 changed files with 1117 additions and 1114 deletions

View File

@ -35,7 +35,7 @@ namespace PolyVox
bool aStarDefaultVoxelValidator(const VolumeType* volData, const Vector3DInt32& v3dPos)
{
//Voxels are considered valid candidates for the path if they are inside the volume...
if(volData->getEnclosingRegion().containsPoint(v3dPos) == false)
if (volData->getEnclosingRegion().containsPoint(v3dPos) == false)
{
return false;
}
@ -83,12 +83,12 @@ namespace PolyVox
float fDistStartToEnd = (endNode->position - startNode->position).length();
m_fProgress = 0.0f;
if(m_params.progressCallback)
if (m_params.progressCallback)
{
m_params.progressCallback(m_fProgress);
}
while((openNodes.empty() == false) && (openNodes.getFirst() != endNode))
while ((openNodes.empty() == false) && (openNodes.getFirst() != endNode))
{
//Move the first node from open to closed.
current = openNodes.getFirst();
@ -96,13 +96,13 @@ namespace PolyVox
closedNodes.insert(current);
//Update the user on our progress
if(m_params.progressCallback)
if (m_params.progressCallback)
{
const float fMinProgresIncreament = 0.001f;
float fDistCurrentToEnd = (endNode->position - current->position).length();
float fDistNormalised = fDistCurrentToEnd / fDistStartToEnd;
float fProgress = 1.0f - fDistNormalised;
if(fProgress >= m_fProgress + fMinProgresIncreament)
if (fProgress >= m_fProgress + fMinProgresIncreament)
{
m_fProgress = fProgress;
m_params.progressCallback(m_fProgress);
@ -116,7 +116,7 @@ namespace PolyVox
//Process the neighbours. Note the deliberate lack of 'break'
//statements, larger connectivities include smaller ones.
switch(m_params.connectivity)
switch (m_params.connectivity)
{
case TwentySixConnected:
processNeighbour(current->position + arrayPathfinderCorners[0], current->gVal + fCornerCost);
@ -129,16 +129,16 @@ namespace PolyVox
processNeighbour(current->position + arrayPathfinderCorners[7], current->gVal + fCornerCost);
case EighteenConnected:
processNeighbour(current->position + arrayPathfinderEdges[ 0], current->gVal + fEdgeCost);
processNeighbour(current->position + arrayPathfinderEdges[ 1], current->gVal + fEdgeCost);
processNeighbour(current->position + arrayPathfinderEdges[ 2], current->gVal + fEdgeCost);
processNeighbour(current->position + arrayPathfinderEdges[ 3], current->gVal + fEdgeCost);
processNeighbour(current->position + arrayPathfinderEdges[ 4], current->gVal + fEdgeCost);
processNeighbour(current->position + arrayPathfinderEdges[ 5], current->gVal + fEdgeCost);
processNeighbour(current->position + arrayPathfinderEdges[ 6], current->gVal + fEdgeCost);
processNeighbour(current->position + arrayPathfinderEdges[ 7], current->gVal + fEdgeCost);
processNeighbour(current->position + arrayPathfinderEdges[ 8], current->gVal + fEdgeCost);
processNeighbour(current->position + arrayPathfinderEdges[ 9], current->gVal + fEdgeCost);
processNeighbour(current->position + arrayPathfinderEdges[0], current->gVal + fEdgeCost);
processNeighbour(current->position + arrayPathfinderEdges[1], current->gVal + fEdgeCost);
processNeighbour(current->position + arrayPathfinderEdges[2], current->gVal + fEdgeCost);
processNeighbour(current->position + arrayPathfinderEdges[3], current->gVal + fEdgeCost);
processNeighbour(current->position + arrayPathfinderEdges[4], current->gVal + fEdgeCost);
processNeighbour(current->position + arrayPathfinderEdges[5], current->gVal + fEdgeCost);
processNeighbour(current->position + arrayPathfinderEdges[6], current->gVal + fEdgeCost);
processNeighbour(current->position + arrayPathfinderEdges[7], current->gVal + fEdgeCost);
processNeighbour(current->position + arrayPathfinderEdges[8], current->gVal + fEdgeCost);
processNeighbour(current->position + arrayPathfinderEdges[9], current->gVal + fEdgeCost);
processNeighbour(current->position + arrayPathfinderEdges[10], current->gVal + fEdgeCost);
processNeighbour(current->position + arrayPathfinderEdges[11], current->gVal + fEdgeCost);
@ -151,7 +151,7 @@ namespace PolyVox
processNeighbour(current->position + arrayPathfinderFaces[5], current->gVal + fFaceCost);
}
if(allNodes.size() > m_params.maxNumberOfNodes)
if (allNodes.size() > m_params.maxNumberOfNodes)
{
//We've reached the specified maximum number
//of nodes. Just give up on the search.
@ -159,7 +159,7 @@ namespace PolyVox
}
}
if((openNodes.empty()) || (openNodes.getFirst() != endNode))
if ((openNodes.empty()) || (openNodes.getFirst() != endNode))
{
//In this case we failed to find a valid path.
POLYVOX_THROW(std::runtime_error, "No path found");
@ -172,14 +172,14 @@ namespace PolyVox
//custom sort operator for the set which we know only uses the position to sort. Hence we can safely
//modify other properties of the object while it is in the set.
Node* n = const_cast<Node*>(&(*endNode));
while(n != 0)
while (n != 0)
{
m_params.result->push_front(n->position);
n = n->parent;
}
}
if(m_params.progressCallback)
if (m_params.progressCallback)
{
m_params.progressCallback(1.0f);
}
@ -189,7 +189,7 @@ namespace PolyVox
void AStarPathfinder<VolumeType>::processNeighbour(const Vector3DInt32& neighbourPos, float neighbourGVal)
{
bool bIsVoxelValidForPath = m_params.isVoxelValidForPath(m_params.volume, neighbourPos);
if(!bIsVoxelValidForPath)
if (!bIsVoxelValidForPath)
{
return;
}
@ -199,16 +199,16 @@ namespace PolyVox
std::pair<AllNodesContainer::iterator, bool> insertResult = allNodes.insert(Node(neighbourPos.getX(), neighbourPos.getY(), neighbourPos.getZ()));
AllNodesContainer::iterator neighbour = insertResult.first;
if(insertResult.second == true) //New node, compute h.
if (insertResult.second == true) //New node, compute h.
{
Node* tempNeighbour = const_cast<Node*>(&(*neighbour));
tempNeighbour -> hVal = computeH(neighbour->position, m_params.end);
tempNeighbour->hVal = computeH(neighbour->position, m_params.end);
}
OpenNodesContainer::iterator openIter = openNodes.find(neighbour);
if(openIter != openNodes.end())
if (openIter != openNodes.end())
{
if(cost < neighbour->gVal)
if (cost < neighbour->gVal)
{
openNodes.remove(openIter);
openIter = openNodes.end();
@ -217,9 +217,9 @@ namespace PolyVox
//TODO - Nodes could keep track of if they are in open or closed? And a pointer to where they are?
ClosedNodesContainer::iterator closedIter = closedNodes.find(neighbour);
if(closedIter != closedNodes.end())
if (closedIter != closedNodes.end())
{
if(cost < neighbour->gVal)
if (cost < neighbour->gVal)
{
//Probably shouldn't happen?
closedNodes.remove(closedIter);
@ -227,7 +227,7 @@ namespace PolyVox
}
}
if((openIter == openNodes.end()) && (closedIter == closedNodes.end()))
if ((openIter == openNodes.end()) && (closedIter == closedNodes.end()))
{
//Regarding the const_cast - normally you should not modify an object which is in an sdt::set.
//The reason is that objects in a set are stored sorted in a tree so they can be accessed quickly,
@ -245,7 +245,7 @@ namespace PolyVox
float AStarPathfinder<VolumeType>::SixConnectedCost(const Vector3DInt32& a, const Vector3DInt32& b)
{
//This is the only heuristic I'm sure of - just use the manhatten distance for the 6-connected case.
uint32_t faceSteps = std::abs(a.getX()-b.getX()) + std::abs(a.getY()-b.getY()) + std::abs(a.getZ()-b.getZ());
uint32_t faceSteps = std::abs(a.getX() - b.getX()) + std::abs(a.getY() - b.getY()) + std::abs(a.getZ() - b.getZ());
return faceSteps * 1.0f;
}
@ -257,7 +257,7 @@ namespace PolyVox
//6-connected case. This means 'h' will be bigger than it should be, resulting in a faster path which may not
//actually be the shortest one. If you have a correct heuristic for the 18-connected case then please let me know.
return SixConnectedCost(a,b);
return SixConnectedCost(a, b);
}
template<typename VolumeType>
@ -269,7 +269,7 @@ namespace PolyVox
array[0] = std::abs(a.getX() - b.getX());
array[1] = std::abs(a.getY() - b.getY());
array[2] = std::abs(a.getZ() - b.getZ());
//Maybe this is better implemented directly
//using three compares and two swaps... but not
//until the profiler says so.
@ -286,8 +286,8 @@ namespace PolyVox
float AStarPathfinder<VolumeType>::computeH(const Vector3DInt32& a, const Vector3DInt32& b)
{
float hVal;
switch(m_params.connectivity)
switch (m_params.connectivity)
{
case TwentySixConnected:
hVal = TwentySixConnectedCost(a, b);
@ -295,7 +295,7 @@ namespace PolyVox
case EighteenConnected:
hVal = EighteenConnectedCost(a, b);
break;
case SixConnected:
case SixConnected:
hVal = SixConnectedCost(a, b);
break;
default:
@ -304,9 +304,9 @@ namespace PolyVox
//Sanity checks in debug mode. These can come out eventually, but I
//want to make sure that the heuristics I've come up with make sense.
POLYVOX_ASSERT((a-b).length() <= TwentySixConnectedCost(a,b), "A* heuristic error.");
POLYVOX_ASSERT(TwentySixConnectedCost(a,b) <= EighteenConnectedCost(a,b), "A* heuristic error.");
POLYVOX_ASSERT(EighteenConnectedCost(a,b) <= SixConnectedCost(a,b), "A* heuristic error.");
POLYVOX_ASSERT((a - b).length() <= TwentySixConnectedCost(a, b), "A* heuristic error.");
POLYVOX_ASSERT(TwentySixConnectedCost(a, b) <= EighteenConnectedCost(a, b), "A* heuristic error.");
POLYVOX_ASSERT(EighteenConnectedCost(a, b) <= SixConnectedCost(a, b), "A* heuristic error.");
//Apply the bias to the computed h value;
hVal *= m_params.hBias;
@ -323,8 +323,8 @@ namespace PolyVox
//while the other one doesn't - both approaches are valid). For the same reason we want
//to make sure that position (x,y,z) has a differnt hash from e.g. position (x,z,y).
uint32_t aX = (a.getX() << 16) & 0x00FF0000;
uint32_t aY = (a.getY() << 8) & 0x0000FF00;
uint32_t aZ = (a.getZ() ) & 0x000000FF;
uint32_t aY = (a.getY() << 8) & 0x0000FF00;
uint32_t aZ = (a.getZ()) & 0x000000FF;
uint32_t hashVal = hash(aX | aY | aZ);
//Stop hashVal going over 65535, and divide by 1000000 to make sure it is small.
@ -339,14 +339,14 @@ namespace PolyVox
// Robert Jenkins' 32 bit integer hash function
// http://www.burtleburtle.net/bob/hash/integer.html
template<typename VolumeType>
uint32_t AStarPathfinder<VolumeType>::hash( uint32_t a)
uint32_t AStarPathfinder<VolumeType>::hash(uint32_t a)
{
a = (a+0x7ed55d16) + (a<<12);
a = (a^0xc761c23c) ^ (a>>19);
a = (a+0x165667b1) + (a<<5);
a = (a+0xd3a2646c) ^ (a<<9);
a = (a+0xfd7046c5) + (a<<3);
a = (a^0xb55a4f09) ^ (a>>16);
a = (a + 0x7ed55d16) + (a << 12);
a = (a ^ 0xc761c23c) ^ (a >> 19);
a = (a + 0x165667b1) + (a << 5);
a = (a + 0xd3a2646c) ^ (a << 9);
a = (a + 0xfd7046c5) + (a << 3);
a = (a ^ 0xb55a4f09) ^ (a >> 16);
return a;
}
}