Skip to content

Commit

Permalink
#5410: When assigning textures to the selection, also include brushes…
Browse files Browse the repository at this point in the history
… that are otherwise filtered or invisible (but are visible due to their selection status)
  • Loading branch information
codereader committed Nov 16, 2020
1 parent ebc08f6 commit d7bb39e
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 11 deletions.
6 changes: 3 additions & 3 deletions libs/scene/Node.h
Expand Up @@ -99,9 +99,6 @@ class Node :
bool visible() const override;
bool excluded() const override;

// Set the "forced visible" flag, only to be used internally by subclasses
void setForcedVisibility(bool forceVisible, bool includeChildren) override;

// Layered implementation
virtual void addToLayer(int layerId) override;
virtual void removeFromLayer(int layerId) override;
Expand Down Expand Up @@ -198,6 +195,9 @@ class Node :
virtual void setRenderSystem(const RenderSystemPtr& renderSystem) override;

protected:
// Set the "forced visible" flag, only to be used internally by subclasses
void setForcedVisibility(bool forceVisible, bool includeChildren) override;

// Method for subclasses to check whether this node is forcedly visible
bool isForcedVisible() const;

Expand Down
3 changes: 3 additions & 0 deletions libs/selectionlib.h
Expand Up @@ -4,6 +4,7 @@
#include "iselection.h"
#include "ibrush.h"
#include "igroupnode.h"
#include "iscenegraph.h"
#include "ientity.h"
#include "ipatch.h"
#include "math/Vector3.h"
Expand Down Expand Up @@ -185,6 +186,8 @@ inline void applyShaderToSelection(const std::string& shaderName)
{
GlobalSelectionSystem().foreachFace([&](IFace& face) { face.setShader(shaderName); });
GlobalSelectionSystem().foreachPatch([&](IPatch& patch) { patch.setShader(shaderName); });

SceneChangeNotify();
}

/**
Expand Down
13 changes: 13 additions & 0 deletions radiantcore/brush/Brush.cpp
Expand Up @@ -129,6 +129,19 @@ void Brush::forEachFace(const std::function<void(Face&)>& functor) const
for (const FacePtr& face : m_faces) functor(*face);
}

void Brush::forEachVisibleFace(const std::function<void(Face&)>& functor) const
{
bool forceVisible = _owner.facesAreForcedVisible();

for (const auto& face : m_faces)
{
if (forceVisible || face->isVisible())
{
functor(*face);
}
}
}

void Brush::connectUndoSystem(IMapFileChangeTracker& changeTracker)
{
assert(_undoStateSaver == nullptr);
Expand Down
4 changes: 4 additions & 0 deletions radiantcore/brush/Brush.h
Expand Up @@ -173,6 +173,10 @@ class Brush :

void forEachFace(const std::function<void(Face&)>& functor) const;

// Call the functor for each visible face (including those faces that are filtered out
// but are forcedly visible due to the brush being selected)
void forEachVisibleFace(const std::function<void(Face&)>& functor) const;

void connectUndoSystem(IMapFileChangeTracker& map);
void disconnectUndoSystem(IMapFileChangeTracker& map);

Expand Down
5 changes: 5 additions & 0 deletions radiantcore/brush/BrushNode.cpp
Expand Up @@ -572,6 +572,11 @@ const Vector3& BrushNode::getUntransformedOrigin()
return _untransformedOrigin;
}

bool BrushNode::facesAreForcedVisible()
{
return isForcedVisible();
}

void BrushNode::_onTransformationChanged()
{
m_brush.transformChanged();
Expand Down
5 changes: 5 additions & 0 deletions radiantcore/brush/BrushNode.h
Expand Up @@ -165,6 +165,11 @@ class BrushNode :
// Returns the center of the untransformed world AABB
const Vector3& getUntransformedOrigin() override;

// Returns true if this node is visible due to its selection status
// even though it might otherwise be filtered or hidden
// Should only be used by the internal Brush object
bool facesAreForcedVisible();

protected:
// Gets called by the Transformable implementation whenever
// scale, rotation or translation is changed.
Expand Down
10 changes: 2 additions & 8 deletions radiantcore/selection/SceneWalkers.h
Expand Up @@ -193,15 +193,9 @@ class FaceSelectionWalker :
{
Brush* brush = Node_getBrush(node);

if (brush != NULL)
if (brush != nullptr)
{
brush->forEachFace([&] (Face& face)
{
if (face.isVisible())
{
_functor(face);
}
});
brush->forEachVisibleFace(_functor);
}
}
};

0 comments on commit d7bb39e

Please sign in to comment.