#include "texturelib.h"
#include "container/container.h"
#include "generic/bitfield.h"
+#include "signal/signalfwd.h"
#include "winding.h"
#include "brush_primit.h"
-#define CONTENTS_DETAIL 0x8000000
-
+const unsigned int BRUSH_DETAIL_FLAG = 27;
+const unsigned int BRUSH_DETAIL_MASK = (1 << BRUSH_DETAIL_FLAG);
enum EBrushType
{
#endif
}
-const Colour4b colour_vertex(0, 255, 0, 255);
-
#include "shaderlib.h"
bool m_specified;
};
-inline unsigned int ContentFlags_assignable(unsigned int contentFlags)
-{
- return contentFlags & ~CONTENTS_DETAIL;
-}
-
-inline ContentsFlagsValue ContentsFlagsValue_maskDetail(const ContentsFlagsValue& other)
+inline void ContentsFlagsValue_assignMasked(ContentsFlagsValue& flags, const ContentsFlagsValue& other)
{
- return ContentsFlagsValue(other.m_surfaceFlags, ContentFlags_assignable(other.m_contentFlags), other.m_value, other.m_specified);
+ bool detail = bitfield_enabled(flags.m_contentFlags, BRUSH_DETAIL_MASK);
+ flags = other;
+ if(detail)
+ {
+ flags.m_contentFlags = bitfield_enable(flags.m_contentFlags, BRUSH_DETAIL_MASK);
+ }
+ else
+ {
+ flags.m_contentFlags = bitfield_disable(flags.m_contentFlags, BRUSH_DETAIL_MASK);
+ }
}
void setFlags(const ContentsFlagsValue& flags)
{
ASSERT_MESSAGE(m_realised, "FaceShader::setFlags: flags not valid when unrealised");
- m_flags = ContentsFlagsValue_maskDetail(flags);
+ ContentsFlagsValue_assignMasked(m_flags, flags);
}
Shader* state() const
};
-inline void FaceShader_getFlags(const FaceShader& faceShader, ContentsFlagsValue& flags)
-{
- flags = faceShader.getFlags();
-}
-
-
-
class FaceTexdef : public FaceShaderObserver
}
};
-inline void FaceTexdef_getTexdef(const FaceTexdef& faceTexdef, TextureProjection& projection)
-{
- projection = faceTexdef.normalised();
-}
-
inline void planepts_print(const PlanePoints& planePoints, TextOutputStream& ostream)
{
ostream << "( " << planePoints[0][0] << " " << planePoints[0][1] << " " << planePoints[0][2] << " ) "
}
};
+inline void Winding_testSelect(Winding& winding, SelectionTest& test, SelectionIntersection& best)
+{
+ test.TestPolygon(VertexPointer(reinterpret_cast<VertexPointer::pointer>(&winding.points.data()->vertex), sizeof(WindingVertex)), winding.numpoints, best);
+}
const double GRID_MIN = 0.125;
};
bool face_filtered(Face& face);
+void add_face_filter(FaceFilter& filter, int mask, bool invert = false);
-void Brush_addTextureChangedCallback(const Callback& callback);
+void Brush_addTextureChangedCallback(const SignalHandler& callback);
void Brush_textureChanged();
}
}
-
void testSelect(SelectionTest& test, SelectionIntersection& best)
{
- test.TestPolygon(VertexPointer(reinterpret_cast<VertexPointer::pointer>(&m_winding.points.data()->vertex), sizeof(WindingVertex)), m_winding.numpoints, best);
+ Winding_testSelect(m_winding, test, best);
}
void testSelect_centroid(SelectionTest& test, SelectionIntersection& best)
Brush_textureChanged();
m_observer->shaderChanged();
updateFiltered();
+ planeChanged();
SceneChangeNotify();
}
Brush_textureChanged();
}
+ void GetTexdef(TextureProjection& projection) const
+ {
+ projection = m_texdef.normalised();
+ }
void SetTexdef(const TextureProjection& projection)
{
undoSave();
texdefChanged();
}
+ void GetFlags(ContentsFlagsValue& flags) const
+ {
+ flags = m_shader.getFlags();
+ }
void SetFlags(const ContentsFlagsValue& flags)
{
undoSave();
bool isDetail() const
{
- return (m_shader.m_flags.m_contentFlags & CONTENTS_DETAIL) != 0;
+ return (m_shader.m_flags.m_contentFlags & BRUSH_DETAIL_MASK) != 0;
}
void setDetail(bool detail)
{
undoSave();
if(detail && !isDetail())
{
- m_shader.m_flags.m_contentFlags |= CONTENTS_DETAIL;
+ m_shader.m_flags.m_contentFlags |= BRUSH_DETAIL_MASK;
}
else if(!detail && isDetail())
{
- m_shader.m_flags.m_contentFlags &= ~CONTENTS_DETAIL;
+ m_shader.m_flags.m_contentFlags &= ~BRUSH_DETAIL_MASK;
}
m_observer->shaderChanged();
}
m_render_faces(m_faceCentroidPoints, GL_POINTS),
m_render_vertices(m_uniqueVertexPoints, GL_POINTS),
m_render_edges(m_uniqueEdgePoints, GL_POINTS),
- m_planeChanged(false),
- m_transformChanged(false),
m_evaluateTransform(evaluateTransform),
- m_boundsChanged(boundsChanged)
+ m_boundsChanged(boundsChanged),
+ m_planeChanged(false),
+ m_transformChanged(false)
{
planeChanged();
}
m_render_faces(m_faceCentroidPoints, GL_POINTS),
m_render_vertices(m_uniqueVertexPoints, GL_POINTS),
m_render_edges(m_uniqueEdgePoints, GL_POINTS),
- m_planeChanged(false),
- m_transformChanged(false),
m_evaluateTransform(evaluateTransform),
- m_boundsChanged(boundsChanged)
+ m_boundsChanged(boundsChanged),
+ m_planeChanged(false),
+ m_transformChanged(false)
{
copy(other);
}
TransformNode(other),
Bounded(other),
Cullable(other),
+ Snappable(),
Undoable(other),
FaceObserver(other),
Filterable(other),
void shaderChanged()
{
updateFiltered();
+ planeChanged();
}
void evaluateBRep() const
{
return m_faces.back();
}
- void reserve(std::size_t size)
+ void reserve(std::size_t count)
{
- m_faces.reserve(size);
+ m_faces.reserve(count);
for(Observers::iterator i = m_observers.begin(); i != m_observers.end(); ++i)
{
- (*i)->reserve(size);
+ (*i)->reserve(count);
}
}
void push_back(Faces::value_type face)
void clear()
{
+ undoSave();
if(m_instanceCounter.m_count != 0)
{
forEachFace_instanceDetach(m_map);
m_face->getWinding()[2].vertex
),
"update_move_planepts_vertex2: error"
- )
+ );
m_face->m_move_planepts[0] = m_face->getWinding()[opposite].vertex;
m_face->m_move_planepts[1] = m_face->getWinding()[index].vertex;
}
typedef MemberCaller1<BrushInstance, const Selectable&, &BrushInstance::selectedChangedComponent> SelectedChangedComponentCaller;
- void forEachFaceInstance(const BrushInstanceVisitor& visitor)
+ const BrushInstanceVisitor& forEachFaceInstance(const BrushInstanceVisitor& visitor)
{
for(FaceInstances::iterator i = m_faceInstances.begin(); i != m_faceInstances.end(); ++i)
{
visitor.visit(*i);
}
+ return visitor;
}
static void constructStatic()
};
template<typename Functor>
-inline void Scene_forEachSelectedBrush(const Functor& functor)
+inline const Functor& Scene_forEachSelectedBrush(const Functor& functor)
{
GlobalSelectionSystem().foreachSelected(BrushSelectedVisitor<Functor>(functor));
+ return functor;
}
template<typename Functor>
};
template<typename Functor>
-inline void Scene_forEachVisibleSelectedBrush(const Functor& functor)
+inline const Functor& Scene_forEachVisibleSelectedBrush(const Functor& functor)
{
GlobalSelectionSystem().foreachSelected(BrushVisibleSelectedVisitor<Functor>(functor));
+ return functor;
}
+class BrushForEachFace
+{
+ const BrushInstanceVisitor& m_visitor;
+public:
+ BrushForEachFace(const BrushInstanceVisitor& visitor) : m_visitor(visitor)
+ {
+ }
+ void operator()(BrushInstance& brush) const
+ {
+ brush.forEachFaceInstance(m_visitor);
+ }
+};
+
+template<class Functor>
+class FaceInstanceVisitFace : public BrushInstanceVisitor
+{
+ const Functor& functor;
+public:
+ FaceInstanceVisitFace(const Functor& functor)
+ : functor(functor)
+ {
+ }
+ void visit(FaceInstance& face) const
+ {
+ functor(face.getFace());
+ }
+};
+
+template<typename Functor>
+inline const Functor& Brush_forEachFace(BrushInstance& brush, const Functor& functor)
+{
+ brush.forEachFaceInstance(FaceInstanceVisitFace<Functor>(functor));
+ return functor;
+}
+
+template<class Functor>
+class FaceVisitAll : public BrushVisitor
+{
+ const Functor& functor;
+public:
+ FaceVisitAll(const Functor& functor)
+ : functor(functor)
+ {
+ }
+ void visit(Face& face) const
+ {
+ functor(face);
+ }
+};
+
+template<typename Functor>
+inline const Functor& Brush_forEachFace(const Brush& brush, const Functor& functor)
+{
+ brush.forEachFace(FaceVisitAll<Functor>(functor));
+ return functor;
+}
+
+template<typename Functor>
+inline const Functor& Brush_forEachFace(Brush& brush, const Functor& functor)
+{
+ brush.forEachFace(FaceVisitAll<Functor>(functor));
+ return functor;
+}
+
+template<class Functor>
+class FaceInstanceVisitAll : public BrushInstanceVisitor
+{
+ const Functor& functor;
+public:
+ FaceInstanceVisitAll(const Functor& functor)
+ : functor(functor)
+ {
+ }
+ void visit(FaceInstance& face) const
+ {
+ functor(face);
+ }
+};
+
+template<typename Functor>
+inline const Functor& Brush_ForEachFaceInstance(BrushInstance& brush, const Functor& functor)
+{
+ brush.forEachFaceInstance(FaceInstanceVisitAll<Functor>(functor));
+ return functor;
+}
+
+template<typename Functor>
+inline const Functor& Scene_forEachBrush(scene::Graph& graph, const Functor& functor)
+{
+ graph.traverse(InstanceWalker< InstanceApply<BrushInstance, Functor> >(functor));
+ return functor;
+}
+
+template<typename Type, typename Functor>
+class InstanceIfVisible : public Functor
+{
+public:
+ InstanceIfVisible(const Functor& functor) : Functor(functor)
+ {
+ }
+ void operator()(scene::Instance& instance)
+ {
+ if(instance.path().top().get().visible())
+ {
+ Functor::operator()(instance);
+ }
+ }
+};
+
+template<typename Functor>
+class BrushVisibleWalker : public scene::Graph::Walker
+{
+ const Functor& m_functor;
+public:
+ BrushVisibleWalker(const Functor& functor) : m_functor(functor)
+ {
+ }
+ bool pre(const scene::Path& path, scene::Instance& instance) const
+ {
+ if(path.top().get().visible())
+ {
+ BrushInstance* brush = Instance_getBrush(instance);
+ if(brush != 0)
+ {
+ m_functor(*brush);
+ }
+ }
+ return true;
+ }
+};
+
+template<typename Functor>
+inline const Functor& Scene_forEachVisibleBrush(scene::Graph& graph, const Functor& functor)
+{
+ graph.traverse(BrushVisibleWalker<Functor>(functor));
+ return functor;
+}
+
+template<typename Functor>
+inline const Functor& Scene_ForEachBrush_ForEachFace(scene::Graph& graph, const Functor& functor)
+{
+ Scene_forEachBrush(graph, BrushForEachFace(FaceInstanceVisitFace<Functor>(functor)));
+ return functor;
+}
+
+template<typename Functor>
+inline const Functor& Scene_ForEachSelectedBrush_ForEachFace(scene::Graph& graph, const Functor& functor)
+{
+ Scene_forEachSelectedBrush(BrushForEachFace(FaceInstanceVisitFace<Functor>(functor)));
+ return functor;
+}
+
+template<typename Functor>
+inline const Functor& Scene_ForEachSelectedBrush_ForEachFaceInstance(scene::Graph& graph, const Functor& functor)
+{
+ Scene_forEachSelectedBrush(BrushForEachFace(FaceInstanceVisitAll<Functor>(functor)));
+ return functor;
+}
+
+template<typename Functor>
+class FaceVisitorWrapper
+{
+ const Functor& functor;
+public:
+ FaceVisitorWrapper(const Functor& functor) : functor(functor)
+ {
+ }
+
+ void operator()(FaceInstance& faceInstance) const
+ {
+ functor(faceInstance.getFace());
+ }
+};
+
+template<typename Functor>
+inline const Functor& Scene_ForEachSelectedBrushFace(scene::Graph& graph, const Functor& functor)
+{
+ g_SelectedFaceInstances.foreach(FaceVisitorWrapper<Functor>(functor));
+ return functor;
+}
+
+
#endif