Ignore:
Timestamp:
06/22/08 05:24:22 (16 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/App/Demos/Vis/FriendlyCulling/src
Files:
19 edited
2 moved

Legend:

Unmodified
Added
Removed
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.cpp

    r2792 r2795  
    1313#include "Geometry.h" 
    1414#include "RenderState.h" 
     15#include "gzstream.h" 
    1516 
    1617 
     
    6667static int sClipPlaneAABBVertexIndices[12]; 
    6768 
     69 
     70#define ALIGN_INDICES 
    6871 
    6972BvhNode::BvhNode(BvhNode *parent):  
     
    177180        mCurrentIndicesPtr = 0; 
    178181        mNumNodes = 0; 
    179         mMaxDepthForTestingChildren = 4; 
    180         mAreaRatioThreshold = 1.4f; 
     182         
     183        mMaxDepthForTestingChildren = 3; 
     184        //mMaxDepthForTestingChildren = 4; 
     185        mAreaRatioThreshold = 2.0f; 
     186        //mAreaRatioThreshold = 1.4f; 
     187 
    181188        mVboId = -1; 
    182189} 
     
    452459                memcpy(mIndices + numNodes * sNumIndicesPerBox,  
    453460                           mTestIndices + node->mIndicesPtr,  
    454 #if 0 //ALIGN_INDICES 
    455                            ((numIndices / 32) * 32 + 32) * sizeof(unsigned int)); 
    456 #else 
    457461                           numIndices * sizeof(unsigned int)); 
    458 #endif 
     462 
    459463                numNodes += node->mNumTestNodes; 
    460464        } 
     
    485489 
    486490 
    487 #define ALIGN_INDICES 1 
    488  
    489491void Bvh::CreateIndices() 
    490492{ 
     
    502504        { 
    503505                int offset = (*lit)->mNumTestNodes * sNumIndicesPerBox; 
    504 #if ALIGN_INDICES 
     506#ifdef ALIGN_INDICES 
    505507                // align with 32 
    506508                offset = (offset / 32) * 32 + 32;  
     
    547549 
    548550                // align with 32 
    549 #if ALIGN_INDICES 
     551#ifdef ALIGN_INDICES 
    550552                const int offset = (numIndices / 32) * 32 + 32; 
    551553#else 
     
    654656                BvhNode *node = *lit; 
    655657 
    656                 // recreate list of nodes that will be tested as a proxy ... 
     658                // recreate list of nodes that will be queried as a proxy 
    657659                if (CreateNodeRenderList(node)) 
    658660                        ++ success; 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/BvhLoader.cpp

    r2786 r2795  
    55 
    66#include "BvhLoader.h" 
    7  
     7#include "gzstream.h" 
    88 
    99 
     
    1919 
    2020 
    21 BvhNode *BvhLoader::LoadNextNode(ifstream &stream, BvhInterior *parent) 
     21BvhNode *BvhLoader::LoadNextNode(igzstream &stream, BvhInterior *parent) 
    2222{ 
    2323        int nodeType; 
     
    5555{ 
    5656        queue<BvhNode *> tQueue; 
    57         ifstream stream(filename.c_str(), ifstream::binary); 
     57        igzstream stream(filename.c_str()); 
    5858 
    5959        if (!stream.is_open()) return NULL; 
     
    9898 
    9999        bvh->PostProcess(); 
    100         const int n = 1000; 
    101         // set virtual leaves for n triangles 
    102         bvh->SetVirtualLeaves(n); 
     100         
     101        const int trianglesPerVirtualLeaves = 1000; 
     102        // set virtual leaves for specified number of triangles 
     103        bvh->SetVirtualLeaves(trianglesPerVirtualLeaves); 
    103104 
    104105        bvh->UpdateNumLeaves(bvh->mRoot); 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/BvhLoader.h

    r2782 r2795  
    55 
    66#include "Bvh.h" 
     7 
     8class igzstream; 
    79 
    810 
     
    2022protected: 
    2123         
    22         BvhNode *LoadNextNode(std::ifstream &stream, BvhInterior *parent); 
     24        BvhNode *LoadNextNode(igzstream &stream, BvhInterior *parent); 
    2325}; 
    2426 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/CHCPlusPlusTraverser.cpp

    r2792 r2795  
    184184 
    185185        // render the rest of the objects 
    186         if (mUseRenderQueue) 
    187         { 
    188                 if (mRenderState->SetState(RenderState::RENDER)) 
    189                         ++ mStats.mNumStateChanges; 
    190  
    191                 mRenderQueue.Render(); 
    192                 mRenderQueue.Clear(); 
    193         } 
     186        if (mUseRenderQueue) ApplyRenderQueue(); 
    194187 
    195188 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/CHCTraverser.cpp

    r2792 r2795  
    1212OcclusionQuery *CHCTraverser::IssueOcclusionQueryWithGeometry(BvhNode *node) 
    1313{ 
     14        // render out what is left in the qeue 
     15        if (mUseRenderQueue) ApplyRenderQueue(); 
     16 
    1417        OcclusionQuery *query = mQueryHandler.RequestQuery(); 
    1518        query->AddNode(node); 
     
    2023 
    2124        RenderNode(node); 
    22  
    23         if (mUseRenderQueue) 
    24         { 
    25                 mRenderQueue.Render(); 
    26                 mRenderQueue.Clear(); 
    27         } 
     25        if (mUseRenderQueue) ApplyRenderQueue(); 
    2826 
    2927        query->EndQuery(); 
     
    134132                } 
    135133        } 
    136  
    137         /// Empty render queue. 
    138         if (mUseRenderQueue) 
    139         { 
    140                 mRenderQueue.Render(); 
    141                 mRenderQueue.Clear(); 
    142         } 
    143134} 
    144135 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/FrustumCullingTraverser.cpp

    r2792 r2795  
    3636                } 
    3737        } 
    38  
    39         // render the contents of the render queue 
    40         if (mUseRenderQueue) 
    41         { 
    42                 mRenderQueue.Render(); 
    43                 mRenderQueue.Clear(); 
    44         } 
    4538} 
    4639 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Geometry.cpp

    r2786 r2795  
    1919mVboId(-1) 
    2020{ 
     21        mHasTexture = (mTexCoords != NULL); 
     22 
    2123        Prepare(); 
    2224 
    2325        if (delData) 
    2426        { 
    25                 delete [] mVertices; mVertices = NULL; 
    26                 delete [] mNormals;  mNormals = NULL; 
    27                 //if (mTexCoords) delete [] mTexCoords; mTexCoords = NULL; 
     27                DEL_ARRAY_PTR(mVertices); 
     28                DEL_ARRAY_PTR(mNormals); 
     29                DEL_ARRAY_PTR(mTexCoords); 
    2830        } 
    2931} 
     
    3234Geometry::~Geometry() 
    3335{ 
    34         if (mVertices) delete [] mVertices;      
    35         if (mNormals) delete [] mNormals; 
    36         if (mTexCoords) delete [] mTexCoords; 
     36        DEL_ARRAY_PTR(mVertices); 
     37        DEL_ARRAY_PTR(mNormals); 
     38        DEL_ARRAY_PTR(mTexCoords); 
    3739 
    3840        // delete vbo 
     
    6567 
    6668        glGenBuffersARB(1, &mVboId); 
    67          
    6869        glBindBufferARB(GL_ARRAY_BUFFER_ARB, mVboId); 
    6970 
     
    9394        { 
    9495                glBindBufferARB(GL_ARRAY_BUFFER_ARB, mVboId); 
    95                 glVertexPointer(3, GL_FLOAT, 0, (char *)NULL);   
     96                 
     97                if (mHasTexture) 
     98                        glTexCoordPointer(2, GL_FLOAT, 0, (char *)NULL + 2 * mNumVertices * sizeof(Vector3)); 
     99 
    96100                glNormalPointer(GL_FLOAT, 0, (char *)NULL + mNumVertices * sizeof(Vector3)); 
    97101 
    98                 if (mTexCoords) 
    99                         glTexCoordPointer(2, GL_FLOAT, 0, (char *)NULL + 2 * mNumVertices * sizeof(Vector3)); 
     102                glVertexPointer(3, GL_FLOAT, 0, (char *)NULL);   
    100103 
    101104                state->SetCurrentVboId(mVboId); 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Geometry.h

    r2793 r2795  
    2828        int GetNumTriangles() const { return mNumVertices / 3; } 
    2929 
    30         inline bool HasTexture() const { return mTexCoords != NULL; } 
     30        inline bool HasTexture() const { return mHasTexture; } 
    3131        const AxisAlignedBox3& GetBoundingBox() const; 
    3232 
     
    5252 
    5353        AxisAlignedBox3 mBoundingBox; 
     54 
     55        bool mHasTexture; 
    5456}; 
    5557 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Material.cpp

    r2782 r2795  
    2020        mAlphaTestEnabled = false; 
    2121 
    22         mAmbientColor = RgbaColor(.2f, .2f, .2f, 1.0f); 
     22        mAmbientColor = RgbaColor(0.2f, 0.2f, 0.2f, 1.0f); 
    2323        mDiffuseColor = RgbaColor(1.0f, 1.0f, 1.0f, 1.0f); 
    24         //mSpecularColor = RgbaColor(0.0f, 0.0f, 0.0f, 1.0f); 
     24        //mSpecularColor = RgbaColor(.0f, .0f, .0f, 1.0f); 
    2525        mSpecularColor = RgbaColor(0.5f, 0.5f, 0.5f, 1.0f); 
     26        mEmmisiveColor = RgbaColor(.0f, .0f, .0f, 1.0f); 
    2627} 
    2728 
    2829 
    29 Material::Material(): mId(0) 
    30 { 
    31         InitMaterial(); 
    32 } 
    33  
    34  
    35 Material::Material(int id):  
    36 mId(id) 
     30Material::Material() 
    3731{ 
    3832        InitMaterial(); 
     
    4337mDiffuseColor(color), 
    4438mAmbientColor(color), 
    45 mSpecularColor(0, 0, 0, 1),  
    46 mId(0), 
     39mSpecularColor(0, 0, 0, 1), 
    4740mTexture(NULL) 
    4841{ 
    49 } 
    50  
    51  
    52 int Material::GetId() const 
    53 { 
    54         return mId; 
    5542} 
    5643 
     
    8067        glMaterialfv(GL_FRONT, GL_AMBIENT, (float *)&mAmbientColor.r); 
    8168        glMaterialfv(GL_FRONT, GL_DIFFUSE, (float *)&mDiffuseColor.r); 
     69        glMaterialfv(GL_FRONT, GL_EMISSION, (float *)&mEmmisiveColor.r); 
    8270        glMaterialfv(GL_FRONT, GL_SPECULAR, (float *)&mSpecularColor.r); 
    8371} 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Material.h

    r2782 r2795  
    11#ifndef __MATERIAL_H 
    22#define __MATERIAL_H 
     3 
     4#include "common.h" 
    35 
    46 
     
    3436class Material  
    3537{ 
     38friend class ResourceManager; 
     39 
    3640public: 
    3741 
    3842        Material(); 
    3943 
    40         Material(int id); 
    41  
    4244        Material(const RgbaColor &color); 
    43         /** Returns unique material id. 
    44         */ 
    45         int GetId() const; 
    4645 
    4746        friend Material RandomMaterial(); 
     
    4948        inline Texture *GetTexture() const { return mTexture; } 
    5049 
    51         void SetTexture(Texture *texture) { mTexture = texture; } 
     50        inline RgbaColor GetAmbient() const { return mAmbientColor; } 
     51        inline RgbaColor GetDiffuse() const { return mDiffuseColor; } 
     52        inline RgbaColor GetSpecular() const { return mSpecularColor; } 
     53        inline RgbaColor GetEmmisive() const { return mEmmisiveColor; } 
     54 
     55        inline void SetTexture(Texture *texture) { mTexture = texture; } 
     56 
     57        inline void SetAmbient(const RgbaColor &color) { mAmbientColor = color; } 
     58        inline void SetDiffuse(const RgbaColor &color) { mDiffuseColor = color; } 
     59        inline void SetSpecular(const RgbaColor &color) { mSpecularColor = color; } 
     60        inline void SetEmmisive(const RgbaColor &color) { mEmmisiveColor = color; } 
     61         
     62        inline void SetAlphaTestEnabled(bool alpha) { mAlphaTestEnabled = alpha; } 
     63        inline bool IsAlphaTestEnabled() const { return mAlphaTestEnabled; }  
    5264        /** Renders this material. 
    5365        */ 
    5466        void Render(RenderState *state); 
     67        /** Initialize the material with default values 
     68        */ 
     69        void InitMaterial(); 
    5570 
     71 
     72protected: 
    5673 
    5774        /////////// 
     
    6077        RgbaColor mSpecularColor; 
    6178        RgbaColor mAmbientColor; 
     79        RgbaColor mEmmisiveColor; 
    6280 
    6381        bool mAlphaTestEnabled; 
    64  
    65 protected: 
    66  
    67         /** Initialize the material with default values 
    68         */ 
    69         void InitMaterial(); 
    70  
    71         //////////////// 
    72  
    73         /// unique material id 
    74         int mId; 
    7582        /// the assciated texture 
    7683        Texture *mTexture; 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderQueue.cpp

    r2782 r2795  
    44#include "Texture.h" 
    55#include "Material.h" 
    6  
    76 
    87using namespace std; 
     
    2221        int tsize2 = t2 ? t2->GetByteSize() : 0; 
    2322 
    24         // if texture size equal, group by material 
    25         if (tsize1 == tsize2) 
    26                 return ent1->GetMaterial() < ent2->GetMaterial(); 
     23        return tsize1 < tsize2; 
     24} 
    2725 
    28         return tsize1 < tsize2; 
     26 
     27inline static bool IsLower2(SceneEntity *ent1, SceneEntity *ent2) 
     28{ 
     29        return ent1->GetMaterial() < ent2->GetMaterial(); 
    2930} 
    3031 
     
    6364{ 
    6465        if (mEntities.size() >= mMinSizeForSorting) 
     66        { 
     67                sortTimer.Entry(); 
    6568                Sort(); 
     69                sortTimer.Exit(); 
     70        } 
    6671         
    6772        SceneEntityContainer::const_iterator sit, sit_end = mEntities.end(); 
     
    7277                ent->Render(mState); 
    7378        } 
     79 
     80        //Print(); 
    7481} 
     82 
     83 
     84void RenderQueue::Print() 
     85{ 
     86        SceneEntityContainer::const_iterator sit, sit_end = mEntities.end(); 
     87 
     88        Debug << "\nrq size: " << GetSize() << endl; 
     89        Debug << "texture size: " << endl; 
     90        // show ordering by texture size 
     91        for (sit = mEntities.begin(); sit != sit_end; ++ sit) 
     92        { 
     93                SceneEntity *ent = *sit; 
     94                Texture *t = ent->GetMaterial()->GetTexture(); 
     95                int tsize = t ? t->GetByteSize() : 0; 
     96                Debug << tsize << " "; 
     97        } 
     98 
     99        // show ordering by material 
     100        Debug << "\nmaterial ptr: " << endl; 
    75101         
     102        for (sit = mEntities.begin(); sit != sit_end; ++ sit) 
     103        { 
     104                Debug << (*sit)->GetMaterial() << " "; 
     105        } 
     106} 
     107 
     108 
     109void RenderQueue::Apply() 
     110{ 
     111        Render(); 
     112        Clear(); 
     113} 
     114 
    76115 
    77116void RenderQueue::Sort() 
    78117{ 
    79         sort(mEntities.begin(), mEntities.end(), IsLower); 
     118        // sort by material 
     119        sort(mEntities.begin(), mEntities.end(), IsLower2); 
     120        // sort by texture size 
     121        stable_sort(mEntities.begin(), mEntities.end(), IsLower); 
    80122} 
    81123 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderQueue.h

    r2793 r2795  
    33 
    44#include "common.h" 
     5#include "Timer/PerfTimer.h" 
     6 
    57 
    68namespace CHCDemoEngine  
     
    3840        */ 
    3941        int GetSize() const { return (int)mEntities.size(); } 
     42        /** Renders and clears the queue. 
     43        */ 
     44        void Apply(); 
     45        /** Prints the ordering in the render queue. 
     46        */ 
     47        void Print(); 
     48 
     49        PerfTimer sortTimer; 
     50 
    4051 
    4152protected: 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderTraverser.cpp

    r2792 r2795  
    130130void RenderTraverser::RenderScene() 
    131131{ 
    132         //glFinish(); 
    133132        PerfTimer timer; 
     133         
    134134        timer.Start(); 
    135135 
     
    152152        Traverse(); 
    153153 
     154        // render the contents of the render queue 
     155        if (mUseRenderQueue) ApplyRenderQueue(); 
    154156        mRenderState->Reset(); 
    155157 
     
    157159        glDisableClientState(GL_NORMAL_ARRAY); 
    158160 
    159         //glFinish(); 
    160161        mStats.mRenderTime = timer.Elapsedms(); 
     162         
     163        //if (mUseRenderQueue) Debug << "rq sort: " << 1e3f * mRenderQueue.sortTimer.TotalTime() << " ms" << endl; 
    161164} 
    162165 
     
    178181{ 
    179182        mUseOptimization = useOptimization; 
    180         //cout << "using optimization: " << mUseOptimization << endl; 
     183        cout << "using optimization: " << mUseOptimization << endl; 
    181184} 
    182185 
     
    229232        ++ mStats.mNumIssuedQueries; 
    230233 
     234        // render pending objects before changing to query mode 
    231235        if (mUseRenderQueue && (mRenderState->GetMode() == RenderState::RENDER)) 
    232         { 
    233                 //Debug << "render queue: " << mRenderQueue.GetSize() << endl; 
    234                 mRenderQueue.Render(); 
    235                 mRenderQueue.Clear(); 
    236         } 
     236                ApplyRenderQueue(); 
     237         
    237238 
    238239        query.BeginQuery(); 
     
    248249 
    249250 
    250 } 
     251void RenderTraverser::ApplyRenderQueue() 
     252{ 
     253        if (mRenderState->SetState(RenderState::RENDER)) 
     254                ++ mStats.mNumStateChanges; 
     255                  
     256        mRenderQueue.Apply(); 
     257} 
     258 
     259 
     260} 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderTraverser.h

    r2792 r2795  
    118118        void SetShowBounds(bool showBounds); 
    119119 
     120         
    120121protected: 
    121122 
     
    142143        */ 
    143144        void RenderNode(BvhNode *node); 
     145        /** Renders and clears the contents of the render queue. 
     146        */ 
     147        void ApplyRenderQueue(); 
    144148 
    145149 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ResourceManager.cpp

    r2793 r2795  
    1 #include "BinaryLoader.h" 
     1#include "ResourceManager.h" 
    22#include "Matrix4x4.h" 
    33#include "Geometry.h" 
     
    55#include "Material.h" 
    66#include "Texture.h" 
    7 //#include "gzstream.h" 
     7#include "gzstream.h" 
    88 
    99 
     
    1515 
    1616 
    17 BinaryLoader::~BinaryLoader() 
    18 { 
    19         /** delete all maps. 
    20         */ 
    21         std::map<int, Texture *>::iterator it, it_end = mTextureTable.end(); 
    22  
    23         for (it = mTextureTable.begin(); it != it_end; ++ it) 
    24         { 
    25                 Texture *tex = (*it).second; 
    26                 delete tex; 
    27         } 
    28  
    29         std::map<int, Material *>::iterator nit, nit_end = mMaterialTable.end(); 
    30  
    31         for (nit = mMaterialTable.begin(); nit != nit_end; ++ nit) 
    32         { 
    33                 Material *mat = (*nit).second; 
    34                 delete mat; 
    35         } 
    36  
    37          
    38         std::map<int, Geometry *>::iterator git, git_end = mGeometryTable.end(); 
    39  
    40         for (git = mGeometryTable.begin(); git != git_end; ++git) 
    41         { 
    42                 Geometry *geom = (*git).second; 
    43                 delete geom; 
    44         } 
    45 } 
    46  
    47 //SceneEntity *BinaryLoader::LoadSceneEntity(igzstream &str) 
    48 SceneEntity *BinaryLoader::LoadSceneEntity(ifstream &str) 
     17ResourceManager::~ResourceManager() 
     18{ 
     19        // delete all resources. 
     20        CLEAR_CONTAINER(mSceneEntities); 
     21        CLEAR_CONTAINER(mGeometry); 
     22        CLEAR_CONTAINER(mMaterials); 
     23        CLEAR_CONTAINER(mTextures); 
     24        CLEAR_CONTAINER(mTrafos); 
     25} 
     26 
     27 
     28SceneEntity *ResourceManager::LoadSceneEntity(igzstream &str) 
    4929{        
    5030        // shape 
     
    6949                trafo = new Matrix4x4(); 
    7050                str.read(reinterpret_cast<char *>(trafo->x), sizeof(Matrix4x4)); 
     51                mTrafos.push_back(trafo); 
    7152        } 
    7253 
     
    7758 
    7859 
    79 void BinaryLoader::LoadTextures(ifstream &str) 
     60void ResourceManager::LoadTextures(igzstream &str) 
    8061{ 
    8162        int numTextures; 
     
    9778 
    9879                mTextureTable[i] = tex; 
     80                mTextures.push_back(tex); 
    9981        } 
    10082 
     
    10385 
    10486 
    105 void BinaryLoader::LoadShapes(ifstream &str) 
     87void ResourceManager::LoadShapes(igzstream &str) 
    10688{ 
    10789        int numShapes; 
     
    11597                mGeometryTable[i] = geom; 
    11698                mMaterialTable[i] = mat; 
     99 
     100                mGeometry.push_back(geom); 
     101                mMaterials.push_back(mat); 
    117102        } 
    118103 
     
    121106 
    122107 
    123 //Appearance *BinaryLoader::LoadMaterial(igzstream &str) 
    124 Material *BinaryLoader::LoadMaterial(ifstream &str) 
     108Material *ResourceManager::LoadMaterial(igzstream &str) 
    125109{ 
    126110        // default material 
     
    145129                str.read(reinterpret_cast<char *>(&mat->mAmbientColor), sizeof(Vector3)); 
    146130                str.read(reinterpret_cast<char *>(&mat->mDiffuseColor), sizeof(Vector3)); 
     131                str.read(reinterpret_cast<char *>(&mat->mEmmisiveColor), sizeof(Vector3)); 
    147132                str.read(reinterpret_cast<char *>(&mat->mSpecularColor), sizeof(Vector3)); 
    148133        } 
     
    152137 
    153138 
    154 //Geometry *BinaryLoader::LoadGeometry(igzstream &str) 
    155 Geometry *BinaryLoader::LoadGeometry(ifstream &str) 
     139Geometry *ResourceManager::LoadGeometry(igzstream &str) 
    156140{ 
    157141        Vector3 *vertices; 
     
    183167        if (texCoordCount) 
    184168        { 
    185                 //cout << "loading texcoords of size " << texCoordCount << endl; 
    186169                texcoords = new float[texCoordCount * 2]; 
    187170                str.read(reinterpret_cast<char *>(texcoords), sizeof(float) * vertexCount * 2); 
     
    194177 
    195178 
    196 void BinaryLoader::LoadSceneEntities(ifstream &str, SceneEntityContainer &entities) 
     179void ResourceManager::LoadSceneEntities(igzstream &str, SceneEntityContainer &entities) 
    197180{ 
    198181        int entityCount; 
     
    205188                SceneEntity *ent = LoadSceneEntity(str); 
    206189                entities[i] = ent; 
     190                mSceneEntities.push_back(ent); 
    207191        } 
    208192 
     
    211195 
    212196 
    213 bool BinaryLoader::Load(const std::string &filename, SceneEntityContainer &entities) 
    214 { 
    215         //clear_textures(); // clear the texture table 
    216  
    217         //igzstream str(filename.c_str());//, ios::binary); 
    218         ifstream istr(filename.c_str(), ios::binary); 
     197bool ResourceManager::Load(const std::string &filename, SceneEntityContainer &entities) 
     198{ 
     199        igzstream istr(filename.c_str()); 
    219200         
    220201        if (!istr.is_open()) 
     
    236217        cout << "bin loading finished" << endl; 
    237218 
     219        // clean up 
     220        mTextureTable.clear(); 
     221        mGeometryTable.clear(); 
     222        mMaterialTable.clear(); 
     223 
    238224        return true; 
    239225} 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ResourceManager.h

    r2782 r2795  
    1 #ifndef __BinaryLoader_H__ 
    2 #define __BinaryLoader_H__ 
     1#ifndef __ResourceManager_H__ 
     2#define __ResourceManager_H__ 
    33 
    4 // note use forward declaration instead 
     4 
    55#include <string> 
    66#include <iostream> 
     
    1010#include "common.h" 
    1111 
     12class igzstream; 
     13 
    1214 
    1315namespace CHCDemoEngine 
    1416{ 
    1517 
    16 class igzstream; 
    1718class SceneEntity; 
    1819class Material; 
    1920class Geometry; 
    2021class Texture; 
     22class Matrix4x4; 
    2123 
    22  
    23 class BinaryLoader 
     24/** Loads a scene and also handles the cleanup 
     25*/ 
     26class ResourceManager 
    2427{ 
    2528public: 
    2629 
    27         ~BinaryLoader(); 
    28  
     30        ~ResourceManager(); 
     31        /** Loads a model 
     32        */ 
    2933        bool Load(const std::string &filename, SceneEntityContainer &geometry); 
    3034 
    3135protected: 
    3236         
    33         void LoadTextures(std::ifstream &str); 
    34         void LoadShapes(std::ifstream &str); 
    35         void LoadSceneEntities(std::ifstream &str, SceneEntityContainer &entities); 
     37        void LoadTextures(igzstream &str); 
     38        void LoadShapes(igzstream &str); 
     39        void LoadSceneEntities(igzstream &str, SceneEntityContainer &entities); 
    3640 
    37         SceneEntity *LoadSceneEntity(std::ifstream &str); 
    38         Material *LoadMaterial(std::ifstream &str); 
    39         Geometry *LoadGeometry(std::ifstream &str); 
     41        SceneEntity *LoadSceneEntity(igzstream &str); 
     42        Material *LoadMaterial(igzstream &str); 
     43        Geometry *LoadGeometry(igzstream &str); 
    4044 
    4145        std::map<int, Texture *> mTextureTable; 
    4246        std::map<int, Material *> mMaterialTable; 
    4347        std::map<int, Geometry *> mGeometryTable; 
     48 
     49        // these are kept to be able to delete these resources afterwards 
     50        std::vector<Texture *> mTextures; 
     51        std::vector<Material *> mMaterials; 
     52        std::vector<Geometry *> mGeometry; 
     53        std::vector<SceneEntity *> mSceneEntities; 
     54        std::vector<Matrix4x4 *> mTrafos; 
    4455}; 
    4556 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneEntity.cpp

    r2792 r2795  
    2020SceneEntity::~SceneEntity() 
    2121{ 
    22         // delete only trafo here, the other members could be shared 
    23         // among several entities and are therefore handled separately 
    24         DEL_PTR(mTransform); 
    2522} 
    2623 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneEntity.h

    r2793 r2795  
    5959        Geometry *mGeometry; 
    6060        Material *mMaterial; 
    61  
    62         //AxisAlignedBox3 mBoundingBox; 
    6361         
    6462        int mLastRendered; 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/StopAndWaitTraverser.cpp

    r2792 r2795  
    2222                mDistanceQueue.pop(); 
    2323         
    24                 // interesting for the visualization 
    25                 node->SetVisible(false); 
    26  
    27  
    2824                if (mBvh->IsWithinViewFrustum(node)) 
    2925                { 
     
    3733                                OcclusionQuery *query = IssueOcclusionQuery(node); 
    3834 
    39                                 int visiblePixels = query->GetQueryResult(); 
     35                                bool visible = query->GetQueryResult() > mVisibilityThreshold; 
    4036 
    41                                 if (visiblePixels > mVisibilityThreshold) 
     37                                if (visible) 
    4238                                { 
    43                                         //cout<< "visible: " << visiblePixels << endl; 
    44                                         // update node's visited flag => needed for rendering 
    45                                         // so set it also here 
    46                                         //node->SetLastVisited(mFrameID); 
    47                                         //node->SetVisible(true); 
    48                                  
    4939                                        TraverseNode(node); 
    5040                                } 
    5141                                else 
    5242                                { 
     43                                        node->SetVisible(false); 
    5344                                        ++ mStats.mNumQueryCulledNodes; 
    5445                                } 
     46                                 
     47                                // update node's visited flag (could be interesting for the visualization) 
     48                                node->SetVisible(visible);               
    5549                        } 
    5650                } 
     
    6054                }        
    6155        } 
    62  
    63         /// Empty render queue. 
    64         if (mUseRenderQueue) 
    65         { 
    66                 mRenderQueue.Render(); 
    67                 mRenderQueue.Clear(); 
    68         } 
    6956} 
    7057 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp

    r2794 r2795  
    99#include "Vector3.h" 
    1010#include "Matrix4x4.h" 
    11 #include "BinaryLoader.h" 
     11#include "ResourceManager.h" 
    1212#include "Bvh.h" 
    1313#include "Camera.h" 
     
    2020#include "Visualization.h" 
    2121#include "RenderState.h" 
    22  
     22#include "Timer/PerfTimer.h" 
    2323 
    2424 
     
    3535Bvh *bvh = NULL; 
    3636/// handles scene loading 
    37 BinaryLoader *loader = NULL; 
     37ResourceManager *loader = NULL; 
    3838/// the scene camera 
    3939Camera *camera = NULL; 
     40/// the scene camera 
     41Camera *visCamera = NULL; 
    4042/// the visualization 
    4143Visualization *visualization = NULL; 
     
    4345RenderState state; 
    4446/// the rendering algorithm 
    45 int renderMode = RenderTraverser::CULL_FRUSTUM; 
     47int renderMode = RenderTraverser::CHCPLUSPLUS; 
    4648// eye near plane distance 
    4749float nearDist = 0.1f;  
     
    4951int threshold; 
    5052 
     53float fov = 50.0f; 
     54 
    5155int assumedVisibleFrames = 10; 
    5256int maxBatchSize = 50; 
    5357 
    54 const float keyForwardMotion = 0.5f; 
    55 const float keyRotation = 0.05f; 
     58int trianglesPerVirtualLeaf = 1000; 
     59 
     60/// these values get scaled with the frame rate 
     61const float keyForwardMotion = 50.0f; 
     62const float keyRotation = 2.0f; 
     63/// elapsed time in seconds 
     64double elapsedTime = 1.0f; 
    5665 
    5766int winWidth = 1024; 
     
    8493bool useOptimization = false; 
    8594bool useTightBounds = true; 
    86 bool useRenderQueue = false; 
     95bool useRenderQueue = true; 
    8796bool useMultiQueries = true; 
    8897 
     98/// the accumulated z axis rotation 
    8999float rotation = 0; 
    90100 
    91101Matrix4x4 visView = IdentityMatrix(); 
     102 
     103SceneEntityContainer skyGeometry; 
    92104 
    93105bool leftKeyPressed = false; 
     
    129141void KeyHorizontalMotion(float shift); 
    130142void KeyVerticalMotion(float shift); 
    131 void KeyRotate(float angle); 
     143 
     144 
     145inline float KeyRotationAngle() { return keyRotation * elapsedTime; } 
     146inline float KeyShift() { return keyForwardMotion * elapsedTime; } 
    132147 
    133148 
     
    137152        int returnCode = 0; 
    138153 
    139 #ifdef _CRT_SET 
    140  
    141         //Now just call this function at the start of your program and if you're 
    142         //compiling in debug mode (F5), any leaks will be displayed in the Output 
    143         //window when the program shuts down. If you're not in debug mode this will 
    144         //be ignored. Use it as you will! 
    145         //note: from GDNet Direct [3.8.04 - 3.14.04] void detectMemoryLeaks() { 
    146  
    147         _CrtSetDbgFlag(_CRTDBG_LEAK_CHECK_DF|_CRTDBG_ALLOC_MEM_DF); 
    148         _CrtSetReportMode(_CRT_ASSERT,_CRTDBG_MODE_FILE); 
    149         _CrtSetReportFile(_CRT_ASSERT,_CRTDBG_FILE_STDERR);  
    150 #endif 
    151  
    152  
    153         camera = new Camera(winWidth, winHeight, 60); 
     154        camera = new Camera(winWidth, winHeight, fov); 
    154155        camera->SetNear(nearDist); 
     156 
     157        visCamera = new Camera(winWidth, winHeight, fov); 
     158        visCamera->SetNear(nearDist); 
    155159 
    156160        glutInitWindowSize(winWidth, winHeight); 
     
    158162        glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH); 
    159163 
    160         glutCreateWindow("Coherent Hierarchical Culling"); 
     164        glutCreateWindow("FriendlyCulling"); 
    161165 
    162166        glutDisplayFunc(Display); 
     
    177181 
    178182 
    179         loader = new BinaryLoader(); 
     183        loader = new ResourceManager(); 
    180184 
    181185        //const string filename("data/city/model/city.dem"); 
     
    190194                exit(0); 
    191195        } 
     196 
     197        SceneEntityContainer dummy; 
     198 
     199        const string envname = string(model_path + "env.dem"); 
     200 
     201        if (loader->Load(envname, skyGeometry)) 
     202                cout << "sky box " << filename << " loaded" << endl; 
     203        else 
     204        { 
     205                cerr << "loading sky box " << filename << " failed" << endl; 
     206                CleanUp(); 
     207                exit(0); 
     208        } 
     209 
    192210 
    193211        const string bvh_filename = string(model_path + "city.bvh"); 
     
    206224        ResetTraverser(); 
    207225 
    208         camera->SetDirection(Vector3(0.961829f, 0.273652f, 0.0f)); 
     226        //camera->SetDirection(Vector3(0.961829f, 0.273652f, 0.0f)); 
     227        camera->Pitch(-M_PI * 0.5); 
    209228        camera->SetPosition(Vector3(483.398f, 242.364f, 186.078f)); 
    210229 
     
    265284                "", 
    266285                "'F1'           - shows/dismisses this message", 
    267                 "'F2'           - shows/hides statistics", 
     286                "'F2'           - shows/hides bird eye view", 
    268287                "'F3'           - shows/hides bounds (boxes or tight bounds)", 
    269                 "'F4'           - shows/hides bird eye view", 
    270                 "'f5',          - load helpScreen", 
     288                "'F4'           - shows/hides statistics", 
     289                "'F5',          - shows/hides parameters", 
    271290                "'SPACE'        - cycles through occlusion culling algorithms", 
    272291                "", 
     
    281300                "'-'            - decreases max batch size", 
    282301                "'+'            - increases max batch size", 
     302                "'4'            - decrease triangles per virtual leaf (sets depth of bvh)", 
     303                "'5'            - increase triangles per virtual leaf (sets depth of bvh)", 
    283304                "'6'            - decrease assumed visible frames", 
    284305                "'7'            - increase assumed visible frames", 
    285                 "'8'            - upward motion", 
    286                 "'9'            - downward motion", 
     306                "'8'            - downward motion", 
     307                "'9'            - upward motion", 
    287308                "", 
    288309                "'R'            - use render queue", 
     
    405426} 
    406427 
    407 void SetupEyeView(void) 
     428void SetupEyeView() 
    408429{ 
    409430        glMatrixMode(GL_PROJECTION); 
    410431        glLoadIdentity(); 
    411432 
    412         gluPerspective(60.0f, 1.0f / winAspectRatio, nearDist, 2.0f * Magnitude(bvh->GetBox().Diagonal())); 
     433        gluPerspective(fov, 1.0f / winAspectRatio, nearDist, 10.0f * Magnitude(bvh->GetBox().Diagonal())); 
    413434 
    414435        glMatrixMode(GL_MODELVIEW); 
     436        glLoadIdentity(); 
    415437        camera->SetupCameraView(); 
    416438 
     
    423445 
    424446 
    425 void KeyRotate(float angle) 
    426 { 
    427         Vector3 viewDir = camera->GetDirection(); 
    428         // rotate view vector 
    429         Matrix4x4 rot = RotationZMatrix(angle); 
    430         viewDir = rot * viewDir; 
    431         camera->SetDirection(viewDir); 
    432 } 
    433  
    434  
    435447void KeyHorizontalMotion(float shift) 
    436448{ 
     
    459471void Display()  
    460472{ 
     473        PerfTimer frameTimer; 
     474 
     475        frameTimer.Start(); 
     476 
    461477        if (leftKeyPressed) 
    462                 KeyRotate(keyRotation); 
     478                camera->Pitch(KeyRotationAngle()); 
    463479        if (rightKeyPressed) 
    464                 KeyRotate(-keyRotation); 
     480                camera->Pitch(-KeyRotationAngle()); 
    465481        if (upKeyPressed) 
    466                 KeyHorizontalMotion(keyForwardMotion); 
     482                KeyHorizontalMotion(KeyShift()); 
    467483        if (downKeyPressed) 
    468                 KeyHorizontalMotion(-keyForwardMotion); 
     484                KeyHorizontalMotion(-KeyShift()); 
    469485        if (eightKeyPressed) 
    470                 KeyVerticalMotion(keyForwardMotion); 
     486                KeyVerticalMotion(-KeyShift()); 
    471487        if (nineKeyPressed) 
    472                 KeyVerticalMotion(-keyForwardMotion); 
     488                KeyVerticalMotion(KeyShift()); 
    473489 
    474490        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
     
    479495        // actually render the scene geometry using one of the specified algorithms 
    480496        traverser->RenderScene(); 
    481          
     497 
     498         
     499        glEnableClientState(GL_VERTEX_ARRAY); 
     500        glEnableClientState(GL_NORMAL_ARRAY); 
     501 
     502        SceneEntityContainer::const_iterator sit, sit_end = skyGeometry.end(); 
     503 
     504        for (sit = skyGeometry.begin(); sit != sit_end; ++ sit) 
     505                (*sit)->Render(&state); 
     506 
     507        glDisableClientState(GL_VERTEX_ARRAY); 
     508        glDisableClientState(GL_NORMAL_ARRAY); 
     509 
     510        state.Reset(); 
     511 
    482512        if (visMode) DisplayVisualization(); 
    483513         
     
    485515 
    486516        glutSwapBuffers(); 
     517 
     518        elapsedTime = frameTimer.Elapsed(); 
    487519} 
    488520 
     
    531563                { 
    532564                        eightKeyPressed = true; 
    533                         KeyVerticalMotion(keyForwardMotion); 
     565                        KeyVerticalMotion(-KeyShift()); 
    534566                        break; 
    535567                } 
     
    537569                { 
    538570                        nineKeyPressed = true; 
    539                         KeyVerticalMotion(-keyForwardMotion); 
     571                        KeyVerticalMotion(+KeyShift()); 
    540572                        break; 
    541573                }        
     
    549581                { 
    550582                        leftKeyPressed = true; 
    551                         KeyRotate(keyRotation); 
     583                        camera->Pitch(KeyRotationAngle()); 
    552584                } 
    553585                break; 
     
    556588        { 
    557589                        rightKeyPressed = true; 
    558                         KeyRotate(-keyRotation); 
     590                        camera->Pitch(-KeyRotationAngle()); 
    559591                } 
    560592                break; 
     
    563595                { 
    564596                        upKeyPressed = true; 
    565                         KeyHorizontalMotion(keyForwardMotion); 
     597                        KeyHorizontalMotion(KeyShift()); 
    566598                } 
    567599                break; 
     
    570602                { 
    571603                        downKeyPressed = true; 
    572                         KeyHorizontalMotion(-keyForwardMotion); 
     604                        KeyHorizontalMotion(-KeyShift()); 
    573605                } 
    574606                break; 
     
    587619                } 
    588620                break; 
    589  
    590  
    591  
     621        case '4': 
     622                if (trianglesPerVirtualLeaf >= 100) 
     623                        trianglesPerVirtualLeaf -= 100; 
     624 
     625                bvh->SetVirtualLeaves(trianglesPerVirtualLeaf); 
     626                break; 
     627        case '5': 
     628                trianglesPerVirtualLeaf += 100; 
     629                bvh->SetVirtualLeaves(trianglesPerVirtualLeaf); 
     630                break; 
    592631        default: 
    593632                return; 
     
    658697void Special(int c, int x, int y)  
    659698{ 
    660         // used to avoid vertical motion with the keys 
    661         Vector3 hvec = Vector3(camera->GetDirection()[0], camera->GetDirection()[1], 0.0f); 
    662          
    663699        switch(c)  
    664700        { 
     
    667703                break; 
    668704        case GLUT_KEY_F2: 
    669                 showStatistics = !showStatistics; 
     705                visMode = !visMode; 
    670706                break; 
    671707        case GLUT_KEY_F3: 
     
    674710                break; 
    675711        case GLUT_KEY_F4: 
    676                 visMode = !visMode; 
     712                showStatistics = !showStatistics; 
    677713                break; 
    678714        case GLUT_KEY_F5: 
     
    682718                { 
    683719                        leftKeyPressed = true; 
    684                         KeyRotate(keyRotation); 
     720                        camera->Pitch(KeyRotationAngle()); 
    685721                } 
    686722                break; 
     
    688724                { 
    689725                        rightKeyPressed = true; 
    690                         KeyRotate(-keyRotation); 
     726                        camera->Pitch(-KeyRotationAngle()); 
    691727                } 
    692728                break; 
     
    694730                { 
    695731                        upKeyPressed = true; 
    696                         KeyHorizontalMotion(keyForwardMotion); 
     732                        KeyHorizontalMotion(KeyShift()); 
    697733                } 
    698734                break; 
     
    700736                { 
    701737                        downKeyPressed = true; 
    702                         KeyHorizontalMotion(-keyForwardMotion); 
     738                        KeyHorizontalMotion(-KeyShift()); 
    703739                } 
    704740                break; 
     
    728764        glLoadIdentity(); 
    729765 
    730         gluPerspective(60.0f, 1.0f / winAspectRatio, nearDist, 2.0f * Magnitude(bvh->GetBox().Diagonal())); 
     766        gluPerspective(fov, 1.0f / winAspectRatio, nearDist, 2.0f * Magnitude(bvh->GetBox().Diagonal())); 
    731767 
    732768        glMatrixMode(GL_MODELVIEW); 
     
    768804void LeftMotion(int x, int y)  
    769805{ 
    770         static float eyeXAngle = 0.0f; 
    771  
    772806        Vector3 viewDir = camera->GetDirection(); 
    773807        Vector3 pos = camera->GetPosition(); 
     
    776810        Vector3 horView(viewDir[0], viewDir[1], 0); 
    777811         
    778         eyeXAngle = 0.2f *  M_PI * (xEyeBegin - x) / 180.0; 
    779  
    780         rotation += eyeXAngle; 
    781  
    782         // rotate view vector 
    783         Matrix4x4 rot = RotationZMatrix(eyeXAngle); 
    784         viewDir = rot * viewDir; 
     812        float eyeXAngle = 0.2f *  M_PI * (xEyeBegin - x) / 180.0; 
     813 
     814        camera->Pitch(eyeXAngle); 
    785815 
    786816        pos += horView * (yMotionBegin - y) * 0.2f; 
    787  
    788         camera->SetDirection(viewDir); 
     817         
    789818        camera->SetPosition(pos); 
    790819         
     
    801830void RightMotion(int x, int y)  
    802831{ 
    803         static float eyeYAngle = 0.0f; 
    804  
    805         Vector3 viewDir = camera->GetDirection(); 
    806         Vector3 right = camera->GetRightVector(); 
    807  
    808         eyeYAngle = -0.2f *  M_PI * (yEyeBegin - y) / 180.0; 
    809  
    810         // rotate view vector 
    811         Matrix4x4 rot = RotationAxisMatrix(right, eyeYAngle); 
    812         viewDir = rot * viewDir; 
    813  
    814         camera->SetDirection(viewDir); 
    815                  
     832        float eyeYAngle = -0.2f *  M_PI * (yEyeBegin - y) / 180.0; 
     833 
     834        camera->Yaw(eyeYAngle); 
     835 
    816836        yEyeBegin = y; 
    817          
    818837        glutPostRedisplay(); 
    819838} 
     
    907926// displays the visualisation of culling algorithm 
    908927void DisplayVisualization() 
    909 { 
     928{cout<<"here34"<<endl; 
    910929        SetupVisView(); 
    911930 
     
    923942        glViewport(winWidth - winWidth / 4, winHeight - winHeight / 3, winWidth, winHeight); 
    924943 
    925  
    926944        glMatrixMode(GL_PROJECTION); 
    927945        glLoadIdentity(); 
    928946         
    929         //gluPerspective(60.0f, 1.0f / winAspectRatio, nearDist, 2.0f * Magnitude(bvh->GetBox().Diagonal())); 
     947        gluPerspective(fov, 1.0f / winAspectRatio, nearDist, 20.0f * Magnitude(bvh->GetBox().Diagonal())); 
     948         
    930949        AxisAlignedBox3 box = bvh->GetBox(); 
    931950        const float offs = 2000; 
    932         glOrtho(box.Min().y - offs, box.Max().y + offs, box.Min().y - offs, box.Max().y + offs, 0.1, 20.0f * Magnitude(bvh->GetBox().Diagonal()));  
    933          
    934          
    935         glPushMatrix(); 
    936  
     951         
     952        //glOrtho(box.Min().y - offs, box.Max().y + offs, box.Min().y - offs, box.Max().y + offs, 0.1, 20.0f * Magnitude(bvh->GetBox().Diagonal()));  
     953        //glOrtho(-offs, offs, offs, -offs, 0.1, 20.0f * Magnitude(bvh->GetBox().Diagonal()));  
     954        //glPushMatrix(); 
     955 
     956        Vector3 vizpos = Vector3(box.Center().x, box.Center().y, box.Max().z); 
     957        visCamera->SetPosition(vizpos); 
     958        visCamera->Yaw(-0.5 * M_PI); 
     959        cout<<"pos: " << visCamera->GetPosition()<<endl; 
    937960        glMatrixMode(GL_MODELVIEW); 
    938961        glLoadIdentity(); 
    939962 
    940         glMultMatrixf((float *)visView.x); 
     963        visCamera->SetupCameraView(); 
     964        //glMultMatrixf((float *)visView.x); 
    941965 
    942966        //SetupLighting(); 
     
    947971        glLightfv(GL_LIGHT1, GL_POSITION, position1); 
    948972 
    949  
    950  
    951973        glClear(GL_DEPTH_BUFFER_BIT); 
    952974 
     
    956978        visualization->Render(); 
    957979         
    958         glPopMatrix(); 
     980        //glPopMatrix(); 
    959981         
    960982        glViewport(0, 0, winWidth, winHeight); 
     
    9911013void CleanUp() 
    9921014{ 
    993         CLEAR_CONTAINER(sceneEntities); 
    9941015        DEL_PTR(traverser); 
    995  
    9961016        DEL_PTR(bvh); 
    9971017        DEL_PTR(visualization); 
    9981018        DEL_PTR(camera); 
    999  
    10001019        DEL_PTR(loader); 
    10011020} 
     
    10401059        char msg6[200]; 
    10411060        char msg7[200]; 
     1061        char msg8[200]; 
    10421062 
    10431063 
     
    10841104        sprintf_s(msg6, "issued queries: %5d, state changes: %5d", issuedQueries, stateChanges); 
    10851105 
     1106        sprintf_s(msg8, "triangles per virtual leaf: %5d", trianglesPerVirtualLeaf); 
     1107 
    10861108        sprintf_s(msg7, "fps: %6.1f", fps); 
    10871109 
     
    11111133                        Output(20, 150, msg2); 
    11121134                        Output(20, 180, msg3); 
     1135                        Output(20, 210, msg8); 
    11131136                } 
    11141137        } 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/common.h

    r2784 r2795  
    145145 
    146146 
     147// delete a pointer and set to NULL 
     148#ifndef DEL_ARRAY_PTR 
     149#define DEL_ARRAY_PTR(ptr) do {if (ptr) {           \ 
     150                                   delete [] (ptr); \ 
     151                                                           (ptr) = 0;}}     \ 
     152                           while (0) 
     153#endif 
     154 
     155 
    147156// Clears a container (i.e., a vector of pointers) and deletes the pointers 
    148157#ifndef CLEAR_CONTAINER 
Note: See TracChangeset for help on using the changeset viewer.