]> git.xonotic.org Git - xonotic/netradiant.git/blobdiff - radiant/patch.h
Merge branch 'master' into master-merge
[xonotic/netradiant.git] / radiant / patch.h
index a1f1d272a20a682bb987337d12f8f481925d787b..45d53fa845b85676ae2a6e9b1558713a13544127 100644 (file)
@@ -30,7 +30,7 @@
 /// The surface is recursively tesselated until the angle between each triangle
 /// edge is smaller than a specified tolerance.
 
-
+#include "globaldefs.h"
 #include "nameable.h"
 #include "ifilter.h"
 #include "imap.h"
@@ -317,7 +317,7 @@ void render( RenderStateFlags state ) const {
                }
        }
 
-#if defined( _DEBUG )
+#if GDEF_DEBUG
        RenderNormals();
 #endif
 }
@@ -447,8 +447,8 @@ RenderableIndexBuffer m_render_lattice;
 bool m_bOverlay;
 
 bool m_transformChanged;
-Callback m_evaluateTransform;
-Callback m_boundsChanged;
+Callback<void()> m_evaluateTransform;
+Callback<void()> m_boundsChanged;
 
 void construct(){
        m_bOverlay = false;
@@ -465,14 +465,14 @@ void construct(){
 }
 
 public:
-Callback m_lightsChanged;
+Callback<void()> m_lightsChanged;
 
 static int m_CycleCapIndex;  // = 0;
 static EPatchType m_type;
 
 STRING_CONSTANT( Name, "Patch" );
 
-Patch( scene::Node& node, const Callback& evaluateTransform, const Callback& boundsChanged ) :
+Patch( scene::Node& node, const Callback<void()>& evaluateTransform, const Callback<void()>& boundsChanged ) :
        m_node( &node ),
        m_shader( texdef_name_default() ),
        m_state( 0 ),
@@ -488,7 +488,7 @@ Patch( scene::Node& node, const Callback& evaluateTransform, const Callback& bou
        m_boundsChanged( boundsChanged ){
        construct();
 }
-Patch( const Patch& other, scene::Node& node, const Callback& evaluateTransform, const Callback& boundsChanged ) :
+Patch( const Patch& other, scene::Node& node, const Callback<void()>& evaluateTransform, const Callback<void()>& boundsChanged ) :
        m_node( &node ),
        m_shader( texdef_name_default() ),
        m_state( 0 ),
@@ -674,7 +674,7 @@ void transformChanged(){
        m_lightsChanged();
        SceneChangeNotify();
 }
-typedef MemberCaller<Patch, &Patch::transformChanged> TransformChangedCaller;
+typedef MemberCaller<Patch, void(), &Patch::transformChanged> TransformChangedCaller;
 
 void evaluateTransform(){
        if ( m_transformChanged ) {
@@ -880,6 +880,12 @@ const_iterator end() const {
 PatchControlArray& getControlPoints(){
        return m_ctrl;
 }
+
+// Same as above, just for const arguments
+const PatchControlArray& getControlPoints() const {
+       return m_ctrl;
+}
+
 PatchControlArray& getControlPointsTransformed(){
        return m_ctrlTransformed;
 }
@@ -916,6 +922,8 @@ void SetTextureRepeat( float s, float t ); // call with s=1 t=1 for FIT
 void CapTexture();
 void NaturalTexture();
 void ProjectTexture( int nAxis );
+void createThickenedOpposite(const Patch& sourcePatch, const float thickness, const int axis, bool& no12, bool& no34 );
+void createThickenedWall(const Patch& sourcePatch, const Patch& targetPatch, const int wallIndex);
 
 void undoSave(){
        if ( m_map != 0 ) {
@@ -1338,7 +1346,7 @@ typedef LazyStatic<TypeCasts> StaticTypeCasts;
 void lightsChanged(){
        m_lightList->lightsChanged();
 }
-typedef MemberCaller<PatchInstance, &PatchInstance::lightsChanged> LightsChangedCaller;
+typedef MemberCaller<PatchInstance, void(), &PatchInstance::lightsChanged> LightsChangedCaller;
 
 STRING_CONSTANT( Name, "PatchInstance" );
 
@@ -1358,9 +1366,9 @@ PatchInstance( const scene::Path& path, scene::Instance* parent, Patch& patch )
        Instance::setTransformChangedCallback( LightsChangedCaller( *this ) );
 }
 ~PatchInstance(){
-       Instance::setTransformChangedCallback( Callback() );
+       Instance::setTransformChangedCallback( Callback<void()>() );
 
-       m_patch.m_lightsChanged = Callback();
+       m_patch.m_lightsChanged = Callback<void()>();
        GlobalShaderCache().detach( *this );
 
        m_patch.detach( this );
@@ -1373,13 +1381,13 @@ void selectedChanged( const Selectable& selectable ){
 
        Instance::selectedChanged();
 }
-typedef MemberCaller1<PatchInstance, const Selectable&, &PatchInstance::selectedChanged> SelectedChangedCaller;
+typedef MemberCaller<PatchInstance, void(const Selectable&), &PatchInstance::selectedChanged> SelectedChangedCaller;
 
 void selectedChangedComponent( const Selectable& selectable ){
        GlobalSelectionSystem().getObserver ( SelectionSystem::eComponent )( selectable );
        GlobalSelectionSystem().onComponentSelection( *this, selectable );
 }
-typedef MemberCaller1<PatchInstance, const Selectable&, &PatchInstance::selectedChangedComponent> SelectedChangedComponentCaller;
+typedef MemberCaller<PatchInstance, void(const Selectable&), &PatchInstance::selectedChangedComponent> SelectedChangedComponentCaller;
 
 Patch& getPatch(){
        return m_patch;
@@ -1414,6 +1422,11 @@ void allocate( std::size_t size ){
 
 void setSelected( bool select ){
        m_selectable.setSelected( select );
+       if ( !select && parent() ){
+               Selectable* sel_parent = Instance_getSelectable( *parent() );
+               if ( sel_parent && sel_parent->isSelected() )
+                       sel_parent->setSelected( false );
+       }
 }
 bool isSelected() const {
        return m_selectable.isSelected();
@@ -1572,6 +1585,13 @@ void transformComponents( const Matrix4& matrix ){
        }
 }
 
+void invertComponentSelection(){
+       for ( PatchControlInstances::iterator i = m_ctrl_instances.begin(); i != m_ctrl_instances.end(); ++i )
+       {
+               ( *i ).m_selectable.setSelected( !( *i ).m_selectable.isSelected() );
+       }
+}
+
 
 void selectPlanes( Selector& selector, SelectionTest& test, const PlaneCallback& selectedPlaneCallback ){
        test.BeginMesh( localToWorld() );
@@ -1612,7 +1632,7 @@ void applyTransform(){
        evaluateTransform();
        m_patch.freezeTransform();
 }
-typedef MemberCaller<PatchInstance, &PatchInstance::applyTransform> ApplyTransformCaller;
+typedef MemberCaller<PatchInstance, void(), &PatchInstance::applyTransform> ApplyTransformCaller;
 
 
 bool testLight( const RendererLight& light ) const {
@@ -1802,6 +1822,9 @@ bool pre( const scene::Path& path, scene::Instance& instance ) const {
                        m_functor( *patch );
                }
        }
+       else{
+               return false;
+       }
        return true;
 }
 };
@@ -1826,6 +1849,9 @@ bool pre( const scene::Path& path, scene::Instance& instance ) const {
                        m_functor( *patch );
                }
        }
+       else{
+               return false;
+       }
        return true;
 }
 };
@@ -1849,6 +1875,9 @@ bool pre( const scene::Path& path, scene::Instance& instance ) const {
                        m_functor( *patch );
                }
        }
+       else{
+               return false;
+       }
        return true;
 }
 };