Skip to content

Commit

Permalink
#5231: Move child primitive OriginAdder/OriginRemover algorithm to sc…
Browse files Browse the repository at this point in the history
…enelib
  • Loading branch information
codereader committed May 24, 2020
1 parent fc015cb commit 78d1019
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 24 deletions.
Expand Up @@ -6,7 +6,7 @@

#include "registry/registry.h"

namespace map
namespace scene
{

// Local helper to add origins
Expand All @@ -15,18 +15,18 @@ class OriginAdder :
{
public:
// NodeVisitor implementation
bool pre(const scene::INodePtr& node)
bool pre(const scene::INodePtr& node) override
{
Entity* entity = Node_getEntity(node);

// Check for an entity
if (entity != NULL)
if (entity != nullptr)
{
// greebo: Check for a Doom3Group
scene::GroupNodePtr groupNode = Node_getGroupNode(node);

// Don't handle the worldspawn children, they're safe&sound
if (groupNode != NULL && !entity->isWorldspawn())
if (groupNode && !entity->isWorldspawn())
{
groupNode->addOriginToChildren();
// Don't traverse the children
Expand All @@ -42,18 +42,18 @@ class OriginRemover :
public scene::NodeVisitor
{
public:
bool pre(const scene::INodePtr& node)
bool pre(const scene::INodePtr& node) override
{
Entity* entity = Node_getEntity(node);

// Check for an entity
if (entity != NULL)
if (entity != nullptr)
{
// greebo: Check for a Doom3Group
scene::GroupNodePtr groupNode = Node_getGroupNode(node);

// Don't handle the worldspawn children, they're safe&sound
if (groupNode != NULL && !entity->isWorldspawn())
if (groupNode && !entity->isWorldspawn())
{
groupNode->removeOriginFromChildren();
// Don't traverse the children
Expand Down
Expand Up @@ -5,7 +5,7 @@
// Forward Decl.
namespace scene { class INode; typedef std::shared_ptr<INode> INodePtr; }

namespace map
namespace scene
{

/**
Expand Down
1 change: 1 addition & 0 deletions libs/scene/Makefile.am
Expand Up @@ -4,6 +4,7 @@ pkglib_LTLIBRARIES = libscenegraph.la
libscenegraph_la_LDFLAGS = -release @PACKAGE_VERSION@ $(LIBSIGC_LIBS)
libscenegraph_la_LIBADD = $(top_builddir)/libs/math/libmath.la
libscenegraph_la_SOURCES = InstanceWalkers.cpp \
ChildPrimitives.cpp \
TraversableNodeSet.cpp \
LayerUsageBreakdown.cpp \
SelectableNode.cpp \
Expand Down
1 change: 0 additions & 1 deletion radiant/Makefile.am
Expand Up @@ -304,7 +304,6 @@ darkradiant_SOURCES = main.cpp \
map/infofile/InfoFile.cpp \
map/infofile/InfoFileExporter.cpp \
map/MapFileManager.cpp \
map/algorithm/ChildPrimitives.cpp \
map/algorithm/Skins.cpp \
map/algorithm/Traverse.cpp \
map/algorithm/MapExporter.cpp \
Expand Down
2 changes: 1 addition & 1 deletion radiant/map/Map.cpp
Expand Up @@ -56,7 +56,7 @@
#include "MapPropertyInfoFileModule.h"

#include <fmt/format.h>
#include "algorithm/ChildPrimitives.h"
#include "scene/ChildPrimitives.h"

namespace map
{
Expand Down
4 changes: 2 additions & 2 deletions radiant/map/MapResource.cpp
Expand Up @@ -34,7 +34,7 @@
#include "algorithm/MapExporter.h"
#include "algorithm/Import.h"
#include "infofile/InfoFileExporter.h"
#include "algorithm/ChildPrimitives.h"
#include "scene/ChildPrimitives.h"
#include "messages/MapFileOperation.h"

namespace map
Expand Down Expand Up @@ -330,7 +330,7 @@ bool MapResource::loadFile(std::istream& mapStream, const MapFormat& format, con
reader->readFromStream(mapStream);

// Prepare child primitives
addOriginToChildPrimitives(root);
scene::addOriginToChildPrimitives(root);

if (!format.allowInfoFileCreation())
{
Expand Down
4 changes: 2 additions & 2 deletions radiant/map/algorithm/Import.cpp
Expand Up @@ -11,7 +11,7 @@
#include "ientity.h"
#include "iscenegraph.h"
#include "scene/BasicRootNode.h"
#include "map/algorithm/ChildPrimitives.h"
#include "scene/ChildPrimitives.h"
#include "map/Map.h"
#include "scenelib.h"
#include "entitylib.h"
Expand Down Expand Up @@ -355,7 +355,7 @@ void importFromStream(std::istream& stream)
reader->readFromStream(stream);

// Prepare child primitives
addOriginToChildPrimitives(importFilter.getRootNode());
scene::addOriginToChildPrimitives(importFilter.getRootNode());

// Adjust all new names to fit into the existing map namespace
prepareNamesForImport(GlobalMap().getRoot(), importFilter.getRootNode());
Expand Down
4 changes: 2 additions & 2 deletions radiant/map/algorithm/MapExporter.cpp
Expand Up @@ -13,7 +13,7 @@
#include "registry/registry.h"
#include "string/string.h"

#include "ChildPrimitives.h"
#include "scene/ChildPrimitives.h"
#include "messages/MapFileOperation.h"

namespace map
Expand Down Expand Up @@ -258,7 +258,7 @@ void MapExporter::finishScene()
// Emit the post-export event to give subscribers a chance to cleanup the scene
GlobalMapResourceManager().signal_onResourceExported().emit(_root);

addOriginToChildPrimitives(_root);
scene::addOriginToChildPrimitives(_root);

// Re-evaluate all brushes, to update the Winding calculations
recalculateBrushWindings();
Expand Down
2 changes: 0 additions & 2 deletions tools/msvc/DarkRadiant.vcxproj
Expand Up @@ -211,7 +211,6 @@
<ClCompile Include="..\..\radiant\map\aas\Doom3AasFile.cpp" />
<ClCompile Include="..\..\radiant\map\aas\Doom3AasFileLoader.cpp" />
<ClCompile Include="..\..\radiant\map\aas\Doom3AasFileSettings.cpp" />
<ClCompile Include="..\..\radiant\map\algorithm\ChildPrimitives.cpp" />
<ClCompile Include="..\..\radiant\map\algorithm\Export.cpp" />
<ClCompile Include="..\..\radiant\map\algorithm\Import.cpp" />
<ClCompile Include="..\..\radiant\map\algorithm\MapExporter.cpp" />
Expand Down Expand Up @@ -912,7 +911,6 @@
<ClInclude Include="..\..\radiant\map\aas\Doom3AasFileLoader.h" />
<ClInclude Include="..\..\radiant\map\aas\Doom3AasFileSettings.h" />
<ClInclude Include="..\..\radiant\map\aas\Util.h" />
<ClInclude Include="..\..\radiant\map\algorithm\ChildPrimitives.h" />
<ClInclude Include="..\..\radiant\map\algorithm\Export.h" />
<ClInclude Include="..\..\radiant\map\algorithm\Import.h" />
<ClInclude Include="..\..\radiant\map\algorithm\MapExporter.h" />
Expand Down
6 changes: 0 additions & 6 deletions tools/msvc/DarkRadiant.vcxproj.filters
Expand Up @@ -634,9 +634,6 @@
<ClCompile Include="..\..\radiant\map\algorithm\MapExporter.cpp">
<Filter>src\map\algorithm</Filter>
</ClCompile>
<ClCompile Include="..\..\radiant\map\algorithm\ChildPrimitives.cpp">
<Filter>src\map\algorithm</Filter>
</ClCompile>
<ClCompile Include="..\..\radiant\map\algorithm\MapImporter.cpp">
<Filter>src\map\algorithm</Filter>
</ClCompile>
Expand Down Expand Up @@ -1632,9 +1629,6 @@
<ClInclude Include="..\..\radiant\map\algorithm\MapExporter.h">
<Filter>src\map\algorithm</Filter>
</ClInclude>
<ClInclude Include="..\..\radiant\map\algorithm\ChildPrimitives.h">
<Filter>src\map\algorithm</Filter>
</ClInclude>
<ClInclude Include="..\..\radiant\map\algorithm\MapImporter.h">
<Filter>src\map\algorithm</Filter>
</ClInclude>
Expand Down
2 changes: 2 additions & 0 deletions tools/msvc/scenelib.vcxproj
Expand Up @@ -114,6 +114,7 @@
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\libs\scene\ChildPrimitives.cpp" />
<ClCompile Include="..\..\libs\scene\InstanceWalkers.cpp" />
<ClCompile Include="..\..\libs\scene\LayerUsageBreakdown.cpp" />
<ClCompile Include="..\..\libs\scene\Node.cpp" />
Expand All @@ -123,6 +124,7 @@
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\libs\scene\BasicRootNode.h" />
<ClInclude Include="..\..\libs\scene\ChildPrimitives.h" />
<ClInclude Include="..\..\libs\scene\InstanceWalkers.h" />
<ClInclude Include="..\..\libs\scene\LayerUsageBreakdown.h" />
<ClInclude Include="..\..\libs\scene\LayerValidityCheckWalker.h" />
Expand Down
6 changes: 6 additions & 0 deletions tools/msvc/scenelib.vcxproj.filters
Expand Up @@ -24,6 +24,9 @@
<ClCompile Include="..\..\libs\scene\LayerUsageBreakdown.cpp">
<Filter>scene</Filter>
</ClCompile>
<ClCompile Include="..\..\libs\scene\ChildPrimitives.cpp">
<Filter>scene</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\libs\scene\InstanceWalkers.h">
Expand Down Expand Up @@ -52,5 +55,8 @@
<ClInclude Include="..\..\libs\scene\LayerUsageBreakdown.h">
<Filter>scene</Filter>
</ClInclude>
<ClInclude Include="..\..\libs\scene\ChildPrimitives.h">
<Filter>scene</Filter>
</ClInclude>
</ItemGroup>
</Project>

0 comments on commit 78d1019

Please sign in to comment.