X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=radiant%2Fbrushnode.h;h=ac899d9b3a1fc4baa3a38f18349af4eaa99a19c3;hb=e47e3afa806ffd805f91734dcd3cfcd68ad8d7b4;hp=ad6b636ad45555840c16e04e0adc0725e6e5386c;hpb=02a51890a3d97a0e937fbb11071cf7c41cc00aa9;p=xonotic%2Fnetradiant.git diff --git a/radiant/brushnode.h b/radiant/brushnode.h index ad6b636a..ac899d9b 100644 --- a/radiant/brushnode.h +++ b/radiant/brushnode.h @@ -28,155 +28,119 @@ #include "brushxml.h" class BrushNode : - public scene::Node::Symbiot, - public scene::Instantiable, - public scene::Cloneable { - class TypeCasts { - NodeTypeCastTable m_casts; - public: - TypeCasts() - { - NodeStaticCast::install(m_casts); - NodeStaticCast::install(m_casts); - NodeContainedCast::install(m_casts); - NodeContainedCast::install(m_casts); - NodeContainedCast::install(m_casts); - NodeContainedCast::install(m_casts); - NodeContainedCast::install(m_casts); - NodeContainedCast::install(m_casts); - NodeContainedCast::install(m_casts); - NodeContainedCast::install(m_casts); - NodeContainedCast::install(m_casts); - } - - NodeTypeCastTable &get() - { - return m_casts; - } - }; - - - scene::Node m_node; - InstanceSet m_instances; - Brush m_brush; - BrushTokenImporter m_mapImporter; - BrushTokenExporter m_mapExporter; - BrushXMLImporter m_xmlImporter; - BrushXMLExporter m_xmlExporter; + public scene::Node::Symbiot, + public scene::Instantiable, + public scene::Cloneable +{ +class TypeCasts +{ +NodeTypeCastTable m_casts; +public: +TypeCasts(){ + NodeStaticCast::install( m_casts ); + NodeStaticCast::install( m_casts ); + NodeContainedCast::install( m_casts ); + NodeContainedCast::install( m_casts ); + NodeContainedCast::install( m_casts ); + NodeContainedCast::install( m_casts ); + NodeContainedCast::install( m_casts ); + NodeContainedCast::install( m_casts ); + NodeContainedCast::install( m_casts ); + NodeContainedCast::install( m_casts ); + NodeContainedCast::install( m_casts ); +} +NodeTypeCastTable& get(){ + return m_casts; +} +}; + + +scene::Node m_node; +InstanceSet m_instances; +Brush m_brush; +BrushTokenImporter m_mapImporter; +BrushTokenExporter m_mapExporter; +BrushXMLImporter m_xmlImporter; +BrushXMLExporter m_xmlExporter; public: - typedef LazyStatic StaticTypeCasts; - - Snappable &get(NullType) - { - return m_brush; - } - - TransformNode &get(NullType) - { - return m_brush; - } - - Brush &get(NullType) - { - return m_brush; - } - - XMLImporter &get(NullType) - { - return m_xmlImporter; - } - - XMLExporter &get(NullType) - { - return m_xmlExporter; - } - - MapImporter &get(NullType) - { - return m_mapImporter; - } - - MapExporter &get(NullType) - { - return m_mapExporter; - } - - Nameable &get(NullType) - { - return m_brush; - } - - BrushDoom3 &get(NullType) - { - return m_brush; - } - - BrushNode() : - m_node(this, this, StaticTypeCasts::instance().get()), - m_brush(m_node, InstanceSetEvaluateTransform::Caller(m_instances), - InstanceSet::BoundsChangedCaller(m_instances)), - m_mapImporter(m_brush), - m_mapExporter(m_brush), - m_xmlImporter(m_brush), - m_xmlExporter(m_brush) - { - } - - BrushNode(const BrushNode &other) : - scene::Node::Symbiot(other), - scene::Instantiable(other), - scene::Cloneable(other), - m_node(this, this, StaticTypeCasts::instance().get()), - m_brush(other.m_brush, m_node, InstanceSetEvaluateTransform::Caller(m_instances), - InstanceSet::BoundsChangedCaller(m_instances)), - m_mapImporter(m_brush), - m_mapExporter(m_brush), - m_xmlImporter(m_brush), - m_xmlExporter(m_brush) - { - } - - void release() - { - delete this; - } - - scene::Node &node() - { - return m_node; - } - - scene::Node &clone() const - { - return (new BrushNode(*this))->node(); - } - - scene::Instance *create(const scene::Path &path, scene::Instance *parent) - { - return new BrushInstance(path, parent, m_brush); - } - - void forEachInstance(const scene::Instantiable::Visitor &visitor) - { - m_instances.forEachInstance(visitor); - } - - void insert(scene::Instantiable::Observer *observer, const scene::Path &path, scene::Instance *instance) - { - m_instances.insert(observer, path, instance); - } - - scene::Instance *erase(scene::Instantiable::Observer *observer, const scene::Path &path) - { - return m_instances.erase(observer, path); - } +typedef LazyStatic StaticTypeCasts; + +Snappable& get( NullType){ + return m_brush; +} +TransformNode& get( NullType){ + return m_brush; +} +Brush& get( NullType){ + return m_brush; +} +XMLImporter& get( NullType){ + return m_xmlImporter; +} +XMLExporter& get( NullType){ + return m_xmlExporter; +} +MapImporter& get( NullType){ + return m_mapImporter; +} +MapExporter& get( NullType){ + return m_mapExporter; +} +Nameable& get( NullType){ + return m_brush; +} +BrushDoom3& get( NullType){ + return m_brush; +} + +BrushNode() : + m_node( this, this, StaticTypeCasts::instance().get() ), + m_brush( m_node, InstanceSetEvaluateTransform::Caller( m_instances ), InstanceSet::BoundsChangedCaller( m_instances ) ), + m_mapImporter( m_brush ), + m_mapExporter( m_brush ), + m_xmlImporter( m_brush ), + m_xmlExporter( m_brush ){ +} +BrushNode( const BrushNode& other ) : + scene::Node::Symbiot( other ), + scene::Instantiable( other ), + scene::Cloneable( other ), + m_node( this, this, StaticTypeCasts::instance().get() ), + m_brush( other.m_brush, m_node, InstanceSetEvaluateTransform::Caller( m_instances ), InstanceSet::BoundsChangedCaller( m_instances ) ), + m_mapImporter( m_brush ), + m_mapExporter( m_brush ), + m_xmlImporter( m_brush ), + m_xmlExporter( m_brush ){ +} +void release(){ + delete this; +} +scene::Node& node(){ + return m_node; +} + +scene::Node& clone() const { + return ( new BrushNode( *this ) )->node(); +} + +scene::Instance* create( const scene::Path& path, scene::Instance* parent ){ + return new BrushInstance( path, parent, m_brush ); +} +void forEachInstance( const scene::Instantiable::Visitor& visitor ){ + m_instances.forEachInstance( visitor ); +} +void insert( scene::Instantiable::Observer* observer, const scene::Path& path, scene::Instance* instance ){ + m_instances.insert( observer, path, instance ); +} +scene::Instance* erase( scene::Instantiable::Observer* observer, const scene::Path& path ){ + return m_instances.erase( observer, path ); +} }; -inline Brush *Node_getBrush(scene::Node &node) -{ - return NodeTypeCast::cast(node); +inline Brush* Node_getBrush( scene::Node& node ){ + return NodeTypeCast::cast( node ); } #endif