Skip to content

Commit

Permalink
#5108: Move NodeCounter helper to separate file
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Nov 26, 2020
1 parent f096507 commit 439f290
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 26 deletions.
27 changes: 1 addition & 26 deletions radiantcore/map/MapResource.cpp
Expand Up @@ -36,6 +36,7 @@
#include "infofile/InfoFileExporter.h"
#include "scene/ChildPrimitives.h"
#include "messages/MapFileOperation.h"
#include "NodeCounter.h"

namespace map
{
Expand All @@ -50,32 +51,6 @@ namespace
path_is_absolute(name.c_str()) ? name : GlobalFileSystem().findFile(name)
);
}

class NodeCounter :
public scene::NodeVisitor
{
private:
std::size_t _count;
public:
NodeCounter() :
_count(0)
{}

bool pre(const scene::INodePtr& node)
{
if (Node_isPrimitive(node) || Node_isEntity(node))
{
_count++;
}

return true;
}

std::size_t getCount() const
{
return _count;
}
};
}

std::string MapResource::_infoFileExt;
Expand Down
36 changes: 36 additions & 0 deletions radiantcore/map/NodeCounter.h
@@ -0,0 +1,36 @@
#pragma once

#include "inode.h"
#include "ientity.h"
#include "scenelib.h"

namespace map
{

class NodeCounter :
public scene::NodeVisitor
{
private:
std::size_t _count;
public:
NodeCounter() :
_count(0)
{}

bool pre(const scene::INodePtr& node)
{
if (Node_isPrimitive(node) || Node_isEntity(node))
{
_count++;
}

return true;
}

std::size_t getCount() const
{
return _count;
}
};

}
1 change: 1 addition & 0 deletions tools/msvc/DarkRadiantCore.vcxproj
Expand Up @@ -847,6 +847,7 @@
<ClInclude Include="..\..\radiantcore\map\namespace\Namespace.h" />
<ClInclude Include="..\..\radiantcore\map\namespace\NamespaceFactory.h" />
<ClInclude Include="..\..\radiantcore\map\namespace\UniqueNameSet.h" />
<ClInclude Include="..\..\radiantcore\map\NodeCounter.h" />
<ClInclude Include="..\..\radiantcore\map\PointFile.h" />
<ClInclude Include="..\..\radiantcore\map\RegionManager.h" />
<ClInclude Include="..\..\radiantcore\map\RegionWalkers.h" />
Expand Down
3 changes: 3 additions & 0 deletions tools/msvc/DarkRadiantCore.vcxproj.filters
Expand Up @@ -2043,5 +2043,8 @@
<ClInclude Include="..\..\radiantcore\vfs\FileVisitor.h">
<Filter>src\vfs</Filter>
</ClInclude>
<ClInclude Include="..\..\radiantcore\map\NodeCounter.h">
<Filter>src\map</Filter>
</ClInclude>
</ItemGroup>
</Project>

0 comments on commit 439f290

Please sign in to comment.