]> de.git.xonotic.org Git - xonotic/netradiant.git/commitdiff
refactored plugin api; refactored callback library; added signals library
authorspog <spog>
Sun, 9 Apr 2006 17:15:13 +0000 (17:15 +0000)
committerspog <spog>
Sun, 9 Apr 2006 17:15:13 +0000 (17:15 +0000)
git-svn-id: svn://svn.icculus.org/gtkradiant/GtkRadiant/trunk@44 8a3a26a2-13c4-0310-b231-cf6edde360e5

127 files changed:
CHANGES
GtkRadiant.sln
contrib/bobtoolz/CPortals.h
contrib/bobtoolz/DBobView.cpp
contrib/bobtoolz/DBobView.h
contrib/bobtoolz/DBrush.cpp
contrib/bobtoolz/DBrush.h
contrib/bobtoolz/DEPair.cpp
contrib/bobtoolz/DEPair.h
contrib/bobtoolz/DEntity.cpp
contrib/bobtoolz/DEntity.h
contrib/bobtoolz/DListener.cpp
contrib/bobtoolz/DMap.cpp
contrib/bobtoolz/DMap.h
contrib/bobtoolz/DPatch.cpp
contrib/bobtoolz/DPatch.h
contrib/bobtoolz/DPlane.cpp
contrib/bobtoolz/DPlane.h
contrib/bobtoolz/DPoint.cpp
contrib/bobtoolz/DPoint.h
contrib/bobtoolz/DShape.cpp
contrib/bobtoolz/DShape.h
contrib/bobtoolz/DTrainDrawer.cpp
contrib/bobtoolz/DTrainDrawer.h
contrib/bobtoolz/DTreePlanter.cpp
contrib/bobtoolz/DTreePlanter.h
contrib/bobtoolz/DVisDrawer.cpp
contrib/bobtoolz/DVisDrawer.h
contrib/bobtoolz/DWinding.cpp
contrib/bobtoolz/DWinding.h
contrib/bobtoolz/ScriptParser.cpp
contrib/bobtoolz/StdAfx.h
contrib/bobtoolz/bobToolz-GTK.cpp
contrib/bobtoolz/bobToolz.def
contrib/bobtoolz/bsploader.cpp
contrib/bobtoolz/bsploader.h
contrib/bobtoolz/cportals.cpp
contrib/bobtoolz/dialogs/dialogs-gtk.cpp
contrib/bobtoolz/dialogs/dialogs-gtk.h
contrib/bobtoolz/funchandlers-GTK.cpp
contrib/bobtoolz/funchandlers.cpp
contrib/bobtoolz/lists.cpp
contrib/bobtoolz/lists.h
contrib/bobtoolz/misc.cpp
contrib/bobtoolz/misc.h
contrib/bobtoolz/shapes.cpp
contrib/bobtoolz/shapes.h
contrib/bobtoolz/visfind.cpp
contrib/bobtoolz/visfind.h
contrib/gtkgensurf/genmap.cpp
contrib/prtview/portals.cpp
include/ibrush.h
include/icamera.h
include/ientity.h
include/ifilesystem.h
include/irender.h
include/iscenegraph.h
include/iselection.h
include/ishaders.h
include/iundo.h
include/mapfile.h
include/modelskin.h
include/nameable.h
include/namespace.h
include/preferencesystem.h
include/qerplugin.h
include/selectable.h
libs/container/hashtable.h
libs/debugging/debugging.h
libs/entitylib.h
libs/generic/callback.cpp
libs/generic/callback.h
libs/generic/callbackfwd.cpp [new file with mode: 0644]
libs/generic/callbackfwd.h [new file with mode: 0644]
libs/generic/functional.cpp [new file with mode: 0644]
libs/generic/functional.h [new file with mode: 0644]
libs/gtkutil/button.h
libs/gtkutil/menu.h
libs/gtkutil/toolbar.h
libs/libs.vcproj
libs/math/vector.h
libs/signal/isignal.cpp [new file with mode: 0644]
libs/signal/isignal.h [new file with mode: 0644]
libs/signal/signal.cpp [new file with mode: 0644]
libs/signal/signal.h [new file with mode: 0644]
libs/signal/signalfwd.cpp [new file with mode: 0644]
libs/signal/signalfwd.h [new file with mode: 0644]
libs/xml/xmlelement.h
plugins/entity/curve.h
plugins/entity/doom3group.cpp
plugins/entity/keyobservers.h
plugins/entity/namekeys.h
plugins/entity/targetable.h
radiant/brush.cpp
radiant/brush.h
radiant/brushmanip.cpp
radiant/brushmanip.h
radiant/brushmodule.cpp
radiant/camwindow.cpp
radiant/camwindow.h
radiant/csg.cpp
radiant/dialog.cpp
radiant/dialog.h
radiant/eclass_xml.cpp
radiant/grid.cpp
radiant/grid.h
radiant/mainframe.cpp
radiant/mainframe.h
radiant/map.cpp
radiant/map.h
radiant/patch.cpp
radiant/patch.h
radiant/patchdialog.cpp
radiant/plugin.cpp
radiant/preferences.h
radiant/scenegraph.cpp
radiant/select.cpp
radiant/selection.cpp
radiant/selection.h
radiant/surfacedialog.cpp
radiant/textureentry.h
radiant/textures.h
radiant/texwindow.cpp
radiant/texwindow.h
radiant/undo.cpp
radiant/xywindow.cpp
radiant/xywindow.h

diff --git a/CHANGES b/CHANGES
index 3ab71a63a3eb6ef7cfc0bd28113bb7dcf05c73cc..a7b3a7fdaaf5e48325ffde77557375d14940997c 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,14 @@
 This is the changelog for developers, != changelog for the end user 
 that we distribute with the binaries. (see changelog)
 
 This is the changelog for developers, != changelog for the end user 
 that we distribute with the binaries. (see changelog)
 
+01/04/2006
+SPoG
+- Added key-observer interface to entity module API.
+- Rewrote callback library to add support for return-values.
+- Added minimal API to support bobtoolz plugin.
+- Refactored brush for-each functions to take Functor instead of Visitor.
+- Added signals library.
+
 31/03/2006
 SPoG
 - Changed doom3 light creation to use size of selected brushes.
 31/03/2006
 SPoG
 - Changed doom3 light creation to use size of selected brushes.
index 7ee5bd3916b3ecbc85b398ca42ff07d4fa9d4312..2eacd630346c7f790696c5d1a825419060472e5c 100644 (file)
@@ -146,6 +146,10 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PrtView", "contrib\prtview\
                {853632F4-6420-40C5-B80B-38B678E472B8} = {853632F4-6420-40C5-B80B-38B678E472B8}\r
        EndProjectSection\r
 EndProject\r
                {853632F4-6420-40C5-B80B-38B678E472B8} = {853632F4-6420-40C5-B80B-38B678E472B8}\r
        EndProjectSection\r
 EndProject\r
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bobtoolz", "contrib\bobtoolz\bobtoolz.vcproj", "{B20364D1-4329-4D4E-B9CE-C9767618FDD6}"\r
+       ProjectSection(ProjectDependencies) = postProject\r
+       EndProjectSection\r
+EndProject\r
 Global\r
        GlobalSection(SolutionConfiguration) = preSolution\r
                Debug = Debug\r
 Global\r
        GlobalSection(SolutionConfiguration) = preSolution\r
                Debug = Debug\r
@@ -272,6 +276,10 @@ Global
                {B20364D1-4329-4D4E-B9CE-C9767618FDD6}.Debug.Build.0 = Debug|Win32\r
                {B20364D1-4329-4D4E-B9CE-C9767618FDD6}.Release.ActiveCfg = Release|Win32\r
                {B20364D1-4329-4D4E-B9CE-C9767618FDD6}.Release.Build.0 = Release|Win32\r
                {B20364D1-4329-4D4E-B9CE-C9767618FDD6}.Debug.Build.0 = Debug|Win32\r
                {B20364D1-4329-4D4E-B9CE-C9767618FDD6}.Release.ActiveCfg = Release|Win32\r
                {B20364D1-4329-4D4E-B9CE-C9767618FDD6}.Release.Build.0 = Release|Win32\r
+               {B20364D1-4329-4D4E-B9CE-C9767618FDD6}.Debug.ActiveCfg = Debug|Win32\r
+               {B20364D1-4329-4D4E-B9CE-C9767618FDD6}.Debug.Build.0 = Debug|Win32\r
+               {B20364D1-4329-4D4E-B9CE-C9767618FDD6}.Release.ActiveCfg = Release|Win32\r
+               {B20364D1-4329-4D4E-B9CE-C9767618FDD6}.Release.Build.0 = Release|Win32\r
        EndGlobalSection\r
        GlobalSection(ExtensibilityGlobals) = postSolution\r
        EndGlobalSection\r
        EndGlobalSection\r
        GlobalSection(ExtensibilityGlobals) = postSolution\r
        EndGlobalSection\r
index baab0a7519bd045f8963438b52451d532c2a1b62..71f399b71eb1cf5ab741be89babad6e5c2c2c379 100644 (file)
@@ -17,8 +17,6 @@ License along with this library; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
 
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
 
-#include "StdAfx.h"    // Added by ClassView
-
 class CBspPoint {
 public:
        float p[3];
 class CBspPoint {
 public:
        float p[3];
@@ -47,6 +45,8 @@ public:
 };
 
 
 };
 
 
+#define NAME_MAX 255
+
 class CPortals {
 public:
 
 class CPortals {
 public:
 
index f4d36de432c37878af681e78e53a09158c8331ad..c5de46f6c527abf501abb19f6551b7affee68b41 100644 (file)
@@ -21,16 +21,21 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 //
 //////////////////////////////////////////////////////////////////////
 
 //
 //////////////////////////////////////////////////////////////////////
 
-#include "StdAfx.h"
 #include "DBobView.h"
 #include "DBobView.h"
-#include "DListener.h"
 //#include "misc.h"
 #include "funchandlers.h"
 
 //#include "misc.h"
 #include "funchandlers.h"
 
-#include "gtkr_list.h"
+#include <list>
+
+#include "iglrender.h"
+#include "qerplugin.h"
 #include "str.h"
 #include "str.h"
+#include "math/matrix.h"
 
 
+#include "DEntity.h"
+#include "DEPair.h"
 #include "misc.h"
 #include "misc.h"
+#include "dialogs/dialogs-gtk.h"
 
 //////////////////////////////////////////////////////////////////////
 // Construction/Destruction
 
 //////////////////////////////////////////////////////////////////////
 // Construction/Destruction
@@ -39,28 +44,22 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 DBobView::DBobView()
 {
        nPathCount = 0;
 DBobView::DBobView()
 {
        nPathCount = 0;
-       refCount = 1;
        
        
-       m_bHooked = FALSE;
-
        path = NULL;
        path = NULL;
-       eyes = NULL;
 
        boundingShow = BOUNDS_APEX;
 
        boundingShow = BOUNDS_APEX;
+
+  constructShaders();
+  GlobalShaderCache().attachRenderable(*this);
 }
 
 DBobView::~DBobView()
 {
 }
 
 DBobView::~DBobView()
 {
-       if(path)
-               delete[] path;
-
-       // oops forgot to remove our eyes, was causing access violation when it tried
-       // to talk to it's parent
-       if(eyes)
-               delete eyes;
+  GlobalShaderCache().detachRenderable(*this);
+  destroyShaders();
 
 
-       if(m_bHooked)
-               UnRegister();
+  if(path)
+               delete[] path;
 
        g_PathView = NULL;
 }
 
        g_PathView = NULL;
 }
@@ -69,201 +68,77 @@ DBobView::~DBobView()
 // Implementation
 //////////////////////////////////////////////////////////////////////
 
 // Implementation
 //////////////////////////////////////////////////////////////////////
 
-void DBobView::Draw2D(VIEWTYPE vt)
+void DBobView::render(RenderStateFlags state) const
 {
 {
-       if(!path)
-               return;
-
-       __QGLTABLENAME.m_pfn_qglPushAttrib(GL_ALL_ATTRIB_BITS);
-
-       __QGLTABLENAME.m_pfn_qglDisable(GL_BLEND);
-       __QGLTABLENAME.m_pfn_qglEnable(GL_LINE_SMOOTH);
-
-       __QGLTABLENAME.m_pfn_qglPushMatrix();
-       
-       switch(vt)
-       {
-       case XY:
-               break;
-       case XZ:
-               __QGLTABLENAME.m_pfn_qglRotatef(270.0f, 1.0f, 0.0f, 0.0f);
-               break;
-       case YZ:
-               __QGLTABLENAME.m_pfn_qglRotatef(270.0f, 1.0f, 0.0f, 0.0f);
-               __QGLTABLENAME.m_pfn_qglRotatef(270.0f, 0.0f, 0.0f, 1.0f);
-               break;
-       }
-
-       __QGLTABLENAME.m_pfn_qglLineWidth(1.0f);
-       __QGLTABLENAME.m_pfn_qglColor4f(1.0f, 0.0f, 0.0f, 1.0f);
-
-       int i;
-
-       __QGLTABLENAME.m_pfn_qglBegin(GL_LINE_STRIP);
-
-       for(i = 0; i < nPathCount; i++)
-               __QGLTABLENAME.m_pfn_qglVertex3fv(path[i]);
-
-       __QGLTABLENAME.m_pfn_qglEnd();
-
-       if(m_bShowExtra)
-       {
-               // +mars
-               // for the bounding box stuff
-               __QGLTABLENAME.m_pfn_qglColor4f(0.25f, 0.75f, 0.75f, 1.0f);
+       glBegin(GL_LINE_STRIP);
 
 
-               __QGLTABLENAME.m_pfn_qglTranslatef( 16.0f, 16.0f, 28.0f );
-
-               __QGLTABLENAME.m_pfn_qglBegin( GL_LINE_STRIP );
-       
-                       for ( i = 0; i < nPathCount; i++ )
-                               __QGLTABLENAME.m_pfn_qglVertex3fv( path[i] );
-
-               __QGLTABLENAME.m_pfn_qglEnd();
-       
-       // ---------------
-
-               __QGLTABLENAME.m_pfn_qglTranslatef( -16.0f, -16.0f, -28.0f );   // back to where we were
-               __QGLTABLENAME.m_pfn_qglTranslatef( -16.0f, 16.0f, 28.0f );             // move to new postion
-       
-               __QGLTABLENAME.m_pfn_qglBegin( GL_LINE_STRIP );
-
-                       for ( i = 0; i < nPathCount; i++ )
-                               __QGLTABLENAME.m_pfn_qglVertex3fv( path[i] );
-
-               __QGLTABLENAME.m_pfn_qglEnd();
-
-       // --------------
-
-               __QGLTABLENAME.m_pfn_qglTranslatef( 16.0f, -16.0f, -28.0f );            // back to where we were
-               __QGLTABLENAME.m_pfn_qglTranslatef( 16.0f, -16.0f, -28.0f );            // new pos
-
-               __QGLTABLENAME.m_pfn_qglBegin( GL_LINE_STRIP );
-               
-                       for ( i = 0; i < nPathCount; i++ )
-                               __QGLTABLENAME.m_pfn_qglVertex3fv( path[i] );
-
-               __QGLTABLENAME.m_pfn_qglEnd();
-
-       // ----------------
-
-               __QGLTABLENAME.m_pfn_qglTranslatef( -16.0f, 16.0f, 28.0f );             // back to where we were
-
-/*             __QGLTABLENAME.m_pfn_qglTranslatef( -16.0f, -16.0f, -28.0f );           // new pos
+       for(int i = 0; i < nPathCount; i++)
+               glVertex3fv(path[i]);
 
 
-               __QGLTABLENAME.m_pfn_qglBegin( GL_LINE_STRIP );
-               
-               if ( boundingShow == BOUNDS_ALL )
-               {
-                       for ( i = 0; i < nPathCount; i++ )
-                               __QGLTABLENAME.m_pfn_qglVertex3fv( path[i] );
-               }
-               else if ( boundingShow == BOUNDS_APEX )
-               {
-                       for ( i = (nPathCount/4); i < (nPathCount/4) * 3; i++ )
-                               __QGLTABLENAME.m_pfn_qglVertex3fv( path[i] );
-               }
+       glEnd();
+}
 
 
-               __QGLTABLENAME.m_pfn_qglEnd();*/ // djbob: er, um doesn't really seem to do anyhting
-       }
+const char* DBobView_state_line = "$bobtoolz/bobview/line";
+const char* DBobView_state_box = "$bobtoolz/bobview/box";
 
 
-       // -mars
-       
-       __QGLTABLENAME.m_pfn_qglPopMatrix();
+void DBobView::constructShaders()
+{
+  OpenGLState state;
+  GlobalOpenGLStateLibrary().getDefaultState(state);
+  state.m_state = RENDER_COLOURWRITE|RENDER_DEPTHWRITE|RENDER_BLEND|RENDER_LINESMOOTH;
+  state.m_sort = OpenGLState::eSortOpaque;
+  state.m_linewidth = 1;
+  state.m_colour[0] = 1;
+  state.m_colour[1] = 0;
+  state.m_colour[2] = 0;
+  state.m_colour[3] = 1;
+  GlobalOpenGLStateLibrary().insert(DBobView_state_line, state);
+
+  state.m_colour[0] = 0.25f;
+  state.m_colour[1] = 0.75f;
+  state.m_colour[2] = 0.75f;
+  state.m_colour[3] = 1;
+  GlobalOpenGLStateLibrary().insert(DBobView_state_box, state);
+
+  m_shader_line = GlobalShaderCache().capture(DBobView_state_line);
+  m_shader_box = GlobalShaderCache().capture(DBobView_state_box);
+}
 
 
-       __QGLTABLENAME.m_pfn_qglPopAttrib();
+void DBobView::destroyShaders()
+{
+  GlobalOpenGLStateLibrary().erase(DBobView_state_line);
+  GlobalOpenGLStateLibrary().erase(DBobView_state_box);
+  GlobalShaderCache().release(DBobView_state_line);
+  GlobalShaderCache().release(DBobView_state_box);
 }
 
 }
 
-void DBobView::Draw3D()
+Matrix4 g_transform_box1 = matrix4_translation_for_vec3(Vector3(16.0f, 16.0f, 28.0f));
+Matrix4 g_transform_box2 = matrix4_translation_for_vec3(Vector3(-16.0f, 16.0f, 28.0f));
+Matrix4 g_transform_box3 = matrix4_translation_for_vec3(Vector3(16.0f, -16.0f, -28.0f));
+Matrix4 g_transform_box4 = matrix4_translation_for_vec3(Vector3(-16.0f, -16.0f, -28.0f));
+
+void DBobView::renderSolid(Renderer& renderer, const VolumeTest& volume) const
 {
        if(!path)
                return;
 
 {
        if(!path)
                return;
 
-       __QGLTABLENAME.m_pfn_qglPushAttrib(GL_ALL_ATTRIB_BITS);
-
-       __QGLTABLENAME.m_pfn_qglDisable(GL_BLEND);
-       __QGLTABLENAME.m_pfn_qglEnable(GL_LINE_SMOOTH);
-
-       __QGLTABLENAME.m_pfn_qglLineWidth(1.0f);
-       __QGLTABLENAME.m_pfn_qglColor4f(1.0f, 0.0f, 0.0f, 1.0f);
-
-       __QGLTABLENAME.m_pfn_qglBegin(GL_LINE_STRIP);
-
-       for(int i = 0; i < nPathCount; i++)
-               __QGLTABLENAME.m_pfn_qglVertex3fv(path[i]);
-
-       __QGLTABLENAME.m_pfn_qglEnd();
+  renderer.SetState(m_shader_line, eWireframeOnly);
+  renderer.SetState(m_shader_line, eFullMaterials);
+  renderer.addRenderable(*this, g_matrix4_identity);
 
        if(m_bShowExtra)
        {
 
        if(m_bShowExtra)
        {
-               // +mars
-               // ahhh -- a nice C&P job :)
-               // for the bounding box stuff
-               __QGLTABLENAME.m_pfn_qglColor4f(0.25f, 0.75f, 0.75f, 1.0f);
-
-               __QGLTABLENAME.m_pfn_qglTranslatef( 16.0f, 16.0f, 28.0f );
-
-               __QGLTABLENAME.m_pfn_qglBegin( GL_LINE_STRIP );
-               
-               int i;  
-               for ( i = 0; i < nPathCount; i++ )
-                       __QGLTABLENAME.m_pfn_qglVertex3fv( path[i] );
-
-               __QGLTABLENAME.m_pfn_qglEnd();
-       
-       // ---------------
-
-               __QGLTABLENAME.m_pfn_qglTranslatef( -16.0f, -16.0f, -28.0f );   // back to where we were
-               __QGLTABLENAME.m_pfn_qglTranslatef( -16.0f, 16.0f, 28.0f );             // move to new postion
-       
-               __QGLTABLENAME.m_pfn_qglBegin( GL_LINE_STRIP );
-               
-                       for ( i = 0; i < nPathCount; i++ )
-                               __QGLTABLENAME.m_pfn_qglVertex3fv( path[i] );
-
-               __QGLTABLENAME.m_pfn_qglEnd();
-
-       // --------------
-
-               __QGLTABLENAME.m_pfn_qglTranslatef( 16.0f, -16.0f, -28.0f );            // back to where we were
-               __QGLTABLENAME.m_pfn_qglTranslatef( 16.0f, -16.0f, -28.0f );            // new pos
-
-               __QGLTABLENAME.m_pfn_qglBegin( GL_LINE_STRIP );
-               
-                       for ( i = 0; i < nPathCount; i++ )
-                               __QGLTABLENAME.m_pfn_qglVertex3fv( path[i] );
-
-               __QGLTABLENAME.m_pfn_qglEnd();
-
-       // ----------------
-
-               __QGLTABLENAME.m_pfn_qglTranslatef( -16.0f, 16.0f, 28.0f );             // back to where we were
-               __QGLTABLENAME.m_pfn_qglTranslatef( -16.0f, -16.0f, -28.0f );           // new pos
-
-               __QGLTABLENAME.m_pfn_qglBegin( GL_LINE_STRIP );
-               
-                       for ( i = 0; i < nPathCount; i++ )
-                               __QGLTABLENAME.m_pfn_qglVertex3fv( path[i] );
-
-               __QGLTABLENAME.m_pfn_qglEnd();
-       }
-       // -mars
-
-       __QGLTABLENAME.m_pfn_qglPopAttrib();
+    renderer.SetState(m_shader_box, eWireframeOnly);
+    renderer.SetState(m_shader_box, eFullMaterials);
+    renderer.addRenderable(*this, g_transform_box1);
+    renderer.addRenderable(*this, g_transform_box2);
+    renderer.addRenderable(*this, g_transform_box3);
+    renderer.addRenderable(*this, g_transform_box4);
+  }
 }
 }
-
-void DBobView::Register()
+void DBobView::renderWireframe(Renderer& renderer, const VolumeTest& volume) const
 {
 {
-       __QGLTABLENAME.m_pfnHookGL2DWindow( this );
-       __QGLTABLENAME.m_pfnHookGL3DWindow( this );
-       m_bHooked = TRUE;
-}
-
-void DBobView::UnRegister()
-{
-       __QGLTABLENAME.m_pfnUnHookGL2DWindow( this );
-       __QGLTABLENAME.m_pfnUnHookGL3DWindow( this );
-       m_bHooked = FALSE;
+  renderSolid(renderer, volume);
 }
 
 void DBobView::SetPath(vec3_t *pPath)
 }
 
 void DBobView::SetPath(vec3_t *pPath)
@@ -281,7 +156,7 @@ bool DBobView::CalculateTrajectory(vec3_t start, vec3_t apex, float multiplier,
        if(apex[2] <= start[2])
        {
                SetPath(NULL);
        if(apex[2] <= start[2])
        {
                SetPath(NULL);
-               return FALSE;
+               return false;
        }
        // ----think q3a actually would allow these
        //scrub that, coz the plugin wont :]
        }
        // ----think q3a actually would allow these
        //scrub that, coz the plugin wont :]
@@ -319,7 +194,7 @@ bool DBobView::CalculateTrajectory(vec3_t start, vec3_t apex, float multiplier,
        }
 
        SetPath(pPath);
        }
 
        SetPath(pPath);
-       return TRUE;
+       return true;
 }
 
 void DBobView::Begin(const char* trigger, const char *target, float multiplier, int points, float varGravity, bool bNoUpdate, bool bShowExtra)
 }
 
 void DBobView::Begin(const char* trigger, const char *target, float multiplier, int points, float varGravity, bool bNoUpdate, bool bShowExtra)
@@ -332,20 +207,9 @@ void DBobView::Begin(const char* trigger, const char *target, float multiplier,
        nPathCount = points;
        m_bShowExtra = bShowExtra;
 
        nPathCount = points;
        m_bShowExtra = bShowExtra;
 
-       Register();
-
-       if(UpdatePath())
-       {
-               if(!bNoUpdate)
-               {
-                       eyes = new DListener;
-                       eyes->parent = this;
-                       eyes->Register();
-               }
-       }
-       else
+       if(!UpdatePath())
        {
        {
-               Sys_ERROR("Initialization Failure in DBobView::Begin");
+               globalErrorStream() << "Initialization Failure in DBobView::Begin";
                delete this;
        }
 }
                delete this;
        }
 }
@@ -359,8 +223,55 @@ bool DBobView::UpdatePath()
                if(GetEntityCentre(entTarget, apex))
                {
                        CalculateTrajectory(start, apex, fMultiplier, nPathCount, fVarGravity);
                if(GetEntityCentre(entTarget, apex))
                {
                        CalculateTrajectory(start, apex, fMultiplier, nPathCount, fVarGravity);
-                       return TRUE;
+                       return true;
                }
        }
                }
        }
-       return FALSE;
+       return false;
 }
 }
+
+void DBobView_setEntity(Entity& entity, float multiplier, int points, float varGravity, bool bNoUpdate, bool bShowExtra)
+{
+       DEntity trigger;
+       trigger.LoadEPairList(&entity);
+
+       DEPair* trigger_ep = trigger.FindEPairByKey("targetname");
+
+       if(trigger_ep)
+       {
+               if(!strcmp(trigger.m_Classname, "trigger_push"))
+               {
+                       DEPair* target_ep = trigger.FindEPairByKey("target");
+                       if(target_ep)
+                       {
+        scene::Path* entTarget = FindEntityFromTargetname(target_ep->value, NULL);
+                               if(entTarget)
+                               {
+                                       if(g_PathView)
+                                               delete g_PathView;
+                                       g_PathView = new DBobView;
+
+          Entity* target = Node_getEntity(entTarget->top());
+          if(target != 0)
+          {
+            if(!bNoUpdate)
+            {
+              g_PathView->trigger = &entity;
+              entity.attach(*g_PathView);
+              g_PathView->target = target;
+              target->attach(*g_PathView);
+            }
+                                         g_PathView->Begin(trigger_ep->value, target_ep->value, multiplier, points, varGravity, bNoUpdate, bShowExtra);
+          }
+                               }
+                               else
+                                       DoMessageBox("trigger_push target could not be found.", "Error", eMB_OK);
+                       }
+                       else
+                               DoMessageBox("trigger_push has no target.", "Error", eMB_OK);
+               }
+               else
+                       DoMessageBox("You must select a 'trigger_push' entity.", "Error", eMB_OK);
+       }       
+       else
+               DoMessageBox("Entity must have a targetname", "Error", eMB_OK);
+}
\ No newline at end of file
index 949026076812019a0169827900233d6ee31799f1..6869e6bd36bc6e16359e4ae0a0f4867a7d540e07 100644 (file)
@@ -24,7 +24,13 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 #if !defined(AFX_BOBVIEW_H__6E36062A_EF0B_11D4_ACF7_004095A18133__INCLUDED_)
 #define AFX_BOBVIEW_H__6E36062A_EF0B_11D4_ACF7_004095A18133__INCLUDED_
 
 #if !defined(AFX_BOBVIEW_H__6E36062A_EF0B_11D4_ACF7_004095A18133__INCLUDED_)
 #define AFX_BOBVIEW_H__6E36062A_EF0B_11D4_ACF7_004095A18133__INCLUDED_
 
+#include "ientity.h"
+#include "irender.h"
+#include "renderable.h"
+#include "mathlib.h"
+
 class DListener;
 class DListener;
+class Shader;
 
 #define BOUNDS_ALL     0
 #define BOUNDS_APEX    1
 
 #define BOUNDS_ALL     0
 #define BOUNDS_APEX    1
@@ -33,22 +39,26 @@ class DListener;
 #pragma once
 #endif // _MSC_VER > 1000
 
 #pragma once
 #endif // _MSC_VER > 1000
 
-class DBobView : 
-       public IGL2DWindow, 
-       public IGL3DWindow  
+class DBobView : public Renderable, public OpenGLRenderable, public Entity::Observer
 {
 {
+  Shader* m_shader_line;
+  Shader* m_shader_box;
 public:
        DBobView();
        virtual ~DBobView();
 
 protected:
        vec3_t* path;
 public:
        DBobView();
        virtual ~DBobView();
 
 protected:
        vec3_t* path;
-       int refCount;
 public:
        bool m_bShowExtra;
        int boundingShow;
        DListener* eyes;
        float fVarGravity;
 public:
        bool m_bShowExtra;
        int boundingShow;
        DListener* eyes;
        float fVarGravity;
+       float fMultiplier;
+       int nPathCount;
+
+  Entity* trigger;
+  Entity* target;
 
        bool UpdatePath();
        char entTarget[256];
 
        bool UpdatePath();
        char entTarget[256];
@@ -57,16 +67,40 @@ public:
        bool CalculateTrajectory(vec3_t, vec3_t, float, int, float);
 
        void SetPath(vec3_t* pPath);
        bool CalculateTrajectory(vec3_t, vec3_t, float, int, float);
 
        void SetPath(vec3_t* pPath);
-       void UnRegister();
-       void Register();
-       void Draw3D();
-       void Draw2D(VIEWTYPE vt);
-       void IncRef() { refCount++; }
-       void DecRef() { refCount--; if (refCount <= 0) delete this; }
 
 
-       float fMultiplier;
-       bool m_bHooked;
-       int nPathCount;
+  void render(RenderStateFlags state) const;
+  void renderSolid(Renderer& renderer, const VolumeTest& volume) const;
+  void renderWireframe(Renderer& renderer, const VolumeTest& volume) const;
+
+  void constructShaders();
+       void destroyShaders();
+
+  void valueChanged(const char* value)
+  {
+    UpdatePath();
+  }
+  typedef MemberCaller1<DBobView, const char*, &DBobView::valueChanged> ValueChangedCaller;
+  void insert(const char* key, EntityKeyValue& value)
+  {
+    value.attach(ValueChangedCaller(*this));
+  }
+  void erase(const char* key, EntityKeyValue& value)
+  {
+    value.detach(ValueChangedCaller(*this));
+  }
+  void clear()
+  {
+    if(trigger != 0)
+    {
+      trigger->detach(*this);
+      target->detach(*this);
+      trigger = 0;
+      target = 0;
+    }
+  }
 };
 
 };
 
+class Entity;
+void DBobView_setEntity(Entity& entity, float multiplier, int points, float varGravity, bool bNoUpdate, bool bShowExtra);
+
 #endif // !defined(AFX_BOBVIEW_H__6E36062A_EF0B_11D4_ACF7_004095A18133__INCLUDED_)
 #endif // !defined(AFX_BOBVIEW_H__6E36062A_EF0B_11D4_ACF7_004095A18133__INCLUDED_)
index 835e091e954b761316adfc0d4cf28aef644ee4af..75b2a6e84cd3217be60e7e50f7f14cd6f0bd9b06 100644 (file)
@@ -21,32 +21,29 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 //
 //////////////////////////////////////////////////////////////////////
 
 //
 //////////////////////////////////////////////////////////////////////
 
-#include "StdAfx.h"
+#include "DBrush.h"
 
 #ifdef WIN32
 #pragma warning(disable : 4786)
 #endif
 
 
 #ifdef WIN32
 #pragma warning(disable : 4786)
 #endif
 
-#include "StdAfx.h"
-
-#include "gtkr_list.h"
+#include <list>
 #include "str.h"
 
 #include "DPoint.h"
 #include "DPlane.h"
 #include "str.h"
 
 #include "DPoint.h"
 #include "DPlane.h"
-#include "DBrush.h"
 #include "DEPair.h"
 #include "DPatch.h"
 #include "DEntity.h"
 #include "DWinding.h"
 
 #include "DEPair.h"
 #include "DPatch.h"
 #include "DEntity.h"
 #include "DWinding.h"
 
-#include "dialogs-gtk.h"
+#include "dialogs/dialogs-gtk.h"
 
 #include "misc.h"
 
 #include "iundo.h"
 
 
 #include "misc.h"
 
 #include "iundo.h"
 
-#include "refcounted_ptr.h"
+#include "generic/referencecounted.h"
 
 #include "scenelib.h"
 
 
 #include "scenelib.h"
 
@@ -57,7 +54,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 DBrush::DBrush(int ID)
 {
        m_nBrushID = ID;
 DBrush::DBrush(int ID)
 {
        m_nBrushID = ID;
-       bBoundsBuilt = FALSE;
+       bBoundsBuilt = false;
        QER_brush = NULL;
 }
 
        QER_brush = NULL;
 }
 
@@ -71,12 +68,12 @@ DBrush::~DBrush()
 // Implementation
 //////////////////////////////////////////////////////////////////////
 
 // Implementation
 //////////////////////////////////////////////////////////////////////
 
-DPlane* DBrush::AddFace(vec3_t va, vec3_t vb, vec3_t vc, _QERFaceData* texData)
+DPlane* DBrush::AddFace(const vec3_t va, const vec3_t vb, const vec3_t vc, const _QERFaceData* texData)
 {
 #ifdef _DEBUG
 //     Sys_Printf("(%f %f %f) (%f %f %f) (%f %f %f)\n", va[0], va[1], va[2], vb[0], vb[1], vb[2], vc[0], vc[1], vc[2]);
 #endif
 {
 #ifdef _DEBUG
 //     Sys_Printf("(%f %f %f) (%f %f %f) (%f %f %f)\n", va[0], va[1], va[2], vb[0], vb[1], vb[2], vc[0], vc[1], vc[2]);
 #endif
-       bBoundsBuilt = FALSE;
+       bBoundsBuilt = false;
        DPlane* newFace = new DPlane(va, vb, vc, texData);
        faceList.push_back(newFace);
        
        DPlane* newFace = new DPlane(va, vb, vc, texData);
        faceList.push_back(newFace);
        
@@ -90,12 +87,12 @@ int DBrush::BuildPoints()
        if(faceList.size() <= 3)        // if less than 3 faces, there can be no points
                return 0;                                       // with only 3 faces u can't have a bounded soild
 
        if(faceList.size() <= 3)        // if less than 3 faces, there can be no points
                return 0;                                       // with only 3 faces u can't have a bounded soild
 
-       for(list<DPlane *>::const_iterator p1=faceList.begin(); p1!=faceList.end(); p1++)
+       for(std::list<DPlane *>::const_iterator p1=faceList.begin(); p1!=faceList.end(); p1++)
        {
        {
-               list<DPlane *>::const_iterator p2=p1;
+               std::list<DPlane *>::const_iterator p2=p1;
                for(p2++; p2!=faceList.end(); p2++)
                {
                for(p2++; p2!=faceList.end(); p2++)
                {
-                       list<DPlane *>::const_iterator p3=p2;
+                       std::list<DPlane *>::const_iterator p3=p2;
                        for(p3++; p3!=faceList.end(); p3++)
                        {
                                vec3_t pnt;
                        for(p3++; p3!=faceList.end(); p3++)
                        {
                                vec3_t pnt;
@@ -105,7 +102,7 @@ int DBrush::BuildPoints()
 
                                        if(pos == POINT_IN_BRUSH)
                                        {       // ???? shouldn't happen here
 
                                        if(pos == POINT_IN_BRUSH)
                                        {       // ???? shouldn't happen here
-                                               Sys_Printf("ERROR:: Build Brush Points: Point IN brush!!!\n");
+                                               globalErrorStream() << "ERROR:: Build Brush Points: Point IN brush!!!\n";
                                        }
                                        else if(pos == POINT_ON_BRUSH)
                                        {       // normal point
                                        }
                                        else if(pos == POINT_ON_BRUSH)
                                        {       // normal point
@@ -131,34 +128,33 @@ int DBrush::BuildPoints()
        return pointList.size();
 }
 
        return pointList.size();
 }
 
-void DBrush::LoadFromBrush(scene::Node* brush, bool textured)
+void DBrush_addFace(DBrush& brush, const _QERFaceData& faceData)
 {
 {
-       ClearFaces();
-       ClearPoints();
+  brush.AddFace(vector3_to_array(faceData.m_p0), vector3_to_array(faceData.m_p1), vector3_to_array(faceData.m_p2), 0);
+}
+typedef ReferenceCaller1<DBrush, const _QERFaceData&, DBrush_addFace> DBrushAddFaceCaller;
 
 
-#if 0
-       for(int i = g_FuncTable.m_pfnGetFaceCount(brush)-1; i >= 0 ; i--)
-       {       // running backwards so i dont have to use the count function each time (OPT)
-               _QERFaceData* faceData = g_FuncTable.m_pfnGetFaceData(brush, i);
+void DBrush_addFaceTextured(DBrush& brush, const _QERFaceData& faceData)
+{
+  brush.AddFace(vector3_to_array(faceData.m_p0), vector3_to_array(faceData.m_p1), vector3_to_array(faceData.m_p2), &faceData);
+}
+typedef ReferenceCaller1<DBrush, const _QERFaceData&, DBrush_addFaceTextured> DBrushAddFaceTexturedCaller;
 
 
-               if(faceData == NULL)
-                       DoMessageBox("Null pointer returned", "WARNING!", MB_OK);
+void DBrush::LoadFromBrush(scene::Node& brush, bool textured)
+{
+       ClearFaces();
+       ClearPoints();
 
 
-               if(textured)
-                       AddFace(faceData->m_v1, faceData->m_v2, faceData->m_v3, faceData);
-               else
-                       AddFace(faceData->m_v1, faceData->m_v2, faceData->m_v3, NULL);
-       }
-#endif
+  GlobalBrushCreator().forEachBrushFace(brush, textured ? BrushFaceDataCallback(DBrushAddFaceTexturedCaller(*this)) : BrushFaceDataCallback(DBrushAddFaceCaller(*this)));
 
 
-       QER_brush = brush;
+       QER_brush = &brush;
 }
 
 int DBrush::PointPosition(vec3_t pnt)
 {
        int state = POINT_IN_BRUSH;     // if nothing happens point is inside brush
 
 }
 
 int DBrush::PointPosition(vec3_t pnt)
 {
        int state = POINT_IN_BRUSH;     // if nothing happens point is inside brush
 
-       for(list<DPlane *>::const_iterator chkPlane=faceList.begin(); chkPlane!=faceList.end(); chkPlane++)
+       for(std::list<DPlane *>::const_iterator chkPlane=faceList.begin(); chkPlane!=faceList.end(); chkPlane++)
        {
                float dist = (*chkPlane)->DistanceToPoint(pnt);
 
        {
                float dist = (*chkPlane)->DistanceToPoint(pnt);
 
@@ -174,7 +170,7 @@ int DBrush::PointPosition(vec3_t pnt)
 
 void DBrush::ClearPoints()
 {
 
 void DBrush::ClearPoints()
 {
-       for(list<DPoint *>::const_iterator deadPoint=pointList.begin(); deadPoint!=pointList.end(); deadPoint++) {
+       for(std::list<DPoint *>::const_iterator deadPoint=pointList.begin(); deadPoint!=pointList.end(); deadPoint++) {
                delete *deadPoint;
        }
        pointList.clear();
                delete *deadPoint;
        }
        pointList.clear();
@@ -182,8 +178,8 @@ void DBrush::ClearPoints()
 
 void DBrush::ClearFaces()
 {
 
 void DBrush::ClearFaces()
 {
-       bBoundsBuilt = FALSE;
-       for(list<DPlane *>::const_iterator deadPlane=faceList.begin(); deadPlane!=faceList.end(); deadPlane++)
+       bBoundsBuilt = false;
+       for(std::list<DPlane *>::const_iterator deadPlane=faceList.begin(); deadPlane!=faceList.end(); deadPlane++)
        {
                delete *deadPlane;
        }
        {
                delete *deadPlane;
        }
@@ -199,32 +195,32 @@ void DBrush::AddPoint(vec3_t pnt)
 
 bool DBrush::HasPoint(vec3_t pnt)
 {
 
 bool DBrush::HasPoint(vec3_t pnt)
 {
-       for(list<DPoint *>::const_iterator chkPoint=pointList.begin(); chkPoint!=pointList.end(); chkPoint++)
+       for(std::list<DPoint *>::const_iterator chkPoint=pointList.begin(); chkPoint!=pointList.end(); chkPoint++)
        {
                if(**chkPoint == pnt)
        {
                if(**chkPoint == pnt)
-                       return TRUE;
+                       return true;
        }
 
        }
 
-       return FALSE;
+       return false;
 }
 
 int DBrush::RemoveRedundantPlanes()
 {
        int cnt = 0;
 }
 
 int DBrush::RemoveRedundantPlanes()
 {
        int cnt = 0;
-       list<DPlane *>::iterator chkPlane;
+       std::list<DPlane *>::iterator chkPlane;
 
        // find duplicate planes
 
        // find duplicate planes
-       list<DPlane *>::iterator p1=faceList.begin();
+       std::list<DPlane *>::iterator p1=faceList.begin();
 
        while( p1!=faceList.end() )
        {
 
        while( p1!=faceList.end() )
        {
-               list<DPlane *>::iterator p2 = p1;
+               std::list<DPlane *>::iterator p2 = p1;
 
                for(p2++; p2!=faceList.end(); p2++)
                {
                        if(**p1 == **p2)
                        {
 
                for(p2++; p2!=faceList.end(); p2++)
                {
                        if(**p1 == **p2)
                        {
-                               if(!strcmp((*p1)->texInfo.m_texdef.GetName(), "textures/common/caulk"))
+                               if(!strcmp((*p1)->m_shader.c_str(), "textures/common/caulk"))
                                {
                                        delete *p1;
                                        p1 = faceList.erase(p1);        // duplicate plane
                                {
                                        delete *p1;
                                        p1 = faceList.erase(p1);        // duplicate plane
@@ -285,12 +281,12 @@ bool DBrush::GetBounds(vec3_t min, vec3_t max)
        BuildBounds();
 
        if(!bBoundsBuilt)
        BuildBounds();
 
        if(!bBoundsBuilt)
-               return FALSE;
+               return false;
 
        VectorCopy(bbox_min, min);
        VectorCopy(bbox_max, max);
 
 
        VectorCopy(bbox_min, min);
        VectorCopy(bbox_max, max);
 
-       return TRUE;
+       return true;
 }
 
 bool DBrush::BBoxCollision(DBrush* chkBrush)
 }
 
 bool DBrush::BBoxCollision(DBrush* chkBrush)
@@ -302,25 +298,25 @@ bool DBrush::BBoxCollision(DBrush* chkBrush)
        chkBrush->GetBounds(min2, max2);
 
        if(min1[0] >= max2[0])
        chkBrush->GetBounds(min2, max2);
 
        if(min1[0] >= max2[0])
-               return FALSE;
+               return false;
        if(min1[1] >= max2[1])
        if(min1[1] >= max2[1])
-               return FALSE;
+               return false;
        if(min1[2] >= max2[2])
        if(min1[2] >= max2[2])
-               return FALSE;
+               return false;
 
        if(max1[0] <= min2[0])
 
        if(max1[0] <= min2[0])
-               return FALSE;
+               return false;
        if(max1[1] <= min2[1])
        if(max1[1] <= min2[1])
-               return FALSE;
+               return false;
        if(max1[2] <= min2[2])
        if(max1[2] <= min2[2])
-               return FALSE;
+               return false;
 
 
-       return TRUE;
+       return true;
 }
 
 DPlane* DBrush::HasPlane(DPlane* chkPlane)
 {
 }
 
 DPlane* DBrush::HasPlane(DPlane* chkPlane)
 {
-       for(list<DPlane *>::const_iterator brushPlane=faceList.begin(); brushPlane!=faceList.end(); brushPlane++)
+       for(std::list<DPlane *>::const_iterator brushPlane=faceList.begin(); brushPlane!=faceList.end(); brushPlane++)
        {
                if(**brushPlane == *chkPlane)
                        return *brushPlane;
        {
                if(**brushPlane == *chkPlane)
                        return *brushPlane;
@@ -334,21 +330,21 @@ bool DBrush::IsCutByPlane(DPlane *cuttingPlane)
 
        if(pointList.size() == 0)
                if(BuildPoints() == 0)
 
        if(pointList.size() == 0)
                if(BuildPoints() == 0)
-                       return FALSE;
+                       return false;
 
 
-       list<DPoint *>::const_iterator chkPnt = pointList.begin();
+       std::list<DPoint *>::const_iterator chkPnt = pointList.begin();
 
        if(chkPnt == pointList.end())
 
        if(chkPnt == pointList.end())
-               return FALSE;
+               return false;
 
        float dist = cuttingPlane->DistanceToPoint((*chkPnt)->_pnt);
 
        if(dist > MAX_ROUND_ERROR)
 
        float dist = cuttingPlane->DistanceToPoint((*chkPnt)->_pnt);
 
        if(dist > MAX_ROUND_ERROR)
-               isInFront = FALSE;
+               isInFront = false;
        else if(dist < MAX_ROUND_ERROR)
        else if(dist < MAX_ROUND_ERROR)
-               isInFront = TRUE;
+               isInFront = true;
        else
        else
-               return TRUE;
+               return true;
 
        for(chkPnt++=pointList.begin(); chkPnt!=pointList.end(); chkPnt++)
        {
 
        for(chkPnt++=pointList.begin(); chkPnt!=pointList.end(); chkPnt++)
        {
@@ -357,31 +353,32 @@ bool DBrush::IsCutByPlane(DPlane *cuttingPlane)
                if(dist > MAX_ROUND_ERROR)
                {
                        if(isInFront)
                if(dist > MAX_ROUND_ERROR)
                {
                        if(isInFront)
-                               return TRUE;
+                               return true;
                }
                else if(dist < MAX_ROUND_ERROR)
                {
                        if(!isInFront)
                }
                else if(dist < MAX_ROUND_ERROR)
                {
                        if(!isInFront)
-                               return TRUE;
+                               return true;
                }
                else
                }
                else
-                       return TRUE;
+                       return true;
        }
 
        }
 
-       return FALSE;
+       return false;
 }
 
 }
 
+
 scene::Node* DBrush::BuildInRadiant(bool allowDestruction, int* changeCnt, scene::Node* entity)
 {
        if(allowDestruction)
        {
 scene::Node* DBrush::BuildInRadiant(bool allowDestruction, int* changeCnt, scene::Node* entity)
 {
        if(allowDestruction)
        {
-               bool kill = TRUE;
+               bool kill = true;
                
                
-               for(list<DPlane *>::const_iterator chkPlane=faceList.begin(); chkPlane!=faceList.end(); chkPlane++)
+               for(std::list<DPlane *>::const_iterator chkPlane=faceList.begin(); chkPlane!=faceList.end(); chkPlane++)
                {
                        if((*chkPlane)->m_bChkOk)
                        {
                {
                        if((*chkPlane)->m_bChkOk)
                        {
-                               kill = FALSE;
+                               kill = false;
                                break;
                        }
                }
                                break;
                        }
                }
@@ -392,26 +389,26 @@ scene::Node* DBrush::BuildInRadiant(bool allowDestruction, int* changeCnt, scene
        //+djbob: fixed bug when brush had no faces "phantom brush" in radiant.
        if(faceList.size() < 4)
        {
        //+djbob: fixed bug when brush had no faces "phantom brush" in radiant.
        if(faceList.size() < 4)
        {
-               Sys_Printf("Possible Phantom Brush Found, will not rebuild\n");
+               globalErrorStream() << "Possible Phantom Brush Found, will not rebuild\n";
                return NULL;
        }
        //-djbob
 
                return NULL;
        }
        //-djbob
 
-       NodePtr node(Brush_AllocNode());
+  scene::Node& node = GlobalBrushCreator().createBrush();
 
 
-       for(list<DPlane *>::const_iterator buildPlane=faceList.begin(); buildPlane!=faceList.end(); buildPlane++) {
-               if((*buildPlane)->AddToBrush(node->m_brush) && changeCnt) {
+       for(std::list<DPlane *>::const_iterator buildPlane=faceList.begin(); buildPlane!=faceList.end(); buildPlane++) {
+               if((*buildPlane)->AddToBrush(node) && changeCnt) {
                        (*changeCnt)++;
                }
        }
 
        if(entity) {
                        (*changeCnt)++;
                }
        }
 
        if(entity) {
-               entity->m_traverse->insert(node);
+               Node_getTraversable(*entity)->insert(node);
        } else {
        } else {
-               GetWorldspawn()->m_traverse->insert(node);
+               Node_getTraversable(GlobalRadiant().getMapWorldEntity())->insert(node);
        }
 
        }
 
-       return node;
+       return &node;
 }
 
 void DBrush::CutByPlane(DPlane *cutPlane, DBrush **newBrush1, DBrush **newBrush2)
 }
 
 void DBrush::CutByPlane(DPlane *cutPlane, DBrush **newBrush1, DBrush **newBrush2)
@@ -426,7 +423,7 @@ void DBrush::CutByPlane(DPlane *cutPlane, DBrush **newBrush1, DBrush **newBrush2
        DBrush* b1 = new DBrush;
        DBrush* b2 = new DBrush;
        
        DBrush* b1 = new DBrush;
        DBrush* b2 = new DBrush;
        
-       for(list<DPlane *>::const_iterator parsePlane=faceList.begin(); parsePlane!=faceList.end(); parsePlane++)
+       for(std::list<DPlane *>::const_iterator parsePlane=faceList.begin(); parsePlane!=faceList.end(); parsePlane++)
        {
                b1->AddFace((*parsePlane)->points[0], (*parsePlane)->points[1], (*parsePlane)->points[2], NULL);
                b2->AddFace((*parsePlane)->points[0], (*parsePlane)->points[1], (*parsePlane)->points[2], NULL);
        {
                b1->AddFace((*parsePlane)->points[0], (*parsePlane)->points[1], (*parsePlane)->points[2], NULL);
                b2->AddFace((*parsePlane)->points[0], (*parsePlane)->points[1], (*parsePlane)->points[2], NULL);
@@ -446,55 +443,55 @@ bool DBrush::IntersectsWith(DBrush *chkBrush)
 {
        if(pointList.size() == 0)
                if(BuildPoints() == 0)
 {
        if(pointList.size() == 0)
                if(BuildPoints() == 0)
-                       return FALSE;   // invalid brush!!!!
+                       return false;   // invalid brush!!!!
 
        if(chkBrush->pointList.size() == 0)
                if(chkBrush->BuildPoints() == 0)
 
        if(chkBrush->pointList.size() == 0)
                if(chkBrush->BuildPoints() == 0)
-                       return FALSE;   // invalid brush!!!!
+                       return false;   // invalid brush!!!!
        
        if(!BBoxCollision(chkBrush))
        
        if(!BBoxCollision(chkBrush))
-               return FALSE;
+               return false;
 
 
-       list<DPlane *>::const_iterator iplPlane;
+       std::list<DPlane *>::const_iterator iplPlane;
 
        for( iplPlane=faceList.begin(); iplPlane!=faceList.end(); iplPlane++)
        {
 
 
        for( iplPlane=faceList.begin(); iplPlane!=faceList.end(); iplPlane++)
        {
 
-               bool allInFront = TRUE;
-               for(list<DPoint *>::const_iterator iPoint=chkBrush->pointList.begin(); iPoint!=chkBrush->pointList.end(); iPoint++)
+               bool allInFront = true;
+               for(std::list<DPoint *>::const_iterator iPoint=chkBrush->pointList.begin(); iPoint!=chkBrush->pointList.end(); iPoint++)
                {
                        if((*iplPlane)->DistanceToPoint((*iPoint)->_pnt) < -MAX_ROUND_ERROR)
                        {
                {
                        if((*iplPlane)->DistanceToPoint((*iPoint)->_pnt) < -MAX_ROUND_ERROR)
                        {
-                               allInFront = FALSE;
+                               allInFront = false;
                                break;
                        }
                }
                if(allInFront)
                                break;
                        }
                }
                if(allInFront)
-                       return FALSE;
+                       return false;
        }
 
        for( iplPlane=chkBrush->faceList.begin(); iplPlane!=chkBrush->faceList.end(); iplPlane++)
        {
        }
 
        for( iplPlane=chkBrush->faceList.begin(); iplPlane!=chkBrush->faceList.end(); iplPlane++)
        {
-               bool allInFront = TRUE;
-               for(list<DPoint *>::const_iterator iPoint=pointList.begin(); iPoint!=pointList.end(); iPoint++)
+               bool allInFront = true;
+               for(std::list<DPoint *>::const_iterator iPoint=pointList.begin(); iPoint!=pointList.end(); iPoint++)
                {
                        if((*iplPlane)->DistanceToPoint((*iPoint)->_pnt) < -MAX_ROUND_ERROR)
                        {
                {
                        if((*iplPlane)->DistanceToPoint((*iPoint)->_pnt) < -MAX_ROUND_ERROR)
                        {
-                               allInFront = FALSE;
+                               allInFront = false;
                                break;
                        }
                }
                if(allInFront)
                                break;
                        }
                }
                if(allInFront)
-                       return FALSE;
+                       return false;
        }
 
        }
 
-       return TRUE;
+       return true;
 }
 
 bool DBrush::IntersectsWith(DPlane* p1, DPlane* p2, vec3_t v) {
        vec3_t vDown = { 0, 0, -1 };
 
 }
 
 bool DBrush::IntersectsWith(DPlane* p1, DPlane* p2, vec3_t v) {
        vec3_t vDown = { 0, 0, -1 };
 
-       list<DPlane *>::const_iterator iplPlane;
+       std::list<DPlane *>::const_iterator iplPlane;
        for( iplPlane = faceList.begin(); iplPlane != faceList.end(); iplPlane++) {
                DPlane* p = (*iplPlane);
                
        for( iplPlane = faceList.begin(); iplPlane != faceList.end(); iplPlane++) {
                DPlane* p = (*iplPlane);
                
@@ -504,12 +501,12 @@ bool DBrush::IntersectsWith(DPlane* p1, DPlane* p2, vec3_t v) {
                }
                if(p->PlaneIntersection(p1, p2, v)) {
                        if(PointPosition( v ) != POINT_OUT_BRUSH) {
                }
                if(p->PlaneIntersection(p1, p2, v)) {
                        if(PointPosition( v ) != POINT_OUT_BRUSH) {
-                               return TRUE;
+                               return true;
                        }
                }
        }
 
                        }
                }
        }
 
-       return FALSE;
+       return false;
 }
 
 void DBrush::BuildBounds()
 }
 
 void DBrush::BuildBounds()
@@ -520,11 +517,11 @@ void DBrush::BuildBounds()
                        if(BuildPoints() == 0)
                                return;
        
                        if(BuildPoints() == 0)
                                return;
        
-               list<DPoint *>::const_iterator first = pointList.begin();
+               std::list<DPoint *>::const_iterator first = pointList.begin();
                VectorCopy((*first)->_pnt, bbox_min);
                VectorCopy((*first)->_pnt, bbox_max);
 
                VectorCopy((*first)->_pnt, bbox_min);
                VectorCopy((*first)->_pnt, bbox_max);
 
-               list<DPoint *>::const_iterator point=pointList.begin();
+               std::list<DPoint *>::const_iterator point=pointList.begin();
                for( point++; point!=pointList.end(); point++)
                {
                        if((*point)->_pnt[0] > bbox_max[0])
                for( point++; point!=pointList.end(); point++)
                {
                        if((*point)->_pnt[0] > bbox_max[0])
@@ -542,7 +539,7 @@ void DBrush::BuildBounds()
                                bbox_min[2] = (*point)->_pnt[2];
                }
 
                                bbox_min[2] = (*point)->_pnt[2];
                }
 
-               bBoundsBuilt = TRUE;
+               bBoundsBuilt = true;
        }
 }
 
        }
 }
 
@@ -555,18 +552,18 @@ bool DBrush::BBoxTouch(DBrush *chkBrush)
        chkBrush->GetBounds(min2, max2);
 
        if((min1[0] - max2[0]) > MAX_ROUND_ERROR)
        chkBrush->GetBounds(min2, max2);
 
        if((min1[0] - max2[0]) > MAX_ROUND_ERROR)
-               return FALSE;
+               return false;
        if((min1[1] - max2[1]) > MAX_ROUND_ERROR)
        if((min1[1] - max2[1]) > MAX_ROUND_ERROR)
-               return FALSE;
+               return false;
        if((min1[2] - max2[2]) > MAX_ROUND_ERROR)
        if((min1[2] - max2[2]) > MAX_ROUND_ERROR)
-               return FALSE;
+               return false;
 
        if((min2[0] - max1[0]) > MAX_ROUND_ERROR)
 
        if((min2[0] - max1[0]) > MAX_ROUND_ERROR)
-               return FALSE;
+               return false;
        if((min2[1] - max1[1]) > MAX_ROUND_ERROR)
        if((min2[1] - max1[1]) > MAX_ROUND_ERROR)
-               return FALSE;
+               return false;
        if((min2[2] - max1[2]) > MAX_ROUND_ERROR)
        if((min2[2] - max1[2]) > MAX_ROUND_ERROR)
-               return FALSE;
+               return false;
 
        int cnt = 0;
 
 
        int cnt = 0;
 
@@ -589,24 +586,24 @@ bool DBrush::BBoxTouch(DBrush *chkBrush)
                cnt++;
 
        if(cnt > 1)
                cnt++;
 
        if(cnt > 1)
-               return FALSE;
+               return false;
 
 
-       return TRUE;
+       return true;
 }
 
 }
 
-void DBrush::ResetChecks(list<Str>* exclusionList)
+void DBrush::ResetChecks(std::list<Str>* exclusionList)
 {
 {
-       for(list<DPlane *>::const_iterator resetPlane=faceList.begin(); resetPlane!=faceList.end(); resetPlane++)
+       for(std::list<DPlane *>::const_iterator resetPlane=faceList.begin(); resetPlane!=faceList.end(); resetPlane++)
        {
        {
-               bool set = FALSE;
+               bool set = false;
 
                if(exclusionList)
                {
 
                if(exclusionList)
                {
-                       for(list<Str>::iterator eTexture = exclusionList->begin(); eTexture != exclusionList->end(); eTexture++)
+                       for(std::list<Str>::iterator eTexture = exclusionList->begin(); eTexture != exclusionList->end(); eTexture++)
                        {
                        {
-                               if(strstr((*resetPlane)->texInfo.m_texdef.GetName(), eTexture->GetBuffer()))
+                               if(strstr((*resetPlane)->m_shader.c_str(), eTexture->GetBuffer()))
                                {
                                {
-                                       set = TRUE;
+                                       set = true;
                                        break;
                                }
                        }
                                        break;
                                }
                        }
@@ -618,7 +615,7 @@ void DBrush::ResetChecks(list<Str>* exclusionList)
 
 DPlane* DBrush::HasPlaneInverted(DPlane *chkPlane)
 {
 
 DPlane* DBrush::HasPlaneInverted(DPlane *chkPlane)
 {
-       for(list<DPlane *>::const_iterator brushPlane=faceList.begin(); brushPlane!=faceList.end(); brushPlane++)
+       for(std::list<DPlane *>::const_iterator brushPlane=faceList.begin(); brushPlane!=faceList.end(); brushPlane++)
        {
                if(**brushPlane != *chkPlane)
                {
        {
                if(**brushPlane != *chkPlane)
                {
@@ -631,31 +628,31 @@ DPlane* DBrush::HasPlaneInverted(DPlane *chkPlane)
 
 bool DBrush::HasTexture(const char *textureName)
 {
 
 bool DBrush::HasTexture(const char *textureName)
 {
-       for(list<DPlane *>::const_iterator chkPlane=faceList.begin(); chkPlane!=faceList.end(); chkPlane++)
+       for(std::list<DPlane *>::const_iterator chkPlane=faceList.begin(); chkPlane!=faceList.end(); chkPlane++)
        {
        {
-               if(strstr((*chkPlane)->texInfo.m_texdef.GetName(), textureName))
-                       return TRUE;
+               if(strstr((*chkPlane)->m_shader.c_str(), textureName))
+                       return true;
 
        }
 
        }
-       return FALSE;
+       return false;
 }
 
 bool DBrush::IsDetail()
 {
 }
 
 bool DBrush::IsDetail()
 {
-       for(list<DPlane *>::const_iterator chkPlane=faceList.begin(); chkPlane!=faceList.end(); chkPlane++)
+       for(std::list<DPlane *>::const_iterator chkPlane=faceList.begin(); chkPlane!=faceList.end(); chkPlane++)
        {
        {
-               if((*chkPlane)->texInfo.m_texdef.contents & FACE_DETAIL)
-                       return TRUE;
+               if((*chkPlane)->texInfo.contents & FACE_DETAIL)
+                       return true;
 
        }
 
        }
-       return FALSE;
+       return false;
 }
 
 void DBrush::BuildFromWinding(DWinding *w)
 {
        if(w->numpoints < 3)
        {
 }
 
 void DBrush::BuildFromWinding(DWinding *w)
 {
        if(w->numpoints < 3)
        {
-               Sys_ERROR("Winding has invalid number of points");
+               globalErrorStream() << "Winding has invalid number of points";
                return;
        }
 
                return;
        }
 
@@ -682,7 +679,7 @@ void DBrush::SaveToFile(FILE *pFile)
 {
        fprintf(pFile, "{\n");
 
 {
        fprintf(pFile, "{\n");
 
-       for(list<DPlane *>::const_iterator pp=faceList.begin(); pp!=faceList.end(); pp++)
+       for(std::list<DPlane *>::const_iterator pp=faceList.begin(); pp!=faceList.end(); pp++)
        {
                char buffer[512];
 
        {
                char buffer[512];
 
@@ -690,7 +687,7 @@ void DBrush::SaveToFile(FILE *pFile)
                        (*pp)->points[0][0], (*pp)->points[0][1], (*pp)->points[0][2], 
                        (*pp)->points[1][0], (*pp)->points[1][1], (*pp)->points[1][2], 
                        (*pp)->points[2][0], (*pp)->points[2][1], (*pp)->points[2][2], 
                        (*pp)->points[0][0], (*pp)->points[0][1], (*pp)->points[0][2], 
                        (*pp)->points[1][0], (*pp)->points[1][1], (*pp)->points[1][2], 
                        (*pp)->points[2][0], (*pp)->points[2][1], (*pp)->points[2][2], 
-                       (*pp)->texInfo.m_texdef.GetName(),
+                       (*pp)->m_shader.c_str(),
                        (*pp)->texInfo.m_texdef.shift[0], (*pp)->texInfo.m_texdef.shift[1], 
                        (*pp)->texInfo.m_texdef.scale[0], (*pp)->texInfo.m_texdef.scale[0], 
                        (*pp)->texInfo.m_texdef.rotate);
                        (*pp)->texInfo.m_texdef.shift[0], (*pp)->texInfo.m_texdef.shift[1], 
                        (*pp)->texInfo.m_texdef.scale[0], (*pp)->texInfo.m_texdef.scale[0], 
                        (*pp)->texInfo.m_texdef.rotate);
@@ -703,7 +700,7 @@ void DBrush::SaveToFile(FILE *pFile)
 
 void DBrush::Rotate(vec3_t vOrigin, vec3_t vRotation)
 {
 
 void DBrush::Rotate(vec3_t vOrigin, vec3_t vRotation)
 {
-       for(list<DPlane *>::const_iterator rotPlane=faceList.begin(); rotPlane!=faceList.end(); rotPlane++)
+       for(std::list<DPlane *>::const_iterator rotPlane=faceList.begin(); rotPlane!=faceList.end(); rotPlane++)
        {
                for(int i = 0; i < 3; i++)
                        VectorRotate((*rotPlane)->points[i], vRotation, vOrigin);
        {
                for(int i = 0; i < 3; i++)
                        VectorRotate((*rotPlane)->points[i], vRotation, vOrigin);
@@ -727,13 +724,13 @@ bool DBrush::ResetTextures(const char* textureName, float fScale[2],    float fS
 {
        if(textureName)
        {
 {
        if(textureName)
        {
-               bool changed = FALSE;
-               for(list<DPlane *>::const_iterator resetPlane=faceList.begin(); resetPlane!=faceList.end(); resetPlane++)
+               bool changed = false;
+               for(std::list<DPlane *>::const_iterator resetPlane=faceList.begin(); resetPlane!=faceList.end(); resetPlane++)
                {
                {
-                       if(!strcmp((*resetPlane)->texInfo.m_texdef.GetName(), textureName))
+                       if(!strcmp((*resetPlane)->m_shader.c_str(), textureName))
                        {
         if(bResetTextureName)
                        {
         if(bResetTextureName)
-                                 (*resetPlane)->texInfo.m_texdef.SetName(newTextureName);
+                                 (*resetPlane)->m_shader = newTextureName;
 
                                if(bResetScale[0])
                                        (*resetPlane)->texInfo.m_texdef.scale[0] = fScale[0];
 
                                if(bResetScale[0])
                                        (*resetPlane)->texInfo.m_texdef.scale[0] = fScale[0];
@@ -748,17 +745,17 @@ bool DBrush::ResetTextures(const char* textureName, float fScale[2],    float fS
                                if(bResetRotation)
                                        (*resetPlane)->texInfo.m_texdef.rotate = (float)rotation;
 
                                if(bResetRotation)
                                        (*resetPlane)->texInfo.m_texdef.rotate = (float)rotation;
 
-                               changed = TRUE;
+                               changed = true;
                        }
                }
                return changed; // no point rebuilding unless we need to, only slows things down
        }
        else
        {
                        }
                }
                return changed; // no point rebuilding unless we need to, only slows things down
        }
        else
        {
-               for(list<DPlane *>::const_iterator resetPlane=faceList.begin(); resetPlane!=faceList.end(); resetPlane++)
+               for(std::list<DPlane *>::const_iterator resetPlane=faceList.begin(); resetPlane!=faceList.end(); resetPlane++)
                {
         if(bResetTextureName)
                {
         if(bResetTextureName)
-                                 (*resetPlane)->texInfo.m_texdef.SetName(newTextureName);
+                                 (*resetPlane)->m_shader = newTextureName;
 
                                if(bResetScale[0])
                                        (*resetPlane)->texInfo.m_texdef.scale[0] = fScale[0];
 
                                if(bResetScale[0])
                                        (*resetPlane)->texInfo.m_texdef.scale[0] = fScale[0];
@@ -773,32 +770,32 @@ bool DBrush::ResetTextures(const char* textureName, float fScale[2],    float fS
                                if(bResetRotation)
                                        (*resetPlane)->texInfo.m_texdef.rotate = (float)rotation;
                }
                                if(bResetRotation)
                                        (*resetPlane)->texInfo.m_texdef.rotate = (float)rotation;
                }
-               return TRUE;
+               return true;
        }
 }
 
 bool DBrush::operator ==(DBrush* other)
 {
        }
 }
 
 bool DBrush::operator ==(DBrush* other)
 {
-       list<DPlane *>::const_iterator chkPlane;
+       std::list<DPlane *>::const_iterator chkPlane;
        
        for(chkPlane=faceList.begin(); chkPlane!=faceList.end(); chkPlane++)
        {
                if(!other->HasPlane((*chkPlane)))
        
        for(chkPlane=faceList.begin(); chkPlane!=faceList.end(); chkPlane++)
        {
                if(!other->HasPlane((*chkPlane)))
-                       return FALSE;
+                       return false;
        }
 
        for(chkPlane=faceList.begin(); chkPlane!=faceList.end(); chkPlane++)
        {
                if(!HasPlane((*chkPlane)))
        }
 
        for(chkPlane=faceList.begin(); chkPlane!=faceList.end(); chkPlane++)
        {
                if(!HasPlane((*chkPlane)))
-                       return FALSE;
+                       return false;
        }
 
        }
 
-       return TRUE;
+       return true;
 }
 
 }
 
-DPlane* DBrush::AddFace(vec3_t va, vec3_t vb, vec3_t vc, const char *textureName, bool bDetail)
+DPlane* DBrush::AddFace(const vec3_t va, const vec3_t vb, const vec3_t vc, const char *textureName, bool bDetail)
 {
 {
-       bBoundsBuilt = FALSE;
+       bBoundsBuilt = false;
        DPlane* newFace = new DPlane(va, vb, vc, textureName, bDetail);
        faceList.push_back(newFace);
        
        DPlane* newFace = new DPlane(va, vb, vc, textureName, bDetail);
        faceList.push_back(newFace);
        
@@ -808,7 +805,7 @@ DPlane* DBrush::AddFace(vec3_t va, vec3_t vb, vec3_t vc, const char *textureName
 DPlane* DBrush::FindPlaneWithClosestNormal( vec_t* normal ) {
        vec_t bestDot = -2;
        DPlane* bestDotPlane = NULL;
 DPlane* DBrush::FindPlaneWithClosestNormal( vec_t* normal ) {
        vec_t bestDot = -2;
        DPlane* bestDotPlane = NULL;
-       list<DPlane *>::const_iterator chkPlane;
+       std::list<DPlane *>::const_iterator chkPlane;
        for( chkPlane = faceList.begin(); chkPlane != faceList.end(); chkPlane++ ) {
                DPlane* pPlane = (*chkPlane);
 
        for( chkPlane = faceList.begin(); chkPlane != faceList.end(); chkPlane++ ) {
                DPlane* pPlane = (*chkPlane);
 
@@ -831,7 +828,7 @@ int DBrush::FindPointsForPlane( DPlane* plane, DPoint** pnts, int maxpnts ) {
 
        BuildPoints();
 
 
        BuildPoints();
 
-       for( list<DPoint *>::const_iterator points = pointList.begin(); points != pointList.end(); points++ ) {
+       for( std::list<DPoint *>::const_iterator points = pointList.begin(); points != pointList.end(); points++ ) {
                DPoint* point = (*points);
 
                if( fabs(plane->DistanceToPoint( point->_pnt )) < MAX_ROUND_ERROR ) {
                DPoint* point = (*points);
 
                if( fabs(plane->DistanceToPoint( point->_pnt )) < MAX_ROUND_ERROR ) {
@@ -849,19 +846,11 @@ int DBrush::FindPointsForPlane( DPlane* plane, DPoint** pnts, int maxpnts ) {
 }
 
 void DBrush::RemovePlane( DPlane* plane ) {
 }
 
 void DBrush::RemovePlane( DPlane* plane ) {
-       bBoundsBuilt = FALSE;
-       for( list<DPlane *>::const_iterator deadPlane = faceList.begin(); deadPlane != faceList.end(); deadPlane++ ) {          
+       bBoundsBuilt = false;
+       for( std::list<DPlane *>::const_iterator deadPlane = faceList.begin(); deadPlane != faceList.end(); deadPlane++ ) {             
                if(*deadPlane == plane) {
                        delete *deadPlane;
                        faceList.remove( plane );
                }
        }
 }
                if(*deadPlane == plane) {
                        delete *deadPlane;
                        faceList.remove( plane );
                }
        }
 }
-
-void DBrush::RemoveFromRadiant( void ) {
-       if(QER_brush) {
-#if 0
-               g_FuncTable.m_pfnDeleteBrushHandle(QER_brush);
-#endif
-       }
-}
index b285bc0052b5ad4533c499ec8302d72a9d135801..9915d0f90ca5277b61cc06189963ef3525b5ed6c 100644 (file)
@@ -28,6 +28,21 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 #pragma once
 #endif // _MSC_VER > 1000
 
 #pragma once
 #endif // _MSC_VER > 1000
 
+#include <stdio.h>
+#include <list>
+#include "mathlib.h"
+#include "str.h"
+
+class DPlane;
+class DWinding;
+class DPoint;
+class _QERFaceData;
+
+namespace scene
+{
+  class Node;
+}
+
 #define POINT_IN_BRUSH 0
 #define POINT_ON_BRUSH 1
 #define POINT_OUT_BRUSH        2
 #define POINT_IN_BRUSH 0
 #define POINT_ON_BRUSH 1
 #define POINT_OUT_BRUSH        2
@@ -35,7 +50,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 class DBrush  
 {
 public:
 class DBrush  
 {
 public:
-       DPlane* AddFace(vec3_t va, vec3_t vb, vec3_t vc, const char* textureName, bool bDetail);
+       DPlane* AddFace(const vec3_t va, const vec3_t vb, const vec3_t vc, const char* textureName, bool bDetail);
        void SaveToFile(FILE* pFile);
 
        void Rotate(vec3_t vOrigin, vec3_t vRotation);
        void SaveToFile(FILE* pFile);
 
        void Rotate(vec3_t vOrigin, vec3_t vRotation);
@@ -43,7 +58,7 @@ public:
 
        DPlane* HasPlaneInverted(DPlane* chkPlane);
        DPlane* HasPlane(DPlane* chkPlane);
 
        DPlane* HasPlaneInverted(DPlane* chkPlane);
        DPlane* HasPlane(DPlane* chkPlane);
-       DPlane* AddFace(vec3_t va, vec3_t vb, vec3_t vc, _QERFaceData* texData);
+       DPlane* AddFace(const vec3_t va, const vec3_t vb, const vec3_t vc, const _QERFaceData* texData);
 
        bool ResetTextures(const char* textureName, float fScale[2], float fShift[2], int rotation, const char* newTextureName, int bResetTextureName, int bResetScale[2], int bResetShift[2], int bResetRotation);
        bool IsDetail();
 
        bool ResetTextures(const char* textureName, float fScale[2], float fShift[2], int rotation, const char* newTextureName, int bResetTextureName, int bResetScale[2], int bResetShift[2], int bResetRotation);
        bool IsDetail();
@@ -61,7 +76,7 @@ public:
        void BuildFromWinding(DWinding* w);
   scene::Node* BuildInRadiant(bool allowDestruction, int* changeCnt, scene::Node* entity = NULL);
 
        void BuildFromWinding(DWinding* w);
   scene::Node* BuildInRadiant(bool allowDestruction, int* changeCnt, scene::Node* entity = NULL);
 
-       void ResetChecks(list<Str>* exclusionList);
+       void ResetChecks(std::list<Str>* exclusionList);
 
        void ClearFaces();
        void ClearPoints();
 
        void ClearFaces();
        void ClearPoints();
@@ -69,12 +84,11 @@ public:
        int RemoveRedundantPlanes( void );
        void RemovePlane( DPlane* plane );
        int PointPosition(vec3_t pnt);
        int RemoveRedundantPlanes( void );
        void RemovePlane( DPlane* plane );
        int PointPosition(vec3_t pnt);
-       void RemoveFromRadiant( void );
 
        
        void CutByPlane(DPlane* cutPlane, DBrush** newBrush1, DBrush** newBrush2);
 
 
        
        void CutByPlane(DPlane* cutPlane, DBrush** newBrush1, DBrush** newBrush2);
 
-       void LoadFromBrush(scene::Node* brush, bool textured);
+       void LoadFromBrush(scene::Node& brush, bool textured);
        void AddPoint(vec3_t pnt);
 
        DPlane* FindPlaneWithClosestNormal( vec_t* normal );
        void AddPoint(vec3_t pnt);
 
        DPlane* FindPlaneWithClosestNormal( vec_t* normal );
@@ -87,8 +101,8 @@ public:
 
 //     members
   scene::Node* QER_brush;
 
 //     members
   scene::Node* QER_brush;
-       list<DPlane*> faceList;
-       list<DPoint*> pointList;
+       std::list<DPlane*> faceList;
+       std::list<DPoint*> pointList;
        int m_nBrushID;
        vec3_t bbox_min, bbox_max;
        bool bBoundsBuilt;
        int m_nBrushID;
        vec3_t bbox_min, bbox_max;
        bool bBoundsBuilt;
index e7cc1ed57f055218a46a3c9b12a3cd96d02c915a..72dda4b312ae0695c00d29f78875e18c683c690a 100644 (file)
@@ -21,8 +21,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 //
 //////////////////////////////////////////////////////////////////////
 
 //
 //////////////////////////////////////////////////////////////////////
 
-#include "StdAfx.h"
-#include "str.h"
 #include "DEPair.h"
 
 //////////////////////////////////////////////////////////////////////
 #include "DEPair.h"
 
 //////////////////////////////////////////////////////////////////////
index bf8d7ad5c2bdb9a60ddcb7f4a74264f7aa1e17a3..fac4c3340d43fe8b39fb7addc37e177073fa2ce2 100644 (file)
@@ -28,6 +28,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 #pragma once
 #endif // _MSC_VER > 1000
 
 #pragma once
 #endif // _MSC_VER > 1000
 
+#include "str.h"
+
 class DEPair  
 {
 public:
 class DEPair  
 {
 public:
index 5a76ca123fb31d8dfa0957274524f4b18697dcbe..f69b358c28b4e39a0fcffd9d3064023fb4917e28 100644 (file)
@@ -21,13 +21,13 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 //
 //////////////////////////////////////////////////////////////////////
 
 //
 //////////////////////////////////////////////////////////////////////
 
+#include "DEntity.h"
+
 #ifdef WIN32
 #pragma warning(disable : 4786)
 #endif
 
 #ifdef WIN32
 #pragma warning(disable : 4786)
 #endif
 
-#include "StdAfx.h"
-
-#include "gtkr_list.h"
+#include <list>
 #include "str.h"
 
 #include "DPoint.h"
 #include "str.h"
 
 #include "DPoint.h"
@@ -35,15 +35,16 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 #include "DBrush.h"
 #include "DEPair.h"
 #include "DPatch.h"
 #include "DBrush.h"
 #include "DEPair.h"
 #include "DPatch.h"
-#include "DEntity.h"
 
 
-#include "dialogs-gtk.h"
+#include "dialogs/dialogs-gtk.h"
 #include "misc.h"
 #include "CPortals.h"
 
 #include "iundo.h"
 #include "misc.h"
 #include "CPortals.h"
 
 #include "iundo.h"
+#include "ientity.h"
+#include "ieclass.h"
 
 
-#include "refcounted_ptr.h"
+#include "generic/referencecounted.h"
 
 #include <vector>
 #include <list>
 
 #include <vector>
 #include <list>
@@ -97,7 +98,7 @@ DEntity::~DEntity()
 
 void DEntity::ClearBrushes()
 {
 
 void DEntity::ClearBrushes()
 {
-       for(list<DBrush *>::const_iterator deadBrush=brushList.begin(); deadBrush!=brushList.end(); deadBrush++)
+       for(std::list<DBrush *>::const_iterator deadBrush=brushList.begin(); deadBrush!=brushList.end(); deadBrush++)
        {
                delete *deadBrush;
        }
        {
                delete *deadBrush;
        }
@@ -106,7 +107,7 @@ void DEntity::ClearBrushes()
 
 void DEntity::ClearPatches()
 {
 
 void DEntity::ClearPatches()
 {
-       for(list<DPatch *>::const_iterator deadPatch=patchList.begin(); deadPatch!=patchList.end(); deadPatch++)
+       for(std::list<DPatch *>::const_iterator deadPatch=patchList.begin(); deadPatch!=patchList.end(); deadPatch++)
        {
                delete *deadPatch;
        }
        {
                delete *deadPatch;
        }
@@ -151,7 +152,7 @@ bool DEntity::LoadFromPrt(char *filename)
        portals.Load();
 
        if(portals.node_count == 0)
        portals.Load();
 
        if(portals.node_count == 0)
-               return FALSE;
+               return false;
 
        ClearBrushes();
        ClearEPairs();
 
        ClearBrushes();
        ClearEPairs();
@@ -188,15 +189,15 @@ bool DEntity::LoadFromPrt(char *filename)
       }
 
       if(!build)
       }
 
       if(!build)
-                         brush->AddFace(portals.node[i].portal[j].point[2].p, portals.node[i].portal[j].point[1].p, portals.node[i].portal[j].point[0].p, "textures/common/caulk", FALSE);
+                         brush->AddFace(portals.node[i].portal[j].point[2].p, portals.node[i].portal[j].point[1].p, portals.node[i].portal[j].point[0].p, "textures/common/caulk", false);
       else
       else
-                         brush->AddFace(portals.node[i].portal[j].point[0].p, portals.node[i].portal[j].point[1].p, portals.node[i].portal[j].point[2].p, "textures/common/caulk", FALSE);
+                         brush->AddFace(portals.node[i].portal[j].point[0].p, portals.node[i].portal[j].point[1].p, portals.node[i].portal[j].point[2].p, "textures/common/caulk", false);
                }
     if(build)
                }
     if(build)
-      brush->BuildInRadiant(FALSE, NULL);
+      brush->BuildInRadiant(false, NULL);
        }
 
        }
 
-       return TRUE;
+       return true;
 }
 
 DPlane* DEntity::AddFaceToBrush(vec3_t va, vec3_t vb, vec3_t vc, _QERFaceData* faceData, int ID)
 }
 
 DPlane* DEntity::AddFaceToBrush(vec3_t va, vec3_t vb, vec3_t vc, _QERFaceData* faceData, int ID)
@@ -210,7 +211,7 @@ DBrush* DEntity::GetBrushForID(int ID)
 {
        DBrush* buildBrush = NULL;
 
 {
        DBrush* buildBrush = NULL;
 
-       for(list<DBrush *>::const_iterator chkBrush=brushList.begin(); chkBrush!=brushList.end(); chkBrush++)
+       for(std::list<DBrush *>::const_iterator chkBrush=brushList.begin(); chkBrush!=brushList.end(); chkBrush++)
        {
                if((*chkBrush)->m_nBrushID == ID)
                {
        {
                if((*chkBrush)->m_nBrushID == ID)
                {
@@ -225,47 +226,82 @@ DBrush* DEntity::GetBrushForID(int ID)
        return buildBrush;
 }
 
        return buildBrush;
 }
 
+template<typename Functor>
+class BrushSelectedVisitor : public SelectionSystem::Visitor
+{
+  const Functor& m_functor;
+public:
+  BrushSelectedVisitor(const Functor& functor) : m_functor(functor)
+  {
+  }
+  void visit(scene::Instance& instance) const
+  {
+    if(Node_isBrush(instance.path().top()))
+    {
+      m_functor(*instance.path().top());
+    }
+  }
+};
+
+template<typename Functor>
+inline const Functor& Scene_forEachSelectedBrush(const Functor& functor)
+{
+  GlobalSelectionSystem().foreachSelected(BrushSelectedVisitor<Functor>(functor));
+  return functor;
+}
+
+void DEntity_loadBrush(DEntity& entity, scene::Node& brush)
+{
+  DBrush* loadBrush = entity.NewBrush(entity.brushList.size());
+       loadBrush->LoadFromBrush(brush, true);
+}
+typedef ReferenceCaller1<DEntity, scene::Node&, DEntity_loadBrush> DEntityLoadBrushCaller;
+
 void DEntity::LoadSelectedBrushes()
 {
        ClearBrushes();
        ClearEPairs();
 
 void DEntity::LoadSelectedBrushes()
 {
        ClearBrushes();
        ClearEPairs();
 
-#if 0
-       int count = g_FuncTable.m_pfnAllocateSelectedBrushHandles();
-
-       for(int i = 0; i < count; i++) {
-               brush_t *brush = (brush_t*)g_FuncTable.m_pfnGetSelectedBrushHandle(i);
+  Scene_forEachSelectedBrush(DEntityLoadBrushCaller(*this));
+}
 
 
-               if(brush->patchBrush)
-                       continue;
+template<typename Functor>
+class PatchSelectedVisitor : public SelectionSystem::Visitor
+{
+  const Functor& m_functor;
+public:
+  PatchSelectedVisitor(const Functor& functor) : m_functor(functor)
+  {
+  }
+  void visit(scene::Instance& instance) const
+  {
+    if(Node_isPatch(instance.path().top()))
+    {
+      m_functor(*instance.path().top());
+    }
+  }
+};
 
 
-               DBrush* loadBrush = NewBrush(i);
-               loadBrush->LoadFromBrush_t(brush, TRUE);
-       }
+template<typename Functor>
+inline const Functor& Scene_forEachSelectedPatch(const Functor& functor)
+{
+  GlobalSelectionSystem().foreachSelected(PatchSelectedVisitor<Functor>(functor));
+  return functor;
+}
 
 
-       g_FuncTable.m_pfnReleaseSelectedBrushHandles();
-#endif
+void DEntity_loadPatch(DEntity& entity, scene::Node& patch)
+{
+  DPatch* loadPatch = entity.NewPatch();
+       loadPatch->LoadFromBrush(patch);
 }
 }
+typedef ReferenceCaller1<DEntity, scene::Node&, DEntity_loadPatch> DEntityLoadPatchCaller;
 
 void DEntity::LoadSelectedPatches()
 {
        ClearPatches();
        ClearEPairs();
 
 
 void DEntity::LoadSelectedPatches()
 {
        ClearPatches();
        ClearEPairs();
 
-#if 0
-  int count = g_FuncTable.m_pfnAllocateSelectedPatchHandles();
-
-       for(int i = 0; i < count; i++)
-       {
-    //$ FIXME: m_pfnGetPatchHandle
-               patchMesh_t *pmesh = (patchMesh_t*)g_FuncTable.m_pfnGetPatchData(i);
-
-               DPatch* loadPatch = NewPatch();
-               loadPatch->LoadFromBrush_t(pmesh->pSymbiot);
-       }
-
-  g_FuncTable.m_pfnReleasePatchHandles();
-#endif
+  Scene_forEachSelectedPatch(DEntityLoadPatchCaller(*this));
 }
 
 bool* DEntity::BuildIntersectList()
 }
 
 bool* DEntity::BuildIntersectList()
@@ -277,15 +313,15 @@ bool* DEntity::BuildIntersectList()
        bool* pbIntList = new bool[max];
        memset(pbIntList, 0, sizeof(bool)*(max));
 
        bool* pbIntList = new bool[max];
        memset(pbIntList, 0, sizeof(bool)*(max));
 
-       for(list<DBrush *>::const_iterator pB1=brushList.begin(); pB1!=brushList.end(); pB1++)
+       for(std::list<DBrush *>::const_iterator pB1=brushList.begin(); pB1!=brushList.end(); pB1++)
        {
        {
-               list<DBrush *>::const_iterator pB2=pB1;
+               std::list<DBrush *>::const_iterator pB2=pB1;
                for(pB2++; pB2!=brushList.end(); pB2++)
                {
                        if((*pB1)->IntersectsWith((*pB2)))
                        {
                for(pB2++; pB2!=brushList.end(); pB2++)
                {
                        if((*pB1)->IntersectsWith((*pB2)))
                        {
-                               pbIntList[(*pB1)->m_nBrushID] = TRUE;
-                               pbIntList[(*pB2)->m_nBrushID] = TRUE;
+                               pbIntList[(*pB1)->m_nBrushID] = true;
+                               pbIntList[(*pB2)->m_nBrushID] = true;
                        }
                }
        }
                        }
                }
        }
@@ -302,15 +338,15 @@ bool* DEntity::BuildDuplicateList()
        bool* pbDupList = new bool[max];
        memset(pbDupList, 0, sizeof(bool)*(max));
 
        bool* pbDupList = new bool[max];
        memset(pbDupList, 0, sizeof(bool)*(max));
 
-       for(list<DBrush *>::const_iterator pB1=brushList.begin(); pB1!=brushList.end(); pB1++)
+       for(std::list<DBrush *>::const_iterator pB1=brushList.begin(); pB1!=brushList.end(); pB1++)
        {
        {
-               list<DBrush *>::const_iterator pB2=pB1;
+               std::list<DBrush *>::const_iterator pB2=pB1;
                for(pB2++; pB2!=brushList.end(); pB2++)
                {
                        if(**pB1 == *pB2)
                        {
                for(pB2++; pB2!=brushList.end(); pB2++)
                {
                        if(**pB1 == *pB2)
                        {
-                               pbDupList[(*pB1)->m_nBrushID] = TRUE;
-                               pbDupList[(*pB2)->m_nBrushID] = TRUE;
+                               pbDupList[(*pB1)->m_nBrushID] = true;
+                               pbDupList[(*pB2)->m_nBrushID] = true;
                        }
                }
        }
                        }
                }
        }
@@ -323,84 +359,81 @@ void DEntity::SelectBrushes(bool *selectList)
        if(selectList == NULL)
                return;
 
        if(selectList == NULL)
                return;
 
-  GlobalSelectionSystem().Select(false);
+  GlobalSelectionSystem().setSelectedAll(false);
 
 
-  scene::Path path(GlobalSceneGraph().root());
-  path.push(QER_Entity);
+  scene::Path path(NodeReference(GlobalSceneGraph().root()));
+  path.push(NodeReference(*QER_Entity));
 
        for(std::list<DBrush *>::const_iterator pBrush=brushList.begin(); pBrush!=brushList.end(); pBrush++)
        {
                if(selectList[(*pBrush)->m_nBrushID])
     {
 
        for(std::list<DBrush *>::const_iterator pBrush=brushList.begin(); pBrush!=brushList.end(); pBrush++)
        {
                if(selectList[(*pBrush)->m_nBrushID])
     {
-      path.push((*pBrush)->QER_brush);
-      GlobalSceneGraph().find(path)->selectable()->select(true);
+      path.push(NodeReference(*(*pBrush)->QER_brush));
+      Instance_getSelectable(*GlobalSceneGraph().find(path))->setSelected(true);
       path.pop();
     }
        }
 }
 
       path.pop();
     }
        }
 }
 
-bool DEntity::LoadFromEntity(scene::Node* ent, bool bLoadPatches) {
+bool DEntity::LoadFromEntity(scene::Node& ent, bool bLoadPatches) {
        ClearPatches();
        ClearBrushes();
        ClearEPairs();
 
        ClearPatches();
        ClearBrushes();
        ClearEPairs();
 
-       QER_Entity = ent;
+       QER_Entity = &ent;
 
 
-       LoadEPairList(ent->m_entity);
+       LoadEPairList(Node_getEntity(ent));
 
 
-       bool keep = FALSE;
+       bool keep = false;
        int i;
        for(i = 0; brushEntityList[i]; i++)
        {
        int i;
        for(i = 0; brushEntityList[i]; i++)
        {
-               if(!stricmp(brushEntityList[i], m_Classname))
+               if(string_equal_nocase(brushEntityList[i], m_Classname))
                {
                {
-                       keep = TRUE;
+                       keep = true;
                        break;
                }
        }
 
        if(!keep)
                        break;
                }
        }
 
        if(!keep)
-               return FALSE;
+               return false;
 
 
-  if(ent->m_traverse)
+  if(Node_getTraversable(ent))
   {
     class load_brushes_t : public scene::Traversable::Walker
     {
       DEntity* m_entity;
   {
     class load_brushes_t : public scene::Traversable::Walker
     {
       DEntity* m_entity;
-      int m_count;
+      mutable int m_count;
     public:
       load_brushes_t(DEntity* entity)
         : m_entity(entity), m_count(0)
       {
       }
     public:
       load_brushes_t(DEntity* entity)
         : m_entity(entity), m_count(0)
       {
       }
-      bool pre(scene::Node* node)
+      bool pre(scene::Node& node) const
       {
       {
-        if(node->m_brush)
+        if(Node_isPatch(node))
         {
           DPatch* loadPatch = m_entity->NewPatch();
                                  loadPatch->LoadFromBrush(node);
         }
         {
           DPatch* loadPatch = m_entity->NewPatch();
                                  loadPatch->LoadFromBrush(node);
         }
-        else if(node->m_patch)
+        else if(Node_isBrush(node))
         {
                            DBrush* loadBrush = m_entity->NewBrush(m_count++);
         {
                            DBrush* loadBrush = m_entity->NewBrush(m_count++);
-                           loadBrush->LoadFromBrush(node, TRUE);
+                           loadBrush->LoadFromBrush(node, true);
         }
         return false;
       }
         }
         return false;
       }
-      void post(scene::Node* node)
-      {
-      }
     } load_brushes(this);
 
     } load_brushes(this);
 
-    ent->m_traverse->traverse(load_brushes);
+    Node_getTraversable(ent)->traverse(load_brushes);
   }
 
   }
 
-       return TRUE;
+       return true;
 }
 
 }
 
-void DEntity::RemoveNonCheckBrushes(list<Str>* exclusionList, bool useDetail)
+void DEntity::RemoveNonCheckBrushes(std::list<Str>* exclusionList, bool useDetail)
 {
 {
-       list<DBrush *>::iterator chkBrush=brushList.begin();
+       std::list<DBrush *>::iterator chkBrush=brushList.begin();
 
        while( chkBrush!=brushList.end() )
        {
 
        while( chkBrush!=brushList.end() )
        {
@@ -414,7 +447,7 @@ void DEntity::RemoveNonCheckBrushes(list<Str>* exclusionList, bool useDetail)
                        }
                }
 
                        }
                }
 
-               list<Str>::iterator eTexture;
+               std::list<Str>::iterator eTexture;
 
                for( eTexture=exclusionList->begin(); eTexture!=exclusionList->end(); eTexture++ )
                {
 
                for( eTexture=exclusionList->begin(); eTexture!=exclusionList->end(); eTexture++ )
                {
@@ -431,9 +464,9 @@ void DEntity::RemoveNonCheckBrushes(list<Str>* exclusionList, bool useDetail)
        }
 }
 
        }
 }
 
-void DEntity::ResetChecks(list<Str>* exclusionList)
+void DEntity::ResetChecks(std::list<Str>* exclusionList)
 {
 {
-       for(list<DBrush *>::const_iterator resetBrush=brushList.begin(); resetBrush!=brushList.end(); resetBrush++)
+       for(std::list<DBrush *>::const_iterator resetBrush=brushList.begin(); resetBrush!=brushList.end(); resetBrush++)
        {
                (*resetBrush)->ResetChecks(exclusionList);
        }
        {
                (*resetBrush)->ResetChecks(exclusionList);
        }
@@ -443,7 +476,7 @@ int DEntity::FixBrushes()
 {
        int count = 0;
 
 {
        int count = 0;
 
-       for(list<DBrush *>::const_iterator fixBrush=brushList.begin(); fixBrush!=brushList.end(); fixBrush++)
+       for(std::list<DBrush *>::const_iterator fixBrush=brushList.begin(); fixBrush!=brushList.end(); fixBrush++)
        {
     count += (*fixBrush)->RemoveRedundantPlanes();
        }
        {
     count += (*fixBrush)->RemoveRedundantPlanes();
        }
@@ -457,29 +490,29 @@ void DEntity::BuildInRadiant(bool allowDestruction)
 
        if(makeEntity)
        {
 
        if(makeEntity)
        {
-    NodePtr node(GlobalEntityCreator().createEntity(m_Classname.GetBuffer()));
+    NodeReference node(GlobalEntityCreator().createEntity(GlobalEntityClassManager().findOrInsert(m_Classname.GetBuffer(), !brushList.empty() || !patchList.empty())));
 
 
-               for(list<DEPair* >::const_iterator buildEPair=epairList.begin(); buildEPair!=epairList.end(); buildEPair++)
+               for(std::list<DEPair* >::const_iterator buildEPair=epairList.begin(); buildEPair!=epairList.end(); buildEPair++)
                {
                {
-      node->m_entity->setkeyvalue((*buildEPair)->key, (*buildEPair)->value);
+      Node_getEntity(node)->setKeyValue((*buildEPair)->key, (*buildEPair)->value);
                }
 
                }
 
-               GlobalSceneGraph().root()->m_traverse->insert(node);
+               Node_getTraversable(GlobalSceneGraph().root())->insert(node);
 
 
-               for(list<DBrush *>::const_iterator buildBrush=brushList.begin(); buildBrush!=brushList.end(); buildBrush++)
-                       (*buildBrush)->BuildInRadiant(allowDestruction, NULL, node);
+               for(std::list<DBrush *>::const_iterator buildBrush=brushList.begin(); buildBrush!=brushList.end(); buildBrush++)
+                       (*buildBrush)->BuildInRadiant(allowDestruction, NULL, node.get_pointer());
 
 
-               for(list<DPatch *>::const_iterator buildPatch=patchList.begin(); buildPatch!=patchList.end(); buildPatch++)
-                       (*buildPatch)->BuildInRadiant(node);
+               for(std::list<DPatch *>::const_iterator buildPatch=patchList.begin(); buildPatch!=patchList.end(); buildPatch++)
+                       (*buildPatch)->BuildInRadiant(node.get_pointer());
 
 
-               QER_Entity = node;
+               QER_Entity = node.get_pointer();
        }
        else
        {
        }
        else
        {
-               for(list<DBrush *>::const_iterator buildBrush=brushList.begin(); buildBrush!=brushList.end(); buildBrush++)
+               for(std::list<DBrush *>::const_iterator buildBrush=brushList.begin(); buildBrush!=brushList.end(); buildBrush++)
                        (*buildBrush)->BuildInRadiant(allowDestruction, NULL);
 
                        (*buildBrush)->BuildInRadiant(allowDestruction, NULL);
 
-               for(list<DPatch *>::const_iterator buildPatch=patchList.begin(); buildPatch!=patchList.end(); buildPatch++)
+               for(std::list<DPatch *>::const_iterator buildPatch=patchList.begin(); buildPatch!=patchList.end(); buildPatch++)
                        (*buildPatch)->BuildInRadiant();
        }
 }
                        (*buildPatch)->BuildInRadiant();
        }
 }
@@ -488,7 +521,7 @@ void DEntity::BuildInRadiant(bool allowDestruction)
 
 int DEntity::GetIDMax( void ) {
        int max = -1;
 
 int DEntity::GetIDMax( void ) {
        int max = -1;
-       for(list<DBrush *>::const_iterator cntBrush=brushList.begin(); cntBrush!=brushList.end(); cntBrush++) {
+       for(std::list<DBrush *>::const_iterator cntBrush=brushList.begin(); cntBrush!=brushList.end(); cntBrush++) {
                if((*cntBrush)->m_nBrushID > max)
                        max = (*cntBrush)->m_nBrushID;
        }
                if((*cntBrush)->m_nBrushID > max)
                        max = (*cntBrush)->m_nBrushID;
        }
@@ -505,12 +538,12 @@ void DEntity::SaveToFile(FILE *pFile)
 
        fprintf(pFile, "\"classname\" \"%s\"\n", (const char *)m_Classname);
 
 
        fprintf(pFile, "\"classname\" \"%s\"\n", (const char *)m_Classname);
 
-       for(list<DEPair *>::const_iterator ep=epairList.begin(); ep!=epairList.end(); ep++)
+       for(std::list<DEPair *>::const_iterator ep=epairList.begin(); ep!=epairList.end(); ep++)
        {
                fprintf(pFile, "\"%s\" \"%s\"\n", (const char *)(*ep)->key, (const char *)(*ep)->value);
        }
 
        {
                fprintf(pFile, "\"%s\" \"%s\"\n", (const char *)(*ep)->key, (const char *)(*ep)->value);
        }
 
-       for(list<DBrush *>::const_iterator bp=brushList.begin(); bp!=brushList.end(); bp++)
+       for(std::list<DBrush *>::const_iterator bp=brushList.begin(); bp!=brushList.end(); bp++)
        {
                (*bp)->SaveToFile(pFile);
        }
        {
                (*bp)->SaveToFile(pFile);
        }
@@ -520,7 +553,7 @@ void DEntity::SaveToFile(FILE *pFile)
 
 void DEntity::ClearEPairs()
 {
 
 void DEntity::ClearEPairs()
 {
-       for(list<DEPair *>::const_iterator deadEPair=epairList.begin(); deadEPair!=epairList.end(); deadEPair++)
+       for(std::list<DEPair *>::const_iterator deadEPair=epairList.begin(); deadEPair!=epairList.end(); deadEPair++)
        {
                delete (*deadEPair);
        }
        {
                delete (*deadEPair);
        }
@@ -559,34 +592,34 @@ void DEntity::LoadEPairList(Entity *epl)
 
   } load_epairs(this);
 
 
   } load_epairs(this);
 
-  epl->accept(load_epairs);
+  epl->forEachKeyValue(load_epairs);
 }
 
 bool DEntity::ResetTextures(const char* textureName, float fScale[2],     float fShift[2],    int rotation, const char* newTextureName, 
                             int bResetTextureName,    int bResetScale[2], int bResetShift[2], int bResetRotation, bool rebuild)
 {
 }
 
 bool DEntity::ResetTextures(const char* textureName, float fScale[2],     float fShift[2],    int rotation, const char* newTextureName, 
                             int bResetTextureName,    int bResetScale[2], int bResetShift[2], int bResetRotation, bool rebuild)
 {
-       bool reset = FALSE;
+       bool reset = false;
 
 
-       for(list<DBrush *>::const_iterator resetBrush=brushList.begin(); resetBrush!=brushList.end(); resetBrush++)
+       for(std::list<DBrush *>::const_iterator resetBrush=brushList.begin(); resetBrush!=brushList.end(); resetBrush++)
        {
                bool tmp = (*resetBrush)->ResetTextures(textureName,        fScale,       fShift,       rotation, newTextureName, 
                                             bResetTextureName,  bResetScale,  bResetShift,  bResetRotation);
 
                if(tmp)
                {
        {
                bool tmp = (*resetBrush)->ResetTextures(textureName,        fScale,       fShift,       rotation, newTextureName, 
                                             bResetTextureName,  bResetScale,  bResetShift,  bResetRotation);
 
                if(tmp)
                {
-                       reset = TRUE;
+                       reset = true;
                }
        }
 
   if(bResetTextureName)
   {
                }
        }
 
   if(bResetTextureName)
   {
-         for(list<DPatch *>::const_iterator resetPatch=patchList.begin(); resetPatch!=patchList.end(); resetPatch++)
+         for(std::list<DPatch *>::const_iterator resetPatch=patchList.begin(); resetPatch!=patchList.end(); resetPatch++)
          {
                  bool tmp = (*resetPatch)->ResetTextures(textureName, newTextureName);
 
                  if(tmp)
                  {
          {
                  bool tmp = (*resetPatch)->ResetTextures(textureName, newTextureName);
 
                  if(tmp)
                  {
-                         reset = TRUE;
+                         reset = true;
                  }
          }
   }
                  }
          }
   }
@@ -596,7 +629,7 @@ bool DEntity::ResetTextures(const char* textureName, float fScale[2],     float
 
 DEPair* DEntity::FindEPairByKey(const char* keyname)
 {
 
 DEPair* DEntity::FindEPairByKey(const char* keyname)
 {
-       for(list<DEPair *>::const_iterator ep=epairList.begin(); ep!=epairList.end(); ep++)
+       for(std::list<DEPair *>::const_iterator ep=epairList.begin(); ep!=epairList.end(); ep++)
        {
                char* c = (*ep)->key;
                if(!strcmp(c, keyname))
        {
                char* c = (*ep)->key;
                if(!strcmp(c, keyname))
@@ -607,7 +640,7 @@ DEPair* DEntity::FindEPairByKey(const char* keyname)
 
 void DEntity::RemoveFromRadiant()
 {
 
 void DEntity::RemoveFromRadiant()
 {
-       GlobalSceneGraph().root()->m_traverse->erase(QER_Entity);
+       Node_getTraversable(GlobalSceneGraph().root())->erase(*QER_Entity);
 
        QER_Entity = NULL;
 }
 
        QER_Entity = NULL;
 }
@@ -656,10 +689,10 @@ int DEntity::GetBrushCount( void ) {
        return brushList.size();
 }
 
        return brushList.size();
 }
 
-DBrush* DEntity::FindBrushByPointer( scene::Node* brush ) {
-       for(list<DBrush *>::const_iterator listBrush = brushList.begin(); listBrush != brushList.end(); listBrush++) {
+DBrush* DEntity::FindBrushByPointer( scene::Node& brush ) {
+       for(std::list<DBrush *>::const_iterator listBrush = brushList.begin(); listBrush != brushList.end(); listBrush++) {
                DBrush* pBrush = (*listBrush);
                DBrush* pBrush = (*listBrush);
-               if(pBrush->QER_brush == brush) {
+               if(pBrush->QER_brush == &brush) {
                        return pBrush;
                }
        }
                        return pBrush;
                }
        }
index ba3794de4eaf765f0693563cacb51307537c4a28..5baa3d3db400cb05b3eae4d4a14ec1668c1570c0 100644 (file)
@@ -28,6 +28,22 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 #pragma once
 #endif // _MSC_VER > 1000
 
 #pragma once
 #endif // _MSC_VER > 1000
 
+#include <list>
+#include "str.h"
+#include "mathlib.h"
+
+class DEPair;
+class DBrush;
+class DPlane;
+class DPatch;
+class Entity;
+
+namespace scene
+{
+  class Node;
+}
+class _QERFaceData;
+
 class DEntity  
 {
 public:
 class DEntity  
 {
 public:
@@ -54,12 +70,12 @@ public:
        int GetIDMax();
 
        void BuildInRadiant(bool allowDestruction);
        int GetIDMax();
 
        void BuildInRadiant(bool allowDestruction);
-       void ResetChecks(list<Str>* exclusionList);
-       void RemoveNonCheckBrushes(list<Str>* exclusionList, bool useDetail);
+       void ResetChecks(std::list<Str>* exclusionList);
+       void RemoveNonCheckBrushes(std::list<Str>* exclusionList, bool useDetail);
 
        DPlane* AddFaceToBrush(vec3_t va, vec3_t vb, vec3_t vc, _QERFaceData* faceData, int ID);        // slow, try not to use much
        int GetBrushCount( void );
 
        DPlane* AddFaceToBrush(vec3_t va, vec3_t vb, vec3_t vc, _QERFaceData* faceData, int ID);        // slow, try not to use much
        int GetBrushCount( void );
-  DBrush* FindBrushByPointer( scene::Node* brush );
+  DBrush* FindBrushByPointer( scene::Node& brush );
 //     ---------------------------------------------
 
 
 //     ---------------------------------------------
 
 
@@ -84,17 +100,17 @@ public:
 //     ---------------------------------------------
 
 //     vars
 //     ---------------------------------------------
 
 //     vars
-       list<DEPair*> epairList;
-       list<DBrush*> brushList;
+       std::list<DEPair*> epairList;
+       std::list<DBrush*> brushList;
        // new patches, wahey!!!
        // new patches, wahey!!!
-       list<DPatch*> patchList;
+       std::list<DPatch*> patchList;
        Str m_Classname;
 //     ---------------------------------------------
 
 
        int FixBrushes();
 
        Str m_Classname;
 //     ---------------------------------------------
 
 
        int FixBrushes();
 
-       bool LoadFromEntity(scene::Node* ent, bool bLoadPatches = FALSE);
+       bool LoadFromEntity(scene::Node& ent, bool bLoadPatches = false);
        void LoadSelectedBrushes();
        void LoadSelectedPatches();
 
        void LoadSelectedBrushes();
        void LoadSelectedPatches();
 
index cd688f4615b78ee9a3d002cb0373f87de4c918a3..3d04a42333c80b32aedb6c8935f00f941edf7328 100644 (file)
@@ -21,7 +21,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 //
 //////////////////////////////////////////////////////////////////////
 
 //
 //////////////////////////////////////////////////////////////////////
 
-#include "StdAfx.h"
 #include "DListener.h"
 
 //////////////////////////////////////////////////////////////////////
 #include "DListener.h"
 
 //////////////////////////////////////////////////////////////////////
index 382a0254fafb76c72757aa714fd06b235c9fd290..18e431885324fbfef2e7f6a0da45d8b84c3d2911 100644 (file)
@@ -21,10 +21,10 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 //
 //////////////////////////////////////////////////////////////////////
 
 //
 //////////////////////////////////////////////////////////////////////
 
-#include "StdAfx.h"
+#include "DMap.h"
 
 #include "str.h"
 
 #include "str.h"
-#include "gtkr_list.h"
+#include <list>
 
 #include "DPoint.h"
 #include "DPlane.h"
 
 #include "DPoint.h"
 #include "DPlane.h"
@@ -32,11 +32,10 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 #include "DEPair.h"
 #include "DPatch.h"
 #include "DEntity.h"
 #include "DEPair.h"
 #include "DPatch.h"
 #include "DEntity.h"
-#include "DMap.h"
 
 #include "iundo.h"
 
 
 #include "iundo.h"
 
-#include "refcounted_ptr.h"
+#include "generic/referencecounted.h"
 
 #include <vector>
 #include <list>
 
 #include <vector>
 #include <list>
@@ -78,7 +77,7 @@ void DMap::ClearEntities()
 {
        m_nNextEntity = 1;
 
 {
        m_nNextEntity = 1;
 
-       for(list<DEntity *>::const_iterator deadEntity=entityList.begin(); deadEntity!=entityList.end(); deadEntity++)
+       for(std::list<DEntity *>::const_iterator deadEntity=entityList.begin(); deadEntity!=entityList.end(); deadEntity++)
                delete *deadEntity;
 
        entityList.clear();
                delete *deadEntity;
 
        entityList.clear();
@@ -88,7 +87,7 @@ DEntity* DMap::GetEntityForID(int ID)
 {
        DEntity* findEntity = NULL;
 
 {
        DEntity* findEntity = NULL;
 
-       for(list<DEntity *>::const_iterator chkEntity=entityList.begin(); chkEntity!=entityList.end(); chkEntity++)
+       for(std::list<DEntity *>::const_iterator chkEntity=entityList.begin(); chkEntity!=entityList.end(); chkEntity++)
        {
                if((*chkEntity)->m_nID == ID)
                {
        {
                if((*chkEntity)->m_nID == ID)
                {
@@ -111,7 +110,7 @@ DEntity* DMap::GetWorldSpawn()
 
 void DMap::BuildInRadiant(bool bAllowDestruction)
 {
 
 void DMap::BuildInRadiant(bool bAllowDestruction)
 {
-       for(list<DEntity *>::const_iterator buildEntity=entityList.begin(); buildEntity!=entityList.end(); buildEntity++)
+       for(std::list<DEntity *>::const_iterator buildEntity=entityList.begin(); buildEntity!=entityList.end(); buildEntity++)
                (*buildEntity)->BuildInRadiant(bAllowDestruction);
 }
 
                (*buildEntity)->BuildInRadiant(bAllowDestruction);
 }
 
@@ -119,7 +118,7 @@ void DMap::LoadAll(bool bLoadPatches)
 {
        ClearEntities();
 
 {
        ClearEntities();
 
-       GlobalSelectionSystem().Select(false);
+       GlobalSelectionSystem().setSelectedAll(false);
 
   class load_entities_t : public scene::Traversable::Walker
   {
 
   class load_entities_t : public scene::Traversable::Walker
   {
@@ -130,27 +129,24 @@ void DMap::LoadAll(bool bLoadPatches)
       : m_map(map), m_bLoadPatches(bLoadPatches)
     {
     }
       : m_map(map), m_bLoadPatches(bLoadPatches)
     {
     }
-    bool pre(scene::Node* node)
+    bool pre(scene::Node& node) const
     {
     {
-      if(node->m_entity)
+      if(Node_isEntity(node))
       {
         DEntity* loadEntity = m_map->AddEntity("", 0);
                                loadEntity->LoadFromEntity(node, m_bLoadPatches);
       }
       return false;
     }
       {
         DEntity* loadEntity = m_map->AddEntity("", 0);
                                loadEntity->LoadFromEntity(node, m_bLoadPatches);
       }
       return false;
     }
-    void post(scene::Node* node)
-    {
-    }
   } load_entities(this, bLoadPatches);
 
   } load_entities(this, bLoadPatches);
 
-  GlobalSceneGraph().root()->m_traverse->traverse(load_entities);
+  Node_getTraversable(GlobalSceneGraph().root())->traverse(load_entities);
 }
 
 int DMap::FixBrushes()
 {
        int count = 0;
 }
 
 int DMap::FixBrushes()
 {
        int count = 0;
-       for(list<DEntity *>::const_iterator fixEntity=entityList.begin(); fixEntity!=entityList.end(); fixEntity++)
+       for(std::list<DEntity *>::const_iterator fixEntity=entityList.begin(); fixEntity!=entityList.end(); fixEntity++)
        {
                count += (*fixEntity)->FixBrushes();
        }
        {
                count += (*fixEntity)->FixBrushes();
        }
@@ -161,15 +157,15 @@ int DMap::FixBrushes()
 void DMap::ResetTextures( const char* textureName, float fScale[2],      float fShift[2],      int rotation, const char* newTextureName, 
                           int bResetTextureName,  int bResetScale[2],  int bResetShift[2],  int bResetRotation)
 {
 void DMap::ResetTextures( const char* textureName, float fScale[2],      float fShift[2],      int rotation, const char* newTextureName, 
                           int bResetTextureName,  int bResetScale[2],  int bResetShift[2],  int bResetRotation)
 {
-       for(list<DEntity *>::const_iterator texEntity=entityList.begin(); texEntity!=entityList.end(); texEntity++)
+       for(std::list<DEntity *>::const_iterator texEntity=entityList.begin(); texEntity!=entityList.end(); texEntity++)
        {
        {
-               if(!stricmp("worldspawn", (*texEntity)->m_Classname))
+               if(string_equal_nocase("worldspawn", (*texEntity)->m_Classname))
                        (*texEntity)->ResetTextures(textureName,        fScale,       fShift,       rotation, newTextureName, 
                        (*texEntity)->ResetTextures(textureName,        fScale,       fShift,       rotation, newTextureName, 
-                                  bResetTextureName,  bResetScale,  bResetShift,  bResetRotation, TRUE);
+                                  bResetTextureName,  bResetScale,  bResetShift,  bResetRotation, true);
                else
                {
                        if((*texEntity)->ResetTextures( textureName,        fScale,       fShift,       rotation, newTextureName, 
                else
                {
                        if((*texEntity)->ResetTextures( textureName,        fScale,       fShift,       rotation, newTextureName, 
-                                      bResetTextureName,  bResetScale,  bResetShift,  bResetRotation, FALSE))
+                                      bResetTextureName,  bResetScale,  bResetShift,  bResetRotation, false))
                                RebuildEntity(*texEntity);
                }
        }       
                                RebuildEntity(*texEntity);
                }
        }       
@@ -178,5 +174,5 @@ void DMap::ResetTextures( const char* textureName, float fScale[2],      float f
 void DMap::RebuildEntity(DEntity *ent)
 {
        ent->RemoveFromRadiant();
 void DMap::RebuildEntity(DEntity *ent)
 {
        ent->RemoveFromRadiant();
-       ent->BuildInRadiant(FALSE);
+       ent->BuildInRadiant(false);
 }
 }
index 756823401c0364a9f67cdf4336c3e4769b9b9327..970b958a0e8e31fe77a3e41f8ec8312473653f37 100644 (file)
@@ -28,13 +28,17 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 #pragma once
 #endif // _MSC_VER > 1000
 
 #pragma once
 #endif // _MSC_VER > 1000
 
+#include <list>
+
+class DEntity;
+
 class DMap  
 {
 public:
        static void RebuildEntity(DEntity* ent);
 
        void ResetTextures( const char* textureName, float fScale[2],      float fShift[2],      int rotation, const char* newTextureName, int bResetTextureName,  int bResetScale[2],  int bResetShift[2],  int bResetRotation);
 class DMap  
 {
 public:
        static void RebuildEntity(DEntity* ent);
 
        void ResetTextures( const char* textureName, float fScale[2],      float fShift[2],      int rotation, const char* newTextureName, int bResetTextureName,  int bResetScale[2],  int bResetShift[2],  int bResetRotation);
-       void LoadAll(bool bLoadPatches = FALSE);
+       void LoadAll(bool bLoadPatches = false);
        void BuildInRadiant(bool bAllowDestruction);
        int m_nNextEntity;
        DEntity* GetWorldSpawn();
        void BuildInRadiant(bool bAllowDestruction);
        int m_nNextEntity;
        DEntity* GetWorldSpawn();
@@ -43,7 +47,7 @@ public:
        DEntity* DMap::GetEntityForID(int ID);
        DEntity* AddEntity(char* classname = "worldspawn", int ID = -1);
 
        DEntity* DMap::GetEntityForID(int ID);
        DEntity* AddEntity(char* classname = "worldspawn", int ID = -1);
 
-       list<DEntity*> entityList;
+       std::list<DEntity*> entityList;
 
        DMap();
        virtual ~DMap();
 
        DMap();
        virtual ~DMap();
index 50bca9fad447c1c65b0e83515126c8c9235cd463..2158eff7575d359b19a25a167ce95217e3fac293 100644 (file)
@@ -21,17 +21,13 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 //
 //////////////////////////////////////////////////////////////////////
 
 //
 //////////////////////////////////////////////////////////////////////
 
-#include "StdAfx.h"
+#include "DPatch.h"
 
 
-#include "gtkr_list.h"
+#include <list>
 #include "str.h"
 #include "str.h"
+#include "scenelib.h"
 
 
-//#include "DPoint.h"
-//#include "DPlane.h"
-//#include "DBrush.h"
-//#include "DEPair.h"
-#include "DPatch.h"
-//#include "DEntity.h"
+#include "ipatch.h"
 
 #include "misc.h"
 #include "./dialogs/dialogs-gtk.h"
 
 #include "misc.h"
 #include "./dialogs/dialogs-gtk.h"
@@ -73,8 +69,15 @@ void CopyDrawVert(const drawVert_t* in, drawVert_t* out)
        VectorCopy(in->xyz, out->xyz);
 }
 
        VectorCopy(in->xyz, out->xyz);
 }
 
-void DPatch::BuildInRadiant(void* entity)
+void DPatch::BuildInRadiant(scene::Node* entity)
 {
 {
+       NodeSmartReference node(GlobalPatchCreator().createPatch());
+
+       if(entity) {
+               Node_getTraversable(*entity)->insert(node);
+       } else {
+               Node_getTraversable(GlobalRadiant().getMapWorldEntity())->insert(node);
+       }
 #if 0
        int nIndex = g_FuncTable.m_pfnCreatePatchHandle();
     //$ FIXME: m_pfnGetPatchHandle
 #if 0
        int nIndex = g_FuncTable.m_pfnCreatePatchHandle();
     //$ FIXME: m_pfnGetPatchHandle
@@ -113,7 +116,7 @@ void DPatch::BuildInRadiant(void* entity)
 //             strcpy(pm->d_texture->name, texture);
 
                brush_t* brush = (brush_t*)g_FuncTable.m_pfnCreateBrushHandle();
 //             strcpy(pm->d_texture->name, texture);
 
                brush_t* brush = (brush_t*)g_FuncTable.m_pfnCreateBrushHandle();
-               brush->patchBrush = TRUE;
+               brush->patchBrush = true;
                brush->pPatch = pm;             
 
                pm->pSymbiot = brush;
                brush->pPatch = pm;             
 
                pm->pSymbiot = brush;
@@ -135,9 +138,9 @@ void DPatch::BuildInRadiant(void* entity)
 #endif
 }
 
 #endif
 }
 
-void DPatch::LoadFromBrush(scene::Node* brush)
+void DPatch::LoadFromBrush(scene::Node& brush)
 {
 {
-       QER_brush = brush;
+       QER_brush = &brush;
 
 #if 0
        SetTexture(brush->pPatch->GetShader());
 
 #if 0
        SetTexture(brush->pPatch->GetShader());
@@ -160,25 +163,15 @@ void DPatch::LoadFromBrush(scene::Node* brush)
 #endif
 }
 
 #endif
 }
 
-void DPatch::RemoveFromRadiant()
-{
-       if(QER_brush)
-  {
-#if 0
-               g_FuncTable.m_pfnDeleteBrushHandle(QER_brush);
-#endif
-  }
-}
-
 bool DPatch::ResetTextures(const char *oldTextureName, const char *newTextureName)
 {
        if( !oldTextureName || !strcmp(texture, oldTextureName))
        {
                strcpy(texture, newTextureName);
 bool DPatch::ResetTextures(const char *oldTextureName, const char *newTextureName)
 {
        if( !oldTextureName || !strcmp(texture, oldTextureName))
        {
                strcpy(texture, newTextureName);
-               return TRUE;
+               return true;
        }
 
        }
 
-       return FALSE;
+       return false;
 }
 
 void Build1dArray(vec3_t* array, drawVert_t points[MAX_PATCH_WIDTH][MAX_PATCH_HEIGHT], 
 }
 
 void Build1dArray(vec3_t* array, drawVert_t points[MAX_PATCH_WIDTH][MAX_PATCH_HEIGHT], 
@@ -205,8 +198,8 @@ void Build1dArray(vec3_t* array, drawVert_t points[MAX_PATCH_WIDTH][MAX_PATCH_HE
 void Print1dArray(vec3_t* array, int size)
 {
        for(int i = 0; i < size; i++)
 void Print1dArray(vec3_t* array, int size)
 {
        for(int i = 0; i < size; i++)
-               Sys_Printf("(" << array[i][0] << " " << array[i][1] << " " << array[i][2] << ")\t");
-       Sys_Printf("\n");
+               globalOutputStream() << "(" << array[i][0] << " " << array[i][1] << " " << array[i][2] << ")\t";
+       globalOutputStream() << "\n";
 }
 
 bool Compare1dArrays(vec3_t* a1, vec3_t* a2, int size)
 }
 
 bool Compare1dArrays(vec3_t* a1, vec3_t* a2, int size)
@@ -391,9 +384,9 @@ void DPatch::Transpose()
        Invert();
 }
 
        Invert();
 }
 
-list<DPatch> DPatch::Split(bool rows, bool cols)
+std::list<DPatch> DPatch::Split(bool rows, bool cols)
 {
 {
-       list<DPatch> patchList;
+       std::list<DPatch> patchList;
        int i;
        int x, y;
 
        int i;
        int x, y;
 
@@ -419,13 +412,13 @@ list<DPatch> DPatch::Split(bool rows, bool cols)
 
                if(cols && width >= 5)
                {
 
                if(cols && width >= 5)
                {
-                       list<DPatch> patchList2;
+                       std::list<DPatch> patchList2;
 
 
-                       for(list<DPatch>::iterator patches = patchList.begin(); patches != patchList.end(); patches++)
+                       for(std::list<DPatch>::iterator patches = patchList.begin(); patches != patchList.end(); patches++)
                        {
                        {
-                               list<DPatch> patchList3 = (*patches).Split(false, true);
+                               std::list<DPatch> patchList3 = (*patches).Split(false, true);
                                
                                
-                               for(list<DPatch>::iterator patches2 = patchList3.begin(); patches2 != patchList3.end(); patches2++)
+                               for(std::list<DPatch>::iterator patches2 = patchList3.begin(); patches2 != patchList3.end(); patches2++)
                                        patchList2.push_front(*patches2);
                        }
 
                                        patchList2.push_front(*patches2);
                        }
 
index 4d85e90939f70c2426235003d85f7debecba4d5b..d1442ce45dd3e539c3979efa99b9ea9528510e1f 100644 (file)
@@ -24,10 +24,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 #if !defined(AFX_DPATCH_H__26C6B083_CE5B_420B_836B_1DDA733C04CE__INCLUDED_)
 #define AFX_DPATCH_H__26C6B083_CE5B_420B_836B_1DDA733C04CE__INCLUDED_
 
 #if !defined(AFX_DPATCH_H__26C6B083_CE5B_420B_836B_1DDA733C04CE__INCLUDED_)
 #define AFX_DPATCH_H__26C6B083_CE5B_420B_836B_1DDA733C04CE__INCLUDED_
 
-#include "StdAfx.h"    // Added by ClassView
-#if _MSC_VER > 1000
-#pragma once
-#endif // _MSC_VER > 1000
+#include <list>
 
 typedef struct
 {      
 
 typedef struct
 {      
@@ -43,7 +40,10 @@ typedef struct {
   float lightmap[2];
 } drawVert_t;
 
   float lightmap[2];
 } drawVert_t;
 
-class Patch;
+namespace scene
+{
+  class Node;
+}
 
 #define MAX_PATCH_WIDTH 16
 #define MAX_PATCH_HEIGHT 16
 
 #define MAX_PATCH_WIDTH 16
 #define MAX_PATCH_HEIGHT 16
@@ -53,16 +53,15 @@ class Patch;
 class DPatch  
 {
 public:
 class DPatch  
 {
 public:
-       list<DPatch> Split(bool rows, bool cols);
+       std::list<DPatch> Split(bool rows, bool cols);
        void Transpose();
        void Invert();
        DPatch* MergePatches(patch_merge_t merge_info, DPatch* p1, DPatch* p2);
        patch_merge_t IsMergable(DPatch* other);
   bool ResetTextures(const char *oldTextureName, const char *newTextureName);
        void Transpose();
        void Invert();
        DPatch* MergePatches(patch_merge_t merge_info, DPatch* p1, DPatch* p2);
        patch_merge_t IsMergable(DPatch* other);
   bool ResetTextures(const char *oldTextureName, const char *newTextureName);
-       void RemoveFromRadiant(void);
        scene::Node* QER_brush;
        scene::Node* QER_brush;
-       void LoadFromBrush(scene::Node* brush);
-       void BuildInRadiant(void* entity = NULL);
+       void LoadFromBrush(scene::Node& brush);
+       void BuildInRadiant(scene::Node* entity = NULL);
        void SetTexture(const char* textureName);
        char texture[256];
        int width, height;
        void SetTexture(const char* textureName);
        char texture[256];
        int width, height;
index f577683952cfe2f257131e4203d34bbf22848d45..c9c7b67f94bc6026e64c679bfce3b0f25083db76 100644 (file)
@@ -21,12 +21,11 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 //
 //////////////////////////////////////////////////////////////////////
 
 //
 //////////////////////////////////////////////////////////////////////
 
-#include "StdAfx.h"
+#include "DPlane.h"
 
 
-#include "gtkr_list.h"
+#include <list>
 
 #include "DPoint.h"
 
 #include "DPoint.h"
-#include "DPlane.h"
 #include "DWinding.h"
 
 #include "str.h"
 #include "DWinding.h"
 
 #include "str.h"
@@ -36,11 +35,11 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 // Construction/Destruction
 //////////////////////////////////////////////////////////////////////
 
 // Construction/Destruction
 //////////////////////////////////////////////////////////////////////
 
-DPlane::DPlane(vec3_t va, vec3_t vb, vec3_t vc, _QERFaceData* texData)
+DPlane::DPlane(const vec3_t va, const vec3_t vb, const vec3_t vc, const _QERFaceData* texData)
 {
        MakeNormal( va, vb, vc, normal );
        if(VectorNormalize(normal, normal) == 0)        // normalizes and returns length
 {
        MakeNormal( va, vb, vc, normal );
        if(VectorNormalize(normal, normal) == 0)        // normalizes and returns length
-               Sys_ERROR("DPlane::DPlane: Bad Normal.\n");
+               globalErrorStream() << "DPlane::DPlane: Bad Normal.\n";
 
        _d = (normal[0]*va[0]) + (normal[1]*va[1]) + (normal[2]*va[2]);
 
 
        _d = (normal[0]*va[0]) + (normal[1]*va[1]) + (normal[2]*va[2]);
 
@@ -48,7 +47,7 @@ DPlane::DPlane(vec3_t va, vec3_t vb, vec3_t vc, _QERFaceData* texData)
        VectorCopy(vb, points[1]);
        VectorCopy(vc, points[2]);
 
        VectorCopy(vb, points[1]);
        VectorCopy(vc, points[2]);
 
-       m_bChkOk = TRUE;
+       m_bChkOk = true;
 
        if(texData)
                memcpy(&texInfo, texData, sizeof(_QERFaceData));
 
        if(texData)
                memcpy(&texInfo, texData, sizeof(_QERFaceData));
@@ -85,7 +84,7 @@ bool DPlane::PlaneIntersection(DPlane *pl1, DPlane *pl2, vec3_t out)
        float d = Determinant3x3(a1, a2, a3, b1, b2, b3, c1, c2, c3);
 
        if(d == 0)
        float d = Determinant3x3(a1, a2, a3, b1, b2, b3, c1, c2, c3);
 
        if(d == 0)
-               return FALSE;
+               return false;
        
        float v1 = _d;
        float v2 = pl1->_d;
        
        float v1 = _d;
        float v2 = pl1->_d;
@@ -99,23 +98,23 @@ bool DPlane::PlaneIntersection(DPlane *pl1, DPlane *pl2, vec3_t out)
        out[1] = d2/d;  
        out[2] = d3/d;  
 
        out[1] = d2/d;  
        out[2] = d3/d;  
 
-       return TRUE;
+       return true;
 }
 
 }
 
-bool DPlane::IsRedundant(list<DPoint*>& pointList)
+bool DPlane::IsRedundant(std::list<DPoint*>& pointList)
 {
        int cnt = 0;
 
 {
        int cnt = 0;
 
-       //list<DPoint *>::const_iterator point=pointList.begin();
-       for(list<DPoint *>::const_iterator point=pointList.begin(); point!=pointList.end(); point++)
+       //std::list<DPoint *>::const_iterator point=pointList.begin();
+       for(std::list<DPoint *>::const_iterator point=pointList.begin(); point!=pointList.end(); point++)
        {
                 if(fabs(DistanceToPoint((*point)->_pnt)) < MAX_ROUND_ERROR)
                         cnt++;
 
                 if(cnt == 3)
        {
                 if(fabs(DistanceToPoint((*point)->_pnt)) < MAX_ROUND_ERROR)
                         cnt++;
 
                 if(cnt == 3)
-                        return FALSE;
+                        return false;
        }
        }
-       return TRUE;
+       return true;
 }
 
 bool DPlane::operator == (DPlane& other)
 }
 
 bool DPlane::operator == (DPlane& other)
@@ -123,12 +122,12 @@ bool DPlane::operator == (DPlane& other)
        vec3_t chk;
        VectorSubtract(other.normal, normal, chk);
        if(fabs(VectorLength(chk)) > MAX_ROUND_ERROR)
        vec3_t chk;
        VectorSubtract(other.normal, normal, chk);
        if(fabs(VectorLength(chk)) > MAX_ROUND_ERROR)
-               return FALSE;
+               return false;
 
        if(fabs(other._d - _d) > MAX_ROUND_ERROR)
 
        if(fabs(other._d - _d) > MAX_ROUND_ERROR)
-               return FALSE;
+               return false;
 
 
-       return TRUE;
+       return true;
 }
 
 bool DPlane::operator != (DPlane& other)
 }
 
 bool DPlane::operator != (DPlane& other)
@@ -136,9 +135,9 @@ bool DPlane::operator != (DPlane& other)
        vec3_t chk;
        VectorAdd(other.normal, normal, chk);
        if(fabs(VectorLength(chk)) > MAX_ROUND_ERROR)
        vec3_t chk;
        VectorAdd(other.normal, normal, chk);
        if(fabs(VectorLength(chk)) > MAX_ROUND_ERROR)
-               return FALSE;
+               return false;
 
 
-       return TRUE;
+       return true;
 }
 
 DWinding* DPlane::BaseWindingForPlane()
 }
 
 DWinding* DPlane::BaseWindingForPlane()
@@ -161,7 +160,7 @@ DWinding* DPlane::BaseWindingForPlane()
                }
        }
        if (x==-1)
                }
        }
        if (x==-1)
-               Sys_Printf ("BaseWindingForPlane: no axis found");
+               globalOutputStream() << "BaseWindingForPlane: no axis found";
                
        VectorCopy (vec3_origin, vup);  
        switch (x)
                
        VectorCopy (vec3_origin, vup);  
        switch (x)
@@ -213,7 +212,7 @@ void DPlane::Rebuild()
        CrossProduct(v1, v2, normal);
 
        if(VectorNormalize(normal, normal) == 0)        // normalizes and returns length
        CrossProduct(v1, v2, normal);
 
        if(VectorNormalize(normal, normal) == 0)        // normalizes and returns length
-               Sys_ERROR("DPlane::Rebuild: Bad Normal.\n");
+               globalErrorStream() << "DPlane::Rebuild: Bad Normal.\n";
 
        _d = (normal[0]*points[0][0]) + (normal[1]*points[0][1]) + (normal[2]*points[0][2]);
 
 
        _d = (normal[0]*points[0][0]) + (normal[1]*points[0][1]) + (normal[2]*points[0][2]);
 
@@ -222,25 +221,30 @@ void DPlane::Rebuild()
        VectorCopy(points[2], texInfo.m_p2);
 }
 
        VectorCopy(points[2], texInfo.m_p2);
 }
 
-bool DPlane::AddToBrush(Brush *brush)
+bool DPlane::AddToBrush(scene::Node& brush)
 {
 {
-#if 0
-       if(m_bChkOk || !strcmp(texInfo.m_TextureName, "textures/common/caulk"))
-       {
-               brush->addPlane(m_p0, m_p1, m_p2, m_texdef, false);
-               return FALSE;
-       }
-
-       strcpy(texInfo.m_TextureName, "textures/common/caulk");
-       brush->addPlane(m_p0, m_p1, m_p2, m_texdef, false);
-#endif
-       return TRUE;
+  bool changed = false;
+  if(!(m_bChkOk || !strcmp(m_shader.c_str(), "textures/common/caulk")))
+  {
+         m_shader = "textures/common/caulk";
+    changed = true;
+  }
+
+  _QERFaceData faceData;
+  faceData.m_p0 = vector3_from_array(points[0]);
+  faceData.m_p1 = vector3_from_array(points[1]);
+  faceData.m_p2 = vector3_from_array(points[2]);
+  faceData.m_texdef = texInfo.m_texdef;
+  faceData.m_shader = m_shader.c_str();
+  GlobalBrushCreator().addBrushFace(brush, faceData);
+
+       return changed;
 }
 
 void DPlane::ScaleTexture()
 { }
 
 }
 
 void DPlane::ScaleTexture()
 { }
 
-DPlane::DPlane(vec3_t va, vec3_t vb, vec3_t vc, const char* textureName, bool bDetail)
+DPlane::DPlane(const vec3_t va, const vec3_t vb, const vec3_t vc, const char* textureName, bool bDetail)
 {
        vec3_t v1, v2;
        VectorSubtract(va, vb, v1);
 {
        vec3_t v1, v2;
        VectorSubtract(va, vb, v1);
@@ -248,7 +252,7 @@ DPlane::DPlane(vec3_t va, vec3_t vb, vec3_t vc, const char* textureName, bool bD
        CrossProduct(v1, v2, normal);
 
        if(VectorNormalize(normal, normal) == 0)        // normalizes and returns length
        CrossProduct(v1, v2, normal);
 
        if(VectorNormalize(normal, normal) == 0)        // normalizes and returns length
-               Sys_ERROR("DPlane::DPlane: Bad Normal.\n");
+               globalErrorStream() << "DPlane::DPlane: Bad Normal.\n";
 
        _d = (normal[0]*va[0]) + (normal[1]*va[1]) + (normal[2]*va[2]);
 
 
        _d = (normal[0]*va[0]) + (normal[1]*va[1]) + (normal[2]*va[2]);
 
@@ -256,9 +260,9 @@ DPlane::DPlane(vec3_t va, vec3_t vb, vec3_t vc, const char* textureName, bool bD
        VectorCopy(vb, points[1]);
        VectorCopy(vc, points[2]);
 
        VectorCopy(vb, points[1]);
        VectorCopy(vc, points[2]);
 
-       m_bChkOk = TRUE;
+       m_bChkOk = true;
 
        FillDefaultTexture(&texInfo, points[0], points[1], points[2], textureName);
        if(bDetail)
 
        FillDefaultTexture(&texInfo, points[0], points[1], points[2], textureName);
        if(bDetail)
-               texInfo.m_texdef.contents |= FACE_DETAIL;
+               texInfo.contents |= FACE_DETAIL;
 }
 }
index 11c3f685172b41e1935af34bdaca9a8f38814800..68db6ed94da1b6b8c1da42fea95bf0a27ac678d5 100644 (file)
@@ -24,7 +24,13 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 #if !defined(AFX_DPLANE_H__FC37C021_F0A1_11D4_ACF7_004095A18133__INCLUDED_)
 #define AFX_DPLANE_H__FC37C021_F0A1_11D4_ACF7_004095A18133__INCLUDED_
 
 #if !defined(AFX_DPLANE_H__FC37C021_F0A1_11D4_ACF7_004095A18133__INCLUDED_)
 #define AFX_DPLANE_H__FC37C021_F0A1_11D4_ACF7_004095A18133__INCLUDED_
 
+#include <list>
+#include "ibrush.h"
+#include "string/string.h"
+#include "mathlib.h"
+
 class Brush;
 class Brush;
+class DPoint;
 
 #define FACE_DETAIL 0x8000000
 
 
 #define FACE_DETAIL 0x8000000
 
@@ -37,27 +43,28 @@ class DWinding;
 class DPlane  
 {
 public:
 class DPlane  
 {
 public:
-       DPlane(vec3_t va, vec3_t vb, vec3_t vc, const char* textureName, bool bDetail);
+       DPlane(const vec3_t va, const vec3_t vb, const vec3_t vc, const char* textureName, bool bDetail);
        void ScaleTexture();
        DWinding* BaseWindingForPlane();
 
        void Rebuild();
 
        void ScaleTexture();
        DWinding* BaseWindingForPlane();
 
        void Rebuild();
 
-       bool AddToBrush(Brush *brush);
+  bool AddToBrush(scene::Node& brush);
        bool operator != (DPlane& other);
        bool operator == (DPlane& other);
 
        bool operator != (DPlane& other);
        bool operator == (DPlane& other);
 
-       bool IsRedundant(list<DPoint*>& pointList);
+       bool IsRedundant(std::list<DPoint*>& pointList);
        bool PlaneIntersection(DPlane* pl1, DPlane* pl2, vec3_t out);;
 
        vec_t DistanceToPoint(vec3_t pnt);
 
        bool PlaneIntersection(DPlane* pl1, DPlane* pl2, vec3_t out);;
 
        vec_t DistanceToPoint(vec3_t pnt);
 
-       DPlane(vec3_t va, vec3_t vb, vec3_t vc, _QERFaceData* texData);
+       DPlane(const vec3_t va, const vec3_t vb, const vec3_t vc, const _QERFaceData* texData);
        DPlane() { }
        virtual ~DPlane();
 
        bool m_bChkOk;
        _QERFaceData texInfo;
        DPlane() { }
        virtual ~DPlane();
 
        bool m_bChkOk;
        _QERFaceData texInfo;
+  CopiedString m_shader;
        vec3_t points[3];               // djbob:do we really need these any more?
        vec3_t normal;
        float _d;
        vec3_t points[3];               // djbob:do we really need these any more?
        vec3_t normal;
        float _d;
index a56e91f0c67f3602318af1e71a92f863d021e982..b0b6015388440c76840fca017f95bc799aa3d33a 100644 (file)
@@ -21,8 +21,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 //
 //////////////////////////////////////////////////////////////////////
 
 //
 //////////////////////////////////////////////////////////////////////
 
-#include "StdAfx.h"
 #include "DPoint.h"
 #include "DPoint.h"
+#include "misc.h"
 
 //////////////////////////////////////////////////////////////////////
 // Construction/Destruction
 
 //////////////////////////////////////////////////////////////////////
 // Construction/Destruction
@@ -47,6 +47,6 @@ bool DPoint::operator ==(vec3_t other)
        vec3_t test;
        VectorSubtract(other, _pnt, test);
        if(fabs(VectorLength(test)) > MAX_ROUND_ERROR)
        vec3_t test;
        VectorSubtract(other, _pnt, test);
        if(fabs(VectorLength(test)) > MAX_ROUND_ERROR)
-               return FALSE;
-       return TRUE;
+               return false;
+       return true;
 }
 }
index 394352cfb098b9258f0f7fb44ddccdd7835fa9a3..121373418f5848bb96012b5605c82cbe3b41c070 100644 (file)
@@ -28,6 +28,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 #pragma once
 #endif // _MSC_VER > 1000
 
 #pragma once
 #endif // _MSC_VER > 1000
 
+#include "mathlib.h"
+
 class DPoint  
 {
 public:
 class DPoint  
 {
 public:
index ebe2c0da1ad6f8e66a0e9759c70163ac15be4061..9201d29cfa14831387a15d8fec6234475eaa9b53 100644 (file)
@@ -21,9 +21,10 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 //
 //////////////////////////////////////////////////////////////////////
 
 //
 //////////////////////////////////////////////////////////////////////
 
-#include "StdAfx.h"
+#include "DShape.h"
 
 
-#include "gtkr_list.h"
+#include <list>
+#include <time.h>
 #include "str.h"
 
 #include "DPoint.h"
 #include "str.h"
 
 #include "DPoint.h"
@@ -32,7 +33,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 #include "DEPair.h"
 #include "DPatch.h"
 #include "DEntity.h"
 #include "DEPair.h"
 #include "DPatch.h"
 #include "DEntity.h"
-#include "DShape.h"
 
 //#include "dialogs-gtk.h"
 
 
 //#include "dialogs-gtk.h"
 
@@ -43,7 +43,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 // Construction/Destruction
 //////////////////////////////////////////////////////////////////////
 
 // Construction/Destruction
 //////////////////////////////////////////////////////////////////////
 
-bool bFacesAll[6] = {TRUE, TRUE, TRUE, TRUE, TRUE, TRUE};
+bool bFacesAll[6] = {true, true, true, true, true, true};
 
 DShape::DShape()
 {
 
 DShape::DShape()
 {
@@ -104,16 +104,16 @@ void DShape::BuildRegularPrism(vec3_t min, vec3_t max, int nSides, bool bAlignTo
        DBrush* pB = m_Container.GetWorldSpawn()->NewBrush(m_nNextBrush++);
 
        for(i = 1; i <= nSides; i++)
        DBrush* pB = m_Container.GetWorldSpawn()->NewBrush(m_nNextBrush++);
 
        for(i = 1; i <= nSides; i++)
-               pB->AddFace(vc[i-1], vc[i], vd[i], GetCurrentTexture(), FALSE);
+               pB->AddFace(vc[i-1], vc[i], vd[i], GetCurrentTexture(), false);
 
 
-       pB->AddFace(vc[2], vc[1], vc[0], "textures/common/caulk", FALSE);
-       pB->AddFace(vd[0], vd[1], vd[2], "textures/common/caulk", FALSE);
+       pB->AddFace(vc[2], vc[1], vc[0], "textures/common/caulk", false);
+       pB->AddFace(vd[0], vd[1], vd[2], "textures/common/caulk", false);
 }
 
 void DShape::Commit()
 {
        m_Container.GetWorldSpawn()->FixBrushes();
 }
 
 void DShape::Commit()
 {
        m_Container.GetWorldSpawn()->FixBrushes();
-       m_Container.BuildInRadiant(TRUE);
+       m_Container.BuildInRadiant(true);
 }
 
 void DShape::BuildInversePrism(vec3_t min, vec3_t max, int nSides, bool bAlignTop)
 }
 
 void DShape::BuildInversePrism(vec3_t min, vec3_t max, int nSides, bool bAlignTop)
@@ -180,11 +180,11 @@ void DShape::BuildInversePrism(vec3_t min, vec3_t max, int nSides, bool bAlignTo
                
                if(top[1] != bottom[1]) // internal line is flat already if true
                {                       
                
                if(top[1] != bottom[1]) // internal line is flat already if true
                {                       
-                       pB->AddFace(va[i-1], top, vb[i-1], "textures/common/caulk", FALSE);
-                       pB->AddFace(va[i], vb[i], bottom, "textures/common/caulk", FALSE);
+                       pB->AddFace(va[i-1], top, vb[i-1], "textures/common/caulk", false);
+                       pB->AddFace(va[i], vb[i], bottom, "textures/common/caulk", false);
                }       // add cut-off planes
 
                }       // add cut-off planes
 
-               pB->AddFace(va[i-1], vb[i-1], vb[i], GetCurrentTexture(), FALSE);
+               pB->AddFace(va[i-1], vb[i-1], vb[i], GetCurrentTexture(), false);
                // add internal polygon plane
        }
 }
                // add internal polygon plane
        }
 }
@@ -264,11 +264,11 @@ void DShape::BuildBorderedPrism(vec3_t min, vec3_t max, int nSides, int nBorder,
        {
                DBrush* pB = GetBoundingCube(min, max, "textures/common/caulk");
 
        {
                DBrush* pB = GetBoundingCube(min, max, "textures/common/caulk");
 
-               pB->AddFace(origin, vc[i-1], vd[i-1], "textures/common/caulk", FALSE);
-               pB->AddFace(origin, vd[i], vc[i], "textures/common/caulk", FALSE); 
+               pB->AddFace(origin, vc[i-1], vd[i-1], "textures/common/caulk", false);
+               pB->AddFace(origin, vd[i], vc[i], "textures/common/caulk", false); 
 
 
-               pB->AddFace(vc[i-1], vc[i], vd[i], GetCurrentTexture(), FALSE);
-               pB->AddFace(vb[i], va[i], va[i-1], GetCurrentTexture(), FALSE);
+               pB->AddFace(vc[i-1], vc[i], vd[i], GetCurrentTexture(), false);
+               pB->AddFace(vb[i], va[i], va[i-1], GetCurrentTexture(), false);
        }
 }
 
        }
 }
 
@@ -343,18 +343,18 @@ DBrush* DShape::GetBoundingCube(vec3_t min, vec3_t max, const char *textureName,
        //----- Add Six Cube Faces ---------
 
        if(bUseFaces[0])
        //----- Add Six Cube Faces ---------
 
        if(bUseFaces[0])
-               pB->AddFace(v1, v2, v3, textureName, FALSE);
+               pB->AddFace(v1, v2, v3, textureName, false);
        if(bUseFaces[1])
        if(bUseFaces[1])
-               pB->AddFace(v1, v3, v6, textureName, FALSE);
+               pB->AddFace(v1, v3, v6, textureName, false);
        if(bUseFaces[2])
        if(bUseFaces[2])
-               pB->AddFace(v1, v7, v2, textureName, FALSE);
+               pB->AddFace(v1, v7, v2, textureName, false);
 
        if(bUseFaces[3])
 
        if(bUseFaces[3])
-               pB->AddFace(v5, v6, v3, textureName, FALSE);
+               pB->AddFace(v5, v6, v3, textureName, false);
        if(bUseFaces[4])
        if(bUseFaces[4])
-               pB->AddFace(v5, v2, v7, textureName, FALSE);
+               pB->AddFace(v5, v2, v7, textureName, false);
        if(bUseFaces[5])
        if(bUseFaces[5])
-               pB->AddFace(v5, v7, v6, textureName, FALSE);
+               pB->AddFace(v5, v7, v6, textureName, false);
 
        //----------------------------------
 
 
        //----------------------------------
 
@@ -364,7 +364,7 @@ DBrush* DShape::GetBoundingCube(vec3_t min, vec3_t max, const char *textureName,
 bool DShape::BuildPit(vec3_t min, vec3_t max)
 {
        if((max[2] - min[2]) < 196)
 bool DShape::BuildPit(vec3_t min, vec3_t max)
 {
        if((max[2] - min[2]) < 196)
-               return FALSE;
+               return false;
 
        srand(time(NULL));
 
 
        srand(time(NULL));
 
@@ -465,5 +465,5 @@ bool DShape::BuildPit(vec3_t min, vec3_t max)
 
 // ****** END NODROP ********
 
 
 // ****** END NODROP ********
 
-       return TRUE;
+       return true;
 }
 }
index 4bc4baa856efb3996468351511d35206775fa2fa..3c4ed75e5f54bdeb1a8ac4ec787174b38f0cddff 100644 (file)
@@ -24,13 +24,15 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 #if !defined(AFX_DSHAPE_H__0B30B302_9D21_4C2D_836A_61F3C8D4244D__INCLUDED_)
 #define AFX_DSHAPE_H__0B30B302_9D21_4C2D_836A_61F3C8D4244D__INCLUDED_
 
 #if !defined(AFX_DSHAPE_H__0B30B302_9D21_4C2D_836A_61F3C8D4244D__INCLUDED_)
 #define AFX_DSHAPE_H__0B30B302_9D21_4C2D_836A_61F3C8D4244D__INCLUDED_
 
-#include "DMap.h"      // Added by ClassView
-#include "StdAfx.h"    // Added by ClassView
-
 #if _MSC_VER > 1000
 #pragma once
 #endif // _MSC_VER > 1000
 
 #if _MSC_VER > 1000
 #pragma once
 #endif // _MSC_VER > 1000
 
+#include "mathlib.h"
+#include "DMap.h"
+class DBrush;
+class DEntity;
+
 // defines for polygon stuff
 #define MAX_POLYGON_FACES      128
 
 // defines for polygon stuff
 #define MAX_POLYGON_FACES      128
 
index 35ee494d4ba00319456b641ca80ca7c62dd54f0d..38abb659c0ada0912335d009de7b13bc183dc440 100644 (file)
@@ -17,9 +17,9 @@ License along with this library; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
 
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
 
-#include "StdAfx.h"
+#include "DTrainDrawer.h"
 
 
-#include "gtkr_list.h"
+#include <list>
 #include "str.h"
 
 #include "DPoint.h"
 #include "str.h"
 
 #include "DPoint.h"
@@ -28,31 +28,33 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 #include "DEPair.h"
 #include "DPatch.h"
 #include "DEntity.h"
 #include "DEPair.h"
 #include "DPatch.h"
 #include "DEntity.h"
-#include "DTrainDrawer.h"
 
 #include "misc.h"
 #include "funchandlers.h"
 
 
 #include "misc.h"
 #include "funchandlers.h"
 
+#include "iglrender.h"
+#include "math/matrix.h"
+
 #include "dialogs/dialogs-gtk.h"
 
 DTrainDrawer::DTrainDrawer() {
 #include "dialogs/dialogs-gtk.h"
 
 DTrainDrawer::DTrainDrawer() {
-       refCount = 1;
-       m_bHooked = FALSE;
-       m_bDisplay = FALSE;
+       m_bDisplay = false;
 
        BuildPaths();
 
        BuildPaths();
+  constructShaders();
+  GlobalShaderCache().attachRenderable(*this);
 }
 
 DTrainDrawer::~DTrainDrawer(void) {
 }
 
 DTrainDrawer::~DTrainDrawer(void) {
-       if(m_bHooked)
-               UnRegister();
+  GlobalShaderCache().detachRenderable(*this);
+  destroyShaders();
 
        ClearPoints();
        ClearSplines();
 }
 
 void DTrainDrawer::ClearSplines() {
 
        ClearPoints();
        ClearSplines();
 }
 
 void DTrainDrawer::ClearSplines() {
-       for(list<splinePoint_t *>::const_iterator deadSpline = m_splineList.begin(); deadSpline != m_splineList.end(); deadSpline++) {
+       for(std::list<splinePoint_t *>::const_iterator deadSpline = m_splineList.begin(); deadSpline != m_splineList.end(); deadSpline++) {
                (*deadSpline)->m_pointList.clear();
                (*deadSpline)->m_vertexList.clear();
                delete (*deadSpline);
                (*deadSpline)->m_pointList.clear();
                (*deadSpline)->m_vertexList.clear();
                delete (*deadSpline);
@@ -62,25 +64,13 @@ void DTrainDrawer::ClearSplines() {
 }
 
 void DTrainDrawer::ClearPoints() {
 }
 
 void DTrainDrawer::ClearPoints() {
-       for(list<controlPoint_t *>::const_iterator deadPoint = m_pointList.begin(); deadPoint != m_pointList.end(); deadPoint++) {
+       for(std::list<controlPoint_t *>::const_iterator deadPoint = m_pointList.begin(); deadPoint != m_pointList.end(); deadPoint++) {
                delete *deadPoint;
        }
 
        m_pointList.clear();
 }
 
                delete *deadPoint;
        }
 
        m_pointList.clear();
 }
 
-void DTrainDrawer::Register() {
-       __QGLTABLENAME.m_pfnHookGL2DWindow( this );
-       __QGLTABLENAME.m_pfnHookGL3DWindow( this );
-       m_bHooked = TRUE;
-}
-
-void DTrainDrawer::UnRegister() {
-       __QGLTABLENAME.m_pfnUnHookGL2DWindow( this );
-       __QGLTABLENAME.m_pfnUnHookGL3DWindow( this );
-       m_bHooked = FALSE;
-}
-
 void CalculateSpline_r(vec3_t* v, int count, vec3_t out, float tension) {
        vec3_t dist;
 
 void CalculateSpline_r(vec3_t* v, int count, vec3_t out, float tension) {
        vec3_t dist;
 
@@ -106,93 +96,70 @@ void CalculateSpline_r(vec3_t* v, int count, vec3_t out, float tension) {
        delete[] v2;
 }
 
        delete[] v2;
 }
 
-void DTrainDrawer::Draw3D() {
-
-       if(!m_bDisplay) {
-               return;
-       }
-
-       __QGLTABLENAME.m_pfn_qglPushAttrib(GL_ALL_ATTRIB_BITS);
-
-       __QGLTABLENAME.m_pfn_qglDisable(GL_BLEND);
-       __QGLTABLENAME.m_pfn_qglDisable(GL_LINE_SMOOTH);
-
-       __QGLTABLENAME.m_pfn_qglPushMatrix();
-       
-       __QGLTABLENAME.m_pfn_qglLineWidth(2.0f);
-       __QGLTABLENAME.m_pfn_qglColor4f(1.0f, 1.0f, 1.0f, 1.0f);
-
-       __QGLTABLENAME.m_pfn_qglEnable(GL_BLEND);
-       __QGLTABLENAME.m_pfn_qglBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-       __QGLTABLENAME.m_pfn_qglDisable(GL_POLYGON_SMOOTH);
-
-       __QGLTABLENAME.m_pfn_qglDepthFunc(GL_ALWAYS);
-
-       for(list<splinePoint_t* >::const_iterator sp = m_splineList.begin(); sp != m_splineList.end(); sp++) {
+void DTrainDrawer::render(RenderStateFlags state) const
+{
+       for(std::list<splinePoint_t* >::const_iterator sp = m_splineList.begin(); sp != m_splineList.end(); sp++) {
                splinePoint_t* pSP = (*sp);
 
                splinePoint_t* pSP = (*sp);
 
-               __QGLTABLENAME.m_pfn_qglBegin(GL_LINE_STRIP);
-                       for(list<DPoint >::const_iterator v = pSP->m_vertexList.begin(); v != pSP->m_vertexList.end(); v++) {
-                               __QGLTABLENAME.m_pfn_qglVertex3fv((*v)._pnt);
+               glBegin(GL_LINE_STRIP);
+                       for(std::list<DPoint >::const_iterator v = pSP->m_vertexList.begin(); v != pSP->m_vertexList.end(); v++) {
+                               glVertex3fv((*v)._pnt);
                        }
                        }
-               __QGLTABLENAME.m_pfn_qglEnd();
+               glEnd();
 
        }
 
        }
-
-       __QGLTABLENAME.m_pfn_qglPopMatrix();
-       __QGLTABLENAME.m_pfn_qglPopAttrib();
 }
 
 }
 
-void DTrainDrawer::Draw2D(VIEWTYPE vt) {
+const char* DTrainDrawer_state_wireframe = "$bobtoolz/traindrawer/wireframe";
+const char* DTrainDrawer_state_solid = "$bobtoolz/traindrawer/solid";
 
 
-       if(!m_bDisplay) {
-               return;
-       }
-
-       __QGLTABLENAME.m_pfn_qglPushAttrib(GL_ALL_ATTRIB_BITS);
-
-       __QGLTABLENAME.m_pfn_qglDisable(GL_BLEND);
-       __QGLTABLENAME.m_pfn_qglDisable(GL_LINE_SMOOTH);
-
-       __QGLTABLENAME.m_pfn_qglPushMatrix();
-       
-       switch(vt)
-       {
-       case XY:
-               break;
-       case XZ:
-               __QGLTABLENAME.m_pfn_qglRotatef(270.0f, 1.0f, 0.0f, 0.0f);
-               break;
-       case YZ:
-               __QGLTABLENAME.m_pfn_qglRotatef(270.0f, 1.0f, 0.0f, 0.0f);
-               __QGLTABLENAME.m_pfn_qglRotatef(270.0f, 0.0f, 0.0f, 1.0f);
-               break;
-       }
-
-       __QGLTABLENAME.m_pfn_qglLineWidth(1.0f);
-       __QGLTABLENAME.m_pfn_qglColor4f(1.0f, 0.0f, 0.0f, 0.5f);
-
-       __QGLTABLENAME.m_pfn_qglEnable(GL_BLEND);
-       __QGLTABLENAME.m_pfn_qglBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-       __QGLTABLENAME.m_pfn_qglDisable(GL_POLYGON_SMOOTH);
-
-       __QGLTABLENAME.m_pfn_qglDepthFunc(GL_ALWAYS);
-
-       __QGLTABLENAME.m_pfn_qglColor4f(1.f, 0.f, 0.f, 1.f);
+void DTrainDrawer::constructShaders()
+{
+  OpenGLState state;
+  GlobalOpenGLStateLibrary().getDefaultState(state);
+  state.m_state = RENDER_COLOURWRITE|RENDER_DEPTHWRITE|RENDER_BLEND;
+  state.m_sort = OpenGLState::eSortOverlayFirst;
+  state.m_linewidth = 1;
+  state.m_colour[0] = 1;
+  state.m_colour[1] = 0;
+  state.m_colour[2] = 0;
+  state.m_colour[3] = 1;
+  state.m_linewidth = 1;
+  GlobalOpenGLStateLibrary().insert(DTrainDrawer_state_wireframe, state);
+
+  state.m_colour[0] = 1;
+  state.m_colour[1] = 1;
+  state.m_colour[2] = 1;
+  state.m_colour[3] = 1;
+  state.m_linewidth = 2;
+  GlobalOpenGLStateLibrary().insert(DTrainDrawer_state_solid, state);
+
+  m_shader_wireframe = GlobalShaderCache().capture(DTrainDrawer_state_wireframe);
+  m_shader_solid = GlobalShaderCache().capture(DTrainDrawer_state_solid);
+}
 
 
-       for(list<splinePoint_t* >::const_iterator sp = m_splineList.begin(); sp != m_splineList.end(); sp++) {
-               splinePoint_t* pSP = (*sp);
+void DTrainDrawer::destroyShaders()
+{
+  GlobalOpenGLStateLibrary().erase(DTrainDrawer_state_wireframe);
+  GlobalOpenGLStateLibrary().erase(DTrainDrawer_state_solid);
+  GlobalShaderCache().release(DTrainDrawer_state_wireframe);
+  GlobalShaderCache().release(DTrainDrawer_state_solid);
+}
 
 
-               __QGLTABLENAME.m_pfn_qglBegin(GL_LINE_STRIP);
-                       for(list<DPoint >::const_iterator v = pSP->m_vertexList.begin(); v != pSP->m_vertexList.end(); v++) {
-                               __QGLTABLENAME.m_pfn_qglVertex3fv((*v)._pnt);
-                       }
-               __QGLTABLENAME.m_pfn_qglEnd();
 
 
+void DTrainDrawer::renderSolid(Renderer& renderer, const VolumeTest& volume) const
+{
+       if(!m_bDisplay) {
+               return;
        }
 
        }
 
-       __QGLTABLENAME.m_pfn_qglPopMatrix();
-       __QGLTABLENAME.m_pfn_qglPopAttrib();
+  renderer.SetState(m_shader_wireframe, Renderer::eWireframeOnly);
+  renderer.SetState(m_shader_solid, Renderer::eFullMaterials);
+  renderer.addRenderable(*this, g_matrix4_identity);
+}
+void DTrainDrawer::renderWireframe(Renderer& renderer, const VolumeTest& volume) const
+{
+  renderSolid(renderer, volume);
 }
 
 void AddSplineControl(const char* control, splinePoint_t* pSP) {
 }
 
 void AddSplineControl(const char* control, splinePoint_t* pSP) {
@@ -263,7 +230,7 @@ void DTrainDrawer::BuildPaths() {
                }
        }
 
                }
        }
 
-  list<splinePoint_t* >::const_iterator sp;
+  std::list<splinePoint_t* >::const_iterator sp;
        for(sp = m_splineList.begin(); sp != m_splineList.end(); sp++) {
                splinePoint_t* pSP = (*sp);
 
        for(sp = m_splineList.begin(); sp != m_splineList.end(); sp++) {
                splinePoint_t* pSP = (*sp);
 
@@ -278,7 +245,7 @@ void DTrainDrawer::BuildPaths() {
                pSP->pTarget = pTarget;
 
 
                pSP->pTarget = pTarget;
 
 
-               for(list<controlPoint_t >::iterator cp = pSP->m_pointList.begin(); cp != pSP->m_pointList.end(); cp++) {                        
+               for(std::list<controlPoint_t >::iterator cp = pSP->m_pointList.begin(); cp != pSP->m_pointList.end(); cp++) {                   
                        controlPoint_t* pControl = FindControlPoint( (*cp).strName );
                        if(!pControl) {
                                Sys_Printf( "couldn't find control %s", (*cp).strName );
                        controlPoint_t* pControl = FindControlPoint( (*cp).strName );
                        if(!pControl) {
                                Sys_Printf( "couldn't find control %s", (*cp).strName );
@@ -306,7 +273,7 @@ void DTrainDrawer::BuildPaths() {
                VectorCopy(pSP->point.vOrigin, v[0]);
 
                int i = 1;
                VectorCopy(pSP->point.vOrigin, v[0]);
 
                int i = 1;
-               for(list<controlPoint_t>::reverse_iterator cp = pSP->m_pointList.rbegin(); cp != pSP->m_pointList.rend(); cp++) {
+               for(std::list<controlPoint_t>::reverse_iterator cp = pSP->m_pointList.rbegin(); cp != pSP->m_pointList.rend(); cp++) {
                        VectorCopy((*cp).vOrigin, v[i]);
                        i++;
                }
                        VectorCopy((*cp).vOrigin, v[i]);
                        i++;
                }
@@ -350,13 +317,13 @@ splinePoint_t* DTrainDrawer::AddSplinePoint(const char* name, const char* target
 
 controlPoint_t* DTrainDrawer::FindControlPoint(const char* name)
 {
 
 controlPoint_t* DTrainDrawer::FindControlPoint(const char* name)
 {
-       for(list<controlPoint_t*>::const_iterator cp = m_pointList.begin(); cp != m_pointList.end(); cp++) {
+       for(std::list<controlPoint_t*>::const_iterator cp = m_pointList.begin(); cp != m_pointList.end(); cp++) {
                if(!strcmp(name, (*cp)->strName)) {
                        return (*cp);
                }
        }
 
                if(!strcmp(name, (*cp)->strName)) {
                        return (*cp);
                }
        }
 
-       for(list<splinePoint_t*>::const_iterator sp = m_splineList.begin(); sp != m_splineList.end(); sp++) {
+       for(std::list<splinePoint_t*>::const_iterator sp = m_splineList.begin(); sp != m_splineList.end(); sp++) {
                if(!strcmp(name, (*sp)->point.strName)) {
                        return &((*sp)->point);
                }
                if(!strcmp(name, (*sp)->point.strName)) {
                        return &((*sp)->point);
                }
index ae9fa2c0ac5af2118a473dc8ac300a5c0f8d1f4a..9d8903ee736681d1db8a0bb7388d7f240c35cfda 100644 (file)
@@ -29,6 +29,15 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 #pragma once
 #endif // _MSC_VER > 1000
 
 #pragma once
 #endif // _MSC_VER > 1000
 
+#include <list>
+#include "mathlib.h"
+
+#include "irender.h"
+#include "renderable.h"
+
+class DPoint;
+class Shader;
+
 typedef struct {
        char strName[64];
 
 typedef struct {
        char strName[64];
 
@@ -41,34 +50,33 @@ typedef struct {
        char strControl[64];
        char strTarget[64];
 
        char strControl[64];
        char strTarget[64];
 
-       list<controlPoint_t> m_pointList;
-       list<DPoint> m_vertexList;
+       std::list<controlPoint_t> m_pointList;
+       std::list<DPoint> m_vertexList;
 
        controlPoint_t* pTarget;
 } splinePoint_t;
 
 
        controlPoint_t* pTarget;
 } splinePoint_t;
 
-class DTrainDrawer :
-       public IGL2DWindow,
-       public IGL3DWindow
+class DTrainDrawer : public Renderable, public OpenGLRenderable
 {
 private:
 {
 private:
-       list<splinePoint_t*> m_splineList;
-       list<controlPoint_t*> m_pointList;
-       int refCount;
+       std::list<splinePoint_t*> m_splineList;
+       std::list<controlPoint_t*> m_pointList;
 
 
-       bool m_bHooked;
        bool m_bDisplay;
        bool m_bDisplay;
+  Shader* m_shader_wireframe;
+  Shader* m_shader_solid;
 public:
 public:
-       void UnRegister();
-       void Register();
        
        DTrainDrawer();
        virtual ~DTrainDrawer(void);
 
        
        DTrainDrawer();
        virtual ~DTrainDrawer(void);
 
-       void Draw3D();
-       void Draw2D(VIEWTYPE vt);
-       void IncRef() { refCount++; }
-       void DecRef() { refCount--; if (refCount <= 0) delete this; }
+  void render(RenderStateFlags state) const;
+  void renderSolid(Renderer& renderer, const VolumeTest& volume) const;
+  void renderWireframe(Renderer& renderer, const VolumeTest& volume) const;
+
+  void constructShaders();
+       void destroyShaders();
+
        void ClearSplines();
        void ClearPoints();
        void BuildPaths();
        void ClearSplines();
        void ClearPoints();
        void BuildPaths();
index 237c9ccf75101da8eeeb4ad57d4049a19ae2d79d..54850ceb4f76966106e2041a64da841f9b2d2cda 100644 (file)
@@ -17,9 +17,9 @@ License along with this library; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
 
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
 
-#include "StdAfx.h"
+#include "DTreePlanter.h"
 
 
-#include "gtkr_list.h"
+#include <list>
 #include "str.h"
 
 #include "DPoint.h"
 #include "str.h"
 
 #include "DPoint.h"
@@ -32,17 +32,17 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 #include "ScriptParser.h"
 #include "misc.h"
 
 #include "ScriptParser.h"
 #include "misc.h"
 
-#include "DTreePlanter.h"
 
 
 #include "funchandlers.h"
 
 
 
 #include "funchandlers.h"
 
-bool DTreePlanter::OnMouseMove(guint32 nFlags, gdouble x, gdouble y) {
-       return false;
-}
-
-bool DTreePlanter::OnLButtonDown(guint32 nFlags, gdouble x, gdouble y) {
-       VIEWTYPE vt = m_XYWrapper->GetViewType();
+SignalHandlerResult DTreePlanter::mouseDown(const WindowVector& position, ButtonIdentifier button, ModifierFlags modifiers)
+{
+  if(button != c_buttonLeft)
+  {
+    return SIGNAL_CONTINUE_EMISSION;
+  }
+       VIEWTYPE vt = GlobalRadiant().XYWindow_getViewType();
 
        switch(vt) {
                case XY:
 
        switch(vt) {
                case XY:
@@ -50,14 +50,14 @@ bool DTreePlanter::OnLButtonDown(guint32 nFlags, gdouble x, gdouble y) {
                case YZ:
                case XZ:
                default:
                case YZ:
                case XZ:
                default:
-                       return false;
+                       return SIGNAL_CONTINUE_EMISSION;
        }
 
        }
 
-       vec3_t pt, vhit;
+       Vector3 pt, vhit;
 
 
-       m_XYWrapper->SnapToGrid( static_cast<int>(x), static_cast<int>(y), pt );
+  pt = vector3_snapped(GlobalRadiant().XYWindow_windowToWorld(position));
 
 
-       if(FindDropPoint(pt, vhit)) {
+       if(FindDropPoint(vector3_to_array(pt), vector3_to_array(vhit))) {
                vhit[2] += m_offset;
 
                char buffer[128];
                vhit[2] += m_offset;
 
                char buffer[128];
@@ -96,7 +96,7 @@ bool DTreePlanter::OnLButtonDown(guint32 nFlags, gdouble x, gdouble y) {
                                e2.LoadFromEntity(lastEntNum, TRUE);
                                e2.AddEPair("target", buffer);
                                e2.RemoveFromRadiant();
                                e2.LoadFromEntity(lastEntNum, TRUE);
                                e2.AddEPair("target", buffer);
                                e2.RemoveFromRadiant();
-                               e2.BuildInRadiant(FALSE);
+                               e2.BuildInRadiant(false);
                        }
 #endif
                }
                        }
 #endif
                }
@@ -121,34 +121,14 @@ bool DTreePlanter::OnLButtonDown(guint32 nFlags, gdouble x, gdouble y) {
                        e.AddEPair("modelscale", buffer);
                }
 
                        e.AddEPair("modelscale", buffer);
                }
 
-               e.BuildInRadiant( FALSE );
+               e.BuildInRadiant( false );
        }
 
        if(m_autoLink) {
                DoTrainPathPlot();
        }
 
        }
 
        if(m_autoLink) {
                DoTrainPathPlot();
        }
 
-       return true;
-}
-
-bool DTreePlanter::OnLButtonUp(guint32 nFlags, gdouble x, gdouble y) {
-       return false;
-}
-
-bool DTreePlanter::OnRButtonDown(guint32 nFlags, gdouble x, gdouble y) {
-       return false;
-}
-
-bool DTreePlanter::OnRButtonUp(guint32 nFlags, gdouble x, gdouble y) {
-       return false;
-}
-
-bool DTreePlanter::OnMButtonDown(guint32 nFlags, gdouble x, gdouble y) {
-       return false;
-}
-
-bool DTreePlanter::OnMButtonUp(guint32 nFlags, gdouble x, gdouble y) {
-       return false;
+       return SIGNAL_STOP_EMISSION;
 }
 
 bool DTreePlanter::FindDropPoint(vec3_t in, vec3_t out) {
 }
 
 bool DTreePlanter::FindDropPoint(vec3_t in, vec3_t out) {
@@ -226,7 +206,7 @@ void DTreePlanter::DropEntsToGround( void ) {
                sprintf( buffer, "%f %f %f", out[0], out[1], out[2] );
                ent.AddEPair( "origin", buffer );
                ent.RemoveFromRadiant();
                sprintf( buffer, "%f %f %f", out[0], out[1], out[2] );
                ent.AddEPair( "origin", buffer );
                ent.RemoveFromRadiant();
-               ent.BuildInRadiant(FALSE);
+               ent.BuildInRadiant(false);
        }
 
        g_FuncTable.m_pfnReleaseSelectedBrushHandles();
        }
 
        g_FuncTable.m_pfnReleaseSelectedBrushHandles();
@@ -254,7 +234,7 @@ void DTreePlanter::MakeChain( void ) {
                        e.AddEPair( "control", buffer );
                }
 
                        e.AddEPair( "control", buffer );
                }
 
-               e.BuildInRadiant( FALSE );
+               e.BuildInRadiant( false );
        }
 
        for(i = 0; i < m_linkNum-1; i++) {
        }
 
        for(i = 0; i < m_linkNum-1; i++) {
@@ -266,7 +246,7 @@ void DTreePlanter::MakeChain( void ) {
                sprintf( buffer, "0 %i 0", (i * 64) + 32);
                e.AddEPair( "origin", buffer );
 
                sprintf( buffer, "0 %i 0", (i * 64) + 32);
                e.AddEPair( "origin", buffer );
 
-               e.BuildInRadiant( FALSE );
+               e.BuildInRadiant( false );
        }
 }
 
        }
 }
 
@@ -290,7 +270,7 @@ void DTreePlanter::SelectChain( void ) {
                        e.AddEPair( "control", buffer );
                }
 
                        e.AddEPair( "control", buffer );
                }
 
-               e.BuildInRadiant( FALSE );
+               e.BuildInRadiant( false );
        }
 
        for(int i = 0; i < m_linkNum-1; i++) {
        }
 
        for(int i = 0; i < m_linkNum-1; i++) {
@@ -302,6 +282,6 @@ void DTreePlanter::SelectChain( void ) {
                sprintf( buffer, "0 %i 0", (i * 64) + 32);
                e.AddEPair( "origin", buffer );
 
                sprintf( buffer, "0 %i 0", (i * 64) + 32);
                e.AddEPair( "origin", buffer );
 
-               e.BuildInRadiant( FALSE );
+               e.BuildInRadiant( false );
        }*/
 }
        }*/
 }
index 87d0d6c8b71e76c084e0dbff99fa7e7c586f4b2d..61bc1e8950e50130b2a4a79250aa1954ce0e21d7 100644 (file)
@@ -20,6 +20,14 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 #ifndef __DTREE_H__
 #define __DTREE_H__
 
 #ifndef __DTREE_H__
 #define __DTREE_H__
 
+#include "qerplugin.h"
+#include "signal/isignal.h"
+#include "string/string.h"
+
+#include "DEntity.h"
+#include "scriptparser.h"
+#include "mathlib.h"
+#include "misc.h"
 
 #define MAX_QPATH 64
 
 
 #define MAX_QPATH 64
 
@@ -29,23 +37,13 @@ typedef struct treeModel_s {
 
 #define MAX_TP_MODELS 256
 
 
 #define MAX_TP_MODELS 256
 
-class DTreePlanter : public IWindowListener {
+class DTreePlanter {
+  MouseEventHandlerId m_mouseDown;
 public:
 public:
-       virtual bool OnMouseMove(guint32 nFlags, gdouble x, gdouble y);
-       virtual bool OnLButtonDown(guint32 nFlags, gdouble x, gdouble y);
-       virtual bool OnMButtonDown(guint32 nFlags, gdouble x, gdouble y);
-       virtual bool OnRButtonDown(guint32 nFlags, gdouble x, gdouble y);
-       virtual bool OnLButtonUp(guint32 nFlags, gdouble x, gdouble y);
-       virtual bool OnMButtonUp(guint32 nFlags, gdouble x, gdouble y);
-       virtual bool OnRButtonUp(guint32 nFlags, gdouble x, gdouble y);
-       virtual bool OnKeyPressed(char *s) { return false; }
-       virtual bool Paint() { return true; }
-       virtual void Close() { }
-       
-       DTreePlanter() {
-               m_refCount =    1;
-               m_hooked =              false;
-               m_XYWrapper =   NULL;
+       SignalHandlerResult mouseDown(const WindowVector& position, ButtonIdentifier button, ModifierFlags modifiers);
+  typedef Member3<DTreePlanter, const WindowVector&, ButtonIdentifier, ModifierFlags, SignalHandlerResult, &DTreePlanter::mouseDown> MouseDownCaller;
+
+  DTreePlanter() {
                m_numModels =   0;
                m_offset =              0;
                m_maxPitch =    0;
                m_numModels =   0;
                m_offset =              0;
                m_maxPitch =    0;
@@ -57,8 +55,6 @@ public:
                m_autoLink =    false;
                m_linkNum =             0;
 
                m_autoLink =    false;
                m_linkNum =             0;
 
-               Register();
-
                m_world.LoadSelectedBrushes();
 
                char buffer[256];
                m_world.LoadSelectedBrushes();
 
                char buffer[256];
@@ -85,9 +81,16 @@ public:
 
                        fclose( file );
                }
 
                        fclose( file );
                }
+
+    m_mouseDown = GlobalRadiant().XYWindowMouseDown_connect(makeSignalHandler3(MouseDownCaller(), *this));
        }
 
        }
 
-#define MT(t)  !stricmp( pToken, t )
+  virtual ~DTreePlanter()
+  {
+    GlobalRadiant().XYWindowMouseDown_disconnect(m_mouseDown);
+  }
+
+#define MT(t)  string_equal_nocase( pToken, t )
 #define GT             pToken = pScriptParser->GetToken( true )
 #define CT             if(!*pToken) { return; }
 
 #define GT             pToken = pScriptParser->GetToken( true )
 #define CT             if(!*pToken) { return; }
 
@@ -161,41 +164,16 @@ public:
                } while( true );
        }
 
                } while( true );
        }
 
-       virtual ~DTreePlanter() {
-               UnRegister();
-       }
-
-       virtual void IncRef() { m_refCount++; }
-       virtual void DecRef() { m_refCount--; if (m_refCount <= 0) delete this; }
-
-       void Register() {
-               if(!m_hooked) {
-                       g_MessageTable.m_pfnHookWindow( this );
-                       m_XYWrapper = g_MessageTable.m_pfnGetXYWndWrapper();
-                       m_hooked = true;
-               }
-       }
-
-       void UnRegister() {
-               if(m_hooked) {
-                       g_MessageTable.m_pfnUnHookWindow( this );
-                       m_XYWrapper = NULL;
-                       m_hooked = false;
-               }
-       }
-
        bool FindDropPoint(vec3_t in, vec3_t out);
        void DropEntsToGround( void );
        void MakeChain( void );
        void SelectChain( void );
 
 private:
        bool FindDropPoint(vec3_t in, vec3_t out);
        void DropEntsToGround( void );
        void MakeChain( void );
        void SelectChain( void );
 
 private:
-       IXYWndWrapper*  m_XYWrapper;
        DEntity                 m_world;
 
        treeModel_t             m_trees[MAX_TP_MODELS];
 
        DEntity                 m_world;
 
        treeModel_t             m_trees[MAX_TP_MODELS];
 
-       int                             m_refCount;
        int                             m_numModels;
        int                             m_offset;
        int                             m_maxPitch;
        int                             m_numModels;
        int                             m_offset;
        int                             m_maxPitch;
@@ -210,7 +188,6 @@ private:
        float                   m_minScale;
        float                   m_maxScale;
 
        float                   m_minScale;
        float                   m_maxScale;
 
-       bool                    m_hooked;
        bool                    m_useScale;
        bool                    m_setAngles;
        bool                    m_autoLink;
        bool                    m_useScale;
        bool                    m_setAngles;
        bool                    m_autoLink;
index 46ddca55cd18456d9b79764f21459f90e62b6024..0a936941883d18225cc354ceadca6f10d2819dac 100644 (file)
@@ -21,14 +21,16 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 //
 //////////////////////////////////////////////////////////////////////
 
 //
 //////////////////////////////////////////////////////////////////////
 
-#include "StdAfx.h"
+#include "DVisDrawer.h"
+
+#include "iglrender.h"
+#include "math/matrix.h"
 
 
-#include "gtkr_list.h"
+#include <list>
 #include "str.h"
 
 #include "DPoint.h"
 #include "DWinding.h"
 #include "str.h"
 
 #include "DPoint.h"
 #include "DWinding.h"
-#include "DVisDrawer.h"
 
 #include "misc.h"
 #include "funchandlers.h"
 
 #include "misc.h"
 #include "funchandlers.h"
@@ -39,15 +41,16 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
 DVisDrawer::DVisDrawer()
 {
 
 DVisDrawer::DVisDrawer()
 {
-       refCount = 1;
-       m_bHooked = FALSE;
        m_list = NULL;
        m_list = NULL;
+
+  constructShaders();
+  GlobalShaderCache().attachRenderable(*this);
 }
 
 DVisDrawer::~DVisDrawer()
 {
 }
 
 DVisDrawer::~DVisDrawer()
 {
-       if(m_bHooked)
-               UnRegister();
+  GlobalShaderCache().detachRenderable(*this);
+  destroyShaders();
 
        g_VisView = NULL;
 }
 
        g_VisView = NULL;
 }
@@ -55,117 +58,73 @@ DVisDrawer::~DVisDrawer()
 //////////////////////////////////////////////////////////////////////
 // Implementation
 //////////////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////////////
 // Implementation
 //////////////////////////////////////////////////////////////////////
+const char* g_state_solid = "$bobtoolz/visdrawer/solid";
+const char* g_state_wireframe = "$bobtoolz/visdrawer/wireframe";
 
 
-void DVisDrawer::Draw2D(VIEWTYPE vt)
+void DVisDrawer::constructShaders()
 {
 {
-       if(!m_list)
-               return;
-
-       __QGLTABLENAME.m_pfn_qglPushAttrib(GL_ALL_ATTRIB_BITS);
+  OpenGLState state;
+  GlobalOpenGLStateLibrary().getDefaultState(state);
+  state.m_state = RENDER_COLOURWRITE|RENDER_DEPTHWRITE|RENDER_COLOURCHANGE;
+  state.m_linewidth = 1;
 
 
-       __QGLTABLENAME.m_pfn_qglDisable(GL_BLEND);
-       __QGLTABLENAME.m_pfn_qglDisable(GL_LINE_SMOOTH);
+  GlobalOpenGLStateLibrary().insert(g_state_wireframe, state);
 
 
-       __QGLTABLENAME.m_pfn_qglPushMatrix();
-       
-       switch(vt)
-       {
-       case XY:
-               break;
-       case XZ:
-               __QGLTABLENAME.m_pfn_qglRotatef(270.0f, 1.0f, 0.0f, 0.0f);
-               break;
-       case YZ:
-               __QGLTABLENAME.m_pfn_qglRotatef(270.0f, 1.0f, 0.0f, 0.0f);
-               __QGLTABLENAME.m_pfn_qglRotatef(270.0f, 0.0f, 0.0f, 1.0f);
-               break;
-       }
+  GlobalOpenGLStateLibrary().getDefaultState(state);
+  state.m_state = RENDER_FILL|RENDER_BLEND|RENDER_COLOURWRITE|RENDER_COLOURCHANGE|RENDER_SMOOTH|RENDER_DEPTHWRITE;
 
 
-       __QGLTABLENAME.m_pfn_qglLineWidth(1.0f);
-       __QGLTABLENAME.m_pfn_qglColor4f(1.0f, 0.0f, 0.0f, 0.5f);
+  GlobalOpenGLStateLibrary().insert(g_state_solid, state);
 
 
-       __QGLTABLENAME.m_pfn_qglEnable(GL_BLEND);
-       __QGLTABLENAME.m_pfn_qglBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-       __QGLTABLENAME.m_pfn_qglDisable(GL_POLYGON_SMOOTH);
+  m_shader_solid = GlobalShaderCache().capture(g_state_solid);
+  m_shader_wireframe = GlobalShaderCache().capture(g_state_wireframe);
+}
 
 
-       __QGLTABLENAME.m_pfn_qglDepthFunc(GL_ALWAYS);
+void DVisDrawer::destroyShaders()
+{
+  GlobalShaderCache().release(g_state_solid);
+  GlobalShaderCache().release(g_state_wireframe);
+  GlobalOpenGLStateLibrary().erase(g_state_solid);
+  GlobalOpenGLStateLibrary().erase(g_state_wireframe);
+}
 
 
+void DVisDrawer::render(RenderStateFlags state) const
+{
        //bleh
        //bleh
-       list<DWinding *>::const_iterator l=m_list->begin();
+       std::list<DWinding *>::const_iterator l=m_list->begin();
 
        for(; l != m_list->end(); l++)
        {
                DWinding* w = *l;
 
 
        for(; l != m_list->end(); l++)
        {
                DWinding* w = *l;
 
-               __QGLTABLENAME.m_pfn_qglColor4f(w->clr[0], w->clr[1], w->clr[2], 0.5f);
+               glColor4f(w->clr[0], w->clr[1], w->clr[2], 0.5f);
 
 
-               __QGLTABLENAME.m_pfn_qglBegin(GL_POLYGON);
+               glBegin(GL_POLYGON);
                for(int i = 0; i < w->numpoints; i++) {
                for(int i = 0; i < w->numpoints; i++) {
-                       __QGLTABLENAME.m_pfn_qglVertex3f((w->p[i])[0], (w->p[i])[1], (w->p[i])[2]);
+                       glVertex3f((w->p[i])[0], (w->p[i])[1], (w->p[i])[2]);
                }
                }
-               __QGLTABLENAME.m_pfn_qglEnd();
+               glEnd();
        }
        }
-
-       
-       __QGLTABLENAME.m_pfn_qglPopMatrix();
-
-       __QGLTABLENAME.m_pfn_qglPopAttrib();
 }
 
 }
 
-void DVisDrawer::Draw3D()
+void DVisDrawer::renderWireframe(Renderer& renderer, const VolumeTest& volume) const
 {
        if(!m_list)
                return;
 
 {
        if(!m_list)
                return;
 
-       __QGLTABLENAME.m_pfn_qglPushAttrib(GL_ALL_ATTRIB_BITS);
-
-       __QGLTABLENAME.m_pfn_qglColor4f(1.0, 0.0, 0.0, 0.5f);
-
-//     __QGLTABLENAME.m_pfn_qglHint(GL_FOG_HINT, GL_NICEST);
-       
-//     __QGLTABLENAME.m_pfn_qglDisable(GL_CULL_FACE);
-       __QGLTABLENAME.m_pfn_qglDisable(GL_LINE_SMOOTH);
-
-//     __QGLTABLENAME.m_pfn_qglPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
-//     __QGLTABLENAME.m_pfn_qglShadeModel(GL_SMOOTH);
+  renderer.SetState(m_shader_wireframe, Renderer::eWireframeOnly);
 
 
-       __QGLTABLENAME.m_pfn_qglEnable(GL_BLEND);
-       __QGLTABLENAME.m_pfn_qglBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-       __QGLTABLENAME.m_pfn_qglDisable(GL_POLYGON_SMOOTH);
-
-       __QGLTABLENAME.m_pfn_qglDepthFunc(GL_ALWAYS);
-
-       //bleh
-       list<DWinding *>::const_iterator l=m_list->begin();
-
-       for(; l != m_list->end(); l++)
-       {
-               DWinding* w = *l;
-
-               __QGLTABLENAME.m_pfn_qglColor4f(w->clr[0], w->clr[1], w->clr[2], 0.5f);
-
-               __QGLTABLENAME.m_pfn_qglBegin(GL_POLYGON);
-               for(int i = 0; i < w->numpoints; i++) {
-                       __QGLTABLENAME.m_pfn_qglVertex3f((w->p[i])[0], (w->p[i])[1], (w->p[i])[2]);
-               }
-               __QGLTABLENAME.m_pfn_qglEnd();
-       }
-
-       __QGLTABLENAME.m_pfn_qglPopAttrib();
+  renderer.addRenderable(*this, g_matrix4_identity);
 }
 
 }
 
-void DVisDrawer::Register()
+void DVisDrawer::renderSolid(Renderer& renderer, const VolumeTest& volume) const
 {
 {
-       __QGLTABLENAME.m_pfnHookGL2DWindow( this );
-       __QGLTABLENAME.m_pfnHookGL3DWindow( this );
-       m_bHooked = TRUE;
-}
+       if(!m_list)
+               return;
 
 
-void DVisDrawer::UnRegister()
-{
-       __QGLTABLENAME.m_pfnUnHookGL2DWindow( this );
-       __QGLTABLENAME.m_pfnUnHookGL3DWindow( this );
-       m_bHooked = FALSE;
+  renderer.SetState(m_shader_solid, Renderer::eWireframeOnly);
+  renderer.SetState(m_shader_solid, Renderer::eFullMaterials);
+
+  renderer.addRenderable(*this, g_matrix4_identity);
 }
 
 void DVisDrawer::SetList(std::list<DWinding*> *pointList)
 }
 
 void DVisDrawer::SetList(std::list<DWinding*> *pointList)
@@ -178,7 +137,7 @@ void DVisDrawer::SetList(std::list<DWinding*> *pointList)
 
 void DVisDrawer::ClearPoints()
 {
 
 void DVisDrawer::ClearPoints()
 {
-  list<DWinding *>::const_iterator deadPoint=m_list->begin();
+  std::list<DWinding *>::const_iterator deadPoint=m_list->begin();
        for(; deadPoint!=m_list->end(); deadPoint++)
                delete *deadPoint;
        m_list->clear();
        for(; deadPoint!=m_list->end(); deadPoint++)
                delete *deadPoint;
        m_list->clear();
index d09c36fcbbcb2d4a2ac2347b0a1af88fe06a5fcf..83a80cb16dbc03263a96a7bcbd1c72c69010b7f2 100644 (file)
@@ -29,28 +29,34 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 #pragma once
 #endif // _MSC_VER > 1000
 
 #pragma once
 #endif // _MSC_VER > 1000
 
-class DVisDrawer : 
-       public IGL2DWindow, 
-       public IGL3DWindow  
+#include <list>
+#include "renderable.h"
+#include "irender.h"
+
+#include "DWinding.h"
+
+class DVisDrawer : public Renderable, public OpenGLRenderable
 {
 {
+  Shader* m_shader_solid;
+  Shader* m_shader_wireframe;
 public:
        DVisDrawer();
        virtual ~DVisDrawer();
 
 protected:
 public:
        DVisDrawer();
        virtual ~DVisDrawer();
 
 protected:
-       list<DWinding*>* m_list;
+       std::list<DWinding*>* m_list;
        int refCount;
 public:
        void ClearPoints();
        int refCount;
 public:
        void ClearPoints();
-       void SetList(list<DWinding*>* pointList);
-       void UnRegister();
-       void Register();
-       void Draw3D();
-       void Draw2D(VIEWTYPE vt);
-       void IncRef() { refCount++; }
-       void DecRef() { refCount--; if (refCount <= 0) delete this; }
-
-       bool m_bHooked;
+       void SetList(std::list<DWinding*>* pointList);
+
+  void render(RenderStateFlags state) const;
+  void renderSolid(Renderer& renderer, const VolumeTest& volume) const;
+  void renderWireframe(Renderer& renderer, const VolumeTest& volume) const;
+
+  void constructShaders();
+       void destroyShaders();
+
 };
 
 #endif // !defined(AFX_VISDRAWER_H__6E36062A_EF0B_11D4_ACF7_004095A18133__INCLUDED_)
 };
 
 #endif // !defined(AFX_VISDRAWER_H__6E36062A_EF0B_11D4_ACF7_004095A18133__INCLUDED_)
index d3c7afdd0686ebcf8542703958d29f6a311d90b6..2068f3f8420fcd53014db896cb658b61f994df4a 100644 (file)
@@ -21,12 +21,11 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 //
 //////////////////////////////////////////////////////////////////////
 
 //
 //////////////////////////////////////////////////////////////////////
 
-#include "StdAfx.h"
+#include "DWinding.h"
 
 
-#include "gtkr_list.h"
+#include <list>
 
 #include "DPoint.h"
 
 #include "DPoint.h"
-#include "DWinding.h"
 #include "DPlane.h"
 
 //////////////////////////////////////////////////////////////////////
 #include "DPlane.h"
 
 //////////////////////////////////////////////////////////////////////
@@ -157,8 +156,8 @@ DWinding* DWinding::CopyWinding()
 
 int DWinding::WindingOnPlaneSide(vec3_t normal, vec_t dist)
 {
 
 int DWinding::WindingOnPlaneSide(vec3_t normal, vec_t dist)
 {
-       bool front = FALSE;
-       bool back = FALSE;
+       bool front = false;
+       bool back = false;
 
        for (int i = 0; i < numpoints; i++)
        {
 
        for (int i = 0; i < numpoints; i++)
        {
@@ -167,14 +166,14 @@ int DWinding::WindingOnPlaneSide(vec3_t normal, vec_t dist)
                {
                        if (front)
                                return SIDE_CROSS;
                {
                        if (front)
                                return SIDE_CROSS;
-                       back = TRUE;
+                       back = true;
                        continue;
                }
                if (d > ON_EPSILON)
                {
                        if (back)
                                return SIDE_CROSS;
                        continue;
                }
                if (d > ON_EPSILON)
                {
                        if (back)
                                return SIDE_CROSS;
-                       front = TRUE;
+                       front = true;
                        continue;
                }
        }
                        continue;
                }
        }
@@ -193,11 +192,11 @@ void DWinding::CheckWinding()
        vec3_t  dir, edgenormal;
 
        if (numpoints < 3)
        vec3_t  dir, edgenormal;
 
        if (numpoints < 3)
-               Sys_Printf ("CheckWinding: %i points", numpoints);
+               globalOutputStream() << "CheckWinding: " << numpoints << " points\n";
        
        vec_t area = WindingArea();
        if (area < 1)
        
        vec_t area = WindingArea();
        if (area < 1)
-               Sys_Printf ("CheckWinding: %f area", area);
+               globalOutputStream() << "CheckWinding: " << area << " area\n";
 
        DPlane* wPlane = WindingPlane ();
        int i;
 
        DPlane* wPlane = WindingPlane ();
        int i;
@@ -208,21 +207,21 @@ void DWinding::CheckWinding()
                int j;
                for (j = 0; j < 3; j++)
                        if (p1[j] > BOGUS_RANGE || p1[j] < -BOGUS_RANGE)
                int j;
                for (j = 0; j < 3; j++)
                        if (p1[j] > BOGUS_RANGE || p1[j] < -BOGUS_RANGE)
-                               Sys_Printf ("CheckFace: BUGUS_RANGE: %f", p1[j]);
+                               globalOutputStream() << "CheckFace: BOGUS_RANGE: " << p1[j] << "\n";
 
                j = i + 1 == numpoints ? 0 : i + 1;
                
                // check the point is on the face plane
                vec_t d = DotProduct (p1, wPlane->normal) - wPlane->_d;
                if (d < -ON_EPSILON || d > ON_EPSILON)
 
                j = i + 1 == numpoints ? 0 : i + 1;
                
                // check the point is on the face plane
                vec_t d = DotProduct (p1, wPlane->normal) - wPlane->_d;
                if (d < -ON_EPSILON || d > ON_EPSILON)
-                       Sys_Printf ("CheckWinding: point off plane");
+                       globalOutputStream() << "CheckWinding: point off plane\n";
        
                // check the edge isnt degenerate
                p2 = p[j];
                VectorSubtract (p2, p1, dir);
                
                if (VectorLength (dir) < ON_EPSILON)
        
                // check the edge isnt degenerate
                p2 = p[j];
                VectorSubtract (p2, p1, dir);
                
                if (VectorLength (dir) < ON_EPSILON)
-                       Sys_Printf ("CheckWinding: degenerate edge");
+                       globalOutputStream() << "CheckWinding: degenerate edge\n";
                        
                CrossProduct (wPlane->normal, dir, edgenormal);
                VectorNormalize (edgenormal, edgenormal);
                        
                CrossProduct (wPlane->normal, dir, edgenormal);
                VectorNormalize (edgenormal, edgenormal);
@@ -236,7 +235,7 @@ void DWinding::CheckWinding()
 
                        d = DotProduct (p[j], edgenormal);
                        if (d > (edgedist + ON_EPSILON))
 
                        d = DotProduct (p[j], edgenormal);
                        if (d > (edgedist + ON_EPSILON))
-                               Sys_Printf ("CheckWinding: non-convex");
+                               globalOutputStream() << "CheckWinding: non-convex\n";
                }
        }
 
                }
        }
 
@@ -287,11 +286,11 @@ bool DWinding::ChopWindingInPlace(DPlane* chopPlane, vec_t epsilon)
        if (!counts[0])
        {
                delete this;
        if (!counts[0])
        {
                delete this;
-               return FALSE;
+               return false;
        }
 
        if (!counts[1])
        }
 
        if (!counts[1])
-               return TRUE;
+               return true;
 
        int maxpts = numpoints+4;       // cant use counts[0]+2 because
                                                                // of fp grouping errors
 
        int maxpts = numpoints+4;       // cant use counts[0]+2 because
                                                                // of fp grouping errors
@@ -339,15 +338,15 @@ bool DWinding::ChopWindingInPlace(DPlane* chopPlane, vec_t epsilon)
        }
        
        if (f->numpoints > maxpts)
        }
        
        if (f->numpoints > maxpts)
-               Sys_Printf ("ClipWinding: points exceeded estimate");
+               globalOutputStream() << "ClipWinding: points exceeded estimate\n";
        if (f->numpoints > MAX_POINTS_ON_WINDING)
        if (f->numpoints > MAX_POINTS_ON_WINDING)
-               Sys_Printf ("ClipWinding: MAX_POINTS_ON_WINDING");
+               globalOutputStream() << "ClipWinding: MAX_POINTS_ON_WINDING\n";
 
        delete[] p;
        p = f->p;
        f->p = NULL;
        delete f;
 
        delete[] p;
        p = f->p;
        f->p = NULL;
        delete f;
-       return TRUE;
+       return true;
 }
 
 void DWinding::ClipWindingEpsilon(DPlane* chopPlane, vec_t epsilon, DWinding **front, DWinding **back)
 }
 
 void DWinding::ClipWindingEpsilon(DPlane* chopPlane, vec_t epsilon, DWinding **front, DWinding **back)
@@ -455,9 +454,9 @@ void DWinding::ClipWindingEpsilon(DPlane* chopPlane, vec_t epsilon, DWinding **f
        }
        
        if (f->numpoints > maxpts || b->numpoints > maxpts)
        }
        
        if (f->numpoints > maxpts || b->numpoints > maxpts)
-               Sys_Printf ("ClipWinding: points exceeded estimate");
+               globalOutputStream() << "ClipWinding: points exceeded estimate\n";
        if (f->numpoints > MAX_POINTS_ON_WINDING || b->numpoints > MAX_POINTS_ON_WINDING)
        if (f->numpoints > MAX_POINTS_ON_WINDING || b->numpoints > MAX_POINTS_ON_WINDING)
-               Sys_Printf ("ClipWinding: MAX_POINTS_ON_WINDING");
+               globalOutputStream() << "ClipWinding: MAX_POINTS_ON_WINDING\n";
 }
 
 bool DWinding::ChopWinding(DPlane* chopPlane)
 }
 
 bool DWinding::ChopWinding(DPlane* chopPlane)
@@ -473,7 +472,7 @@ bool DWinding::ChopWinding(DPlane* chopPlane)
        if(!f)
        {
                delete this;
        if(!f)
        {
                delete this;
-               return FALSE;
+               return false;
        }
 
        delete[] p;
        }
 
        delete[] p;
@@ -482,5 +481,5 @@ bool DWinding::ChopWinding(DPlane* chopPlane)
        numpoints = f->numpoints;
        delete f;
 
        numpoints = f->numpoints;
        delete f;
 
-       return TRUE;
+       return true;
 }
 }
index 6d58e06e17119b3f6be81bb01a7cd8b6b10405eb..52846aab583458472dc85a536f7789fa39bbb779 100644 (file)
@@ -28,6 +28,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 #pragma once
 #endif // _MSC_VER > 1000
 
 #pragma once
 #endif // _MSC_VER > 1000
 
+#include "mathlib.h"
+
 class DPlane;
 
 class DWinding  
 class DPlane;
 
 class DWinding  
index 2b2354cf0c5d043b133bb6a211b6aec84abfe6e2..b5d8859fde9f0f479cf4673bb2bc8cc658382417 100644 (file)
@@ -17,7 +17,6 @@ License along with this library; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
 
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
 
-#include "StdAfx.h"
 #include "ScriptParser.h"
 
 CScriptParser::CScriptParser(void): 
 #include "ScriptParser.h"
 
 CScriptParser::CScriptParser(void): 
index e7e58a69760351128e64dd414ff708f619af0314..b8897f39deee015f00761f20c86ffc792073032f 100644 (file)
@@ -20,122 +20,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 #ifndef __STDAFX_BOBTOOLZ__
 #define __STDAFX_BOBTOOLZ__
 
 #ifndef __STDAFX_BOBTOOLZ__
 #define __STDAFX_BOBTOOLZ__
 
-#define BOBTOOLZ_MINOR "bobtoolz"
 
 
-#include <gdk/gdkkeysyms.h>
-#include <gtk/gtk.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "time.h"
-
-#define NAME_MAX 255
-
-#if defined (__linux__) || defined (__APPLE__)
-
-#include <GL/glx.h>
-
-typedef void* HMODULE;
-typedef void* LPVOID;
-typedef char* LPCSTR;
-//typedef int  bool;
-
-
-#define WINAPI
-#define APIENTRY
-
-#ifndef GUID_DEFINED
-#define GUID_DEFINED
-typedef struct _GUID
-{
-  unsigned long  Data1;
-  unsigned short Data2;
-  unsigned short Data3;
-  unsigned char  Data4[8];
-} GUID;
-
-#define stricmp strcasecmp
-
-#endif
-#if defined(__cplusplus)
-#ifndef _REFGUID_DEFINED
-#define _REFGUID_DEFINED
-#define REFGUID             const GUID &
-#endif // !_REFGUID_DEFINED
-#endif
-
-typedef struct tagRECT
-{
-    long    left;
-    long    top;
-    long    right;
-    long    bottom;
-} RECT, *PRECT, *LPRECT;
-
-typedef uint UINT;
-
-#endif // __linux__
-
-#include "mathlib.h"
-#include <string.h>
-#include "qertypes.h"
-#include <stdio.h>
-
-#define USE_SCENEGRAPHTABLE_DEFINE
-#include "iscenegraph.h"
-
-#define USE_QERTABLE_DEFINE
-#include "qerplugin.h"
-extern _QERFuncTable_1 __QERTABLENAME;
-
-#define USE_ENTITYTABLE_DEFINE
-#include "ientity.h"
-extern _QEREntityTable __ENTITYTABLENAME;
-
-#define USE_BRUSHTABLE_DEFINE
-#include "ibrush.h"
-extern  _QERBrushTable __BRUSHTABLENAME;
-
-#define USE_PATCHTABLE_DEFINE
-#include "ipatch.h"
-extern  _QERPatchTable __PATCHTABLENAME;
-
-#define USE_SHADERSTABLE_DEFINE
-#include "ishaders.h"
-extern _QERShadersTable __SHADERSTABLENAME;
-
-#define USE_QGLTABLE_DEFINE
-#include "igl.h"
-extern _QERQglTable __QGLTABLENAME;
-
-#include "ibspfrontend.h"
-extern _QERAppBSPFrontendTable g_BSPTable;
-
-#include "iui.h"
-extern _QERUITable                       g_MessageTable;
-
-#define USE_RENDERTABLE_DEFINE
-#include "irender.h"
-
-#define USE_SELECTIONTABLE_DEFINE
-#include "iselection.h"
-
-#include "itoolbar.h"
-
-
-#include "iplugin.h"
-
-#define MAX_ROUND_ERROR        0.05
-
-#include "itexdef.h"
-
-struct _QERFaceData
-{
-  vec3_t m_p0;
-  vec3_t m_p1;
-  vec3_t m_p2;
-  texdef_t m_texdef;
-};
 
 #endif
 
 #endif
index 08cd00dd0855501d048d0e832250b528be409e6b..b0940e0842a951e48d527a21a4df4d2becc21e41 100644 (file)
@@ -19,17 +19,22 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
 #include "libxml/parser.h"
 
 
 #include "libxml/parser.h"
 
-#include "StdAfx.h"
 
 #include "str.h"
 
 #include "str.h"
-//#include "gtkr_list.h"
 
 #include "funchandlers.h"
 
 #include "funchandlers.h"
-//#include "misc.h"
 
 #include "dialogs/dialogs-gtk.h"
 #include "../../libs/cmdlib.h"
 
 
 #include "dialogs/dialogs-gtk.h"
 #include "../../libs/cmdlib.h"
 
+void BobToolz_construct()
+{
+}
+
+void BobToolz_destroy()
+{
+}
+
 // Radiant function table
 _QERFuncTable_1                          __QERTABLENAME;
 _QERShadersTable                 __SHADERSTABLENAME;                   // vvvvvvvvvvvvvvvvvvvv
 // Radiant function table
 _QERFuncTable_1                          __QERTABLENAME;
 _QERShadersTable                 __SHADERSTABLENAME;                   // vvvvvvvvvvvvvvvvvvvv
@@ -71,31 +76,31 @@ extern "C" const char* QERPlug_GetCommandList() {
 extern "C" void QERPlug_Dispatch (const char *p, vec3_t vMin, vec3_t vMax, bool bSingleBrush) {
        LoadLists();
 
 extern "C" void QERPlug_Dispatch (const char *p, vec3_t vMin, vec3_t vMax, bool bSingleBrush) {
        LoadLists();
 
-       if( !stricmp( p, "brush cleanup" ) ) {
+       if( string_equal_nocase( p, "brush cleanup" ) ) {
     DoFixBrushes();
     DoFixBrushes();
-  } else if( !stricmp( p, "polygon builder" ) ) {
+  } else if( string_equal_nocase( p, "polygon builder" ) ) {
     DoPolygonsTB();
     DoPolygonsTB();
-  } else if( !stricmp( p, "caulk selection" ) ) {
+  } else if( string_equal_nocase( p, "caulk selection" ) ) {
     DoCaulkSelection();
     DoCaulkSelection();
-  } else if( !stricmp( p, "tree planter" ) ) {
+  } else if( string_equal_nocase( p, "tree planter" ) ) {
     DoTreePlanter();
     DoTreePlanter();
-  } else if( !stricmp( p, "plot splines" ) ) {
+  } else if( string_equal_nocase( p, "plot splines" ) ) {
     DoTrainPathPlot();
     DoTrainPathPlot();
-  } else if( !stricmp( p, "drop entity" ) ) {
+  } else if( string_equal_nocase( p, "drop entity" ) ) {
     DoDropEnts();
     DoDropEnts();
-  } else if( !stricmp( p, "merge patches" ) ) {
+  } else if( string_equal_nocase( p, "merge patches" ) ) {
     DoMergePatches();
     DoMergePatches();
-  } else if( !stricmp( p, "split patches" ) ) {
+  } else if( string_equal_nocase( p, "split patches" ) ) {
     DoSplitPatch();
     DoSplitPatch();
-  } else if( !stricmp( p, "turn edge" ) ) {
+  } else if( string_equal_nocase( p, "turn edge" ) ) {
     DoFlipTerrain();
     DoFlipTerrain();
-  } else if( !stricmp(p, "reset textures...") ) {
+  } else if( string_equal_nocase(p, "reset textures...") ) {
                DoResetTextures();
                DoResetTextures();
-       } else if( !stricmp(p, "pitomatic") ) {
+       } else if( string_equal_nocase(p, "pitomatic") ) {
                DoPitBuilder();
                DoPitBuilder();
-       } else if( !stricmp(p, "vis viewer") ) {
+       } else if( string_equal_nocase(p, "vis viewer") ) {
                DoVisAnalyse();
                DoVisAnalyse();
-       } else if( !stricmp(p, "about...") ) {
+       } else if( string_equal_nocase(p, "about...") ) {
                DoMessageBox(PLUGIN_ABOUT, "About", eMB_OK);
        }
 }
                DoMessageBox(PLUGIN_ABOUT, "About", eMB_OK);
        }
 }
@@ -221,6 +226,7 @@ public:
   virtual ~CSynapseClientBobtoolz() { }
 };
 
   virtual ~CSynapseClientBobtoolz() { }
 };
 
+#define BOBTOOLZ_MINOR "bobtoolz"
 
 CSynapseServer* g_pSynapseServer = NULL;
 CSynapseClientBobtoolz g_SynapseClient;
 
 CSynapseServer* g_pSynapseServer = NULL;
 CSynapseClientBobtoolz g_SynapseClient;
@@ -288,11 +294,3 @@ const char* CSynapseClientBobtoolz::GetInfo()
   return "bobToolz module built " __DATE__ " " RADIANT_VERSION;
 }
 
   return "bobToolz module built " __DATE__ " " RADIANT_VERSION;
 }
 
-char* GetFilename(char* buffer, const char* filename) {
-       strcpy(buffer, g_pSynapseServer->GetModuleFilename(&g_SynapseClient));
-       StripFilename( buffer );
-       strcat(buffer, "/");
-       strcat(buffer, filename);
-       //buffer = UnixToDosPath(buffer);
-       return buffer;
-}
index c22c76d33dfd7f288ab406ecad98352dfab2bb63..74f9189bcaa56972b372bafecc5bef7338ee0411 100644 (file)
@@ -5,4 +5,4 @@ LIBRARY      "bobToolz"
 
 EXPORTS
     ; Explicit exports can go here
 
 EXPORTS
     ; Explicit exports can go here
-       Synapse_EnumerateInterfaces @1
+       Radiant_RegisterModules @1
index 27c2e6d5f84bd00987177434e8ce16d58fb7e622..287c5fff468de67cf948d70906af2c7b06404006 100644 (file)
@@ -1,7 +1,6 @@
-#include "StdAfx.h"
-#include "./dialogs/dialogs-gtk.h"
 #include "bsploader.h"
 #include "bsploader.h"
-#include "../../libs/cmdlib.h"
+#include "dialogs/dialogs-gtk.h"
+#include "cmdlib.h"
 
 int                    numnodes;
 int                    numplanes;
 
 int                    numnodes;
 int                    numplanes;
@@ -72,15 +71,21 @@ bool    LoadFile( const char *filename, byte **bufferptr)
        return true;
 }
 
        return true;
 }
 
-/*int    LittleLong (int l)
+int    LittleLong (int l)
 {
 {
+#if defined(__BIG_ENDIAN__)
+  std::reverse(reinterpret_cast<unsigned char*>(&l), reinterpret_cast<unsigned char*>(&l) + sizeof(int));
+#endif
        return l;
 }
 
 float  LittleFloat (float l)
 {
        return l;
 }
 
 float  LittleFloat (float l)
 {
+#if defined(__BIG_ENDIAN__)
+  std::reverse(reinterpret_cast<unsigned char*>(&l), reinterpret_cast<unsigned char*>(&l) + sizeof(float));
+#endif
        return l;
        return l;
-}*/
+}
 
 /*
 =============
 
 /*
 =============
index 9414566aa2701c6a0cc0f15c9c0ecaf4a6643608..3cea233bdfa4370bf449896b0a5dbc986e241bf2 100644 (file)
@@ -1,3 +1,6 @@
+
+#include "mathlib.h"
+
 #define        LUMP_ENTITIES           0
 #define        LUMP_SHADERS            1
 #define        LUMP_PLANES                     2
 #define        LUMP_ENTITIES           0
 #define        LUMP_SHADERS            1
 #define        LUMP_PLANES                     2
index 01edc0e1ea1927187a5a7d683b0b2d2df01d4f8e..5048eef04f4baac6c1cbcd77670853fd4300c811 100644 (file)
@@ -17,9 +17,12 @@ License along with this library; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
 
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
 
-#include "StdAfx.h"
 #include "CPortals.h"
 #include "CPortals.h"
-//#include "misc.h"
+
+#include <string.h>
+#include <math.h>
+
+#include "misc.h"
 
 #define LINE_BUF 1000
 #define MSG_PREFIX "bobToolz plugin: "
 
 #define LINE_BUF 1000
 #define MSG_PREFIX "bobToolz plugin: "
@@ -60,7 +63,7 @@ bool CBspPortal::Build(char *def, unsigned int pointCnt, bool bInverse)
        point_count = pointCnt;
 
        if(point_count < 3)
        point_count = pointCnt;
 
        if(point_count < 3)
-               return FALSE;
+               return false;
 
        point = new CBspPoint[point_count];
 
 
        point = new CBspPoint[point_count];
 
@@ -69,7 +72,7 @@ bool CBspPortal::Build(char *def, unsigned int pointCnt, bool bInverse)
                for(; *c != 0 && *c != '('; c++);
 
                if(*c == 0)
                for(; *c != 0 && *c != '('; c++);
 
                if(*c == 0)
-                       return FALSE;
+                       return false;
 
                c++;
 
 
                c++;
 
@@ -86,7 +89,7 @@ bool CBspPortal::Build(char *def, unsigned int pointCnt, bool bInverse)
                ClampFloat(&point[x].p[2]);
        }
 
                ClampFloat(&point[x].p[2]);
        }
 
-       return TRUE;
+       return true;
 }
 
 CPortals::CPortals()
 }
 
 CPortals::CPortals()
@@ -115,7 +118,7 @@ void CPortals::Load()
        
        Purge();
 
        
        Purge();
 
-       Sys_Printf(MSG_PREFIX "Loading portal file %s.\n", fn);
+       globalOutputStream() << MSG_PREFIX "Loading portal file " << fn << ".\n";
 
        FILE *in;
 
 
        FILE *in;
 
@@ -123,7 +126,7 @@ void CPortals::Load()
 
        if(in == NULL)
        {
 
        if(in == NULL)
        {
-               Sys_Printf("  ERROR - could not open file.\n");
+               globalOutputStream() << "  ERROR - could not open file.\n";
 
                return;
        }
 
                return;
        }
@@ -132,7 +135,7 @@ void CPortals::Load()
        {
                fclose(in);
 
        {
                fclose(in);
 
-               Sys_Printf("  ERROR - File ended prematurely.\n");
+               globalOutputStream() << "  ERROR - File ended prematurely.\n";
 
                return;
        }
 
                return;
        }
@@ -141,7 +144,7 @@ void CPortals::Load()
        {
                fclose(in);
 
        {
                fclose(in);
 
-               Sys_Printf("  ERROR - File header indicates wrong file type (should be \"PRT1\").\n");
+               globalOutputStream() << "  ERROR - File header indicates wrong file type (should be \"PRT1\").\n";
 
                return;
        }
 
                return;
        }
@@ -150,7 +153,7 @@ void CPortals::Load()
        {
                fclose(in);
 
        {
                fclose(in);
 
-               Sys_Printf("  ERROR - File ended prematurely.\n");
+               globalOutputStream() << "  ERROR - File ended prematurely.\n";
 
                return;
        }
 
                return;
        }
@@ -163,7 +166,7 @@ void CPortals::Load()
 
                node_count = 0;
 
 
                node_count = 0;
 
-               Sys_Printf("  ERROR - Extreme number of nodes, aborting.\n");
+               globalOutputStream() << "  ERROR - Extreme number of nodes, aborting.\n";
 
                return;
        }
 
                return;
        }
@@ -174,7 +177,7 @@ void CPortals::Load()
 
                node_count = 0;
 
 
                node_count = 0;
 
-               Sys_Printf("  ERROR - File ended prematurely.\n");
+               globalOutputStream() << "  ERROR - File ended prematurely.\n";
 
                return;
        }
 
                return;
        }
@@ -188,7 +191,7 @@ void CPortals::Load()
 
                node_count = 0;
 
 
                node_count = 0;
 
-               Sys_Printf("  ERROR - File ended prematurely.\n");
+               globalOutputStream() << "  ERROR - File ended prematurely.\n";
 
                return;
        }
 
                return;
        }
@@ -207,7 +210,7 @@ void CPortals::Load()
 
                        node_count = 0;
 
 
                        node_count = 0;
 
-                       Sys_Printf("  ERROR - File ended prematurely.\n");
+                       globalOutputStream() << "  ERROR - File ended prematurely.\n";
 
                        return;
                }
 
                        return;
                }
@@ -227,7 +230,7 @@ void CPortals::Load()
 
                        node_count = 0;
 
 
                        node_count = 0;
 
-                       Sys_Printf("  ERROR - File ended prematurely.\n");
+                       globalOutputStream() << "  ERROR - File ended prematurely.\n";
 
                        return;
                }
 
                        return;
                }
@@ -259,7 +262,7 @@ void CPortals::Load()
 
                        Purge();
 
 
                        Purge();
 
-                       Sys_Printf("  ERROR - Could not find information for portal number %d of %d.\n", n + 1, p_count);
+                       globalOutputStream() << "  ERROR - Could not find information for portal number " << n + 1 << " of " << p_count << ".\n";
 
                        return;
                }
 
                        return;
                }
@@ -267,24 +270,24 @@ void CPortals::Load()
                unsigned int pCount, node1, node2;
                sscanf(buf, "%u %u %u", &pCount, &node1, &node2);
 
                unsigned int pCount, node1, node2;
                sscanf(buf, "%u %u %u", &pCount, &node1, &node2);
 
-               if(!node[node1].AddPortal(buf, pCount, FALSE))
+               if(!node[node1].AddPortal(buf, pCount, false))
                {
                        fclose(in);
 
                        Purge();
 
                {
                        fclose(in);
 
                        Purge();
 
-                       Sys_Printf("  ERROR - Information for portal number %d of %d is not formatted correctly.\n", n + 1, p_count);
+                       globalOutputStream() << "  ERROR - Information for portal number " << n + 1 << " of " << p_count << " is not formatted correctly.\n";
 
                        return;
                }
 
 
                        return;
                }
 
-               if(!node[node2].AddPortal(buf, pCount, TRUE))
+               if(!node[node2].AddPortal(buf, pCount, true))
                {
                        fclose(in);
 
                        Purge();
 
                {
                        fclose(in);
 
                        Purge();
 
-                       Sys_Printf("  ERROR - Information for portal number %d of %d is not formatted correctly.\n", n + 1, p_count);
+                       globalOutputStream() << "  ERROR - Information for portal number " << n + 1 << " of " << p_count << " is not formatted correctly.\n";
 
                        return;
                }
 
                        return;
                }
@@ -298,7 +301,7 @@ void CPortals::Load()
 
                        Purge();
 
 
                        Purge();
 
-                       Sys_Printf("  ERROR - Could not find information for portal number %d of %d.\n", n + 1, p_count);
+                       globalOutputStream() << "  ERROR - Could not find information for portal number " << n + 1 << " of " << p_count << ".\n";
 
                        return;
                }
 
                        return;
                }
@@ -306,13 +309,13 @@ void CPortals::Load()
                unsigned int pCount, node1;
                sscanf(buf, "%u %u", &pCount, &node1);
 
                unsigned int pCount, node1;
                sscanf(buf, "%u %u", &pCount, &node1);
 
-               if(!node[node1].AddPortal(buf, pCount, FALSE))
+               if(!node[node1].AddPortal(buf, pCount, false))
                {
                        fclose(in);
 
                        Purge();
 
                {
                        fclose(in);
 
                        Purge();
 
-                       Sys_Printf("  ERROR - Information for portal number %d of %d is not formatted correctly.\n", n + 1, p_count);
+                       globalOutputStream() << "  ERROR - Information for portal number " << n + 1 << " of " << p_count << " is not formatted correctly.\n";
 
                        return;
                }
 
                        return;
                }
index 57177ef41c01aef30712601c9bebf9ab17581f34..0058ea7aef9de1e210cdf26d210f9b878302bf33 100644 (file)
@@ -17,14 +17,11 @@ License along with this library; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
 
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
 
-#include "../StdAfx.h"
-
-
 #include "dialogs-gtk.h"
 #include "../funchandlers.h"
 
 #include "str.h"
 #include "dialogs-gtk.h"
 #include "../funchandlers.h"
 
 #include "str.h"
-#include "gtkr_list.h"
+#include <list>
 
 #include "../lists.h"
 #include "../misc.h"
 
 #include "../lists.h"
 #include "../misc.h"
index 5838db6fbe7d9f92e45b7fc895c21459cb99518d..bcafdae818ac7cd86be358563cb00a0792791879 100644 (file)
@@ -17,6 +17,11 @@ License along with this library; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
 
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
 
+#if !defined(INCLUDED_DIALOGS_GTK_H)
+#define INCLUDED_DIALOGS_GTK_H
+
+#include "qerplugin.h"
+
 struct BuildStairsRS{
        char mainTexture[256];
        char riserTexture[256];
 struct BuildStairsRS{
        char mainTexture[256];
        char riserTexture[256];
@@ -80,6 +85,8 @@ struct PathPlotterRS{
        bool bShowExtra;
 };
 
        bool bShowExtra;
 };
 
+typedef struct _GtkWidget GtkWidget;
+
 struct TwinWidget{
        GtkWidget* one;
        GtkWidget* two;
 struct TwinWidget{
        GtkWidget* one;
        GtkWidget* two;
@@ -96,3 +103,5 @@ EMessageBoxReturn DoCTFColourChangeBox();
 EMessageBoxReturn DoTrainThingBox (TrainThingRS* rs);
 
 //GtkWidget* GetProgressWindow(char* title, GtkProgressBar* feedback);
 EMessageBoxReturn DoTrainThingBox (TrainThingRS* rs);
 
 //GtkWidget* GetProgressWindow(char* title, GtkProgressBar* feedback);
+
+#endif
index deb3ff829d5668e8eefe6907dba5f1d7ce6e9966..d492d7420e0d0096027d5d4d91837d5bd0b6609b 100644 (file)
@@ -17,7 +17,7 @@ License along with this library; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
 
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
 
-#include "StdAfx.h"
+#include "funchandlers.h"
 
 #ifdef WIN32
 #pragma warning(disable : 4786)
 
 #ifdef WIN32
 #pragma warning(disable : 4786)
@@ -25,7 +25,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
 #include "dialogs/dialogs-gtk.h"
 
 
 #include "dialogs/dialogs-gtk.h"
 
-#include "gtkr_list.h"
+#include <list>
 #include "str.h"
 
 #include "DPoint.h"
 #include "str.h"
 
 #include "DPoint.h"
@@ -45,13 +45,10 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
 #include "shapes.h"
 #include "lists.h"
 
 #include "shapes.h"
 #include "lists.h"
-#include "funchandlers.h"
 #include "visfind.h"
 
 #include "iundo.h"
 
 #include "visfind.h"
 
 #include "iundo.h"
 
-#include "refcounted_ptr.h"
-
 #include <vector>
 #include <list>
 #include <map>
 #include <vector>
 #include <list>
 #include <map>
@@ -60,8 +57,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 #include "scenelib.h"
 
 // for autocaulk
 #include "scenelib.h"
 
 // for autocaulk
-list<Str> exclusionList;               // whole brush exclusion
-list<Str> exclusionList_Face;  // single face exclusion
+std::list<Str> exclusionList;          // whole brush exclusion
+std::list<Str> exclusionList_Face;     // single face exclusion
 
 bool el1Loaded =               FALSE;
 bool el2Loaded =               FALSE;
 
 bool el1Loaded =               FALSE;
 bool el2Loaded =               FALSE;
@@ -166,7 +163,7 @@ void DoPolygons()
       VectorSubtract(instance.aabb_world().origin, instance.aabb_world().extents, vMin);
       VectorAdd(instance.aabb_world().origin, instance.aabb_world().extents, vMax);
 
       VectorSubtract(instance.aabb_world().origin, instance.aabb_world().extents, vMin);
       VectorAdd(instance.aabb_world().origin, instance.aabb_world().extents, vMax);
 
-      instance.path().parent()->m_traverse->erase(instance.path().top());
+      Node_getTraversable(instance.path().parent())->erase(instance.path().top());
     }
 
                if(rs.bInverse)
     }
 
                if(rs.bInverse)
@@ -269,7 +266,7 @@ void DoBuildStairs()
                {
       {
         scene::Instance& instance = GlobalSelectionSystem().ultimateSelected();
                {
       {
         scene::Instance& instance = GlobalSelectionSystem().ultimateSelected();
-        instance.path().parent()->m_traverse->erase(instance.path().top());
+        Node_getTraversable(instance.path().parent())->erase(instance.path().top());
       }
                                                
                        // Get Step Count
       }
                                                
                        // Get Step Count
@@ -340,7 +337,7 @@ void DoBuildDoors()
       scene::Instance& instance = GlobalSelectionSystem().ultimateSelected();
       VectorSubtract(instance.aabb_world().origin, instance.aabb_world().extents, vMin);
       VectorAdd(instance.aabb_world().origin, instance.aabb_world().extents, vMax);
       scene::Instance& instance = GlobalSelectionSystem().ultimateSelected();
       VectorSubtract(instance.aabb_world().origin, instance.aabb_world().extents, vMin);
       VectorAdd(instance.aabb_world().origin, instance.aabb_world().extents, vMax);
-      instance.path().parent()->m_traverse->erase(instance.path().top());
+      Node_getTraversable(instance.path().parent())->erase(instance.path().top());
     }
 
                BuildDoorsX2(vMin, vMax, 
     }
 
                BuildDoorsX2(vMin, vMax, 
@@ -371,40 +368,11 @@ void DoPathPlotter()
                return; 
        }
 
                return; 
        }
 
-  scene::Instance& instance = GlobalSelectionSystem().ultimateSelected();
-
-       DEntity world;
-       world.LoadEPairList(instance.path().top()->m_entity);
-
-       DEPair* trigger_ep = world.FindEPairByKey("targetname");
-
-       if(trigger_ep)
-       {
-               if(!strcmp(world.m_Classname, "trigger_push"))
-               {
-                       DEPair* target_ep = world.FindEPairByKey("target");
-                       if(target_ep)
-                       {
-        scene::Path* entTarget = FindEntityFromTargetname(target_ep->value, NULL);
-                               if(entTarget)
-                               {
-                                       if(g_PathView)
-                                               delete g_PathView;
-                                       g_PathView = new DBobView;
-
-                                       g_PathView->Begin(trigger_ep->value, target_ep->value, rs.fMultiplier, rs.nPoints, rs.fGravity, rs.bNoUpdate, rs.bShowExtra);
-                               }
-                               else
-                                       DoMessageBox("trigger_push target could not be found.", "Error", eMB_OK);
-                       }
-                       else
-                               DoMessageBox("trigger_push has no target.", "Error", eMB_OK);
-               }
-               else
-                       DoMessageBox("You must select a 'trigger_push' entity.", "Error", eMB_OK);
-       }       
-       else
-               DoMessageBox("Entity must have a targetname", "Error", eMB_OK);
+  Entity* entity = Node_getEntity(GlobalSelectionSystem().ultimateSelected().path().top());
+  if(entity != 0)
+  {
+    DBobView_setEntity(*entity, rs.fMultiplier, rs.nPoints, rs.fGravity, rs.bNoUpdate, rs.bShowExtra);
+  }
 }
 
 void DoPitBuilder()
 }
 
 void DoPitBuilder()
@@ -428,7 +396,7 @@ void DoPitBuilder()
        {
                pit.Commit();
 
        {
                pit.Commit();
 
-    instance.path().parent()->m_traverse->erase(instance.path().top());
+    Node_getTraversable(instance.path().parent())->erase(instance.path().top());
        }
        else
                DoMessageBox("Failed To Make Pit\nTry Making The Brush Bigger", "Error", eMB_OK);
        }
        else
                DoMessageBox("Failed To Make Pit\nTry Making The Brush Bigger", "Error", eMB_OK);
@@ -450,6 +418,9 @@ void DoMergePatches()
   scene::Node* patches[2];
   patches[0] = GlobalSelectionSystem().ultimateSelected().path().top();
   patches[1] = GlobalSelectionSystem().penultimateSelected().path().top();
   scene::Node* patches[2];
   patches[0] = GlobalSelectionSystem().ultimateSelected().path().top();
   patches[1] = GlobalSelectionSystem().penultimateSelected().path().top();
+  scene::Node* ents[2];
+  ents[0] = GlobalSelectionSystem().ultimateSelected().path().parent();
+  ents[1] = GlobalSelectionSystem().penultimateSelected().path().parent();
 
   for (i = 0; i < 2; i++)
   {
 
   for (i = 0; i < 2; i++)
   {
@@ -488,8 +459,8 @@ void DoMergePatches()
     {
     } else
     {
     {
     } else
     {
-      mrgPatches[0].RemoveFromRadiant();
-      mrgPatches[1].RemoveFromRadiant();
+      Node_getTraversable(*ents[0])->erase(*patches[0]);
+      Node_getTraversable(*ents[1])->erase(*patches[1]);
 
       newPatch->BuildInRadiant();
       delete newPatch;
 
       newPatch->BuildInRadiant();
       delete newPatch;
@@ -516,8 +487,8 @@ void DoSplitPatch() {
 
        patch.LoadFromBrush(node);
 
 
        patch.LoadFromBrush(node);
 
-       list<DPatch> patchList = patch.Split( true, true );
-       for(list<DPatch>::iterator patches = patchList.begin(); patches != patchList.end(); patches++) {
+       std::list<DPatch> patchList = patch.Split( true, true );
+       for(std::list<DPatch>::iterator patches = patchList.begin(); patches != patchList.end(); patches++) {
                (*patches).BuildInRadiant();
        }
 
                (*patches).BuildInRadiant();
        }
 
@@ -568,7 +539,7 @@ void DoVisAnalyse()
        char* ext = strrchr(filename, '.')+1;
        strcpy(ext, "bsp");// rename the extension
 
        char* ext = strrchr(filename, '.')+1;
        strcpy(ext, "bsp");// rename the extension
 
-       list<DWinding*> *pointList = BuildTrace(filename, origin);
+       std::list<DWinding*> *pointList = BuildTrace(filename, origin);
 
        if(!g_VisView)
        {
 
        if(!g_VisView)
        {
@@ -662,7 +633,7 @@ void DoFlipTerrain() {
        ents[1] = GlobalSelectionSystem().penultimateSelected().path().parent();
 
        for( i = 0; i < 2; i++ ) {
        ents[1] = GlobalSelectionSystem().penultimateSelected().path().parent();
 
        for( i = 0; i < 2; i++ ) {
-               Brushes[i].RemoveFromRadiant();
+               Node_getTraversable(*ents[i])->erase(*brushes[i]);
        }
 
 
        }
 
 
index c83d2ae0a0341b50b31a0b78e84e467ed2e361d7..ca218f5b522aa13404f38137a827469c53f812ee 100644 (file)
@@ -39,8 +39,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 #include "DShape.h"
 
 // for autocaulk
 #include "DShape.h"
 
 // for autocaulk
-list<Str> exclusionList;               // whole brush exclusion
-list<Str> exclusionList_Face;  // single face exclusion
+std::list<Str> exclusionList;          // whole brush exclusion
+std::list<Str> exclusionList_Face;     // single face exclusion
 
 BOOL el1Loaded;
 BOOL el2Loaded;
 
 BOOL el1Loaded;
 BOOL el2Loaded;
index b8b1dd44754381dca87474d354b34e800ad6a283..faacbb77a520604dd4f1496212113354292071e4 100644 (file)
@@ -17,19 +17,17 @@ License along with this library; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
 
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
 
-#include "StdAfx.h"
+#include "lists.h"
 
 #ifdef WIN32
 #pragma warning(disable : 4786)
 #endif
 
 
 #ifdef WIN32
 #pragma warning(disable : 4786)
 #endif
 
-#include "gtkr_list.h"
-#include "str.h"
+#include <glib/glist.h>
 
 
-#include "lists.h"
 #include "misc.h"
 
 #include "misc.h"
 
-bool LoadExclusionList(char* filename, list<Str>* exclusionList)
+bool LoadExclusionList(char* filename, std::list<Str>* exclusionList)
 {
        FILE* eFile = fopen(filename, "r");
        if(eFile)
 {
        FILE* eFile = fopen(filename, "r");
        if(eFile)
@@ -52,7 +50,7 @@ bool LoadExclusionList(char* filename, list<Str>* exclusionList)
                return TRUE;
        }
 
                return TRUE;
        }
 
-       Sys_ERROR("Failed To Load Exclusion List: %s\n", filename);
+       globalErrorStream() << "Failed To Load Exclusion List: " << filename << "\n";
        return FALSE;
 }
 
        return FALSE;
 }
 
index 6f9774f62bfd8d120d9ccda35f999f47ebf55902..c4ccf77e3c52136bb396ccd4a70a5a900f688485 100644 (file)
@@ -17,5 +17,9 @@ License along with this library; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
 
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
 
-bool LoadExclusionList(char* filename, list<Str>* exclusionList);
+#include <list>
+#include "str.h"
+typedef struct _GList          GList;
+
+bool LoadExclusionList(char* filename, std::list<Str>* exclusionList);
 bool LoadGList(char* filename, GList** loadlist);
 bool LoadGList(char* filename, GList** loadlist);
index f793bcc426e52b22f12d05d0a88e07e4601fb569..e56c4d89129056299a27bba921889c80733e1c00 100644 (file)
@@ -17,13 +17,11 @@ License along with this library; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
 
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
 
-#include "StdAfx.h"
+#include "misc.h"
 
 
-#include "gtkr_list.h"
+#include <list>
 #include "str.h"
 
 #include "str.h"
 
-#include "misc.h"
-
 #include "DPoint.h"
 #include "DPlane.h"
 #include "DBrush.h"
 #include "DPoint.h"
 #include "DPlane.h"
 #include "DBrush.h"
@@ -39,8 +37,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 #endif
 
 #include "iundo.h"
 #endif
 
 #include "iundo.h"
-
-#include "refcounted_ptr.h"
+#include "qerplugin.h"
 
 #include <vector>
 #include <list>
 
 #include <vector>
 #include <list>
@@ -61,7 +58,7 @@ char  g_CurrentTexture[256] = "";
 
 void ReadCurrentTexture()
 {
 
 void ReadCurrentTexture()
 {
-       const char* textureName = g_FuncTable.m_pfnGetCurrentTexture();
+       const char* textureName = GlobalRadiant().TextureBrowser_getSelectedShader();
        strcpy(g_CurrentTexture, textureName);
 }
 
        strcpy(g_CurrentTexture, textureName);
 }
 
@@ -152,29 +149,6 @@ char* TranslateString (char *buf)
        return buf2;
 }
 
        return buf2;
 }
 
-void Sys_ERROR (char* text, ...)
-{
-       va_list argptr;
-       char    buf[32768];
-
-       va_start (argptr,text);
-       vsprintf (buf, text,argptr);
-       va_end (argptr);
-
-       Sys_Printf("BobToolz::ERROR->%s", buf);
-}
-
-/*void Sys_Printf (char *text, ...)
-{
-       va_list argptr;
-       char    buf[32768];
-
-       va_start (argptr,text);
-       vsprintf (buf, text,argptr);
-       va_end (argptr);
-
-       g_FuncTable.m_pfnSysMsg ( buf );
-}*/
 
 char* UnixToDosPath(char* path)
 {
 
 char* UnixToDosPath(char* path)
 {
@@ -289,7 +263,7 @@ void StartBSP()
        Q_Exec( command, TRUE );
 }
 
        Q_Exec( command, TRUE );
 }
 
-void BuildMiniPrt(list<Str>* exclusionList)
+void BuildMiniPrt(std::list<Str>* exclusionList)
 {
        // yes, we could just use -fulldetail option, but, as SPOG said
        // it'd be faster without all the hint, donotenter etc textures and
 {
        // yes, we could just use -fulldetail option, but, as SPOG said
        // it'd be faster without all the hint, donotenter etc textures and
@@ -347,6 +321,31 @@ void BuildMiniPrt(list<Str>* exclusionList)
        StartBSP();
 }
 
        StartBSP();
 }
 
+template<typename Functor>
+class EntityWalker
+{
+  const Functor& functor;
+public:
+  EntityWalker(const Functor& functor) : functor(functor)
+  {
+  }
+  bool pre(const Path& path, Instance& instance) const
+  {
+    if(Node_isEntity(path.top()))
+    {
+      functor(path.top());
+    }
+  }
+};
+
+template<typename Functor>
+const Functor& Scene_forEachEntity(const Functor& functor)
+{
+  GlobalSceneGraph().traverse(EntityWalker<Functor>(functor));
+}
+
+void 
+
 scene::Path* FindEntityFromTargetname(const char* targetname, int* entNum)
 {
 #if 0
 scene::Path* FindEntityFromTargetname(const char* targetname, int* entNum)
 {
 #if 0
@@ -364,7 +363,7 @@ scene::Path* FindEntityFromTargetname(const char* targetname, int* entNum)
                DEPair* tn = world.FindEPairByKey("targetname");
                if(tn)
                {
                DEPair* tn = world.FindEPairByKey("targetname");
                if(tn)
                {
-                       if(!stricmp(tn->value, targetname)) {
+                       if(string_equal_nocase(tn->value, targetname)) {
                                if(entNum) {
                                        *entNum = i;
                                }
                                if(entNum) {
                                        *entNum = i;
                                }
@@ -388,9 +387,9 @@ void FillDefaultTexture(_QERFaceData* faceData, vec3_t va, vec3_t vb, vec3_t vc,
        faceData->m_texdef.flags = 0;
        faceData->m_texdef.value = 0;
        if(*texture)
        faceData->m_texdef.flags = 0;
        faceData->m_texdef.value = 0;
        if(*texture)
-               faceData->m_texdef.SetName(texture);
+               faceData->m_shader = texture;
        else
        else
-               faceData->m_texdef.SetName("textures/common/caulk");
+               faceData->m_shader = "textures/common/caulk";
        VectorCopy(va, faceData->m_p0);
        VectorCopy(vb, faceData->m_p1);
        VectorCopy(vc, faceData->m_p2);
        VectorCopy(va, faceData->m_p0);
        VectorCopy(vb, faceData->m_p1);
        VectorCopy(vc, faceData->m_p2);
@@ -422,9 +421,19 @@ vec_t Min(vec_t a, vec_t b)
        return b;
 }
 
        return b;
 }
 
-void MakeNormal( vec_t* va, vec_t* vb, vec_t* vc, vec_t* out ) {
+void MakeNormal( const vec_t* va, const vec_t* vb, const vec_t* vc, vec_t* out ) {
        vec3_t v1, v2;
        VectorSubtract(va, vb, v1);
        VectorSubtract(vc, vb, v2);
        CrossProduct(v1, v2, out);
 }
        vec3_t v1, v2;
        VectorSubtract(va, vb, v1);
        VectorSubtract(vc, vb, v2);
        CrossProduct(v1, v2, out);
 }
+
+char* GetFilename(char* buffer, const char* filename) {
+       strcpy(buffer, g_pSynapseServer->GetModuleFilename(&g_SynapseClient));
+       StripFilename( buffer );
+       strcat(buffer, "/");
+       strcat(buffer, filename);
+       //buffer = UnixToDosPath(buffer);
+       return buffer;
+}
+
index f1431c43de85326159a2cbe5e4f1cd677de9016c..e011b67e9f9bdb088580078c66b5729abb4179d5 100644 (file)
@@ -17,16 +17,24 @@ License along with this library; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
 
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
 
+#if !defined(INCLUDED_MISC_H)
+#define INCLUDED_MISC_H
+
+#include "mathlib.h"
+#include <list>
+#include "str.h"
+#include "iscenegraph.h"
+
+#define MAX_ROUND_ERROR        0.05
+
 vec_t Min(vec_t a, vec_t b);
 
 // reads current texture into global, returns pointer to it
 const char* GetCurrentTexture();
 
 vec_t Min(vec_t a, vec_t b);
 
 // reads current texture into global, returns pointer to it
 const char* GetCurrentTexture();
 
-void FillDefaultTexture(_QERFaceData* faceData, vec3_t va, vec3_t vb, vec3_t vc, const char* texture);
+void FillDefaultTexture(void* faceData, vec3_t va, vec3_t vb, vec3_t vc, const char* texture);
 
 
-void Sys_ERROR (char* text, ...);
-
-void BuildMiniPrt(list<Str>* exclusionList);
+void BuildMiniPrt(std::list<Str>* exclusionList);
 
 void MoveBlock(int dir, vec3_t min, vec3_t max, float dist);
 void SetInitialStairPos(int dir, vec3_t min, vec3_t max, float width);
 
 void MoveBlock(int dir, vec3_t min, vec3_t max, float dist);
 void SetInitialStairPos(int dir, vec3_t min, vec3_t max, float width);
@@ -43,4 +51,6 @@ float Determinant3x3(float a1, float a2, float a3,
                                         float c1, float c2, float c3);
 
 bool GetEntityCentre(const char* entity, vec3_t centre);
                                         float c1, float c2, float c3);
 
 bool GetEntityCentre(const char* entity, vec3_t centre);
-void MakeNormal( vec_t* va, vec_t* vb, vec_t* vc, vec_t* out );
+void MakeNormal( const vec_t* va, const vec_t* vb, const vec_t* vc, vec_t* out );
+
+#endif
index 84bdc011bc45e19d4201a532040f832d699e6a17..3c5e37340352e9399c8a5660d203683ceb750d25 100644 (file)
@@ -18,11 +18,9 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
 
 
 */
 
 
-#include "StdAfx.h"
-
 #include "shapes.h"
 
 #include "shapes.h"
 
-#include "gtkr_list.h"
+#include <list>
 
 #include "DPoint.h"
 #include "DPlane.h"
 
 #include "DPoint.h"
 #include "DPlane.h"
@@ -80,18 +78,16 @@ float Deg2Rad(float angle)
        return (float)(angle*Q_PI/180);
 }
 
        return (float)(angle*Q_PI/180);
 }
 
-void AddFaceWithTexture(scene::Node* brush, vec3_t va, vec3_t vb, vec3_t vc, const char* texture, bool detail)
+void AddFaceWithTexture(scene::Node& brush, vec3_t va, vec3_t vb, vec3_t vc, const char* texture, bool detail)
 {
        _QERFaceData faceData;
        FillDefaultTexture(&faceData, va, vb, vc, texture);
        if(detail)
                faceData.m_texdef.contents |= FACE_DETAIL;
 {
        _QERFaceData faceData;
        FillDefaultTexture(&faceData, va, vb, vc, texture);
        if(detail)
                faceData.m_texdef.contents |= FACE_DETAIL;
-#if 0
-       brush->m_brush->addPlane(faceData.m_p0, faceData.m_p1, faceData.m_p2, faceData.m_texdef);
-#endif
+  GlobalBrushCreator().addBrushFace(brush, faceData);
 }
 
 }
 
-void AddFaceWithTextureScaled(scene::Node* brush, vec3_t va, vec3_t vb, vec3_t vc, 
+void AddFaceWithTextureScaled(scene::Node& brush, vec3_t va, vec3_t vb, vec3_t vc, 
                                                          const char* texture, bool bVertScale, bool bHorScale, 
                                                          float minX, float minY, float maxX, float maxY)
 {
                                                          const char* texture, bool bVertScale, bool bHorScale, 
                                                          float minX, float minY, float maxX, float maxY)
 {
@@ -135,9 +131,7 @@ void AddFaceWithTextureScaled(scene::Node* brush, vec3_t va, vec3_t vb, vec3_t v
                addFace.m_texdef.shift[0] = shift[0];
                addFace.m_texdef.shift[1] = shift[1];
 
                addFace.m_texdef.shift[0] = shift[0];
                addFace.m_texdef.shift[1] = shift[1];
 
-#if 0
-         brush->m_brush->addPlane(addFace.m_p0, addFace.m_p1, addFace.m_p2, addFace.m_texdef);
-#endif
+    GlobalBrushCreator().addBrushFace(brush, addFace);
        }
        else
        {
        }
        else
        {
@@ -156,7 +150,7 @@ void AddFaceWithTextureScaled(scene::Node* brush, vec3_t va, vec3_t vb, vec3_t v
 
 void Build_Wedge(int dir, vec3_t min, vec3_t max, bool bUp)
 {
 
 void Build_Wedge(int dir, vec3_t min, vec3_t max, bool bUp)
 {
-  scene::Node* newBrush = Brush_AllocNode();
+  NodeSmartReference newBrush(GlobalBrushCreator().createBrush());
 
        vec3_t v1, v2, v3, v5, v6, v7, v8;
        VectorCopy(min, v1);
 
        vec3_t v1, v2, v3, v5, v6, v7, v8;
        VectorCopy(min, v1);
@@ -233,7 +227,7 @@ void Build_Wedge(int dir, vec3_t min, vec3_t max, bool bUp)
                        AddFaceWithTexture(newBrush, v7, v8, v3, "textures/common/caulk", FALSE);
        }
 
                        AddFaceWithTexture(newBrush, v7, v8, v3, "textures/common/caulk", FALSE);
        }
 
-       GetWorldspawn()->m_traverse->insert(newBrush);
+       Node_getTraversable(GetWorldspawn())->insert(newBrush);
 }
 
 //-----------------------------------------------------------------------------------
 }
 
 //-----------------------------------------------------------------------------------
@@ -241,7 +235,7 @@ void Build_Wedge(int dir, vec3_t min, vec3_t max, bool bUp)
 
 void Build_StairStep_Wedge(int dir, vec3_t min, vec3_t max, const char* mainTexture, const char* riserTexture, bool detail)
 {
 
 void Build_StairStep_Wedge(int dir, vec3_t min, vec3_t max, const char* mainTexture, const char* riserTexture, bool detail)
 {
-  scene::Node* newBrush = Brush_AllocNode();
+  NodeSmartReference newBrush(GlobalBrushCreator().createBrush());
 
        //----- Build Outer Bounds ---------
 
 
        //----- Build Outer Bounds ---------
 
@@ -312,16 +306,16 @@ void Build_StairStep_Wedge(int dir, vec3_t min, vec3_t max, const char* mainText
        if(dir == MOVE_SOUTH)
                AddFaceWithTexture(newBrush, v7, v8, v3, "textures/common/caulk", detail);
 
        if(dir == MOVE_SOUTH)
                AddFaceWithTexture(newBrush, v7, v8, v3, "textures/common/caulk", detail);
 
-  GetWorldspawn()->m_traverse->insert(newBrush);
+  Node_getTraversable(GetWorldspawn())->insert(newBrush);
 }
 
 //-----------------------------------------------------------------------------------
 //-----------------------------------------------------------------------------------
 
 // internal use only, to get a box without finishing construction
 }
 
 //-----------------------------------------------------------------------------------
 //-----------------------------------------------------------------------------------
 
 // internal use only, to get a box without finishing construction
-scene::Node* Build_Get_BoundingCube_Selective(vec3_t min, vec3_t max, char* texture, bool* useFaces)
+scene::Node& Build_Get_BoundingCube_Selective(vec3_t min, vec3_t max, char* texture, bool* useFaces)
 {
 {
-  scene::Node* newBrush = Brush_AllocNode();
+  scene::Node& newBrush(GlobalBrushCreator().createBrush());
 
        //----- Build Outer Bounds ---------
 
 
        //----- Build Outer Bounds ---------
 
@@ -362,7 +356,7 @@ scene::Node* Build_Get_BoundingCube_Selective(vec3_t min, vec3_t max, char* text
        return newBrush;
 }
 
        return newBrush;
 }
 
-scene::Node* Build_Get_BoundingCube(vec3_t min, vec3_t max, char* texture)
+scene::Node& Build_Get_BoundingCube(vec3_t min, vec3_t max, char* texture)
 {
        return Build_Get_BoundingCube_Selective(min, max, texture, bFacesAll);
 }
 {
        return Build_Get_BoundingCube_Selective(min, max, texture, bFacesAll);
 }
@@ -372,7 +366,7 @@ scene::Node* Build_Get_BoundingCube(vec3_t min, vec3_t max, char* texture)
 
 void Build_StairStep(vec3_t min, vec3_t max, const char* mainTexture, const char* riserTexture, int direction)
 {
 
 void Build_StairStep(vec3_t min, vec3_t max, const char* mainTexture, const char* riserTexture, int direction)
 {
-  scene::Node* newBrush = Brush_AllocNode();
+  scene::Node& newBrush(GlobalBrushCreator().createBrush());
 
        //----- Build Outer Bounds ---------
 
 
        //----- Build Outer Bounds ---------
 
@@ -422,7 +416,7 @@ void Build_StairStep(vec3_t min, vec3_t max, const char* mainTexture, const char
        AddFaceWithTexture(newBrush, v1, v2, v3, "textures/common/caulk", FALSE);
        // base is caulked
 
        AddFaceWithTexture(newBrush, v1, v2, v3, "textures/common/caulk", FALSE);
        // base is caulked
 
-       GetWorldspawn()->m_traverse->insert(newBrush);
+       Node_getTraversable(GetWorldspawn())->insert(newBrush);
        // finish brush
 }
 
        // finish brush
 }
 
@@ -478,8 +472,8 @@ void BuildDoorsX2(vec3_t min, vec3_t max,
 
        //----------------------------------
 
 
        //----------------------------------
 
-  scene::Node* newBrush1 = Brush_AllocNode();
-       scene::Node* newBrush2 = Brush_AllocNode();
+  NodeSmartReference newBrush1(GlobalBrushCreator().createBrush());
+       NodeSmartReference newBrush2(GlobalBrushCreator().createBrush());
 
        AddFaceWithTexture(newBrush1, v1, v2, v3, "textures/common/caulk", FALSE);
        AddFaceWithTexture(newBrush1, v5, v7, v6, "textures/common/caulk", FALSE);
 
        AddFaceWithTexture(newBrush1, v1, v2, v3, "textures/common/caulk", FALSE);
        AddFaceWithTexture(newBrush1, v5, v7, v6, "textures/common/caulk", FALSE);
@@ -543,8 +537,8 @@ void BuildDoorsX2(vec3_t min, vec3_t max,
        //----------------------------------
        
 
        //----------------------------------
        
 
-  scene::Node* pEDoor1 = GlobalEntityCreator().createEntity("func_door");
-       scene::Node* pEDoor2 = GlobalEntityCreator().createEntity("func_door");
+  NodeSmartReference pEDoor1 = GlobalEntityCreator().createEntity("func_door");
+       NodeSmartReference pEDoor2 = GlobalEntityCreator().createEntity("func_door");
 
        if(direction == 0)
        {
 
        if(direction == 0)
        {
@@ -564,11 +558,11 @@ void BuildDoorsX2(vec3_t min, vec3_t max,
   pEDoor1->m_entity->setkeyvalue("team", teamname);
   pEDoor2->m_entity->setkeyvalue("team", teamname);
 
   pEDoor1->m_entity->setkeyvalue("team", teamname);
   pEDoor2->m_entity->setkeyvalue("team", teamname);
 
-       pEDoor1->m_traverse->insert(newBrush1);
-       pEDoor2->m_traverse->insert(newBrush2);
+       Node_getTraversable(pEDoor1)->insert(newBrush1);
+       Node_getTraversable(pEDoor2)->insert(newBrush2);
 
 
-  GlobalSceneGraph().root()->m_traverse->insert(pEDoor1);
-  GlobalSceneGraph().root()->m_traverse->insert(pEDoor2);
+  Node_getTraversable(GlobalSceneGraph().root())->insert(pEDoor1);
+  Node_getTraversable(GlobalSceneGraph().root())->insert(pEDoor2);
 
 //     ResetCurrentTexture();
 }
 
 //     ResetCurrentTexture();
 }
@@ -578,14 +572,14 @@ void BuildDoorsX2(vec3_t min, vec3_t max,
 
 void MakeBevel(vec3_t vMin, vec3_t vMax)
 {
 
 void MakeBevel(vec3_t vMin, vec3_t vMax)
 {
-  scene::Node* patch = Patch_AllocNode();
+  NodeSmartReference patch(GlobalPatchCreator().createPatch());
   aabb_t aabb;
   aabb_construct_for_vec3(&aabb, vMin, vMax);
 #if 0
   patch->m_patch->ConstructPrefab(&aabb, eBevel, 2); // 2 == XY view
 #endif
 
   aabb_t aabb;
   aabb_construct_for_vec3(&aabb, vMin, vMax);
 #if 0
   patch->m_patch->ConstructPrefab(&aabb, eBevel, 2); // 2 == XY view
 #endif
 
-  GetWorldspawn()->m_traverse->insert(patch);
+  Node_getTraversable(GetWorldspawn())->insert(patch);
 }
 
 void BuildCornerStairs(vec3_t vMin, vec3_t vMax, int nSteps, const char* mainTexture, const char* riserTex)
 }
 
 void BuildCornerStairs(vec3_t vMin, vec3_t vMax, int nSteps, const char* mainTexture, const char* riserTex)
@@ -628,7 +622,7 @@ void BuildCornerStairs(vec3_t vMin, vec3_t vMax, int nSteps, const char* mainTex
 
        for(i = 0; i < nSteps; i++)
        {
 
        for(i = 0; i < nSteps; i++)
        {
-    scene::Node* brush = Build_Get_BoundingCube_Selective(vBot, vTop, "textures/common/caulk", bFacesUse);
+    scene::Node& brush = Build_Get_BoundingCube_Selective(vBot, vTop, "textures/common/caulk", bFacesUse);
 
                for(int j = 0; j < 3; j++)
                        tp[j][2] = vTop[2];
 
                for(int j = 0; j < 3; j++)
                        tp[j][2] = vTop[2];
@@ -638,7 +632,7 @@ void BuildCornerStairs(vec3_t vMin, vec3_t vMax, int nSteps, const char* mainTex
                AddFaceWithTexture(brush, centre, botPoints[i+1], topPoints[i+1], "textures/common/caulk", FALSE);
                AddFaceWithTexture(brush, centre, topPoints[i], botPoints[i], riserTex, FALSE);
 
                AddFaceWithTexture(brush, centre, botPoints[i+1], topPoints[i+1], "textures/common/caulk", FALSE);
                AddFaceWithTexture(brush, centre, topPoints[i], botPoints[i], riserTex, FALSE);
 
-               GetWorldspawn()->m_traverse->insert(brush);
+               Node_getTraversable(GetWorldspawn())->insert(brush);
 
                vTop[2] += height;
                vBot[2] += height;
 
                vTop[2] += height;
                vBot[2] += height;
index d48969e1ff8b4b92f621a1e9b97272d23215edb9..c277d428ac9d37429dd23a892c70321c6c0f6d5b 100644 (file)
@@ -27,7 +27,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 #define MAX_POLYGON_FACES      128
 
 // generic (detail added 12/01/01, for AC+)
 #define MAX_POLYGON_FACES      128
 
 // generic (detail added 12/01/01, for AC+)
-void AddFaceWithTexture(scene::Node* brush, vec3_t va, vec3_t vb, vec3_t vc, const char* texture, bool detail);
+void AddFaceWithTexture(scene::Node& brush, vec3_t va, vec3_t vb, vec3_t vc, const char* texture, bool detail);
 
 // -------------
 // ---caulked---
 
 // -------------
 // ---caulked---
index ae3602d18004f80cdff59082f8f0e257c623dc5e..e5b890b1bfcd2fd2529ecf0690bcfe75264aa88d 100644 (file)
@@ -2,12 +2,12 @@
 // Date: Oct 5, 2001
 // Written by: Brad Whitehead (whiteheb@gamerstv.net)
 
 // Date: Oct 5, 2001
 // Written by: Brad Whitehead (whiteheb@gamerstv.net)
 
-#include "StdAfx.h"
+#include "visfind.h"
 #include "dialogs/dialogs-gtk.h"
 #include "DWinding.h"
 #include "bsploader.h"
 
 #include "dialogs/dialogs-gtk.h"
 #include "DWinding.h"
 #include "bsploader.h"
 
-#include "gtkr_list.h"
+#include <list>
 
 typedef struct {
        int             portalclusters;
 
 typedef struct {
        int             portalclusters;
@@ -122,7 +122,7 @@ int bsp_countclusters_mask(byte *bitvector, byte *maskvector, int length)
        return(c);
 }
 
        return(c);
 }
 
-void AddCluster(list<DWinding*> *pointlist, dleaf_t    *cl, bool* repeatlist, vec3_t clr)
+void AddCluster(std::list<DWinding*> *pointlist, dleaf_t       *cl, bool* repeatlist, vec3_t clr)
 {
        DWinding*       w;
        
 {
        DWinding*       w;
        
@@ -164,11 +164,11 @@ void AddCluster(list<DWinding*> *pointlist, dleaf_t       *cl, bool* repeatlist, vec3_
 CreateTrace
 =============
 */
 CreateTrace
 =============
 */
-list<DWinding*> *CreateTrace( dleaf_t *leaf, int c, vis_header *header, byte *visdata, byte *seen )
+std::list<DWinding*> *CreateTrace( dleaf_t *leaf, int c, vis_header *header, byte *visdata, byte *seen )
 {
        byte            *vis;
        int                     i, j, clusterNum;
 {
        byte            *vis;
        int                     i, j, clusterNum;
-       list<DWinding*> *pointlist = new list<DWinding*>;
+       std::list<DWinding*> *pointlist = new std::list<DWinding*>;
        bool*   repeatlist = new bool[numDrawSurfaces];
        dleaf_t         *cl;
 
        bool*   repeatlist = new bool[numDrawSurfaces];
        dleaf_t         *cl;
 
@@ -214,7 +214,7 @@ TraceCluster
 setup for CreateTrace
 =============
 */
 setup for CreateTrace
 =============
 */
-list<DWinding*> *TraceCluster (int leafnum)
+std::list<DWinding*> *TraceCluster (int leafnum)
 {
        byte                    seen[(MAX_MAP_LEAFS/8) + 1];
        vis_header              *vheader;
 {
        byte                    seen[(MAX_MAP_LEAFS/8) + 1];
        vis_header              *vheader;
@@ -232,14 +232,14 @@ list<DWinding*> *TraceCluster (int leafnum)
        return CreateTrace(leaf, leaf->cluster, vheader, visdata, seen);
 }
 
        return CreateTrace(leaf, leaf->cluster, vheader, visdata, seen);
 }
 
-list<DWinding *>* BuildTrace(char* filename, vec3_t v_origin)
+std::list<DWinding *>* BuildTrace(char* filename, vec3_t v_origin)
 {
        if(!LoadBSPFile(filename))
                return NULL;
        
        int leafnum = bsp_leafnumfororigin(v_origin);
 
 {
        if(!LoadBSPFile(filename))
                return NULL;
        
        int leafnum = bsp_leafnumfororigin(v_origin);
 
-       list<DWinding*> *pointlist = TraceCluster(leafnum);
+       std::list<DWinding*> *pointlist = TraceCluster(leafnum);
 
        FreeBSPData();
 
 
        FreeBSPData();
 
index 0a4b601e37a03d45fa5cbc73b3dda5ec6087e025..3476d8645f5b5786cfaa357597115a629ac0ee74 100644 (file)
@@ -1 +1,7 @@
-list<DWinding*> *BuildTrace(char* filename, vec3_t v_origin);
+
+#include <list>
+#include "mathlib.h"
+
+class DWinding;
+
+std::list<DWinding*> *BuildTrace(char* filename, vec3_t v_origin);
index ef5001cdf328fdd5dad41a8b8f482e8209c8b77e..6e9c95dc854a8f76376e2bf1deef07e401af0df3 100644 (file)
@@ -1979,7 +1979,7 @@ scene::Node* MakePatch(void)
 #if 0
   patch->m_patch->SetShader(Texture[Game][0]);
 #endif
 #if 0
   patch->m_patch->SetShader(Texture[Game][0]);
 #endif
-  h_worldspawn->m_traverse->insert(patch);
+  Node_getTraversable(h_worldspawn)->insert(patch);
   return patch;
 }
 
   return patch;
 }
 
@@ -2021,7 +2021,7 @@ void MakeBrush(BRUSH *brush)
   }
 #endif
 
   }
 #endif
 
-  h_func_group->m_traverse->insert(node);
+  Node_getTraversable(h_func_group)->insert(node);
 }
 //=============================================================
 void OpenFuncGroup()
 }
 //=============================================================
 void OpenFuncGroup()
index 6b3178c06648e70363c33f333e8ea7866b1aef75..e5dea3082cca69a791467d33015e80d59361a54a 100644 (file)
@@ -337,7 +337,7 @@ void Portals_constructShaders()
   GlobalOpenGLStateLibrary().insert(g_state_wireframe, state);
 
   GlobalOpenGLStateLibrary().getDefaultState(state);
   GlobalOpenGLStateLibrary().insert(g_state_wireframe, state);
 
   GlobalOpenGLStateLibrary().getDefaultState(state);
-  state.m_state = RENDER_FILL|RENDER_BLEND|RENDER_COLOURWRITE|RENDER_COLOURCHANGE|RENDER_SMOOTH|RENDER_POLYGONSMOOTH;
+  state.m_state = RENDER_FILL|RENDER_BLEND|RENDER_COLOURWRITE|RENDER_COLOURCHANGE|RENDER_SMOOTH;
 
        if(portals.aa_3d)
   {
 
        if(portals.aa_3d)
   {
index 318ee55278daac4aa360b8540ad08fc9a7d1c794..187ebcc4a02e7b2284b855616a192a0cb8663356 100644 (file)
@@ -23,12 +23,81 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #define INCLUDED_IBRUSH_H
 
 #include "generic/constant.h"
 #define INCLUDED_IBRUSH_H
 
 #include "generic/constant.h"
+#include "generic/callback.h"
+#include "math/vector.h"
+#include "itexdef.h"
 
 namespace scene
 {
   class Node;
 }
 
 
 namespace scene
 {
   class Node;
 }
 
+#if 0
+class IBrushFace
+{
+public:
+  virtual const char* GetShader() const = 0;
+  virtual void SetShader(const char* name) = 0;
+  virtual const TextureProjection& GetTexdef() const = 0;
+  virtual void GetTexdef(TextureProjection& projection) const = 0;
+  virtual void SetTexdef(const TextureProjection& projection) = 0;
+  virtual void GetFlags(ContentsFlagsValue& flags) const = 0;
+  virtual void SetFlags(const ContentsFlagsValue& flags) = 0;
+  virtual void ShiftTexdef(float s, float t) = 0;
+  virtual void ScaleTexdef(float s, float t) = 0;
+  virtual void RotateTexdef(float angle) = 0;
+  virtual void FitTexture(float s_repeat, float t_repeat) = 0;
+  virtual bool isDetail() const = 0;
+  virtual void setDetail(bool detail) = 0;
+};
+
+class IBrush
+{
+public:
+  STRING_CONSTANT(Name, "IBrush");
+  virtual void reserve(std::size_t count) = 0;
+  virtual void clear() = 0;
+  virtual void copy(const IBrush& other) = 0;
+  virtual IBrushFace* addPlane(const Vector3& p0, const Vector3& p1, const Vector3& p2, const char* shader, const TextureProjection& projection) = 0;
+  virtual const AABB& localAABB() const = 0;
+  virtual void removeEmptyFaces() = 0;
+};
+
+class IBrushFaceInstance
+{
+public:
+  virtual IBrushFace& getFace() = 0;
+  virtual const IBrushFace& getFace() const = 0;
+  virtual bool isSelected() const = 0;
+  virtual void setSelected(SelectionSystem::EComponentMode mode, bool select) const = 0;
+};
+
+class IBrushInstance
+{
+public:
+  STRING_CONSTANT(Name, "IBrushInstance");
+  virtual void forEachFaceInstance(const BrushInstanceVisitor& visitor) = 0;
+};
+#endif
+
+class _QERFaceData
+{
+public:
+  _QERFaceData() : contents(0), flags(0), value(0), m_shader("")
+  {
+  }
+  Vector3 m_p0;
+  Vector3 m_p1;
+  Vector3 m_p2;
+  texdef_t m_texdef;
+  const char* m_shader;
+  int contents;
+  int flags;
+  int value;
+};
+
+typedef Callback1<const _QERFaceData&> BrushFaceDataCallback;
+
 class BrushCreator
 {
 public:
 class BrushCreator
 {
 public:
@@ -36,6 +105,8 @@ public:
   STRING_CONSTANT(Name, "brush");
   virtual scene::Node& createBrush() = 0;
   virtual bool useAlternativeTextureProjection() const = 0;
   STRING_CONSTANT(Name, "brush");
   virtual scene::Node& createBrush() = 0;
   virtual bool useAlternativeTextureProjection() const = 0;
+  virtual void forEachBrushFace(scene::Node& brush, const BrushFaceDataCallback& callback) = 0;
+  virtual bool addBrushFace(scene::Node& brush, const _QERFaceData& faceData) = 0;
 };
 
 #include "modulesystem.h"
 };
 
 #include "modulesystem.h"
index 0c6f4dd9aad88f32ed1b6f51e99955f08860da4a..c98fdc062833b5096b8a28c70b8c17c9f6897242 100644 (file)
@@ -29,6 +29,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #define INCLUDED_ICAMERA_H
 
 #include "generic/constant.h"
 #define INCLUDED_ICAMERA_H
 
 #include "generic/constant.h"
+#include "generic/callbackfwd.h"
 
 class Matrix4;
 
 
 class Matrix4;
 
@@ -39,8 +40,6 @@ public:
   virtual void setFieldOfView(float fieldOfView) = 0;
 };
 
   virtual void setFieldOfView(float fieldOfView) = 0;
 };
 
-class Callback;
-
 class CameraModel
 {
 public:
 class CameraModel
 {
 public:
index 34a5638dc9f8c3016012b8fa82fad9a54df45ad7..f96e049574a8847c214879b500e81a297145deb4 100644 (file)
@@ -29,11 +29,30 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
 class EntityClass;
 
 
 class EntityClass;
 
+typedef Callback1<const char*> KeyObserver;
+
+class EntityKeyValue
+{
+public:
+  virtual const char* c_str() const = 0;
+  virtual void assign(const char* other) = 0;
+  virtual void attach(const KeyObserver& observer) = 0;
+  virtual void detach(const KeyObserver& observer) = 0;
+};
+
 class Entity
 {
 public:
   STRING_CONSTANT(Name, "Entity");
 
 class Entity
 {
 public:
   STRING_CONSTANT(Name, "Entity");
 
+  class Observer
+  {
+  public:
+    virtual void insert(const char* key, EntityKeyValue& value) = 0;
+    virtual void erase(const char* key, EntityKeyValue& value) = 0;
+    virtual void clear() { };
+  };
+
   class Visitor
   {
   public:
   class Visitor
   {
   public:
@@ -45,6 +64,8 @@ public:
   virtual void setKeyValue(const char* key, const char* value) = 0;
   virtual const char* getKeyValue(const char* key) const = 0;
   virtual bool isContainer() const = 0;
   virtual void setKeyValue(const char* key, const char* value) = 0;
   virtual const char* getKeyValue(const char* key) const = 0;
   virtual bool isContainer() const = 0;
+  void attach(Observer& observer);
+  void detach(Observer& observer);
 };
 
 class EntityCopyingVisitor : public Entity::Visitor
 };
 
 class EntityCopyingVisitor : public Entity::Visitor
index b44c7fbc735a8f0e7d76857abef7246e59d3775e..339c82f1aad65258f22e90f30b226625c0b5ad9a 100644 (file)
@@ -24,9 +24,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
 #include <cstddef>
 #include "generic/constant.h"
 
 #include <cstddef>
 #include "generic/constant.h"
+#include "generic/callbackfwd.h"
 
 
-template<typename FirstArgument>
-class Callback1;
 typedef Callback1<const char*> ArchiveNameCallback;
 typedef Callback1<const char*> FileNameCallback;
 
 typedef Callback1<const char*> ArchiveNameCallback;
 typedef Callback1<const char*> FileNameCallback;
 
index 77cdf0e8653908acc219e4695b53d7b5cf6a0829..2846670870fa1366fa9c975fed3d27c01aecc00a 100644 (file)
@@ -23,6 +23,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #define INCLUDED_IRENDER_H
 
 #include "generic/constant.h"
 #define INCLUDED_IRENDER_H
 
 #include "generic/constant.h"
+#include "generic/callbackfwd.h"
 
 
 // Rendering states to sort by.
 
 
 // Rendering states to sort by.
@@ -88,9 +89,6 @@ public:
   }
 };
 
   }
 };
 
-template<typename FirstArgument>
-class Callback1;
-
 class Renderable;
 typedef Callback1<const Renderable&> RenderableCallback;
 
 class Renderable;
 typedef Callback1<const Renderable&> RenderableCallback;
 
index 48e99aaf95f33bdfac8ee8cf195fe550372481d2..18e50f77276b6f81269b8e426ab78f892cb34950 100644 (file)
@@ -24,14 +24,13 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
 #include <cstddef>
 #include "generic/constant.h"
 
 #include <cstddef>
 #include "generic/constant.h"
+#include "signal/signalfwd.h"
 
 template<typename value_type>
 class Stack;
 template<typename Contained>
 class Reference;
 
 
 template<typename value_type>
 class Stack;
 template<typename Contained>
 class Reference;
 
-class Callback;
-
 namespace scene
 {
   class Instance;
 namespace scene
 {
   class Instance;
@@ -105,15 +104,15 @@ namespace scene
     virtual void sceneChanged() = 0;
     /// \brief Add a \p callback to be invoked when the scene changes.
     /// \todo Move to a separate class.
     virtual void sceneChanged() = 0;
     /// \brief Add a \p callback to be invoked when the scene changes.
     /// \todo Move to a separate class.
-    virtual void addSceneChangedCallback(const Callback& callback) = 0;
+    virtual void addSceneChangedCallback(const SignalHandler& handler) = 0;
 
     /// \brief Invokes all bounds-changed callbacks. Called when the bounds of any instance in the scene change.
     /// \todo Move to a separate class.
     virtual void boundsChanged() = 0;
     /// \brief Add a \p callback to be invoked when the bounds of any instance in the scene change.
 
     /// \brief Invokes all bounds-changed callbacks. Called when the bounds of any instance in the scene change.
     /// \todo Move to a separate class.
     virtual void boundsChanged() = 0;
     /// \brief Add a \p callback to be invoked when the bounds of any instance in the scene change.
-    virtual void addBoundsChangedCallback(const Callback& callback) = 0;
+    virtual SignalHandlerId addBoundsChangedCallback(const SignalHandler& boundsChanged) = 0;
     /// \brief Remove a \p callback to be invoked when the bounds of any instance in the scene change.
     /// \brief Remove a \p callback to be invoked when the bounds of any instance in the scene change.
-    virtual void removeBoundsChangedCallback(const Callback& callback) = 0;
+    virtual void removeBoundsChangedCallback(SignalHandlerId id) = 0;
 
     virtual TypeId getNodeTypeId(const char* name) = 0;
     virtual TypeId getInstanceTypeId(const char* name) = 0;
 
     virtual TypeId getNodeTypeId(const char* name) = 0;
     virtual TypeId getInstanceTypeId(const char* name) = 0;
@@ -208,9 +207,9 @@ inline scene::Graph& GlobalSceneGraph()
   return GlobalSceneGraphModule::getTable();
 }
 
   return GlobalSceneGraphModule::getTable();
 }
 
-inline void AddSceneChangeCallback(const Callback& callback)
+inline void AddSceneChangeCallback(const SignalHandler& handler)
 {
 {
-  GlobalSceneGraph().addSceneChangedCallback(callback);
+  GlobalSceneGraph().addSceneChangedCallback(handler);
 }
 inline void SceneChangeNotify()
 {
 }
 inline void SceneChangeNotify()
 {
index 2a86a31e07258384bfa2c3f74017f1ef6ed86194..ec32561e1651b9418d17a8843092352bc83da91f 100644 (file)
@@ -24,15 +24,12 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
 #include <cstddef>
 #include "generic/constant.h"
 
 #include <cstddef>
 #include "generic/constant.h"
+#include "generic/callbackfwd.h"
+#include "signal/signalfwd.h"
 
 class Renderer;
 class View;
 
 
 class Renderer;
 class View;
 
-class Callback;
-
-template<typename FirstArgument>
-class Callback1;
-
 class Selectable
 {
 public:
 class Selectable
 {
 public:
@@ -61,6 +58,7 @@ class Matrix4;
 typedef Vector4 Quaternion;
 
 typedef Callback1<const Selectable&> SelectionChangeCallback;
 typedef Vector4 Quaternion;
 
 typedef Callback1<const Selectable&> SelectionChangeCallback;
+typedef SignalHandler1<const Selectable&> SelectionChangeHandler;
 
 class SelectionSystem
 {
 
 class SelectionSystem
 {
@@ -117,7 +115,7 @@ public:
   virtual void foreachSelected(const Visitor& visitor) const = 0;
   virtual void foreachSelectedComponent(const Visitor& visitor) const = 0;
 
   virtual void foreachSelected(const Visitor& visitor) const = 0;
   virtual void foreachSelectedComponent(const Visitor& visitor) const = 0;
 
-  virtual void addSelectionChangeCallback(const SelectionChangeCallback& callback) = 0;
+  virtual void addSelectionChangeCallback(const SelectionChangeHandler& handler) = 0;
 
   virtual void NudgeManipulator(const Vector3& nudge, const Vector3& view) = 0;
 
 
   virtual void NudgeManipulator(const Vector3& nudge, const Vector3& view) = 0;
 
index 49ddf46b401f647b6030f31e4d7fbb341841ea01..928dd1dec3649bc82cd73049f675c54e993ad674 100644 (file)
@@ -23,6 +23,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #define INCLUDED_ISHADERS_H
 
 #include "generic/constant.h"
 #define INCLUDED_ISHADERS_H
 
 #include "generic/constant.h"
+#include "generic/callbackfwd.h"
 
 enum
 {
 
 enum
 {
@@ -78,8 +79,6 @@ public:
   virtual float alphaTest() const = 0;
 };
 
   virtual float alphaTest() const = 0;
 };
 
-template<typename FirstArgument>
-class Callback1;
 typedef Callback1<const ShaderLayer&> ShaderLayerCallback;
 
 
 typedef Callback1<const ShaderLayer&> ShaderLayerCallback;
 
 
@@ -133,7 +132,6 @@ public:
   virtual qtexture_t* lightFalloffImage() const = 0;
 };
 
   virtual qtexture_t* lightFalloffImage() const = 0;
 };
 
-class Callback;
 typedef struct _GSList GSList;
 typedef Callback1<const char*> ShaderNameCallback;
 
 typedef struct _GSList GSList;
 typedef Callback1<const char*> ShaderNameCallback;
 
index 6719a49751bae945b4516d3521ee97c0a166cfcc..4dcbad8552e3a3693b2240f77306f66758850609 100644 (file)
@@ -27,6 +27,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
 #include <cstddef>
 #include "generic/constant.h"
 
 #include <cstddef>
 #include "generic/constant.h"
+#include "generic/callbackfwd.h"
 
 class UndoMemento
 {
 
 class UndoMemento
 {
@@ -47,8 +48,6 @@ public:
   virtual void save(Undoable* undoable) = 0;
 };
 
   virtual void save(Undoable* undoable) = 0;
 };
 
-class Callback;
-
 class UndoTracker
 {
 public:
 class UndoTracker
 {
 public:
index 2df91a7d94d7f321fc0d03e3b3b2951ed282ad34..e53d79c17a861da56d1374e5c291ecbb54faeb73 100644 (file)
@@ -25,8 +25,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #include <limits>
 
 #include "iscenegraph.h"
 #include <limits>
 
 #include "iscenegraph.h"
-
-class Callback;
+#include "generic/callbackfwd.h"
 
 const std::size_t MAPFILE_MAX_CHANGES = std::numeric_limits<std::size_t>::max();
 
 
 const std::size_t MAPFILE_MAX_CHANGES = std::numeric_limits<std::size_t>::max();
 
index 1104800ddc0b771d782f9e67ed8bd9094f1501ee..c01b5f307935713c708756be76e2855428529138 100644 (file)
@@ -23,6 +23,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #define INCLUDED_MODELSKIN_H
 
 #include "generic/constant.h"
 #define INCLUDED_MODELSKIN_H
 
 #include "generic/constant.h"
+#include "generic/callbackfwd.h"
 
 class SkinRemap
 {
 
 class SkinRemap
 {
@@ -34,8 +35,6 @@ public:
   }
 };
 
   }
 };
 
-template<typename FirstArgument>
-class Callback1;
 typedef Callback1<SkinRemap> SkinRemapCallback;
 class ModuleObserver;
 
 typedef Callback1<SkinRemap> SkinRemapCallback;
 class ModuleObserver;
 
index 9147554e58afe8d0379fa1214cc48c79392350a4..8e1357a46be52b682084f5557fef1fd5ef189d25 100644 (file)
@@ -23,9 +23,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #define INCLUDED_NAMEABLE_H
 
 #include "generic/constant.h"
 #define INCLUDED_NAMEABLE_H
 
 #include "generic/constant.h"
+#include "generic/callbackfwd.h"
 
 
-template<typename FirstArgument>
-class Callback1;
 typedef Callback1<const char*> NameCallback;
 
 class Nameable
 typedef Callback1<const char*> NameCallback;
 
 class Nameable
index df8fda4a23ab1d4078c7fed52dae2424c296cc0e..30367bfdb46f8b6c40cbaa5ef37a289ea1fe8ffb 100644 (file)
@@ -23,9 +23,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #define INCLUDED_NAMESPACE_H
 
 #include "generic/constant.h"
 #define INCLUDED_NAMESPACE_H
 
 #include "generic/constant.h"
+#include "generic/callbackfwd.h"
 
 
-template<typename FirstArgument>
-class Callback1;
 typedef Callback1<const char*> NameCallback;
 typedef Callback1<const NameCallback&> NameCallbackCallback;
 
 typedef Callback1<const char*> NameCallback;
 typedef Callback1<const NameCallback&> NameCallbackCallback;
 
index f1891ae3f21cf4427d67fd91c13766a3b53fc944..f5ebae1dda5fc04094fec239604a7321be49c53a 100644 (file)
@@ -23,9 +23,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #define INCLUDED_PREFERENCESYSTEM_H
 
 #include "generic/constant.h"
 #define INCLUDED_PREFERENCESYSTEM_H
 
 #include "generic/constant.h"
+#include "generic/callbackfwd.h"
 
 
-template<typename FirstArgument>
-class Callback1;
 typedef Callback1<const char*> StringImportCallback;
 typedef Callback1<const StringImportCallback&> StringExportCallback;
 
 typedef Callback1<const char*> StringImportCallback;
 typedef Callback1<const StringImportCallback&> StringExportCallback;
 
index 1a4591952f4aef92930ea3cf866058387a7c9170..3e352e53b19c391d8a6469a796a5e6efe0409f96 100644 (file)
@@ -90,8 +90,27 @@ typedef GtkImage* (* PFN_QERAPP_NEWIMAGE) (const char* filename);
 
 // ========================================
 
 
 // ========================================
 
+namespace scene
+{
+  class Node;
+}
+
 class ModuleObserver;
 
 class ModuleObserver;
 
+#include "signal/signalfwd.h"
+#include "windowobserver.h"
+#include "math/vector.h"
+
+typedef SignalHandler3<const WindowVector&, ButtonIdentifier, ModifierFlags> MouseEventHandler;
+typedef SignalFwd<MouseEventHandler>::handler_id_type MouseEventHandlerId;
+
+enum VIEWTYPE
+{
+  YZ = 0,
+  XZ = 1,
+  XY = 2
+};
+
 // the radiant core API
 struct _QERFuncTable_1
 {
 // the radiant core API
 struct _QERFuncTable_1
 {
@@ -107,6 +126,8 @@ struct _QERFuncTable_1
   const char* (*getGameMode)();
 
   const char* (*getMapName)();
   const char* (*getGameMode)();
 
   const char* (*getMapName)();
+  scene::Node& (*getMapWorldEntity)();
+  float (*getGridSize)();
 
   const char* (*getGameDescriptionKeyValue)(const char* key);
   const char* (*getRequiredGameDescriptionKeyValue)(const char* key);
 
   const char* (*getGameDescriptionKeyValue)(const char* key);
   const char* (*getRequiredGameDescriptionKeyValue)(const char* key);
@@ -120,6 +141,12 @@ struct _QERFuncTable_1
   void (*attachGameModeObserver)(ModuleObserver& observer);
   void (*detachGameModeObserver)(ModuleObserver& observer);
 
   void (*attachGameModeObserver)(ModuleObserver& observer);
   void (*detachGameModeObserver)(ModuleObserver& observer);
 
+  MouseEventHandlerId (*XYWindowMouseDown_connect)(const MouseEventHandler& handler);
+  void (*XYWindowMouseDown_disconnect)(MouseEventHandlerId id);
+  VIEWTYPE (*XYWindow_getViewType)();
+  Vector3 (*XYWindow_windowToWorld)(const WindowVector& position);
+  const char* (*TextureBrowser_getSelectedShader)();
+
   // GTK+ functions
   PFN_QERAPP_MESSAGEBOX  m_pfnMessageBox;
   PFN_QERAPP_FILEDIALOG  m_pfnFileDialog;
   // GTK+ functions
   PFN_QERAPP_MESSAGEBOX  m_pfnMessageBox;
   PFN_QERAPP_FILEDIALOG  m_pfnFileDialog;
index f6da5cc54c7a6cc7e100f4d48ada8c4df031e1cb..774f4e0b46df59f9e92bbf4a35af969fb118158f 100644 (file)
@@ -26,6 +26,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
 #include "math/vector.h"
 #include "scenelib.h"
 
 #include "math/vector.h"
 #include "scenelib.h"
+#include "generic/callbackfwd.h"
 
 class SelectionIntersection
 {
 
 class SelectionIntersection
 {
@@ -281,8 +282,6 @@ inline SelectionTestable* Instance_getSelectionTestable(scene::Instance& instanc
 }
 
 
 }
 
 
-template<typename FirstArgument>
-class Callback1;
 class Plane3;
 typedef Callback1<const Plane3&> PlaneCallback;
 
 class Plane3;
 typedef Callback1<const Plane3&> PlaneCallback;
 
index c4b1aded8fb4f1f15ae6f7b387efb2352e04b398..88d672cfc7f14e83406fa1e778f977bfa5891169 100644 (file)
@@ -109,11 +109,11 @@ namespace HashTableDetail
      : m_hash(hash), m_value(key, value)
     {
     }
      : m_hash(hash), m_value(key, value)
     {
     }
-    BucketNode* getNext()
+    BucketNode* getNext() const
     {
       return static_cast<BucketNode*>(next);
     }
     {
       return static_cast<BucketNode*>(next);
     }
-    BucketNode* getPrev()
+    BucketNode* getPrev() const
     {
       return static_cast<BucketNode*>(prev);
     }
     {
       return static_cast<BucketNode*>(prev);
     }
index 2a9cbe70ce8e445e519b7afe15b2c12a9d53d82a..642283fd712ac2ebab842de4b576529ca1b6248a 100644 (file)
@@ -39,8 +39,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #define DEBUGGER_BREAKPOINT() raise(SIGTRAP);
 #endif
 
 #define DEBUGGER_BREAKPOINT() raise(SIGTRAP);
 #endif
 
-
-#define FILE_LINE __FILE__ ":" << __LINE__
+#define STR(x) #x
+#define STR2(x)        STR(x)
+#define FILE_LINE __FILE__ ":" STR2(__LINE__)
 
 #if defined(_DEBUG) || 1
 #define DEBUG_ASSERTS
 
 #if defined(_DEBUG) || 1
 #define DEBUG_ASSERTS
@@ -114,13 +115,13 @@ inline DebugMessageHandler& globalDebugMessageHandler()
 #define ASSERT_MESSAGE(condition, message)\
 if(!(condition))\
 {\
 #define ASSERT_MESSAGE(condition, message)\
 if(!(condition))\
 {\
-  globalDebugMessageHandler().getOutputStream() << FILE_LINE << "\nassertion failure: " << message << "\n";\
+  globalDebugMessageHandler().getOutputStream() << FILE_LINE "\nassertion failure: " << message << "\n";\
   if(!globalDebugMessageHandler().handleMessage()) { DEBUGGER_BREAKPOINT(); }\
 } else\
 
 /// \brief Sends a \p message to the current debug-message-handler text-output-stream.
 #define ERROR_MESSAGE(message)\
   if(!globalDebugMessageHandler().handleMessage()) { DEBUGGER_BREAKPOINT(); }\
 } else\
 
 /// \brief Sends a \p message to the current debug-message-handler text-output-stream.
 #define ERROR_MESSAGE(message)\
-globalDebugMessageHandler().getOutputStream() << FILE_LINE << "\nruntime error: " << message << "\n";\
+globalDebugMessageHandler().getOutputStream() << FILE_LINE "\nruntime error: " << message << "\n";\
 if(!globalDebugMessageHandler().handleMessage()) { DEBUGGER_BREAKPOINT(); } else\
 
 #define ASSERT_NOTNULL(ptr) ASSERT_MESSAGE(ptr != 0, "pointer \"" #ptr "\" is null")
 if(!globalDebugMessageHandler().handleMessage()) { DEBUGGER_BREAKPOINT(); } else\
 
 #define ASSERT_NOTNULL(ptr) ASSERT_MESSAGE(ptr != 0, "pointer \"" #ptr "\" is null")
index b9e93002ee21666436253c5d9010a41c707450ae..4a34f0a53722a910538d2b8f5bd45839417988ba 100644 (file)
@@ -304,13 +304,11 @@ public:
 };
 
 
 };
 
 
-typedef Callback1<const char*> KeyObserver;
-
 /// \brief A key/value pair of strings.
 ///
 /// - Notifies observers when value changes - value changes to "" on destruction.
 /// - Provides undo support through the global undo system.
 /// \brief A key/value pair of strings.
 ///
 /// - Notifies observers when value changes - value changes to "" on destruction.
 /// - Provides undo support through the global undo system.
-class KeyValue
+class KeyValue : public EntityKeyValue
 {
   typedef UnsortedSet<KeyObserver> KeyObservers;
 
 {
   typedef UnsortedSet<KeyObserver> KeyObservers;
 
@@ -414,13 +412,6 @@ class EntityKeyValues : public Entity
 public:
   typedef KeyValue Value;
 
 public:
   typedef KeyValue Value;
 
-  class Observer
-  {
-  public:
-    virtual void insert(const char* key, Value& value) = 0;
-    virtual void erase(const char* key, Value& value) = 0;
-  };
-
   static StringPool& getPool()
   {
     return Static<StringPool, KeyContext>::instance();
   static StringPool& getPool()
   {
     return Static<StringPool, KeyContext>::instance();
@@ -553,6 +544,11 @@ public:
   }
   ~EntityKeyValues()
   {
   }
   ~EntityKeyValues()
   {
+    for(Observers::iterator i = m_observers.begin(); i != m_observers.end();)
+    {
+      // post-increment to allow current element to be removed safely
+      (*i++)->clear();
+    }
     ASSERT_MESSAGE(m_observers.empty(), "EntityKeyValues::~EntityKeyValues: observers still attached");
   }
 
     ASSERT_MESSAGE(m_observers.empty(), "EntityKeyValues::~EntityKeyValues: observers still attached");
   }
 
index 6152b9dcd8ea4dc32621f0b71151247736ba30aa..2344830aecfc2679f2fcd0ece86442e02dc81bb4 100644 (file)
@@ -107,3 +107,179 @@ namespace ExampleReferenceCaller
 }
 
 #endif
 }
 
 #endif
+
+namespace
+{
+  class A1
+  {
+  };
+  class A2
+  {
+  };
+  class A3
+  {
+  };
+  class A4
+  {
+  };
+
+  class Test
+  {
+  public:
+    void test0()
+    {
+    }
+    typedef Member<Test, void, &Test::test0> Test0;
+    typedef MemberCaller<Test, &Test::test0> Test0Caller;
+    void test0const() const
+    {
+    }
+    typedef ConstMember<Test, void, &Test::test0const> Test0Const;
+    typedef ConstMemberCaller<Test, &Test::test0const> Test0ConstCaller;
+    void test1(A1)
+    {
+    }
+    typedef Member1<Test, A1, void, &Test::test1> Test1;
+    typedef MemberCaller1<Test, A1, &Test::test1> Test1Caller;
+    void test1const(A1) const
+    {
+    }
+    typedef ConstMember1<Test, A1, void, &Test::test1const> Test1Const;
+    typedef ConstMemberCaller1<Test, A1, &Test::test1const> Test1ConstCaller;
+    void test2(A1, A2)
+    {
+    }
+    typedef Member2<Test, A1, A2, void, &Test::test2> Test2;
+    void test2const(A1, A2) const
+    {
+    }
+    typedef ConstMember2<Test, A1, A2, void, &Test::test2const> Test2Const;
+    void test3(A1, A2, A3)
+    {
+    }
+    typedef Member3<Test, A1, A2, A3, void, &Test::test3> Test3;
+    void test3const(A1, A2, A3) const
+    {
+    }
+    typedef ConstMember3<Test, A1, A2, A3, void, &Test::test3const> Test3Const;
+  };
+
+  void test0free()
+  {
+  }
+  typedef FreeCaller<&test0free> Test0FreeCaller;
+  void test1free(A1)
+  {
+  }
+  typedef FreeCaller1<A1, &test1free> Test1FreeCaller;
+  void test2free(A1, A2)
+  {
+  }
+  typedef Function2<A1, A2, void, &test2free> Test2Free;
+  void test3free(A1, A2, A3)
+  {
+  }
+  typedef Function3<A1, A2, A3, void, &test3free> Test3Free;
+
+
+  void test0(Test& test)
+  {
+  }
+  typedef ReferenceCaller<Test, &test0> Test0Caller;
+
+  void test0const(const Test& test)
+  {
+  }
+  typedef ConstReferenceCaller<Test, &test0const> Test0ConstCaller;
+
+  void test0p(Test* test)
+  {
+  }
+  typedef PointerCaller<Test, &test0p> Test0PCaller;
+
+  void test0constp(const Test* test)
+  {
+  }
+  typedef ConstPointerCaller<Test, &test0constp> Test0ConstPCaller;
+
+  void test1(Test& test, A1)
+  {
+  }
+  typedef ReferenceCaller1<Test, A1, &test1> Test1Caller;
+
+  void test1const(const Test& test, A1)
+  {
+  }
+  typedef ConstReferenceCaller1<Test, A1, &test1const> Test1ConstCaller;
+
+  void test1p(Test* test, A1)
+  {
+  }
+  typedef PointerCaller1<Test, A1, &test1p> Test1PCaller;
+
+  void test1constp(const Test* test, A1)
+  {
+  }
+  typedef ConstPointerCaller1<Test, A1, &test1constp> Test1ConstPCaller;
+
+  void test2(Test& test, A1, A2)
+  {
+  }
+  typedef Function3<Test&, A1, A2, void, &test2> Test2;
+
+  void test3(Test& test, A1, A2, A3)
+  {
+  }
+  typedef Function4<Test&, A1, A2, A3, void, &test3> Test3;
+
+  void instantiate()
+  {
+    Test test;
+    const Test& testconst = test;
+    {
+      Callback a = Test0FreeCaller();
+      Callback b = Test::Test0Caller(test);
+      b = makeCallback0(Test::Test0(), test);
+      Callback c = Test::Test0ConstCaller(testconst);
+      c = makeCallback0(Test::Test0Const(), test);
+      Callback d = Test0Caller(test);
+      Callback e = Test0ConstCaller(testconst);
+      Callback f = Test0PCaller(&test);
+      Callback g = Test0ConstPCaller(&testconst);
+      a();
+      bool u = a != b;
+    }
+    {
+      typedef Callback1<A1> TestCallback1;
+      TestCallback1 a = Test1FreeCaller();
+      TestCallback1 b = Test::Test1Caller(test);
+      b = makeCallback1(Test::Test1(), test);
+      TestCallback1 c = Test::Test1ConstCaller(testconst);
+      c = makeCallback1(Test::Test1Const(), test);
+      TestCallback1 d = Test1Caller(test);
+      TestCallback1 e = Test1ConstCaller(testconst);
+      TestCallback1 f = Test1PCaller(&test);
+      TestCallback1 g = Test1ConstPCaller(&testconst);
+      a(A1());
+      bool u = a != b;
+    }
+    {
+      typedef Callback2<A1, A2> TestCallback2;
+      TestCallback2 a = makeStatelessCallback2(Test2Free());
+      TestCallback2 b = makeCallback2(Test2(), test);
+      TestCallback2 c = makeCallback2(Test::Test2(), test);
+      TestCallback2 d = makeCallback2(Test::Test2Const(), test);
+      a(A1(), A2());
+      bool u = a != b;
+    }
+    {
+      typedef Callback3<A1, A2, A3> TestCallback3;
+      TestCallback3 a = makeStatelessCallback3(Test3Free());
+      TestCallback3 b = makeCallback3(Test3(), test);
+      TestCallback3 c = makeCallback3(Test::Test3(), test);
+      TestCallback3 d = makeCallback3(Test::Test3Const(), test);
+      a(A1(), A2(), A3());
+      bool u = a != b;
+    }
+  }
+}
index e5a8c8b4ad04403ea3d2e76c9d6eddd377eed91d..68fc0662c6d17c049ba540a3cebc219a7e5b4b04 100644 (file)
@@ -23,28 +23,206 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #define INCLUDED_GENERIC_CLOSURE_H
 
 /// \file
 #define INCLUDED_GENERIC_CLOSURE_H
 
 /// \file
-/// \brief Type-safe techniques for binding the first argument of an anonymous callback. 
+/// \brief Type-safe techniques for binding the first argument of an opaque callback. 
 
 #include <cstddef>
 
 #include <cstddef>
+#include "functional.h"
+#include "callbackfwd.h"
 
 
-/// \brief Combines a void pointer with a pointer to a function which operates on a void pointer.
-///
-/// Use with the callback constructors MemberCaller, ConstMemberCaller, ReferenceCaller, ConstReferenceCaller, PointerCaller, ConstPointerCaller and FreeCaller.
-class Callback
+template<typename Type>
+inline void* convertToOpaque(Type* t)
 {
 {
-  typedef void (*Thunk)(void*);
-  void* m_environment;
-  Thunk m_thunk;
+  return t;
+}
+template<typename Type>
+inline void* convertToOpaque(const Type* t)
+{
+  return const_cast<Type*>(t);
+}
+template<typename Type>
+inline void* convertToOpaque(Type& t)
+{
+  return &t;
+}
+template<typename Type>
+inline void* convertToOpaque(const Type& t)
+{
+  return const_cast<Type*>(&t);
+}
+
+
+template<typename Type>
+class ConvertFromOpaque
+{
+};
+
+template<typename Type>
+class ConvertFromOpaque<Type&>
+{
+public:
+  static Type& apply(void* p)
+  {
+    return *static_cast<Type*>(p);
+  }
+};
 
 
-  static void nullThunk(void*)
+template<typename Type>
+class ConvertFromOpaque<const Type&>
+{
+public:
+  static const Type& apply(void* p)
   {
   {
+    return *static_cast<Type*>(p);
   }
   }
+};
 
 
+
+template<typename Type>
+class ConvertFromOpaque<Type*>
+{
+public:
+  static Type* apply(void* p)
+  {
+    return static_cast<Type*>(p);
+  }
+};
+
+template<typename Type>
+class ConvertFromOpaque<const Type*>
+{
+public:
+  static const Type* apply(void* p)
+  {
+    return static_cast<Type*>(p);
+  }
+};
+
+template<typename Caller>
+class BindFirstOpaque
+{
+  typedef typename Caller::first_argument_type FirstBound;
+  FirstBound firstBound;
 public:
 public:
-  Callback() : m_environment(0), m_thunk(nullThunk)
+  typedef typename Caller::result_type result_type;
+  explicit BindFirstOpaque(FirstBound firstBound) : firstBound(firstBound)
   {
   }
   {
   }
-  Callback(void* environment, Thunk function) : m_environment(environment), m_thunk(function)
+  result_type operator()() const
+  {
+    return Caller::call(firstBound);
+  }
+  FirstBound getBound() const
+  {
+    return firstBound;
+  }
+  static result_type thunk(void* environment)
+  {
+    return Caller::call(ConvertFromOpaque<FirstBound>::apply(environment));
+  }
+  void* getEnvironment() const
+  {
+    return convertToOpaque(firstBound);
+  }
+};
+
+template<typename Caller>
+class BindFirstOpaque1
+{
+  typedef typename Caller::first_argument_type FirstBound;
+  FirstBound firstBound;
+public:
+  typedef typename Caller::second_argument_type first_argument_type;
+  typedef typename Caller::result_type result_type;
+  explicit BindFirstOpaque1(FirstBound firstBound) : firstBound(firstBound)
+  {
+  }
+  result_type operator()(first_argument_type a1) const
+  {
+    return Caller::call(firstBound, a1);
+  }
+  FirstBound getBound() const
+  {
+    return firstBound;
+  }
+  static result_type thunk(void* environment, first_argument_type a1)
+  {
+    return Caller::call(ConvertFromOpaque<FirstBound>::apply(environment), a1);
+  }
+  void* getEnvironment() const
+  {
+    return convertToOpaque(firstBound);
+  }
+};
+
+template<typename Caller>
+class BindFirstOpaque2
+{
+  typedef typename Caller::first_argument_type FirstBound;
+  FirstBound firstBound;
+public:
+  typedef typename Caller::second_argument_type first_argument_type;
+  typedef typename Caller::third_argument_type second_argument_type;
+  typedef typename Caller::result_type result_type;
+  explicit BindFirstOpaque2(FirstBound firstBound) : firstBound(firstBound)
+  {
+  }
+  result_type operator()(first_argument_type a1, second_argument_type a2) const
+  {
+    return Caller::call(firstBound, a1, a2);
+  }
+  FirstBound getBound() const
+  {
+    return firstBound;
+  }
+  static result_type thunk(void* environment, first_argument_type a1, second_argument_type a2)
+  {
+    return Caller::call(ConvertFromOpaque<FirstBound>::apply(environment), a1, a2);
+  }
+  void* getEnvironment() const
+  {
+    return convertToOpaque(firstBound);
+  }
+};
+
+template<typename Caller>
+class BindFirstOpaque3
+{
+  typedef typename Caller::first_argument_type FirstBound;
+  FirstBound firstBound;
+public:
+  typedef typename Caller::second_argument_type first_argument_type;
+  typedef typename Caller::third_argument_type second_argument_type;
+  typedef typename Caller::fourth_argument_type third_argument_type;
+  typedef typename Caller::result_type result_type;
+  explicit BindFirstOpaque3(FirstBound firstBound) : firstBound(firstBound)
+  {
+  }
+  result_type operator()(first_argument_type a1, second_argument_type a2, third_argument_type a3) const
+  {
+    return Caller::call(firstBound, a1, a2, a3);
+  }
+  FirstBound getBound() const
+  {
+    return firstBound;
+  }
+  static result_type thunk(void* environment, first_argument_type a1, second_argument_type a2, third_argument_type a3)
+  {
+    return Caller::call(ConvertFromOpaque<FirstBound>::apply(environment), a1, a2, a3);
+  }
+  void* getEnvironment() const
+  {
+    return convertToOpaque(firstBound);
+  }
+};
+
+template<typename typename Thunk_>
+class CallbackBase
+{
+  void* m_environment;
+  Thunk_ m_thunk;
+public:
+  typedef Thunk_ Thunk;
+  CallbackBase(void* environment, Thunk function) : m_environment(environment), m_thunk(function)
   {
   }
   void* getEnvironment() const
   {
   }
   void* getEnvironment() const
@@ -55,113 +233,226 @@ public:
   {
     return m_thunk;
   }
   {
     return m_thunk;
   }
-  void operator()() const
-  {
-    m_thunk(m_environment);
-  }
 };
 
 };
 
-inline bool operator==(const Callback& self, const Callback& other)
+template<typename typename Thunk>
+inline bool operator==(const CallbackBase<Thunk>& self, const CallbackBase<Thunk>& other)
 {
   return self.getEnvironment() == other.getEnvironment() && self.getThunk() == other.getThunk();
 }
 {
   return self.getEnvironment() == other.getEnvironment() && self.getThunk() == other.getThunk();
 }
-inline bool operator<(const Callback& self, const Callback& other)
+template<typename typename Thunk>
+inline bool operator!=(const CallbackBase<Thunk>& self, const CallbackBase<Thunk>& other)
+{
+  return !(self == other);
+}
+template<typename typename Thunk>
+inline bool operator<(const CallbackBase<Thunk>& self, const CallbackBase<Thunk>& other)
 {
   return self.getEnvironment() < other.getEnvironment() || 
         (!(other.getEnvironment() < self.getEnvironment()) && self.getThunk() < other.getThunk()); 
 }
 
 {
   return self.getEnvironment() < other.getEnvironment() || 
         (!(other.getEnvironment() < self.getEnvironment()) && self.getThunk() < other.getThunk()); 
 }
 
-/// \brief Combines a void pointer with a pointer to a function which operates on a void pointer and one other argument. 
+
+/// \brief Combines a void pointer with a pointer to a function which operates on a void pointer.
 ///
 ///
-/// Use with the callback constructors MemberCaller1, ConstMemberCaller1, ReferenceCaller1, ConstReferenceCaller1, PointerCaller1, ConstPointerCaller1 and FreeCaller1.
-template<typename FirstArgument>
-class Callback1
+/// Use with the callback constructors MemberCaller, ConstMemberCaller, ReferenceCaller, ConstReferenceCaller, PointerCaller, ConstPointerCaller and FreeCaller.
+template<typename Result>
+class Callback0 : public CallbackBase<Result (*)(void*)>
 {
 {
-  typedef void (*Thunk)(void*, FirstArgument);
-  void* m_environment;
-  Thunk m_thunk;
-
-  static void nullThunk(void*, FirstArgument)
+  typedef CallbackBase<Result (*)(void*)> Base;
+  static Result nullThunk(void*)
   {
   }
 
 public:
   {
   }
 
 public:
-  typedef FirstArgument first_argument_type;
+  typedef Result result_type;
 
 
-  Callback1() : m_environment(0), m_thunk(nullThunk)
-  {
-  }
-  Callback1(void* environment, Thunk function) : m_environment(environment), m_thunk(function)
+  Callback0() : Base(0, nullThunk)
   {
   }
   {
   }
-  void* getEnvironment() const
+  template<typename Caller>
+  Callback0(const BindFirstOpaque<Caller>& caller) : Base(caller.getEnvironment(), BindFirstOpaque<Caller>::thunk)
   {
   {
-    return m_environment;
   }
   }
-  Thunk getThunk() const
+  Callback0(void* environment, Thunk function) : Base(environment, function)
   {
   {
-    return m_thunk;
   }
   }
-  void operator()(FirstArgument firstArgument) const
+  result_type operator()() const
   {
   {
-    m_thunk(m_environment, firstArgument);
+    return getThunk()(getEnvironment());
   }
 };
 
   }
 };
 
-template<typename FirstArgument>
-inline bool operator==(const Callback1<FirstArgument>& self, const Callback1<FirstArgument>& other)
+template<typename Caller>
+inline Callback0<typename Caller::result_type> makeCallback0(const Caller& caller, typename Caller::first_argument_type callee)
 {
 {
-  return self.getEnvironment() == other.getEnvironment() && self.getThunk() == other.getThunk();
+  return Callback0<typename Caller::result_type>(BindFirstOpaque<Caller>(callee));
 }
 }
-template<typename FirstArgument>
-inline bool operator<(const Callback1<FirstArgument>& self, const Callback1<FirstArgument>& other)
+template<typename Caller>
+inline Callback0<typename Caller::result_type> makeStatelessCallback0(const Caller& caller)
 {
 {
-  return self.getEnvironment() < other.getEnvironment() || 
-        (!(other.getEnvironment() < self.getEnvironment()) && self.getThunk() < other.getThunk()); 
+  return makeCallback0(Caller0To1<Caller>(), 0);
 }
 
 }
 
-template<typename Functor>
-class FunctorInvoke
+typedef Callback0<void> Callback;
+
+
+
+/// \brief Combines a void pointer with a pointer to a function which operates on a void pointer and one other argument. 
+///
+/// Use with the callback constructors MemberCaller1, ConstMemberCaller1, ReferenceCaller1, ConstReferenceCaller1, PointerCaller1, ConstPointerCaller1 and FreeCaller1.
+template<typename FirstArgument, typename Result>
+class Callback1 : public CallbackBase<Result (*)(void*, FirstArgument)>
 {
 {
+  typedef CallbackBase<Result (*)(void*, FirstArgument)> Base;
+  static Result nullThunk(void*, FirstArgument)
+  {
+  }
+
 public:
 public:
-  inline void operator()(Functor functor)
+  typedef FirstArgument first_argument_type;
+  typedef Result result_type;
+
+  Callback1() : Base(0, nullThunk)
   {
   {
-    functor();
+  }
+  template<typename Caller>
+  Callback1(const BindFirstOpaque1<Caller>& caller) : Base(caller.getEnvironment(), BindFirstOpaque1<Caller>::thunk)
+  {
+  }
+  Callback1(void* environment, Thunk function) : Base(environment, function)
+  {
+  }
+  result_type operator()(FirstArgument firstArgument) const
+  {
+    return getThunk()(getEnvironment(), firstArgument);
   }
 };
 
   }
 };
 
-typedef FunctorInvoke<Callback> CallbackInvoke;
+template<typename Caller>
+inline Callback1<typename Caller::second_argument_type, typename Caller::result_type> makeCallback1(const Caller& caller, typename Caller::first_argument_type callee)
+{
+  return Callback1<typename Caller::second_argument_type, typename Caller::result_type>(BindFirstOpaque1<Caller>(callee));
+}
+template<typename Caller>
+inline Callback1<typename Caller::second_argument_type, typename Caller::result_type> makeStatelessCallback1(const Caller& caller)
+{
+  return makeCallback1(Caller1To2<Caller>(), 0);
+}
 
 
 
 
-template<typename Functor, typename FirstArgument>
-class Functor1Invoke
+/// \brief Combines a void pointer with a pointer to a function which operates on a void pointer and two other arguments. 
+///
+template<typename FirstArgument, typename SecondArgument, typename Result>
+class Callback2 : public CallbackBase<Result (*)(void*, FirstArgument, SecondArgument)>
 {
 {
-  FirstArgument m_firstArgument;
+  typedef CallbackBase<Result (*)(void*, FirstArgument, SecondArgument)> Base;
+  static Result nullThunk(void*, FirstArgument, SecondArgument)
+  {
+  }
+
 public:
 public:
-  Functor1Invoke(FirstArgument firstArgument) : m_firstArgument(firstArgument)
+  typedef FirstArgument first_argument_type;
+  typedef SecondArgument second_argument_type;
+  typedef Result result_type;
+
+  Callback2() : Base(0, nullThunk)
+  {
+  }
+  template<typename Caller>
+  Callback2(const BindFirstOpaque2<Caller>& caller) : Base(caller.getEnvironment(), BindFirstOpaque2<Caller>::thunk)
   {
   }
   {
   }
-  inline void operator()(Functor functor)
+  Callback2(void* environment, Thunk function) : Base(environment, function)
   {
   {
-    functor(m_firstArgument);
+  }
+  result_type operator()(FirstArgument firstArgument, SecondArgument secondArgument) const
+  {
+    return getThunk()(getEnvironment(), firstArgument, secondArgument);
   }
 };
 
   }
 };
 
+template<typename Caller>
+inline Callback2<
+  typename Caller::second_argument_type,
+  typename Caller::third_argument_type,
+  typename Caller::result_type
+> makeCallback2(const Caller& caller, typename Caller::first_argument_type callee)
+{
+  return Callback2<
+    typename Caller::second_argument_type,
+    typename Caller::third_argument_type,
+    typename Caller::result_type
+  >(BindFirstOpaque2<Caller>(callee));
+}
+template<typename Caller>
+inline Callback2<
+  typename Caller::first_argument_type,
+  typename Caller::second_argument_type,
+  typename Caller::result_type
+> makeStatelessCallback2(const Caller& caller)
+{
+  return makeCallback2(Caller2To3<Caller>(), 0);
+}
 
 
-typedef Callback1<bool> BoolImportCallback;
-typedef Callback1<const BoolImportCallback&> BoolExportCallback;
 
 
-typedef Callback1<int> IntImportCallback;
-typedef Callback1<const IntImportCallback&> IntExportCallback;
+/// \brief Combines a void pointer with a pointer to a function which operates on a void pointer and three other arguments. 
+///
+template<typename FirstArgument, typename SecondArgument, typename ThirdArgument, typename Result>
+class Callback3 : public CallbackBase<Result (*)(void*, FirstArgument, SecondArgument, ThirdArgument)>
+{
+  typedef CallbackBase<Result (*)(void*, FirstArgument, SecondArgument, ThirdArgument)> Base;
+  static Result nullThunk(void*, FirstArgument, SecondArgument, ThirdArgument)
+  {
+  }
 
 
-typedef Callback1<float> FloatImportCallback;
-typedef Callback1<const FloatImportCallback&> FloatExportCallback;
+public:
+  typedef FirstArgument first_argument_type;
+  typedef SecondArgument second_argument_type;
+  typedef ThirdArgument third_argument_type;
+  typedef Result result_type;
 
 
-typedef Callback1<const char*> StringImportCallback;
-typedef Callback1<const StringImportCallback&> StringExportCallback;
+  Callback3() : Base(0, nullThunk)
+  {
+  }
+  template<typename Caller>
+  Callback3(const BindFirstOpaque3<Caller>& caller) : Base(caller.getEnvironment(), BindFirstOpaque3<Caller>::thunk)
+  {
+  }
+  Callback3(void* environment, Thunk function) : Base(environment, function)
+  {
+  }
+  result_type operator()(FirstArgument firstArgument, SecondArgument secondArgument, ThirdArgument thirdArgument) const
+  {
+    return getThunk()(getEnvironment(), firstArgument, secondArgument, thirdArgument);
+  }
+};
 
 
-typedef Callback1<std::size_t> SizeImportCallback;
-typedef Callback1<const SizeImportCallback&> SizeExportCallback;
+template<typename Caller>
+inline Callback3<
+  typename Caller::second_argument_type,
+  typename Caller::third_argument_type,
+  typename Caller::fourth_argument_type,
+  typename Caller::result_type
+> makeCallback3(const Caller& caller, typename Caller::first_argument_type callee)
+{
+  return Callback3<
+    typename Caller::second_argument_type,
+    typename Caller::third_argument_type,
+    typename Caller::fourth_argument_type,
+    typename Caller::result_type
+  >(BindFirstOpaque3<Caller>(callee));
+}
+template<typename Caller>
+inline Callback3<
+  typename Caller::first_argument_type,
+  typename Caller::second_argument_type,
+  typename Caller::third_argument_type,
+  typename Caller::result_type
+> makeStatelessCallback3(const Caller& caller)
+{
+  return makeCallback3(Caller3To4<Caller>(), 0);
+}
 
 
 /// \brief Forms a Callback from a non-const Environment reference and a non-const Environment member-function.
 
 
 /// \brief Forms a Callback from a non-const Environment reference and a non-const Environment member-function.
@@ -170,24 +461,11 @@ typedef Callback1<const SizeImportCallback&> SizeExportCallback;
 /// \skipline MemberCaller example
 /// \until end example
 template<typename Environment, void (Environment::*member)()>
 /// \skipline MemberCaller example
 /// \until end example
 template<typename Environment, void (Environment::*member)()>
-class MemberCaller
+class MemberCaller : public BindFirstOpaque< Member<Environment, void, member> >
 {
 {
-  Environment& m_environment;
 public:
 public:
-  MemberCaller(Environment& environment) : m_environment(environment)
-  {
-  }
-  void* getEnvironment() const
+  MemberCaller(Environment& environment) : BindFirstOpaque< Member<Environment, void, member> >(environment)
   {
   {
-    return &m_environment;
-  }
-  static void thunk(void* environment)
-  {
-    ((*reinterpret_cast<Environment*>(environment)).*member)();
-  }
-  operator Callback() const
-  {
-    return Callback(getEnvironment(), thunk);
   }
 };
 
   }
 };
 
@@ -197,71 +475,32 @@ public:
 /// \skipline MemberCaller example
 /// \until end example
 template<typename Environment, void (Environment::*member)() const>
 /// \skipline MemberCaller example
 /// \until end example
 template<typename Environment, void (Environment::*member)() const>
-class ConstMemberCaller
+class ConstMemberCaller : public BindFirstOpaque< ConstMember<Environment, void, member> >
 {
 {
-  const Environment& m_environment;
 public:
 public:
-  ConstMemberCaller(const Environment& environment) : m_environment(environment)
-  {
-  }
-  void* getEnvironment() const
+  ConstMemberCaller(const Environment& environment) : BindFirstOpaque< ConstMember<Environment, void, member> >(environment)
   {
   {
-    return const_cast<Environment*>(&m_environment);
-  }
-  static void thunk(void* environment)
-  {
-    ((*reinterpret_cast<const Environment*>(environment)).*member)();
-  }
-  operator Callback() const
-  {
-    return Callback(getEnvironment(), thunk);
   }
 };
 
 /// \brief Forms a Callback from a non-const Environment reference and a const Environment member-function which takes one argument.
 template<typename Environment, typename FirstArgument, void (Environment::*member)(FirstArgument)>
   }
 };
 
 /// \brief Forms a Callback from a non-const Environment reference and a const Environment member-function which takes one argument.
 template<typename Environment, typename FirstArgument, void (Environment::*member)(FirstArgument)>
-class MemberCaller1
+class MemberCaller1 : public BindFirstOpaque1< Member1<Environment, FirstArgument, void, member> >
 {
 {
-  Environment& m_environment;
 public:
 public:
-  MemberCaller1(Environment& environment) : m_environment(environment)
+  MemberCaller1(Environment& environment) : BindFirstOpaque1< Member1<Environment, FirstArgument, void, member> >(environment)
   {
   }
   {
   }
-  void* getEnvironment() const
-  {
-    return &m_environment;
-  }
-  static void thunk(void* environment, FirstArgument firstArgument)
-  {
-    ((*reinterpret_cast<Environment*>(environment)).*member)(firstArgument);
-  }
-  operator Callback1<FirstArgument>() const
-  {
-    return Callback1<FirstArgument>(getEnvironment(), thunk);
-  }
 };
 
 /// \brief Forms a Callback from a const Environment reference and a const Environment member-function which takes one argument.
 template<typename Environment, typename FirstArgument, void (Environment::*member)(FirstArgument) const>
 };
 
 /// \brief Forms a Callback from a const Environment reference and a const Environment member-function which takes one argument.
 template<typename Environment, typename FirstArgument, void (Environment::*member)(FirstArgument) const>
-class ConstMemberCaller1
+class ConstMemberCaller1 : public BindFirstOpaque1< ConstMember1<Environment, FirstArgument, void, member> >
 {
 {
-  const Environment& m_environment;
 public:
 public:
-  ConstMemberCaller1(const Environment& environment) : m_environment(environment)
+  ConstMemberCaller1(const Environment& environment) : BindFirstOpaque1< ConstMember1<Environment, FirstArgument, void, member> >(environment)
   {
   }
   {
   }
-  void* getEnvironment() const
-  {
-    return const_cast<Environment*>(&m_environment);
-  }
-  static void thunk(void* environment, FirstArgument firstArgument)
-  {
-    ((*reinterpret_cast<Environment*>(environment)).*member)(firstArgument);
-  }
-  operator Callback1<FirstArgument>() const
-  {
-    return Callback1<FirstArgument>(getEnvironment(), thunk);
-  }
 };
 
 /// \brief Forms a Callback from a non-const Environment reference and a free function which operates on a non-const Environment reference.
 };
 
 /// \brief Forms a Callback from a non-const Environment reference and a free function which operates on a non-const Environment reference.
@@ -270,24 +509,11 @@ public:
 /// \skipline ReferenceCaller example
 /// \until end example
 template<typename Environment, void (*func)(Environment&)> 
 /// \skipline ReferenceCaller example
 /// \until end example
 template<typename Environment, void (*func)(Environment&)> 
-class ReferenceCaller
+class ReferenceCaller : public BindFirstOpaque< Function1<Environment&, void, func> >
 {
 {
-  Environment& m_environment;
 public:
 public:
-  ReferenceCaller(Environment& environment) : m_environment(environment)
-  {
-  }
-  void* getEnvironment() const
+  ReferenceCaller(Environment& environment) : BindFirstOpaque< Function1<Environment&, void, func> >(environment)
   {
   {
-    return &m_environment;
-  }
-  static void thunk(void* environment)
-  {
-    (func)(*reinterpret_cast<Environment*>(environment));
-  }
-  operator Callback() const
-  {
-    return Callback(getEnvironment(), thunk);
   }
 };
 
   }
 };
 
@@ -297,201 +523,91 @@ public:
 /// \skipline ReferenceCaller example
 /// \until end example
 template<typename Environment, void (*func)(const Environment&)> 
 /// \skipline ReferenceCaller example
 /// \until end example
 template<typename Environment, void (*func)(const Environment&)> 
-class ConstReferenceCaller
+class ConstReferenceCaller : public BindFirstOpaque< Function1<const Environment&, void, func> >
 {
 {
-  const Environment& m_environment;
 public:
 public:
-  ConstReferenceCaller(const Environment& environment) : m_environment(environment)
-  {
-  }
-  void* getEnvironment() const
-  {
-    return const_cast<Environment*>(&m_environment);
-  }
-  static void thunk(void* environment)
+  ConstReferenceCaller(const Environment& environment) : BindFirstOpaque< Function1<const Environment&, void, func> >(environment)
   {
   {
-    (func)(*reinterpret_cast<const Environment*>(environment));
-  }
-  operator Callback() const
-  {
-    return Callback(getEnvironment(), thunk);
   }
 };
 
 /// \brief Forms a Callback from a non-const Environment reference and a free function which operates on a non-const Environment reference and one other argument.
 template<typename Environment, typename FirstArgument, void (*func)(Environment&, FirstArgument)> 
   }
 };
 
 /// \brief Forms a Callback from a non-const Environment reference and a free function which operates on a non-const Environment reference and one other argument.
 template<typename Environment, typename FirstArgument, void (*func)(Environment&, FirstArgument)> 
-class ReferenceCaller1
+class ReferenceCaller1 : public BindFirstOpaque1< Function2<Environment&, FirstArgument, void, func> >
 {
 {
-  Environment& m_environment;
 public:
 public:
-  ReferenceCaller1(Environment& environment) : m_environment(environment)
-  {
-  }
-  void* getEnvironment() const
+  ReferenceCaller1(Environment& environment) : BindFirstOpaque1< Function2<Environment&, FirstArgument, void, func> >(environment)
   {
   {
-    return &m_environment;
-  }
-  static void thunk(void* environment, FirstArgument firstArgument)
-  {
-    (func)(*reinterpret_cast<Environment*>(environment), firstArgument);
-  }
-  operator Callback1<FirstArgument>() const
-  {
-    return Callback1<FirstArgument>(getEnvironment(), thunk);
   }
 };
 
 /// \brief Forms a Callback from a const Environment reference and a free function which operates on a const Environment reference and one other argument.
 template<typename Environment, typename FirstArgument, void (*func)(const Environment&, FirstArgument)> 
   }
 };
 
 /// \brief Forms a Callback from a const Environment reference and a free function which operates on a const Environment reference and one other argument.
 template<typename Environment, typename FirstArgument, void (*func)(const Environment&, FirstArgument)> 
-class ConstReferenceCaller1
+class ConstReferenceCaller1 : public BindFirstOpaque1< Function2<const Environment&, FirstArgument, void, func> >
 {
 {
-  const Environment& m_environment;
 public:
 public:
-  ConstReferenceCaller1(const Environment& environment) : m_environment(environment)
+  ConstReferenceCaller1(const Environment& environment) : BindFirstOpaque1< Function2<const Environment&, FirstArgument, void, func> >(environment)
   {
   }
   {
   }
-  void* getEnvironment() const
-  {
-    return const_cast<Environment*>(&m_environment);
-  }
-  static void thunk(void* environment, FirstArgument firstArgument)
-  {
-    (func)(*reinterpret_cast<const Environment*>(environment), firstArgument);
-  }
-  operator Callback1<FirstArgument>() const
-  {
-    return Callback1<FirstArgument>(getEnvironment(), thunk);
-  }
 };
 
 /// \brief Forms a Callback from a non-const Environment pointer and a free function which operates on a non-const Environment pointer.
 template<typename Environment, void (*func)(Environment*)> 
 };
 
 /// \brief Forms a Callback from a non-const Environment pointer and a free function which operates on a non-const Environment pointer.
 template<typename Environment, void (*func)(Environment*)> 
-class PointerCaller
+class PointerCaller : public BindFirstOpaque< Function1<Environment*, void, func> >
 {
 {
-  Environment* m_environment;
 public:
 public:
-  PointerCaller(Environment* environment) : m_environment(environment)
+  PointerCaller(Environment* environment) : BindFirstOpaque< Function1<Environment*, void, func> >(environment)
   {
   }
   {
   }
-  void* getEnvironment() const
-  {
-    return m_environment;
-  }
-  static void thunk(void* environment)
-  {
-    (func)(reinterpret_cast<Environment*>(environment));
-  }
-  operator Callback() const
-  {
-    return Callback(getEnvironment(), thunk);
-  }
 };
 
 /// \brief Forms a Callback from a const Environment pointer and a free function which operates on a const Environment pointer.
 template<typename Environment, void (*func)(const Environment*)> 
 };
 
 /// \brief Forms a Callback from a const Environment pointer and a free function which operates on a const Environment pointer.
 template<typename Environment, void (*func)(const Environment*)> 
-class ConstPointerCaller
+class ConstPointerCaller : public BindFirstOpaque< Function1<const Environment*, void, func> >
 {
 {
-  const Environment* m_environment;
 public:
 public:
-  ConstPointerCaller(const Environment* environment) : m_environment(environment)
-  {
-  }
-  void* getEnvironment() const
-  {
-    return const_cast<Environment*>(m_environment);
-  }
-  static void thunk(void* environment)
-  {
-    (func)(reinterpret_cast<const Environment*>(environment));
-  }
-  operator Callback() const
+  ConstPointerCaller(const Environment* environment) : BindFirstOpaque< Function1<const Environment*, void, func> >(environment)
   {
   {
-    return Callback(getEnvironment(), thunk);
   }
 };
 
 /// \brief Forms a Callback from a non-const Environment pointer and a free function which operates on a non-const Environment pointer and one other argument.
 template<typename Environment, typename FirstArgument, void (*func)(Environment*, FirstArgument)> 
   }
 };
 
 /// \brief Forms a Callback from a non-const Environment pointer and a free function which operates on a non-const Environment pointer and one other argument.
 template<typename Environment, typename FirstArgument, void (*func)(Environment*, FirstArgument)> 
-class PointerCaller1
+class PointerCaller1 : public BindFirstOpaque1< Function2<Environment*, FirstArgument, void, func> >
 {
 {
-  Environment* m_environment;
 public:
 public:
-  PointerCaller1(Environment* environment) : m_environment(environment)
-  {
-  }
-  void* getEnvironment() const
-  {
-    return m_environment;
-  }
-  static void thunk(void* environment, FirstArgument firstArgument)
+  PointerCaller1(Environment* environment) : BindFirstOpaque1< Function2<Environment*, FirstArgument, void, func> >(environment)
   {
   {
-    (func)(reinterpret_cast<Environment*>(environment), firstArgument);
-  }
-  operator Callback1<FirstArgument>() const
-  {
-    return Callback1<FirstArgument>(getEnvironment(), thunk);
   }
 };
 
 /// \brief Forms a Callback from a const Environment pointer and a free function which operates on a const Environment pointer and one other argument.
 template<typename Environment, typename FirstArgument, void (*func)(const Environment*, FirstArgument)> 
   }
 };
 
 /// \brief Forms a Callback from a const Environment pointer and a free function which operates on a const Environment pointer and one other argument.
 template<typename Environment, typename FirstArgument, void (*func)(const Environment*, FirstArgument)> 
-class ConstPointerCaller1
+class ConstPointerCaller1 : public BindFirstOpaque1< Function2<const Environment*, FirstArgument, void, func> >
 {
 {
-  const Environment* m_environment;
 public:
 public:
-  ConstPointerCaller1(const Environment* environment) : m_environment(environment)
-  {
-  }
-  void* getEnvironment() const
+  ConstPointerCaller1(const Environment* environment) : BindFirstOpaque1< Function2<const Environment*, FirstArgument, void, func> >(environment)
   {
   {
-    return const_cast<Environment*>(m_environment);
-  }
-  static void thunk(void* environment, FirstArgument firstArgument)
-  {
-    (func)(reinterpret_cast<const Environment*>(environment), firstArgument);
-  }
-  operator Callback1<FirstArgument>() const
-  {
-    return Callback1<FirstArgument>(getEnvironment(), thunk);
   }
 };
 
   }
 };
 
-
 /// \brief Forms a Callback from a free function which takes no arguments.
 template<void (*func)()> 
 /// \brief Forms a Callback from a free function which takes no arguments.
 template<void (*func)()> 
-class FreeCaller
+class FreeCaller : public BindFirstOpaque< Caller0To1< Function0<void, func> > >
 {
 public:
 {
 public:
-  void* getEnvironment() const
-  {
-    return 0;
-  }
-  static void thunk(void*)
-  {
-    (func)();
-  }
-  operator Callback() const
+  FreeCaller() : BindFirstOpaque< Caller0To1< Function0<void, func> > >(0)
   {
   {
-    return Callback(getEnvironment(), thunk);
   }
 };
 
 /// \brief Forms a Callback from a free function which takes a single argument.
 template<typename FirstArgument, void (*func)(FirstArgument)> 
   }
 };
 
 /// \brief Forms a Callback from a free function which takes a single argument.
 template<typename FirstArgument, void (*func)(FirstArgument)> 
-class FreeCaller1
+class FreeCaller1 : public BindFirstOpaque1< Caller1To2< Function1<FirstArgument, void, func> > >
 {
 public:
 {
 public:
-  void* getEnvironment() const
-  {
-    return 0;
-  }
-  static void thunk(void*, FirstArgument firstArgument)
+  FreeCaller1() : BindFirstOpaque1< Caller1To2< Function1<FirstArgument, void, func> > >(0)
   {
   {
-    (func)(firstArgument);
-  }
-  operator Callback1<FirstArgument>() const
-  {
-    return Callback1<FirstArgument>(getEnvironment(), thunk);
   }
 };
 
   }
 };
 
@@ -534,4 +650,21 @@ inline Callback1<typename Functor::first_argument_type> makeCallback1(const Func
   return Callback1<FirstArgument>(ConstMemberCaller1<Functor, FirstArgument, &Functor::operator()>(functor));
 }
 
   return Callback1<FirstArgument>(ConstMemberCaller1<Functor, FirstArgument, &Functor::operator()>(functor));
 }
 
+
+typedef Callback1<bool> BoolImportCallback;
+typedef Callback1<const BoolImportCallback&> BoolExportCallback;
+
+typedef Callback1<int> IntImportCallback;
+typedef Callback1<const IntImportCallback&> IntExportCallback;
+
+typedef Callback1<float> FloatImportCallback;
+typedef Callback1<const FloatImportCallback&> FloatExportCallback;
+
+typedef Callback1<const char*> StringImportCallback;
+typedef Callback1<const StringImportCallback&> StringExportCallback;
+
+typedef Callback1<std::size_t> SizeImportCallback;
+typedef Callback1<const SizeImportCallback&> SizeExportCallback;
+
+
 #endif
 #endif
diff --git a/libs/generic/callbackfwd.cpp b/libs/generic/callbackfwd.cpp
new file mode 100644 (file)
index 0000000..a2faa66
--- /dev/null
@@ -0,0 +1,3 @@
+
+#include "callbackfwd.h"
+
diff --git a/libs/generic/callbackfwd.h b/libs/generic/callbackfwd.h
new file mode 100644 (file)
index 0000000..f89f909
--- /dev/null
@@ -0,0 +1,18 @@
+
+#if !defined(INCLUDED_CALLBACKFWD_H)
+#define INCLUDED_CALLBACKFWD_H
+
+template<typename Return>
+class Callback0;
+typedef Callback0<void> Callback;
+
+template<typename FirstArgument, typename Result = void>
+class Callback1;
+
+template<typename FirstArgument, typename SecondArgument, typename Result = void>
+class Callback2;
+
+template<typename FirstArgument, typename SecondArgument, typename ThirdArgument, typename Result = void>
+class Callback3;
+
+#endif
diff --git a/libs/generic/functional.cpp b/libs/generic/functional.cpp
new file mode 100644 (file)
index 0000000..4717c8e
--- /dev/null
@@ -0,0 +1,3 @@
+
+#include "functional.h"
+
diff --git a/libs/generic/functional.h b/libs/generic/functional.h
new file mode 100644 (file)
index 0000000..ca1d863
--- /dev/null
@@ -0,0 +1,319 @@
+
+#if !defined(INCLUDED_FUNCTIONAL_H)
+#define INCLUDED_FUNCTIONAL_H
+
+template<typename Object, typename R, R (Object::*member)()>
+class Member
+{
+public:
+  typedef Object& first_argument_type;
+  typedef R result_type;
+  static result_type call(first_argument_type object)
+  {
+    return (object.*member)();
+  }
+};
+
+template<typename Object, typename R, R (Object::*member)() const>
+class ConstMember
+{
+public:
+  typedef const Object& first_argument_type;
+  typedef R result_type;
+  static result_type call(first_argument_type object)
+  {
+    return (object.*member)();
+  }
+};
+
+template<typename Object, typename A1, typename R, R (Object::*member)(A1)>
+class Member1
+{
+public:
+  typedef Object& first_argument_type;
+  typedef A1 second_argument_type;
+  typedef R result_type;
+  static result_type call(first_argument_type object, second_argument_type a1)
+  {
+    return (object.*member)(a1);
+  }
+};
+
+template<typename Object, typename A1, typename R, R (Object::*member)(A1) const>
+class ConstMember1
+{
+public:
+  typedef const Object& first_argument_type;
+  typedef A1 second_argument_type;
+  typedef R result_type;
+  static result_type call(first_argument_type object, second_argument_type a1)
+  {
+    return (object.*member)(a1);
+  }
+};
+
+template<typename Object, typename A2, typename A3, typename R, R (Object::*member)(A2, A3)>
+class Member2
+{
+public:
+  typedef Object& first_argument_type;
+  typedef A2 second_argument_type;
+  typedef A3 third_argument_type;
+  typedef R result_type;
+  static result_type call(first_argument_type object, second_argument_type a2, third_argument_type a3)
+  {
+    return (object.*member)(a2, a3);
+  }
+};
+
+template<typename Object, typename A2, typename A3, typename R, R (Object::*member)(A2, A3) const>
+class ConstMember2
+{
+public:
+  typedef const Object& first_argument_type;
+  typedef A2 second_argument_type;
+  typedef A3 third_argument_type;
+  typedef R result_type;
+  static result_type call(first_argument_type object, second_argument_type a2, third_argument_type a3)
+  {
+    return (object.*member)(a2, a3);
+  }
+};
+
+template<typename Object, typename A2, typename A3, typename A4, typename R, R (Object::*member)(A2, A3, A4)>
+class Member3
+{
+public:
+  typedef Object& first_argument_type;
+  typedef A2 second_argument_type;
+  typedef A3 third_argument_type;
+  typedef A4 fourth_argument_type;
+  typedef R result_type;
+  static result_type call(first_argument_type object, second_argument_type a2, third_argument_type a3, fourth_argument_type a4)
+  {
+    return (object.*member)(a2, a3, a4);
+  }
+};
+
+template<typename Object, typename A2, typename A3, typename A4, typename R, R (Object::*member)(A2, A3, A4) const>
+class ConstMember3
+{
+public:
+  typedef const Object& first_argument_type;
+  typedef A2 second_argument_type;
+  typedef A3 third_argument_type;
+  typedef A4 fourth_argument_type;
+  typedef R result_type;
+  static result_type call(first_argument_type object, second_argument_type a2, third_argument_type a3, fourth_argument_type a4)
+  {
+    return (object.*member)(a2, a3, a4);
+  }
+};
+
+template<typename R, R (*func)()> 
+class Function0
+{
+public:
+  typedef R result_type;
+  static result_type call()
+  {
+    return (func)();
+  }
+};
+
+template<typename A1, typename R, R (*func)(A1)> 
+class Function1
+{
+public:
+  typedef A1 first_argument_type;
+  typedef R result_type;
+  static result_type call(first_argument_type a1)
+  {
+    return (func)(a1);
+  }
+};
+
+template<typename A1, typename A2, typename R, R (*func)(A1, A2)> 
+class Function2
+{
+public:
+  typedef A1 first_argument_type;
+  typedef A2 second_argument_type;
+  typedef R result_type;
+  static result_type call(first_argument_type a1, second_argument_type a2)
+  {
+    return (func)(a1, a2);
+  }
+};
+
+template<typename A1, typename A2, typename A3, typename R, R (*func)(A1, A2, A3)> 
+class Function3
+{
+public:
+  typedef A1 first_argument_type;
+  typedef A2 second_argument_type;
+  typedef A3 third_argument_type;
+  typedef R result_type;
+  static result_type call(first_argument_type a1, second_argument_type a2, third_argument_type a3)
+  {
+    return (func)(a1, a2, a3);
+  }
+};
+
+template<typename A1, typename A2, typename A3, typename A4, typename R, R (*func)(A1, A2, A3, A4)> 
+class Function4
+{
+public:
+  typedef A1 first_argument_type;
+  typedef A2 second_argument_type;
+  typedef A3 third_argument_type;
+  typedef A4 fourth_argument_type;
+  typedef R result_type;
+  static result_type call(first_argument_type a1, second_argument_type a2, third_argument_type a3, fourth_argument_type a4)
+  {
+    return (func)(a1, a2, a3, a4);
+  }
+};
+
+template<typename Caller, typename FirstArgument = void*> 
+class Caller0To1
+{
+public:
+  typedef FirstArgument first_argument_type;
+  typedef typename Caller::result_type result_type;
+  static result_type call(first_argument_type)
+  {
+    return Caller::call();
+  }
+};
+
+template<typename Caller, typename FirstArgument = void*> 
+class Caller1To2
+{
+public:
+  typedef FirstArgument first_argument_type;
+  typedef typename Caller::first_argument_type second_argument_type;
+  typedef typename Caller::result_type result_type;
+  static result_type call(first_argument_type, second_argument_type a2)
+  {
+    return Caller::call(a2);
+  }
+};
+
+template<typename Caller, typename FirstArgument = void*> 
+class Caller2To3
+{
+public:
+  typedef FirstArgument first_argument_type;
+  typedef typename Caller::first_argument_type second_argument_type;
+  typedef typename Caller::second_argument_type third_argument_type;
+  typedef typename Caller::result_type result_type;
+  static result_type call(first_argument_type, second_argument_type a2, third_argument_type a3)
+  {
+    return Caller::call(a2, a3);
+  }
+};
+
+template<typename Caller, typename FirstArgument = void*> 
+class Caller3To4
+{
+public:
+  typedef FirstArgument first_argument_type;
+  typedef typename Caller::first_argument_type second_argument_type;
+  typedef typename Caller::second_argument_type third_argument_type;
+  typedef typename Caller::third_argument_type fourth_argument_type;
+  typedef typename Caller::result_type result_type;
+  static result_type call(first_argument_type, second_argument_type a2, third_argument_type a3, fourth_argument_type a4)
+  {
+    return Caller::call(a2, a3, a4);
+  }
+};
+
+template<typename Functor>
+class FunctorInvoke
+{
+public:
+  typedef typename Functor::result_type result_type;
+  inline result_type operator()(Functor functor)
+  {
+    return functor();
+  }
+};
+
+template<typename Functor>
+class Functor1Invoke
+{
+  typename Functor::first_argument_type a1;
+public:
+  typedef typename Functor::first_argument_type first_argument_type;
+  typedef typename Functor::result_type result_type;
+  Functor1Invoke(first_argument_type a1) : a1(a1)
+  {
+  }
+  inline result_type operator()(Functor functor)
+  {
+    return functor(a1);
+  }
+};
+
+template<typename Functor>
+class Functor2Invoke
+{
+  typename Functor::first_argument_type a1;
+  typename Functor::second_argument_type a2;
+public:
+  typedef typename Functor::first_argument_type first_argument_type;
+  typedef typename Functor::second_argument_type second_argument_type;
+  typedef typename Functor::result_type result_type;
+  Functor2Invoke(first_argument_type a1, second_argument_type a2)
+    : a1(a1), a2(a2)
+  {
+  }
+  inline result_type operator()(Functor functor)
+  {
+    return functor(a1, a2);
+  }
+};
+
+template<typename Functor>
+class Functor3Invoke
+{
+  typename Functor::first_argument_type a1;
+  typename Functor::second_argument_type a2;
+  typename Functor::third_argument_type a3;
+public:
+  typedef typename Functor::first_argument_type first_argument_type;
+  typedef typename Functor::second_argument_type second_argument_type;
+  typedef typename Functor::third_argument_type third_argument_type;
+  typedef typename Functor::result_type result_type;
+  Functor3Invoke(first_argument_type a1, second_argument_type a2, third_argument_type a3)
+    : a1(a1), a2(a2), a3(a3)
+  {
+  }
+  inline result_type operator()(Functor functor)
+  {
+    return functor(a1, a2, a3);
+  }
+};
+
+template<typename Type, typename Other, typename True, typename False>
+class TypeEqual
+{
+  template<typename Matched>
+  class Match
+  {
+  public:
+    typedef False type;
+  };
+  template<>
+  class Match<Other>
+  {
+  public:
+    typedef True type;
+  };
+public:
+  typedef typename Match<Type>::type type;
+};
+
+
+#endif
index 3da5b073df76d67d5442e6fbcd5fee83572f1a1d..69ddac4bf914dbb19c0fd9b8522d6113fd8ba8ca 100644 (file)
@@ -22,13 +22,14 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #if !defined(INCLUDED_GTKUTIL_BUTTON_H)
 #define INCLUDED_GTKUTIL_BUTTON_H
 
 #if !defined(INCLUDED_GTKUTIL_BUTTON_H)
 #define INCLUDED_GTKUTIL_BUTTON_H
 
+#include "generic/callbackfwd.h"
+
 typedef struct _GtkButton GtkButton;
 typedef struct _GtkToggleButton GtkToggleButton;
 typedef struct _GtkRadioButton GtkRadioButton;
 typedef int gint;
 typedef gint gboolean;
 typedef unsigned int guint;
 typedef struct _GtkButton GtkButton;
 typedef struct _GtkToggleButton GtkToggleButton;
 typedef struct _GtkRadioButton GtkRadioButton;
 typedef int gint;
 typedef gint gboolean;
 typedef unsigned int guint;
-class Callback;
 
 void button_connect_callback(GtkButton* button, const Callback& callback);
 guint toggle_button_connect_callback(GtkToggleButton* button, const Callback& callback);
 
 void button_connect_callback(GtkButton* button, const Callback& callback);
 guint toggle_button_connect_callback(GtkToggleButton* button, const Callback& callback);
index 3372c0294f04da0073bb4c5bca5350468a0913db..a394d82358bfe6d5b8d473ee75de013d2f64b635 100644 (file)
@@ -22,7 +22,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #if !defined(INCLUDED_GTKUTIL_MENU_H)
 #define INCLUDED_GTKUTIL_MENU_H
 
 #if !defined(INCLUDED_GTKUTIL_MENU_H)
 #define INCLUDED_GTKUTIL_MENU_H
 
-class Callback;
+#include "generic/callbackfwd.h"
+
 typedef int gint;
 typedef gint gboolean;
 typedef struct _GSList GSList;
 typedef int gint;
 typedef gint gboolean;
 typedef struct _GSList GSList;
index d0c83a8fc47d67e4b8a7276083384b05491a2e30..9bf847d248ff6c48adc6113b9b9eaceeaef7148e 100644 (file)
@@ -22,7 +22,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #if !defined(INCLUDED_GTKUTIL_TOOLBAR_H)
 #define INCLUDED_GTKUTIL_TOOLBAR_H
 
 #if !defined(INCLUDED_GTKUTIL_TOOLBAR_H)
 #define INCLUDED_GTKUTIL_TOOLBAR_H
 
-class Callback;
+#include "generic/callbackfwd.h"
+
 typedef struct _GtkButton GtkButton;
 typedef struct _GtkToggleButton GtkToggleButton;
 typedef struct _GtkToolbar GtkToolbar;
 typedef struct _GtkButton GtkButton;
 typedef struct _GtkToggleButton GtkToggleButton;
 typedef struct _GtkToolbar GtkToolbar;
index c418b703570516014d6304ba5e3ade005b34c908..00bd4e06adef31da311ceda87e8b6b011362022d 100644 (file)
                        <File
                                RelativePath=".\generic\callback.h">
                        </File>
                        <File
                                RelativePath=".\generic\callback.h">
                        </File>
+                       <File
+                               RelativePath=".\generic\callbackfwd.cpp">
+                       </File>
+                       <File
+                               RelativePath=".\generic\callbackfwd.h">
+                       </File>
                        <File
                                RelativePath=".\generic\constant.cpp">
                        </File>
                        <File
                                RelativePath=".\generic\constant.cpp">
                        </File>
                        <File
                                RelativePath=".\generic\enumeration.h">
                        </File>
                        <File
                                RelativePath=".\generic\enumeration.h">
                        </File>
+                       <File
+                               RelativePath=".\generic\functional.cpp">
+                       </File>
+                       <File
+                               RelativePath=".\generic\functional.h">
+                       </File>
                        <File
                                RelativePath=".\generic\object.cpp">
                        </File>
                        <File
                                RelativePath=".\generic\object.cpp">
                        </File>
                                RelativePath=".\debugging\debugging.h">
                        </File>
                </Filter>
                                RelativePath=".\debugging\debugging.h">
                        </File>
                </Filter>
+               <Filter
+                       Name="signal"
+                       Filter="">
+                       <File
+                               RelativePath=".\signal\isignal.cpp">
+                       </File>
+                       <File
+                               RelativePath=".\signal\isignal.h">
+                       </File>
+                       <File
+                               RelativePath=".\signal\signal.cpp">
+                       </File>
+                       <File
+                               RelativePath=".\signal\signal.h">
+                       </File>
+                       <File
+                               RelativePath=".\signal\signalfwd.cpp">
+                       </File>
+                       <File
+                               RelativePath=".\signal\signalfwd.h">
+                       </File>
+               </Filter>
                <File
                        RelativePath=".\archivelib.cpp">
                </File>
                <File
                        RelativePath=".\archivelib.cpp">
                </File>
index ef0d2251bc4b78f13e1fffde2cf21942567e754d..a9d2a80905ef1d954e7a6f51caf462576e8aa2ef 100644 (file)
@@ -416,6 +416,15 @@ const Vector3 g_vector3_axis_z(0, 0, 1);
 
 const Vector3 g_vector3_axes[3] = { g_vector3_axis_x, g_vector3_axis_y, g_vector3_axis_z };
 
 
 const Vector3 g_vector3_axes[3] = { g_vector3_axis_x, g_vector3_axis_y, g_vector3_axis_z };
 
+inline Vector3& vector3_from_array(float* array)
+{
+  return *reinterpret_cast<Vector3*>(array);
+}
+inline const Vector3& vector3_from_array(const float* array)
+{
+  return *reinterpret_cast<const Vector3*>(array);
+}
+
 template<typename Element>
 inline Element* vector3_to_array(BasicVector3<Element>& self)
 {
 template<typename Element>
 inline Element* vector3_to_array(BasicVector3<Element>& self)
 {
diff --git a/libs/signal/isignal.cpp b/libs/signal/isignal.cpp
new file mode 100644 (file)
index 0000000..ee7e4cb
--- /dev/null
@@ -0,0 +1,3 @@
+
+#include "isignal.h"
+
diff --git a/libs/signal/isignal.h b/libs/signal/isignal.h
new file mode 100644 (file)
index 0000000..e6cb215
--- /dev/null
@@ -0,0 +1,224 @@
+
+#if !defined(INCLUDED_ISIGNAL_H)
+#define INCLUDED_ISIGNAL_H
+
+#include "generic/callback.h"
+#include "signal/signalfwd.h"
+
+class SignalHandlerResult
+{
+  bool value;
+public:
+  explicit SignalHandlerResult(bool value) : value(value)
+  {
+  }
+  bool operator==(SignalHandlerResult other) const
+  {
+    return value == other.value;
+  }
+  bool operator!=(SignalHandlerResult other) const
+  {
+    return !operator==(other);
+  }
+};
+
+const SignalHandlerResult SIGNAL_CONTINUE_EMISSION = SignalHandlerResult(false);
+const SignalHandlerResult SIGNAL_STOP_EMISSION = SignalHandlerResult(true);
+
+template<typename Caller> 
+class SignalHandlerCaller1
+{
+public:
+  typedef typename Caller::first_argument_type first_argument_type;
+  typedef SignalHandlerResult result_type;
+  static result_type call(first_argument_type a1)
+  {
+    Caller::call(a1);
+    return SIGNAL_CONTINUE_EMISSION;
+  }
+};
+
+template<typename Caller> 
+class SignalHandlerCaller2
+{
+public:
+  typedef typename Caller::first_argument_type first_argument_type;
+  typedef typename Caller::second_argument_type second_argument_type;
+  typedef SignalHandlerResult result_type;
+  static result_type call(first_argument_type a1, second_argument_type a2)
+  {
+    Caller::call(a1, a2);
+    return SIGNAL_CONTINUE_EMISSION;
+  }
+};
+
+template<typename Caller> 
+class SignalHandlerCaller3
+{
+public:
+  typedef typename Caller::first_argument_type first_argument_type;
+  typedef typename Caller::second_argument_type second_argument_type;
+  typedef typename Caller::third_argument_type third_argument_type;
+  typedef SignalHandlerResult result_type;
+  static result_type call(first_argument_type a1, second_argument_type a2, third_argument_type a3)
+  {
+    Caller::call(a1, a2, a3);
+    return SIGNAL_CONTINUE_EMISSION;
+  }
+};
+
+template<typename Caller> 
+class SignalHandlerCaller4
+{
+public:
+  typedef typename Caller::first_argument_type first_argument_type;
+  typedef typename Caller::second_argument_type second_argument_type;
+  typedef typename Caller::third_argument_type third_argument_type;
+  typedef typename Caller::fourth_argument_type fourth_argument_type;
+  typedef SignalHandlerResult result_type;
+  static result_type call(first_argument_type a1, second_argument_type a2, third_argument_type a3, fourth_argument_type a4)
+  {
+    Caller::call(a1, a2, a3, a4);
+    return SIGNAL_CONTINUE_EMISSION;
+  }
+};
+
+class SignalHandler : public Callback0<SignalHandlerResult>
+{
+public:
+  template<typename Caller>
+  SignalHandler(const BindFirstOpaque<Caller>& caller)
+    : Callback0<SignalHandlerResult>(BindFirstOpaque<typename TypeEqual<
+      typename Caller::result_type,
+      SignalHandlerResult,
+      Caller,
+      SignalHandlerCaller1<Caller>
+    >::type>(caller.getBound()))
+  {
+  }
+};
+
+template<typename Caller>
+inline SignalHandler makeSignalHandler(const BindFirstOpaque<Caller>& caller)
+{
+  return SignalHandler(caller);
+}
+template<typename Caller>
+inline SignalHandler makeSignalHandler(const Caller& caller, typename Caller::first_argument_type callee)
+{
+  return SignalHandler(BindFirstOpaque<Caller>(callee));
+}
+
+
+template<typename FirstArgument>
+class SignalHandler1 : public Callback1<FirstArgument, SignalHandlerResult>
+{
+public:
+  template<typename Caller>
+  SignalHandler1(const BindFirstOpaque1<Caller>& caller)
+    : Callback1<FirstArgument, SignalHandlerResult>(BindFirstOpaque1<typename TypeEqual<
+      typename Caller::result_type,
+      SignalHandlerResult,
+      Caller,
+      SignalHandlerCaller2<Caller>
+    >::type>(caller.getBound()))
+  {
+  }
+};
+
+template<typename Caller>
+inline SignalHandler1<typename Caller::second_argument_type> makeSignalHandler1(const BindFirstOpaque1<Caller>& caller)
+{
+  return SignalHandler1<typename Caller::second_argument_type>(caller);
+}
+template<typename Caller>
+inline SignalHandler1<typename Caller::second_argument_type> makeSignalHandler1(const Caller& caller, typename Caller::first_argument_type callee)
+{
+  return SignalHandler1<typename Caller::second_argument_type>(BindFirstOpaque1<Caller>(callee));
+}
+
+
+template<typename FirstArgument, typename SecondArgument>
+class SignalHandler2 : public Callback2<FirstArgument, SecondArgument, SignalHandlerResult>
+{
+public:
+  template<typename Caller>
+  SignalHandler2(const BindFirstOpaque2<Caller>& caller)
+    : Callback2<FirstArgument, SecondArgument, SignalHandlerResult>(BindFirstOpaque2<typename TypeEqual<
+      typename Caller::result_type,
+      SignalHandlerResult,
+      Caller,
+      SignalHandlerCaller3<Caller>
+    >::type>(caller.getBound()))
+  {
+  }
+};
+
+template<typename Caller>
+inline SignalHandler2<
+  typename Caller::second_argument_type,
+  typename Caller::third_argument_type
+> makeSignalHandler2(const BindFirstOpaque2<Caller>& caller)
+{
+  return SignalHandler2<
+    typename Caller::second_argument_type,
+    typename Caller::third_argument_type
+  >(caller);
+}
+template<typename Caller>
+inline SignalHandler2<
+  typename Caller::second_argument_type,
+  typename Caller::third_argument_type
+> makeSignalHandler2(const Caller& caller, typename Caller::first_argument_type callee)
+{
+  return SignalHandler2<
+    typename Caller::second_argument_type,
+    typename Caller::third_argument_type
+  >(BindFirstOpaque2<Caller>(callee));
+}
+
+
+template<typename FirstArgument, typename SecondArgument, typename ThirdArgument>
+class SignalHandler3 : public Callback3<FirstArgument, SecondArgument, ThirdArgument, SignalHandlerResult>
+{
+public:
+  template<typename Caller>
+  SignalHandler3(const BindFirstOpaque3<Caller>& caller)
+    : Callback3<FirstArgument, SecondArgument, ThirdArgument, SignalHandlerResult>(BindFirstOpaque3<typename TypeEqual<
+      typename Caller::result_type,
+      SignalHandlerResult,
+      Caller,
+      SignalHandlerCaller4<Caller>
+    >::type>(caller.getBound()))
+  {
+  }
+};
+
+template<typename Caller>
+inline SignalHandler3<
+  typename Caller::second_argument_type,
+  typename Caller::third_argument_type,
+  typename Caller::fourth_argument_type
+> makeSignalHandler3(const BindFirstOpaque3<Caller>& caller)
+{
+  return SignalHandler3<
+    typename Caller::second_argument_type,
+    typename Caller::third_argument_type,
+    typename Caller::fourth_argument_type
+  >(caller);
+}
+template<typename Caller>
+inline SignalHandler3<
+  typename Caller::second_argument_type,
+  typename Caller::third_argument_type,
+  typename Caller::fourth_argument_type
+> makeSignalHandler3(const Caller& caller, typename Caller::first_argument_type callee)
+{
+  return SignalHandler3<
+    typename Caller::second_argument_type,
+    typename Caller::third_argument_type,
+    typename Caller::fourth_argument_type
+  >(BindFirstOpaque3<Caller>(callee));
+}
+
+#endif
diff --git a/libs/signal/signal.cpp b/libs/signal/signal.cpp
new file mode 100644 (file)
index 0000000..617a3a4
--- /dev/null
@@ -0,0 +1,105 @@
+
+#include "signal.h"
+
+
+
+namespace
+{
+  class Test
+  {
+  };
+  class A1
+  {
+  };
+  class A2
+  {
+  };
+  class A3
+  {
+  };
+
+  SignalHandlerResult handler0(Test&)
+  {
+    return SIGNAL_CONTINUE_EMISSION;
+  }
+  typedef Function1<Test&, SignalHandlerResult, handler0> TestHandler0;
+
+  int function0(Test&)
+  {
+    return 7;
+  }
+  typedef Function1<Test&, int, function0> TestFunction0;
+
+  SignalHandlerResult handler1(Test&, A1)
+  {
+    return SIGNAL_CONTINUE_EMISSION;
+  }
+  typedef Function2<Test&, A1, SignalHandlerResult, handler1> TestHandler1;
+
+  void function1(Test&, A1)
+  {
+  }
+  typedef ReferenceCaller1<Test, A1, function1> TestFunction1;
+
+  SignalHandlerResult handler2(Test&, A1, A2)
+  {
+    return SIGNAL_CONTINUE_EMISSION;
+  }
+  typedef Function3<Test&, A1, A2, SignalHandlerResult, handler2> TestHandler2;
+
+  void function2(Test&, A1, A2)
+  {
+  }
+  typedef Function3<Test&, A1, A2, void, function2> TestFunction2;
+
+  SignalHandlerResult handler3(Test&, A1, A2, A3)
+  {
+    return SIGNAL_CONTINUE_EMISSION;
+  }
+  typedef Function4<Test&, A1, A2, A3, SignalHandlerResult, handler3> TestHandler3;
+
+  void function3(Test&, A1, A2, A3)
+  {
+  }
+  typedef Function4<Test&, A1, A2, A3, void, function3> TestFunction3;
+
+  void testSignals()
+  {
+    Test test;
+    {
+      Signal0 e0;
+      Signal0::handler_id_type a = e0.connectLast(makeSignalHandler(TestHandler0(), test)); // signal handler from direct caller returning result
+      Signal0::handler_id_type b = e0.connectFirst(makeSignalHandler(TestFunction0(), test)); // signal handler from direct caller returning int
+      e0();
+      e0.disconnect(a);
+      e0.disconnect(b);
+    }
+    {
+      typedef Signal1<A1> Signal1Test;
+      Signal1Test e1;
+      Signal1Test::handler_id_type a = e1.connectLast(makeSignalHandler1(TestHandler1(), test)); // signal handler from direct caller with one argument, returning result
+      Signal1Test::handler_id_type b = e1.connectFirst(makeSignalHandler1(TestFunction1(test))); // signal handler from opaque caller with one argument, returning void
+      e1(A1());
+      e1.disconnect(a);
+      e1.disconnect(b);
+    }
+    {
+      typedef Signal2<A1, A2> Signal2Test;
+      Signal2Test e2;
+      Signal2Test::handler_id_type a = e2.connectLast(makeSignalHandler2(TestHandler2(), test)); // signal handler from direct caller with two arguments, returning result
+      Signal2Test::handler_id_type b = e2.connectLast(makeSignalHandler2(TestFunction2(), test)); // signal handler from direct caller with two arguments, returning void
+      e2(A1(), A2());
+      e2.disconnect(a);
+      e2.disconnect(b);
+    }
+    {
+      typedef Signal3<A1, A2, A3> Signal3Test;
+      Signal3Test e3;
+      Signal3Test::handler_id_type a = e3.connectLast(makeSignalHandler3(TestHandler3(), test)); // signal handler from direct caller with three arguments, returning result
+      Signal3Test::handler_id_type b = e3.connectLast(makeSignalHandler3(TestFunction3(), test)); // signal handler from direct caller with three arguments, returning void
+      e3(A1(), A2(), A3());
+      e3.disconnect(a);
+      e3.disconnect(b);
+    }
+  }
+}
diff --git a/libs/signal/signal.h b/libs/signal/signal.h
new file mode 100644 (file)
index 0000000..dc187e9
--- /dev/null
@@ -0,0 +1,377 @@
+
+#if !defined(INCLUDED_SIGNAL_H)
+#define INCLUDED_SIGNAL_H
+
+#include "isignal.h"
+#include "memory/allocator.h"
+#include "debugging/debugging.h"
+#include <iterator>
+
+namespace ListDetail
+{
+  struct ListNodeBase
+  {
+    ListNodeBase* next;
+    ListNodeBase* prev;
+  };
+
+  inline void list_initialise(ListNodeBase& self)
+  {
+    self.next = self.prev = &self;
+  }
+
+  inline void list_swap(ListNodeBase& self, ListNodeBase& other)
+  {
+    ListNodeBase tmp(self);
+    if(other.next == &other)
+    {
+      list_initialise(self);
+    }
+    else
+    {
+      self = other;
+      self.next->prev = self.prev->next = &self;
+    }
+    if(tmp.next == &self)
+    {
+      list_initialise(other);
+    }
+    else
+    {
+      other = tmp;
+      other.next->prev = other.prev->next = &other;
+    }
+  }
+
+  inline void node_link(ListNodeBase* node, ListNodeBase* next)
+  {
+    node->next = next;
+    node->prev = next->prev;
+    next->prev = node;
+    node->prev->next = node;
+  }
+  inline void node_unlink(ListNodeBase* node)
+  {
+    node->prev->next = node->next;
+    node->next->prev = node->prev;
+  }
+
+  template<typename Value>
+  struct ListNode : public ListNodeBase
+  {
+    Value value;
+
+    ListNode(const Value& value) : value(value) 
+    {
+    }
+    ListNode* getNext() const
+    {
+      return static_cast<ListNode*>(next);
+    }
+    ListNode* getPrev() const
+    {
+      return static_cast<ListNode*>(prev);
+    }
+  };
+
+  template<typename Type>
+  class NonConstTraits
+  {
+  public:
+    typedef Type value_type;
+    typedef value_type* pointer;
+    typedef value_type& reference;
+
+    template<typename Other>
+    struct rebind
+    {
+      typedef NonConstTraits<Other> other;
+    };
+  };
+
+  template<typename Type>
+  class ConstTraits
+  {
+  public:
+    typedef Type value_type;
+    typedef const value_type* pointer;
+    typedef const value_type& reference;
+
+    template<typename Other>
+    struct rebind
+    {
+      typedef ConstTraits<Other> other;
+    };
+  };
+
+  template<typename Traits>
+  class ListIterator
+  {
+  public:
+    typedef std::forward_iterator_tag iterator_category;
+    typedef std::ptrdiff_t difference_type;
+    typedef difference_type distance_type;
+    typedef typename Traits::value_type value_type;
+    typedef typename Traits::pointer pointer;
+    typedef typename Traits::reference reference;
+
+  private:
+    typedef ListNode<value_type> Node;
+    typedef typename Traits::template rebind<Node>::other NodeTraits;
+    typedef typename NodeTraits::pointer NodePointer;
+    typedef typename Traits::template rebind< Opaque<value_type> >::other OpaqueTraits;
+    typedef typename OpaqueTraits::pointer OpaquePointer;
+    NodePointer m_node;
+
+    void increment()
+    {
+      m_node = m_node->getNext();
+    }
+    void decrement()
+    {
+      m_node = m_node->getPrev();
+    }
+
+
+ public:
+   explicit ListIterator(NodePointer node) : m_node(node)
+    {
+    }
+    explicit ListIterator(OpaquePointer p) : m_node(reinterpret_cast<NodePointer>(p))
+    {
+    }
+
+    NodePointer node()
+    {
+      return m_node;
+    }
+    OpaquePointer opaque() const
+    {
+      return reinterpret_cast<OpaquePointer>(m_node);
+    }
+
+    bool operator==(const ListIterator& other) const
+    {
+      return m_node == other.m_node;
+    }
+    bool operator!=(const ListIterator& other) const
+    {
+      return !operator==(other);
+    }
+    ListIterator& operator++()
+    {
+      increment();
+      return *this;
+    }
+    ListIterator operator++(int)
+    {
+      ListIterator tmp = *this;
+      increment();
+      return tmp;
+    }
+    ListIterator& operator--()
+    {
+      decrement();
+      return *this;
+    }
+    ListIterator operator--(int)
+    {
+      ListIterator tmp = *this;
+      decrement();
+      return tmp;
+    }
+    reference operator*() const
+    {
+      return m_node->value;
+    }
+    pointer operator->() const
+    {
+      return &(operator*());
+    }
+  };
+}
+
+class Opaque;
+
+template<typename Value, typename Allocator = DefaultAllocator<Value> >
+class List : private Allocator
+{
+  typedef ListDetail::ListNode<Value> Node;
+  ListDetail::ListNodeBase list;
+  typedef typename Allocator::template rebind<Node>::other NodeAllocator;
+public:
+  typedef Value value_type;
+  typedef ListDetail::ListIterator< ListDetail::NonConstTraits<Value> > iterator;
+  typedef ListDetail::ListIterator< ListDetail::ConstTraits<Value> > const_iterator;
+
+  List()
+  {
+    list_initialise(list);
+  }
+  explicit List(const Allocator& allocator) : Allocator(allocator)
+  {
+    list_initialise(list);
+  }
+  iterator begin()
+  {
+    return iterator(static_cast<Node*>(list.next));
+  }
+  iterator end()
+  {
+    return iterator(static_cast<Node*>(&list));
+  }
+  const_iterator begin() const
+  {
+    return const_iterator(static_cast<const Node*>(list.next));
+  }
+  const_iterator end() const
+  {
+    return const_iterator(static_cast<const Node*>(&list));
+  }
+  void push_back(const Value& value)
+  {
+    insert(end(), value);
+  }
+  void pop_back(const Value& value)
+  {
+    erase(--end(), value);
+  }
+  void push_front(const Value& value)
+  {
+    insert(begin(), value);
+  }
+  void pop_front(const Value& value)
+  {
+    erase(begin(), value);
+  }
+  iterator insert(iterator pos, const Value& x)
+  {
+    Node* node = new (NodeAllocator(*this).allocate(1)) Node(x);
+    node_link(node, pos.node());
+    return iterator(node);
+  }
+  iterator erase(iterator pos)
+  {
+    Node* node = pos.node();
+    Node* next = node->getNext();
+    node_unlink(node);
+    node->~Node();
+    NodeAllocator(*this).deallocate(node, 1);
+    return iterator(next);
+  }
+};
+
+template<typename Functor>
+class SignalBase
+{
+  typedef List<Functor> SignalList;
+  SignalList events;
+
+public:
+
+  typedef Functor handler_type;
+  typedef Handle< Opaque<Functor> > handler_id_type;
+  typedef typename SignalList::iterator iterator;
+  typedef typename SignalList::const_iterator const_iterator;
+  iterator begin()
+  {
+    return events.begin();
+  }
+  iterator end()
+  {
+    return events.end();
+  }
+  const_iterator begin() const
+  {
+    return events.begin();
+  }
+  const_iterator end() const
+  {
+    return events.end();
+  }
+  handler_id_type connectFirst(const Functor& event)
+  {
+    events.push_front(event);
+    return handler_id_type(begin().opaque());
+  }
+  handler_id_type connectLast(const Functor& event)
+  {
+    events.push_back(event);
+    return handler_id_type((--end()).opaque());
+  }
+  bool isConnected(handler_id_type id)
+  {
+    for(iterator i = begin(); i != end(); ++i)
+    {
+      if(id.get() == i.opaque())
+      {
+        return true;
+      }
+    }
+    return false;
+  }
+  handler_id_type connectBefore(handler_id_type id, const Functor& event)
+  {
+    ASSERT_MESSAGE(isConnected(id), "SignalBase::connectBefore: invalid id");
+    return events.insert(iterator(id.get()), event).opaque();
+  }
+  handler_id_type connectAfter(handler_id_type id, const Functor& event)
+  {
+    ASSERT_MESSAGE(isConnected(id), "SignalBase::connectAfter: invalid id");
+    return events.insert(++iterator(id.get()), event).opaque();
+  }
+  void disconnect(handler_id_type id)
+  {
+    ASSERT_MESSAGE(isConnected(id), "SignalBase::disconnect: invalid id");
+    events.erase(iterator(id.get()));
+  }
+};
+
+///\brief
+// It is safe to disconnect the signal handler currently being invoked.
+template<typename InputIterator, typename SignalHandlerInvoke>
+inline void invokeSignalHandlers(InputIterator first, InputIterator last, SignalHandlerInvoke invoke)
+{
+  while(first != last && invoke(*first++) != SIGNAL_STOP_EMISSION);
+}
+
+class Signal0 : public SignalBase<SignalHandler>
+{
+public:
+  void operator()() const
+  {
+    invokeSignalHandlers(begin(), end(), FunctorInvoke<typename handler_type>());
+  }
+};
+
+template<typename FirstArgument>
+class Signal1 : public SignalBase< SignalHandler1<FirstArgument> >
+{
+public:
+  void operator()(FirstArgument a1) const
+  {
+    invokeSignalHandlers(begin(), end(), Functor1Invoke<typename handler_type>(a1));
+  }
+};
+
+template<typename FirstArgument, typename SecondArgument>
+class Signal2 : public SignalBase< SignalHandler2<FirstArgument, SecondArgument> >
+{
+public:
+  void operator()(FirstArgument a1, SecondArgument a2) const
+  {
+    invokeSignalHandlers(begin(), end(), Functor2Invoke<typename handler_type>(a1, a2));
+  }
+};
+
+template<typename FirstArgument, typename SecondArgument, typename ThirdArgument>
+class Signal3 : public SignalBase< SignalHandler3<FirstArgument, SecondArgument, ThirdArgument> >
+{
+public:
+  void operator()(FirstArgument a1, SecondArgument a2, ThirdArgument a3) const
+  {
+    invokeSignalHandlers(begin(), end(), Functor3Invoke<typename handler_type>(a1, a2, a3));
+  }
+};
+
+#endif
diff --git a/libs/signal/signalfwd.cpp b/libs/signal/signalfwd.cpp
new file mode 100644 (file)
index 0000000..c274b06
--- /dev/null
@@ -0,0 +1,3 @@
+
+#include "signalfwd.h"
+
diff --git a/libs/signal/signalfwd.h b/libs/signal/signalfwd.h
new file mode 100644 (file)
index 0000000..79597e2
--- /dev/null
@@ -0,0 +1,48 @@
+
+#if !defined(INCLUDED_SIGNALFWD_H)
+#define INCLUDED_SIGNALFWD_H
+
+class SignalHandler;
+template<typename FirstArgument>
+class SignalHandler1;
+template<typename FirstArgument, typename SecondArgument>
+class SignalHandler2;
+template<typename FirstArgument, typename SecondArgument, typename ThirdArgument>
+class SignalHandler3;
+
+template<typename Context>
+class Opaque;
+
+///\brief A pointer that always has a well-defined value.
+/// If no value is specified, the appropriate null value is used.
+template<typename Type>
+class Handle
+{
+  Type* p;
+public:
+  Handle() : p(0)
+  {
+  }
+  explicit Handle(Type* p) : p(p)
+  {
+  }
+  Type* get() const
+  {
+    return p;
+  }
+  bool isNull() const
+  {
+    return p == 0;
+  }
+};
+
+template<typename Handler>
+class SignalFwd
+{
+public:
+  typedef Handle< Opaque<Handler> > handler_id_type;
+};
+
+typedef SignalFwd<SignalHandler>::handler_id_type SignalHandlerId;
+
+#endif
index 2e354e32cdde3aaaee193e2f3cfe68da447cde47..26200253ece42dd5438973f99b3723e8a97ca015 100644 (file)
@@ -27,17 +27,11 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
 #include <map>
 
 
 #include <map>
 
+///\brief All string pointers passed to an instance of this class are not
+/// copied and must stay valid for the lifetime of the instance.
 class StaticElement : public XMLElement
 {
 class StaticElement : public XMLElement
 {
-  struct strless
-  {
-    bool operator()(const char* s1, const char* s2) const
-    {
-      return strcmp(s1, s2) < 0;
-    }
-  };
-
-  typedef std::map<const char*, const char*, strless> attrs_t;
+  typedef std::map<const char*, const char*, RawStringLess> attrs_t;
 public:
   StaticElement(const char* name)
     : m_name(name)
 public:
   StaticElement(const char* name)
     : m_name(name)
@@ -71,13 +65,15 @@ private:
   attrs_t m_attrs;
 };
 
   attrs_t m_attrs;
 };
 
+///\brief All string pointers passed to an instance of this class are copied.
 class DynamicElement : public XMLElement
 {
   typedef std::map<CopiedString, CopiedString> attrs_t;
 public:
   DynamicElement(const char* name)
     : m_name(name)
 class DynamicElement : public XMLElement
 {
   typedef std::map<CopiedString, CopiedString> attrs_t;
 public:
   DynamicElement(const char* name)
     : m_name(name)
-  {}
+  {
+  }
   void insertAttribute(const char* name, const char* value)
   {
     m_attrs.insert(attrs_t::value_type(name, value));
   void insertAttribute(const char* name, const char* value)
   {
     m_attrs.insert(attrs_t::value_type(name, value));
index 6f3ad9e7a9d4591c020e8c99e58cd21905e6128e..71ff385af6cf6feca01a75a44ed3ccd77c96b4bd 100644 (file)
@@ -30,6 +30,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
 #include "math/curve.h"
 #include "stream/stringstream.h"
 
 #include "math/curve.h"
 #include "stream/stringstream.h"
+#include "signal/signal.h"
 #include "selectionlib.h"
 #include "render.h"
 #include "stringio.h"
 #include "selectionlib.h"
 #include "render.h"
 #include "stringio.h"
@@ -339,8 +340,7 @@ const int NURBS_degree = 3;
 
 class NURBSCurve
 {
 
 class NURBSCurve
 {
-  typedef std::set<Callback> Callbacks;
-  Callbacks m_curveChanged;
+  Signal0 m_curveChanged;
   Callback m_boundsChanged;
 public:
   ControlPoints m_controlPoints;
   Callback m_boundsChanged;
 public:
   ControlPoints m_controlPoints;
@@ -354,18 +354,18 @@ public:
   {
   }
 
   {
   }
 
-  void attach(const Callback& curveChanged)
+  SignalHandlerId connect(const SignalHandler& curveChanged)
   {
   {
-    m_curveChanged.insert(curveChanged);
     curveChanged();
     curveChanged();
+    return m_curveChanged.connectLast(curveChanged);
   }
   }
-  void detach(const Callback& curveChanged)
+  void disconnect(SignalHandlerId id)
   {
   {
-    m_curveChanged.erase(curveChanged);
+    m_curveChanged.disconnect(id);
   }
   void notify()
   {
   }
   void notify()
   {
-    std::for_each(m_curveChanged.begin(), m_curveChanged.end(), CallbackInvoke());
+    m_curveChanged();
   }
 
   void tesselate()
   }
 
   void tesselate()
@@ -437,8 +437,7 @@ public:
 
 class CatmullRomSpline
 {
 
 class CatmullRomSpline
 {
-  typedef std::set<Callback> Callbacks;
-  Callbacks m_curveChanged;
+  Signal0 m_curveChanged;
   Callback m_boundsChanged;
 public:
   ControlPoints m_controlPoints;
   Callback m_boundsChanged;
 public:
   ControlPoints m_controlPoints;
@@ -450,18 +449,18 @@ public:
   {
   }
 
   {
   }
 
-  void attach(const Callback& curveChanged)
+  SignalHandlerId connect(const SignalHandler& curveChanged)
   {
   {
-    m_curveChanged.insert(curveChanged);
     curveChanged();
     curveChanged();
+    return m_curveChanged.connectLast(curveChanged);
   }
   }
-  void detach(const Callback& curveChanged)
+  void disconnect(SignalHandlerId id)
   {
   {
-    m_curveChanged.erase(curveChanged);
+    m_curveChanged.disconnect(id);
   }
   void notify()
   {
   }
   void notify()
   {
-    std::for_each(m_curveChanged.begin(), m_curveChanged.end(), CallbackInvoke());
+    m_curveChanged();
   }
 
   void tesselate()
   }
 
   void tesselate()
index 5d819909f5d13eb199715029a4a53713587451e5..72048bdbaa3ac7041a14a086e4a89e004f22f3c2 100644 (file)
@@ -96,7 +96,9 @@ class Doom3Group :
 
 public:
   NURBSCurve m_curveNURBS;
 
 public:
   NURBSCurve m_curveNURBS;
+  SignalHandlerId m_curveNURBSChanged;
   CatmullRomSpline m_curveCatmullRom;
   CatmullRomSpline m_curveCatmullRom;
+  SignalHandlerId m_curveCatmullRomChanged;
 private:
   mutable AABB m_curveBounds;
 
 private:
   mutable AABB m_curveBounds;
 
@@ -522,8 +524,8 @@ public:
     m_curveCatmullRom(m_contained.m_curveCatmullRom.m_controlPointsTransformed, SelectionChangedComponentCaller(*this))
   {
     m_contained.instanceAttach(Instance::path());
     m_curveCatmullRom(m_contained.m_curveCatmullRom.m_controlPointsTransformed, SelectionChangedComponentCaller(*this))
   {
     m_contained.instanceAttach(Instance::path());
-    m_contained.m_curveNURBS.attach(CurveEdit::CurveChangedCaller(m_curveNURBS));
-    m_contained.m_curveCatmullRom.attach(CurveEdit::CurveChangedCaller(m_curveCatmullRom));
+    m_contained.m_curveNURBSChanged = m_contained.m_curveNURBS.connect(CurveEdit::CurveChangedCaller(m_curveNURBS));
+    m_contained.m_curveCatmullRomChanged = m_contained.m_curveCatmullRom.connect(CurveEdit::CurveChangedCaller(m_curveCatmullRom));
 
     StaticRenderableConnectionLines::instance().attach(*this);
   }
 
     StaticRenderableConnectionLines::instance().attach(*this);
   }
@@ -531,8 +533,8 @@ public:
   {
     StaticRenderableConnectionLines::instance().detach(*this);
 
   {
     StaticRenderableConnectionLines::instance().detach(*this);
 
-    m_contained.m_curveCatmullRom.detach(CurveEdit::CurveChangedCaller(m_curveCatmullRom));
-    m_contained.m_curveNURBS.detach(CurveEdit::CurveChangedCaller(m_curveNURBS));
+    m_contained.m_curveCatmullRom.disconnect(m_contained.m_curveCatmullRomChanged);
+    m_contained.m_curveNURBS.disconnect(m_contained.m_curveNURBSChanged);
     m_contained.instanceDetach(Instance::path());
   }
   void renderSolid(Renderer& renderer, const VolumeTest& volume) const
     m_contained.instanceDetach(Instance::path());
   }
   void renderSolid(Renderer& renderer, const VolumeTest& volume) const
index a10109fc70c601ee9346a9c981c5311932dd2c77..3921e36444e4469e558b93d40bc3fd35440246f4 100644 (file)
@@ -25,7 +25,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #include "entitylib.h"
 #include <map>
 
 #include "entitylib.h"
 #include <map>
 
-class KeyObserverMap : public EntityKeyValues::Observer
+class KeyObserverMap : public Entity::Observer
 {
   typedef std::multimap<const char*, KeyObserver, RawStringLess> KeyObservers;
   KeyObservers m_keyObservers;
 {
   typedef std::multimap<const char*, KeyObserver, RawStringLess> KeyObservers;
   KeyObservers m_keyObservers;
@@ -34,14 +34,14 @@ public:
   {
     m_keyObservers.insert(KeyObservers::value_type(key, observer));
   }
   {
     m_keyObservers.insert(KeyObservers::value_type(key, observer));
   }
-  void insert(const char* key, EntityKeyValues::Value& value)
+  void insert(const char* key, EntityKeyValue& value)
   {
     for(KeyObservers::const_iterator i = m_keyObservers.find(key); i != m_keyObservers.end() && string_equal((*i).first, key); ++i)
     {
       value.attach((*i).second);
     }
   }
   {
     for(KeyObservers::const_iterator i = m_keyObservers.find(key); i != m_keyObservers.end() && string_equal((*i).first, key); ++i)
     {
       value.attach((*i).second);
     }
   }
-  void erase(const char* key, EntityKeyValues::Value& value)
+  void erase(const char* key, EntityKeyValue& value)
   {
     for(KeyObservers::const_iterator i = m_keyObservers.find(key); i != m_keyObservers.end() && string_equal((*i).first, key); ++i)
     {
   {
     for(KeyObservers::const_iterator i = m_keyObservers.find(key); i != m_keyObservers.end() && string_equal((*i).first, key); ++i)
     {
index 0afdaaa4d54b0459dfddfd938299943f5ea3b71c..bb0405e66be758686ab9ff093d05f740d9a63809 100644 (file)
@@ -48,11 +48,11 @@ public:
 };
 
 
 };
 
 
-typedef MemberCaller1<KeyValue, const char*, &KeyValue::assign> KeyValueAssignCaller;
-typedef MemberCaller1<KeyValue, const KeyObserver&, &KeyValue::attach> KeyValueAttachCaller;
-typedef MemberCaller1<KeyValue, const KeyObserver&, &KeyValue::detach> KeyValueDetachCaller;
+typedef MemberCaller1<EntityKeyValue, const char*, &EntityKeyValue::assign> KeyValueAssignCaller;
+typedef MemberCaller1<EntityKeyValue, const KeyObserver&, &EntityKeyValue::attach> KeyValueAttachCaller;
+typedef MemberCaller1<EntityKeyValue, const KeyObserver&, &EntityKeyValue::detach> KeyValueDetachCaller;
 
 
-class NameKeys : public EntityKeyValues::Observer, public Namespaced
+class NameKeys : public Entity::Observer, public Namespaced
 {
   Namespace* m_namespace;
   EntityKeyValues& m_entity;
 {
   Namespace* m_namespace;
   EntityKeyValues& m_entity;
@@ -60,10 +60,10 @@ class NameKeys : public EntityKeyValues::Observer, public Namespaced
   NameKeys(const NameKeys& other);
   NameKeys& operator=(const NameKeys& other);
 
   NameKeys(const NameKeys& other);
   NameKeys& operator=(const NameKeys& other);
 
-  typedef std::map<CopiedString, EntityKeyValues::Value*> KeyValues;
+  typedef std::map<CopiedString, EntityKeyValue*> KeyValues;
   KeyValues m_keyValues;
 
   KeyValues m_keyValues;
 
-  void insertName(const char* key, EntityKeyValues::Value& value)
+  void insertName(const char* key, EntityKeyValue& value)
   {
     if(m_namespace != 0 && m_keyIsName(key))
     {
   {
     if(m_namespace != 0 && m_keyIsName(key))
     {
@@ -71,7 +71,7 @@ class NameKeys : public EntityKeyValues::Observer, public Namespaced
       m_namespace->attach(KeyValueAssignCaller(value), KeyValueAttachCaller(value));
     }
   }
       m_namespace->attach(KeyValueAssignCaller(value), KeyValueAttachCaller(value));
     }
   }
-  void eraseName(const char* key, EntityKeyValues::Value& value)
+  void eraseName(const char* key, EntityKeyValue& value)
   {
     if(m_namespace != 0 && m_keyIsName(key))
     {
   {
     if(m_namespace != 0 && m_keyIsName(key))
     {
@@ -114,12 +114,12 @@ public:
     m_keyIsName = keyIsName;
     insertAll();
   }
     m_keyIsName = keyIsName;
     insertAll();
   }
-  void insert(const char* key, EntityKeyValues::Value& value)
+  void insert(const char* key, EntityKeyValue& value)
   {
     m_keyValues.insert(KeyValues::value_type(key, &value));
     insertName(key, value);
   }
   {
     m_keyValues.insert(KeyValues::value_type(key, &value));
     insertName(key, value);
   }
-  void erase(const char* key, EntityKeyValues::Value& value)
+  void erase(const char* key, EntityKeyValue& value)
   {
     eraseName(key, value);
     m_keyValues.erase(key);
   {
     eraseName(key, value);
     m_keyValues.erase(key);
index 234bac39a318a391e03555e5e825109dd4f07096..82dd43afa0dd87dae70b5700dd211818d2e6ff0e 100644 (file)
@@ -209,7 +209,7 @@ public:
   }
 };
 
   }
 };
 
-class TargetKeys : public EntityKeyValues::Observer
+class TargetKeys : public Entity::Observer
 {
   TargetingEntities m_targetingEntities;
   Callback m_targetsChanged;
 {
   TargetingEntities m_targetingEntities;
   Callback m_targetsChanged;
@@ -236,7 +236,7 @@ public:
     m_targetsChanged();
   }
 
     m_targetsChanged();
   }
 
-  void insert(const char* key, EntityKeyValues::Value& value)
+  void insert(const char* key, EntityKeyValue& value)
   {
     std::size_t index;
     if(readTargetKey(key, index))
   {
     std::size_t index;
     if(readTargetKey(key, index))
@@ -246,7 +246,7 @@ public:
       targetsChanged();
     }
   }
       targetsChanged();
     }
   }
-  void erase(const char* key, EntityKeyValues::Value& value)
+  void erase(const char* key, EntityKeyValue& value)
   {
     std::size_t index;
     if(readTargetKey(key, index))
   {
     std::size_t index;
     if(readTargetKey(key, index))
@@ -328,7 +328,7 @@ public:
 class TargetableInstance :
 public SelectableInstance,
 public Targetable,
 class TargetableInstance :
 public SelectableInstance,
 public Targetable,
-public EntityKeyValues::Observer
+public Entity::Observer
 {
   mutable Vertex3f m_position;
   EntityKeyValues& m_entity;
 {
   mutable Vertex3f m_position;
   EntityKeyValues& m_entity;
@@ -368,14 +368,14 @@ public:
     m_targeting.targetsChanged();
   }
 
     m_targeting.targetsChanged();
   }
 
-  void insert(const char* key, EntityKeyValues::Value& value)
+  void insert(const char* key, EntityKeyValue& value)
   {
     if(string_equal(key, g_targetable_nameKey))
     {
       value.attach(TargetedEntity::TargetnameChangedCaller(m_targeted));
     }
   }
   {
     if(string_equal(key, g_targetable_nameKey))
     {
       value.attach(TargetedEntity::TargetnameChangedCaller(m_targeted));
     }
   }
-  void erase(const char* key, EntityKeyValues::Value& value)
+  void erase(const char* key, EntityKeyValue& value)
   {
     if(string_equal(key, g_targetable_nameKey))
     {
   {
     if(string_equal(key, g_targetable_nameKey))
     {
index 2250b45a39d0242a181b28e683773c5c5b89a884..002125091685e570a27a4ece81f79672701cef34 100644 (file)
@@ -20,17 +20,18 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */
 
 #include "brush.h"
 */
 
 #include "brush.h"
+#include "signal/signal.h"
 
 
-std::set<Callback> g_brushTextureChangedCallbacks;
+Signal0 g_brushTextureChangedCallbacks;
 
 
-void Brush_addTextureChangedCallback(const Callback& callback)
+void Brush_addTextureChangedCallback(const SignalHandler& handler)
 {
 {
-  g_brushTextureChangedCallbacks.insert(callback);
+  g_brushTextureChangedCallbacks.connectLast(handler);
 }
 
 void Brush_textureChanged()
 {
 }
 
 void Brush_textureChanged()
 {
-  std::for_each(g_brushTextureChangedCallbacks.begin(), g_brushTextureChangedCallbacks.end(), CallbackInvoke());
+  g_brushTextureChangedCallbacks();
 }
 
 QuantiseFunc Face::m_quantise;
 }
 
 QuantiseFunc Face::m_quantise;
index 8645063f5039860623f96f3a5d38483ea7ffab13..b0a932d86deeacfdeea692e4e27bd6fdb3ada5ae 100644 (file)
@@ -60,6 +60,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #include "texturelib.h"
 #include "container/container.h"
 #include "generic/bitfield.h"
 #include "texturelib.h"
 #include "container/container.h"
 #include "generic/bitfield.h"
+#include "signal/signalfwd.h"
 
 #include "winding.h"
 #include "brush_primit.h"
 
 #include "winding.h"
 #include "brush_primit.h"
@@ -560,13 +561,6 @@ public:
 };
 
 
 };
 
 
-inline void FaceShader_getFlags(const FaceShader& faceShader, ContentsFlagsValue& flags)
-{
-  flags = faceShader.getFlags();
-}
-
-
-
 
 
 class FaceTexdef : public FaceShaderObserver
 
 
 class FaceTexdef : public FaceShaderObserver
@@ -703,11 +697,6 @@ public:
   }
 };
 
   }
 };
 
-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 planepts_print(const PlanePoints& planePoints, TextOutputStream& ostream)
 {
   ostream << "( " << planePoints[0][0] << " " << planePoints[0][1] << " " << planePoints[0][2] << " ) "
@@ -938,6 +927,10 @@ public:
   }
 };
 
   }
 };
 
+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;
 
 
 const double GRID_MIN = 0.125;
 
@@ -963,7 +956,7 @@ public:
 
 bool face_filtered(Face& face);
 
 
 bool face_filtered(Face& face);
 
-void Brush_addTextureChangedCallback(const Callback& callback);
+void Brush_addTextureChangedCallback(const SignalHandler& callback);
 void Brush_textureChanged();
 
 
 void Brush_textureChanged();
 
 
@@ -1269,10 +1262,9 @@ public:
     }
   }
 
     }
   }
 
-
   void testSelect(SelectionTest& test, SelectionIntersection& best)
   {
   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)
   }
 
   void testSelect_centroid(SelectionTest& test, SelectionIntersection& best)
@@ -1311,6 +1303,10 @@ public:
     Brush_textureChanged();
   }
 
     Brush_textureChanged();
   }
 
+  void GetTexdef(TextureProjection& projection) const
+  {
+    projection = m_texdef.normalised();
+  }
   void SetTexdef(const TextureProjection& projection)
   {
     undoSave();
   void SetTexdef(const TextureProjection& projection)
   {
     undoSave();
@@ -1318,6 +1314,10 @@ public:
     texdefChanged();
   }
 
     texdefChanged();
   }
 
+  void GetFlags(ContentsFlagsValue& flags) const
+  {
+    flags = m_shader.getFlags();
+  }
   void SetFlags(const ContentsFlagsValue& flags)
   {
     undoSave();
   void SetFlags(const ContentsFlagsValue& flags)
   {
     undoSave();
@@ -2145,12 +2145,12 @@ public:
   {
     return m_faces.back();
   }
   {
     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)
     {
     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 push_back(Faces::value_type face)
@@ -2203,6 +2203,7 @@ public:
 
   void clear()
   {
 
   void clear()
   {
+    undoSave();
     if(m_instanceCounter.m_count != 0)
     {
       forEachFace_instanceDetach(m_map);
     if(m_instanceCounter.m_count != 0)
     {
       forEachFace_instanceDetach(m_map);
@@ -3557,12 +3558,13 @@ public:
   }
   typedef MemberCaller1<BrushInstance, const Selectable&, &BrushInstance::selectedChangedComponent> SelectedChangedComponentCaller;
 
   }
   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);
     }
   {
     for(FaceInstances::iterator i = m_faceInstances.begin(); i != m_faceInstances.end(); ++i)
     {
       visitor.visit(*i);
     }
+    return visitor;
   }
 
   static void constructStatic()
   }
 
   static void constructStatic()
@@ -3985,9 +3987,10 @@ public:
 };
 
 template<typename Functor>
 };
 
 template<typename Functor>
-inline void Scene_forEachSelectedBrush(const Functor& functor)
+inline const Functor& Scene_forEachSelectedBrush(const Functor& functor)
 {
   GlobalSelectionSystem().foreachSelected(BrushSelectedVisitor<Functor>(functor));
 {
   GlobalSelectionSystem().foreachSelected(BrushSelectedVisitor<Functor>(functor));
+  return functor;
 }
 
 template<typename Functor>
 }
 
 template<typename Functor>
@@ -4010,9 +4013,192 @@ public:
 };
 
 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));
 {
   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_getIBrush(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
 #endif
index e9f6ca212ffe9a02e10c82b8fdf4b13cf027a2d1..76748797b4ebf54d644d808101ecb51311c2c346 100644 (file)
@@ -37,14 +37,12 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
 #include <list>
 
 
 #include <list>
 
-
 void Brush_ConstructCuboid(Brush& brush, const AABB& bounds, const char* shader, const TextureProjection& projection)
 {
   const unsigned char box[3][2] = { { 0, 1 }, { 2, 0 }, { 1, 2 } };
   Vector3 mins(vector3_subtracted(bounds.origin, bounds.extents));
   Vector3 maxs(vector3_added(bounds.origin, bounds.extents));
 
 void Brush_ConstructCuboid(Brush& brush, const AABB& bounds, const char* shader, const TextureProjection& projection)
 {
   const unsigned char box[3][2] = { { 0, 1 }, { 2, 0 }, { 1, 2 } };
   Vector3 mins(vector3_subtracted(bounds.origin, bounds.extents));
   Vector3 maxs(vector3_added(bounds.origin, bounds.extents));
 
-  brush.undoSave();
   brush.clear();
   brush.reserve(6);
 
   brush.clear();
   brush.reserve(6);
 
@@ -107,7 +105,6 @@ void Brush_ConstructPrism(Brush& brush, const AABB& bounds, std::size_t sides, i
     return;
   }
 
     return;
   }
 
-  brush.undoSave();
   brush.clear();
   brush.reserve(sides+2);
 
   brush.clear();
   brush.reserve(sides+2);
 
@@ -180,7 +177,6 @@ void Brush_ConstructCone(Brush& brush, const AABB& bounds, std::size_t sides, co
     return;
   }
 
     return;
   }
 
-  brush.undoSave();
   brush.clear();
   brush.reserve(sides+1);
 
   brush.clear();
   brush.reserve(sides+1);
 
@@ -235,7 +231,6 @@ void Brush_ConstructSphere(Brush& brush, const AABB& bounds, std::size_t sides,
     return;
   }
 
     return;
   }
 
-  brush.undoSave();
   brush.clear();
   brush.reserve(sides*sides);
 
   brush.clear();
   brush.reserve(sides*sides);
 
@@ -362,168 +357,14 @@ void ConstructRegionBrushes(scene::Node* brushes[6], const Vector3& region_mins,
 }
 
 
 }
 
 
-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 Visitor>
-class FaceVisitAll : public BrushInstanceVisitor
-{
-  const Visitor& m_visitor;
-public:
-  FaceVisitAll(const Visitor& visitor)
-    : m_visitor(visitor)
-  {
-  }
-  void visit(FaceInstance& face) const
-  {
-    m_visitor.visit(face.getFace());
-  }
-};
-
-template<class Visitor>
-class FaceInstanceVisitAll : public BrushInstanceVisitor
-{
-  const Visitor& m_visitor;
-public:
-  FaceInstanceVisitAll(const Visitor& visitor)
-    : m_visitor(visitor)
-  {
-  }
-  void visit(FaceInstance& face) const
-  {
-    m_visitor.visit(face);
-  }
-};
-
-#if 0
-template<class Visitor>
-class FaceVisitSelected : public BrushInstanceVisitor
-{
-  const Visitor& m_visitor;
-public:
-  FaceVisitSelected(const Visitor& visitor)
-    : m_visitor(visitor)
-  {
-  }
-  void visit(FaceInstance& face) const
-  {
-    if(face.isSelected(SelectionSystem::eFace))
-    {
-      m_visitor.visit(face.getFace());
-    }
-  }
-};
-#endif
-
-template<typename Functor>
-inline void Scene_forEachBrush(scene::Graph& graph, const Functor& functor)
-{
-  graph.traverse(InstanceWalker< InstanceApply<BrushInstance, Functor> >(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 void Scene_forEachVisibleBrush(scene::Graph& graph, const Functor& functor)
-{
-  graph.traverse(BrushVisibleWalker<Functor>(functor));
-}
-
-template<typename Visitor>
-inline void Scene_ForEachBrush_ForEachFace(scene::Graph& graph, const Visitor& visitor)
-{
-  Scene_forEachBrush(graph, BrushForEachFace(FaceVisitAll<Visitor>(visitor)));
-}
-
-template<typename Visitor>
-inline void Scene_ForEachSelectedBrush_ForEachFace(scene::Graph& graph, const Visitor& visitor)
-{
-  Scene_forEachSelectedBrush(BrushForEachFace(FaceVisitAll<Visitor>(visitor)));
-}
-
-template<typename Visitor>
-inline void Scene_ForEachSelectedBrush_ForEachFaceInstance(scene::Graph& graph, const Visitor& visitor)
-{
-  Scene_forEachSelectedBrush(BrushForEachFace(FaceInstanceVisitAll<Visitor>(visitor)));
-}
-
-template<typename Visitor>
-class FaceVisitorWrapper
-{
-  Visitor& m_visitor;
-public:
-  FaceVisitorWrapper(Visitor& visitor) : m_visitor(visitor)
-  {
-  }
-
-  void operator()(FaceInstance& faceInstance)
-  {
-    m_visitor.visit(faceInstance.getFace());
-  }
-};
-
-template<typename Visitor>
-inline void Scene_ForEachSelectedBrushFace(scene::Graph& graph, Visitor& faceVisitor)
-{
-  g_SelectedFaceInstances.foreach(FaceVisitorWrapper<Visitor>(faceVisitor));
-}
-
-
-
-class FaceSetTexdefVisitor
+class FaceSetTexdef
 {
   const TextureProjection& m_projection;
 public:
 {
   const TextureProjection& m_projection;
 public:
-  FaceSetTexdefVisitor(const TextureProjection& projection) : m_projection(projection)
+  FaceSetTexdef(const TextureProjection& projection) : m_projection(projection)
   {
   }
   {
   }
-  void visit(Face& face) const
+  void operator()(Face& face) const
   {
     face.SetTexdef(m_projection);
   }
   {
     face.SetTexdef(m_projection);
   }
@@ -531,26 +372,25 @@ public:
 
 void Scene_BrushSetTexdef_Selected(scene::Graph& graph, const TextureProjection& projection)
 {
 
 void Scene_BrushSetTexdef_Selected(scene::Graph& graph, const TextureProjection& projection)
 {
-  Scene_ForEachSelectedBrush_ForEachFace(graph, FaceSetTexdefVisitor(projection));
+  Scene_ForEachSelectedBrush_ForEachFace(graph, FaceSetTexdef(projection));
   SceneChangeNotify();
 }
 
 void Scene_BrushSetTexdef_Component_Selected(scene::Graph& graph, const TextureProjection& projection)
 {
   SceneChangeNotify();
 }
 
 void Scene_BrushSetTexdef_Component_Selected(scene::Graph& graph, const TextureProjection& projection)
 {
-  FaceSetTexdefVisitor visitor(projection);
-  Scene_ForEachSelectedBrushFace(graph, visitor);
+  Scene_ForEachSelectedBrushFace(graph, FaceSetTexdef(projection));
   SceneChangeNotify();
 }
 
 
   SceneChangeNotify();
 }
 
 
-class FaceSetFlagsVisitor
+class FaceSetFlags
 {
   const ContentsFlagsValue& m_projection;
 public:
 {
   const ContentsFlagsValue& m_projection;
 public:
-  FaceSetFlagsVisitor(const ContentsFlagsValue& flags) : m_projection(flags)
+  FaceSetFlags(const ContentsFlagsValue& flags) : m_projection(flags)
   {
   }
   {
   }
-  void visit(Face& face) const
+  void operator()(Face& face) const
   {
     face.SetFlags(m_projection);
   }
   {
     face.SetFlags(m_projection);
   }
@@ -558,25 +398,24 @@ public:
 
 void Scene_BrushSetFlags_Selected(scene::Graph& graph, const ContentsFlagsValue& flags)
 {
 
 void Scene_BrushSetFlags_Selected(scene::Graph& graph, const ContentsFlagsValue& flags)
 {
-  Scene_ForEachSelectedBrush_ForEachFace(graph, FaceSetFlagsVisitor(flags));
+  Scene_ForEachSelectedBrush_ForEachFace(graph, FaceSetFlags(flags));
   SceneChangeNotify();
 }
 
 void Scene_BrushSetFlags_Component_Selected(scene::Graph& graph, const ContentsFlagsValue& flags)
 {
   SceneChangeNotify();
 }
 
 void Scene_BrushSetFlags_Component_Selected(scene::Graph& graph, const ContentsFlagsValue& flags)
 {
-  FaceSetFlagsVisitor visitor(flags);
-  Scene_ForEachSelectedBrushFace(graph, visitor);
+  Scene_ForEachSelectedBrushFace(graph, FaceSetFlags(flags));
   SceneChangeNotify();
 }
 
   SceneChangeNotify();
 }
 
-class FaceShiftTexdefVisitor
+class FaceShiftTexdef
 {
   float m_s, m_t;
 public:
 {
   float m_s, m_t;
 public:
-  FaceShiftTexdefVisitor(float s, float t) : m_s(s), m_t(t)
+  FaceShiftTexdef(float s, float t) : m_s(s), m_t(t)
   {
   }
   {
   }
-  void visit(Face& face) const
+  void operator()(Face& face) const
   {
     face.ShiftTexdef(m_s, m_t);
   }
   {
     face.ShiftTexdef(m_s, m_t);
   }
@@ -584,25 +423,24 @@ public:
 
 void Scene_BrushShiftTexdef_Selected(scene::Graph& graph, float s, float t)
 {
 
 void Scene_BrushShiftTexdef_Selected(scene::Graph& graph, float s, float t)
 {
-  Scene_ForEachSelectedBrush_ForEachFace(graph, FaceShiftTexdefVisitor(s, t));
+  Scene_ForEachSelectedBrush_ForEachFace(graph, FaceShiftTexdef(s, t));
   SceneChangeNotify();
 }
 
 void Scene_BrushShiftTexdef_Component_Selected(scene::Graph& graph, float s, float t)
 {
   SceneChangeNotify();
 }
 
 void Scene_BrushShiftTexdef_Component_Selected(scene::Graph& graph, float s, float t)
 {
-  FaceShiftTexdefVisitor visitor(s, t);
-  Scene_ForEachSelectedBrushFace(graph, visitor);
+  Scene_ForEachSelectedBrushFace(graph, FaceShiftTexdef(s, t));
   SceneChangeNotify();
 }
 
   SceneChangeNotify();
 }
 
-class FaceScaleTexdefVisitor
+class FaceScaleTexdef
 {
   float m_s, m_t;
 public:
 {
   float m_s, m_t;
 public:
-  FaceScaleTexdefVisitor(float s, float t) : m_s(s), m_t(t)
+  FaceScaleTexdef(float s, float t) : m_s(s), m_t(t)
   {
   }
   {
   }
-  void visit(Face& face) const
+  void operator()(Face& face) const
   {
     face.ScaleTexdef(m_s, m_t);
   }
   {
     face.ScaleTexdef(m_s, m_t);
   }
@@ -610,25 +448,24 @@ public:
 
 void Scene_BrushScaleTexdef_Selected(scene::Graph& graph, float s, float t)
 {
 
 void Scene_BrushScaleTexdef_Selected(scene::Graph& graph, float s, float t)
 {
-  Scene_ForEachSelectedBrush_ForEachFace(graph, FaceScaleTexdefVisitor(s, t));
+  Scene_ForEachSelectedBrush_ForEachFace(graph, FaceScaleTexdef(s, t));
   SceneChangeNotify();
 }
 
 void Scene_BrushScaleTexdef_Component_Selected(scene::Graph& graph, float s, float t)
 {
   SceneChangeNotify();
 }
 
 void Scene_BrushScaleTexdef_Component_Selected(scene::Graph& graph, float s, float t)
 {
-  FaceScaleTexdefVisitor visitor(s, t);
-  Scene_ForEachSelectedBrushFace(graph, visitor);
+  Scene_ForEachSelectedBrushFace(graph, FaceScaleTexdef(s, t));
   SceneChangeNotify();
 }
 
   SceneChangeNotify();
 }
 
-class FaceRotateTexdefVisitor
+class FaceRotateTexdef
 {
   float m_angle;
 public:
 {
   float m_angle;
 public:
-  FaceRotateTexdefVisitor(float angle) : m_angle(angle)
+  FaceRotateTexdef(float angle) : m_angle(angle)
   {
   }
   {
   }
-  void visit(Face& face) const
+  void operator()(Face& face) const
   {
     face.RotateTexdef(m_angle);
   }
   {
     face.RotateTexdef(m_angle);
   }
@@ -636,24 +473,23 @@ public:
 
 void Scene_BrushRotateTexdef_Selected(scene::Graph& graph, float angle)
 {
 
 void Scene_BrushRotateTexdef_Selected(scene::Graph& graph, float angle)
 {
-  Scene_ForEachSelectedBrush_ForEachFace(graph, FaceRotateTexdefVisitor(angle));
+  Scene_ForEachSelectedBrush_ForEachFace(graph, FaceRotateTexdef(angle));
   SceneChangeNotify();
 }
 
 void Scene_BrushRotateTexdef_Component_Selected(scene::Graph& graph, float angle)
 {
   SceneChangeNotify();
 }
 
 void Scene_BrushRotateTexdef_Component_Selected(scene::Graph& graph, float angle)
 {
-  FaceRotateTexdefVisitor visitor(angle);
-  Scene_ForEachSelectedBrushFace(graph, visitor);
+  Scene_ForEachSelectedBrushFace(graph, FaceRotateTexdef(angle));
   SceneChangeNotify();
 }
 
 
   SceneChangeNotify();
 }
 
 
-class FaceSetShaderVisitor
+class FaceSetShader
 {
   const char* m_name;
 public:
 {
   const char* m_name;
 public:
-  FaceSetShaderVisitor(const char* name) : m_name(name) {}
-  void visit(Face& face) const
+  FaceSetShader(const char* name) : m_name(name) {}
+  void operator()(Face& face) const
   {
     face.SetShader(m_name);
   }
   {
     face.SetShader(m_name);
   }
@@ -661,25 +497,24 @@ public:
 
 void Scene_BrushSetShader_Selected(scene::Graph& graph, const char* name)
 {
 
 void Scene_BrushSetShader_Selected(scene::Graph& graph, const char* name)
 {
-  Scene_ForEachSelectedBrush_ForEachFace(graph, FaceSetShaderVisitor(name));
+  Scene_ForEachSelectedBrush_ForEachFace(graph, FaceSetShader(name));
   SceneChangeNotify();
 }
 
 void Scene_BrushSetShader_Component_Selected(scene::Graph& graph, const char* name)
 {
   SceneChangeNotify();
 }
 
 void Scene_BrushSetShader_Component_Selected(scene::Graph& graph, const char* name)
 {
-  FaceSetShaderVisitor visitor(name);
-  Scene_ForEachSelectedBrushFace(graph, visitor);
+  Scene_ForEachSelectedBrushFace(graph, FaceSetShader(name));
   SceneChangeNotify();
 }
 
   SceneChangeNotify();
 }
 
-class FaceSetDetailVisitor
+class FaceSetDetail
 {
   bool m_detail;
 public:
 {
   bool m_detail;
 public:
-  FaceSetDetailVisitor(bool detail) : m_detail(detail)
+  FaceSetDetail(bool detail) : m_detail(detail)
   {
   }
   {
   }
-  void visit(Face& face) const
+  void operator()(Face& face) const
   {
     face.setDetail(m_detail);
   }
   {
     face.setDetail(m_detail);
   }
@@ -687,7 +522,7 @@ public:
 
 void Scene_BrushSetDetail_Selected(scene::Graph& graph, bool detail)
 {
 
 void Scene_BrushSetDetail_Selected(scene::Graph& graph, bool detail)
 {
-  Scene_ForEachSelectedBrush_ForEachFace(graph, FaceSetDetailVisitor(detail));
+  Scene_ForEachSelectedBrush_ForEachFace(graph, FaceSetDetail(detail));
   SceneChangeNotify();
 }
 
   SceneChangeNotify();
 }
 
@@ -701,15 +536,15 @@ bool Face_FindReplaceShader(Face& face, const char* find, const char* replace)
   return false;
 }
 
   return false;
 }
 
-class FaceFindReplaceShaderVisitor
+class FaceFindReplaceShader
 {
   const char* m_find;
   const char* m_replace;
 public:
 {
   const char* m_find;
   const char* m_replace;
 public:
-  FaceFindReplaceShaderVisitor(const char* find, const char* replace) : m_find(find), m_replace(replace)
+  FaceFindReplaceShader(const char* find, const char* replace) : m_find(find), m_replace(replace)
   {
   }
   {
   }
-  void visit(Face& face) const
+  void operator()(Face& face) const
   {
     Face_FindReplaceShader(face, m_find, m_replace);
   }
   {
     Face_FindReplaceShader(face, m_find, m_replace);
   }
@@ -717,29 +552,28 @@ public:
 
 void Scene_BrushFindReplaceShader(scene::Graph& graph, const char* find, const char* replace)
 {
 
 void Scene_BrushFindReplaceShader(scene::Graph& graph, const char* find, const char* replace)
 {
-  Scene_ForEachBrush_ForEachFace(graph, FaceFindReplaceShaderVisitor(find, replace));
+  Scene_ForEachBrush_ForEachFace(graph, FaceFindReplaceShader(find, replace));
 }
 
 void Scene_BrushFindReplaceShader_Selected(scene::Graph& graph, const char* find, const char* replace)
 {
 }
 
 void Scene_BrushFindReplaceShader_Selected(scene::Graph& graph, const char* find, const char* replace)
 {
-  Scene_ForEachSelectedBrush_ForEachFace(graph, FaceFindReplaceShaderVisitor(find, replace));
+  Scene_ForEachSelectedBrush_ForEachFace(graph, FaceFindReplaceShader(find, replace));
 }
 
 void Scene_BrushFindReplaceShader_Component_Selected(scene::Graph& graph, const char* find, const char* replace)
 {
 }
 
 void Scene_BrushFindReplaceShader_Component_Selected(scene::Graph& graph, const char* find, const char* replace)
 {
-  FaceFindReplaceShaderVisitor visitor(find, replace);
-  Scene_ForEachSelectedBrushFace(graph, visitor);
+  Scene_ForEachSelectedBrushFace(graph, FaceFindReplaceShader(find, replace));
 }
 
 
 }
 
 
-class FaceFitTextureVisitor
+class FaceFitTexture
 {
   float m_s_repeat, m_t_repeat;
 public:
 {
   float m_s_repeat, m_t_repeat;
 public:
-  FaceFitTextureVisitor(float s_repeat, float t_repeat) : m_s_repeat(s_repeat), m_t_repeat(t_repeat)
+  FaceFitTexture(float s_repeat, float t_repeat) : m_s_repeat(s_repeat), m_t_repeat(t_repeat)
   {
   }
   {
   }
-  void visit(Face& face) const
+  void operator()(Face& face) const
   {
     face.FitTexture(m_s_repeat, m_t_repeat);
   }
   {
     face.FitTexture(m_s_repeat, m_t_repeat);
   }
@@ -747,17 +581,22 @@ public:
 
 void Scene_BrushFitTexture_Selected(scene::Graph& graph, float s_repeat, float t_repeat)
 {
 
 void Scene_BrushFitTexture_Selected(scene::Graph& graph, float s_repeat, float t_repeat)
 {
-  Scene_ForEachSelectedBrush_ForEachFace(graph, FaceFitTextureVisitor(s_repeat, t_repeat));
+  Scene_ForEachSelectedBrush_ForEachFace(graph, FaceFitTexture(s_repeat, t_repeat));
   SceneChangeNotify();
 }
 
 void Scene_BrushFitTexture_Component_Selected(scene::Graph& graph, float s_repeat, float t_repeat)
 {
   SceneChangeNotify();
 }
 
 void Scene_BrushFitTexture_Component_Selected(scene::Graph& graph, float s_repeat, float t_repeat)
 {
-  FaceFitTextureVisitor visitor(s_repeat, t_repeat);
-  Scene_ForEachSelectedBrushFace(graph, visitor);
+  Scene_ForEachSelectedBrushFace(graph, FaceFitTexture(s_repeat, t_repeat));
   SceneChangeNotify();
 }
 
   SceneChangeNotify();
 }
 
+TextureProjection g_defaultTextureProjection;
+const TextureProjection& TextureTransform_getDefault()
+{
+  TexDef_Construct_Default(g_defaultTextureProjection);
+  return g_defaultTextureProjection;
+}
 
 void Scene_BrushConstructPrefab(scene::Graph& graph, EBrushPrefab type, std::size_t sides, const char* shader)
 {
 
 void Scene_BrushConstructPrefab(scene::Graph& graph, EBrushPrefab type, std::size_t sides, const char* shader)
 {
@@ -768,10 +607,8 @@ void Scene_BrushConstructPrefab(scene::Graph& graph, EBrushPrefab type, std::siz
     Brush* brush = Node_getBrush(path.top());
     if(brush != 0)
     {
     Brush* brush = Node_getBrush(path.top());
     if(brush != 0)
     {
-      AABB bounds = brush->localAABB();
-      TextureProjection projection;
-      TexDef_Construct_Default(projection);
-      Brush_ConstructPrefab(*brush, type, bounds, sides, shader, projection);
+      AABB bounds = brush->localAABB(); // copy bounds because the brush will be modified
+      Brush_ConstructPrefab(*brush, type, bounds, sides, shader, TextureTransform_getDefault());
       SceneChangeNotify();
     }
   }
       SceneChangeNotify();
     }
   }
@@ -786,9 +623,7 @@ void Scene_BrushResize_Selected(scene::Graph& graph, const AABB& bounds, const c
     Brush* brush = Node_getBrush(path.top());
     if(brush != 0)
     {
     Brush* brush = Node_getBrush(path.top());
     if(brush != 0)
     {
-      TextureProjection projection;
-      TexDef_Construct_Default(projection);
-      Brush_ConstructCuboid(*brush, bounds, shader, projection);
+      Brush_ConstructCuboid(*brush, bounds, shader, TextureTransform_getDefault());
       SceneChangeNotify();
     }
   }
       SceneChangeNotify();
     }
   }
@@ -833,15 +668,15 @@ void Scene_BrushSelectByShader(scene::Graph& graph, const char* name)
   graph.traverse(BrushSelectByShaderWalker(name));
 }
 
   graph.traverse(BrushSelectByShaderWalker(name));
 }
 
-class FaceSelectByShaderVisitor : public BrushInstanceVisitor
+class FaceSelectByShader
 {
   const char* m_name;
 public:
 {
   const char* m_name;
 public:
-  FaceSelectByShaderVisitor(const char* name)
+  FaceSelectByShader(const char* name)
     : m_name(name)
   {
   }
     : m_name(name)
   {
   }
-  void visit(FaceInstance& face) const
+  void operator()(FaceInstance& face) const
   {
     if(shader_equal(face.getFace().GetShader(), m_name))
     {
   {
     if(shader_equal(face.getFace().GetShader(), m_name))
     {
@@ -852,24 +687,24 @@ public:
 
 void Scene_BrushSelectByShader_Component(scene::Graph& graph, const char* name)
 {
 
 void Scene_BrushSelectByShader_Component(scene::Graph& graph, const char* name)
 {
-  Scene_ForEachSelectedBrush_ForEachFaceInstance(graph, FaceSelectByShaderVisitor(name));
+  Scene_ForEachSelectedBrush_ForEachFaceInstance(graph, FaceSelectByShader(name));
 }
 
 }
 
-class FaceGetTexdefVisitor
+class FaceGetTexdef
 {
   TextureProjection& m_projection;
   mutable bool m_done;
 public:
 {
   TextureProjection& m_projection;
   mutable bool m_done;
 public:
-  FaceGetTexdefVisitor(TextureProjection& projection)
+  FaceGetTexdef(TextureProjection& projection)
     : m_projection(projection), m_done(false)
   {
   }
     : m_projection(projection), m_done(false)
   {
   }
-  void visit(Face& face) const
+  void operator()(Face& face) const
   {
     if(!m_done)
     {
       m_done = true;
   {
     if(!m_done)
     {
       m_done = true;
-      FaceTexdef_getTexdef(face.getTexdef(), m_projection);
+      face.GetTexdef(m_projection);
     }
   }
 };
     }
   }
 };
@@ -877,8 +712,7 @@ public:
 
 void Scene_BrushGetTexdef_Selected(scene::Graph& graph, TextureProjection& projection)
 {
 
 void Scene_BrushGetTexdef_Selected(scene::Graph& graph, TextureProjection& projection)
 {
-  FaceGetTexdefVisitor visitor(projection);
-  Scene_ForEachSelectedBrush_ForEachFace(graph, visitor);
+  Scene_ForEachSelectedBrush_ForEachFace(graph, FaceGetTexdef(projection));
 }
 
 void Scene_BrushGetTexdef_Component_Selected(scene::Graph& graph, TextureProjection& projection)
 }
 
 void Scene_BrushGetTexdef_Component_Selected(scene::Graph& graph, TextureProjection& projection)
@@ -887,30 +721,30 @@ void Scene_BrushGetTexdef_Component_Selected(scene::Graph& graph, TextureProject
   if(!g_SelectedFaceInstances.empty())
   {
     FaceInstance& faceInstance = g_SelectedFaceInstances.last();
   if(!g_SelectedFaceInstances.empty())
   {
     FaceInstance& faceInstance = g_SelectedFaceInstances.last();
-    FaceTexdef_getTexdef(faceInstance.getFace().getTexdef(), projection);
+    faceInstance.getFace().GetTexdef(projection);
   }
 #else
   }
 #else
-  FaceGetTexdefVisitor visitor(projection);
+  FaceGetTexdef visitor(projection);
   Scene_ForEachSelectedBrushFace(graph, visitor);
 #endif
 }
 
 
   Scene_ForEachSelectedBrushFace(graph, visitor);
 #endif
 }
 
 
-class FaceGetFlagsVisitor
+class FaceGetFlags
 {
   ContentsFlagsValue& m_flags;
   mutable bool m_done;
 public:
 {
   ContentsFlagsValue& m_flags;
   mutable bool m_done;
 public:
-  FaceGetFlagsVisitor(ContentsFlagsValue& flags)
+  FaceGetFlags(ContentsFlagsValue& flags)
     : m_flags(flags), m_done(false)
   {
   }
     : m_flags(flags), m_done(false)
   {
   }
-  void visit(Face& face) const
+  void operator()(Face& face) const
   {
     if(!m_done)
     {
       m_done = true;
   {
     if(!m_done)
     {
       m_done = true;
-      FaceShader_getFlags(face.getShader(), m_flags);
+      face.GetFlags(m_flags);
     }
   }
 };
     }
   }
 };
@@ -918,8 +752,18 @@ public:
 
 void Scene_BrushGetFlags_Selected(scene::Graph& graph, ContentsFlagsValue& flags)
 {
 
 void Scene_BrushGetFlags_Selected(scene::Graph& graph, ContentsFlagsValue& flags)
 {
-  FaceGetFlagsVisitor visitor(flags);
-  Scene_ForEachSelectedBrush_ForEachFace(graph, visitor);
+#if 1
+  if(GlobalSelectionSystem().countSelected() != 0)
+  {
+    BrushInstance* brush = Instance_getBrush(GlobalSelectionSystem().ultimateSelected());
+    if(brush != 0)
+    {
+      Brush_forEachFace(*brush, FaceGetFlags(flags));
+    }
+  }
+#else
+  Scene_ForEachSelectedBrush_ForEachFace(graph, FaceGetFlags(flags));
+#endif
 }
 
 void Scene_BrushGetFlags_Component_Selected(scene::Graph& graph, ContentsFlagsValue& flags)
 }
 
 void Scene_BrushGetFlags_Component_Selected(scene::Graph& graph, ContentsFlagsValue& flags)
@@ -928,38 +772,47 @@ void Scene_BrushGetFlags_Component_Selected(scene::Graph& graph, ContentsFlagsVa
   if(!g_SelectedFaceInstances.empty())
   {
     FaceInstance& faceInstance = g_SelectedFaceInstances.last();
   if(!g_SelectedFaceInstances.empty())
   {
     FaceInstance& faceInstance = g_SelectedFaceInstances.last();
-    FaceShader_getFlags(faceInstance.getFace().getShader(), flags);
+    faceInstance.getFace().GetFlags(flags);
   }
 #else
   }
 #else
-  FaceGetFlagsVisitor visitor(flags);
-  Scene_ForEachSelectedBrushFace(graph, visitor);
+  Scene_ForEachSelectedBrushFace(graph, FaceGetFlags(flags));
 #endif
 }
 
 
 #endif
 }
 
 
-class FaceGetShaderVisitor
+class FaceGetShader
 {
   CopiedString& m_shader;
   mutable bool m_done;
 public:
 {
   CopiedString& m_shader;
   mutable bool m_done;
 public:
-  FaceGetShaderVisitor(CopiedString& shader)
+  FaceGetShader(CopiedString& shader)
     : m_shader(shader), m_done(false)
   {
   }
     : m_shader(shader), m_done(false)
   {
   }
-  void visit(Face& face) const
+  void operator()(Face& face) const
   {
     if(!m_done)
     {
       m_done = true;
   {
     if(!m_done)
     {
       m_done = true;
-      m_shader = face.getShader().getShader();
+      m_shader = face.GetShader();
     }
   }
 };
 
 void Scene_BrushGetShader_Selected(scene::Graph& graph, CopiedString& shader)
 {
     }
   }
 };
 
 void Scene_BrushGetShader_Selected(scene::Graph& graph, CopiedString& shader)
 {
-  FaceGetShaderVisitor visitor(shader);
-  Scene_ForEachSelectedBrush_ForEachFace(graph, visitor);
+#if 1
+  if(GlobalSelectionSystem().countSelected() != 0)
+  {
+    BrushInstance* brush = Instance_getBrush(GlobalSelectionSystem().ultimateSelected());
+    if(brush != 0)
+    {
+      Brush_forEachFace(*brush, FaceGetShader(shader));
+    }
+  }
+#else
+  Scene_ForEachSelectedBrush_ForEachFace(graph, FaceGetShader(shader));
+#endif
 }
 
 void Scene_BrushGetShader_Component_Selected(scene::Graph& graph, CopiedString& shader)
 }
 
 void Scene_BrushGetShader_Component_Selected(scene::Graph& graph, CopiedString& shader)
@@ -968,10 +821,10 @@ void Scene_BrushGetShader_Component_Selected(scene::Graph& graph, CopiedString&
   if(!g_SelectedFaceInstances.empty())
   {
     FaceInstance& faceInstance = g_SelectedFaceInstances.last();
   if(!g_SelectedFaceInstances.empty())
   {
     FaceInstance& faceInstance = g_SelectedFaceInstances.last();
-    shader = faceInstance.getFace().getShader().getShader();
+    shader = faceInstance.getFace().GetShader();
   }
 #else
   }
 #else
-  FaceGetShaderVisitor visitor(shader);
+  FaceGetShader visitor(shader);
   Scene_ForEachSelectedBrushFace(graph, visitor);
 #endif
 }
   Scene_ForEachSelectedBrushFace(graph, visitor);
 #endif
 }
@@ -1031,16 +884,16 @@ public:
 
 
 
 
 
 
-class FaceFilterAnyVisitor : public BrushVisitor
+class FaceFilterAny
 {
   FaceFilter* m_filter;
   bool& m_filtered;
 public:
 {
   FaceFilter* m_filter;
   bool& m_filtered;
 public:
-  FaceFilterAnyVisitor(FaceFilter* filter, bool& filtered) : m_filter(filter), m_filtered(filtered)
+  FaceFilterAny(FaceFilter* filter, bool& filtered) : m_filter(filter), m_filtered(filtered)
   {
     m_filtered = false;
   }
   {
     m_filtered = false;
   }
-  void visit(Face& face) const
+  void operator()(Face& face) const
   {
     if(m_filter->filter(face))
     {
   {
     if(m_filter->filter(face))
     {
@@ -1059,21 +912,21 @@ public:
   bool filter(const Brush& brush) const
   {
     bool filtered;
   bool filter(const Brush& brush) const
   {
     bool filtered;
-    brush.forEachFace(FaceFilterAnyVisitor(m_filter, filtered));
+    Brush_forEachFace(brush, FaceFilterAny(m_filter, filtered));
     return filtered;
   }   
 };
 
     return filtered;
   }   
 };
 
-class FaceFilterAllVisitor : public BrushVisitor
+class FaceFilterAll
 {
   FaceFilter* m_filter;
   bool& m_filtered;
 public:
 {
   FaceFilter* m_filter;
   bool& m_filtered;
 public:
-  FaceFilterAllVisitor(FaceFilter* filter, bool& filtered) : m_filter(filter), m_filtered(filtered)
+  FaceFilterAll(FaceFilter* filter, bool& filtered) : m_filter(filter), m_filtered(filtered)
   {
     m_filtered = true;
   }
   {
     m_filtered = true;
   }
-  void visit(Face& face) const
+  void operator()(Face& face) const
   {
     if(!m_filter->filter(face))
     {
   {
     if(!m_filter->filter(face))
     {
@@ -1092,7 +945,7 @@ public:
   bool filter(const Brush& brush) const
   {
     bool filtered;
   bool filter(const Brush& brush) const
   {
     bool filtered;
-    brush.forEachFace(FaceFilterAllVisitor(m_filter, filtered));
+    Brush_forEachFace(brush, FaceFilterAll(m_filter, filtered));
     return filtered;
   }   
 };
     return filtered;
   }   
 };
@@ -1602,7 +1455,7 @@ bool Scene_BrushGetClosestFaceTexture(scene::Graph& graph, SelectionTest& test,
   if(face != 0)
   {
     shader = face->GetShader();
   if(face != 0)
   {
     shader = face->GetShader();
-    FaceTexdef_getTexdef(face->getTexdef(), projection);
+    face->GetTexdef(projection);
     flags = face->getShader().m_flags;
     return true;
   }
     flags = face->getShader().m_flags;
     return true;
   }
@@ -1671,7 +1524,7 @@ void SelectedFaces_copyTexture()
   if(!g_SelectedFaceInstances.empty())
   {
     Face& face = g_SelectedFaceInstances.last().getFace();
   if(!g_SelectedFaceInstances.empty())
   {
     Face& face = g_SelectedFaceInstances.last().getFace();
-    FaceTexdef_getTexdef(face.getTexdef(), g_faceTextureClipboard.m_projection);
+    face.GetTexdef(g_faceTextureClipboard.m_projection);
     g_faceTextureClipboard.m_flags = face.getShader().m_flags;
 
     TextureBrowser_SetSelectedShader(g_TextureBrowser, face.getShader().getShader());
     g_faceTextureClipboard.m_flags = face.getShader().m_flags;
 
     TextureBrowser_SetSelectedShader(g_TextureBrowser, face.getShader().getShader());
index 9c41f7a3037117d783b24e9aab37d0b47df756ee..2c5cb9518ec7de39c90dc61d509e39d71b1b4d10 100644 (file)
@@ -22,7 +22,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #if !defined (INCLUDED_BRUSHWRAPPER_H)
 #define INCLUDED_BRUSHWRAPPER_H
 
 #if !defined (INCLUDED_BRUSHWRAPPER_H)
 #define INCLUDED_BRUSHWRAPPER_H
 
-#include "string/string.h"
+#include <cstddef>
+#include "string/stringfwd.h"
+#include "generic/callbackfwd.h"
 
 enum EBrushPrefab
 {
 
 enum EBrushPrefab
 {
@@ -67,8 +69,6 @@ void Scene_BrushSelectByShader_Component(scene::Graph& graph, const char* name);
 void Scene_BrushFitTexture_Selected(scene::Graph& graph, float s_repeat, float t_repeat);
 void Scene_BrushFitTexture_Component_Selected(scene::Graph& graph, float s_repeat, float t_repeat);
 
 void Scene_BrushFitTexture_Selected(scene::Graph& graph, float s_repeat, float t_repeat);
 void Scene_BrushFitTexture_Component_Selected(scene::Graph& graph, float s_repeat, float t_repeat);
 
-class Callback;
-
 typedef struct _GtkMenu GtkMenu;
 void Brush_constructMenu(GtkMenu* menu);
 
 typedef struct _GtkMenu GtkMenu;
 void Brush_constructMenu(GtkMenu* menu);
 
index ae9d8126c12211d1cc3ad49c005d9fdb3c778a40..e289f3ccb1e161f1bfa58be1f61043f99170b42d 100644 (file)
@@ -157,6 +157,21 @@ void Brush_clipperColourChanged()
   BrushClipPlane::constructStatic();
 }
 
   BrushClipPlane::constructStatic();
 }
 
+void BrushFaceData_fromFace(const BrushFaceDataCallback& callback, Face& face)
+{
+  _QERFaceData faceData;
+  faceData.m_p0 = face.getPlane().planePoints()[0];
+  faceData.m_p1 = face.getPlane().planePoints()[1];
+  faceData.m_p2 = face.getPlane().planePoints()[2];
+  faceData.m_shader = face.GetShader();
+  faceData.m_texdef = face.getTexdef().m_projection.m_texdef;
+  faceData.contents = face.getShader().m_flags.m_contentFlags;
+  faceData.flags = face.getShader().m_flags.m_surfaceFlags;
+  faceData.value = face.getShader().m_flags.m_value;
+  callback(faceData);
+}
+typedef ConstReferenceCaller1<BrushFaceDataCallback, Face&, BrushFaceData_fromFace> BrushFaceDataFromFaceCaller;
+typedef Callback1<Face&> FaceCallback;
 
 class Quake3BrushCreator : public BrushCreator
 {
 
 class Quake3BrushCreator : public BrushCreator
 {
@@ -169,6 +184,14 @@ public:
   {
     return g_useAlternativeTextureProjection.m_value;
   }
   {
     return g_useAlternativeTextureProjection.m_value;
   }
+  void forEachBrushFace(scene::Node& brush, const BrushFaceDataCallback& callback)
+  {
+    Brush_forEachFace(*Node_getBrush(brush), FaceCallback(BrushFaceDataFromFaceCaller(callback)));
+  }
+  bool addBrushFace(scene::Node& brush, const _QERFaceData& faceData)
+  {
+    return Node_getBrush(brush)->addPlane(faceData.m_p0, faceData.m_p1, faceData.m_p2, faceData.m_shader, TextureProjection(faceData.m_texdef, brushprimit_texdef_t(), Vector3(0, 0, 0), Vector3(0, 0, 0))) != 0;
+  }
 };
 
 Quake3BrushCreator g_Quake3BrushCreator;
 };
 
 Quake3BrushCreator g_Quake3BrushCreator;
index 04de6b4099d3dae336462f80c46bfd24c64fc377..62e209b8b58a77e7d2410c88c53424ae383a0da9 100644 (file)
@@ -37,7 +37,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #include "renderable.h"
 #include "preferencesystem.h"
 
 #include "renderable.h"
 #include "preferencesystem.h"
 
-#include "generic/callback.h"
+#include "signal/signal.h"
 #include "container/array.h"
 #include "scenelib.h"
 #include "render.h"
 #include "container/array.h"
 #include "scenelib.h"
 #include "render.h"
@@ -60,16 +60,16 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
 #include "timer.h"
 
 
 #include "timer.h"
 
-std::vector<Callback> g_cameraMoved_callbacks;
+Signal0 g_cameraMoved_callbacks;
 
 
-void AddCameraMovedCallback(const Callback& callback)
+void AddCameraMovedCallback(const SignalHandler& handler)
 {
 {
-  g_cameraMoved_callbacks.push_back(callback);
+  g_cameraMoved_callbacks.connectLast(handler);
 }
 
 void CameraMovedNotify()
 {
 }
 
 void CameraMovedNotify()
 {
-  std::for_each(g_cameraMoved_callbacks.begin(), g_cameraMoved_callbacks.end(), CallbackInvoke());
+  g_cameraMoved_callbacks();
 }
 
 
 }
 
 
@@ -1120,6 +1120,7 @@ void CamWnd_Move_Discrete_Import(bool value)
 }
 
 
 }
 
 
+
 void CamWnd_Add_Handlers_Move(CamWnd& camwnd)
 {
   camwnd.m_selection_button_press_handler = g_signal_connect(G_OBJECT(camwnd.m_gl_widget), "button_press_event", G_CALLBACK(selection_button_press), camwnd.m_window_observer);
 void CamWnd_Add_Handlers_Move(CamWnd& camwnd)
 {
   camwnd.m_selection_button_press_handler = g_signal_connect(G_OBJECT(camwnd.m_gl_widget), "button_press_event", G_CALLBACK(selection_button_press), camwnd.m_window_observer);
index 66f4bfac23d80cebd18f7eaca20ca2259779facf..2c8c59f72161cbc3f7ebfb9cf886661299d6337c 100644 (file)
@@ -23,6 +23,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #define INCLUDED_CAMWINDOW_H
 
 #include "math/vector.h"
 #define INCLUDED_CAMWINDOW_H
 
 #include "math/vector.h"
+#include "signal/signalfwd.h"
 
 typedef struct _GtkWidget GtkWidget;
 typedef struct _GtkWindow GtkWindow;
 
 typedef struct _GtkWidget GtkWidget;
 typedef struct _GtkWindow GtkWindow;
@@ -31,8 +32,7 @@ class CamWnd;
 CamWnd* NewCamWnd();
 void DeleteCamWnd(CamWnd* camwnd);
 
 CamWnd* NewCamWnd();
 void DeleteCamWnd(CamWnd* camwnd);
 
-class Callback;
-void AddCameraMovedCallback(const Callback& callback);
+void AddCameraMovedCallback(const SignalHandler& handler);
 
 void CamWnd_Update(CamWnd& camwnd);
 
 
 void CamWnd_Update(CamWnd& camwnd);
 
index c8a5fbd44325120ed3b2782a3b1f08e67c477dce..34029f6be121d3eccee13d04b87fdc72e7a6b694 100644 (file)
@@ -30,26 +30,42 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #include "brushnode.h"
 #include "grid.h"
 
 #include "brushnode.h"
 #include "grid.h"
 
-
-
-void Brush_makeHollow(const Brush& brush, brush_vector_t& out, float offset)
+void Face_makeBrush(Face& face, const Brush& brush, brush_vector_t& out, float offset)
 {
 {
-  for(Brush::const_iterator i(brush.begin()); i != brush.end(); ++i)
+  if(face.contributes())
   {
   {
-    if((*i)->contributes())
+    out.push_back(new Brush(brush));
+    Face* newFace = out.back()->addFace(face);
+    if(newFace != 0)
     {
     {
-      out.push_back(new Brush(brush));
-      Face* newFace = out.back()->addFace(*(*i));
-      if(newFace != 0)
-      {
-        newFace->flipWinding();
-        newFace->getPlane().offset(offset);
-        newFace->planeChanged();
-      }
+      newFace->flipWinding();
+      newFace->getPlane().offset(offset);
+      newFace->planeChanged();
     }
   }
 }
 
     }
   }
 }
 
+class FaceMakeBrush
+{
+  const Brush& brush;
+  brush_vector_t& out;
+  float offset;
+public:
+  FaceMakeBrush(const Brush& brush, brush_vector_t& out, float offset)
+    : brush(brush), out(out), offset(offset)
+  {
+  }
+  void operator()(Face& face) const
+  {
+    Face_makeBrush(face, brush, out, offset);
+  }
+};
+
+void Brush_makeHollow(const Brush& brush, brush_vector_t& out, float offset)
+{
+  Brush_forEachFace(brush, FaceMakeBrush(brush, out, offset));
+}
+
 class BrushHollowSelectedWalker : public scene::Graph::Walker
 {
   float m_offset;
 class BrushHollowSelectedWalker : public scene::Graph::Walker
 {
   float m_offset;
@@ -71,8 +87,8 @@ public:
         Brush_makeHollow(*brush, out, m_offset);
         for(brush_vector_t::const_iterator i = out.begin(); i != out.end(); ++i)
         {
         Brush_makeHollow(*brush, out, m_offset);
         for(brush_vector_t::const_iterator i = out.begin(); i != out.end(); ++i)
         {
-          NodeSmartReference node((new BrushNode())->node());
           (*i)->removeEmptyFaces();
           (*i)->removeEmptyFaces();
+          NodeSmartReference node((new BrushNode())->node());
           Node_getBrush(node)->copy(*(*i));
           delete (*i);
           Node_getTraversable(path.parent())->insert(node);
           Node_getBrush(node)->copy(*(*i));
           delete (*i);
           Node_getTraversable(path.parent())->insert(node);
@@ -151,6 +167,86 @@ void CSG_MakeHollow (void)
   SceneChangeNotify();
 }
 
   SceneChangeNotify();
 }
 
+template<typename Functor>
+class Dereference
+{
+  const Functor& functor;
+public:
+  typedef typename Functor::first_argument_type first_argument_type;
+  typedef typename Functor::result_type result_type;
+  Dereference(const Functor& functor) : functor(functor)
+  {
+  }
+  result_type operator()(first_argument_type firstArgument) const
+  {
+    return functor(*firstArgument);
+  }
+};
+
+template<typename Functor>
+inline Dereference<Functor> makeDereference(const Functor& functor)
+{
+  return Dereference<Functor>(functor);
+}
+
+template<typename Predicate>
+Face* Brush_findIf(const Brush& brush, const Predicate& predicate)
+{
+  Brush::const_iterator i = std::find_if(brush.begin(), brush.end(), makeDereference(predicate));
+  return i == brush.end() ? 0 : *i;
+}
+
+template<typename Caller>
+class BindArguments1
+{
+  typedef typename Caller::SecondArgument FirstBound;
+  FirstBound firstBound;
+public:
+  typedef typename Caller::Return Return;
+  typedef typename Caller::FirstArgument FirstArgument;
+  BindArguments1(FirstBound firstBound)
+    : firstBound(firstBound)
+  {
+  }
+  Return operator()(FirstArgument firstArgument) const
+  {
+    return Caller::call(firstArgument, firstBound);
+  }
+};
+
+template<typename Caller>
+class BindArguments2
+{
+  typedef typename Caller::SecondArgument FirstBound;
+  typedef typename Caller::ThirdArgument SecondBound;
+  FirstBound firstBound;
+  SecondBound secondBound;
+public:
+  typedef typename Caller::Return Return;
+  typedef typename Caller::FirstArgument FirstArgument;
+  BindArguments2(FirstBound firstBound, SecondBound secondBound)
+    : firstBound(firstBound), secondBound(secondBound)
+  {
+  }
+  Return operator()(FirstArgument firstArgument) const
+  {
+    return Caller::call(firstArgument, firstBound, secondBound);
+  }
+};
+
+template<typename Caller, typename FirstBound, typename SecondBound>
+BindArguments2<Caller> bindArguments(const Caller& caller, FirstBound firstBound, SecondBound secondBound)
+{
+  return BindArguments2<Caller>(firstBound, secondBound);
+}
+
+inline bool Face_testPlane(const Face& face, const Plane3& plane, bool flipped)
+{
+  return face.contributes() && !Winding_TestPlane(face.getWinding(), plane, flipped);
+}
+typedef Function3<const Face&, const Plane3&, bool, bool, Face_testPlane> FaceTestPlane;
+
+
 
 /// \brief Returns true if
 /// \li !flipped && brush is BACK or ON
 
 /// \brief Returns true if
 /// \li !flipped && brush is BACK or ON
@@ -158,14 +254,18 @@ void CSG_MakeHollow (void)
 bool Brush_testPlane(const Brush& brush, const Plane3& plane, bool flipped)
 {
   brush.evaluateBRep();
 bool Brush_testPlane(const Brush& brush, const Plane3& plane, bool flipped)
 {
   brush.evaluateBRep();
+#if 1
   for(Brush::const_iterator i(brush.begin()); i != brush.end(); ++i)
   {
   for(Brush::const_iterator i(brush.begin()); i != brush.end(); ++i)
   {
-    if((*i)->contributes() && !Winding_TestPlane((*i)->getWinding(), plane, flipped))
+    if(Face_testPlane(*(*i), plane, flipped))
     {
       return false;
     }
   }
   return true;
     {
       return false;
     }
   }
   return true;
+#else
+  return Brush_findIf(brush, bindArguments(FaceTestPlane(), makeReference(plane), flipped)) == 0;
+#endif
 }
 
 brushsplit_t Brush_classifyPlane(const Brush& brush, const Plane3& plane)
 }
 
 brushsplit_t Brush_classifyPlane(const Brush& brush, const Plane3& plane)
index e57dae78d25e3d767fb0f134c478f924bc959b77..0240e6757208ab980ade270628a4262939a6f09d 100644 (file)
@@ -676,7 +676,7 @@ void Dialog::addRadioIcons(GtkWidget* vbox, const char* name, int& data, StringA
   addRadioIcons(vbox, name, icons, IntImportCaller(data), IntExportCaller(data));
 }
 
   addRadioIcons(vbox, name, icons, IntImportCaller(data), IntExportCaller(data));
 }
 
-GtkWidget* Dialog::addEntry(GtkWidget* vbox, const char* name, const IntImportCallback& importViewer, const IntExportCallback& exportViewer)
+GtkWidget* Dialog::addIntEntry(GtkWidget* vbox, const char* name, const IntImportCallback& importViewer, const IntExportCallback& exportViewer)
 {
   DialogEntryRow row(DialogEntryRow_new(name));
   AddIntEntryData(*row.m_entry, importViewer, exportViewer);
 {
   DialogEntryRow row(DialogEntryRow_new(name));
   AddIntEntryData(*row.m_entry, importViewer, exportViewer);
@@ -684,7 +684,7 @@ GtkWidget* Dialog::addEntry(GtkWidget* vbox, const char* name, const IntImportCa
   return row.m_row;
 }
 
   return row.m_row;
 }
 
-GtkWidget* Dialog::addEntry(GtkWidget* vbox, const char* name, const SizeImportCallback& importViewer, const SizeExportCallback& exportViewer)
+GtkWidget* Dialog::addSizeEntry(GtkWidget* vbox, const char* name, const SizeImportCallback& importViewer, const SizeExportCallback& exportViewer)
 {
   DialogEntryRow row(DialogEntryRow_new(name));
   AddSizeEntryData(*row.m_entry, importViewer, exportViewer);
 {
   DialogEntryRow row(DialogEntryRow_new(name));
   AddSizeEntryData(*row.m_entry, importViewer, exportViewer);
@@ -692,7 +692,7 @@ GtkWidget* Dialog::addEntry(GtkWidget* vbox, const char* name, const SizeImportC
   return row.m_row;
 }
 
   return row.m_row;
 }
 
-GtkWidget* Dialog::addEntry(GtkWidget* vbox, const char* name, const FloatImportCallback& importViewer, const FloatExportCallback& exportViewer)
+GtkWidget* Dialog::addFloatEntry(GtkWidget* vbox, const char* name, const FloatImportCallback& importViewer, const FloatExportCallback& exportViewer)
 {
   DialogEntryRow row(DialogEntryRow_new(name));
   AddFloatEntryData(*row.m_entry, importViewer, exportViewer);
 {
   DialogEntryRow row(DialogEntryRow_new(name));
   AddFloatEntryData(*row.m_entry, importViewer, exportViewer);
index 882985e3b3906a9f39de90415fa0a11878879cd6..d7ac94bda49eccf6894c89a57513ae143ade0c12 100644 (file)
@@ -159,20 +159,20 @@ public:
   void addRadio(GtkWidget* vbox, const char* name, int& data, StringArrayRange names);
   void addRadioIcons(GtkWidget* vbox, const char* name, StringArrayRange icons, const IntImportCallback& importCallback, const IntExportCallback& exportCallback);
   void addRadioIcons(GtkWidget* vbox, const char* name, int& data, StringArrayRange icons);
   void addRadio(GtkWidget* vbox, const char* name, int& data, StringArrayRange names);
   void addRadioIcons(GtkWidget* vbox, const char* name, StringArrayRange icons, const IntImportCallback& importCallback, const IntExportCallback& exportCallback);
   void addRadioIcons(GtkWidget* vbox, const char* name, int& data, StringArrayRange icons);
-  GtkWidget* addEntry(GtkWidget* vbox, const char* name, const IntImportCallback& importCallback, const IntExportCallback& exportCallback);
+  GtkWidget* addIntEntry(GtkWidget* vbox, const char* name, const IntImportCallback& importCallback, const IntExportCallback& exportCallback);
   GtkWidget* addEntry(GtkWidget* vbox, const char* name, int& data)
   {
   GtkWidget* addEntry(GtkWidget* vbox, const char* name, int& data)
   {
-    return addEntry(vbox, name, IntImportCaller(data), IntExportCaller(data));
+    return addIntEntry(vbox, name, IntImportCaller(data), IntExportCaller(data));
   }
   }
-  GtkWidget* addEntry(GtkWidget* vbox, const char* name, const SizeImportCallback& importCallback, const SizeExportCallback& exportCallback);
+  GtkWidget* addSizeEntry(GtkWidget* vbox, const char* name, const SizeImportCallback& importCallback, const SizeExportCallback& exportCallback);
   GtkWidget* addEntry(GtkWidget* vbox, const char* name, std::size_t& data)
   {
   GtkWidget* addEntry(GtkWidget* vbox, const char* name, std::size_t& data)
   {
-    return addEntry(vbox, name, SizeImportCaller(data), SizeExportCaller(data));
+    return addSizeEntry(vbox, name, SizeImportCaller(data), SizeExportCaller(data));
   }
   }
-  GtkWidget* addEntry(GtkWidget* vbox, const char* name, const FloatImportCallback& importCallback, const FloatExportCallback& exportCallback);
+  GtkWidget* addFloatEntry(GtkWidget* vbox, const char* name, const FloatImportCallback& importCallback, const FloatExportCallback& exportCallback);
   GtkWidget* addEntry(GtkWidget* vbox, const char* name, float& data)
   {
   GtkWidget* addEntry(GtkWidget* vbox, const char* name, float& data)
   {
-    return addEntry(vbox, name, FloatImportCaller(data), FloatExportCaller(data));
+    return addFloatEntry(vbox, name, FloatImportCaller(data), FloatExportCaller(data));
   }
   GtkWidget* addPathEntry(GtkWidget* vbox, const char* name, bool browse_directory, const StringImportCallback& importCallback, const StringExportCallback& exportCallback);
   GtkWidget* addPathEntry(GtkWidget* vbox, const char* name, CopiedString& data, bool directory);
   }
   GtkWidget* addPathEntry(GtkWidget* vbox, const char* name, bool browse_directory, const StringImportCallback& importCallback, const StringExportCallback& exportCallback);
   GtkWidget* addPathEntry(GtkWidget* vbox, const char* name, CopiedString& data, bool directory);
index aeaca03c74427d51fe97b79ce26abf60ec8b651d..5195b4e7bb98abb0038b05ae26d1cea2bf5b0c6a 100644 (file)
@@ -67,7 +67,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 /// skin            the VFS path to a skin file
 /// 
 /// 
 /// skin            the VFS path to a skin file
 /// 
 /// 
-/// flag attributes define a flag in the spawnflags key:          
+/// flag attributes define a flag in the "spawnflags" key:          
 ///
 ///   <flag
 ///     key="[flag name]"
 ///
 ///   <flag
 ///     key="[flag name]"
index 93595ac4f3bb1ab9bd69b2339c88bb2b2bf5a5e9..e93ce4016ec70a58f868b2fb85763f676b93f20e 100644 (file)
@@ -28,6 +28,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #include "preferencesystem.h"
 
 #include "gtkutil/widget.h"
 #include "preferencesystem.h"
 
 #include "gtkutil/widget.h"
+#include "signal/signal.h"
 #include "stringio.h"
 
 #include "gtkmisc.h"
 #include "stringio.h"
 
 #include "gtkmisc.h"
@@ -36,17 +37,17 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
 
 
 
 
 
-std::vector<Callback> g_gridChange_callbacks;
+Signal0 g_gridChange_callbacks;
 
 
-void AddGridChangeCallback(const Callback& callback)
+void AddGridChangeCallback(const SignalHandler& handler)
 {
 {
-  g_gridChange_callbacks.push_back(callback);
-  callback();
+  g_gridChange_callbacks.connectLast(handler);
+  handler();
 }
 
 void GridChangeNotify()
 {
 }
 
 void GridChangeNotify()
 {
-  std::for_each(g_gridChange_callbacks.begin(), g_gridChange_callbacks.end(), CallbackInvoke());
+  g_gridChange_callbacks();
 }
 
 enum GridPower
 }
 
 enum GridPower
index 02e664fe70e121db3c07b421317997e4cd02d9f8..cf2671e91913789fb83f645d13890147be6e7503 100644 (file)
@@ -22,11 +22,12 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #if !defined(INCLUDED_GRID_H)
 #define INCLUDED_GRID_H
 
 #if !defined(INCLUDED_GRID_H)
 #define INCLUDED_GRID_H
 
+#include "signal/signalfwd.h"
+
 float GetGridSize();
 int Grid_getPower();
 
 float GetGridSize();
 int Grid_getPower();
 
-class Callback;
-void AddGridChangeCallback(const Callback& callback);
+void AddGridChangeCallback(const SignalHandler& handler);
 
 void Grid_registerCommands();
 typedef struct _GtkMenu GtkMenu;
 
 void Grid_registerCommands();
 typedef struct _GtkMenu GtkMenu;
index d0b900012f9c197f7c29773a4ee9937a3f7da2da..ee4f8cbbafce75af07fe9a8fb2ec0ee81dfcca8f 100644 (file)
@@ -58,6 +58,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #include "cmdlib.h"
 #include "scenelib.h"
 #include "stream/stringstream.h"
 #include "cmdlib.h"
 #include "scenelib.h"
 #include "stream/stringstream.h"
+#include "signal/isignal.h"
 #include "os/path.h"
 #include "os/file.h"
 #include "eclasslib.h"
 #include "os/path.h"
 #include "os/file.h"
 #include "eclasslib.h"
@@ -181,7 +182,6 @@ void VFS_Destroy()
     Radiant_detachHomePathsObserver(g_VFSModuleObserver);
 }
 
     Radiant_detachHomePathsObserver(g_VFSModuleObserver);
 }
 
-
 // Home Paths
 
 void HomePaths_Realise()
 // Home Paths
 
 void HomePaths_Realise()
@@ -2631,6 +2631,16 @@ public:
 
 MainWindowActive g_MainWindowActive;
 
 
 MainWindowActive g_MainWindowActive;
 
+MouseEventHandlerId XYWindowMouseDown_connect(const MouseEventHandler& handler)
+{
+  return g_pParentWnd->GetXYWnd()->onMouseDown.connectFirst(handler);
+}
+
+void XYWindowMouseDown_disconnect(MouseEventHandlerId id)
+{
+  g_pParentWnd->GetXYWnd()->onMouseDown.disconnect(id);
+}
+
 // =============================================================================
 // MainFrame class
 
 // =============================================================================
 // MainFrame class
 
index ab8278e78f39decc33ea5d3c094919186a21580f..4fadaae5adc929349717e8a110aaeb4af34b71bc 100644 (file)
@@ -27,6 +27,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #include "gtkutil/widget.h"
 #include "string/string.h"
 
 #include "gtkutil/widget.h"
 #include "string/string.h"
 
+#include "qerplugin.h"
+
 class IPlugIn;
 class IToolbarButton;
 
 class IPlugIn;
 class IToolbarButton;
 
@@ -274,6 +276,7 @@ extern int (*GridStatus_getFarClipDistance)();
 extern bool (*GridStatus_getTextureLockEnabled)();
 void GridStatus_onTextureLockEnabledChanged();
 
 extern bool (*GridStatus_getTextureLockEnabled)();
 void GridStatus_onTextureLockEnabledChanged();
 
-
+MouseEventHandlerId XYWindowMouseDown_connect(const MouseEventHandler& handler);
+void XYWindowMouseDown_disconnect(MouseEventHandlerId id);
 
 #endif
 
 #endif
index c846ca7ea7e722aeb89b1a0b7bc581789eed0537..67f528ec30a7069331ebdd6a1014b99959b41c6d 100644 (file)
@@ -64,6 +64,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #include "modulesystem/singletonmodule.h"
 #include "modulesystem/moduleregistry.h"
 #include "stream/stringstream.h"
 #include "modulesystem/singletonmodule.h"
 #include "modulesystem/moduleregistry.h"
 #include "stream/stringstream.h"
+#include "signal/signal.h"
 
 #include "gtkutil/filechooser.h"
 #include "timer.h"
 
 #include "gtkutil/filechooser.h"
 #include "timer.h"
@@ -311,8 +312,7 @@ public:
   bool m_modified;
   void (*m_modified_changed)(const Map&);
 
   bool m_modified;
   void (*m_modified_changed)(const Map&);
 
-  typedef std::vector<Callback> MapValidCallbacks;
-  MapValidCallbacks m_mapValidCallbacks;
+  Signal0 m_mapValidCallbacks;
 
   WorldNode m_world_node; // "classname" "worldspawn" !
 
 
   WorldNode m_world_node; // "classname" "worldspawn" !
 
@@ -363,9 +363,9 @@ public:
 Map g_map;
 Map* g_currentMap = 0;
 
 Map g_map;
 Map* g_currentMap = 0;
 
-void Map_addValidCallback(Map& map, const Callback& callback)
+void Map_addValidCallback(Map& map, const SignalHandler& handler)
 {
 {
-  map.m_mapValidCallbacks.push_back(callback);
+  map.m_mapValidCallbacks.connectLast(handler);
 }
 
 bool Map_Valid(const Map& map)
 }
 
 bool Map_Valid(const Map& map)
@@ -376,7 +376,7 @@ bool Map_Valid(const Map& map)
 void Map_SetValid(Map& map, bool valid)
 {
   map.m_valid = valid;
 void Map_SetValid(Map& map, bool valid)
 {
   map.m_valid = valid;
-  std::for_each(map.m_mapValidCallbacks.begin(), map.m_mapValidCallbacks.end(), CallbackInvoke());
+  map.m_mapValidCallbacks();
 }
 
 
 }
 
 
@@ -1870,25 +1870,21 @@ void NewMap()
   }
 }
 
   }
 }
 
-void maps_directory(StringOutputStream& buffer)
+CopiedString g_mapsPath;
+
+const char* getMapsPath()
 {
 {
-  ASSERT_MESSAGE(!string_empty(g_qeglobals.m_userGamePath.c_str()), "maps_directory: user-game-path is empty");
-  buffer << g_qeglobals.m_userGamePath.c_str() << "maps/";
-  Q_mkdir(buffer.c_str());
+  return g_mapsPath.c_str();
 }
 
 const char* map_open(const char* title)
 {
 }
 
 const char* map_open(const char* title)
 {
-       StringOutputStream buf(256);
-  maps_directory(buf);
-  return file_dialog(GTK_WIDGET(MainFrame_getWindow()), TRUE, title, buf.c_str(), MapFormat::Name());
+  return file_dialog(GTK_WIDGET(MainFrame_getWindow()), TRUE, title, getMapsPath(), MapFormat::Name());
 }
 
 const char* map_save(const char* title)
 {
 }
 
 const char* map_save(const char* title)
 {
-       StringOutputStream buf(256);
-  maps_directory(buf);
-  return file_dialog(GTK_WIDGET(MainFrame_getWindow()), FALSE, title, buf.c_str(), MapFormat::Name());
+  return file_dialog(GTK_WIDGET(MainFrame_getWindow()), FALSE, title, getMapsPath(), MapFormat::Name());
 }
 
 void OpenMap()
 }
 
 void OpenMap()
@@ -2232,6 +2228,11 @@ void DoFind()
   gtk_widget_destroy(GTK_WIDGET(window));
 }
 
   gtk_widget_destroy(GTK_WIDGET(window));
 }
 
+void Map_constructPreferences(PreferencesPage& page)
+{
+  page.appendCheckBox("", "Load last map on open", g_bLoadLastMap);
+}
+
 
 class MapEntityClasses : public ModuleObserver
 {
 
 class MapEntityClasses : public ModuleObserver
 {
@@ -2267,10 +2268,34 @@ public:
 MapEntityClasses g_MapEntityClasses;
 
 
 MapEntityClasses g_MapEntityClasses;
 
 
-void Map_constructPreferences(PreferencesPage& page)
+class MapModuleObserver : public ModuleObserver
 {
 {
-  page.appendCheckBox("", "Load last map on open", g_bLoadLastMap);
-}
+  std::size_t m_unrealised;
+public:
+  MapModuleObserver() : m_unrealised(1)
+  {
+  }
+  void realise()
+  {
+    if(--m_unrealised == 0)
+    {
+      ASSERT_MESSAGE(!string_empty(g_qeglobals.m_userGamePath.c_str()), "maps_directory: user-game-path is empty");
+      StringOutputStream buffer(256);
+      buffer << g_qeglobals.m_userGamePath.c_str() << "maps/";
+      Q_mkdir(buffer.c_str());
+      g_mapsPath = buffer.c_str();
+    }
+  }
+  void unrealise()
+  {
+    if(++m_unrealised == 1)
+    {
+      g_mapsPath = "";
+    }
+  }
+};
+
+MapModuleObserver g_MapModuleObserver;
 
 #include "preferencesystem.h"
 
 
 #include "preferencesystem.h"
 
@@ -2291,9 +2316,11 @@ void Map_Construct()
   PreferencesDialog_addSettingsPreferences(FreeCaller1<PreferencesPage&, Map_constructPreferences>());
 
   GlobalEntityClassManager().attach(g_MapEntityClasses);
   PreferencesDialog_addSettingsPreferences(FreeCaller1<PreferencesPage&, Map_constructPreferences>());
 
   GlobalEntityClassManager().attach(g_MapEntityClasses);
+  Radiant_attachHomePathsObserver(g_MapModuleObserver);
 }
 
 void Map_Destroy()
 {
 }
 
 void Map_Destroy()
 {
+  Radiant_detachHomePathsObserver(g_MapModuleObserver);
   GlobalEntityClassManager().detach(g_MapEntityClasses);
 }
   GlobalEntityClassManager().detach(g_MapEntityClasses);
 }
index 5640afd1965d592f359ac6010ed8e5d58beafbf9..e74d89816e55840dda0b7b5a00a43e93ab7de128 100644 (file)
@@ -24,6 +24,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
 #include "iscenegraph.h"
 #include "generic/callback.h"
 
 #include "iscenegraph.h"
 #include "generic/callback.h"
+#include "signal/signalfwd.h"
 #include "string/stringfwd.h"
 
 class Map;
 #include "string/stringfwd.h"
 
 class Map;
@@ -31,7 +32,7 @@ extern Map g_map;
 
 class MapFormat;
 
 
 class MapFormat;
 
-void Map_addValidCallback(Map& map, const Callback& callback);
+void Map_addValidCallback(Map& map, const SignalHandler& handler);
 bool Map_Valid(const Map& map);
 
 class DeferredDraw
 bool Map_Valid(const Map& map);
 
 class DeferredDraw
index 0da6d69d41bbf3f49b51e6575efdc695c0bbfb66..80ffe35142058f2a07717ecec9fc926e72d8f1b0 100644 (file)
@@ -24,18 +24,19 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #include <glib/gslist.h>
 #include "preferences.h"
 #include "brush_primit.h"
 #include <glib/gslist.h>
 #include "preferences.h"
 #include "brush_primit.h"
+#include "signal/signal.h"
 
 
 
 
-std::set<Callback> g_patchTextureChangedCallbacks;
+Signal0 g_patchTextureChangedCallbacks;
 
 
-void Patch_addTextureChangedCallback(const Callback& callback)
+void Patch_addTextureChangedCallback(const SignalHandler& handler)
 {
 {
-  g_patchTextureChangedCallbacks.insert(callback);
+  g_patchTextureChangedCallbacks.connectLast(handler);
 }
 
 void Patch_textureChanged()
 {
 }
 
 void Patch_textureChanged()
 {
-  std::for_each(g_patchTextureChangedCallbacks.begin(), g_patchTextureChangedCallbacks.end(), CallbackInvoke());
+  g_patchTextureChangedCallbacks();
 }
 
 
 }
 
 
index ebb291fc3eea505175f2130a81273ef04e7bd5c3..614a4eb27e35a47924422b21954c8194739ced5c 100644 (file)
@@ -57,6 +57,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #include "stringio.h"
 #include "shaderlib.h"
 #include "generic/callback.h"
 #include "stringio.h"
 #include "shaderlib.h"
 #include "generic/callback.h"
+#include "signal/signalfwd.h"
 #include "texturelib.h"
 #include "xml/ixml.h"
 #include "dragplanes.h"
 #include "texturelib.h"
 #include "xml/ixml.h"
 #include "dragplanes.h"
@@ -164,7 +165,7 @@ public:
 bool patch_filtered(Patch& patch);
 void add_patch_filter(PatchFilter& filter, int mask, bool invert = false);
 
 bool patch_filtered(Patch& patch);
 void add_patch_filter(PatchFilter& filter, int mask, bool invert = false);
 
-void Patch_addTextureChangedCallback(const Callback& callback);
+void Patch_addTextureChangedCallback(const SignalHandler& handler);
 void Patch_textureChanged();
 
 inline void BezierCurveTreeArray_deleteAll(Array<BezierCurveTree*>& curveTrees)
 void Patch_textureChanged();
 
 inline void BezierCurveTreeArray_deleteAll(Array<BezierCurveTree*>& curveTrees)
index a8fb156985f832381bf355f25a4ab656865df015..04b2aed098357f09c681d61372a59ce340b4c3c3 100644 (file)
@@ -52,6 +52,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #include "patch.h"
 #include "commands.h"
 #include "preferences.h"
 #include "patch.h"
 #include "commands.h"
 #include "preferences.h"
+#include "signal/isignal.h"
 
 
 #include <gdk/gdkkeysyms.h>
 
 
 #include <gdk/gdkkeysyms.h>
index cd85e2a5658f77534ea4b4503c809c26fea31f64..1e57eeb3375701e02c78d628e90a1937f0f4a258 100644 (file)
@@ -93,11 +93,33 @@ const char* GameDescription_getRequiredKeyValue(const char* key)
   return g_pGameDescription->getRequiredKeyValue(key);
 }
 
   return g_pGameDescription->getRequiredKeyValue(key);
 }
 
-const char* mapname_get()
+const char* getMapName()
 {
   return Map_Name(g_map);
 }
 
 {
   return Map_Name(g_map);
 }
 
+scene::Node& getMapWorldEntity()
+{
+  return Map_FindOrInsertWorldspawn(g_map);
+}
+
+VIEWTYPE XYWindow_getViewType()
+{
+  return g_pParentWnd->GetXYWnd()->GetViewType();
+}
+
+Vector3 XYWindow_windowToWorld(const WindowVector& position)
+{
+  Vector3 result(0, 0, 0);
+  g_pParentWnd->GetXYWnd()->XY_ToPoint(static_cast<int>(position.x()), static_cast<int>(position.y()), result);
+  return result;
+}
+
+const char* TextureBrowser_getSelectedShader()
+{
+  return TextureBrowser_GetSelectedShader(GlobalTextureBrowser());
+}
+
 class RadiantCoreAPI
 {
   _QERFuncTable_1 m_radiantcore;
 class RadiantCoreAPI
 {
   _QERFuncTable_1 m_radiantcore;
@@ -115,7 +137,9 @@ public:
     m_radiantcore.getGameName = &gamename_get;
     m_radiantcore.getGameMode = &gamemode_get;
 
     m_radiantcore.getGameName = &gamename_get;
     m_radiantcore.getGameMode = &gamemode_get;
 
-    m_radiantcore.getMapName = &mapname_get;
+    m_radiantcore.getMapName = &getMapName;
+    m_radiantcore.getMapWorldEntity = getMapWorldEntity;
+    m_radiantcore.getGridSize = GetGridSize;
 
     m_radiantcore.getGameDescriptionKeyValue = &GameDescription_getKeyValue;
     m_radiantcore.getRequiredGameDescriptionKeyValue = &GameDescription_getRequiredKeyValue;
 
     m_radiantcore.getGameDescriptionKeyValue = &GameDescription_getKeyValue;
     m_radiantcore.getRequiredGameDescriptionKeyValue = &GameDescription_getRequiredKeyValue;
@@ -129,6 +153,12 @@ public:
     m_radiantcore.attachGameModeObserver = Radiant_attachGameModeObserver;
     m_radiantcore.detachGameModeObserver = Radiant_detachGameModeObserver;
 
     m_radiantcore.attachGameModeObserver = Radiant_attachGameModeObserver;
     m_radiantcore.detachGameModeObserver = Radiant_detachGameModeObserver;
 
+    m_radiantcore.XYWindowMouseDown_connect = XYWindowMouseDown_connect;
+    m_radiantcore.XYWindowMouseDown_disconnect = XYWindowMouseDown_disconnect;
+    m_radiantcore.XYWindow_getViewType = XYWindow_getViewType;
+    m_radiantcore.XYWindow_windowToWorld = XYWindow_windowToWorld;
+    m_radiantcore.TextureBrowser_getSelectedShader = TextureBrowser_getSelectedShader;
+
     m_radiantcore.m_pfnMessageBox = &gtk_MessageBox;
     m_radiantcore.m_pfnFileDialog = &file_dialog;
     m_radiantcore.m_pfnColorDialog = &color_dialog;
     m_radiantcore.m_pfnMessageBox = &gtk_MessageBox;
     m_radiantcore.m_pfnFileDialog = &file_dialog;
     m_radiantcore.m_pfnColorDialog = &color_dialog;
index 49c9a5e99e6094995bef14f8b024dab3e9d26bb6..497f183cbb4c1f1d9150d288ab3816c4b9c89ca3 100644 (file)
@@ -82,7 +82,7 @@ public:
   }
   GtkWidget* appendEntry(const char* name, const IntImportCallback& importCallback, const IntExportCallback& exportCallback)
   {
   }
   GtkWidget* appendEntry(const char* name, const IntImportCallback& importCallback, const IntExportCallback& exportCallback)
   {
-    return m_dialog.addEntry(m_vbox, name, importCallback, exportCallback);
+    return m_dialog.addIntEntry(m_vbox, name, importCallback, exportCallback);
   }
   GtkWidget* appendEntry(const char* name, int& data)
   {
   }
   GtkWidget* appendEntry(const char* name, int& data)
   {
@@ -90,7 +90,7 @@ public:
   }
   GtkWidget* appendEntry(const char* name, const SizeImportCallback& importCallback, const SizeExportCallback& exportCallback)
   {
   }
   GtkWidget* appendEntry(const char* name, const SizeImportCallback& importCallback, const SizeExportCallback& exportCallback)
   {
-    return m_dialog.addEntry(m_vbox, name, importCallback, exportCallback);
+    return m_dialog.addSizeEntry(m_vbox, name, importCallback, exportCallback);
   }
   GtkWidget* appendEntry(const char* name, std::size_t& data)
   {
   }
   GtkWidget* appendEntry(const char* name, std::size_t& data)
   {
@@ -98,7 +98,7 @@ public:
   }
   GtkWidget* appendEntry(const char* name, const FloatImportCallback& importCallback, const FloatExportCallback& exportCallback)
   {
   }
   GtkWidget* appendEntry(const char* name, const FloatImportCallback& importCallback, const FloatExportCallback& exportCallback)
   {
-    return m_dialog.addEntry(m_vbox, name, importCallback, exportCallback);
+    return m_dialog.addFloatEntry(m_vbox, name, importCallback, exportCallback);
   }
   GtkWidget* appendEntry(const char* name, float& data)
   {
   }
   GtkWidget* appendEntry(const char* name, float& data)
   {
index 84648d0363815ed4afd95aa72968a86a64d99048..b58cea4152f27e3f72643db2f446a42d2685ce3c 100644 (file)
@@ -28,7 +28,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #include <vector>
 
 #include "string/string.h"
 #include <vector>
 
 #include "string/string.h"
-#include "generic/callback.h"
+#include "signal/signal.h"
 #include "scenelib.h"
 #include "instancelib.h"
 #include "treemodel.h"
 #include "scenelib.h"
 #include "instancelib.h"
 #include "treemodel.h"
@@ -76,10 +76,9 @@ class CompiledGraph : public scene::Graph, public scene::Instantiable::Observer
 
   InstanceMap m_instances;
   scene::Instantiable::Observer* m_observer;
 
   InstanceMap m_instances;
   scene::Instantiable::Observer* m_observer;
-  typedef std::set<Callback> BoundsChangedCallbacks;
-  BoundsChangedCallbacks m_boundsChanged;
+  Signal0 m_boundsChanged;
   scene::Path m_rootpath;
   scene::Path m_rootpath;
-  std::vector<Callback> m_sceneChangedCallbacks;
+  Signal0 m_sceneChangedCallbacks;
 
   TypeIdMap<NODETYPEID_MAX> m_nodeTypeIds;
   TypeIdMap<INSTANCETYPEID_MAX> m_instanceTypeIds;
 
   TypeIdMap<NODETYPEID_MAX> m_nodeTypeIds;
   TypeIdMap<INSTANCETYPEID_MAX> m_instanceTypeIds;
@@ -91,13 +90,13 @@ public:
   {
   }
 
   {
   }
 
-  void addSceneChangedCallback(const Callback& callback)
+  void addSceneChangedCallback(const SignalHandler& handler)
   {
   {
-    m_sceneChangedCallbacks.push_back(callback);
+    m_sceneChangedCallbacks.connectLast(handler);
   }
   void sceneChanged()
   {
   }
   void sceneChanged()
   {
-    std::for_each(m_sceneChangedCallbacks.begin(), m_sceneChangedCallbacks.end(), CallbackInvoke());
+    m_sceneChangedCallbacks();
   }
 
   scene::Node& root()
   }
 
   scene::Node& root()
@@ -133,7 +132,7 @@ public:
   }
   void boundsChanged()
   {
   }
   void boundsChanged()
   {
-    std::for_each(m_boundsChanged.begin(), m_boundsChanged.end(), CallbackInvoke());
+    m_boundsChanged();
   }
 
   void traverse(const Walker& walker)
   }
 
   void traverse(const Walker& walker)
@@ -172,15 +171,13 @@ public:
     m_instances.erase(PathConstReference(instance->path()));
   }
 
     m_instances.erase(PathConstReference(instance->path()));
   }
 
-  void addBoundsChangedCallback(const Callback& boundsChanged)
+  SignalHandlerId addBoundsChangedCallback(const SignalHandler& boundsChanged)
   {
   {
-    ASSERT_MESSAGE(m_boundsChanged.find(boundsChanged) == m_boundsChanged.end(), "bounds-changed callback already registered");
-    m_boundsChanged.insert(boundsChanged);
+    return m_boundsChanged.connectLast(boundsChanged);
   }
   }
-  void removeBoundsChangedCallback(const Callback& boundsChanged)
+  void removeBoundsChangedCallback(SignalHandlerId id)
   {
   {
-    ASSERT_MESSAGE(m_boundsChanged.find(boundsChanged) != m_boundsChanged.end(), "bounds-changed callback not registered");
-    m_boundsChanged.erase(boundsChanged);
+    m_boundsChanged.disconnect(id);
   }
 
   TypeId getNodeTypeId(const char* name)
   }
 
   TypeId getNodeTypeId(const char* name)
index 36b2e3e86021186f62531d4c6a4d23756c32bf98..09f0709c83007a13d186a757f422d439c589ddf5 100644 (file)
@@ -30,6 +30,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #include <vector>
 
 #include "stream/stringstream.h"
 #include <vector>
 
 #include "stream/stringstream.h"
+#include "signal/isignal.h"
 #include "shaderlib.h"
 #include "scenelib.h"
 
 #include "shaderlib.h"
 #include "scenelib.h"
 
@@ -730,16 +731,18 @@ void SceneSelectionChange(const Selectable& selectable)
   SceneChangeNotify();
 }
 
   SceneChangeNotify();
 }
 
+SignalHandlerId Selection_boundsChanged;
+
 void Selection_construct()
 {
   GlobalSelectionSystem().addSelectionChangeCallback(FreeCaller1<const Selectable&, SceneSelectionChange>());
   GlobalSelectionSystem().addSelectionChangeCallback(FreeCaller1<const Selectable&, UpdateWorkzone_ForSelection>());
 void Selection_construct()
 {
   GlobalSelectionSystem().addSelectionChangeCallback(FreeCaller1<const Selectable&, SceneSelectionChange>());
   GlobalSelectionSystem().addSelectionChangeCallback(FreeCaller1<const Selectable&, UpdateWorkzone_ForSelection>());
-  GlobalSceneGraph().addBoundsChangedCallback(FreeCaller<UpdateWorkzone_ForSelection>());
+  Selection_boundsChanged = GlobalSceneGraph().addBoundsChangedCallback(FreeCaller<UpdateWorkzone_ForSelection>());
 }
 
 void Selection_destroy()
 {
 }
 
 void Selection_destroy()
 {
-  GlobalSceneGraph().removeBoundsChangedCallback(FreeCaller<UpdateWorkzone_ForSelection>());
+  GlobalSceneGraph().removeBoundsChangedCallback(Selection_boundsChanged);
 }
 
 
 }
 
 
index 15e7d14627d31aa236c3ddacb15f56bf77176565..e6142d4e28aed33b46480819147e667f1526d007 100644 (file)
@@ -36,7 +36,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #include "editable.h"
 
 #include "math/frustum.h"
 #include "editable.h"
 
 #include "math/frustum.h"
-#include "generic/callback.h"
+#include "signal/signal.h"
 #include "generic/object.h"
 #include "selectionlib.h"
 #include "render.h"
 #include "generic/object.h"
 #include "selectionlib.h"
 #include "render.h"
@@ -2797,7 +2797,7 @@ private:
   selection_t m_selection;
   selection_t m_component_selection;
 
   selection_t m_selection;
   selection_t m_component_selection;
 
-  std::vector<SelectionChangeCallback> m_selectionChanged_callbacks;
+  Signal1<const Selectable&> m_selectionChanged_callbacks;
 
   void ConstructPivot() const;
   mutable bool m_pivotChanged;
 
   void ConstructPivot() const;
   mutable bool m_pivotChanged;
@@ -2975,14 +2975,13 @@ public:
     }
   }
 
     }
   }
 
-  void addSelectionChangeCallback(const SelectionChangeCallback& callback)
+  void addSelectionChangeCallback(const SelectionChangeHandler& handler)
   {
   {
-    m_selectionChanged_callbacks.push_back(callback);
+    m_selectionChanged_callbacks.connectLast(handler);
   }
   void selectionChanged(const Selectable& selectable)
   {
   }
   void selectionChanged(const Selectable& selectable)
   {
-    typedef Functor1Invoke<SelectionChangeCallback, const Selectable&> SelectionChangeCallbackInvoke;
-    std::for_each(m_selectionChanged_callbacks.begin(), m_selectionChanged_callbacks.end(), SelectionChangeCallbackInvoke(selectable));
+    m_selectionChanged_callbacks(selectable);
   }
   typedef MemberCaller1<RadiantSelectionSystem, const Selectable&, &RadiantSelectionSystem::selectionChanged> SelectionChangedCaller;
 
   }
   typedef MemberCaller1<RadiantSelectionSystem, const Selectable&, &RadiantSelectionSystem::selectionChanged> SelectionChangedCaller;
 
@@ -3341,7 +3340,6 @@ namespace
 
   inline RadiantSelectionSystem& getSelectionSystem()
   {
 
   inline RadiantSelectionSystem& getSelectionSystem()
   {
-    ASSERT_NOTNULL(g_RadiantSelectionSystem);
     return *g_RadiantSelectionSystem;
   }
 }
     return *g_RadiantSelectionSystem;
   }
 }
@@ -3757,13 +3755,15 @@ void SelectionSystem_OnBoundsChanged()
 }
 
 
 }
 
 
+SignalHandlerId SelectionSystem_boundsChanged;
+
 void SelectionSystem_Construct()
 {
   RadiantSelectionSystem::constructStatic();
 
   g_RadiantSelectionSystem = new RadiantSelectionSystem;
 
 void SelectionSystem_Construct()
 {
   RadiantSelectionSystem::constructStatic();
 
   g_RadiantSelectionSystem = new RadiantSelectionSystem;
 
-  GlobalSceneGraph().addBoundsChangedCallback(FreeCaller<SelectionSystem_OnBoundsChanged>());
+  SelectionSystem_boundsChanged = GlobalSceneGraph().addBoundsChangedCallback(FreeCaller<SelectionSystem_OnBoundsChanged>());
 
   GlobalShaderCache().attachRenderable(getSelectionSystem());
 }
 
   GlobalShaderCache().attachRenderable(getSelectionSystem());
 }
@@ -3772,7 +3772,7 @@ void SelectionSystem_Destroy()
 {
   GlobalShaderCache().detachRenderable(getSelectionSystem());
 
 {
   GlobalShaderCache().detachRenderable(getSelectionSystem());
 
-  GlobalSceneGraph().removeBoundsChangedCallback(FreeCaller<SelectionSystem_OnBoundsChanged>());
+  GlobalSceneGraph().removeBoundsChangedCallback(SelectionSystem_boundsChanged);
 
   delete g_RadiantSelectionSystem;
 
 
   delete g_RadiantSelectionSystem;
 
index 429ac0f9f7996c75559231aeaff649412c574b36..8334ec63a95c04b0a60e881a88ec886ebb236f56 100644 (file)
@@ -23,6 +23,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #define INCLUDED_SELECTION_H
 
 #include "windowobserver.h"
 #define INCLUDED_SELECTION_H
 
 #include "windowobserver.h"
+#include "generic/callbackfwd.h"
 
 struct rect_t
 {
 
 struct rect_t
 {
@@ -30,12 +31,9 @@ struct rect_t
   float max[2];
 };
 
   float max[2];
 };
 
-template<typename FirstArgument>
-class Callback1;
 typedef Callback1<rect_t> RectangleCallback;
 
 class View;
 typedef Callback1<rect_t> RectangleCallback;
 
 class View;
-class Callback;
 
 class SelectionSystemWindowObserver : public WindowObserver
 {
 
 class SelectionSystemWindowObserver : public WindowObserver
 {
index b938dd03135070c60196d1b373eb88b2a3446034..1ec069515956999a373da1c8b079562cade440ba 100644 (file)
@@ -45,7 +45,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #include <gdk/gdkkeysyms.h>
 #include <gtk/gtkcheckbutton.h>        //Shamus: For Textool
 
 #include <gdk/gdkkeysyms.h>
 #include <gtk/gtkcheckbutton.h>        //Shamus: For Textool
 
-#include "generic/callback.h"
+#include "signal/isignal.h"
 #include "generic/object.h"
 #include "math/vector.h"
 #include "texturelib.h"
 #include "generic/object.h"
 #include "math/vector.h"
 #include "texturelib.h"
index 4325c09548af6be5c6f3c4b529c76acab966e5c8..3965fe29676d7f2b91133135da45b5818ad3eb39 100644 (file)
@@ -28,6 +28,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #include "gtkutil/idledraw.h"
 
 #include "generic/static.h"
 #include "gtkutil/idledraw.h"
 
 #include "generic/static.h"
+#include "signal/isignal.h"
 #include "shaderlib.h"
 
 #include "texwindow.h"
 #include "shaderlib.h"
 
 #include "texwindow.h"
@@ -100,7 +101,7 @@ public:
       }
     }
   }
       }
     }
   }
-  void connect(const Callback& update) const
+  void connect(const SignalHandler& update) const
   {
     TextureBrowser_addActiveShadersChangedCallback(update);
   }
   {
     TextureBrowser_addActiveShadersChangedCallback(update);
   }
@@ -116,7 +117,7 @@ public:
   {
     GlobalShaderSystem().foreachShaderName(callback);
   }
   {
     GlobalShaderSystem().foreachShaderName(callback);
   }
-  void connect(const Callback& update) const
+  void connect(const SignalHandler& update) const
   {
     TextureBrowser_addShadersRealiseCallback(update);
   }
   {
     TextureBrowser_addShadersRealiseCallback(update);
   }
index 02b45621223c37f5bc400f86ca3a6db4a9b1124d..0a570b7d3c3e79624d29d828e29ad01fbdea2a35 100644 (file)
@@ -22,11 +22,12 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #if !defined (INCLUDED_TEXTURES_H)
 #define INCLUDED_TEXTURES_H
 
 #if !defined (INCLUDED_TEXTURES_H)
 #define INCLUDED_TEXTURES_H
 
+#include "generic/callbackfwd.h"
+
 void Textures_Realise();
 void Textures_Unrealise();
 void Textures_sharedContextDestroyed();
 
 void Textures_Realise();
 void Textures_Unrealise();
 void Textures_sharedContextDestroyed();
 
-class Callback;
 void Textures_setModeChangedNotify(const Callback& notify);
 
 #endif
 void Textures_setModeChangedNotify(const Callback& notify);
 
 #endif
index 58285259667c9b55c5e5a17a5a3b91af2dd6a3b5..23374ec8df82b37c93186a6e6a12bfee3ec825bc 100644 (file)
@@ -53,7 +53,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #include <gtk/gtkvscrollbar.h>
 #include <gtk/gtkmenu.h>
 
 #include <gtk/gtkvscrollbar.h>
 #include <gtk/gtkmenu.h>
 
-#include "generic/callback.h"
+#include "signal/signal.h"
 #include "math/vector.h"
 #include "texturelib.h"
 #include "string/string.h"
 #include "math/vector.h"
 #include "texturelib.h"
 #include "string/string.h"
@@ -715,27 +715,27 @@ void TextureBrowser_setOriginY(TextureBrowser& textureBrowser, int originy)
 }
 
 
 }
 
 
-std::set<Callback> g_activeShadersChangedCallbacks;
+Signal0 g_activeShadersChangedCallbacks;
 
 
-void TextureBrowser_addActiveShadersChangedCallback(const Callback& callback)
+void TextureBrowser_addActiveShadersChangedCallback(const SignalHandler& handler)
 {
 {
-  g_activeShadersChangedCallbacks.insert(callback);
+  g_activeShadersChangedCallbacks.connectLast(handler);
 }
 
 class ShadersObserver : public ModuleObserver
 {
 }
 
 class ShadersObserver : public ModuleObserver
 {
-  std::set<Callback> m_realiseCallbacks;
+  Signal0 m_realiseCallbacks;
 public:
   void realise()
   {
 public:
   void realise()
   {
-    std::for_each(m_realiseCallbacks.begin(), m_realiseCallbacks.end(), CallbackInvoke());
+    m_realiseCallbacks();
   }
   void unrealise()
   {
   }
   }
   void unrealise()
   {
   }
-  void insert(const Callback& callback)
+  void insert(const SignalHandler& handler)
   {
   {
-    m_realiseCallbacks.insert(callback);
+    m_realiseCallbacks.connectLast(handler);
   }
 };
 
   }
 };
 
@@ -744,9 +744,9 @@ namespace
   ShadersObserver g_ShadersObserver;
 }
 
   ShadersObserver g_ShadersObserver;
 }
 
-void TextureBrowser_addShadersRealiseCallback(const Callback& callback)
+void TextureBrowser_addShadersRealiseCallback(const SignalHandler& handler)
 {
 {
-  g_ShadersObserver.insert(callback);
+  g_ShadersObserver.insert(handler);
 }
 
 void TextureBrowser_activeShadersChanged(TextureBrowser& textureBrowser)
 }
 
 void TextureBrowser_activeShadersChanged(TextureBrowser& textureBrowser)
@@ -754,7 +754,7 @@ void TextureBrowser_activeShadersChanged(TextureBrowser& textureBrowser)
   TextureBrowser_heightChanged(textureBrowser);
   textureBrowser.m_originInvalid = true;
 
   TextureBrowser_heightChanged(textureBrowser);
   textureBrowser.m_originInvalid = true;
 
-  std::for_each(g_activeShadersChangedCallbacks.begin(), g_activeShadersChangedCallbacks.end(), CallbackInvoke());
+  g_activeShadersChangedCallbacks();
 }
 
 void TextureBrowser_importShowScrollbar(TextureBrowser& textureBrowser, bool value)
 }
 
 void TextureBrowser_importShowScrollbar(TextureBrowser& textureBrowser, bool value)
index 4921fa0509a10997c8d27b72dc98a8e766b55e36..dd871b37be278025e3cab7349330f3689ffa31be 100644 (file)
@@ -23,6 +23,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #define INCLUDED_TEXWINDOW_H
 
 #include "math/vector.h"
 #define INCLUDED_TEXWINDOW_H
 
 #include "math/vector.h"
+#include "generic/callbackfwd.h"
+#include "signal/signalfwd.h"
 
 // textures menu
 
 
 // textures menu
 
@@ -57,8 +59,6 @@ const char* TextureBrowser_GetSelectedShader(TextureBrowser& textureBrower);
 void TextureBrowser_Construct();
 void TextureBrowser_Destroy();
 
 void TextureBrowser_Construct();
 void TextureBrowser_Destroy();
 
-template<typename FirstArgument>
-class Callback1;
 typedef Callback1<const char*> StringImportCallback;
 template<typename FirstArgument, void (*func)(FirstArgument)> 
 class FreeCaller1;
 typedef Callback1<const char*> StringImportCallback;
 template<typename FirstArgument, void (*func)(FirstArgument)> 
 class FreeCaller1;
@@ -70,8 +70,7 @@ typedef FreeCaller1<const StringImportCallback&, TextureBrowser_exportTitle> Tex
 const Vector3& TextureBrowser_getBackgroundColour(TextureBrowser& textureBrowser);
 void TextureBrowser_setBackgroundColour(TextureBrowser& textureBrowser, const Vector3& colour);
 
 const Vector3& TextureBrowser_getBackgroundColour(TextureBrowser& textureBrowser);
 void TextureBrowser_setBackgroundColour(TextureBrowser& textureBrowser, const Vector3& colour);
 
-class Callback;
-void TextureBrowser_addActiveShadersChangedCallback(const Callback& callback);
-void TextureBrowser_addShadersRealiseCallback(const Callback& callback);
+void TextureBrowser_addActiveShadersChangedCallback(const SignalHandler& handler);
+void TextureBrowser_addShadersRealiseCallback(const SignalHandler& handler);
 
 #endif
 
 #endif
index 001adbf9145eecbdb19ae00411e04a2611827892..aa75d950e27e61f415963dbfa624c0b5bbeef581 100644 (file)
@@ -467,7 +467,7 @@ typedef ConstReferenceCaller1<RadiantUndoSystem, const IntImportCallback&, UndoL
 
 void Undo_constructPreferences(RadiantUndoSystem& undo, PreferencesPage& page)
 {
 
 void Undo_constructPreferences(RadiantUndoSystem& undo, PreferencesPage& page)
 {
-  page.appendSpinner("Undo Queue Size", 64, 0, 1024, UndoLevelsImportCaller(undo), UndoLevelsExportCaller(undo));
+  page.appendSpinner("Undo Queue Size", 64, 0, 1024, IntImportCallback(UndoLevelsImportCaller(undo)), IntExportCallback(UndoLevelsExportCaller(undo)));
 }
 void Undo_constructPage(RadiantUndoSystem& undo, PreferenceGroup& group)
 {
 }
 void Undo_constructPage(RadiantUndoSystem& undo, PreferenceGroup& group)
 {
index 3951cbb58773848183fb9070465dceee9bf200f8..9000601a10dc0f69f96f386de1a89cf75737863a 100644 (file)
@@ -40,6 +40,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #include "generic/callback.h"
 #include "string/string.h"
 #include "stream/stringstream.h"
 #include "generic/callback.h"
 #include "string/string.h"
 #include "stream/stringstream.h"
+
 #include "scenelib.h"
 #include "eclasslib.h"
 #include "renderer.h"
 #include "scenelib.h"
 #include "eclasslib.h"
 #include "renderer.h"
@@ -422,6 +423,29 @@ inline ModifierFlags modifiers_for_flags(unsigned int flags)
   return modifiers;
 }
 
   return modifiers;
 }
 
+inline unsigned int buttons_for_button_and_modifiers(ButtonIdentifier button, ModifierFlags flags)
+{
+  unsigned int buttons = 0;
+
+  switch (button.get())
+  {
+  case ButtonEnumeration::LEFT: buttons |= RAD_LBUTTON; break;
+  case ButtonEnumeration::MIDDLE: buttons |= RAD_MBUTTON; break;
+  case ButtonEnumeration::RIGHT: buttons |= RAD_RBUTTON; break;
+  }
+
+  if(bitfield_enabled(flags, c_modifierControl))
+    buttons |= RAD_CONTROL;
+
+  if(bitfield_enabled(flags, c_modifierShift))
+    buttons |= RAD_SHIFT;
+
+  if(bitfield_enabled(flags, c_modifierAlt))
+    buttons |= RAD_ALT;
+
+  return buttons;
+}
+
 inline unsigned int buttons_for_event_button(GdkEventButton* event)
 {
   unsigned int flags = 0;
 inline unsigned int buttons_for_event_button(GdkEventButton* event)
 {
   unsigned int flags = 0;
@@ -723,7 +747,11 @@ gboolean xywnd_button_press(GtkWidget* widget, GdkEventButton* event, XYWnd* xyw
 {
   if(event->type == GDK_BUTTON_PRESS)
   {
 {
   if(event->type == GDK_BUTTON_PRESS)
   {
-    xywnd->XY_MouseDown(static_cast<int>(event->x), static_cast<int>(event->y), buttons_for_event_button(event));
+    g_pParentWnd->SetActiveXY(xywnd);
+
+    xywnd->ButtonState_onMouseDown(buttons_for_event_button(event));
+
+    xywnd->onMouseDown(WindowVector(event->x, event->y), button_for_button(event->button), modifiers_for_state(event->state));
   }
   return FALSE;
 }
   }
   return FALSE;
 }
@@ -733,6 +761,8 @@ gboolean xywnd_button_release(GtkWidget* widget, GdkEventButton* event, XYWnd* x
   if(event->type == GDK_BUTTON_RELEASE)
   {
     xywnd->XY_MouseUp(static_cast<int>(event->x), static_cast<int>(event->y), buttons_for_event_button(event));
   if(event->type == GDK_BUTTON_RELEASE)
   {
     xywnd->XY_MouseUp(static_cast<int>(event->x), static_cast<int>(event->y), buttons_for_event_button(event));
+
+    xywnd->ButtonState_onMouseUp(buttons_for_event_button(event));
   }
   return FALSE;
 }
   }
   return FALSE;
 }
@@ -852,6 +882,8 @@ XYWnd::XYWnd() :
   AddCameraMovedCallback(ReferenceCaller<XYWnd, &XYWnd_CameraMoved>(*this));
 
   PressedButtons_connect(g_pressedButtons, m_gl_widget);
   AddCameraMovedCallback(ReferenceCaller<XYWnd, &XYWnd_CameraMoved>(*this));
 
   PressedButtons_connect(g_pressedButtons, m_gl_widget);
+
+  onMouseDown.connectLast(makeSignalHandler3(MouseDownCaller(), *this));
 }
 
 XYWnd::~XYWnd()
 }
 
 XYWnd::~XYWnd()
@@ -1308,12 +1340,12 @@ inline WindowVector WindowVector_forInteger(int x, int y)
   return WindowVector(static_cast<float>(x), static_cast<float>(y));
 }
 
   return WindowVector(static_cast<float>(x), static_cast<float>(y));
 }
 
+void XYWnd::mouseDown(const WindowVector& position, ButtonIdentifier button, ModifierFlags modifiers)
+{
+  XY_MouseDown(static_cast<int>(position.x()), static_cast<int>(position.y()), buttons_for_button_and_modifiers(button, modifiers));
+}
 void XYWnd::XY_MouseDown (int x, int y, unsigned int buttons)
 {
 void XYWnd::XY_MouseDown (int x, int y, unsigned int buttons)
 {
-  g_pParentWnd->SetActiveXY(this);
-
-  ButtonState_onMouseDown(buttons);
-
   if(buttons == Move_buttons())
   {
     Move_Begin();
   if(buttons == Move_buttons())
   {
     Move_Begin();
@@ -1371,8 +1403,6 @@ void XYWnd::XY_MouseUp(int x, int y, unsigned int buttons)
   {
     m_window_observer->onMouseUp(WindowVector_forInteger(x, y), button_for_flags(buttons), modifiers_for_flags(buttons));
   }
   {
     m_window_observer->onMouseUp(WindowVector_forInteger(x, y), button_for_flags(buttons), modifiers_for_flags(buttons));
   }
-
-  ButtonState_onMouseUp(buttons);
 }
 
 void XYWnd::XY_MouseMoved (int x, int y, unsigned int buttons)
 }
 
 void XYWnd::XY_MouseMoved (int x, int y, unsigned int buttons)
index 5891c0380354cedc2d0a81146e422aa7ad001032..317ec591ae0fb7af27f8a1c51c2e0df1f256466d 100644 (file)
@@ -23,6 +23,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #define INCLUDED_XYWINDOW_H
 
 #include "math/matrix.h"
 #define INCLUDED_XYWINDOW_H
 
 #include "math/matrix.h"
+#include "signal/signal.h"
 
 #include "gtkutil/cursor.h"
 #include "gtkutil/window.h"
 
 #include "gtkutil/cursor.h"
 #include "gtkutil/window.h"
@@ -30,6 +31,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #include "view.h"
 #include "map.h"
 
 #include "view.h"
 #include "map.h"
 
+#include "qerplugin.h"
+
 class Shader;
 class SelectionSystemWindowObserver;
 namespace scene
 class Shader;
 class SelectionSystemWindowObserver;
 namespace scene
@@ -46,13 +49,6 @@ void Clip();
 void OnClipMode(bool enabled);
 bool ClipMode();
 
 void OnClipMode(bool enabled);
 bool ClipMode();
 
-enum VIEWTYPE
-{
-  YZ = 0,
-  XZ = 1,
-  XY = 2
-};
-
 inline const char* ViewType_getTitle(VIEWTYPE viewtype)
 {
   if(viewtype == XY)
 inline const char* ViewType_getTitle(VIEWTYPE viewtype)
 {
   if(viewtype == XY)
@@ -177,18 +173,6 @@ private:
   int m_ptCursorX, m_ptCursorY;
 
   unsigned int m_buttonstate;
   int m_ptCursorX, m_ptCursorY;
 
   unsigned int m_buttonstate;
-  void ButtonState_onMouseDown(unsigned int buttons)
-  {
-    m_buttonstate |= buttons;
-  }
-  void ButtonState_onMouseUp(unsigned int buttons)
-  {
-    m_buttonstate &= ~buttons;
-  }
-  unsigned int getButtonState() const
-  {
-    return m_buttonstate;
-  }
 
   int m_nNewBrushPressx;
   int m_nNewBrushPressy;
 
   int m_nNewBrushPressx;
   int m_nNewBrushPressy;
@@ -209,6 +193,18 @@ private:
   bool m_entityCreate;
 
 public:
   bool m_entityCreate;
 
 public:
+  void ButtonState_onMouseDown(unsigned int buttons)
+  {
+    m_buttonstate |= buttons;
+  }
+  void ButtonState_onMouseUp(unsigned int buttons)
+  {
+    m_buttonstate &= ~buttons;
+  }
+  unsigned int getButtonState() const
+  {
+    return m_buttonstate;
+  }
   void EntityCreate_MouseDown(int x, int y);
   void EntityCreate_MouseMove(int x, int y);
   void EntityCreate_MouseUp(int x, int y);
   void EntityCreate_MouseDown(int x, int y);
   void EntityCreate_MouseMove(int x, int y);
   void EntityCreate_MouseUp(int x, int y);
@@ -231,6 +227,10 @@ public:
   {
     return m_nHeight;
   }
   {
     return m_nHeight;
   }
+
+  Signal3<const WindowVector&, ButtonIdentifier, ModifierFlags> onMouseDown;
+  void mouseDown(const WindowVector& position, ButtonIdentifier button, ModifierFlags modifiers);
+  typedef Member3<XYWnd, const WindowVector&, ButtonIdentifier, ModifierFlags, void, &XYWnd::mouseDown> MouseDownCaller;
 };
 
 inline void XYWnd_Update(XYWnd& xywnd)
 };
 
 inline void XYWnd_Update(XYWnd& xywnd)