Revert partially (auto) "reformat code! now the code is only ugly on the *inside*"
authorThomas Debesse <dev@illwieckz.net>
Sun, 10 Feb 2019 19:43:55 +0000 (20:43 +0100)
committerThomas Debesse <dev@illwieckz.net>
Mon, 11 Feb 2019 01:48:47 +0000 (02:48 +0100)
This reverts commit 9dfae1c9b270ee369c6362903a9205b30751b95f.
But only for files whose changes that were automatically reverted.

417 files changed:
contrib/bkgrnd2d/bkgrnd2d.cpp
contrib/bkgrnd2d/bkgrnd2d.h
contrib/bkgrnd2d/dialog.cpp
contrib/bkgrnd2d/dialog.h
contrib/bkgrnd2d/plugin.cpp
contrib/bkgrnd2d/plugin.h
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.h
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/ScriptParser.h
contrib/bobtoolz/bobToolz-GTK.cpp
contrib/bobtoolz/bobToolz.h
contrib/bobtoolz/bobToolz.rc
contrib/bobtoolz/bsploader.cpp
contrib/bobtoolz/bsploader.h
contrib/bobtoolz/cportals.cpp
contrib/bobtoolz/ctfToolz-GTK.cpp
contrib/bobtoolz/dialogs/AboutDialog.cpp
contrib/bobtoolz/dialogs/AboutDialog.h
contrib/bobtoolz/dialogs/AutoCaulkDialog.cpp
contrib/bobtoolz/dialogs/AutoCaulkDialog.h
contrib/bobtoolz/dialogs/AutoCaulkStartDialog.cpp
contrib/bobtoolz/dialogs/AutoCaulkStartDialog.h
contrib/bobtoolz/dialogs/BrushCheckDialog.h
contrib/bobtoolz/dialogs/DoorDialog.cpp
contrib/bobtoolz/dialogs/DoorDialog.h
contrib/bobtoolz/dialogs/IntersectDialog.cpp
contrib/bobtoolz/dialogs/IntersectDialog.h
contrib/bobtoolz/dialogs/IntersectInfoDialog.cpp
contrib/bobtoolz/dialogs/IntersectInfoDialog.h
contrib/bobtoolz/dialogs/PolygonDialog.cpp
contrib/bobtoolz/dialogs/PolygonDialog.h
contrib/bobtoolz/dialogs/StairDialog.cpp
contrib/bobtoolz/dialogs/StairDialog.h
contrib/bobtoolz/dialogs/TextureResetDialog.cpp
contrib/bobtoolz/dialogs/TextureResetDialog.h
contrib/bobtoolz/dialogs/brushcheckdialog.cpp
contrib/bobtoolz/dialogs/dialogs-gtk.cpp
contrib/bobtoolz/dialogs/dialogs-gtk.h
contrib/bobtoolz/dialogs/pathplotterdialog.cpp
contrib/bobtoolz/dialogs/pathplotterdialog.h
contrib/bobtoolz/funchandlers-GTK.cpp
contrib/bobtoolz/funchandlers-ctf-GTK.cpp
contrib/bobtoolz/funchandlers.cpp
contrib/bobtoolz/funchandlers.h
contrib/bobtoolz/lists.cpp
contrib/bobtoolz/lists.h
contrib/bobtoolz/misc.cpp
contrib/bobtoolz/misc.h
contrib/bobtoolz/res/plugin.rc2
contrib/bobtoolz/shapes.cpp
contrib/bobtoolz/shapes.h
contrib/bobtoolz/visfind.cpp
contrib/bobtoolz/visfind.h
contrib/brushexport/callbacks.cpp
contrib/brushexport/callbacks.h
contrib/brushexport/export.cpp
contrib/brushexport/export.h
contrib/brushexport/interface.cpp
contrib/brushexport/plugin.cpp
contrib/brushexport/support.cpp
contrib/brushexport/support.h
contrib/camera/camera.cpp
contrib/camera/camera.h
contrib/camera/dialogs.cpp
contrib/camera/dialogs.h
contrib/camera/dialogs_common.cpp
contrib/camera/funchandlers.cpp
contrib/camera/funchandlers.h
contrib/camera/listener.cpp
contrib/camera/listener.h
contrib/camera/misc.cpp
contrib/camera/misc.h
contrib/camera/renderer.cpp
contrib/camera/renderer.h
contrib/gtkgensurf/bitmap.cpp
contrib/gtkgensurf/dec.cpp
contrib/gtkgensurf/face.cpp
contrib/gtkgensurf/font.cpp
contrib/gtkgensurf/gendlgs.cpp
contrib/gtkgensurf/genmap.cpp
contrib/gtkgensurf/gensurf.cpp
contrib/gtkgensurf/gensurf.h
contrib/gtkgensurf/heretic.cpp
contrib/gtkgensurf/plugin.cpp
contrib/gtkgensurf/triangle.c
contrib/gtkgensurf/triangle.h
contrib/gtkgensurf/view.cpp
contrib/hydratoolz/plugin.cpp
contrib/hydratoolz/plugin.h
contrib/prtview/AboutDialog.cpp
contrib/prtview/ConfigDialog.cpp
contrib/prtview/LoadPortalFileDialog.cpp
contrib/prtview/portals.cpp
contrib/prtview/portals.h
contrib/prtview/prtview.cpp
contrib/prtview/prtview.h
contrib/prtview/res/PrtView.rc2
contrib/shaderplug/shaderplug.cpp
contrib/sunplug/sunplug.cpp
contrib/sunplug/sunplug.h
contrib/ufoaiplug/ufoai.cpp
contrib/ufoaiplug/ufoai_filters.cpp
contrib/ufoaiplug/ufoai_filters.h
contrib/ufoaiplug/ufoai_gtk.cpp
contrib/ufoaiplug/ufoai_gtk.h
contrib/ufoaiplug/ufoai_level.cpp
contrib/ufoaiplug/ufoai_level.h
libs/gtkutil/accelerator.cpp
libs/gtkutil/accelerator.h
libs/gtkutil/button.cpp
libs/gtkutil/button.h
libs/gtkutil/clipboard.cpp
libs/gtkutil/clipboard.h
libs/gtkutil/closure.h
libs/gtkutil/cursor.cpp
libs/gtkutil/cursor.h
libs/gtkutil/dialog.cpp
libs/gtkutil/dialog.h
libs/gtkutil/filechooser.cpp
libs/gtkutil/filechooser.h
libs/gtkutil/frame.cpp
libs/gtkutil/frame.h
libs/gtkutil/glfont.cpp
libs/gtkutil/glfont.h
libs/gtkutil/glwidget.h
libs/gtkutil/idledraw.h
libs/gtkutil/image.cpp
libs/gtkutil/image.h
libs/gtkutil/menu.cpp
libs/gtkutil/menu.h
libs/gtkutil/messagebox.cpp
libs/gtkutil/messagebox.h
libs/gtkutil/nonmodal.h
libs/gtkutil/paned.cpp
libs/gtkutil/paned.h
libs/gtkutil/pointer.h
libs/gtkutil/toolbar.cpp
libs/gtkutil/toolbar.h
libs/gtkutil/window.cpp
libs/gtkutil/xorrectangle.h
plugins/archivepak/archive.cpp
plugins/archivepak/archive.h
plugins/archivepak/pak.h
plugins/archivepak/plugin.cpp
plugins/archivewad/archive.cpp
plugins/archivewad/archive.h
plugins/archivewad/plugin.cpp
plugins/archivewad/wad.h
plugins/archivezip/archive.cpp
plugins/archivezip/archive.h
plugins/archivezip/pkzip.h
plugins/archivezip/plugin.cpp
plugins/archivezip/zlibstream.h
plugins/entity/CMakeLists.txt
plugins/entity/angle.h
plugins/entity/angles.h
plugins/entity/colour.h
plugins/entity/curve.h
plugins/entity/doom3group.cpp
plugins/entity/doom3group.h
plugins/entity/eclassmodel.cpp
plugins/entity/eclassmodel.h
plugins/entity/entity.cpp
plugins/entity/entity.h
plugins/entity/filters.cpp
plugins/entity/filters.h
plugins/entity/generic.cpp
plugins/entity/generic.h
plugins/entity/group.cpp
plugins/entity/group.h
plugins/entity/keyobservers.h
plugins/entity/light.cpp
plugins/entity/light.h
plugins/entity/miscmodel.cpp
plugins/entity/miscmodel.h
plugins/entity/model.h
plugins/entity/modelskinkey.h
plugins/entity/namedentity.h
plugins/entity/namekeys.h
plugins/entity/origin.h
plugins/entity/plugin.cpp
plugins/entity/rotation.h
plugins/entity/scale.h
plugins/entity/skincache.cpp
plugins/entity/skincache.h
plugins/entity/targetable.cpp
plugins/entity/targetable.h
plugins/image/bmp.cpp
plugins/image/bmp.h
plugins/image/dds.cpp
plugins/image/dds.h
plugins/image/image.cpp
plugins/image/jpeg.cpp
plugins/image/jpeg.h
plugins/image/ktx.cpp
plugins/image/ktx.h
plugins/image/pcx.cpp
plugins/image/pcx.h
plugins/image/tga.cpp
plugins/image/tga.h
plugins/imagehl/hlw.cpp
plugins/imagehl/hlw.h
plugins/imagehl/imagehl.cpp
plugins/imagehl/mip.cpp
plugins/imagehl/mip.h
plugins/imagehl/sprite.cpp
plugins/imagehl/sprite.h
plugins/imageq2/imageq2.cpp
plugins/imageq2/wal.cpp
plugins/imageq2/wal.h
plugins/imageq2/wal32.cpp
plugins/imageq2/wal32.h
plugins/mapq3/CMakeLists.txt
plugins/mapq3/parse.cpp
plugins/mapq3/parse.h
plugins/mapxml/xmlparse.cpp
plugins/mapxml/xmlparse.h
plugins/mapxml/xmlwrite.cpp
plugins/mapxml/xmlwrite.h
plugins/md3model/ident.h
plugins/md3model/md2.cpp
plugins/md3model/md2.h
plugins/md3model/md3.cpp
plugins/md3model/md3.h
plugins/md3model/md3normals.h
plugins/md3model/md5.cpp
plugins/md3model/md5.h
plugins/md3model/mdc.cpp
plugins/md3model/mdc.h
plugins/md3model/mdl.cpp
plugins/md3model/mdl.h
plugins/md3model/mdlformat.h
plugins/md3model/mdlimage.cpp
plugins/md3model/mdlimage.h
plugins/md3model/mdlnormals.h
plugins/md3model/model.h
plugins/md3model/plugin.cpp
plugins/model/model.cpp
plugins/model/model.h
plugins/model/plugin.cpp
plugins/sample/sample.cpp
plugins/shaders/plugin.cpp
plugins/shaders/shaders.h
plugins/spritemodel/plugin.cpp
plugins/spritemodel/plugin.h
plugins/spritemodel/spritemodel.cpp
plugins/spritemodel/spritemodel.h
plugins/textool/2DView.cpp
plugins/textool/2DView.h
plugins/textool/ControlPointsManager.cpp
plugins/textool/ControlPointsManager.h
plugins/textool/Doc/TexTool.html
plugins/textool/StdAfx.h
plugins/textool/TexTool.cpp
plugins/textool/TexTool.rc
plugins/vfspk3/archive.cpp
plugins/vfspk3/archive.h
plugins/vfspk3/vfs.cpp
plugins/vfspk3/vfs.h
plugins/vfspk3/vfspk3.cpp
radiant/CMakeLists.txt
radiant/autosave.cpp
radiant/autosave.h
radiant/brush.cpp
radiant/brush_primit.cpp
radiant/brush_primit.h
radiant/brushmanip.h
radiant/brushmodule.cpp
radiant/brushmodule.h
radiant/brushnode.h
radiant/brushtokens.h
radiant/brushxml.h
radiant/build.cpp
radiant/build.h
radiant/camwindow.cpp
radiant/camwindow.h
radiant/commands.cpp
radiant/commands.h
radiant/console.cpp
radiant/console.h
radiant/dialog.cpp
radiant/dialog.h
radiant/eclass.cpp
radiant/eclass_def.cpp
radiant/eclass_doom3.cpp
radiant/eclass_fgd.cpp
radiant/eclass_xml.cpp
radiant/entity.h
radiant/entityinspector.cpp
radiant/entityinspector.h
radiant/entitylist.cpp
radiant/entitylist.h
radiant/environment.h
radiant/error.cpp
radiant/error.h
radiant/feedback.cpp
radiant/feedback.h
radiant/filetypes.cpp
radiant/filetypes.h
radiant/filters.cpp
radiant/filters.h
radiant/findtexturedialog.cpp
radiant/findtexturedialog.h
radiant/glwidget.cpp
radiant/grid.cpp
radiant/grid.h
radiant/groupdialog.cpp
radiant/groupdialog.h
radiant/gtkdlgs.cpp
radiant/gtkdlgs.h
radiant/gtkmisc.cpp
radiant/gtkmisc.h
radiant/help.cpp
radiant/help.h
radiant/image.cpp
radiant/image.h
radiant/main.cpp
radiant/mainframe.h
radiant/map.h
radiant/mru.cpp
radiant/mru.h
radiant/multimon.h
radiant/nullmodel.cpp
radiant/nullmodel.h
radiant/parse.cpp
radiant/patch.cpp
radiant/patch.h
radiant/patchdialog.cpp
radiant/patchdialog.h
radiant/patchmanip.cpp
radiant/patchmanip.h
radiant/patchmodule.cpp
radiant/plugin.cpp
radiant/plugin.h
radiant/pluginapi.cpp
radiant/pluginapi.h
radiant/pluginmanager.cpp
radiant/pluginmanager.h
radiant/pluginmenu.cpp
radiant/pluginmenu.h
radiant/plugintoolbar.cpp
radiant/plugintoolbar.h
radiant/points.cpp
radiant/points.h
radiant/preferencedictionary.h
radiant/preferences.cpp
radiant/preferences.h
radiant/qe3.h
radiant/qgl.cpp
radiant/qgl.h
radiant/radiant.rc
radiant/referencecache.h
radiant/renderer.h
radiant/renderstate.h
radiant/scenegraph.cpp
radiant/select.cpp
radiant/select.h
radiant/selection.cpp
radiant/selection.h
radiant/server.cpp
radiant/server.h
radiant/shaders.cpp
radiant/shaders.h
radiant/sockets.cpp
radiant/sockets.h
radiant/stacktrace.cpp
radiant/stacktrace.h
radiant/surfacedialog.cpp
radiant/surfacedialog.h
radiant/texmanip.cpp
radiant/texmanip.h
radiant/textures.cpp
radiant/textures.h
radiant/texwindow.h
radiant/timer.cpp
radiant/timer.h
radiant/treemodel.cpp
radiant/treemodel.h
radiant/undo.cpp
radiant/url.cpp
radiant/url.h
radiant/view.cpp
radiant/view.h
radiant/watchbsp.cpp
radiant/watchbsp.h
radiant/winding.cpp
radiant/winding.h
radiant/windowobservers.cpp
radiant/windowobservers.h
radiant/xmlstuff.h
radiant/xywindow.cpp
radiant/xywindow.h

index 7ed6315..b115952 100644 (file)
 
 CBackgroundRender render;
 
-CBackgroundImage backgroundXY(XY), backgroundXZ(XZ), backgroundYZ(YZ);
+CBackgroundImage backgroundXY( XY ),backgroundXZ( XZ ),backgroundYZ( YZ );
 
-CBackgroundRender::CBackgroundRender()
-{
-    refCount = 1;
+CBackgroundRender::CBackgroundRender(){
+       refCount = 1;
 }
 
-CBackgroundRender::~CBackgroundRender()
-{
+CBackgroundRender::~CBackgroundRender(){
 }
 
-void CBackgroundRender::Register()
-{
-    g_QglTable.m_pfnHookGL2DWindow(this);
+void CBackgroundRender::Register(){
+       g_QglTable.m_pfnHookGL2DWindow( this );
 }
 
-void CBackgroundRender::Draw2D(VIEWTYPE vt)
-{
-    switch (vt) {
-        case XY:
-            backgroundXY.Render();
-            break;
-        case XZ:
-            backgroundXZ.Render();
-            break;
-        case YZ:
-            backgroundYZ.Render();
-            break;
-    }
+void CBackgroundRender::Draw2D( VIEWTYPE vt ){
+       switch ( vt )
+       {
+       case XY:
+               backgroundXY.Render();
+               break;
+       case XZ:
+               backgroundXZ.Render();
+               break;
+       case YZ:
+               backgroundYZ.Render();
+               break;
+       }
 }
 
 
-CBackgroundImage::CBackgroundImage(VIEWTYPE vt)
-{
-    m_tex = NULL;
-    m_alpha = 0.5;
-
-    // TODO, sensible defaults ? Or not show until we have extents ?
-    m_xmin = m_ymin = 0.0f;
-    m_xmax = m_ymax = 0.0f;
-
-    m_bActive = false;
-
-    m_vt = vt;
-
-    switch (m_vt) {
-        case XY:
-            m_ix = 0;
-            m_iy = 1;
-            break;
-        case XZ:
-            m_ix = 0;
-            m_iy = 2;
-            break;
-        case YZ:
-            m_ix = 1;
-            m_iy = 2;
-            break;
-    }
+CBackgroundImage::CBackgroundImage( VIEWTYPE vt ){
+       m_tex = NULL;
+       m_alpha = 0.5;
+
+       // TODO, sensible defaults ? Or not show until we have extents ?
+       m_xmin = m_ymin = 0.0f;
+       m_xmax = m_ymax = 0.0f;
+
+       m_bActive = false;
+
+       m_vt = vt;
+
+       switch ( m_vt )
+       {
+       case XY:
+               m_ix = 0;
+               m_iy = 1;
+               break;
+       case XZ:
+               m_ix = 0;
+               m_iy = 2;
+               break;
+       case YZ:
+               m_ix = 1;
+               m_iy = 2;
+               break;
+       }
 }
 
 /*
@@ -99,214 +96,214 @@ CBackgroundImage::CBackgroundImage(VIEWTYPE vt)
    }
  */
 
-void CBackgroundImage::Cleanup()
-{
-    if (m_tex) {
-        g_QglTable.m_pfn_qglDeleteTextures(1, &m_tex->texture_number);
-        g_free(m_tex);
-        m_tex = NULL;
-    }
+void CBackgroundImage::Cleanup(){
+       if ( m_tex ) {
+               g_QglTable.m_pfn_qglDeleteTextures( 1,&m_tex->texture_number );
+               g_free( m_tex );
+               m_tex = NULL;
+       }
 }
 
-void CBackgroundImage::Render()
-{
-    if (!m_bActive || !Valid()) {
-        return;
-    }
-    g_QglTable.m_pfn_qglPushAttrib(GL_ALL_ATTRIB_BITS);
+void CBackgroundImage::Render(){
+       if ( !m_bActive || !Valid() ) {
+               return;
+       }
+       g_QglTable.m_pfn_qglPushAttrib( GL_ALL_ATTRIB_BITS );
 
-    g_QglTable.m_pfn_qglEnable(GL_TEXTURE_2D);
-    g_QglTable.m_pfn_qglEnable(GL_BLEND);
-    g_QglTable.m_pfn_qglBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-    g_QglTable.m_pfn_qglTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
-    g_QglTable.m_pfn_qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
-    g_QglTable.m_pfn_qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
+       g_QglTable.m_pfn_qglEnable( GL_TEXTURE_2D );
+       g_QglTable.m_pfn_qglEnable( GL_BLEND );
+       g_QglTable.m_pfn_qglBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
+       g_QglTable.m_pfn_qglTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
+       g_QglTable.m_pfn_qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
+       g_QglTable.m_pfn_qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
 
-    g_QglTable.m_pfn_qglPolygonMode(GL_FRONT, GL_FILL);
-    // TODO, just so we can tell if we end up going the wrong way
-    // g_QglTable.m_pfn_qglPolygonMode(GL_BACK,GL_LINE);
-    // TODO any other state we should not assume ?
+       g_QglTable.m_pfn_qglPolygonMode( GL_FRONT,GL_FILL );
+       // TODO, just so we can tell if we end up going the wrong way
+       // g_QglTable.m_pfn_qglPolygonMode(GL_BACK,GL_LINE);
+       // TODO any other state we should not assume ?
 
-    g_QglTable.m_pfn_qglBindTexture(GL_TEXTURE_2D, m_tex->texture_number);
-    g_QglTable.m_pfn_qglBegin(GL_QUADS);
+       g_QglTable.m_pfn_qglBindTexture( GL_TEXTURE_2D, m_tex->texture_number );
+       g_QglTable.m_pfn_qglBegin( GL_QUADS );
 
-    g_QglTable.m_pfn_qglColor4f(1.0, 1.0, 1.0, m_alpha);
-    g_QglTable.m_pfn_qglTexCoord2f(0.0, 1.0);
-    g_QglTable.m_pfn_qglVertex2f(m_xmin, m_ymin);
+       g_QglTable.m_pfn_qglColor4f( 1.0,1.0,1.0,m_alpha );
+       g_QglTable.m_pfn_qglTexCoord2f( 0.0,1.0 );
+       g_QglTable.m_pfn_qglVertex2f( m_xmin,m_ymin );
 
-    g_QglTable.m_pfn_qglTexCoord2f(1.0, 1.0);
-    g_QglTable.m_pfn_qglVertex2f(m_xmax, m_ymin);
+       g_QglTable.m_pfn_qglTexCoord2f( 1.0,1.0 );
+       g_QglTable.m_pfn_qglVertex2f( m_xmax,m_ymin );
 
-    g_QglTable.m_pfn_qglTexCoord2f(1.0, 0.0);
-    g_QglTable.m_pfn_qglVertex2f(m_xmax, m_ymax);
+       g_QglTable.m_pfn_qglTexCoord2f( 1.0,0.0 );
+       g_QglTable.m_pfn_qglVertex2f( m_xmax,m_ymax );
 
-    g_QglTable.m_pfn_qglTexCoord2f(0.0, 0.0);
-    g_QglTable.m_pfn_qglVertex2f(m_xmin, m_ymax);
+       g_QglTable.m_pfn_qglTexCoord2f( 0.0,0.0 );
+       g_QglTable.m_pfn_qglVertex2f( m_xmin,m_ymax );
 
-    g_QglTable.m_pfn_qglEnd();
-    g_QglTable.m_pfn_qglBindTexture(GL_TEXTURE_2D, 0);
+       g_QglTable.m_pfn_qglEnd();
+       g_QglTable.m_pfn_qglBindTexture( GL_TEXTURE_2D, 0 );
 
-    g_QglTable.m_pfn_qglPopAttrib();
+       g_QglTable.m_pfn_qglPopAttrib();
 }
 
-bool CBackgroundImage::Load(const char *filename)
-{
-    qtexture_t *newtex;
+bool CBackgroundImage::Load( const char *filename ){
+       qtexture_t *newtex;
 
-    unsigned char *image = NULL; // gets allocated with what ? g_malloc
-    int width = 0, height = 0;
+       unsigned char *image = NULL; // gets allocated with what ? g_malloc
+       int width = 0, height = 0;
 
-    g_FuncTable.m_pfnLoadImage(filename, &image, &width, &height);
+       g_FuncTable.m_pfnLoadImage( filename,&image,&width,&height );
 
-    if (!image) {
-        Syn_Printf(MSG_WARN "load %s failed\n", filename);
-        return false;
-    }
+       if ( !image ) {
+               Syn_Printf( MSG_WARN "load %s failed\n",filename );
+               return false;
+       }
 
 // just in case we want to build for an old version
 // http://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=900
 #ifdef BKGRND2D_JPG_WORKAROUND
-    if ( strlen( filename ) > 4 && !strcmp( ".jpg",filename + strlen( filename ) - 4 ) ) {
-        Syn_Printf( MSG_PREFIX ".jpg workaround, clearing alpha channel\n" );
-        int size = width * height * 4;
-        int i;
-        for ( i = 3; i < size; i += 4 ) {
-            image[i] = 255;
-        }
-    }
+       if ( strlen( filename ) > 4 && !strcmp( ".jpg",filename + strlen( filename ) - 4 ) ) {
+               Syn_Printf( MSG_PREFIX ".jpg workaround, clearing alpha channel\n" );
+               int size = width * height * 4;
+               int i;
+               for ( i = 3; i < size; i += 4 ) {
+                       image[i] = 255;
+               }
+       }
 #endif
 
-    //TODO bug for stored texture size
-    //TODO whose gl context are we in, anyway ?
-    newtex = g_FuncTable.m_pfnLoadTextureRGBA(image, width, height);
+       //TODO bug for stored texture size
+       //TODO whose gl context are we in, anyway ?
+       newtex = g_FuncTable.m_pfnLoadTextureRGBA( image,width,height );
 
-    g_free(image);
+       g_free( image );
 
-    if (!newtex) {
-        Syn_Printf(MSG_WARN "image to texture failed\n");
-        return false;
-    }
+       if ( !newtex ) {
+               Syn_Printf( MSG_WARN "image to texture failed\n" );
+               return false;
+       }
 
-    Cleanup();
-    m_tex = newtex;
+       Cleanup();
+       m_tex = newtex;
 
-    g_FuncTable.m_pfnSysUpdateWindows(W_XY);
+       g_FuncTable.m_pfnSysUpdateWindows( W_XY );
 
-    return true;
+       return true;
 }
 
-bool CBackgroundImage::SetExtentsMM()
-{
-    entity_s *worldentity;
-    const char *val;
-    int xmin = 0, ymin = 0, xmax = 0, ymax = 0;
-
-    worldentity = (entity_s *) g_FuncTable.m_pfnGetEntityHandle(0);
-    if (!worldentity) {
-        Syn_Printf(MSG_WARN "SetExtentsMM worldspawn not found\n");
-        return false;
-    }
-    //TODO val is not NULL even if key does not exist
-    val = g_EntityTable.m_pfnValueForKey(worldentity, "mapcoordsmins");
-    if (!val || !val[0]) {
-        Syn_Printf(MSG_WARN "SetExtentsMM mapcoordsmins not found\n");
-        return false;
-    }
+bool CBackgroundImage::SetExtentsMM(){
+       entity_s *worldentity;
+       const char *val;
+       int xmin = 0, ymin = 0, xmax = 0, ymax = 0;
+
+       worldentity = (entity_s *)g_FuncTable.m_pfnGetEntityHandle( 0 );
+       if ( !worldentity ) {
+               Syn_Printf( MSG_WARN "SetExtentsMM worldspawn not found\n" );
+               return false;
+       }
+       //TODO val is not NULL even if key does not exist
+       val = g_EntityTable.m_pfnValueForKey( worldentity,"mapcoordsmins" );
+       if ( !val || !val[0] ) {
+               Syn_Printf( MSG_WARN "SetExtentsMM mapcoordsmins not found\n" );
+               return false;
+       }
 // we could be more robust
 // note contortions due to splashs strange idea of min and max
-    if (sscanf(val, "%d %d", &xmin, &ymax) != 2) {
-        Syn_Printf(MSG_WARN "SetExtentsMM mapcoordsmins malformed\n");
-        return false;
-    }
-
-    val = g_EntityTable.m_pfnValueForKey(worldentity, "mapcoordsmaxs");
-    if (!val || !val[0]) {
-        Syn_Printf(MSG_WARN "SetExtentsMM mapcoordsmaxs not found\n");
-        return false;
-    }
-    if (sscanf(val, "%d %d", &xmax, &ymin) != 2) {
-        Syn_Printf(MSG_WARN "SetExtentsMM mapcoordsmaxs malformed\n");
-        return false;
-    }
-    //might do sanity check before we commit
-    m_xmin = (float) xmin;
-    m_ymin = (float) ymin;
-    m_xmax = (float) xmax;
-    m_ymax = (float) ymax;
-
-    g_FuncTable.m_pfnSysUpdateWindows(W_XY);
-    return true;
+       if ( sscanf( val, "%d %d",&xmin,&ymax ) != 2 ) {
+               Syn_Printf( MSG_WARN "SetExtentsMM mapcoordsmins malformed\n" );
+               return false;
+       }
+
+       val = g_EntityTable.m_pfnValueForKey( worldentity,"mapcoordsmaxs" );
+       if ( !val || !val[0] ) {
+               Syn_Printf( MSG_WARN "SetExtentsMM mapcoordsmaxs not found\n" );
+               return false;
+       }
+       if ( sscanf( val, "%d %d",&xmax,&ymin ) != 2 ) {
+               Syn_Printf( MSG_WARN "SetExtentsMM mapcoordsmaxs malformed\n" );
+               return false;
+       }
+       //might do sanity check before we commit
+       m_xmin = (float)xmin;
+       m_ymin = (float)ymin;
+       m_xmax = (float)xmax;
+       m_ymax = (float)ymax;
+
+       g_FuncTable.m_pfnSysUpdateWindows( W_XY );
+       return true;
 }
 
 // TODO, this should just be exported from core
 // ripped directly from radiant/select.cpp:Select_GetBounds
 //
-static bool get_selection_bounds(vec3_t mins, vec3_t maxs)
-{
-    brush_t *b;
-    int i;
-    brush_t *selected_brushes = g_DataTable.m_pfnSelectedBrushes();
-    //TODO should never happen
-    if (!selected_brushes) {
-        Sys_Printf(MSG_PREFIX "selected_brushes = NULL\n");
-        return false;
-    }
-    // this should mean no selection
-    if (selected_brushes == selected_brushes->next) {
-        Sys_Printf(MSG_PREFIX "nothing selected\n");
-
-        return false;
-    }
-
-    for (i = 0; i < 3; i++) {
-        mins[i] = 99999;
-        maxs[i] = -99999;
-    }
-
-    for (b = selected_brushes->next; b != selected_brushes; b = b->next) {
-        if (b->owner->eclass->fixedsize) {
-            for (i = 0; i < 3; i++) {
-                if (b->owner->origin[i] < mins[i]) {
-                    mins[i] = b->owner->origin[i];
-                }
-                if (b->owner->origin[i] > maxs[i]) {
-                    maxs[i] = b->owner->origin[i];
-                }
-            }
-        } else {
-            for (i = 0; i < 3; i++) {
-                if (b->mins[i] < mins[i]) {
-                    mins[i] = b->mins[i];
-                }
-                if (b->maxs[i] > maxs[i]) {
-                    maxs[i] = b->maxs[i];
-                }
-            }
-        }
-    }
-    return true;
+static bool get_selection_bounds( vec3_t mins, vec3_t maxs ){
+       brush_t *b;
+       int i;
+       brush_t *selected_brushes = g_DataTable.m_pfnSelectedBrushes();
+       //TODO should never happen
+       if ( !selected_brushes ) {
+               Sys_Printf( MSG_PREFIX "selected_brushes = NULL\n" );
+               return false;
+       }
+       // this should mean no selection
+       if ( selected_brushes == selected_brushes->next ) {
+               Sys_Printf( MSG_PREFIX "nothing selected\n" );
+
+               return false;
+       }
+
+       for ( i = 0 ; i < 3 ; i++ )
+       {
+               mins[i] = 99999;
+               maxs[i] = -99999;
+       }
+
+       for ( b = selected_brushes->next ; b != selected_brushes ; b = b->next )
+       {
+               if ( b->owner->eclass->fixedsize ) {
+                       for ( i = 0 ; i < 3 ; i++ )
+                       {
+                               if ( b->owner->origin[i] < mins[i] ) {
+                                       mins[i] = b->owner->origin[i];
+                               }
+                               if ( b->owner->origin[i] > maxs[i] ) {
+                                       maxs[i] = b->owner->origin[i];
+                               }
+                       }
+               }
+               else
+               {
+                       for ( i = 0 ; i < 3 ; i++ )
+                       {
+                               if ( b->mins[i] < mins[i] ) {
+                                       mins[i] = b->mins[i];
+                               }
+                               if ( b->maxs[i] > maxs[i] ) {
+                                       maxs[i] = b->maxs[i];
+                               }
+                       }
+               }
+       }
+       return true;
 }
 
-bool CBackgroundImage::SetExtentsSel()
-{
-    vec3_t mins, maxs;
+bool CBackgroundImage::SetExtentsSel(){
+       vec3_t mins,maxs;
 
-    if (!get_selection_bounds(mins, maxs)) {
-        return false;
-    }
+       if ( !get_selection_bounds( mins,maxs ) ) {
+               return false;
+       }
 
-    if (((int) mins[m_ix] == (int) maxs[m_ix]) ||
-        ((int) mins[m_iy] == (int) maxs[m_iy])) {
-        Syn_Printf(MSG_PREFIX "tiny selection\n");
-        return false;
-    }
+       if ( ( (int)mins[m_ix] == (int)maxs[m_ix] ) ||
+                ( (int)mins[m_iy] == (int)maxs[m_iy] ) ) {
+               Syn_Printf( MSG_PREFIX "tiny selection\n" );
+               return false;
+       }
 
-    m_xmin = mins[m_ix];
-    m_ymin = mins[m_iy];
-    m_xmax = maxs[m_ix];
-    m_ymax = maxs[m_iy];
+       m_xmin = mins[m_ix];
+       m_ymin = mins[m_iy];
+       m_xmax = maxs[m_ix];
+       m_ymax = maxs[m_iy];
 
-    g_FuncTable.m_pfnSysUpdateWindows(W_XY);
+       g_FuncTable.m_pfnSysUpdateWindows( W_XY );
 
-    return true;
+       return true;
 }
index 5c3bf3e..41ee271 100644 (file)
 
 class CBackgroundImage {
 private:
-    qtexture_t *m_tex;
-    VIEWTYPE m_vt;
+qtexture_t *m_tex;
+VIEWTYPE m_vt;
 
 // which components of a vec3_t correspond to x and y in the image
-    unsigned m_ix, m_iy;
+unsigned m_ix,m_iy;
 
 public:
-    CBackgroundImage(VIEWTYPE vt);
+CBackgroundImage( VIEWTYPE vt );
 //  ~CBackgroundImage();
 
-    float m_alpha;     // vertex alpha
-    bool m_bActive;
+float m_alpha;     // vertex alpha
+bool m_bActive;
 
 // x and y axis are in relation to the screen, not world, making rendering
 // the same for each view type. Whoever sets them is responsible for
 // shuffling.
 // units are world units.
 // TODO should be private
-    float m_xmin, m_ymin, m_xmax, m_ymax;
+float m_xmin,m_ymin,m_xmax,m_ymax;
 
 // load file, create new tex, cleanup old tex, set new tex
-    bool Load(const char *filename);
-
-    void Cleanup();     // free texture, free tex, set make tex NULL
-    bool SetExtentsMM();     // set extents by ET mapcoordsmaxs/mapcoordsmins
-    bool SetExtentsSel();     // set extents by selection
-    void Render();
-
-    bool Valid()
-    { return (m_tex && (m_xmin != m_xmax) && (m_ymin != m_ymax)); }
+bool Load( const char *filename );
+void Cleanup();     // free texture, free tex, set make tex NULL
+bool SetExtentsMM();     // set extents by ET mapcoordsmaxs/mapcoordsmins
+bool SetExtentsSel();     // set extents by selection
+void Render();
+bool Valid() { return ( m_tex && ( m_xmin != m_xmax ) && ( m_ymin != m_ymax ) ); }
 };
 
 class CBackgroundRender : public IGL2DWindow {
 public:
 
-    CBackgroundRender();
-
-    virtual ~CBackgroundRender();
+CBackgroundRender();
+virtual ~CBackgroundRender();
 
 protected:
-    int refCount;
+int refCount;
 
 public:
 
 // IGL2DWindow IGL3DWindow interface
-    void IncRef()
-    { refCount++; }
-
-    void DecRef()
-    {
-        refCount--;
-        if (refCount <= 0) {
-            delete this;
-        }
-    }
-
-    void Draw2D(VIEWTYPE vt);
-
-    void Register();
+void IncRef() { refCount++; }
+void DecRef() {
+       refCount--; if ( refCount <= 0 ) {
+               delete this;
+       }
+}
+void Draw2D( VIEWTYPE vt );
+void Register();
 };
 
-extern CBackgroundImage backgroundXY, backgroundXZ, backgroundYZ;
+extern CBackgroundImage backgroundXY,backgroundXZ,backgroundYZ;
 extern CBackgroundRender render;
index 7bdf466..01a1b98 100644 (file)
@@ -38,268 +38,250 @@ static ui::Window pDialogWnd{ui::null};
 static GtkWidget *pNotebook;
 static GtkTooltips *pTooltips;
 
-class CBackgroundDialogPage {
+class CBackgroundDialogPage
+{
 private:
-    GtkWidget *m_pWidget;
-    GtkWidget *m_pTabLabel;
-    ui::Label m_pFileLabel;
-    GtkWidget *m_pPosLabel;
-    VIEWTYPE m_vt;
-    bool m_bValidFile;
+GtkWidget *m_pWidget;
+GtkWidget *m_pTabLabel;
+ui::Label m_pFileLabel;
+GtkWidget *m_pPosLabel;
+VIEWTYPE m_vt;
+bool m_bValidFile;
 
 public:
-    CBackgroundImage *m_pImage;
-
-    CBackgroundDialogPage(VIEWTYPE vt);
-
-    void Append(GtkWidget *notebook);
-
-    void Browse();
-
-    void Reload();
-
-    void SetPosLabel();
+CBackgroundImage *m_pImage;
+CBackgroundDialogPage( VIEWTYPE vt );
+void Append( GtkWidget *notebook );
+void Browse();
+void Reload();
+void SetPosLabel();
 //  ~BackgroundDialogPage();
 };
 
 
 // dialog page callbacks
-static void browse_callback(GtkWidget *widget, gpointer data)
-{
-    ((CBackgroundDialogPage *) data)->Browse();
+static void browse_callback( GtkWidget *widget, gpointer data ){
+       ( (CBackgroundDialogPage *)data )->Browse();
 }
 
-static void reload_callback(GtkWidget *widget, gpointer data)
-{
-    ((CBackgroundDialogPage *) data)->Reload();
+static void reload_callback( GtkWidget *widget, gpointer data ){
+       ( (CBackgroundDialogPage *)data )->Reload();
 }
 
-static void size_sel_callback(GtkWidget *widget, gpointer data)
-{
-    CBackgroundDialogPage *pPage = (CBackgroundDialogPage *) data;
-    if (pPage->m_pImage->SetExtentsSel()) {
-        pPage->SetPosLabel();
-    }
+static void size_sel_callback( GtkWidget *widget, gpointer data ){
+       CBackgroundDialogPage *pPage = (CBackgroundDialogPage *)data;
+       if ( pPage->m_pImage->SetExtentsSel() ) {
+               pPage->SetPosLabel();
+       }
 }
 
-static void size_mm_callback(GtkWidget *widget, gpointer data)
-{
-    CBackgroundDialogPage *pPage = (CBackgroundDialogPage *) data;
-    if (pPage->m_pImage->SetExtentsMM()) {
-        pPage->SetPosLabel();
-    }
+static void size_mm_callback( GtkWidget *widget, gpointer data ){
+       CBackgroundDialogPage *pPage = (CBackgroundDialogPage *)data;
+       if ( pPage->m_pImage->SetExtentsMM() ) {
+               pPage->SetPosLabel();
+       }
 }
 
-static void alpha_adjust_callback(GtkWidget *widget, gpointer data)
-{
-    CBackgroundDialogPage *pPage = (CBackgroundDialogPage *) data;
-    pPage->m_pImage->m_alpha = (float) gtk_range_get_value(GTK_RANGE(widget));
-    g_FuncTable.m_pfnSysUpdateWindows(W_XY);
+static void alpha_adjust_callback( GtkWidget *widget, gpointer data ){
+       CBackgroundDialogPage *pPage = (CBackgroundDialogPage *)data;
+       pPage->m_pImage->m_alpha = (float)gtk_range_get_value( GTK_RANGE( widget ) );
+       g_FuncTable.m_pfnSysUpdateWindows( W_XY );
 }
 
-void CBackgroundDialogPage::Reload()
-{
-    if (m_bValidFile) {
-        m_pImage->Load(gtk_label_get_text(GTK_LABEL(m_pFileLabel)));
-    }
+void CBackgroundDialogPage::Reload(){
+       if ( m_bValidFile ) {
+               m_pImage->Load( gtk_label_get_text( GTK_LABEL( m_pFileLabel ) ) );
+       }
 }
 
-void CBackgroundDialogPage::Browse()
-{
-    char browsedir[PATH_MAX];
-    const char *ct;
-    const char *newfile;
-    char *t;
+void CBackgroundDialogPage::Browse(){
+       char browsedir[PATH_MAX];
+       const char *ct;
+       const char *newfile;
+       char *t;
 
-    //TODO GetMapName saves the map. eeep!
-    //also with no map, returns unnamed.map, otherwise returns full path
+       //TODO GetMapName saves the map. eeep!
+       //also with no map, returns unnamed.map, otherwise returns full path
 //     Syn_Printf(MSG_PREFIX "GetMapName() %s\n",
 //                             g_FuncTable.m_pfnGetMapName());
 
-    ct = g_FuncTable.m_pfnReadProjectKey("basepath");
-    // TODO shouldn't need this stuff
-    if (!ct || !strlen(ct)) {
-        Syn_Printf(MSG_PREFIX "basepath = NULL or empty\n");
-        return;
-    }
-    Syn_Printf(MSG_PREFIX "basepath: %s\n", ct);
-    if (strlen(ct) >= PATH_MAX) {
-        Syn_Printf(MSG_PREFIX "base game dir too long\n");
-        return;
-    }
-
-    strcpy(browsedir, ct);
-    // make sure we have a trailing /
-    if (browsedir[strlen(browsedir) - 1] != '/') {
-        strcat(browsedir, "/");
-    }
-
-    //if we dont have a file yet, don't try to use it for default dir
-    if (m_bValidFile) {
-        // filename should always be a nice clean unix style relative path
-        ct = gtk_label_get_text(GTK_LABEL(m_pFileLabel));
-        strcat(browsedir, ct);
-        Syn_Printf(MSG_PREFIX "full path: %s\n", browsedir);
-
-        // lop off the file part
-        t = browsedir + strlen(browsedir) - 1;
-        while (t != browsedir && *t != '/') {
-            t--;
-        }
-        *t = 0;
-    }
-    Syn_Printf(MSG_PREFIX "browse directory %s\n", browsedir);
+       ct = g_FuncTable.m_pfnReadProjectKey( "basepath" );
+       // TODO shouldn't need this stuff
+       if ( !ct || !strlen( ct ) ) {
+               Syn_Printf( MSG_PREFIX "basepath = NULL or empty\n" );
+               return;
+       }
+       Syn_Printf( MSG_PREFIX "basepath: %s\n",ct );
+       if ( strlen( ct ) >= PATH_MAX ) {
+               Syn_Printf( MSG_PREFIX "base game dir too long\n" );
+               return;
+       }
+
+       strcpy( browsedir,ct );
+       // make sure we have a trailing /
+       if ( browsedir[strlen( browsedir ) - 1] != '/' ) {
+               strcat( browsedir,"/" );
+       }
+
+       //if we dont have a file yet, don't try to use it for default dir
+       if ( m_bValidFile ) {
+               // filename should always be a nice clean unix style relative path
+               ct = gtk_label_get_text( GTK_LABEL( m_pFileLabel ) );
+               strcat( browsedir,ct );
+               Syn_Printf( MSG_PREFIX "full path: %s\n",browsedir );
+
+               // lop off the file part
+               t = browsedir + strlen( browsedir ) - 1;
+               while ( t != browsedir && *t != '/' )
+                       t--;
+               *t = 0;
+       }
+       Syn_Printf( MSG_PREFIX "browse directory %s\n",browsedir );
 
 //does NOT need freeing contrary to include/qerplugin.h comments
 //TODO bug/patch for comments
 //TODO patern gets fucked up sometimes if empty
 //http://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=915
-    newfile = g_FuncTable.m_pfnFileDialog(pDialogWnd, TRUE,
-                                          "Load Background Image", browsedir, FILETYPE_KEY);
-    if (!newfile) {
-        Syn_Printf(MSG_PREFIX "newfile = NULL\n");
-        return;
-    }
-    Syn_Printf(MSG_PREFIX "newfile: %s\n", newfile);
-    newfile = g_FileSystemTable.m_pfnExtractRelativePath(newfile);
-
-    if (!newfile) {
-        Syn_Printf(MSG_PREFIX "newfile = NULL\n");
-        return;
-    }
-    Syn_Printf(MSG_PREFIX "newfile: %s\n", newfile);
-
-    if (m_pImage->Load(newfile)) {
-        m_bValidFile = true;
-        m_pFileLabel.text(newfile);
-    }
+       newfile = g_FuncTable.m_pfnFileDialog( pDialogWnd,TRUE,
+                                                                                  "Load Background Image",browsedir,FILETYPE_KEY );
+       if ( !newfile ) {
+               Syn_Printf( MSG_PREFIX "newfile = NULL\n" );
+               return;
+       }
+       Syn_Printf( MSG_PREFIX "newfile: %s\n",newfile );
+       newfile = g_FileSystemTable.m_pfnExtractRelativePath( newfile );
+
+       if ( !newfile ) {
+               Syn_Printf( MSG_PREFIX "newfile = NULL\n" );
+               return;
+       }
+       Syn_Printf( MSG_PREFIX "newfile: %s\n",newfile );
+
+       if ( m_pImage->Load( newfile ) ) {
+               m_bValidFile = true;
+               m_pFileLabel.text(newfile);
+       }
 }
 
-void CBackgroundDialogPage::SetPosLabel()
-{
-    char s[64];
-    // TODO no snprintf ?
-    sprintf(s, "Size/Position (%d,%d) (%d,%d)", (int) (m_pImage->m_xmin),
-            (int) (m_pImage->m_ymin), (int) (m_pImage->m_xmax), (int) (m_pImage->m_ymax));
-    m_pPosLabel.text(s);
+void CBackgroundDialogPage::SetPosLabel(){
+       char s[64];
+       // TODO no snprintf ?
+       sprintf( s, "Size/Position (%d,%d) (%d,%d)",(int)( m_pImage->m_xmin ),
+                        (int)( m_pImage->m_ymin ),(int)( m_pImage->m_xmax ),(int)( m_pImage->m_ymax ) );
+       m_pPosLabel.text(s);
 }
 
-CBackgroundDialogPage::CBackgroundDialogPage(VIEWTYPE vt)
-{
-    GtkWidget *w;
-
-    m_vt = vt;
-
-    m_bValidFile = false;
-
-    switch (m_vt) {
-        case XY:
-            m_pTabLabel = ui::Label("X/Y");
-            m_pImage = &backgroundXY;
-            break;
-        case XZ:
-            m_pTabLabel = ui::Label("X/Z");
-            m_pImage = &backgroundXZ;
-            break;
-        case YZ:
-            m_pTabLabel = ui::Label("Y/Z");
-            m_pImage = &backgroundYZ;
-            break;
-    }
+CBackgroundDialogPage::CBackgroundDialogPage( VIEWTYPE vt ){
+       GtkWidget *w;
+
+       m_vt = vt;
+
+       m_bValidFile = false;
+
+       switch ( m_vt )
+       {
+       case XY:
+               m_pTabLabel = ui::Label( "X/Y" );
+               m_pImage = &backgroundXY;
+               break;
+       case XZ:
+               m_pTabLabel = ui::Label( "X/Z" );
+               m_pImage = &backgroundXZ;
+               break;
+       case YZ:
+               m_pTabLabel = ui::Label( "Y/Z" );
+               m_pImage = &backgroundYZ;
+               break;
+       }
 // A vbox to hold everything
-    m_pWidget = ui::VBox(FALSE, 0);
+       m_pWidget = ui::VBox( FALSE,0 );
 // Frame for file row
-    auto frame = ui::Frame("File");
-    m_pWidget.pack_start(frame, FALSE, FALSE, 2);
+       auto frame = ui::Frame( "File" );
+       m_pWidget.pack_start(frame, FALSE, FALSE, 2 );
 
 // hbox for first row
-    auto hbox = ui::HBox(FALSE, 5);
-    gtk_container_set_border_width(GTK_CONTAINER(hbox), 4);
-    frame.add(hbox);
+       auto hbox = ui::HBox( FALSE,5 );
+       gtk_container_set_border_width( GTK_CONTAINER( hbox ),4 );
+       frame.add(hbox);
 
 // label to display filename
-    m_pFileLabel = ui::Label(NO_FILE_MSG);
-    gtk_label_set_selectable(GTK_LABEL(m_pFileLabel), TRUE);
+       m_pFileLabel  = ui::Label( NO_FILE_MSG );
+       gtk_label_set_selectable( GTK_LABEL( m_pFileLabel ),TRUE );
 //TODO set min size ? done with spaces right now
-    hbox.pack_start(m_pFileLabel, TRUE, TRUE, 5);
+       hbox.pack_start(m_pFileLabel, TRUE, TRUE, 5 );
 
-    m_pFileLabel.show();
+       m_pFileLabel.show();
 
-    w = ui::Button("Browse...");
-    w.connect("clicked", G_CALLBACK(browse_callback), (gpointer) this );
-    hbox.pack_start(w, FALSE, FALSE, 5);
-    gtk_tooltips_set_tip(pTooltips, w, "Select a file", NULL);
-    w.show();
+       w = ui::Button( "Browse..." );
+       w.connect( "clicked", G_CALLBACK( browse_callback ), ( gpointer ) this );
+       hbox.pack_start(w, FALSE, FALSE, 5 );
+       gtk_tooltips_set_tip( pTooltips, w, "Select a file", NULL );
+       w.show();
 
-    w = ui::Button("Reload");
-    w.connect("clicked", G_CALLBACK(reload_callback), (gpointer) this );
-    // TODO disable until we have file
-    // gtk_widget_set_sensitive(w,FALSE);
-    gtk_tooltips_set_tip(pTooltips, w, "Reload current file", NULL);
-    hbox.pack_start(w, FALSE, FALSE, 5);
-    w.show();
+       w = ui::Button( "Reload" );
+       w.connect( "clicked", G_CALLBACK( reload_callback ), ( gpointer ) this );
+       // TODO disable until we have file
+       // gtk_widget_set_sensitive(w,FALSE);
+       gtk_tooltips_set_tip( pTooltips, w, "Reload current file", NULL );
+       hbox.pack_start(w, FALSE, FALSE, 5 );
+       w.show();
 
-    hbox.show();
-    frame.show();
+       hbox.show();
+       frame.show();
 
 // second row (rendering options)
-    frame = ui::Frame("Rendering");
-    m_pWidget.pack_start(frame, FALSE, FALSE, 2);
-
-    hbox = ui::HBox(FALSE, 5);
-    gtk_container_set_border_width(GTK_CONTAINER(hbox), 4);
-    frame.add(hbox);
-
-    w = ui::Label("Vertex alpha:");
-    hbox.pack_start(w, FALSE, FALSE, 5);
-    w.show();
-
-    w = ui::HScale(0.0, 1.0, 0.01);
-    gtk_range_set_value(GTK_RANGE(w), 0.5);
-    gtk_scale_set_value_pos(GTK_SCALE(w), GTK_POS_LEFT);
-    w.connect("value-changed", G_CALLBACK(alpha_adjust_callback), (gpointer) this );
-    hbox.pack_start(w, TRUE, TRUE, 5);
-    gtk_tooltips_set_tip(pTooltips, w, "Set image transparancy", NULL);
-    w.show();
-
-    hbox.show();
-    frame.show();
+       frame = ui::Frame( "Rendering" );
+       m_pWidget.pack_start(frame, FALSE, FALSE, 2 );
+
+       hbox = ui::HBox( FALSE,5 );
+       gtk_container_set_border_width( GTK_CONTAINER( hbox ),4 );
+       frame.add(hbox);
+
+       w = ui::Label( "Vertex alpha:" );
+       hbox.pack_start(w, FALSE, FALSE, 5 );
+       w.show();
+
+       w = ui::HScale( 0.0, 1.0, 0.01 );
+       gtk_range_set_value( GTK_RANGE( w ),0.5 );
+       gtk_scale_set_value_pos( GTK_SCALE( w ),GTK_POS_LEFT );
+       w.connect( "value-changed", G_CALLBACK( alpha_adjust_callback ), ( gpointer ) this );
+       hbox.pack_start(w, TRUE, TRUE, 5 );
+       gtk_tooltips_set_tip( pTooltips, w, "Set image transparancy", NULL );
+       w.show();
+
+       hbox.show();
+       frame.show();
 // Third row (size and position)
-    frame = ui::Frame("Size/Position (undefined)");
-    m_pPosLabel = gtk_frame_get_label_widget(GTK_FRAME(frame));
-    m_pWidget.pack_start(frame, FALSE, FALSE, 2);
-
-    hbox = ui::HBox(FALSE, 5);
-    frame.add(hbox);
-    gtk_container_set_border_width(GTK_CONTAINER(hbox), 4);
-
-    w = ui::Button("from selection");
-    hbox.pack_start(w, TRUE, FALSE, 5);
-    w.connect("clicked", G_CALLBACK(size_sel_callback), (gpointer) this );
-    gtk_tooltips_set_tip(pTooltips, w,
-                         "Set the size of the image to the bounding rectangle of all selected brushes and entities",
-                         NULL);
-    w.show();
-
-    if (m_vt == XY) {
-        w = ui::Button("from map mins/maxs");
-        hbox.pack_start(w, TRUE, FALSE, 2);
-        w.connect("clicked", G_CALLBACK(size_mm_callback), (gpointer) this );
-        gtk_tooltips_set_tip(pTooltips, w,
-                             "Set the size of the image using the mapcoordsmins and mapcoordsmaxs keys of the worldspawn entity",
-                             NULL);
-        w.show();
-    }
-
-    hbox.show();
-    frame.show();
-
-    m_pWidget.show();
+       frame = ui::Frame( "Size/Position (undefined)" );
+       m_pPosLabel = gtk_frame_get_label_widget( GTK_FRAME( frame ) );
+       m_pWidget.pack_start( frame, FALSE, FALSE, 2 );
+
+       hbox = ui::HBox( FALSE,5 );
+       frame.add(hbox);
+       gtk_container_set_border_width( GTK_CONTAINER( hbox ),4 );
+
+       w = ui::Button( "from selection" );
+       hbox.pack_start(w, TRUE, FALSE, 5 );
+       w.connect( "clicked", G_CALLBACK( size_sel_callback ), ( gpointer ) this );
+       gtk_tooltips_set_tip( pTooltips, w, "Set the size of the image to the bounding rectangle of all selected brushes and entities", NULL );
+       w.show();
+
+       if ( m_vt == XY ) {
+               w = ui::Button( "from map mins/maxs" );
+               hbox.pack_start(w, TRUE, FALSE, 2 );
+               w.connect( "clicked", G_CALLBACK( size_mm_callback ), ( gpointer ) this );
+               gtk_tooltips_set_tip( pTooltips, w, "Set the size of the image using the mapcoordsmins and mapcoordsmaxs keys of the worldspawn entity", NULL );
+               w.show();
+       }
+
+       hbox.show();
+       frame.show();
+
+       m_pWidget.show();
 }
 
-void CBackgroundDialogPage::Append(GtkWidget *notebook)
-{
-    gtk_notebook_append_page(GTK_NOTEBOOK(notebook), m_pWidget, m_pTabLabel);
+void CBackgroundDialogPage::Append( GtkWidget *notebook ){
+       gtk_notebook_append_page( GTK_NOTEBOOK( notebook ), m_pWidget, m_pTabLabel );
 }
 
 // dialog global callbacks
@@ -310,58 +292,53 @@ void CBackgroundDialogPage::Append(GtkWidget *notebook)
    }
  */
 
-static void response_callback(GtkWidget *widget, gint response, gpointer data)
-{
-    if (response == GTK_RESPONSE_CLOSE) {
-        gtk_widget_hide(pDialogWnd);
-    }
+static void response_callback( GtkWidget *widget, gint response, gpointer data ){
+       if ( response == GTK_RESPONSE_CLOSE ) {
+               gtk_widget_hide( pDialogWnd );
+       }
 }
 
-static gint close_callback(GtkWidget *widget, gpointer data)
-{
-    gtk_widget_hide(pDialogWnd);
-    return TRUE;
+static gint close_callback( GtkWidget *widget, gpointer data ){
+       gtk_widget_hide( pDialogWnd );
+       return TRUE;
 }
 
-void InitBackgroundDialog()
-{
-    CBackgroundDialogPage *pPage;
-
-    pDialogWnd = gtk_dialog_new_with_buttons("Background Images",
-                                             g_pMainWidget,
-                                             (GtkDialogFlags)(GTK_DIALOG_DESTROY_WITH_PARENT),
-            // TODO dialog with no buttons
-            //                                                                           GTK_STOCK_CLOSE,
-            //                                                                           GTK_RESPONSE_CLOSE,
-                                             NULL);
-    pDialogWnd.connect("delete_event", G_CALLBACK(close_callback), NULL);
-    pDialogWnd.connect("response", G_CALLBACK(response_callback), NULL);
+void InitBackgroundDialog(){
+       CBackgroundDialogPage *pPage;
+
+       pDialogWnd = gtk_dialog_new_with_buttons( "Background Images",
+                                                                                         g_pMainWidget,
+                                                                                         (GtkDialogFlags)( GTK_DIALOG_DESTROY_WITH_PARENT ),
+                                                 // TODO dialog with no buttons
+                                                 //                                                                              GTK_STOCK_CLOSE,
+                                                 //                                                                              GTK_RESPONSE_CLOSE,
+                                                                                         NULL );
+       pDialogWnd.connect( "delete_event", G_CALLBACK( close_callback ), NULL );
+       pDialogWnd.connect( "response", G_CALLBACK( response_callback ), NULL );
 //  pDialogWnd.connect( "expose_event", G_CALLBACK( ci_expose ), NULL );
 
-    pTooltips = gtk_tooltips_new();
+       pTooltips = gtk_tooltips_new();
 
-    pNotebook = gtk_notebook_new();
-    pPage = new CBackgroundDialogPage(XY);
-    pPage->Append(pNotebook);
-    pPage = new CBackgroundDialogPage(XZ);
-    pPage->Append(pNotebook);
-    pPage = new CBackgroundDialogPage(YZ);
-    pPage->Append(pNotebook);
+       pNotebook = gtk_notebook_new();
+       pPage = new CBackgroundDialogPage( XY );
+       pPage->Append( pNotebook );
+       pPage = new CBackgroundDialogPage( XZ );
+       pPage->Append( pNotebook );
+       pPage = new CBackgroundDialogPage( YZ );
+       pPage->Append( pNotebook );
 
-    gtk_box_pack_start(GTK_BOX(GTK_DIALOG(pDialogWnd)->vbox), pNotebook, TRUE, TRUE, 0);
+       gtk_box_pack_start( GTK_BOX( GTK_DIALOG( pDialogWnd )->vbox ), pNotebook, TRUE, TRUE, 0 );
 
-    pNotebook.show();
+       pNotebook.show();
 
-    gtk_widget_realize(pDialogWnd);
+       gtk_widget_realize( pDialogWnd );
 }
 
-void ShowBackgroundDialog()
-{
-    gtk_window_present(pDialogWnd);
+void ShowBackgroundDialog(){
+       gtk_window_present( pDialogWnd );
 }
 
-void ShowBackgroundDialogPG(int page)
-{
-    gtk_notebook_set_current_page(GTK_NOTEBOOK(pNotebook), page);
-    ShowBackgroundDialog();
+void ShowBackgroundDialogPG( int page ){
+       gtk_notebook_set_current_page( GTK_NOTEBOOK( pNotebook ),page );
+       ShowBackgroundDialog();
 }
index e442dda..29a511d 100644 (file)
@@ -29,9 +29,7 @@
 #define _BKGRND2D_DIALOG_H_
 
 void InitBackgroundDialog();
-
 void ShowBackgroundDialog();
-
-void ShowBackgroundDialogPG(int page);
+void ShowBackgroundDialogPG( int page );
 
 #endif // _BKGRND2D_DIALOG_H_
index 261b541..35fb072 100644 (file)
@@ -80,248 +80,224 @@ static const char *PLUGIN_NAME = "2d window background plugin";
 
 //backwards for some reason
 static const char *PLUGIN_COMMANDS = CMD_ABOUT ";"
-        CMD_SEP ";"
-        CMD_CONFIG;
+                                                                        CMD_SEP ";"
+                                                                        CMD_CONFIG
+;
 
 static const char *PLUGIN_ABOUT = "2d window background v0.25\n\n"
-        "By reyalP (hellsownpuppy@yahoo.com)";
+                                                                 "By reyalP (hellsownpuppy@yahoo.com)";
 
 
-void DoBkgrndToggleXY();
 
-void DoBkgrndToggleXZ();
 
+void DoBkgrndToggleXY();
+void DoBkgrndToggleXZ();
 void DoBkgrndToggleYZ();
 
 #define NUM_TOOLBAR_BUTTONS 4
-
-struct toolbar_button_info_s {
-    const char *image;
-    const char *text;
-    const char *tip;
-
-    void ( *func )();
-
-    IToolbarButton::EType type;
+struct toolbar_button_info_s
+{
+       const char *image;
+       const char *text;
+       const char *tip;
+       void ( *func )();
+       IToolbarButton::EType type;
 };
 
 struct toolbar_button_info_s toolbar_buttons[NUM_TOOLBAR_BUTTONS] =
-        {
-                {
-                        "bkgrnd2d_xy_toggle.png",
-                        "xy background",
-                        "Toggle xy background image",
-                        DoBkgrndToggleXY,
-                        IToolbarButton::eToggleButton
-                },
-                {
-                        "bkgrnd2d_xz_toggle.png",
-                        "xz background",
-                        "Toggle xz background image",
-                        DoBkgrndToggleXZ,
-                        IToolbarButton::eToggleButton
-                },
-                {
-                        "bkgrnd2d_yz_toggle.png",
-                        "yz background",
-                        "Toggle yz background image",
-                        DoBkgrndToggleYZ,
-                        IToolbarButton::eToggleButton
-                },
-                {
-                        "bkgrnd2d_conf.png",
-                        "Configure",
-                        "Configure background images",
-                        ShowBackgroundDialog,
-                        IToolbarButton::eButton
-                },
-        };
-
-class Bkgrnd2dButton : public IToolbarButton {
+{
+       {
+               "bkgrnd2d_xy_toggle.png",
+               "xy background",
+               "Toggle xy background image",
+               DoBkgrndToggleXY,
+               IToolbarButton::eToggleButton
+       },
+       {
+               "bkgrnd2d_xz_toggle.png",
+               "xz background",
+               "Toggle xz background image",
+               DoBkgrndToggleXZ,
+               IToolbarButton::eToggleButton
+       },
+       {
+               "bkgrnd2d_yz_toggle.png",
+               "yz background",
+               "Toggle yz background image",
+               DoBkgrndToggleYZ,
+               IToolbarButton::eToggleButton
+       },
+       {
+               "bkgrnd2d_conf.png",
+               "Configure",
+               "Configure background images",
+               ShowBackgroundDialog,
+               IToolbarButton::eButton
+       },
+};
+
+class Bkgrnd2dButton : public IToolbarButton
+{
 public:
-    const toolbar_button_info_s *bi;
-
-    virtual const char *getImage() const
-    {
-        return bi->image;
-    }
-
-    virtual const char *getText() const
-    {
-        return bi->text;
-    }
-
-    virtual const char *getTooltip() const
-    {
-        return bi->tip;
-    }
-
-    virtual void activate() const
-    {
-        bi->func();
-        return;
-    }
-
-    virtual EType getType() const
-    {
-        return bi->type;
-    }
+const toolbar_button_info_s *bi;
+virtual const char* getImage() const {
+       return bi->image;
+}
+virtual const char* getText() const {
+       return bi->text;
+}
+virtual const char* getTooltip() const {
+       return bi->tip;
+}
+virtual void activate() const {
+       bi->func();
+       return ;
+}
+virtual EType getType() const {
+       return bi->type;
+}
 };
 
 Bkgrnd2dButton g_bkgrnd2dbuttons[NUM_TOOLBAR_BUTTONS];
 
-unsigned int ToolbarButtonCount()
-{
-    return NUM_TOOLBAR_BUTTONS;
+unsigned int ToolbarButtonCount(){
+       return NUM_TOOLBAR_BUTTONS;
 }
 
-const IToolbarButton *GetToolbarButton(unsigned int index)
-{
-    g_bkgrnd2dbuttons[index].bi = &toolbar_buttons[index];
-    return &g_bkgrnd2dbuttons[index];
+const IToolbarButton* GetToolbarButton( unsigned int index ){
+       g_bkgrnd2dbuttons[index].bi = &toolbar_buttons[index];
+       return &g_bkgrnd2dbuttons[index];
 }
 
-extern "C" const char *QERPlug_Init(void *hApp, void *pMainWidget)
-{
-    g_pMainWidget = pMainWidget;
+extern "C" const char* QERPlug_Init( void *hApp, void* pMainWidget ){
+       g_pMainWidget = pMainWidget;
 
-    InitBackgroundDialog();
-    render.Register();
+       InitBackgroundDialog();
+       render.Register();
 
 //TODO is it right ? is it wrong ? it works
 //TODO figure out supported image types
-    GetFileTypeRegistry()->addType(FILETYPE_KEY, filetype_t("all files", "*.*"));
-    GetFileTypeRegistry()->addType(FILETYPE_KEY, filetype_t("jpeg files", "*.jpg"));
-    GetFileTypeRegistry()->addType(FILETYPE_KEY, filetype_t("targa files", "*.tga"));
-    return (char *) PLUGIN_NAME;
+       GetFileTypeRegistry()->addType( FILETYPE_KEY, filetype_t( "all files", "*.*" ) );
+       GetFileTypeRegistry()->addType( FILETYPE_KEY, filetype_t( "jpeg files", "*.jpg" ) );
+       GetFileTypeRegistry()->addType( FILETYPE_KEY, filetype_t( "targa files", "*.tga" ) );
+       return (char *) PLUGIN_NAME;
 }
 
-extern "C" const char *QERPlug_GetName()
-{
-    return (char *) PLUGIN_NAME;
+extern "C" const char* QERPlug_GetName(){
+       return (char *) PLUGIN_NAME;
 }
 
-extern "C" const char *QERPlug_GetCommandList()
-{
-    return (char *) PLUGIN_COMMANDS;
+extern "C" const char* QERPlug_GetCommandList(){
+       return (char *) PLUGIN_COMMANDS;
 }
 
-extern "C" void QERPlug_Dispatch(const char *p, vec3_t vMin, vec3_t vMax, bool bSingleBrush)
-{
-    Sys_Printf(MSG_PREFIX "Command \"%s\"\n", p);
-    if (!strcmp(p, CMD_ABOUT)) {
-        g_FuncTable.m_pfnMessageBox(NULL, PLUGIN_ABOUT, "About", MB_OK, NULL);
-    } else if (!strcmp(p, CMD_CONFIG)) {
-        ShowBackgroundDialog();
-    }
+extern "C" void QERPlug_Dispatch( const char *p, vec3_t vMin, vec3_t vMax, bool bSingleBrush ){
+       Sys_Printf( MSG_PREFIX "Command \"%s\"\n",p );
+       if ( !strcmp( p, CMD_ABOUT ) ) {
+               g_FuncTable.m_pfnMessageBox( NULL, PLUGIN_ABOUT, "About", MB_OK, NULL );
+       }
+       else if ( !strcmp( p,CMD_CONFIG ) ) {
+               ShowBackgroundDialog();
+       }
 }
 
 //TODO these three suck
-void DoBkgrndToggleXY()
-{
-    Sys_Printf(MSG_PREFIX "DoBkgrndToggleXY\n");
-    // always toggle, since the buttons do
-    backgroundXY.m_bActive = (backgroundXY.m_bActive) ? false : true;
-    // if we don't have image or extents, and we activated,
-    // bring up the dialog with the corresponding page
-    // would be better to hide or grey out button, but we can't
-    if (backgroundXY.m_bActive && !backgroundXY.Valid()) {
-        ShowBackgroundDialogPG(0);
-    } else {
-        g_FuncTable.m_pfnSysUpdateWindows(W_XY);
-    }
+void DoBkgrndToggleXY(){
+       Sys_Printf( MSG_PREFIX "DoBkgrndToggleXY\n" );
+       // always toggle, since the buttons do
+       backgroundXY.m_bActive = ( backgroundXY.m_bActive ) ? false : true;
+       // if we don't have image or extents, and we activated,
+       // bring up the dialog with the corresponding page
+       // would be better to hide or grey out button, but we can't
+       if ( backgroundXY.m_bActive && !backgroundXY.Valid() ) {
+               ShowBackgroundDialogPG( 0 );
+       }
+       else{
+               g_FuncTable.m_pfnSysUpdateWindows( W_XY );
+       }
 }
 
-void DoBkgrndToggleXZ()
-{
-    Sys_Printf(MSG_PREFIX "DoBkgrndToggleXZ\n");
-    backgroundXZ.m_bActive = (backgroundXZ.m_bActive) ? false : true;
-    if (backgroundXZ.m_bActive && !backgroundXZ.Valid()) {
-        ShowBackgroundDialogPG(1);
-    } else {
-        g_FuncTable.m_pfnSysUpdateWindows(W_XY);
-    }
+void DoBkgrndToggleXZ(){
+       Sys_Printf( MSG_PREFIX "DoBkgrndToggleXZ\n" );
+       backgroundXZ.m_bActive = ( backgroundXZ.m_bActive ) ? false : true;
+       if ( backgroundXZ.m_bActive && !backgroundXZ.Valid() ) {
+               ShowBackgroundDialogPG( 1 );
+       }
+       else{
+               g_FuncTable.m_pfnSysUpdateWindows( W_XY );
+       }
 }
 
-void DoBkgrndToggleYZ()
-{
-    Sys_Printf(MSG_PREFIX "DoBkgrndToggleYZ\n");
-    backgroundYZ.m_bActive = (backgroundYZ.m_bActive) ? false : true;
-    if (backgroundYZ.m_bActive && !backgroundYZ.Valid()) {
-        ShowBackgroundDialogPG(2);
-    } else {
-        g_FuncTable.m_pfnSysUpdateWindows(W_XY);
-    }
+void DoBkgrndToggleYZ(){
+       Sys_Printf( MSG_PREFIX "DoBkgrndToggleYZ\n" );
+       backgroundYZ.m_bActive = ( backgroundYZ.m_bActive ) ? false : true;
+       if ( backgroundYZ.m_bActive && !backgroundYZ.Valid() ) {
+               ShowBackgroundDialogPG( 2 );
+       }
+       else{
+               g_FuncTable.m_pfnSysUpdateWindows( W_XY );
+       }
 }
 
 // =============================================================================
 // SYNAPSE
 
-CSynapseServer *g_pSynapseServer = NULL;
+CSynapseServerg_pSynapseServer = NULL;
 CSynapseClientBkgrnd2d g_SynapseClient;
 
-extern "C" CSynapseClient *SYNAPSE_DLL_EXPORT
+extern "C" CSynapseClient * SYNAPSE_DLL_EXPORT Synapse_EnumerateInterfaces( const char *version, CSynapseServer *pServer ){
+       if ( strcmp( version, SYNAPSE_VERSION ) ) {
+               Syn_Printf( "ERROR: synapse API version mismatch: should be '" SYNAPSE_VERSION "', got '%s'\n", version );
+               return NULL;
+       }
+       g_pSynapseServer = pServer;
+       g_pSynapseServer->IncRef();
+       Set_Syn_Printf( g_pSynapseServer->Get_Syn_Printf() );
 
-Synapse_EnumerateInterfaces(const char *version, CSynapseServer *pServer)
-{
-    if (strcmp(version, SYNAPSE_VERSION)) {
-        Syn_Printf("ERROR: synapse API version mismatch: should be '"
-        SYNAPSE_VERSION
-        "', got '%s'\n", version );
-        return NULL;
-    }
-    g_pSynapseServer = pServer;
-    g_pSynapseServer->IncRef();
-    Set_Syn_Printf(g_pSynapseServer->Get_Syn_Printf());
-
-    g_SynapseClient.AddAPI(TOOLBAR_MAJOR, BKGRND2D_MINOR, sizeof(_QERPlugToolbarTable));
-    g_SynapseClient.AddAPI(PLUGIN_MAJOR, BKGRND2D_MINOR, sizeof(_QERPluginTable));
-
-    g_SynapseClient.AddAPI(RADIANT_MAJOR, NULL, sizeof(g_FuncTable), SYN_REQUIRE, &g_FuncTable);
-    g_SynapseClient.AddAPI(QGL_MAJOR, NULL, sizeof(g_QglTable), SYN_REQUIRE, &g_QglTable);
+       g_SynapseClient.AddAPI( TOOLBAR_MAJOR, BKGRND2D_MINOR, sizeof( _QERPlugToolbarTable ) );
+       g_SynapseClient.AddAPI( PLUGIN_MAJOR, BKGRND2D_MINOR, sizeof( _QERPluginTable ) );
+
+       g_SynapseClient.AddAPI( RADIANT_MAJOR, NULL, sizeof( g_FuncTable ), SYN_REQUIRE, &g_FuncTable );
+       g_SynapseClient.AddAPI( QGL_MAJOR, NULL, sizeof( g_QglTable ), SYN_REQUIRE, &g_QglTable );
 // TODO is this the right way to ask for 'whichever VFS we have loaded' ? Seems to work
 // for misc filename functions
-    g_SynapseClient.AddAPI(VFS_MAJOR, "*", sizeof(g_FileSystemTable), SYN_REQUIRE, &g_FileSystemTable);
+       g_SynapseClient.AddAPI( VFS_MAJOR, "*", sizeof( g_FileSystemTable ), SYN_REQUIRE, &g_FileSystemTable );
 // get worldspawn
-    g_SynapseClient.AddAPI(ENTITY_MAJOR, NULL, sizeof(g_EntityTable), SYN_REQUIRE, &g_EntityTable);
+       g_SynapseClient.AddAPI( ENTITY_MAJOR, NULL, sizeof( g_EntityTable ), SYN_REQUIRE, &g_EntityTable );
 // selected brushes
-    g_SynapseClient.AddAPI(DATA_MAJOR, NULL, sizeof(g_DataTable), SYN_REQUIRE, &g_DataTable);
+       g_SynapseClient.AddAPI( DATA_MAJOR, NULL, sizeof( g_DataTable ), SYN_REQUIRE, &g_DataTable );
 
-    return &g_SynapseClient;
+       return &g_SynapseClient;
 }
 
-bool CSynapseClientBkgrnd2d::RequestAPI(APIDescriptor_t *pAPI)
-{
-    if (!strcmp(pAPI->major_name, PLUGIN_MAJOR)) {
-        _QERPluginTable *pTable = static_cast<_QERPluginTable *>( pAPI->mpTable );
-
-        pTable->m_pfnQERPlug_Init = QERPlug_Init;
-        pTable->m_pfnQERPlug_GetName = QERPlug_GetName;
-        pTable->m_pfnQERPlug_GetCommandList = QERPlug_GetCommandList;
-        pTable->m_pfnQERPlug_Dispatch = QERPlug_Dispatch;
-        return true;
-    }
-    if (!strcmp(pAPI->major_name, TOOLBAR_MAJOR)) {
-        _QERPlugToolbarTable *pTable = static_cast<_QERPlugToolbarTable *>( pAPI->mpTable );
-
-        pTable->m_pfnToolbarButtonCount = &ToolbarButtonCount;
-        pTable->m_pfnGetToolbarButton = &GetToolbarButton;
-        return true;
-    }
-
-    Syn_Printf("ERROR: RequestAPI( '%s' ) not found in '%s'\n", pAPI->major_name, GetInfo());
-    return false;
+bool CSynapseClientBkgrnd2d::RequestAPI( APIDescriptor_t *pAPI ){
+       if ( !strcmp( pAPI->major_name, PLUGIN_MAJOR ) ) {
+               _QERPluginTable* pTable = static_cast<_QERPluginTable*>( pAPI->mpTable );
+
+               pTable->m_pfnQERPlug_Init = QERPlug_Init;
+               pTable->m_pfnQERPlug_GetName = QERPlug_GetName;
+               pTable->m_pfnQERPlug_GetCommandList = QERPlug_GetCommandList;
+               pTable->m_pfnQERPlug_Dispatch = QERPlug_Dispatch;
+               return true;
+       }
+       if ( !strcmp( pAPI->major_name, TOOLBAR_MAJOR ) ) {
+               _QERPlugToolbarTable* pTable = static_cast<_QERPlugToolbarTable*>( pAPI->mpTable );
+
+               pTable->m_pfnToolbarButtonCount = &ToolbarButtonCount;
+               pTable->m_pfnGetToolbarButton = &GetToolbarButton;
+               return true;
+       }
+
+       Syn_Printf( "ERROR: RequestAPI( '%s' ) not found in '%s'\n", pAPI->major_name, GetInfo() );
+       return false;
 }
 
 #include "version.h"
 
-const char *CSynapseClientBkgrnd2d::GetInfo()
-{
-    return "2d Background plugin built " __DATE__ " "
-    RADIANT_VERSION;
+const char* CSynapseClientBkgrnd2d::GetInfo(){
+       return "2d Background plugin built " __DATE__ " " RADIANT_VERSION;
 }
 
-const char *CSynapseClientBkgrnd2d::GetName()
-{
-    return "bkgrnd2d";
+const char* CSynapseClientBkgrnd2d::GetName(){
+       return "bkgrnd2d";
 }
index 361bf83..13ca737 100644 (file)
@@ -41,9 +41,7 @@
 #include "synapse.h"
 #include "iplugin.h"
 #include "itoolbar.h"
-
 #define USE_QERTABLE_DEFINE
-
 #include "qerplugin.h"
 #include "igl.h"
 #include "ifilesystem.h"
@@ -60,24 +58,19 @@ extern _QEREntityTable g_EntityTable;
 extern _QERAppDataTable g_DataTable;
 extern void *g_pMainWidget;
 
-extern CSynapseServer *g_pSynapseServer;
+extern CSynapseServerg_pSynapseServer;
 
-class CSynapseClientBkgrnd2d : public CSynapseClient {
+class CSynapseClientBkgrnd2d : public CSynapseClient
+{
 public:
 // CSynapseClient API
-    bool RequestAPI(APIDescriptor_t *pAPI);
-
-    const char *GetInfo();
+bool RequestAPI( APIDescriptor_t *pAPI );
+const char* GetInfo();
+const char* GetName();
 
-    const char *GetName();
-
-    CSynapseClientBkgrnd2d()
-    {}
-
-    virtual ~CSynapseClientBkgrnd2d()
-    {}
+CSynapseClientBkgrnd2d() { }
+virtual ~CSynapseClientBkgrnd2d() { }
 };
-
 #define MSG_PREFIX "bkgrnd2d: "
 #define MSG_WARN "bkgrnd2d WARNING: "
 #define BKGRND2D_MINOR "bkgrnd2d"
index eea867c..fc55553 100644 (file)
 
 class CBspPoint {
 public:
-    float p[3];
+float p[3];
 };
 
 class CBspPortal {
 public:
-    CBspPortal();
+CBspPortal();
+~CBspPortal();
 
-    ~CBspPortal();
-
-    unsigned point_count;
-    CBspPoint *point;
-
-    bool Build(char *def, unsigned int pointCnt, bool bInverse);
+unsigned point_count;
+CBspPoint *point;
+bool Build( char *def, unsigned int pointCnt, bool bInverse );
 };
 
 
 class CBspNode {
 public:
-    CBspPortal *portal;
-    unsigned int portal_count;
-
-    bool AddPortal(char *def, unsigned int pointCnt, bool bInverse);
+CBspPortal *portal;
+unsigned int portal_count;
 
-    unsigned int portal_next;
-
-    CBspNode();
-
-    ~CBspNode();
+bool AddPortal( char* def, unsigned int pointCnt, bool bInverse );
+unsigned int portal_next;
+CBspNode();
+~CBspNode();
 };
 
 
@@ -55,15 +50,14 @@ public:
 class CPortals {
 public:
 
-    CPortals();
-
-    ~CPortals();
+CPortals();
+~CPortals();
 
-    void Load();     // use filename in fn
-    void Purge();
+void Load();     // use filename in fn
+void Purge();
 
-    char fn[NAME_MAX];
-    CBspNode *node;
+char fn[NAME_MAX];
+CBspNode *node;
 
-    unsigned int node_count;
+unsigned int node_count;
 };
index 940d191..decfe77 100644 (file)
 // Construction/Destruction
 //////////////////////////////////////////////////////////////////////
 
-DBobView::DBobView()
-{
-    nPathCount = 0;
+DBobView::DBobView(){
+       nPathCount = 0;
 
-    path = NULL;
+       path = NULL;
 
-    boundingShow = BOUNDS_APEX;
+       boundingShow = BOUNDS_APEX;
 
-    constructShaders();
-    GlobalShaderCache().attachRenderable(*this);
+       constructShaders();
+       GlobalShaderCache().attachRenderable( *this );
 }
 
-DBobView::~DBobView()
-{
-    GlobalShaderCache().detachRenderable(*this);
-    destroyShaders();
+DBobView::~DBobView(){
+       GlobalShaderCache().detachRenderable( *this );
+       destroyShaders();
 
-    if (path) {
-        delete[] path;
-    }
+       if ( path ) {
+               delete[] path;
+       }
 
-    g_PathView = NULL;
+       g_PathView = NULL;
 }
 
 //////////////////////////////////////////////////////////////////////
 // Implementation
 //////////////////////////////////////////////////////////////////////
 
-void DBobView::render(RenderStateFlags state) const
-{
-    glBegin(GL_LINE_STRIP);
+void DBobView::render( RenderStateFlags state ) const {
+       glBegin( GL_LINE_STRIP );
 
-    for (int i = 0; i < nPathCount; i++)
-        glVertex3fv(path[i]);
+       for ( int i = 0; i < nPathCount; i++ )
+               glVertex3fv( path[i] );
 
-    glEnd();
+       glEnd();
 }
 
-const char *DBobView_state_line = "$bobtoolz/bobview/line";
-const char *DBobView_state_box = "$bobtoolz/bobview/box";
-
-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);
+const char* DBobView_state_line = "$bobtoolz/bobview/line";
+const char* DBobView_state_box = "$bobtoolz/bobview/box";
+
+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 );
 }
 
-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::destroyShaders(){
+       GlobalOpenGLStateLibrary().erase( DBobView_state_line );
+       GlobalOpenGLStateLibrary().erase( DBobView_state_box );
+       GlobalShaderCache().release( DBobView_state_line );
+       GlobalShaderCache().release( DBobView_state_box );
 }
 
-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;
-    }
-
-    renderer.SetState(m_shader_line, Renderer::eWireframeOnly);
-    renderer.SetState(m_shader_line, Renderer::eFullMaterials);
-    renderer.addRenderable(*this, g_matrix4_identity);
-
-    if (m_bShowExtra) {
-        renderer.SetState(m_shader_box, Renderer::eWireframeOnly);
-        renderer.SetState(m_shader_box, Renderer::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);
-    }
+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;
+       }
+
+       renderer.SetState( m_shader_line, Renderer::eWireframeOnly );
+       renderer.SetState( m_shader_line, Renderer::eFullMaterials );
+       renderer.addRenderable( *this, g_matrix4_identity );
+
+       if ( m_bShowExtra ) {
+               renderer.SetState( m_shader_box, Renderer::eWireframeOnly );
+               renderer.SetState( m_shader_box, Renderer::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::renderWireframe(Renderer &renderer, const VolumeTest &volume) const
-{
-    renderSolid(renderer, volume);
+void DBobView::renderWireframe( Renderer& renderer, const VolumeTest& volume ) const {
+       renderSolid( renderer, volume );
 }
 
-void DBobView::SetPath(vec3_t *pPath)
-{
-    if (path) {
-        delete[] path;
-    }
+void DBobView::SetPath( vec3_t *pPath ){
+       if ( path ) {
+               delete[] path;
+       }
 
-    path = pPath;
+       path = pPath;
 }
 
 const float LOCAL_GRAVITY = -800.0f;
 
-bool DBobView::CalculateTrajectory(vec3_t start, vec3_t apex, float multiplier, int points, float varGravity)
-{
-    if (apex[2] <= start[2]) {
-        SetPath(NULL);
-        return false;
-    }
-    // ----think q3a actually would allow these
-    //scrub that, coz the plugin wont :]
+bool DBobView::CalculateTrajectory( vec3_t start, vec3_t apex, float multiplier, int points, float varGravity ){
+       if ( apex[2] <= start[2] ) {
+               SetPath( NULL );
+               return false;
+       }
+       // ----think q3a actually would allow these
+       //scrub that, coz the plugin wont :]
 
-    vec3_t dist, speed;
-    VectorSubtract(apex, start, dist);
+       vec3_t dist, speed;
+       VectorSubtract( apex, start, dist );
 
-    vec_t speed_z = (float) sqrt(-2 * LOCAL_GRAVITY * dist[2]);
-    float flight_time = -speed_z / LOCAL_GRAVITY;
+       vec_t speed_z = (float)sqrt( -2 * LOCAL_GRAVITY * dist[2] );
+       float flight_time = -speed_z / LOCAL_GRAVITY;
 
 
-    VectorScale(dist, 1 / flight_time, speed);
-    speed[2] = speed_z;
+       VectorScale( dist, 1 / flight_time, speed );
+       speed[2] = speed_z;
 
 //     Sys_Printf("Speed: (%.4f %.4f %.4f)\n", speed[0], speed[1], speed[2]);
 
-    vec3_t *pPath = new vec3_t[points];
+       vec3_t* pPath = new vec3_t[points];
 
-    float interval = multiplier * flight_time / points;
-    for (int i = 0; i < points; i++) {
-        float ltime = interval * i;
+       float interval = multiplier * flight_time / points;
+       for ( int i = 0; i < points; i++ )
+       {
+               float ltime = interval * i;
 
-        VectorScale(speed, ltime, pPath[i]);
-        VectorAdd(pPath[i], start, pPath[i]);
+               VectorScale( speed, ltime, pPath[i] );
+               VectorAdd( pPath[i], start, pPath[i] );
 
-        // could do this all with vectors
-        // vGrav = {0, 0, -800.0f}
-        // VectorScale(vGrav, 0.5f*ltime*ltime, vAdd);
-        // VectorScale(speed, ltime, pPath[i]);
-        // _VectorAdd(pPath[i], start, pPath[i])
-        // _VectorAdd(pPath[i], vAdd, pPath[i])
+               // could do this all with vectors
+               // vGrav = {0, 0, -800.0f}
+               // VectorScale(vGrav, 0.5f*ltime*ltime, vAdd);
+               // VectorScale(speed, ltime, pPath[i]);
+               // _VectorAdd(pPath[i], start, pPath[i])
+               // _VectorAdd(pPath[i], vAdd, pPath[i])
 
-        pPath[i][2] = start[2] + (speed_z * ltime) + (varGravity * 0.5f * ltime * ltime);
-    }
+               pPath[i][2] = start[2] + ( speed_z * ltime ) + ( varGravity * 0.5f * ltime * ltime );
+       }
 
-    SetPath(pPath);
-    return true;
+       SetPath( pPath );
+       return true;
 }
 
-void
-DBobView::Begin(const char *trigger, const char *target, float multiplier, int points, float varGravity, bool bNoUpdate,
-                bool bShowExtra)
-{
-    strcpy(entTrigger, trigger);
-    strcpy(entTarget, target);
-
-    fMultiplier = multiplier;
-    fVarGravity = varGravity;
-    nPathCount = points;
-    m_bShowExtra = bShowExtra;
-
-    if (!UpdatePath()) {
-        globalErrorStream() << "Initialization Failure in DBobView::Begin";
-        delete this;
-    }
-    globalOutputStream() << "Initialization of Path Plotter succeeded.";
+void DBobView::Begin( const char* trigger, const char *target, float multiplier, int points, float varGravity, bool bNoUpdate, bool bShowExtra ){
+       strcpy( entTrigger, trigger );
+       strcpy( entTarget, target );
+
+       fMultiplier = multiplier;
+       fVarGravity = varGravity;
+       nPathCount = points;
+       m_bShowExtra = bShowExtra;
+
+       if ( !UpdatePath() ) {
+               globalErrorStream() << "Initialization Failure in DBobView::Begin";
+               delete this;
+       }
+       globalOutputStream() << "Initialization of Path Plotter succeeded.";
 }
 
-bool DBobView::UpdatePath()
-{
-    vec3_t start, apex;
-
-    if (GetEntityCentre(entTrigger, start)) {
-        if (GetEntityCentre(entTarget, apex)) {
-            CalculateTrajectory(start, apex, fMultiplier, nPathCount, fVarGravity);
-            return true;
-        }
-    }
-    return false;
+bool DBobView::UpdatePath(){
+       vec3_t start, apex;
+
+       if ( GetEntityCentre( entTrigger, start ) ) {
+               if ( GetEntityCentre( entTarget, apex ) ) {
+                       CalculateTrajectory( start, apex, fMultiplier, nPathCount, fVarGravity );
+                       return true;
+               }
+       }
+       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) {
-                const scene::Path *entTarget = FindEntityFromTargetname(target_ep->value);
-                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 {
-                        globalErrorStream() << "bobToolz PathPlotter: trigger_push ARGH\n";
-                    }
-                } else {
-                    globalErrorStream() << "bobToolz PathPlotter: trigger_push target could not be found..\n";
-                }
-            } else {
-                globalErrorStream() << "bobToolz PathPlotter: trigger_push has no target..\n";
-            }
-        } else {
-            globalErrorStream() << "bobToolz PathPlotter: You must select a 'trigger_push' entity..\n";
-        }
-    } else {
-        globalErrorStream() << "bobToolz PathPlotter: Entity must have a targetname.\n";
-    }
-    return;
+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 ) {
+                               const scene::Path* entTarget = FindEntityFromTargetname( target_ep->value );
+                               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{
+                                               globalErrorStream() << "bobToolz PathPlotter: trigger_push ARGH\n";
+                                       }
+                               }
+                               else{
+                                       globalErrorStream() << "bobToolz PathPlotter: trigger_push target could not be found..\n";
+                               }
+                       }
+                       else{
+                               globalErrorStream() << "bobToolz PathPlotter: trigger_push has no target..\n";
+                       }
+               }
+               else{
+                       globalErrorStream() << "bobToolz PathPlotter: You must select a 'trigger_push' entity..\n";
+               }
+       }
+       else{
+               globalErrorStream() << "bobToolz PathPlotter: Entity must have a targetname.\n";
+       }
+       return;
 }
index f0f40fd..b20ef14 100644 (file)
 #include "mathlib.h"
 
 class DListener;
-
 class Shader;
 
-const int BOUNDS_ALL = 0;
+const int BOUNDS_ALL  = 0;
 const int BOUNDS_APEX = 1;
 
 #if _MSC_VER > 1000
 #pragma once
 #endif // _MSC_VER > 1000
 
-class DBobView : public Renderable, public OpenGLRenderable, public Entity::Observer {
-    Shader *m_shader_line;
-    Shader *m_shader_box;
+class DBobView : public Renderable, public OpenGLRenderable, public Entity::Observer
+{
+Shader* m_shader_line;
+Shader* m_shader_box;
 public:
-    DBobView();
-
-    virtual ~DBobView();
+DBobView();
+virtual ~DBobView();
 
 protected:
-    vec3_t *path;
+vec3_t* path;
 public:
-    bool m_bShowExtra;
-    int boundingShow;
-    DListener *eyes;
-    float fVarGravity;
-    float fMultiplier;
-    int nPathCount;
-
-    Entity *trigger;
-    Entity *target;
-
-    bool UpdatePath();
-
-    char entTarget[256];
-    char entTrigger[256];
-
-    void Begin(const char *, const char *, float, int, float, bool, bool);
-
-    bool CalculateTrajectory(vec3_t, vec3_t, float, int, float);
-
-    void SetPath(vec3_t *pPath);
-
-    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 MemberCaller<DBobView, void(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;
-        }
-    }
+bool m_bShowExtra;
+int boundingShow;
+DListener* eyes;
+float fVarGravity;
+float fMultiplier;
+int nPathCount;
+
+Entity* trigger;
+Entity* target;
+
+bool UpdatePath();
+char entTarget[256];
+char entTrigger[256];
+void Begin( const char*, const char*, float, int, float, bool, bool );
+bool CalculateTrajectory( vec3_t, vec3_t, float, int, float );
+
+void SetPath( vec3_t* pPath );
+
+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 MemberCaller<DBobView, void(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);
+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_)
index a5b18ce..a0d9769 100644 (file)
 // Construction/Destruction
 //////////////////////////////////////////////////////////////////////
 
-DBrush::DBrush(int ID)
-{
-    m_nBrushID = ID;
-    bBoundsBuilt = false;
-    QER_entity = NULL;
-    QER_brush = NULL;
+DBrush::DBrush( int ID ){
+       m_nBrushID = ID;
+       bBoundsBuilt = false;
+       QER_entity = NULL;
+       QER_brush = NULL;
 }
 
-DBrush::~DBrush()
-{
-    ClearFaces();
-    ClearPoints();
+DBrush::~DBrush(){
+       ClearFaces();
+       ClearPoints();
 }
 
 //////////////////////////////////////////////////////////////////////
 // Implementation
 //////////////////////////////////////////////////////////////////////
 
-DPlane *DBrush::AddFace(const vec3_t va, const vec3_t vb, const vec3_t vc, const _QERFaceData *texData)
-{
+DPlane* DBrush::AddFace( const vec3_t va, const vec3_t vb, const vec3_t vc, const _QERFaceData* texData ){
 #if GDEF_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;
-    DPlane *newFace = new DPlane(va, vb, vc, texData);
-    faceList.push_back(newFace);
-
-    return newFace;
-}
-
-int DBrush::BuildPoints()
-{
-    ClearPoints();
-
-    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 (std::list<DPlane *>::const_iterator p1 = faceList.begin(); p1 != faceList.end(); p1++) {
-        std::list<DPlane *>::const_iterator p2 = p1;
-        for (p2++; p2 != faceList.end(); p2++) {
-            std::list<DPlane *>::const_iterator p3 = p2;
-            for (p3++; p3 != faceList.end(); p3++) {
-                vec3_t pnt;
-                if ((*p1)->PlaneIntersection(*p2, *p3, pnt)) {
-                    int pos = PointPosition(pnt);
-
-                    if (pos == POINT_IN_BRUSH) { // ???? shouldn't happen here
-                        globalErrorStream() << "ERROR:: Build Brush Points: Point IN brush!!!\n";
-                    } else if (pos == POINT_ON_BRUSH) { // normal point
-                        if (!HasPoint(pnt)) {
-                            AddPoint(pnt);
-                        }
+       bBoundsBuilt = false;
+       DPlane* newFace = new DPlane( va, vb, vc, texData );
+       faceList.push_back( newFace );
+
+       return newFace;
+}
+
+int DBrush::BuildPoints(){
+       ClearPoints();
+
+       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 ( std::list<DPlane *>::const_iterator p1 = faceList.begin(); p1 != faceList.end(); p1++ )
+       {
+               std::list<DPlane *>::const_iterator p2 = p1;
+               for ( p2++; p2 != faceList.end(); p2++ )
+               {
+                       std::list<DPlane *>::const_iterator p3 = p2;
+                       for ( p3++; p3 != faceList.end(); p3++ )
+                       {
+                               vec3_t pnt;
+                               if ( ( *p1 )->PlaneIntersection( *p2, *p3, pnt ) ) {
+                                       int pos = PointPosition( pnt );
+
+                                       if ( pos == POINT_IN_BRUSH ) { // ???? shouldn't happen here
+                                               globalErrorStream() << "ERROR:: Build Brush Points: Point IN brush!!!\n";
+                                       }
+                                       else if ( pos == POINT_ON_BRUSH ) { // normal point
+                                               if ( !HasPoint( pnt ) ) {
+                                                       AddPoint( pnt );
+                                               }
 /*                                             else
                             Sys_Printf("Duplicate Point Found, pyramids ahoy!!!!!\n");*/
-                        // point lies on more that 3 planes
-                    }
+                                               // point lies on more that 3 planes
+                                       }
 
-                    // otherwise point is removed due to another plane..
+                                       // otherwise point is removed due to another plane..
 
-                    // Sys_Printf("(%f, %f, %f)\n", pnt[0], pnt[1], pnt[2]);
-                }
-            }
-        }
-    }
+                                       // Sys_Printf("(%f, %f, %f)\n", pnt[0], pnt[1], pnt[2]);
+                               }
+                       }
+               }
+       }
 
 #if GDEF_DEBUG
 //     Sys_Printf("%i points on brush\n", pointList.size());
 #endif
 
-    return static_cast<int>( pointList.size());
+       return static_cast<int>( pointList.size() );
 }
 
-void DBrush_addFace(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), 0);
+void DBrush_addFace( 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 ), 0 );
 }
+typedef ReferenceCaller<DBrush, void(const _QERFaceData&), DBrush_addFace> DBrushAddFaceCaller;
 
-typedef ReferenceCaller<DBrush, void(const _QERFaceData &), DBrush_addFace> DBrushAddFaceCaller;
-
-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);
+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 ReferenceCaller<DBrush, void(const _QERFaceData&), DBrush_addFaceTextured> DBrushAddFaceTexturedCaller;
 
-typedef ReferenceCaller<DBrush, void(const _QERFaceData &), DBrush_addFaceTextured> DBrushAddFaceTexturedCaller;
-
-void DBrush::LoadFromBrush(scene::Instance &brush, bool textured)
-{
-    ClearFaces();
-    ClearPoints();
+void DBrush::LoadFromBrush( scene::Instance& brush, bool textured ){
+       ClearFaces();
+       ClearPoints();
 
-    GlobalBrushCreator().Brush_forEachFace(brush.path().top(),
-                                           textured ? BrushFaceDataCallback(DBrushAddFaceTexturedCaller(*this))
-                                                    : BrushFaceDataCallback(DBrushAddFaceCaller(*this)));
+       GlobalBrushCreator().Brush_forEachFace( brush.path().top(), textured ? BrushFaceDataCallback( DBrushAddFaceTexturedCaller( *this ) ) : BrushFaceDataCallback( DBrushAddFaceCaller( *this ) ) );
 
-    QER_entity = brush.path().parent().get_pointer();
-    QER_brush = brush.path().top().get_pointer();
+       QER_entity = brush.path().parent().get_pointer();
+       QER_brush = brush.path().top().get_pointer();
 }
 
-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 (std::list<DPlane *>::const_iterator chkPlane = faceList.begin(); chkPlane != faceList.end(); chkPlane++) {
-        float dist = (*chkPlane)->DistanceToPoint(pnt);
+       for ( std::list<DPlane *>::const_iterator chkPlane = faceList.begin(); chkPlane != faceList.end(); chkPlane++ )
+       {
+               float dist = ( *chkPlane )->DistanceToPoint( pnt );
 
-        if (dist > MAX_ROUND_ERROR) {
-            return POINT_OUT_BRUSH;     // if point is in front of plane, it CANT be in the brush
-        } else if (fabs(dist) < MAX_ROUND_ERROR) {
-            state = POINT_ON_BRUSH;     // if point is ON plane point is either ON the brush
-        }
-        // or outside it, it can no longer be in it
-    }
+               if ( dist > MAX_ROUND_ERROR ) {
+                       return POINT_OUT_BRUSH;     // if point is in front of plane, it CANT be in the brush
+               }
+               else if ( fabs( dist ) < MAX_ROUND_ERROR ) {
+                       state = POINT_ON_BRUSH;     // if point is ON plane point is either ON the brush
+               }
+               // or outside it, it can no longer be in it
+       }
 
-    return state;
+       return state;
 }
 
-void DBrush::ClearPoints()
-{
-    for (std::list<DPoint *>::const_iterator deadPoint = pointList.begin(); deadPoint != pointList.end(); deadPoint++) {
-        delete *deadPoint;
-    }
-    pointList.clear();
+void DBrush::ClearPoints(){
+       for ( std::list<DPoint *>::const_iterator deadPoint = pointList.begin(); deadPoint != pointList.end(); deadPoint++ ) {
+               delete *deadPoint;
+       }
+       pointList.clear();
 }
 
-void DBrush::ClearFaces()
-{
-    bBoundsBuilt = false;
-    for (std::list<DPlane *>::const_iterator deadPlane = faceList.begin(); deadPlane != faceList.end(); deadPlane++) {
-        delete *deadPlane;
-    }
-    faceList.clear();
+void DBrush::ClearFaces(){
+       bBoundsBuilt = false;
+       for ( std::list<DPlane *>::const_iterator deadPlane = faceList.begin(); deadPlane != faceList.end(); deadPlane++ )
+       {
+               delete *deadPlane;
+       }
+       faceList.clear();
 }
 
-void DBrush::AddPoint(vec3_t pnt)
-{
-    DPoint *newPoint = new DPoint;
-    VectorCopy(pnt, newPoint->_pnt);
-    pointList.push_back(newPoint);
+void DBrush::AddPoint( vec3_t pnt ){
+       DPoint* newPoint = new DPoint;
+       VectorCopy( pnt, newPoint->_pnt );
+       pointList.push_back( newPoint );
 }
 
-bool DBrush::HasPoint(vec3_t pnt)
-{
-    for (std::list<DPoint *>::const_iterator chkPoint = pointList.begin(); chkPoint != pointList.end(); chkPoint++) {
-        if (**chkPoint == pnt) {
-            return true;
-        }
-    }
+bool DBrush::HasPoint( vec3_t pnt ){
+       for ( std::list<DPoint *>::const_iterator chkPoint = pointList.begin(); chkPoint != pointList.end(); chkPoint++ )
+       {
+               if ( **chkPoint == pnt ) {
+                       return true;
+               }
+       }
 
-    return false;
+       return false;
 }
 
-int DBrush::RemoveRedundantPlanes()
-{
-    int cnt = 0;
-    std::list<DPlane *>::iterator chkPlane;
-
-    // find duplicate planes
-    std::list<DPlane *>::iterator p1 = faceList.begin();
+int DBrush::RemoveRedundantPlanes(){
+       int cnt = 0;
+       std::list<DPlane *>::iterator chkPlane;
 
-    while (p1 != faceList.end()) {
-        std::list<DPlane *>::iterator p2 = p1;
+       // find duplicate planes
+       std::list<DPlane *>::iterator p1 = faceList.begin();
 
-        for (p2++; p2 != faceList.end(); p2++) {
-            if (**p1 == **p2) {
-                if (!strcmp((*p1)->m_shader.c_str(), "textures/common/caulk")) {
-                    delete *p1;
-                    p1 = faceList.erase(p1);    // duplicate plane
-                } else {
-                    delete *p2;
-                    p2 = faceList.erase(p2);    // duplicate plane
-                }
+       while ( p1 != faceList.end() )
+       {
+               std::list<DPlane *>::iterator p2 = p1;
 
-                cnt++;
-                break;
-            }
-        }
-
-        if (p2 == faceList.end()) {
-            p1++;
-        }
-    }
+               for ( p2++; p2 != faceList.end(); p2++ )
+               {
+                       if ( **p1 == **p2 ) {
+                               if ( !strcmp( ( *p1 )->m_shader.c_str(), "textures/common/caulk" ) ) {
+                                       delete *p1;
+                                       p1 = faceList.erase( p1 );    // duplicate plane
+                               }
+                               else
+                               {
+                                       delete *p2;
+                                       p2 = faceList.erase( p2 );    // duplicate plane
+                               }
 
-    //+djbob kill planes with bad normal, they are more of a nuisance than losing a brush
-    chkPlane = faceList.begin();
-    while (chkPlane != faceList.end()) {
-        if (VectorLength((*chkPlane)->normal) == 0) { // plane has bad normal
-            delete *chkPlane;
-            chkPlane = faceList.erase(chkPlane);
-            cnt++;
-        } else {
-            chkPlane++;
-        }
-    }
-    //-djbob
-
-    if (pointList.size() == 0) { // if points may not have been built, build them
+                               cnt++;
+                               break;
+                       }
+               }
+
+               if ( p2 == faceList.end() ) {
+                       p1++;
+               }
+       }
+
+       //+djbob kill planes with bad normal, they are more of a nuisance than losing a brush
+       chkPlane = faceList.begin();
+       while ( chkPlane != faceList.end() )
+       {
+               if ( VectorLength( ( *chkPlane )->normal ) == 0 ) { // plane has bad normal
+                       delete *chkPlane;
+                       chkPlane = faceList.erase( chkPlane );
+                       cnt++;
+               }
+               else {
+                       chkPlane++;
+               }
+       }
+       //-djbob
+
+       if ( pointList.size() == 0 ) { // if points may not have been built, build them
 /*             if(BuildPoints() == 0)  // just let the planes die if they are all bad
             return cnt;*/
-        BuildPoints();
-    }
-
-    chkPlane = faceList.begin();
-    while (chkPlane != faceList.end()) {
-        if ((*chkPlane)->IsRedundant(pointList)) { // checks that plane "0wnz" :), 3 or more points
-            delete *chkPlane;
-            chkPlane = faceList.erase(chkPlane);
-            cnt++;
-        } else {
-            chkPlane++;
-        }
-    }
-
-    return cnt;
-}
-
-bool DBrush::GetBounds(vec3_t min, vec3_t max)
-{
-    BuildBounds();
-
-    if (!bBoundsBuilt) {
-        return false;
-    }
-
-    VectorCopy(bbox_min, min);
-    VectorCopy(bbox_max, max);
-
-    return true;
-}
-
-bool DBrush::BBoxCollision(DBrush *chkBrush)
-{
-    vec3_t min1, min2;
-    vec3_t max1, max2;
-
-    GetBounds(min1, max1);
-    chkBrush->GetBounds(min2, max2);
-
-    if (min1[0] >= max2[0]) {
-        return false;
-    }
-    if (min1[1] >= max2[1]) {
-        return false;
-    }
-    if (min1[2] >= max2[2]) {
-        return false;
-    }
-
-    if (max1[0] <= min2[0]) {
-        return false;
-    }
-    if (max1[1] <= min2[1]) {
-        return false;
-    }
-    if (max1[2] <= min2[2]) {
-        return false;
-    }
-
-    return true;
-}
-
-DPlane *DBrush::HasPlane(DPlane *chkPlane)
-{
-    for (std::list<DPlane *>::const_iterator brushPlane = faceList.begin();
-         brushPlane != faceList.end(); brushPlane++) {
-        if (**brushPlane == *chkPlane) {
-            return *brushPlane;
-        }
-    }
-    return NULL;
-}
-
-bool DBrush::IsCutByPlane(DPlane *cuttingPlane)
-{
-    bool isInFront;
-
-    if (pointList.size() == 0) {
-        if (BuildPoints() == 0) {
-            return false;
-        }
-    }
-
-    std::list<DPoint *>::const_iterator chkPnt = pointList.begin();
-
-    if (chkPnt == pointList.end()) {
-        return false;
-    }
-
-    float dist = cuttingPlane->DistanceToPoint((*chkPnt)->_pnt);
-
-    if (dist > MAX_ROUND_ERROR) {
-        isInFront = false;
-    } else if (dist < MAX_ROUND_ERROR) {
-        isInFront = true;
-    } else {
-        return true;
-    }
-
-    for (chkPnt++ = pointList.begin(); chkPnt != pointList.end(); chkPnt++) {
-        dist = cuttingPlane->DistanceToPoint((*chkPnt)->_pnt);
-
-        if (dist > MAX_ROUND_ERROR) {
-            if (isInFront) {
-                return true;
-            }
-        } else if (dist < MAX_ROUND_ERROR) {
-            if (!isInFront) {
-                return true;
-            }
-        } else {
-            return true;
-        }
-    }
-
-    return false;
-}
-
-
-scene::Node *DBrush::BuildInRadiant(bool allowDestruction, int *changeCnt, scene::Node *entity)
-{
-    if (allowDestruction) {
-        bool kill = true;
-
-        for (std::list<DPlane *>::const_iterator chkPlane = faceList.begin(); chkPlane != faceList.end(); chkPlane++) {
-            if ((*chkPlane)->m_bChkOk) {
-                kill = false;
-                break;
-            }
-        }
-        if (kill) {
-            return NULL;
-        }
-    }
-
-    //+djbob: fixed bug when brush had no faces "phantom brush" in radiant.
-    if (faceList.size() < 4) {
-        globalErrorStream() << "Possible Phantom Brush Found, will not rebuild\n";
-        return NULL;
-    }
-    //-djbob
-
-    NodeSmartReference node(GlobalBrushCreator().createBrush());
-
-    for (std::list<DPlane *>::const_iterator buildPlane = faceList.begin();
-         buildPlane != faceList.end(); buildPlane++) {
-        if ((*buildPlane)->AddToBrush(node) && changeCnt) {
-            (*changeCnt)++;
-        }
-    }
-
-    if (entity) {
-        Node_getTraversable(*entity)->insert(node);
-    } else {
-        Node_getTraversable(GlobalRadiant().getMapWorldEntity())->insert(node);
-    }
-
-    QER_entity = entity;
-    QER_brush = node.get_pointer();
-
-    return node.get_pointer();
-}
-
-void DBrush::CutByPlane(DPlane *cutPlane, DBrush **newBrush1, DBrush **newBrush2)
-{
-    if (!IsCutByPlane(cutPlane)) {
-        *newBrush1 = NULL;
-        *newBrush2 = NULL;
-        return;
-    }
-
-    DBrush *b1 = new DBrush;
-    DBrush *b2 = new DBrush;
-
-    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(cutPlane->points[0], cutPlane->points[1], cutPlane->points[2], NULL);
-    b2->AddFace(cutPlane->points[2], cutPlane->points[1], cutPlane->points[0], NULL);
-
-    b1->RemoveRedundantPlanes();
-    b2->RemoveRedundantPlanes();
-
-    *newBrush1 = b1;
-    *newBrush2 = b2;
-}
-
-bool DBrush::IntersectsWith(DBrush *chkBrush)
-{
-    if (pointList.size() == 0) {
-        if (BuildPoints() == 0) {
-            return false;   // invalid brush!!!!
-
-        }
-    }
-    if (chkBrush->pointList.size() == 0) {
-        if (chkBrush->BuildPoints() == 0) {
-            return false;   // invalid brush!!!!
-
-        }
-    }
-    if (!BBoxCollision(chkBrush)) {
-        return false;
-    }
-
-    std::list<DPlane *>::const_iterator iplPlane;
-
-    for (iplPlane = faceList.begin(); iplPlane != faceList.end(); iplPlane++) {
-
-        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) {
-                allInFront = false;
-                break;
-            }
-        }
-        if (allInFront) {
-            return false;
-        }
-    }
-
-    for (iplPlane = chkBrush->faceList.begin(); iplPlane != chkBrush->faceList.end(); iplPlane++) {
-        bool allInFront = true;
-        for (std::list<DPoint *>::const_iterator iPoint = pointList.begin(); iPoint != pointList.end(); iPoint++) {
-            if ((*iplPlane)->DistanceToPoint((*iPoint)->_pnt) < -MAX_ROUND_ERROR) {
-                allInFront = false;
-                break;
-            }
-        }
-        if (allInFront) {
-            return false;
-        }
-    }
-
-    return true;
-}
-
-bool DBrush::IntersectsWith(DPlane *p1, DPlane *p2, vec3_t v)
-{
-    vec3_t vDown = {0, 0, -1};
-
-    std::list<DPlane *>::const_iterator iplPlane;
-    for (iplPlane = faceList.begin(); iplPlane != faceList.end(); iplPlane++) {
-        DPlane *p = (*iplPlane);
-
-        vec_t d = DotProduct(p->normal, vDown);
-        if (d >= 0) {
-            continue;
-        }
-        if (p->PlaneIntersection(p1, p2, v)) {
-            if (PointPosition(v) != POINT_OUT_BRUSH) {
-                return true;
-            }
-        }
-    }
-
-    return false;
-}
-
-void DBrush::BuildBounds()
-{
-    if (!bBoundsBuilt) {
-        if (pointList.size() == 0) { // if points may not have been built, build them
-            if (BuildPoints() == 0) {
-                return;
-            }
-        }
-
-        std::list<DPoint *>::const_iterator first = pointList.begin();
-        VectorCopy((*first)->_pnt, bbox_min);
-        VectorCopy((*first)->_pnt, bbox_max);
-
-        std::list<DPoint *>::const_iterator point = pointList.begin();
-        for (point++; point != pointList.end(); point++) {
-            if ((*point)->_pnt[0] > bbox_max[0]) {
-                bbox_max[0] = (*point)->_pnt[0];
-            }
-            if ((*point)->_pnt[1] > bbox_max[1]) {
-                bbox_max[1] = (*point)->_pnt[1];
-            }
-            if ((*point)->_pnt[2] > bbox_max[2]) {
-                bbox_max[2] = (*point)->_pnt[2];
-            }
-
-            if ((*point)->_pnt[0] < bbox_min[0]) {
-                bbox_min[0] = (*point)->_pnt[0];
-            }
-            if ((*point)->_pnt[1] < bbox_min[1]) {
-                bbox_min[1] = (*point)->_pnt[1];
-            }
-            if ((*point)->_pnt[2] < bbox_min[2]) {
-                bbox_min[2] = (*point)->_pnt[2];
-            }
-        }
-
-        bBoundsBuilt = true;
-    }
-}
-
-bool DBrush::BBoxTouch(DBrush *chkBrush)
-{
-    vec3_t min1, min2;
-    vec3_t max1, max2;
-
-    GetBounds(min1, max1);
-    chkBrush->GetBounds(min2, max2);
-
-    if ((min1[0] - max2[0]) > MAX_ROUND_ERROR) {
-        return false;
-    }
-    if ((min1[1] - max2[1]) > MAX_ROUND_ERROR) {
-        return false;
-    }
-    if ((min1[2] - max2[2]) > MAX_ROUND_ERROR) {
-        return false;
-    }
-
-    if ((min2[0] - max1[0]) > MAX_ROUND_ERROR) {
-        return false;
-    }
-    if ((min2[1] - max1[1]) > MAX_ROUND_ERROR) {
-        return false;
-    }
-    if ((min2[2] - max1[2]) > MAX_ROUND_ERROR) {
-        return false;
-    }
-
-    int cnt = 0;
-
-    if ((min2[0] - max1[0]) == 0) {
-        cnt++;
-    }
-
-    if ((min2[1] - max1[1]) == 0) {
-        cnt++;
-    }
-
-    if ((min2[2] - max1[2]) == 0) {
-        cnt++;
-    }
-
-    if ((min1[0] - max2[0]) == 0) {
-        cnt++;
-    }
-
-    if ((min1[1] - max2[1]) == 0) {
-        cnt++;
-    }
-
-    if ((min1[2] - max2[2]) == 0) {
-        cnt++;
-    }
-
-    if (cnt > 1) {
-        return false;
-    }
-
-    return true;
-}
-
-void DBrush::ResetChecks(std::list<Str> *exclusionList)
-{
-    for (std::list<DPlane *>::const_iterator resetPlane = faceList.begin();
-         resetPlane != faceList.end(); resetPlane++) {
-        bool set = false;
-
-        if (exclusionList) {
-            for (std::list<Str>::iterator eTexture = exclusionList->begin();
-                 eTexture != exclusionList->end(); eTexture++) {
-                if (strstr((*resetPlane)->m_shader.c_str(), eTexture->GetBuffer())) {
-                    set = true;
-                    break;
-                }
-            }
-        }
-
-        (*resetPlane)->m_bChkOk = set;
-    }
-}
-
-DPlane *DBrush::HasPlaneInverted(DPlane *chkPlane)
-{
-    for (std::list<DPlane *>::const_iterator brushPlane = faceList.begin();
-         brushPlane != faceList.end(); brushPlane++) {
-        if (**brushPlane != *chkPlane) {
-            if (fabs((*brushPlane)->_d + chkPlane->_d) < 0.1) {
-                return (*brushPlane);
-            }
-        }
-    }
-    return NULL;
-}
-
-bool DBrush::HasTexture(const char *textureName)
-{
-    for (std::list<DPlane *>::const_iterator chkPlane = faceList.begin(); chkPlane != faceList.end(); chkPlane++) {
-        if (strstr((*chkPlane)->m_shader.c_str(), textureName)) {
-            return true;
-        }
-
-    }
-    return false;
-}
-
-bool DBrush::IsDetail()
-{
-    for (std::list<DPlane *>::const_iterator chkPlane = faceList.begin(); chkPlane != faceList.end(); chkPlane++) {
-        if ((*chkPlane)->texInfo.contents & FACE_DETAIL) {
-            return true;
-        }
-
-    }
-    return false;
-}
-
-void DBrush::BuildFromWinding(DWinding *w)
-{
-    if (w->numpoints < 3) {
-        globalErrorStream() << "Winding has invalid number of points";
-        return;
-    }
-
-    DPlane *wPlane = w->WindingPlane();
-
-    DWinding *w2;
-    w2 = w->CopyWinding();
-    int i;
-    for (i = 0; i < w2->numpoints; i++)
-        VectorAdd(w2->p[i], wPlane->normal, w2->p[i]);
-
-    AddFace(w2->p[0], w2->p[1], w2->p[2], NULL);
-    AddFace(w->p[2], w->p[1], w->p[0], NULL);
-
-    for (i = 0; i < w->numpoints - 1; i++) {
-        AddFace(w2->p[i], w->p[i], w->p[i + 1], NULL);
-    }
-    AddFace(w2->p[w->numpoints - 1], w->p[w->numpoints - 1], w->p[0], NULL);
-
-    delete wPlane;
-    delete w2;
-}
-
-void DBrush::SaveToFile(FILE *pFile)
-{
-    fprintf(pFile, "{\n");
-
-    for (std::list<DPlane *>::const_iterator pp = faceList.begin(); pp != faceList.end(); pp++) {
-        char buffer[512];
-
-        sprintf(buffer, "( %.0f %.0f %.0f ) ( %.0f %.0f %.0f ) ( %.0f %.0f %.0f ) %s %.0f %.0f %f %f %.0f 0 0 0\n",
-                (*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)->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);
-
-        fprintf(pFile, "%s", buffer);
-    }
-
-    fprintf(pFile, "}\n");
-}
-
-void DBrush::Rotate(vec3_t vOrigin, vec3_t vRotation)
-{
-    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);
-        }
-
-        (*rotPlane)->Rebuild();
-    }
-}
-
-void DBrush::RotateAboutCentre(vec3_t vRotation)
-{
-    vec3_t min, max, centre;
-    GetBounds(min, max);
-    VectorAdd(min, max, centre);
-    VectorScale(centre, 0.5f, centre);
-
-    Rotate(centre, vRotation);
-}
-
-bool DBrush::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)
-{
-    if (textureName) {
-        bool changed = false;
-        for (std::list<DPlane *>::const_iterator resetPlane = faceList.begin();
-             resetPlane != faceList.end(); resetPlane++) {
-            if (!strcmp((*resetPlane)->m_shader.c_str(), textureName)) {
-                if (bResetTextureName) {
-                    (*resetPlane)->m_shader = newTextureName;
-                }
-
-                if (bResetScale[0]) {
-                    (*resetPlane)->texInfo.m_texdef.scale[0] = fScale[0];
-                }
-                if (bResetScale[1]) {
-                    (*resetPlane)->texInfo.m_texdef.scale[1] = fScale[1];
-                }
-
-                if (bResetShift[0]) {
-                    (*resetPlane)->texInfo.m_texdef.shift[0] = fShift[0];
-                }
-                if (bResetShift[1]) {
-                    (*resetPlane)->texInfo.m_texdef.shift[1] = fShift[1];
-                }
-
-                if (bResetRotation) {
-                    (*resetPlane)->texInfo.m_texdef.rotate = (float) rotation;
-                }
-
-                changed = true;
-            }
-        }
-        return changed; // no point rebuilding unless we need to, only slows things down
-    } else {
-        for (std::list<DPlane *>::const_iterator resetPlane = faceList.begin();
-             resetPlane != faceList.end(); resetPlane++) {
-            if (bResetTextureName) {
-                (*resetPlane)->m_shader = newTextureName;
-            }
-
-            if (bResetScale[0]) {
-                (*resetPlane)->texInfo.m_texdef.scale[0] = fScale[0];
-            }
-            if (bResetScale[1]) {
-                (*resetPlane)->texInfo.m_texdef.scale[1] = fScale[1];
-            }
-
-            if (bResetShift[0]) {
-                (*resetPlane)->texInfo.m_texdef.shift[0] = fShift[0];
-            }
-            if (bResetShift[1]) {
-                (*resetPlane)->texInfo.m_texdef.shift[1] = fShift[1];
-            }
-
-            if (bResetRotation) {
-                (*resetPlane)->texInfo.m_texdef.rotate = (float) rotation;
-            }
-        }
-        return true;
-    }
-}
-
-bool DBrush::operator==(DBrush *other)
-{
-    std::list<DPlane *>::const_iterator chkPlane;
-
-    for (chkPlane = faceList.begin(); chkPlane != faceList.end(); chkPlane++) {
-        if (!other->HasPlane((*chkPlane))) {
-            return false;
-        }
-    }
-
-    for (chkPlane = faceList.begin(); chkPlane != faceList.end(); chkPlane++) {
-        if (!HasPlane((*chkPlane))) {
-            return false;
-        }
-    }
-
-    return true;
-}
-
-DPlane *DBrush::AddFace(const vec3_t va, const vec3_t vb, const vec3_t vc, const char *textureName, bool bDetail)
-{
-    bBoundsBuilt = false;
-    DPlane *newFace = new DPlane(va, vb, vc, textureName, bDetail);
-    faceList.push_back(newFace);
-
-    return newFace;
-}
-
-DPlane *DBrush::FindPlaneWithClosestNormal(vec_t *normal)
-{
-    vec_t bestDot = -2;
-    DPlane *bestDotPlane = NULL;
-    std::list<DPlane *>::const_iterator chkPlane;
-    for (chkPlane = faceList.begin(); chkPlane != faceList.end(); chkPlane++) {
-        DPlane *pPlane = (*chkPlane);
-
-        vec_t dot = DotProduct(pPlane->normal, normal);
-        if (dot > bestDot) {
-            bestDot = dot;
-            bestDotPlane = pPlane;
-        }
-    }
-
-    return bestDotPlane;
-}
-
-int DBrush::FindPointsForPlane(DPlane *plane, DPoint **pnts, int maxpnts)
-{
-    int numpnts = 0;
-
-    if (!maxpnts) {
-        return 0;
-    }
-
-    BuildPoints();
-
-    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) {
-            pnts[numpnts] = point;
-            numpnts++;
-
-            if (numpnts >= maxpnts) {
-                return numpnts;
-            }
-
-        }
-    }
-
-    return numpnts;
-}
-
-void DBrush::RemovePlane(DPlane *plane)
-{
-    bBoundsBuilt = false;
-    for (std::list<DPlane *>::const_iterator deadPlane = faceList.begin(); deadPlane != faceList.end(); deadPlane++) {
-        if (*deadPlane == plane) {
-            delete *deadPlane;
-            faceList.remove(plane);
-        }
-    }
+               BuildPoints();
+       }
+
+       chkPlane = faceList.begin();
+       while ( chkPlane != faceList.end() )
+       {
+               if ( ( *chkPlane )->IsRedundant( pointList ) ) { // checks that plane "0wnz" :), 3 or more points
+                       delete *chkPlane;
+                       chkPlane = faceList.erase( chkPlane );
+                       cnt++;
+               }
+               else{
+                       chkPlane++;
+               }
+       }
+
+       return cnt;
+}
+
+bool DBrush::GetBounds( vec3_t min, vec3_t max ){
+       BuildBounds();
+
+       if ( !bBoundsBuilt ) {
+               return false;
+       }
+
+       VectorCopy( bbox_min, min );
+       VectorCopy( bbox_max, max );
+
+       return true;
+}
+
+bool DBrush::BBoxCollision( DBrush* chkBrush ){
+       vec3_t min1, min2;
+       vec3_t max1, max2;
+
+       GetBounds( min1, max1 );
+       chkBrush->GetBounds( min2, max2 );
+
+       if ( min1[0] >= max2[0] ) {
+               return false;
+       }
+       if ( min1[1] >= max2[1] ) {
+               return false;
+       }
+       if ( min1[2] >= max2[2] ) {
+               return false;
+       }
+
+       if ( max1[0] <= min2[0] ) {
+               return false;
+       }
+       if ( max1[1] <= min2[1] ) {
+               return false;
+       }
+       if ( max1[2] <= min2[2] ) {
+               return false;
+       }
+
+       return true;
+}
+
+DPlane* DBrush::HasPlane( DPlane* chkPlane ){
+       for ( std::list<DPlane *>::const_iterator brushPlane = faceList.begin(); brushPlane != faceList.end(); brushPlane++ )
+       {
+               if ( **brushPlane == *chkPlane ) {
+                       return *brushPlane;
+               }
+       }
+       return NULL;
+}
+
+bool DBrush::IsCutByPlane( DPlane *cuttingPlane ){
+       bool isInFront;
+
+       if ( pointList.size() == 0 ) {
+               if ( BuildPoints() == 0 ) {
+                       return false;
+               }
+       }
+
+       std::list<DPoint *>::const_iterator chkPnt = pointList.begin();
+
+       if ( chkPnt == pointList.end() ) {
+               return false;
+       }
+
+       float dist = cuttingPlane->DistanceToPoint( ( *chkPnt )->_pnt );
+
+       if ( dist > MAX_ROUND_ERROR ) {
+               isInFront = false;
+       }
+       else if ( dist < MAX_ROUND_ERROR ) {
+               isInFront = true;
+       }
+       else{
+               return true;
+       }
+
+       for ( chkPnt++ = pointList.begin(); chkPnt != pointList.end(); chkPnt++ )
+       {
+               dist = cuttingPlane->DistanceToPoint( ( *chkPnt )->_pnt );
+
+               if ( dist > MAX_ROUND_ERROR ) {
+                       if ( isInFront ) {
+                               return true;
+                       }
+               }
+               else if ( dist < MAX_ROUND_ERROR ) {
+                       if ( !isInFront ) {
+                               return true;
+                       }
+               }
+               else{
+                       return true;
+               }
+       }
+
+       return false;
+}
+
+
+scene::Node* DBrush::BuildInRadiant( bool allowDestruction, int* changeCnt, scene::Node* entity ){
+       if ( allowDestruction ) {
+               bool kill = true;
+
+               for ( std::list<DPlane *>::const_iterator chkPlane = faceList.begin(); chkPlane != faceList.end(); chkPlane++ )
+               {
+                       if ( ( *chkPlane )->m_bChkOk ) {
+                               kill = false;
+                               break;
+                       }
+               }
+               if ( kill ) {
+                       return NULL;
+               }
+       }
+
+       //+djbob: fixed bug when brush had no faces "phantom brush" in radiant.
+       if ( faceList.size() < 4 ) {
+               globalErrorStream() << "Possible Phantom Brush Found, will not rebuild\n";
+               return NULL;
+       }
+       //-djbob
+
+       NodeSmartReference node( GlobalBrushCreator().createBrush() );
+
+       for ( std::list<DPlane *>::const_iterator buildPlane = faceList.begin(); buildPlane != faceList.end(); buildPlane++ ) {
+               if ( ( *buildPlane )->AddToBrush( node ) && changeCnt ) {
+                       ( *changeCnt )++;
+               }
+       }
+
+       if ( entity ) {
+               Node_getTraversable( *entity )->insert( node );
+       }
+       else {
+               Node_getTraversable( GlobalRadiant().getMapWorldEntity() )->insert( node );
+       }
+
+       QER_entity = entity;
+       QER_brush = node.get_pointer();
+
+       return node.get_pointer();
+}
+
+void DBrush::CutByPlane( DPlane *cutPlane, DBrush **newBrush1, DBrush **newBrush2 ){
+       if ( !IsCutByPlane( cutPlane ) ) {
+               *newBrush1 = NULL;
+               *newBrush2 = NULL;
+               return;
+       }
+
+       DBrush* b1 = new DBrush;
+       DBrush* b2 = new DBrush;
+
+       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( cutPlane->points[0], cutPlane->points[1], cutPlane->points[2], NULL );
+       b2->AddFace( cutPlane->points[2], cutPlane->points[1], cutPlane->points[0], NULL );
+
+       b1->RemoveRedundantPlanes();
+       b2->RemoveRedundantPlanes();
+
+       *newBrush1 = b1;
+       *newBrush2 = b2;
+}
+
+bool DBrush::IntersectsWith( DBrush *chkBrush ){
+       if ( pointList.size() == 0 ) {
+               if ( BuildPoints() == 0 ) {
+                       return false;   // invalid brush!!!!
+
+               }
+       }
+       if ( chkBrush->pointList.size() == 0 ) {
+               if ( chkBrush->BuildPoints() == 0 ) {
+                       return false;   // invalid brush!!!!
+
+               }
+       }
+       if ( !BBoxCollision( chkBrush ) ) {
+               return false;
+       }
+
+       std::list<DPlane *>::const_iterator iplPlane;
+
+       for ( iplPlane = faceList.begin(); iplPlane != faceList.end(); iplPlane++ )
+       {
+
+               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 ) {
+                               allInFront = false;
+                               break;
+                       }
+               }
+               if ( allInFront ) {
+                       return false;
+               }
+       }
+
+       for ( iplPlane = chkBrush->faceList.begin(); iplPlane != chkBrush->faceList.end(); iplPlane++ )
+       {
+               bool allInFront = true;
+               for ( std::list<DPoint *>::const_iterator iPoint = pointList.begin(); iPoint != pointList.end(); iPoint++ )
+               {
+                       if ( ( *iplPlane )->DistanceToPoint( ( *iPoint )->_pnt ) < -MAX_ROUND_ERROR ) {
+                               allInFront = false;
+                               break;
+                       }
+               }
+               if ( allInFront ) {
+                       return false;
+               }
+       }
+
+       return true;
+}
+
+bool DBrush::IntersectsWith( DPlane* p1, DPlane* p2, vec3_t v ) {
+       vec3_t vDown = { 0, 0, -1 };
+
+       std::list<DPlane *>::const_iterator iplPlane;
+       for ( iplPlane = faceList.begin(); iplPlane != faceList.end(); iplPlane++ ) {
+               DPlane* p = ( *iplPlane );
+
+               vec_t d = DotProduct( p->normal, vDown );
+               if ( d >= 0 ) {
+                       continue;
+               }
+               if ( p->PlaneIntersection( p1, p2, v ) ) {
+                       if ( PointPosition( v ) != POINT_OUT_BRUSH ) {
+                               return true;
+                       }
+               }
+       }
+
+       return false;
+}
+
+void DBrush::BuildBounds(){
+       if ( !bBoundsBuilt ) {
+               if ( pointList.size() == 0 ) { // if points may not have been built, build them
+                       if ( BuildPoints() == 0 ) {
+                               return;
+                       }
+               }
+
+               std::list<DPoint *>::const_iterator first = pointList.begin();
+               VectorCopy( ( *first )->_pnt, bbox_min );
+               VectorCopy( ( *first )->_pnt, bbox_max );
+
+               std::list<DPoint *>::const_iterator point = pointList.begin();
+               for ( point++; point != pointList.end(); point++ )
+               {
+                       if ( ( *point )->_pnt[0] > bbox_max[0] ) {
+                               bbox_max[0] = ( *point )->_pnt[0];
+                       }
+                       if ( ( *point )->_pnt[1] > bbox_max[1] ) {
+                               bbox_max[1] = ( *point )->_pnt[1];
+                       }
+                       if ( ( *point )->_pnt[2] > bbox_max[2] ) {
+                               bbox_max[2] = ( *point )->_pnt[2];
+                       }
+
+                       if ( ( *point )->_pnt[0] < bbox_min[0] ) {
+                               bbox_min[0] = ( *point )->_pnt[0];
+                       }
+                       if ( ( *point )->_pnt[1] < bbox_min[1] ) {
+                               bbox_min[1] = ( *point )->_pnt[1];
+                       }
+                       if ( ( *point )->_pnt[2] < bbox_min[2] ) {
+                               bbox_min[2] = ( *point )->_pnt[2];
+                       }
+               }
+
+               bBoundsBuilt = true;
+       }
+}
+
+bool DBrush::BBoxTouch( DBrush *chkBrush ){
+       vec3_t min1, min2;
+       vec3_t max1, max2;
+
+       GetBounds( min1, max1 );
+       chkBrush->GetBounds( min2, max2 );
+
+       if ( ( min1[0] - max2[0] ) > MAX_ROUND_ERROR ) {
+               return false;
+       }
+       if ( ( min1[1] - max2[1] ) > MAX_ROUND_ERROR ) {
+               return false;
+       }
+       if ( ( min1[2] - max2[2] ) > MAX_ROUND_ERROR ) {
+               return false;
+       }
+
+       if ( ( min2[0] - max1[0] ) > MAX_ROUND_ERROR ) {
+               return false;
+       }
+       if ( ( min2[1] - max1[1] ) > MAX_ROUND_ERROR ) {
+               return false;
+       }
+       if ( ( min2[2] - max1[2] ) > MAX_ROUND_ERROR ) {
+               return false;
+       }
+
+       int cnt = 0;
+
+       if ( ( min2[0] - max1[0] ) == 0 ) {
+               cnt++;
+       }
+
+       if ( ( min2[1] - max1[1] ) == 0 ) {
+               cnt++;
+       }
+
+       if ( ( min2[2] - max1[2] ) == 0 ) {
+               cnt++;
+       }
+
+       if ( ( min1[0] - max2[0] ) == 0 ) {
+               cnt++;
+       }
+
+       if ( ( min1[1] - max2[1] ) == 0 ) {
+               cnt++;
+       }
+
+       if ( ( min1[2] - max2[2] ) == 0 ) {
+               cnt++;
+       }
+
+       if ( cnt > 1 ) {
+               return false;
+       }
+
+       return true;
+}
+
+void DBrush::ResetChecks( std::list<Str>* exclusionList ){
+       for ( std::list<DPlane *>::const_iterator resetPlane = faceList.begin(); resetPlane != faceList.end(); resetPlane++ )
+       {
+               bool set = false;
+
+               if ( exclusionList ) {
+                       for ( std::list<Str>::iterator eTexture = exclusionList->begin(); eTexture != exclusionList->end(); eTexture++ )
+                       {
+                               if ( strstr( ( *resetPlane )->m_shader.c_str(), eTexture->GetBuffer() ) ) {
+                                       set = true;
+                                       break;
+                               }
+                       }
+               }
+
+               ( *resetPlane )->m_bChkOk = set;
+       }
+}
+
+DPlane* DBrush::HasPlaneInverted( DPlane *chkPlane ){
+       for ( std::list<DPlane *>::const_iterator brushPlane = faceList.begin(); brushPlane != faceList.end(); brushPlane++ )
+       {
+               if ( **brushPlane != *chkPlane ) {
+                       if ( fabs( ( *brushPlane )->_d + chkPlane->_d ) < 0.1 ) {
+                               return ( *brushPlane );
+                       }
+               }
+       }
+       return NULL;
+}
+
+bool DBrush::HasTexture( const char *textureName ){
+       for ( std::list<DPlane *>::const_iterator chkPlane = faceList.begin(); chkPlane != faceList.end(); chkPlane++ )
+       {
+               if ( strstr( ( *chkPlane )->m_shader.c_str(), textureName ) ) {
+                       return true;
+               }
+
+       }
+       return false;
+}
+
+bool DBrush::IsDetail(){
+       for ( std::list<DPlane *>::const_iterator chkPlane = faceList.begin(); chkPlane != faceList.end(); chkPlane++ )
+       {
+               if ( ( *chkPlane )->texInfo.contents & FACE_DETAIL ) {
+                       return true;
+               }
+
+       }
+       return false;
+}
+
+void DBrush::BuildFromWinding( DWinding *w ){
+       if ( w->numpoints < 3 ) {
+               globalErrorStream() << "Winding has invalid number of points";
+               return;
+       }
+
+       DPlane* wPlane = w->WindingPlane();
+
+       DWinding* w2;
+       w2 = w->CopyWinding();
+       int i;
+       for ( i = 0; i < w2->numpoints; i++ )
+               VectorAdd( w2->p[i], wPlane->normal, w2->p[i] );
+
+       AddFace( w2->p[0], w2->p[1], w2->p[2], NULL );
+       AddFace( w->p[2], w->p[1], w->p[0], NULL );
+
+       for ( i = 0; i < w->numpoints - 1; i++ )
+               AddFace( w2->p[i], w->p[i], w->p[i + 1], NULL );
+       AddFace( w2->p[w->numpoints - 1], w->p[w->numpoints - 1], w->p[0], NULL );
+
+       delete wPlane;
+       delete w2;
+}
+
+void DBrush::SaveToFile( FILE *pFile ){
+       fprintf( pFile, "{\n" );
+
+       for ( std::list<DPlane *>::const_iterator pp = faceList.begin(); pp != faceList.end(); pp++ )
+       {
+               char buffer[512];
+
+               sprintf( buffer, "( %.0f %.0f %.0f ) ( %.0f %.0f %.0f ) ( %.0f %.0f %.0f ) %s %.0f %.0f %f %f %.0f 0 0 0\n",
+                                ( *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 )->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 );
+
+               fprintf( pFile, "%s", buffer );
+       }
+
+       fprintf( pFile, "}\n" );
+}
+
+void DBrush::Rotate( vec3_t vOrigin, vec3_t vRotation ){
+       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 );
+
+               ( *rotPlane )->Rebuild();
+       }
+}
+
+void DBrush::RotateAboutCentre( vec3_t vRotation ){
+       vec3_t min, max, centre;
+       GetBounds( min, max );
+       VectorAdd( min, max, centre );
+       VectorScale( centre, 0.5f, centre );
+
+       Rotate( centre, vRotation );
+}
+
+bool DBrush::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 ){
+       if ( textureName ) {
+               bool changed = false;
+               for ( std::list<DPlane *>::const_iterator resetPlane = faceList.begin(); resetPlane != faceList.end(); resetPlane++ )
+               {
+                       if ( !strcmp( ( *resetPlane )->m_shader.c_str(), textureName ) ) {
+                               if ( bResetTextureName ) {
+                                       ( *resetPlane )->m_shader = newTextureName;
+                               }
+
+                               if ( bResetScale[0] ) {
+                                       ( *resetPlane )->texInfo.m_texdef.scale[0] = fScale[0];
+                               }
+                               if ( bResetScale[1] ) {
+                                       ( *resetPlane )->texInfo.m_texdef.scale[1] = fScale[1];
+                               }
+
+                               if ( bResetShift[0] ) {
+                                       ( *resetPlane )->texInfo.m_texdef.shift[0] = fShift[0];
+                               }
+                               if ( bResetShift[1] ) {
+                                       ( *resetPlane )->texInfo.m_texdef.shift[1] = fShift[1];
+                               }
+
+                               if ( bResetRotation ) {
+                                       ( *resetPlane )->texInfo.m_texdef.rotate = (float)rotation;
+                               }
+
+                               changed = true;
+                       }
+               }
+               return changed; // no point rebuilding unless we need to, only slows things down
+       }
+       else
+       {
+               for ( std::list<DPlane *>::const_iterator resetPlane = faceList.begin(); resetPlane != faceList.end(); resetPlane++ )
+               {
+                       if ( bResetTextureName ) {
+                               ( *resetPlane )->m_shader = newTextureName;
+                       }
+
+                       if ( bResetScale[0] ) {
+                               ( *resetPlane )->texInfo.m_texdef.scale[0] = fScale[0];
+                       }
+                       if ( bResetScale[1] ) {
+                               ( *resetPlane )->texInfo.m_texdef.scale[1] = fScale[1];
+                       }
+
+                       if ( bResetShift[0] ) {
+                               ( *resetPlane )->texInfo.m_texdef.shift[0] = fShift[0];
+                       }
+                       if ( bResetShift[1] ) {
+                               ( *resetPlane )->texInfo.m_texdef.shift[1] = fShift[1];
+                       }
+
+                       if ( bResetRotation ) {
+                               ( *resetPlane )->texInfo.m_texdef.rotate = (float)rotation;
+                       }
+               }
+               return true;
+       }
+}
+
+bool DBrush::operator ==( DBrush* other ){
+       std::list<DPlane *>::const_iterator chkPlane;
+
+       for ( chkPlane = faceList.begin(); chkPlane != faceList.end(); chkPlane++ )
+       {
+               if ( !other->HasPlane( ( *chkPlane ) ) ) {
+                       return false;
+               }
+       }
+
+       for ( chkPlane = faceList.begin(); chkPlane != faceList.end(); chkPlane++ )
+       {
+               if ( !HasPlane( ( *chkPlane ) ) ) {
+                       return false;
+               }
+       }
+
+       return true;
+}
+
+DPlane* DBrush::AddFace( const vec3_t va, const vec3_t vb, const vec3_t vc, const char *textureName, bool bDetail ){
+       bBoundsBuilt = false;
+       DPlane* newFace = new DPlane( va, vb, vc, textureName, bDetail );
+       faceList.push_back( newFace );
+
+       return newFace;
+}
+
+DPlane* DBrush::FindPlaneWithClosestNormal( vec_t* normal ) {
+       vec_t bestDot = -2;
+       DPlane* bestDotPlane = NULL;
+       std::list<DPlane *>::const_iterator chkPlane;
+       for ( chkPlane = faceList.begin(); chkPlane != faceList.end(); chkPlane++ ) {
+               DPlane* pPlane = ( *chkPlane );
+
+               vec_t dot = DotProduct( pPlane->normal, normal );
+               if ( dot > bestDot ) {
+                       bestDot = dot;
+                       bestDotPlane = pPlane;
+               }
+       }
+
+       return bestDotPlane;
+}
+
+int DBrush::FindPointsForPlane( DPlane* plane, DPoint** pnts, int maxpnts ) {
+       int numpnts = 0;
+
+       if ( !maxpnts ) {
+               return 0;
+       }
+
+       BuildPoints();
+
+       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 ) {
+                       pnts[numpnts] = point;
+                       numpnts++;
+
+                       if ( numpnts >= maxpnts ) {
+                               return numpnts;
+                       }
+
+               }
+       }
+
+       return numpnts;
+}
+
+void DBrush::RemovePlane( DPlane* plane ) {
+       bBoundsBuilt = false;
+       for ( std::list<DPlane *>::const_iterator deadPlane = faceList.begin(); deadPlane != faceList.end(); deadPlane++ ) {
+               if ( *deadPlane == plane ) {
+                       delete *deadPlane;
+                       faceList.remove( plane );
+               }
+       }
 }
index d88bee2..7b3e8d6 100644 (file)
 #include "str.h"
 
 class DPlane;
-
 class DWinding;
-
 class DPoint;
-
 class _QERFaceData;
 
-namespace scene {
-    class Node;
-
-    class Instance;
+namespace scene
+{
+class Node;
+class Instance;
 }
 
-const int POINT_IN_BRUSH = 0;
-const int POINT_ON_BRUSH = 1;
+const int POINT_IN_BRUSH  = 0;
+const int POINT_ON_BRUSH  = 1;
 const int POINT_OUT_BRUSH = 2;
 
-class DBrush {
+class DBrush
+{
 public:
-    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 RotateAboutCentre(vec3_t vRotation);
-
-    DPlane *HasPlaneInverted(DPlane *chkPlane);
-
-    DPlane *HasPlane(DPlane *chkPlane);
-
-    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 HasTexture(const char *textureName);
-
-    bool IntersectsWith(DBrush *chkBrush);
-
-    bool IntersectsWith(DPlane *p1, DPlane *p2, vec3_t v);
-
-    bool IsCutByPlane(DPlane *cuttingPlane);
-
-    bool GetBounds(vec3_t min, vec3_t max);
-
-    bool HasPoint(vec3_t pnt);
-
-    bool BBoxCollision(DBrush *chkBrush);
-
-    bool BBoxTouch(DBrush *chkBrush);
-
-    int BuildPoints();
-
-    void BuildBounds();
-
-    void BuildFromWinding(DWinding *w);
-
-    scene::Node *BuildInRadiant(bool allowDestruction, int *changeCnt, scene::Node *entity = NULL);
-
-    void ResetChecks(std::list<Str> *exclusionList);
-
-    void ClearFaces();
+DPlane* AddFace( const vec3_t va, const vec3_t vb, const vec3_t vc, const char* textureName, bool bDetail );
+void SaveToFile( FILE* pFile );
 
-    void ClearPoints();
+void Rotate( vec3_t vOrigin, vec3_t vRotation );
+void RotateAboutCentre( vec3_t vRotation );
 
-    int RemoveRedundantPlanes(void);
+DPlane* HasPlaneInverted( DPlane* chkPlane );
+DPlane* HasPlane( DPlane* chkPlane );
+DPlane* AddFace( const vec3_t va, const vec3_t vb, const vec3_t vc, const _QERFaceData* texData );
 
-    void RemovePlane(DPlane *plane);
+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 HasTexture( const char* textureName );
+bool IntersectsWith( DBrush *chkBrush );
+bool IntersectsWith( DPlane* p1, DPlane* p2, vec3_t v );
+bool IsCutByPlane( DPlane* cuttingPlane );
+bool GetBounds( vec3_t min, vec3_t max );
+bool HasPoint( vec3_t pnt );
+bool BBoxCollision( DBrush* chkBrush );
+bool BBoxTouch( DBrush* chkBrush );
 
-    int PointPosition(vec3_t pnt);
+int BuildPoints();
+void BuildBounds();
+void BuildFromWinding( DWinding* w );
+scene::Node* BuildInRadiant( bool allowDestruction, int* changeCnt, scene::Node* entity = NULL );
 
+void ResetChecks( std::list<Str>* exclusionList );
 
-    void CutByPlane(DPlane *cutPlane, DBrush **newBrush1, DBrush **newBrush2);
+void ClearFaces();
+void ClearPoints();
 
-    void LoadFromBrush(scene::Instance &brush, bool textured);
+int RemoveRedundantPlanes( void );
+void RemovePlane( DPlane* plane );
+int PointPosition( vec3_t pnt );
 
-    void AddPoint(vec3_t pnt);
 
-    DPlane *FindPlaneWithClosestNormal(vec_t *normal);
+void CutByPlane( DPlane* cutPlane, DBrush** newBrush1, DBrush** newBrush2 );
 
-    int FindPointsForPlane(DPlane *plane, DPoint **pnts, int maxpnts);
+void LoadFromBrush( scene::Instance& brush, bool textured );
+void AddPoint( vec3_t pnt );
 
-    DBrush(int ID = -1);
+DPlane* FindPlaneWithClosestNormal( vec_t* normal );
+int FindPointsForPlane( DPlane* plane, DPoint** pnts, int maxpnts );
 
-    virtual ~DBrush();
+DBrush( int ID = -1 );
+virtual ~DBrush();
 
-    bool operator==(DBrush *other);
+bool operator==( DBrush* other );
 
 //     members
-    scene::Node *QER_entity;
-    scene::Node *QER_brush;
-    std::list<DPlane *> faceList;
-    std::list<DPoint *> pointList;
-    int m_nBrushID;
-    vec3_t bbox_min, bbox_max;
-    bool bBoundsBuilt;
+scene::Node* QER_entity;
+scene::Node* QER_brush;
+std::list<DPlane*> faceList;
+std::list<DPoint*> pointList;
+int m_nBrushID;
+vec3_t bbox_min, bbox_max;
+bool bBoundsBuilt;
 };
 
 //typedef CList<DBrush*, DBrush*> DBrushList;
index f32ebee..c75a875 100644 (file)
 // Construction/Destruction
 //////////////////////////////////////////////////////////////////////
 
-DEPair::DEPair()
-{
+DEPair::DEPair(){
 
 }
 
-DEPair::~DEPair()
-{
+DEPair::~DEPair(){
 
 }
 
@@ -41,8 +39,7 @@ DEPair::~DEPair()
 // Implementation
 //////////////////////////////////////////////////////////////////////
 
-void DEPair::Build(const char *pKey, const char *pValue)
-{
-    key = pKey;
-    value = pValue;
+void DEPair::Build( const char *pKey, const char *pValue ){
+       key = pKey;
+       value = pValue;
 }
index f3f0ceb..3b5ca3a 100644 (file)
 
 #include "str.h"
 
-class DEPair {
+class DEPair
+{
 public:
-    DEPair();
+DEPair();
+virtual ~DEPair();
 
-    virtual ~DEPair();
+void Build( const char* pKey, const char* pValue );
 
-    void Build(const char *pKey, const char *pValue);
-
-    Str key;
-    Str value;
+Str key;
+Str value;
 };
 
 //typedef CList<DEPair*, DEPair*> DEPairList;
index 1eb3fec..415442a 100644 (file)
 #include "mathlib.h"
 
 class DEPair;
-
 class DBrush;
-
 class DPlane;
-
 class DPatch;
-
 class Entity;
 
-namespace scene {
-    class Node;
+namespace scene
+{
+class Node;
 }
 class _QERFaceData;
 
-class DEntity {
+class DEntity
+{
 public:
-    void RemoveFromRadiant();
-
-    scene::Node *QER_Entity;
-    int m_nID;
+void RemoveFromRadiant();
+scene::Node* QER_Entity;
+int m_nID;
 
 //     Constrcution/Destruction
-    DEntity(const char *classname = "worldspawn", int ID = -1);   // sets classname
-    virtual ~DEntity();
+DEntity( const char* classname = "worldspawn", int ID = -1 );   // sets classname
+virtual ~DEntity();
 //     ---------------------------------------------
 
 //     epair functions........
-    void LoadEPairList(Entity *epl);
-
-    void AddEPair(const char *key, const char *value);
-
-    void ClearEPairs();
-
-    DEPair *FindEPairByKey(const char *keyname);
+void LoadEPairList( Entity* epl );
+void AddEPair( const char* key, const char* value );
+void ClearEPairs();
+DEPair* FindEPairByKey( const char* keyname );
 //     ---------------------------------------------
 
 //     random functions........
-    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 rebuild);
-
-    void SaveToFile(FILE *pFile);
-
-    void SetClassname(const char *classname);
-
-    int GetIDMax();
-
-    void BuildInRadiant(bool allowDestruction);
-
-    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);
-
-    DBrush *FindBrushByPointer(scene::Node &brush);
+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 rebuild );
+void SaveToFile( FILE* pFile );
+void SetClassname( const char* classname );
+int GetIDMax();
+
+void BuildInRadiant( bool allowDestruction );
+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 );
+DBrush* FindBrushByPointer( scene::Node& brush );
 //     ---------------------------------------------
 
 
 //     bool list functions
-    void SelectBrushes(bool *selectList);
-
-    bool *BuildDuplicateList();
-
-    bool *BuildIntersectList();
+void SelectBrushes( bool* selectList );
+bool* BuildDuplicateList();
+bool* BuildIntersectList();
 //     ---------------------------------------------
 
 
 //     brush operations
-    void ClearBrushes();        // clears brush list and frees memory for brushes
-
-    DBrush *GetBrushForID(int ID);
+void ClearBrushes();        // clears brush list and frees memory for brushes
 
-    DBrush *NewBrush(int ID = -1);
+DBrush* GetBrushForID( int ID );
+DBrush* NewBrush( int ID = -1 );
 //     ---------------------------------------------
 
 //     patch operations
-    void ClearPatches();
+void ClearPatches();
 
-    DPatch *NewPatch();
+DPatch* NewPatch();
 //     ---------------------------------------------
 
 //     vars
-    std::list<DEPair *> epairList;
-    std::list<DBrush *> brushList;
+std::list<DEPair*> epairList;
+std::list<DBrush*> brushList;
 // new patches, wahey!!!
-    std::list<DPatch *> patchList;
-    Str m_Classname;
+std::list<DPatch*> patchList;
+Str m_Classname;
 //     ---------------------------------------------
 
 
-    int FixBrushes();
+int FixBrushes();
 
-    bool LoadFromEntity(scene::Node &ent, bool bLoadPatches = false);
-
-    void LoadSelectedBrushes();
-
-    void LoadSelectedPatches();
-
-    bool LoadFromPrt(char *filename);
+bool LoadFromEntity( scene::Node& ent, bool bLoadPatches = false );
+void LoadSelectedBrushes();
+void LoadSelectedPatches();
 
+bool LoadFromPrt( char* filename );
 //     ---------------------------------------------
-    void SpawnString(const char *key, const char *defaultstring, const char **out);
-
-    void SpawnInt(const char *key, const char *defaultstring, int *out);
-
-    void SpawnFloat(const char *key, const char *defaultstring, float *out);
-
-    void SpawnVector(const char *key, const char *defaultstring, vec_t *out);
+void SpawnString( const char* key, const char* defaultstring, const char** out );
+void SpawnInt( const char* key, const char* defaultstring, int* out );
+void SpawnFloat( const char* key, const char* defaultstring, float* out );
+void SpawnVector( const char* key, const char* defaultstring, vec_t* out );
 };
 
 #endif // !defined(AFX_DENTITY_H__35B2C523_F0A7_11D4_ACF7_004095A18133__INCLUDED_)
index 13898c8..18edc3b 100644 (file)
 // Construction/Destruction
 //////////////////////////////////////////////////////////////////////
 
-DMap::DMap()
-{
-    m_nNextEntity = 1;
-    AddEntity("worldspawn", 0);
+DMap::DMap(){
+       m_nNextEntity = 1;
+       AddEntity( "worldspawn", 0 );
 }
 
-DMap::~DMap()
-{
-    ClearEntities();
+DMap::~DMap(){
+       ClearEntities();
 }
 
-DEntity *DMap::AddEntity(const char *classname, int ID)
-{
-    DEntity *newEntity;
-    if (ID == -1) {
-        newEntity = new DEntity(classname, m_nNextEntity++);
-    } else {
-        newEntity = new DEntity(classname, ID);
-    }
+DEntity* DMap::AddEntity( const char *classname, int ID ){
+       DEntity* newEntity;
+       if ( ID == -1 ) {
+               newEntity = new DEntity( classname, m_nNextEntity++ );
+       }
+       else{
+               newEntity = new DEntity( classname, ID );
+       }
 
-    entityList.push_back(newEntity);
+       entityList.push_back( newEntity );
 
-    return newEntity;
+       return newEntity;
 }
 
-void DMap::ClearEntities()
-{
-    m_nNextEntity = 1;
+void DMap::ClearEntities(){
+       m_nNextEntity = 1;
 
-    for (std::list<DEntity *>::const_iterator deadEntity = entityList.begin();
-         deadEntity != entityList.end(); deadEntity++) {
-             delete *deadEntity;
-    }
+       for ( std::list<DEntity *>::const_iterator deadEntity = entityList.begin(); deadEntity != entityList.end(); deadEntity++ )
+               delete *deadEntity;
 
-    entityList.clear();
+       entityList.clear();
 }
 
-DEntity *DMap::GetEntityForID(int ID)
-{
-    DEntity *findEntity = NULL;
+DEntity* DMap::GetEntityForID( int ID ){
+       DEntity* findEntity = NULL;
 
-    for (std::list<DEntity *>::const_iterator chkEntity = entityList.begin();
-         chkEntity != entityList.end(); chkEntity++) {
-        if ((*chkEntity)->m_nID == ID) {
-            findEntity = (*chkEntity);
-            break;
-        }
-    }
+       for ( std::list<DEntity *>::const_iterator chkEntity = entityList.begin(); chkEntity != entityList.end(); chkEntity++ )
+       {
+               if ( ( *chkEntity )->m_nID == ID ) {
+                       findEntity = ( *chkEntity );
+                       break;
+               }
+       }
 
-    if (!findEntity) {
-        findEntity = AddEntity("worldspawn", ID);
-    }
+       if ( !findEntity ) {
+               findEntity = AddEntity( "worldspawn", ID );
+       }
 
-    return findEntity;
+       return findEntity;
 }
 
 
-DEntity *DMap::GetWorldSpawn()
-{
-    return GetEntityForID(0);
+DEntity* DMap::GetWorldSpawn(){
+       return GetEntityForID( 0 );
 }
 
-void DMap::BuildInRadiant(bool bAllowDestruction)
-{
-    for (std::list<DEntity *>::const_iterator buildEntity = entityList.begin();
-         buildEntity != entityList.end(); buildEntity++) {
-             (*buildEntity)->BuildInRadiant(bAllowDestruction);
-    }
+void DMap::BuildInRadiant( bool bAllowDestruction ){
+       for ( std::list<DEntity *>::const_iterator buildEntity = entityList.begin(); buildEntity != entityList.end(); buildEntity++ )
+               ( *buildEntity )->BuildInRadiant( bAllowDestruction );
 }
 
-void DMap::LoadAll(bool bLoadPatches)
-{
-    ClearEntities();
-
-    GlobalSelectionSystem().setSelectedAll(false);
-
-    class load_entities_t : public scene::Traversable::Walker {
-        DMap *m_map;
-        bool m_bLoadPatches;
-    public:
-        load_entities_t(DMap *map, bool bLoadPatches)
-                : m_map(map), m_bLoadPatches(bLoadPatches)
-        {
-        }
-
-        bool pre(scene::Node &node) const
-        {
-            if (Node_isEntity(node)) {
-                DEntity *loadEntity = m_map->AddEntity("", 0);
-                loadEntity->LoadFromEntity(node, m_bLoadPatches);
-            }
-            return false;
-        }
-    } load_entities(this, bLoadPatches);
-
-    Node_getTraversable(GlobalSceneGraph().root())->traverse(load_entities);
+void DMap::LoadAll( bool bLoadPatches ){
+       ClearEntities();
+
+       GlobalSelectionSystem().setSelectedAll( false );
+
+       class load_entities_t : public scene::Traversable::Walker
+       {
+       DMap* m_map;
+       bool m_bLoadPatches;
+public:
+       load_entities_t( DMap* map, bool bLoadPatches )
+               : m_map( map ), m_bLoadPatches( bLoadPatches ){
+       }
+       bool pre( scene::Node& node ) const {
+               if ( Node_isEntity( node ) ) {
+                       DEntity* loadEntity = m_map->AddEntity( "", 0 );
+                       loadEntity->LoadFromEntity( node, m_bLoadPatches );
+               }
+               return false;
+       }
+       } load_entities( this, bLoadPatches );
+
+       Node_getTraversable( GlobalSceneGraph().root() )->traverse( load_entities );
 }
 
-int DMap::FixBrushes()
-{
-    int count = 0;
-    for (std::list<DEntity *>::const_iterator fixEntity = entityList.begin();
-         fixEntity != entityList.end(); fixEntity++) {
-        count += (*fixEntity)->FixBrushes();
-    }
+int DMap::FixBrushes(){
+       int count = 0;
+       for ( std::list<DEntity *>::const_iterator fixEntity = entityList.begin(); fixEntity != entityList.end(); fixEntity++ )
+       {
+               count += ( *fixEntity )->FixBrushes();
+       }
 
-    return count;
+       return count;
 }
 
-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 (std::list<DEntity *>::const_iterator texEntity = entityList.begin();
-         texEntity != entityList.end(); texEntity++) {
-        if (string_equal_nocase("worldspawn", (*texEntity)->m_Classname)) {
-            (*texEntity)->ResetTextures(textureName, fScale, fShift, rotation, newTextureName,
-                                        bResetTextureName, bResetScale, bResetShift, bResetRotation, true);
-        } else {
-            if ((*texEntity)->ResetTextures(textureName, fScale, fShift, rotation, newTextureName,
-                                            bResetTextureName, bResetScale, bResetShift, bResetRotation, false)) {
-                RebuildEntity(*texEntity);
-            }
-        }
-    }
+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 ( std::list<DEntity *>::const_iterator texEntity = entityList.begin(); texEntity != entityList.end(); texEntity++ )
+       {
+               if ( string_equal_nocase( "worldspawn", ( *texEntity )->m_Classname ) ) {
+                       ( *texEntity )->ResetTextures( textureName,        fScale,       fShift,       rotation, newTextureName,
+                                                                                  bResetTextureName,  bResetScale,  bResetShift,  bResetRotation, true );
+               }
+               else
+               {
+                       if ( ( *texEntity )->ResetTextures( textureName,        fScale,       fShift,       rotation, newTextureName,
+                                                                                               bResetTextureName,  bResetScale,  bResetShift,  bResetRotation, false ) ) {
+                               RebuildEntity( *texEntity );
+                       }
+               }
+       }
 }
 
-void DMap::RebuildEntity(DEntity *ent)
-{
-    ent->RemoveFromRadiant();
-    ent->BuildInRadiant(false);
+void DMap::RebuildEntity( DEntity *ent ){
+       ent->RemoveFromRadiant();
+       ent->BuildInRadiant( false );
 }
index 9959034..f527d04 100644 (file)
 
 class DEntity;
 
-class DMap {
+class DMap
+{
 public:
-    static void RebuildEntity(DEntity *ent);
+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 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 BuildInRadiant( bool bAllowDestruction );
+int m_nNextEntity;
+DEntity* GetWorldSpawn();
+void ClearEntities();
 
-    void LoadAll(bool bLoadPatches = false);
+DEntity* GetEntityForID( int ID );
+DEntity* AddEntity( const char* classname = "worldspawn", int ID = -1 );
 
-    void BuildInRadiant(bool bAllowDestruction);
+std::list<DEntity*> entityList;
 
-    int m_nNextEntity;
+DMap();
+virtual ~DMap();
 
-    DEntity *GetWorldSpawn();
-
-    void ClearEntities();
-
-    DEntity *GetEntityForID(int ID);
-
-    DEntity *AddEntity(const char *classname = "worldspawn", int ID = -1);
-
-    std::list<DEntity *> entityList;
-
-    DMap();
-
-    virtual ~DMap();
-
-    int FixBrushes();
+int FixBrushes();
 };
 
 #endif // !defined(AFX_DMAP_H__ACAE597A_D26D_49AD_AA69_EDE743DB54FA__INCLUDED_)
index 5c806f8..be49df4 100644 (file)
 //             problem is, you cant put patches into entities as yet :(
 //
 
-DPatch::DPatch()
-{
-    width = MIN_PATCH_WIDTH;
-    height = MIN_PATCH_HEIGHT;
-    QER_entity = NULL;
-    QER_brush = NULL;
+DPatch::DPatch(){
+       width = MIN_PATCH_WIDTH;
+       height = MIN_PATCH_HEIGHT;
+       QER_entity = NULL;
+       QER_brush = NULL;
 }
 
-DPatch::~DPatch()
-{
+DPatch::~DPatch(){
 
 }
 
-void DPatch::SetTexture(const char *textureName)
-{
-    strcpy(texture, textureName);
+void DPatch::SetTexture( const char *textureName ){
+       strcpy( texture, textureName );
 }
 
-void CopyDrawVert(const drawVert_t *in, drawVert_t *out)
-{
-    out->lightmap[0] = in->lightmap[0];
-    out->lightmap[1] = in->lightmap[1];
-    out->st[0] = in->st[0];
-    out->st[1] = in->st[1];
-    VectorCopy(in->normal, out->normal);
-    VectorCopy(in->xyz, out->xyz);
+void CopyDrawVert( const drawVert_t* in, drawVert_t* out ){
+       out->lightmap[0] = in->lightmap[0];
+       out->lightmap[1] = in->lightmap[1];
+       out->st[0] = in->st[0];
+       out->st[1] = in->st[1];
+       VectorCopy( in->normal, out->normal );
+       VectorCopy( in->xyz, out->xyz );
 }
 
-void DPatch::BuildInRadiant(scene::Node *entity)
-{
-    NodeSmartReference patch(GlobalPatchCreator().createPatch());
-
-    scene::Node &parent = entity != 0 ? *entity : GlobalRadiant().getMapWorldEntity();
-    Node_getTraversable(parent)->insert(patch);
-
-    GlobalPatchCreator().Patch_setShader(patch, texture);
-    GlobalPatchCreator().Patch_resize(patch, height, width);
-    PatchControlMatrix matrix = GlobalPatchCreator().Patch_getControlPoints(patch);
-    for (int x = 0; x < width; x++) {
-        for (int y = 0; y < height; y++) {
-            PatchControl &p = matrix(x, y);
-            p.m_vertex[0] = points[x][y].xyz[0];
-            p.m_vertex[1] = points[x][y].xyz[1];
-            p.m_vertex[2] = points[x][y].xyz[2];
-            p.m_texcoord[0] = points[x][y].st[0];
-            p.m_texcoord[1] = points[x][y].st[1];
-        }
-    }
-    GlobalPatchCreator().Patch_controlPointsChanged(patch);
-
-    QER_entity = entity;
-    QER_brush = patch.get_pointer();
+void DPatch::BuildInRadiant( scene::Node* entity ){
+       NodeSmartReference patch( GlobalPatchCreator().createPatch() );
+
+       scene::Node& parent = entity != 0 ? *entity : GlobalRadiant().getMapWorldEntity();
+       Node_getTraversable( parent )->insert( patch );
+
+       GlobalPatchCreator().Patch_setShader( patch, texture );
+       GlobalPatchCreator().Patch_resize( patch, height, width );
+       PatchControlMatrix matrix = GlobalPatchCreator().Patch_getControlPoints( patch );
+       for ( int x = 0; x < width; x++ )
+       {
+               for ( int y = 0; y < height; y++ )
+               {
+                       PatchControl& p = matrix( x, y );
+                       p.m_vertex[0] = points[x][y].xyz[0];
+                       p.m_vertex[1] = points[x][y].xyz[1];
+                       p.m_vertex[2] = points[x][y].xyz[2];
+                       p.m_texcoord[0] = points[x][y].st[0];
+                       p.m_texcoord[1] = points[x][y].st[1];
+               }
+       }
+       GlobalPatchCreator().Patch_controlPointsChanged( patch );
+
+       QER_entity = entity;
+       QER_brush = patch.get_pointer();
 
 
 #if 0
-    int nIndex = g_FuncTable.m_pfnCreatePatchHandle();
-    //$ FIXME: m_pfnGetPatchHandle
-    patchMesh_t* pm = g_FuncTable.m_pfnGetPatchData( nIndex );
+       int nIndex = g_FuncTable.m_pfnCreatePatchHandle();
+       //$ FIXME: m_pfnGetPatchHandle
+       patchMesh_t* pm = g_FuncTable.m_pfnGetPatchData( nIndex );
 
-    b->patchBrush = true;
-    b->pPatch = Patch_Alloc();
-    b->pPatch->setDims( width,height );
+       b->patchBrush = true;
+       b->pPatch = Patch_Alloc();
+       b->pPatch->setDims( width,height );
 
-    for ( int x = 0; x < width; x++ )
-        for ( int y = 0; y < height; y++ )
-            CopyDrawVert( &points[x][y], &pm->ctrl[x][y] );
+       for ( int x = 0; x < width; x++ )
+               for ( int y = 0; y < height; y++ )
+                       CopyDrawVert( &points[x][y], &pm->ctrl[x][y] );
 
 /*     if(entity)
     {
@@ -127,218 +124,216 @@ void DPatch::BuildInRadiant(scene::Node *entity)
     }
     else*/                                                                                                                                                                                                                                                                                                                                                                                                                                                                // patch to entity just plain dont work atm
 
-    if ( entity ) {
-        g_FuncTable.m_pfnCommitPatchHandleToEntity( nIndex, pm, texture, entity );
-    }
-    else{
-        g_FuncTable.m_pfnCommitPatchHandleToMap( nIndex, pm, texture );
-    }
+       if ( entity ) {
+               g_FuncTable.m_pfnCommitPatchHandleToEntity( nIndex, pm, texture, entity );
+       }
+       else{
+               g_FuncTable.m_pfnCommitPatchHandleToMap( nIndex, pm, texture );
+       }
 
-    QER_brush = pm->pSymbiot;
+       QER_brush = pm->pSymbiot;
 #endif
 }
 
-void DPatch::LoadFromPatch(scene::Instance &patch)
-{
-    QER_entity = patch.path().parent().get_pointer();
-    QER_brush = patch.path().top().get_pointer();
-
-    PatchControlMatrix matrix = GlobalPatchCreator().Patch_getControlPoints(patch.path().top());
-
-    width = static_cast<int>( matrix.x());
-    height = static_cast<int>( matrix.y());
-
-    for (int x = 0; x < width; x++) {
-        for (int y = 0; y < height; y++) {
-            PatchControl &p = matrix(x, y);
-            points[x][y].xyz[0] = p.m_vertex[0];
-            points[x][y].xyz[1] = p.m_vertex[1];
-            points[x][y].xyz[2] = p.m_vertex[2];
-            points[x][y].st[0] = p.m_texcoord[0];
-            points[x][y].st[1] = p.m_texcoord[1];
-        }
-    }
-    SetTexture(GlobalPatchCreator().Patch_getShader(patch.path().top()));
+void DPatch::LoadFromPatch( scene::Instance& patch ){
+       QER_entity = patch.path().parent().get_pointer();
+       QER_brush = patch.path().top().get_pointer();
+
+       PatchControlMatrix matrix = GlobalPatchCreator().Patch_getControlPoints( patch.path().top() );
+
+       width = static_cast<int>( matrix.x() );
+       height = static_cast<int>( matrix.y() );
+
+       for ( int x = 0; x < width; x++ )
+       {
+               for ( int y = 0; y < height; y++ )
+               {
+                       PatchControl& p = matrix( x, y );
+                       points[x][y].xyz[0] = p.m_vertex[0];
+                       points[x][y].xyz[1] = p.m_vertex[1];
+                       points[x][y].xyz[2] = p.m_vertex[2];
+                       points[x][y].st[0] = p.m_texcoord[0];
+                       points[x][y].st[1] = p.m_texcoord[1];
+               }
+       }
+       SetTexture( GlobalPatchCreator().Patch_getShader( patch.path().top() ) );
 
 #if 0
-    SetTexture( brush->pPatch->GetShader() );
-
-    width = brush->pPatch->getWidth();
-    height = brush->pPatch->getHeight();
-
-    for ( int x = 0; x < height; x++ )
-    {
-        for ( int y = 0; y < width; y++ )
-        {
-            float *p = brush->pPatch->ctrlAt( ROW,x,y );
-            p[0] = points[x][y].xyz[0];
-            p[1] = points[x][y].xyz[1];
-            p[2] = points[x][y].xyz[2];
-            p[3] = points[x][y].st[0];
-            p[4] = points[x][y].st[1];
-        }
-    }
+       SetTexture( brush->pPatch->GetShader() );
+
+       width = brush->pPatch->getWidth();
+       height = brush->pPatch->getHeight();
+
+       for ( int x = 0; x < height; x++ )
+       {
+               for ( int y = 0; y < width; y++ )
+               {
+                       float *p = brush->pPatch->ctrlAt( ROW,x,y );
+                       p[0] = points[x][y].xyz[0];
+                       p[1] = points[x][y].xyz[1];
+                       p[2] = points[x][y].xyz[2];
+                       p[3] = points[x][y].st[0];
+                       p[4] = points[x][y].st[1];
+               }
+       }
 #endif
 }
 
-bool DPatch::ResetTextures(const char *oldTextureName, const char *newTextureName)
-{
-    if (!oldTextureName || !strcmp(texture, oldTextureName)) {
-        strcpy(texture, newTextureName);
-        return true;
-    }
+bool DPatch::ResetTextures( const char *oldTextureName, const char *newTextureName ){
+       if ( !oldTextureName || !strcmp( texture, oldTextureName ) ) {
+               strcpy( texture, newTextureName );
+               return true;
+       }
 
-    return false;
+       return false;
 }
 
-void Build1dArray(vec3_t *array, drawVert_t points[MAX_PATCH_WIDTH][MAX_PATCH_HEIGHT],
-                  int startX, int startY, int number, bool horizontal, bool inverse)
-{
-    int x = startX, y = startY, i, step;
-
-    if (inverse) {
-        step = -1;
-    } else {
-        step = 1;
-    }
-
-    for (i = 0; i < number; i++) {
-        VectorCopy(points[x][y].xyz, array[i]);
-
-        if (horizontal) {
-            x += step;
-        } else {
-            y += step;
-        }
-    }
+void Build1dArray( vec3_t* array, drawVert_t points[MAX_PATCH_WIDTH][MAX_PATCH_HEIGHT],
+                                  int startX, int startY, int number, bool horizontal, bool inverse ){
+       int x = startX, y = startY, i, step;
+
+       if ( inverse ) {
+               step = -1;
+       }
+       else{
+               step = 1;
+       }
+
+       for ( i = 0; i < number; i++ )
+       {
+               VectorCopy( points[x][y].xyz, array[i] );
+
+               if ( horizontal ) {
+                       x += step;
+               }
+               else{
+                       y += step;
+               }
+       }
 }
 
-void Print1dArray(vec3_t *array, int size)
-{
-    for (int i = 0; i < size; i++) {
-        globalOutputStream() << "(" << array[i][0] << " " << array[i][1] << " " << array[i][2] << ")\t";
-    }
-    globalOutputStream() << "\n";
+void Print1dArray( vec3_t* array, int size ){
+       for ( int i = 0; i < size; i++ )
+               globalOutputStream() << "(" << array[i][0] << " " << array[i][1] << " " << array[i][2] << ")\t";
+       globalOutputStream() << "\n";
 }
 
-bool Compare1dArrays(vec3_t *a1, vec3_t *a2, int size)
-{
-    int i;
-    bool equal = true;
-
-    for (i = 0; i < size; i++) {
-        if (!VectorCompare(a1[i], a2[size - i - 1])) {
-            equal = false;
-            break;
-        }
-    }
-    return equal;
+bool Compare1dArrays( vec3_t* a1, vec3_t* a2, int size ){
+       int i;
+       bool equal = true;
+
+       for ( i = 0; i < size; i++ )
+       {
+               if ( !VectorCompare( a1[i], a2[size - i - 1] ) ) {
+                       equal = false;
+                       break;
+               }
+       }
+       return equal;
 }
 
-patch_merge_t DPatch::IsMergable(DPatch *other)
-{
-    int i, j;
-    vec3_t p1Array[4][MAX_PATCH_HEIGHT];
-    vec3_t p2Array[4][MAX_PATCH_HEIGHT];
-
-    int p1ArraySizes[4];
-    int p2ArraySizes[4];
-
-    patch_merge_t merge_info;
-
-    Build1dArray(p1Array[0], this->points, 0, 0, this->width, true, false);
-    Build1dArray(p1Array[1], this->points, this->width - 1, 0, this->height, false, false);
-    Build1dArray(p1Array[2], this->points, this->width - 1, this->height - 1, this->width, true, true);
-    Build1dArray(p1Array[3], this->points, 0, this->height - 1, this->height, false, true);
-
-    Build1dArray(p2Array[0], other->points, 0, 0, other->width, true, false);
-    Build1dArray(p2Array[1], other->points, other->width - 1, 0, other->height, false, false);
-    Build1dArray(p2Array[2], other->points, other->width - 1, other->height - 1, other->width, true, true);
-    Build1dArray(p2Array[3], other->points, 0, other->height - 1, other->height, false, true);
-
-    p1ArraySizes[0] = this->width;
-    p1ArraySizes[1] = this->height;
-    p1ArraySizes[2] = this->width;
-    p1ArraySizes[3] = this->height;
-
-    p2ArraySizes[0] = other->width;
-    p2ArraySizes[1] = other->height;
-    p2ArraySizes[2] = other->width;
-    p2ArraySizes[3] = other->height;
-
-    for (i = 0; i < 4; i++) {
-        for (j = 0; j < 4; j++) {
-            if (p1ArraySizes[i] == p2ArraySizes[j]) {
-                if (Compare1dArrays(p1Array[i], p2Array[j], p1ArraySizes[i])) {
-                    merge_info.pos1 = i;
-                    merge_info.pos2 = j;
-                    merge_info.mergable = true;
-                    return merge_info;
-                }
-            }
-        }
-    }
-
-    merge_info.mergable = false;
-    return merge_info;
+patch_merge_t DPatch::IsMergable( DPatch *other ){
+       int i, j;
+       vec3_t p1Array[4][MAX_PATCH_HEIGHT];
+       vec3_t p2Array[4][MAX_PATCH_HEIGHT];
+
+       int p1ArraySizes[4];
+       int p2ArraySizes[4];
+
+       patch_merge_t merge_info;
+
+       Build1dArray( p1Array[0], this->points, 0,               0,              this->width,    true,   false );
+       Build1dArray( p1Array[1], this->points, this->width - 1,   0,              this->height,   false,  false );
+       Build1dArray( p1Array[2], this->points, this->width - 1,   this->height - 1, this->width,    true,   true );
+       Build1dArray( p1Array[3], this->points, 0,               this->height - 1, this->height,   false,  true );
+
+       Build1dArray( p2Array[0], other->points, 0,              0,                  other->width,   true,   false );
+       Build1dArray( p2Array[1], other->points, other->width - 1, 0,                  other->height,  false,  false );
+       Build1dArray( p2Array[2], other->points, other->width - 1, other->height - 1,    other->width,   true,   true );
+       Build1dArray( p2Array[3], other->points, 0,              other->height - 1,    other->height,  false,  true );
+
+       p1ArraySizes[0] = this->width;
+       p1ArraySizes[1] = this->height;
+       p1ArraySizes[2] = this->width;
+       p1ArraySizes[3] = this->height;
+
+       p2ArraySizes[0] = other->width;
+       p2ArraySizes[1] = other->height;
+       p2ArraySizes[2] = other->width;
+       p2ArraySizes[3] = other->height;
+
+       for ( i = 0; i < 4; i++ )
+       {
+               for ( j = 0; j < 4; j++ )
+               {
+                       if ( p1ArraySizes[i] == p2ArraySizes[j] ) {
+                               if ( Compare1dArrays( p1Array[i], p2Array[j], p1ArraySizes[i] ) ) {
+                                       merge_info.pos1 = i;
+                                       merge_info.pos2 = j;
+                                       merge_info.mergable = true;
+                                       return merge_info;
+                               }
+                       }
+               }
+       }
+
+       merge_info.mergable = false;
+       return merge_info;
 }
 
-DPatch *DPatch::MergePatches(patch_merge_t merge_info, DPatch *p1, DPatch *p2)
-{
-    while (merge_info.pos1 != 2) {
-        p1->Transpose();
-        merge_info.pos1--;
-        if (merge_info.pos1 < 0) {
-            merge_info.pos1 += 4;
-        }
-    }
-
-    while (merge_info.pos2 != 0) {
-        p2->Transpose();
-        merge_info.pos2--;
-        if (merge_info.pos2 < 0) {
-            merge_info.pos2 += 3;
-        }
-    }
-
-    int newHeight = p1->height + p2->height - 1;
-    if (newHeight > MAX_PATCH_HEIGHT) {
-        return NULL;
-    }
-
-    DPatch *newPatch = new DPatch();
-
-    newPatch->height = newHeight;
-    newPatch->width = p1->width;
-    newPatch->SetTexture(p1->texture);
-
-    for (int y = 0; y < p1->height; y++) {
-        for (int x = 0; x < p1->width; x++) {
-            newPatch->points[x][y] = p1->points[x][y];
-        }
-    }
-
-    for (int y = 1; y < p2->height; y++) {
-        for (int x = 0; x < p2->width; x++) {
-            newPatch->points[x][(y + p1->height - 1)] = p2->points[x][y];
-        }
-    }
+DPatch* DPatch::MergePatches( patch_merge_t merge_info, DPatch *p1, DPatch *p2 ){
+       while ( merge_info.pos1 != 2 )
+       {
+               p1->Transpose();
+               merge_info.pos1--;
+               if ( merge_info.pos1 < 0 ) {
+                       merge_info.pos1 += 4;
+               }
+       }
+
+       while ( merge_info.pos2 != 0 )
+       {
+               p2->Transpose();
+               merge_info.pos2--;
+               if ( merge_info.pos2 < 0 ) {
+                       merge_info.pos2 += 3;
+               }
+       }
+
+       int newHeight = p1->height + p2->height - 1;
+       if ( newHeight > MAX_PATCH_HEIGHT ) {
+               return NULL;
+       }
+
+       DPatch* newPatch = new DPatch();
+
+       newPatch->height    = newHeight;
+       newPatch->width     = p1->width;
+       newPatch->SetTexture( p1->texture );
+
+       for ( int y = 0; y < p1->height; y++ )
+               for ( int x = 0; x < p1->width; x++ )
+                       newPatch->points[x][y] = p1->points[x][y];
+
+       for ( int y = 1; y < p2->height; y++ )
+               for ( int x = 0; x < p2->width; x++ )
+                       newPatch->points[x][( y + p1->height - 1 )] = p2->points[x][y];
 
 //     newPatch->Invert();
-    return newPatch;
+       return newPatch;
 }
 
-void DPatch::Invert()
-{
-    int i, j;
+void DPatch::Invert(){
+       int i, j;
 
-    for (i = 0; i < width; i++) {
-        for (j = 0; j < height / 2; j++) {
-            std::swap(points[i][height - 1 - j], points[i][j]);
-        }
-    }
+       for ( i = 0 ; i < width ; i++ )
+       {
+               for ( j = 0; j < height / 2; j++ )
+               {
+                       std::swap( points[i][height - 1 - j], points[i][j] );
+               }
+       }
 }
-
 /*
    //Was used for debugging, obsolete function
    DPatch* DPatch::TransposePatch(DPatch *p1)
@@ -379,122 +374,140 @@ void DPatch::Invert()
    }
  */
 
-void DPatch::Transpose()
-{
-    int i, j, w;
-
-    if (width > height) {
-        for (i = 0; i < height; i++) {
-            for (j = i + 1; j < width; j++) {
-                if (j < height) {
-                    // swap the value
-                    std::swap(points[j][i], points[i][j]);
-                } else {
-                    // just copy
-                    points[i][j] = points[j][i];
-                }
-            }
-        }
-    } else {
-        for (i = 0; i < width; i++) {
-            for (j = i + 1; j < height; j++) {
-                if (j < width) {
-                    // swap the value
-                    std::swap(points[i][j], points[j][i]);
-                } else {
-                    // just copy
-                    points[j][i] = points[i][j];
-                }
-            }
-        }
-    }
-
-    w = width;
-    width = height;
-    height = w;
-
-    Invert();
+void DPatch::Transpose(){
+       int i, j, w;
+
+       if ( width > height ) {
+               for ( i = 0 ; i < height ; i++ )
+               {
+                       for ( j = i + 1 ; j < width ; j++ )
+                       {
+                               if ( j < height ) {
+                                       // swap the value
+                                       std::swap( points[j][i], points[i][j] );
+                               }
+                               else
+                               {
+                                       // just copy
+                                       points[i][j] = points[j][i];
+                               }
+                       }
+               }
+       }
+       else
+       {
+               for ( i = 0 ; i < width ; i++ )
+               {
+                       for ( j = i + 1 ; j < height ; j++ )
+                       {
+                               if ( j < width ) {
+                                       // swap the value
+                                       std::swap( points[i][j], points[j][i] );
+                               }
+                               else
+                               {
+                                       // just copy
+                                       points[j][i] = points[i][j];
+                               }
+                       }
+               }
+       }
+
+       w = width;
+       width = height;
+       height = w;
+
+       Invert();
 }
 
-std::list<DPatch> DPatch::SplitCols()
-{
-    std::list<DPatch> patchList;
-    int i;
-    int x, y;
-
-    if (height >= 5) {
-        for (i = 0; i < (height - 1) / 2; i++) {
-            DPatch p;
-
-            p.width = width;
-            p.height = MIN_PATCH_HEIGHT;
-            p.SetTexture(texture);
-            for (x = 0; x < p.width; x++) {
-                for (y = 0; y < MIN_PATCH_HEIGHT; y++) {
-                    p.points[x][y] = points[x][(i * 2) + y];
-                }
-            }
-            patchList.push_back(p);
-        }
-    } else {
-        //globalErrorStream() << "bobToolz SplitPatchRows: Patch has not enough rows for splitting.\n";
-        patchList.push_back(*this);
-    }
-    return patchList;
+std::list<DPatch> DPatch::SplitCols(){
+       std::list<DPatch> patchList;
+       int i;
+       int x, y;
+
+       if ( height >= 5 ) {
+               for ( i = 0; i < ( height - 1 ) / 2; i++ )
+               {
+                       DPatch p;
+
+                       p.width = width;
+                       p.height = MIN_PATCH_HEIGHT;
+                       p.SetTexture( texture );
+                       for ( x = 0; x < p.width; x++ )
+                       {
+                               for ( y = 0; y < MIN_PATCH_HEIGHT; y++ )
+                               {
+                                       p.points[x][y] = points[x][( i * 2 ) + y];
+                               }
+                       }
+                       patchList.push_back( p );
+               }
+       }
+       else {
+               //globalErrorStream() << "bobToolz SplitPatchRows: Patch has not enough rows for splitting.\n";
+               patchList.push_back( *this );
+       }
+       return patchList;
 }
 
-std::list<DPatch> DPatch::SplitRows()
-{
-    std::list<DPatch> patchList;
-    int i;
-    int x, y;
-
-    if (width >= 5) {
-        for (i = 0; i < (width - 1) / 2; i++) {
-            DPatch p;
-
-            p.width = MIN_PATCH_WIDTH;
-            p.height = height;
-            p.SetTexture(texture);
-
-            for (x = 0; x < MIN_PATCH_WIDTH; x++) {
-                for (y = 0; y < p.height; y++) {
-                    p.points[x][y] = points[(i * 2) + x][y];
-                }
-            }
-            patchList.push_back(p);
-        }
-    } else {
-        patchList.push_back(*this);
-    }
-    return patchList;
+std::list<DPatch> DPatch::SplitRows(){
+       std::list<DPatch> patchList;
+       int i;
+       int x, y;
+
+       if ( width >= 5 ) {
+               for ( i = 0; i < ( width - 1 ) / 2; i++ )
+               {
+                       DPatch p;
+
+                       p.width = MIN_PATCH_WIDTH;
+                       p.height = height;
+                       p.SetTexture( texture );
+
+                       for ( x = 0; x < MIN_PATCH_WIDTH; x++ )
+                       {
+                               for ( y = 0; y < p.height; y++ )
+                               {
+                                       p.points[x][y] = points[( i * 2 ) + x][y];
+                               }
+                       }
+                       patchList.push_back( p );
+               }
+       }
+       else
+       {
+               patchList.push_back( *this );
+       }
+       return patchList;
 }
 
-std::list<DPatch> DPatch::Split()
-{
-    std::list<DPatch> patchList;
-    int i;
-    int x, y;
-
-    if (width >= 5) {
-        std::list<DPatch> patchColList = SplitCols();
-        for (std::list<DPatch>::iterator patchesCol = patchColList.begin();
-             patchesCol != patchColList.end(); patchesCol++) {
-            std::list<DPatch> patchRowList = (*patchesCol).SplitRows();
-            for (std::list<DPatch>::iterator patchesRow = patchRowList.begin();
-                 patchesRow != patchRowList.end(); patchesRow++) {
-                patchList.push_front(*patchesRow);
-            }
-        }
-    } else if (height >= 5) {
-        std::list<DPatch> patchRowList = SplitRows();
-        for (std::list<DPatch>::iterator patchesRow = patchRowList.begin();
-             patchesRow != patchRowList.end(); patchesRow++) {
-            patchList.push_front(*patchesRow);
-        }
-    } else {
-        //globalErrorStream() << "bobToolz SplitPatchRows: Patch has not enough rows for splitting.\n";
-        patchList.push_back(*this);
-    }
-    return patchList;
+std::list<DPatch> DPatch::Split(){
+       std::list<DPatch> patchList;
+       int i;
+       int x, y;
+
+       if ( width >= 5 ) {
+               std::list<DPatch> patchColList = SplitCols();
+               for ( std::list<DPatch>::iterator patchesCol = patchColList.begin(); patchesCol != patchColList.end(); patchesCol++ )
+               {
+                       std::list<DPatch> patchRowList = ( *patchesCol ).SplitRows();
+                       for ( std::list<DPatch>::iterator patchesRow = patchRowList.begin(); patchesRow != patchRowList.end(); patchesRow++ )
+                       {
+                               patchList.push_front( *patchesRow );
+                       }
+               }
+       }
+       else if ( height >= 5 ) {
+               std::list<DPatch> patchRowList = SplitRows();
+               for ( std::list<DPatch>::iterator patchesRow = patchRowList.begin(); patchesRow != patchRowList.end(); patchesRow++ )
+               {
+                       patchList.push_front( *patchesRow );
+               }
+       }
+       else
+       {
+               //globalErrorStream() << "bobToolz SplitPatchRows: Patch has not enough rows for splitting.\n";
+               patchList.push_back( *this );
+       }
+       return patchList;
 }
index e60b1c0..4d0c26c 100644 (file)
 #include <list>
 #include <stdlib.h>
 
-typedef struct {
-    bool mergable;
-    int pos1;
-    int pos2;
+typedef struct
+{
+       bool mergable;
+       int pos1;
+       int pos2;
 } patch_merge_t;
 
 typedef struct {
-    float xyz[3];
-    float st[2];
-    float normal[3];
-    float lightmap[2];
+       float xyz[3];
+       float st[2];
+       float normal[3];
+       float lightmap[2];
 } drawVert_t;
 
-namespace scene {
-    class Node;
-
-    class Instance;
+namespace scene
+{
+class Node;
+class Instance;
 }
 
 const int MAX_PATCH_WIDTH = 32;
@@ -51,42 +52,29 @@ const int MAX_PATCH_HEIGHT = 32;
 const int MIN_PATCH_WIDTH = 3;
 const int MIN_PATCH_HEIGHT = 3;
 
-class DPatch {
+class DPatch
+{
 public:
-    std::list<DPatch> SplitRows();
-
-    std::list<DPatch> SplitCols();
-
-    std::list<DPatch> Split();
-
-    void Transpose();
-
+std::list<DPatch> SplitRows();
+std::list<DPatch> SplitCols();
+std::list<DPatch> Split();
+void Transpose();
 //DPatch* TransposePatch(DPatch* p1);
 //void DebugPrint();
-    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);
-
-    scene::Node *QER_entity;
-    scene::Node *QER_brush;
-
-    void LoadFromPatch(scene::Instance &patch);
-
-    void BuildInRadiant(scene::Node *entity = NULL);
-
-    void SetTexture(const char *textureName);
-
-    char texture[256];
-    int width, height;
-    drawVert_t points[MAX_PATCH_WIDTH][MAX_PATCH_HEIGHT];
-
-    DPatch();
-
-    virtual ~DPatch();
+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 );
+scene::Node* QER_entity;
+scene::Node* QER_brush;
+void LoadFromPatch( scene::Instance& patch );
+void BuildInRadiant( scene::Node* entity = NULL );
+void SetTexture( const char* textureName );
+char texture[256];
+int width, height;
+drawVert_t points[MAX_PATCH_WIDTH][MAX_PATCH_HEIGHT];
+DPatch();
+virtual ~DPatch();
 
 };
 
index 1258e2b..4699085 100644 (file)
 // Construction/Destruction
 //////////////////////////////////////////////////////////////////////
 
-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
-        globalErrorStream() << "DPlane::DPlane: Bad Normal.\n";
-    }
-
-    _d = (normal[0] * va[0]) + (normal[1] * va[1]) + (normal[2] * va[2]);
-
-    VectorCopy(va, points[0]);
-    VectorCopy(vb, points[1]);
-    VectorCopy(vc, points[2]);
-
-    m_bChkOk = true;
-
-    if (texData) {
-        memcpy(&texInfo, texData, sizeof(_QERFaceData));
-    } else {
-        FillDefaultTexture(&texInfo, points[0], points[1], points[2], "textures/common/caulk");
-    }
+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
+               globalErrorStream() << "DPlane::DPlane: Bad Normal.\n";
+       }
+
+       _d = ( normal[0] * va[0] ) + ( normal[1] * va[1] ) + ( normal[2] * va[2] );
+
+       VectorCopy( va, points[0] );
+       VectorCopy( vb, points[1] );
+       VectorCopy( vc, points[2] );
+
+       m_bChkOk = true;
+
+       if ( texData ) {
+               memcpy( &texInfo, texData, sizeof( _QERFaceData ) );
+       }
+       else{
+               FillDefaultTexture( &texInfo, points[0], points[1], points[2], "textures/common/caulk" );
+       }
 }
 
-DPlane::~DPlane()
-{
+DPlane::~DPlane(){
 
 }
 
@@ -66,216 +65,204 @@ DPlane::~DPlane()
 // Implementation
 //////////////////////////////////////////////////////////////////////
 
-vec_t DPlane::DistanceToPoint(vec3_t pnt)
-{
-    vec3_t tmp;
-    VectorSubtract(pnt, points[0], tmp);
-    return DotProduct(tmp, normal);
+vec_t DPlane::DistanceToPoint( vec3_t pnt ){
+       vec3_t tmp;
+       VectorSubtract( pnt, points[0], tmp );
+       return DotProduct( tmp, normal );
 }
 
-bool DPlane::PlaneIntersection(DPlane *pl1, DPlane *pl2, vec3_t out)
-{
-    float a1, a2, a3;
-    float b1, b2, b3;
-    float c1, c2, c3;
-
-    a1 = normal[0];
-    a2 = normal[1];
-    a3 = normal[2];
-    b1 = pl1->normal[0];
-    b2 = pl1->normal[1];
-    b3 = pl1->normal[2];
-    c1 = pl2->normal[0];
-    c2 = pl2->normal[1];
-    c3 = pl2->normal[2];
-
-    float d = Determinant3x3(a1, a2, a3, b1, b2, b3, c1, c2, c3);
-
-    if (d == 0) {
-        return false;
-    }
-
-    float v1 = _d;
-    float v2 = pl1->_d;
-    float v3 = pl2->_d;
-
-    float d1 = Determinant3x3(v1, a2, a3, v2, b2, b3, v3, c2, c3);
-    float d2 = Determinant3x3(a1, v1, a3, b1, v2, b3, c1, v3, c3);
-    float d3 = Determinant3x3(a1, a2, v1, b1, b2, v2, c1, c2, v3);
-
-    out[0] = d1 / d;
-    out[1] = d2 / d;
-    out[2] = d3 / d;
-
-    return true;
+bool DPlane::PlaneIntersection( DPlane *pl1, DPlane *pl2, vec3_t out ){
+       float a1, a2, a3;
+       float b1, b2, b3;
+       float c1, c2, c3;
+
+       a1 = normal[0];         a2 = normal[1];         a3 = normal[2];
+       b1 = pl1->normal[0];    b2 = pl1->normal[1];    b3 = pl1->normal[2];
+       c1 = pl2->normal[0];    c2 = pl2->normal[1];    c3 = pl2->normal[2];
+
+       float d = Determinant3x3( a1, a2, a3, b1, b2, b3, c1, c2, c3 );
+
+       if ( d == 0 ) {
+               return false;
+       }
+
+       float v1 = _d;
+       float v2 = pl1->_d;
+       float v3 = pl2->_d;
+
+       float d1 = Determinant3x3( v1, a2, a3, v2, b2, b3, v3, c2, c3 );
+       float d2 = Determinant3x3( a1, v1, a3, b1, v2, b3, c1, v3, c3 );
+       float d3 = Determinant3x3( a1, a2, v1, b1, b2, v2, c1, c2, v3 );
+
+       out[0] = d1 / d;
+       out[1] = d2 / d;
+       out[2] = d3 / d;
+
+       return true;
 }
 
-bool DPlane::IsRedundant(std::list<DPoint *> &pointList)
-{
-    int cnt = 0;
-
-    //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) {
-            return false;
-        }
-    }
-    return true;
+bool DPlane::IsRedundant( std::list<DPoint*>& pointList ){
+       int cnt = 0;
+
+       //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 ) {
+                       return false;
+               }
+       }
+       return true;
 }
 
-bool DPlane::operator==(DPlane &other)
-{
-    vec3_t chk;
-    VectorSubtract(other.normal, normal, chk);
-    if (fabs(VectorLength(chk)) > MAX_ROUND_ERROR) {
-        return false;
-    }
+bool DPlane::operator ==( DPlane& other ){
+       vec3_t chk;
+       VectorSubtract( other.normal, normal, chk );
+       if ( fabs( VectorLength( chk ) ) > MAX_ROUND_ERROR ) {
+               return false;
+       }
 
-    if (fabs(other._d - _d) > MAX_ROUND_ERROR) {
-        return false;
-    }
+       if ( fabs( other._d - _d ) > MAX_ROUND_ERROR ) {
+               return false;
+       }
 
-    return true;
+       return true;
 }
 
-bool DPlane::operator!=(DPlane &other)
-{
-    vec3_t chk;
-    VectorAdd(other.normal, normal, chk);
-    if (fabs(VectorLength(chk)) > MAX_ROUND_ERROR) {
-        return false;
-    }
+bool DPlane::operator !=( DPlane& other ){
+       vec3_t chk;
+       VectorAdd( other.normal, normal, chk );
+       if ( fabs( VectorLength( chk ) ) > MAX_ROUND_ERROR ) {
+               return false;
+       }
 
-    return true;
+       return true;
 }
 
-DWinding *DPlane::BaseWindingForPlane()
-{
-    int i, x;
-    vec_t max, v;
-    vec3_t org, vright, vup;
+DWinding* DPlane::BaseWindingForPlane(){
+       int i, x;
+       vec_t max, v;
+       vec3_t org, vright, vup;
 
 // find the major axis
 
-    max = -131072;
-    x = -1;
-    for (i = 0; i < 3; i++) {
-        v = (float) fabs(normal[i]);
-        if (v > max) {
-            x = i;
-            max = v;
-        }
-    }
-    if (x == -1) {
-        globalOutputStream() << "BaseWindingForPlane: no axis found";
-    }
-
-    VectorCopy(vec3_origin, vup);
-    switch (x) {
-        case 0:
-        case 1:
-            vup[2] = 1;
-            break;
-        case 2:
-            vup[0] = 1;
-            break;
-    }
-
-    v = DotProduct(vup, normal);
-    VectorMA(vup, -v, normal, vup);
-    VectorNormalize(vup, vup);
-
-    VectorScale(normal, _d, org);
-
-    CrossProduct(vup, normal, vright);
-
-    VectorScale(vup, 131072, vup);
-    VectorScale(vright, 131072, vright);
+       max = -131072;
+       x = -1;
+       for ( i = 0 ; i < 3; i++ )
+       {
+               v = (float)fabs( normal[i] );
+               if ( v > max ) {
+                       x = i;
+                       max = v;
+               }
+       }
+       if ( x == -1 ) {
+               globalOutputStream() << "BaseWindingForPlane: no axis found";
+       }
+
+       VectorCopy( vec3_origin, vup );
+       switch ( x )
+       {
+       case 0:
+       case 1:
+               vup[2] = 1;
+               break;
+       case 2:
+               vup[0] = 1;
+               break;
+       }
+
+       v = DotProduct( vup, normal );
+       VectorMA( vup, -v, normal, vup );
+       VectorNormalize( vup, vup );
+
+       VectorScale( normal, _d, org );
+
+       CrossProduct( vup, normal, vright );
+
+       VectorScale( vup, 131072, vup );
+       VectorScale( vright, 131072, vright );
 
 // project a really big        axis aligned box onto the plane
-    DWinding *w = new DWinding;
-    w->AllocWinding(4);
+       DWinding* w = new DWinding;
+       w->AllocWinding( 4 );
 
-    VectorSubtract(org, vright, w->p[0]);
-    VectorAdd(w->p[0], vup, w->p[0]);
+       VectorSubtract( org, vright, w->p[0] );
+       VectorAdd( w->p[0], vup, w->p[0] );
 
-    VectorAdd(org, vright, w->p[1]);
-    VectorAdd(w->p[1], vup, w->p[1]);
+       VectorAdd( org, vright, w->p[1] );
+       VectorAdd( w->p[1], vup, w->p[1] );
 
-    VectorAdd(org, vright, w->p[2]);
-    VectorSubtract(w->p[2], vup, w->p[2]);
+       VectorAdd( org, vright, w->p[2] );
+       VectorSubtract( w->p[2], vup, w->p[2] );
 
-    VectorSubtract(org, vright, w->p[3]);
-    VectorSubtract(w->p[3], vup, w->p[3]);
+       VectorSubtract( org, vright, w->p[3] );
+       VectorSubtract( w->p[3], vup, w->p[3] );
 
-    return w;
+       return w;
 }
 
-void DPlane::Rebuild()
-{
-    vec3_t v1, v2;
-    VectorSubtract(points[0], points[1], v1);
-    VectorSubtract(points[2], points[1], v2);
-    CrossProduct(v1, v2, normal);
+void DPlane::Rebuild(){
+       vec3_t v1, v2;
+       VectorSubtract( points[0], points[1], v1 );
+       VectorSubtract( points[2], points[1], v2 );
+       CrossProduct( v1, v2, normal );
 
-    if (VectorNormalize(normal, normal) == 0) {  // normalizes and returns length
-        globalErrorStream() << "DPlane::Rebuild: Bad Normal.\n";
-    }
+       if ( VectorNormalize( normal, normal ) == 0 ) {  // normalizes and returns length
+               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] );
 
-    VectorCopy(points[0], texInfo.m_p0);
-    VectorCopy(points[1], texInfo.m_p1);
-    VectorCopy(points[2], texInfo.m_p2);
+       VectorCopy( points[0], texInfo.m_p0 );
+       VectorCopy( points[1], texInfo.m_p1 );
+       VectorCopy( points[2], texInfo.m_p2 );
 }
 
-bool DPlane::AddToBrush(scene::Node &brush)
-{
-    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().Brush_addFace(brush, faceData);
-
-    return changed;
+bool DPlane::AddToBrush( scene::Node& brush ){
+       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().Brush_addFace( brush, faceData );
+
+       return changed;
 }
 
 void DPlane::ScaleTexture()
-{}
+{ }
 
-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);
-    VectorSubtract(vc, vb, v2);
-    CrossProduct(v1, v2, normal);
+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 );
+       VectorSubtract( vc, vb, v2 );
+       CrossProduct( v1, v2, normal );
 
-    if (VectorNormalize(normal, normal) == 0) {  // normalizes and returns length
-        globalErrorStream() << "DPlane::DPlane: Bad Normal.\n";
-    }
+       if ( VectorNormalize( normal, normal ) == 0 ) {  // normalizes and returns length
+               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] );
 
-    VectorCopy(va, points[0]);
-    VectorCopy(vb, points[1]);
-    VectorCopy(vc, points[2]);
+       VectorCopy( va, points[0] );
+       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) {
-        texInfo.contents |= FACE_DETAIL;
-    }
+       FillDefaultTexture( &texInfo, points[0], points[1], points[2], textureName );
+       if ( bDetail ) {
+               texInfo.contents |= FACE_DETAIL;
+       }
 }
index 62c9edb..88a3358 100644 (file)
@@ -30,7 +30,6 @@
 #include "mathlib.h"
 
 class Brush;
-
 class DPoint;
 
 #define FACE_DETAIL 0x8000000
@@ -41,41 +40,34 @@ class DPoint;
 
 class DWinding;
 
-class DPlane {
+class DPlane
+{
 public:
-    DPlane(const vec3_t va, const vec3_t vb, const vec3_t vc, const char *textureName, bool bDetail);
-
-    void ScaleTexture();
-
-    DWinding *BaseWindingForPlane();
-
-    void Rebuild();
-
-    bool AddToBrush(scene::Node &brush);
-
-    bool operator!=(DPlane &other);
-
-    bool operator==(DPlane &other);
-
-    bool IsRedundant(std::list<DPoint *> &pointList);
+DPlane( const vec3_t va, const vec3_t vb, const vec3_t vc, const char* textureName, bool bDetail );
+void ScaleTexture();
+DWinding* BaseWindingForPlane();
 
-    bool PlaneIntersection(DPlane *pl1, DPlane *pl2, vec3_t out);
+void Rebuild();
 
-    vec_t DistanceToPoint(vec3_t pnt);
+bool AddToBrush( scene::Node& brush );
+bool operator !=( DPlane& other );
+bool operator ==( DPlane& other );
 
-    DPlane(const vec3_t va, const vec3_t vb, const vec3_t vc, const _QERFaceData *texData);
+bool IsRedundant( std::list<DPoint*>& pointList );
+bool PlaneIntersection( DPlane* pl1, DPlane* pl2, vec3_t out );
 
-    DPlane()
-    {}
+vec_t DistanceToPoint( vec3_t pnt );
 
-    virtual ~DPlane();
+DPlane( const vec3_t va, const vec3_t vb, const vec3_t vc, const _QERFaceData* texData );
+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;
+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;
 };
 
 //typedef CList<DPlane*, DPlane*> DPlaneList;
index 4eb8fca..58628e6 100644 (file)
 // Construction/Destruction
 //////////////////////////////////////////////////////////////////////
 
-DPoint::DPoint()
-{
+DPoint::DPoint(){
 
 }
 
-DPoint::~DPoint()
-{
+DPoint::~DPoint(){
 
 }
 
@@ -42,12 +40,11 @@ DPoint::~DPoint()
 // Implementation
 //////////////////////////////////////////////////////////////////////
 
-bool DPoint::operator==(vec3_t other)
-{
-    vec3_t test;
-    VectorSubtract(other, _pnt, test);
-    if (fabs(VectorLength(test)) > MAX_ROUND_ERROR) {
-        return false;
-    }
-    return true;
+bool DPoint::operator ==( vec3_t other ){
+       vec3_t test;
+       VectorSubtract( other, _pnt, test );
+       if ( fabs( VectorLength( test ) ) > MAX_ROUND_ERROR ) {
+               return false;
+       }
+       return true;
 }
index d29d415..f7b6839 100644 (file)
 
 #include "mathlib.h"
 
-class DPoint {
+class DPoint
+{
 public:
-    DPoint();
+DPoint();
+virtual ~DPoint();
 
-    virtual ~DPoint();
+bool operator ==( vec3_t other );
 
-    bool operator==(vec3_t other);
-
-    vec3_t _pnt;
-    unsigned char m_uData;
+vec3_t _pnt;
+unsigned char m_uData;
 };
 
 //typedef CList<DPoint*, DPoint*> DPointList;
index aa76888..8c675ff 100644 (file)
 
 bool bFacesAll[6] = {true, true, true, true, true, true};
 
-DShape::DShape()
-{
-    m_nNextBrush = 0;
+DShape::DShape(){
+       m_nNextBrush = 0;
 }
 
-DShape::~DShape()
-{
+DShape::~DShape(){
 
 }
 
-void DShape::BuildRegularPrism(vec3_t min, vec3_t max, int nSides, bool bAlignTop)
-{
-    vec3_t vc[MAX_POLYGON_FACES + 2], vd[MAX_POLYGON_FACES + 2];
+void DShape::BuildRegularPrism( vec3_t min, vec3_t max, int nSides, bool bAlignTop ){
+       vec3_t vc[MAX_POLYGON_FACES + 2], vd[MAX_POLYGON_FACES + 2];
 
-    vec3_t radius;
-    vec3_t origin;
+       vec3_t radius;
+       vec3_t origin;
 
-    VectorSubtract(max, min, radius);
-    VectorScale(radius, 0.5f, radius);
-    // calc 3d radius and origin
-    VectorAdd(max, min, origin);
-    VectorScale(origin, 0.5f, origin);
+       VectorSubtract( max, min, radius );
+       VectorScale( radius, 0.5f, radius );
+       // calc 3d radius and origin
+       VectorAdd( max, min, origin );
+       VectorScale( origin, 0.5f, origin );
 
-    float phase = 0.0f;
+       float phase = 0.0f;
 
-    if (bAlignTop) {
-        phase = -(Q_PI / nSides);
-        VectorScale(radius, static_cast<float>( 1.0 / cos(phase)), radius);
-    }
+       if ( bAlignTop ) {
+               phase = -( Q_PI / nSides );
+               VectorScale( radius, static_cast<float>( 1.0 / cos( phase ) ), radius );
+       }
 
-    //----- Build Polygon Vertices -----
+       //----- Build Polygon Vertices -----
 
-    int i;
-    for (i = 0; i < nSides; i++) {
-        VectorCopy(origin, vc[i]);
-        VectorCopy(origin, vd[i]);
+       int i;
+       for ( i = 0; i < nSides; i++ )
+       {
+               VectorCopy( origin, vc[i] );
+               VectorCopy( origin, vd[i] );
 
-        vc[i][2] = min[2];
-        vd[i][2] = max[2];
+               vc[i][2] = min[2];
+               vd[i][2] = max[2];
 
-        vc[i][0] += radius[0] * sinf((2 * Q_PI * i / nSides) + phase);
-        vc[i][1] += radius[1] * cosf((2 * Q_PI * i / nSides) + phase);
+               vc[i][0] += radius[0] * sinf( ( 2 * Q_PI * i / nSides ) + phase );
+               vc[i][1] += radius[1] * cosf( ( 2 * Q_PI * i / nSides ) + phase );
 
-        vd[i][0] = vc[i][0];
-        vd[i][1] = vc[i][1];
-    }
+               vd[i][0] = vc[i][0];
+               vd[i][1] = vc[i][1];
+       }
 
-    VectorCopy(vc[0], vc[nSides]);
-    VectorCopy(vd[0], vd[nSides]);
-    VectorCopy(vc[1], vc[nSides + 1]);
-    VectorCopy(vd[1], vd[nSides + 1]);
+       VectorCopy( vc[0], vc[nSides] );
+       VectorCopy( vd[0], vd[nSides] );
+       VectorCopy( vc[1], vc[nSides + 1] );
+       VectorCopy( vd[1], vd[nSides + 1] );
 
-    //----------------------------------
+       //----------------------------------
 
-    DBrush *pB = m_Container.GetWorldSpawn()->NewBrush(m_nNextBrush++);
+       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);
-    }
+       for ( i = 1; i <= nSides; i++ )
+               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();
-    m_Container.BuildInRadiant(true);
+void DShape::Commit(){
+       m_Container.GetWorldSpawn()->FixBrushes();
+       m_Container.BuildInRadiant( true );
 }
 
-void DShape::BuildInversePrism(vec3_t min, vec3_t max, int nSides, bool bAlignTop)
-{
-    vec3_t va[MAX_POLYGON_FACES + 1], vb[MAX_POLYGON_FACES + 1];
-    vec3_t radius;
-    vec3_t origin;
-
-    VectorSubtract(max, min, radius);
-    VectorScale(radius, 0.5f, radius);
-    // calc 3d radius and origin
-    VectorAdd(max, min, origin);
-    VectorScale(origin, 0.5f, origin);
-
-    float phase = 0.0f;
-
-    if (bAlignTop) {
-        phase = -(Q_PI / nSides);
-        VectorScale(radius, static_cast<float>( 1.0 / cos(phase)), radius);
-    }
-
-    //----- Build Polygon Vertices -----
-
-    int i;
-    for (i = 0; i < nSides; i++) {
-        VectorCopy(origin, va[i]);
-        VectorCopy(origin, vb[i]);
-
-        va[i][2] = min[2];
-        vb[i][2] = max[2];
-
-        va[i][0] += radius[0] * sinf((2 * Q_PI * i / nSides) + phase);
-        va[i][1] += radius[1] * cosf((2 * Q_PI * i / nSides) + phase);
-
-        vb[i][0] = va[i][0];
-        vb[i][1] = va[i][1];
-    }
-
-    VectorCopy(va[0], va[nSides]);
-    VectorCopy(vb[0], vb[nSides]);
-
-    //----------------------------------
-
-    for (i = 1; i <= nSides; i++) {
-        DBrush *pB = GetBoundingCube(min, max, "textures/common/caulk");
-
-        vec3_t top, bottom;
-        VectorCopy(va[i - 1], top);
-        VectorCopy(va[i], bottom);
-
-        if (va[i - 1][1] > va[i][1]) {
-            top[0] += 5;
-            bottom[0] += 5;
-        } else    // flip direction of plane on crossover
-        {
-            top[0] -= 5;
-            bottom[0] -= 5;
-        }
-
-        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);
-        }   // add cut-off planes
-
-        pB->AddFace(va[i - 1], vb[i - 1], vb[i], GetCurrentTexture(), false);
-        // add internal polygon plane
-    }
+void DShape::BuildInversePrism( vec3_t min, vec3_t max, int nSides, bool bAlignTop ){
+       vec3_t va[MAX_POLYGON_FACES + 1], vb[MAX_POLYGON_FACES + 1];
+       vec3_t radius;
+       vec3_t origin;
+
+       VectorSubtract( max, min, radius );
+       VectorScale( radius, 0.5f, radius );
+       // calc 3d radius and origin
+       VectorAdd( max, min, origin );
+       VectorScale( origin, 0.5f, origin );
+
+       float phase = 0.0f;
+
+       if ( bAlignTop ) {
+               phase = -( Q_PI / nSides );
+               VectorScale( radius, static_cast<float>( 1.0 / cos( phase ) ), radius );
+       }
+
+       //----- Build Polygon Vertices -----
+
+       int i;
+       for ( i = 0; i < nSides; i++ )
+       {
+               VectorCopy( origin, va[i] );
+               VectorCopy( origin, vb[i] );
+
+               va[i][2] = min[2];
+               vb[i][2] = max[2];
+
+               va[i][0] += radius[0] * sinf( ( 2 * Q_PI * i / nSides ) + phase );
+               va[i][1] += radius[1] * cosf( ( 2 * Q_PI * i / nSides ) + phase );
+
+               vb[i][0] = va[i][0];
+               vb[i][1] = va[i][1];
+       }
+
+       VectorCopy( va[0], va[nSides] );
+       VectorCopy( vb[0], vb[nSides] );
+
+       //----------------------------------
+
+       for ( i = 1; i <= nSides; i++ )
+       {
+               DBrush* pB = GetBoundingCube( min, max, "textures/common/caulk" );
+
+               vec3_t top, bottom;
+               VectorCopy( va[i - 1], top );
+               VectorCopy( va[i], bottom );
+
+               if ( va[i - 1][1] > va[i][1] ) {
+                       top[0] += 5;
+                       bottom[0] += 5;
+               }
+               else    // flip direction of plane on crossover
+               {
+                       top[0] -= 5;
+                       bottom[0] -= 5;
+               }
+
+               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 );
+               }   // add cut-off planes
+
+               pB->AddFace( va[i - 1], vb[i - 1], vb[i], GetCurrentTexture(), false );
+               // add internal polygon plane
+       }
 }
 
-void DShape::BuildBorderedPrism(vec3_t min, vec3_t max, int nSides, int nBorder, bool bAlignTop)
-{
-    vec3_t va[MAX_POLYGON_FACES + 2], vb[MAX_POLYGON_FACES + 2];
-    vec3_t vc[MAX_POLYGON_FACES + 2], vd[MAX_POLYGON_FACES + 2];
+void DShape::BuildBorderedPrism( vec3_t min, vec3_t max, int nSides, int nBorder, bool bAlignTop ){
+       vec3_t va[MAX_POLYGON_FACES + 2], vb[MAX_POLYGON_FACES + 2];
+       vec3_t vc[MAX_POLYGON_FACES + 2], vd[MAX_POLYGON_FACES + 2];
 
-    vec3_t radius;
-    vec3_t origin;
+       vec3_t radius;
+       vec3_t origin;
 
-    VectorSubtract(max, min, radius);
-    VectorScale(radius, 0.5f, radius);
-    // calc 3d radius and origin
-    VectorAdd(max, min, origin);
-    VectorScale(origin, 0.5f, origin);
+       VectorSubtract( max, min, radius );
+       VectorScale( radius, 0.5f, radius );
+       // calc 3d radius and origin
+       VectorAdd( max, min, origin );
+       VectorScale( origin, 0.5f, origin );
 
-    if (nBorder >= Min(radius[0], radius[1])) {
+       if ( nBorder >= Min( radius[0], radius[1] ) ) {
 //             DoMessageBox("Border is too large", "Error", MB_OK);
-        return;
-    }
+               return;
+       }
+
+       float phase = 0.0f;
 
-    float phase = 0.0f;
+       if ( bAlignTop ) {
+               phase = -( Q_PI / nSides );
+               VectorScale( radius, static_cast<float>( 1.0 / cos( phase ) ), radius );
+       }
 
-    if (bAlignTop) {
-        phase = -(Q_PI / nSides);
-        VectorScale(radius, static_cast<float>( 1.0 / cos(phase)), radius);
-    }
+       //----- Build Polygon Vertices -----
 
-    //----- Build Polygon Vertices -----
+       int i;
+       for ( i = 0; i < nSides; i++ )
+       {
+               VectorCopy( origin, va[i] );
+               VectorCopy( origin, vb[i] );
+               VectorCopy( origin, vc[i] );
+               VectorCopy( origin, vd[i] );
 
-    int i;
-    for (i = 0; i < nSides; i++) {
-        VectorCopy(origin, va[i]);
-        VectorCopy(origin, vb[i]);
-        VectorCopy(origin, vc[i]);
-        VectorCopy(origin, vd[i]);
+               va[i][2] = min[2];
+               vb[i][2] = max[2];
 
-        va[i][2] = min[2];
-        vb[i][2] = max[2];
+               va[i][0] += ( radius[0] - nBorder ) * sinf( ( 2 * Q_PI * i / nSides ) + phase );
+               va[i][1] += ( radius[1] - nBorder ) * cosf( ( 2 * Q_PI * i / nSides ) + phase );
 
-        va[i][0] += (radius[0] - nBorder) * sinf((2 * Q_PI * i / nSides) + phase);
-        va[i][1] += (radius[1] - nBorder) * cosf((2 * Q_PI * i / nSides) + phase);
+               vb[i][0] = va[i][0];
+               vb[i][1] = va[i][1];
 
-        vb[i][0] = va[i][0];
-        vb[i][1] = va[i][1];
 
 
-        vc[i][2] = min[2];
-        vd[i][2] = max[2];
+               vc[i][2] = min[2];
+               vd[i][2] = max[2];
 
-        vc[i][0] += radius[0] * sinf((2 * Q_PI * i / nSides) + phase);
-        vc[i][1] += radius[1] * cosf((2 * Q_PI * i / nSides) + phase);
+               vc[i][0] += radius[0] * sinf( ( 2 * Q_PI * i / nSides ) + phase );
+               vc[i][1] += radius[1] * cosf( ( 2 * Q_PI * i / nSides ) + phase );
 
-        vd[i][0] = vc[i][0];
-        vd[i][1] = vc[i][1];
-    }
+               vd[i][0] = vc[i][0];
+               vd[i][1] = vc[i][1];
+       }
 
-    VectorCopy(va[0], va[nSides]);
-    VectorCopy(vb[0], vb[nSides]);
-    VectorCopy(va[1], va[nSides + 1]);
-    VectorCopy(vb[1], vb[nSides + 1]);
+       VectorCopy( va[0], va[nSides] );
+       VectorCopy( vb[0], vb[nSides] );
+       VectorCopy( va[1], va[nSides + 1] );
+       VectorCopy( vb[1], vb[nSides + 1] );
 
-    VectorCopy(vc[0], vc[nSides]);
-    VectorCopy(vd[0], vd[nSides]);
-    VectorCopy(vc[1], vc[nSides + 1]);
-    VectorCopy(vd[1], vd[nSides + 1]);
+       VectorCopy( vc[0], vc[nSides] );
+       VectorCopy( vd[0], vd[nSides] );
+       VectorCopy( vc[1], vc[nSides + 1] );
+       VectorCopy( vd[1], vd[nSides + 1] );
 
-    //----------------------------------
+       //----------------------------------
 
-    for (i = 1; i <= nSides; i++) {
-        DBrush *pB = GetBoundingCube(min, max, "textures/common/caulk");
+       for ( i = 1; i <= nSides; i++ )
+       {
+               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 );
+       }
 }
 
-DBrush *DShape::GetBoundingCube_Ext(vec3_t min, vec3_t max, const char *textureName, bool *bUseFaces, bool detail)
-{
-    DBrush *pB = new DBrush;
-    //----- Build Outer Bounds ---------
-
-    vec3_t v1, v2, v3, v5, v6, v7;
-    VectorCopy(min, v1);
-    VectorCopy(min, v2);
-    VectorCopy(min, v3);
-    VectorCopy(max, v5);
-    VectorCopy(max, v6);
-    VectorCopy(max, v7);
-
-    v2[0] = max[0];
-    v3[1] = max[1];
-
-    v6[0] = min[0];
-    v7[1] = min[1];
-
-    //----------------------------------
-
-    //----- Add Six Cube Faces ---------
-
-    if (bUseFaces[0]) {
-        pB->AddFace(v1, v2, v3, textureName, detail);
-    }
-    if (bUseFaces[1]) {
-        pB->AddFace(v1, v3, v6, textureName, detail);
-    }
-    if (bUseFaces[2]) {
-        pB->AddFace(v1, v7, v2, textureName, detail);
-    }
-
-    if (bUseFaces[3]) {
-        pB->AddFace(v5, v6, v3, textureName, detail);
-    }
-    if (bUseFaces[4]) {
-        pB->AddFace(v5, v2, v7, textureName, detail);
-    }
-    if (bUseFaces[5]) {
-        pB->AddFace(v5, v7, v6, textureName, detail);
-    }
-
-    //----------------------------------
-
-    return pB;
+DBrush* DShape::GetBoundingCube_Ext( vec3_t min, vec3_t max, const char *textureName, bool* bUseFaces, bool detail ){
+       DBrush* pB = new DBrush;
+       //----- Build Outer Bounds ---------
+
+       vec3_t v1, v2, v3, v5, v6, v7;
+       VectorCopy( min, v1 );
+       VectorCopy( min, v2 );
+       VectorCopy( min, v3 );
+       VectorCopy( max, v5 );
+       VectorCopy( max, v6 );
+       VectorCopy( max, v7 );
+
+       v2[0] = max[0];
+       v3[1] = max[1];
+
+       v6[0] = min[0];
+       v7[1] = min[1];
+
+       //----------------------------------
+
+       //----- Add Six Cube Faces ---------
+
+       if ( bUseFaces[0] ) {
+               pB->AddFace( v1, v2, v3, textureName, detail );
+       }
+       if ( bUseFaces[1] ) {
+               pB->AddFace( v1, v3, v6, textureName, detail );
+       }
+       if ( bUseFaces[2] ) {
+               pB->AddFace( v1, v7, v2, textureName, detail );
+       }
+
+       if ( bUseFaces[3] ) {
+               pB->AddFace( v5, v6, v3, textureName, detail );
+       }
+       if ( bUseFaces[4] ) {
+               pB->AddFace( v5, v2, v7, textureName, detail );
+       }
+       if ( bUseFaces[5] ) {
+               pB->AddFace( v5, v7, v6, textureName, detail );
+       }
+
+       //----------------------------------
+
+       return pB;
 }
 
-DBrush *DShape::GetBoundingCube(vec3_t min, vec3_t max, const char *textureName, DEntity *ent, bool *bUseFaces)
-{
-    DBrush *pB;
-    if (ent == NULL) {
-        pB = m_Container.GetWorldSpawn()->NewBrush(m_nNextBrush++);
-    } else {
-        pB = ent->NewBrush(m_nNextBrush++);
-    }
-
-    //----- Build Outer Bounds ---------
-
-    vec3_t v1, v2, v3, v5, v6, v7;
-    VectorCopy(min, v1);
-    VectorCopy(min, v2);
-    VectorCopy(min, v3);
-    VectorCopy(max, v5);
-    VectorCopy(max, v6);
-    VectorCopy(max, v7);
-
-    v2[0] = max[0];
-    v3[1] = max[1];
-
-    v6[0] = min[0];
-    v7[1] = min[1];
-
-    //----------------------------------
-
-    //----- Add Six Cube Faces ---------
-
-    if (bUseFaces[0]) {
-        pB->AddFace(v1, v2, v3, textureName, false);
-    }
-    if (bUseFaces[1]) {
-        pB->AddFace(v1, v3, v6, textureName, false);
-    }
-    if (bUseFaces[2]) {
-        pB->AddFace(v1, v7, v2, textureName, false);
-    }
-
-    if (bUseFaces[3]) {
-        pB->AddFace(v5, v6, v3, textureName, false);
-    }
-    if (bUseFaces[4]) {
-        pB->AddFace(v5, v2, v7, textureName, false);
-    }
-    if (bUseFaces[5]) {
-        pB->AddFace(v5, v7, v6, textureName, false);
-    }
-
-    //----------------------------------
-
-    return pB;
+DBrush* DShape::GetBoundingCube( vec3_t min, vec3_t max, const char *textureName, DEntity* ent, bool* bUseFaces ){
+       DBrush* pB;
+       if ( ent == NULL ) {
+               pB = m_Container.GetWorldSpawn()->NewBrush( m_nNextBrush++ );
+       }
+       else{
+               pB = ent->NewBrush( m_nNextBrush++ );
+       }
+
+       //----- Build Outer Bounds ---------
+
+       vec3_t v1, v2, v3, v5, v6, v7;
+       VectorCopy( min, v1 );
+       VectorCopy( min, v2 );
+       VectorCopy( min, v3 );
+       VectorCopy( max, v5 );
+       VectorCopy( max, v6 );
+       VectorCopy( max, v7 );
+
+       v2[0] = max[0];
+       v3[1] = max[1];
+
+       v6[0] = min[0];
+       v7[1] = min[1];
+
+       //----------------------------------
+
+       //----- Add Six Cube Faces ---------
+
+       if ( bUseFaces[0] ) {
+               pB->AddFace( v1, v2, v3, textureName, false );
+       }
+       if ( bUseFaces[1] ) {
+               pB->AddFace( v1, v3, v6, textureName, false );
+       }
+       if ( bUseFaces[2] ) {
+               pB->AddFace( v1, v7, v2, textureName, false );
+       }
+
+       if ( bUseFaces[3] ) {
+               pB->AddFace( v5, v6, v3, textureName, false );
+       }
+       if ( bUseFaces[4] ) {
+               pB->AddFace( v5, v2, v7, textureName, false );
+       }
+       if ( bUseFaces[5] ) {
+               pB->AddFace( v5, v7, v6, textureName, false );
+       }
+
+       //----------------------------------
+
+       return pB;
 }
 
-bool DShape::BuildPit(vec3_t min, vec3_t max)
-{
-    if ((max[2] - min[2]) < 196) {
-        return false;
-    }
+bool DShape::BuildPit( vec3_t min, vec3_t max ){
+       if ( ( max[2] - min[2] ) < 196 ) {
+