Show
Ignore:
Timestamp:
03/21/12 18:36:20 (2 years ago)
Author:
robert
Message:

Ran script to remove trailing spaces and tabs

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/include/osgParticle/ParticleSystem

    r12056 r13041  
    1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield  
     1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield 
    22 * 
    3  * This library is open source and may be redistributed and/or modified under   
    4  * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or  
     3 * This library is open source and may be redistributed and/or modified under 
     4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
    55 * (at your option) any later version.  The full license is in LICENSE file 
    66 * included with this distribution, and on the openscenegraph.org website. 
    7  *  
     7 * 
    88 * This library is distributed in the hope that it will be useful, 
    99 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
    10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the  
     10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    1111 * OpenSceneGraph Public License for more details. 
    1212*/ 
     
    5454    class OSGPARTICLE_EXPORT ParticleSystem: public osg::Drawable { 
    5555    public: 
    56      
     56 
    5757        enum Alignment { 
    5858            BILLBOARD, 
     
    6464 
    6565        META_Object(osgParticle, ParticleSystem); 
    66          
     66 
    6767        /// Get the alignment type of particles. 
    6868        inline Alignment getParticleAlignment() const; 
    69          
     69 
    7070        /// Set the alignment type of particles. 
    7171        inline void setParticleAlignment(Alignment a); 
    72          
     72 
    7373        /// Get the X-axis alignment vector. 
    7474        inline const osg::Vec3& getAlignVectorX() const; 
    75          
     75 
    7676        /// Set the X-axis alignment vector. 
    7777        inline void setAlignVectorX(const osg::Vec3& v); 
     
    7979        /// Get the Y-axis alignment vector. 
    8080        inline const osg::Vec3& getAlignVectorY() const; 
    81          
     81 
    8282        /// Set the Y-axis alignment vector. 
    8383        inline void setAlignVectorY(const osg::Vec3& v); 
    84          
     84 
    8585        /// Set the alignment vectors. 
    8686        inline void setAlignVectors(const osg::Vec3& X, const osg::Vec3& Y); 
     
    103103 
    104104        /// Get the default bounding box 
    105         inline const osg::BoundingBox& getDefaultBoundingBox() const;         
    106          
     105        inline const osg::BoundingBox& getDefaultBoundingBox() const; 
     106 
    107107        /**    Set the default bounding box. 
    108108            The default bounding box is used when a real bounding box cannot be computed, for example 
     
    113113        /// Return true if we use vertex arrays for rendering particles. 
    114114        bool getUseVertexArray() const { return _useVertexArray; } 
    115          
     115 
    116116        /** Set to use vertex arrays for rendering particles. 
    117117            Lots of variables will be omitted: particles' shape, alive or not, visibility distance, and so on, 
     
    121121        */ 
    122122        void setUseVertexArray(bool v) { _useVertexArray = v; } 
    123          
     123 
    124124        /// Return true if shaders are required. 
    125125        bool getUseShaders() const { return _useShaders; } 
    126          
     126 
    127127        /** Set to use GLSL shaders for rendering particles. 
    128128            Particles' parameters will be used as shader attribute arrays, and necessary variables, including 
     
    130130        */ 
    131131        void setUseShaders(bool v) { _useShaders = v; _dirty_uniforms = true; } 
    132          
     132 
    133133        /// Get the double pass rendering flag. 
    134134        inline bool getDoublePassRendering() const; 
    135          
     135 
    136136        /** Set the double pass rendering flag. 
    137137            Double pass rendering avoids overdraw problems between particle systems 
     
    142142        */ 
    143143        inline void setDoublePassRendering(bool v); 
    144          
     144 
    145145        /// Return true if the particle system is frozen. 
    146146        bool getFrozen() const { return _frozen; } 
    147147        inline bool isFrozen() const; 
    148          
     148 
    149149        /**    Set or reset the <I>frozen</I> state. 
    150150            When the particle system is frozen, emitters and programs won't do anything on it. 
     
    154154        /// Get the number of allocated particles (alive + dead). 
    155155        inline int numParticles() const; 
    156          
     156 
    157157        /// Get the number of dead particles. 
    158158        inline int numDeadParticles() const; 
    159159 
    160         /// Get whether all particles are dead         
     160        /// Get whether all particles are dead 
    161161        inline bool areAllParticlesDead() const { return numDeadParticles()==numParticles(); } 
    162          
     162 
    163163        /// Get a pointer to the i-th particle. 
    164164        inline Particle* getParticle(int i); 
    165          
     165 
    166166        /// Get a const pointer to the i-th particle. 
    167167        inline const Particle* getParticle(int i) const; 
    168          
     168 
    169169        /// Create a new particle from the specified template (or the default one if <CODE>ptemplate</CODE> is null). 
    170170        inline virtual Particle* createParticle(const Particle* ptemplate); 
    171          
     171 
    172172        /// Destroy the i-th particle. 
    173173        inline virtual void destroyParticle(int i); 
    174          
     174 
    175175        /// Reuse the i-th particle. 
    176176        inline virtual void reuseParticle(int i) { _deadparts.push(&(_particles[i])); } 
     
    178178        /// Get the last frame number. 
    179179        inline unsigned int getLastFrameNumber() const; 
    180          
     180 
    181181        /// Get the unique delta time for emitters and updaters to use 
    182182        inline double& getDeltaTime( double currentTime ); 
     
    184184        /// Get a reference to the default particle template. 
    185185        inline Particle& getDefaultParticleTemplate(); 
    186          
     186 
    187187        /// Get a const reference to the default particle template. 
    188188        inline const Particle& getDefaultParticleTemplate() const; 
     
    190190        /// Set the default particle template (particle is copied). 
    191191        inline void setDefaultParticleTemplate(const Particle& p); 
    192          
     192 
    193193        /// Get whether the particle system can freeze when culled 
    194194        inline bool getFreezeOnCull() const; 
    195          
     195 
    196196        /// Set whether the particle system can freeze when culled (default is true) 
    197197        inline void setFreezeOnCull(bool v); 
    198          
     198 
    199199        /** A useful method to set the most common <CODE>StateAttribute</CODE>'s in one call. 
    200200            If <CODE>texturefile</CODE> is empty, then texturing is turned off. 
    201201        */ 
    202202        void setDefaultAttributes(const std::string& texturefile = "", bool emissive_particles = true, bool lighting = false, int texture_unit = 0); 
    203          
     203 
    204204        /** A useful method to set the most common <CODE>StateAttribute</CODE> and use GLSL shaders to draw particles. 
    205205            At present, when enabling shaders in the particle system, user-defined shapes will not be usable. 
     
    207207        */ 
    208208        void setDefaultAttributesUsingShaders(const std::string& texturefile = "", bool emissive_particles = true, int texture_unit = 0); 
    209          
     209 
    210210        /// (<B>EXPERIMENTAL</B>) Get the level of detail. 
    211211        inline int getLevelOfDetail() const; 
    212          
     212 
    213213        /** (<B>EXPERIMENTAL</B>) Set the level of detail. The total number of particles is divided by the detail value to 
    214214            get the actual number of particles to be drawn. This value must be greater than zero. 
    215215        */ 
    216216        inline void setLevelOfDetail(int v); 
    217          
     217 
    218218        enum SortMode 
    219219        { 
     
    222222            SORT_BACK_TO_FRONT 
    223223        }; 
    224          
     224 
    225225        /// Get the sort mode. 
    226226        inline SortMode getSortMode() const; 
    227          
     227 
    228228        /** Set the sort mode. It will force resorting the particle list by the Z direction of the view coordinates. 
    229229            This can be used for the purpose of transparent rendering or <CODE>setVisibilityDistance()</CODE>. 
    230230        */ 
    231231        inline void setSortMode(SortMode mode); 
    232          
     232 
    233233        /// Get the visibility distance. 
    234234        inline double getVisibilityDistance() const; 
    235          
     235 
    236236        /** Set the visibility distance which allows the particles to be rendered only when depth is inside the distance. 
    237237            When using shaders, it can work well directly; otherwise the sort mode should also be set to pre-compute depth. 
     
    245245 
    246246        virtual osg::BoundingBox computeBound() const; 
    247          
     247 
    248248#ifdef OSGPARTICLE_USE_ReadWriteMutex 
    249249        typedef OpenThreads::ReadWriteMutex ReadWriterMutex; 
     
    273273        Particle_vector _particles; 
    274274        Death_stack _deadparts; 
    275          
     275 
    276276        osg::BoundingBox _def_bbox; 
    277          
     277 
    278278        Alignment _alignment; 
    279279        osg::Vec3 _align_X_axis; 
    280280        osg::Vec3 _align_Y_axis; 
    281281        ParticleScaleReferenceFrame _particleScaleReferenceFrame; 
    282          
     282 
    283283        bool _useVertexArray; 
    284284        bool _useShaders; 
    285285        bool _dirty_uniforms; 
    286          
     286 
    287287        bool _doublepass; 
    288288        bool _frozen; 
     
    298298        mutable bool _dirty_dt; 
    299299        bool _freeze_on_cull; 
    300          
     300 
    301301        double _t0; 
    302302        double _dt; 
    303          
     303 
    304304        int _detail; 
    305305        SortMode _sortMode; 
    306306        double _visibilityDistance; 
    307          
     307 
    308308        mutable int _draw_count; 
    309          
     309 
    310310        mutable ReadWriterMutex _readWriteMutex; 
    311311    }; 
    312      
     312 
    313313    // INLINE FUNCTIONS 
    314      
     314 
    315315    inline ParticleSystem::Alignment ParticleSystem::getParticleAlignment() const 
    316316    { 
    317317        return _alignment; 
    318318    } 
    319      
     319 
    320320    inline void ParticleSystem::setParticleAlignment(Alignment a) 
    321321    { 
    322322        _alignment = a; 
    323323    } 
    324      
     324 
    325325    inline const osg::Vec3& ParticleSystem::getAlignVectorX() const 
    326326    { 
    327327        return _align_X_axis; 
    328328    } 
    329      
     329 
    330330    inline void ParticleSystem::setAlignVectorX(const osg::Vec3& v) 
    331331    { 
     
    337337        return _align_Y_axis; 
    338338    } 
    339      
     339 
    340340    inline void ParticleSystem::setAlignVectorY(const osg::Vec3& v) 
    341341    { 
    342342        _align_Y_axis = v; 
    343343    } 
    344      
     344 
    345345    inline void ParticleSystem::setAlignVectors(const osg::Vec3& X, const osg::Vec3& Y) 
    346346    { 
     
    353353        return _frozen; 
    354354    } 
    355      
     355 
    356356    inline void ParticleSystem::setFrozen(bool v) 
    357357    { 
    358358        _frozen = v; 
    359359    } 
    360      
     360 
    361361    inline const osg::BoundingBox& ParticleSystem::getDefaultBoundingBox() const 
    362362    { 
    363363        return _def_bbox; 
    364364    } 
    365      
     365 
    366366    inline void ParticleSystem::setDefaultBoundingBox(const osg::BoundingBox& bbox) 
    367367    { 
     
    403403        _particles[i].kill(); 
    404404    } 
    405      
     405 
    406406    inline unsigned int ParticleSystem::getLastFrameNumber() const 
    407407    { 
    408408        return _last_frame; 
    409409    } 
    410      
     410 
    411411    inline double& ParticleSystem::getDeltaTime( double currentTime ) 
    412412    { 
     
    415415            _dt = currentTime - _t0; 
    416416            if ( _dt<0.0 ) _dt = 0.0; 
    417              
     417 
    418418            _t0 = currentTime; 
    419419            _dirty_dt = false; 
     
    436436            if (p.z() + r > _bmax.z()) _bmax.z() = p.z() + r; 
    437437        } 
    438         if (!_bounds_computed)  
     438        if (!_bounds_computed) 
    439439            _bounds_computed = true; 
    440440    } 
     
    454454        _def_ptemp = p; 
    455455    } 
    456      
     456 
    457457    inline bool ParticleSystem::getFreezeOnCull() const 
    458458    { 
    459459        return _freeze_on_cull; 
    460460    } 
    461      
     461 
    462462    inline void ParticleSystem::setFreezeOnCull(bool v) 
    463463    { 
    464464        _freeze_on_cull = v; 
    465465    } 
    466      
     466 
    467467    inline int ParticleSystem::getLevelOfDetail() const 
    468468    { 
    469469        return _detail; 
    470470    } 
    471      
     471 
    472472    inline void ParticleSystem::setLevelOfDetail(int v) 
    473473    { 
     
    475475        _detail = v; 
    476476    } 
    477      
     477 
    478478    inline ParticleSystem::SortMode ParticleSystem::getSortMode() const 
    479479    { 
    480480        return _sortMode; 
    481481    } 
    482      
     482 
    483483    inline void ParticleSystem::setSortMode(SortMode mode) 
    484484    { 
    485485        _sortMode = mode; 
    486486    } 
    487      
     487 
    488488    inline double ParticleSystem::getVisibilityDistance() const 
    489489    { 
    490490        return _visibilityDistance; 
    491491    } 
    492      
     492 
    493493    inline void ParticleSystem::setVisibilityDistance(double distance) 
    494494    { 
     
    496496        if (_useShaders) _dirty_uniforms = true; 
    497497    } 
    498      
    499     // I'm not sure this function should be inlined...  
    500      
     498 
     499    // I'm not sure this function should be inlined... 
     500 
    501501    inline Particle* ParticleSystem::createParticle(const Particle* ptemplate) 
    502502    {