Ignore:
Timestamp:
06/26/06 09:52:08 (18 years ago)
Author:
szirmay
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/OgreSharedRuns.cpp

    r949 r1055  
    11#include "..\include\OgreSharedRuns.h" 
    22#include "OgreIlluminationManager.h" 
     3 
     4void OgreSharedRuns::runChanged(RenderingRunType runType, RenderingRun* run) 
     5{ 
     6        if(child1 != 0) child1->runChanged(runType, run); 
     7        if(child2 != 0) child2->runChanged(runType, run); 
     8         
     9        std::vector<TechniqueGroup*>::iterator it = childTechniqueGroups.begin(); 
     10        std::vector<TechniqueGroup*>::iterator itend = childTechniqueGroups.end(); 
     11 
     12        while(it != itend) 
     13        { 
     14                (*it)->runChanged(runType, run); 
     15                it++; 
     16        } 
     17} 
     18 
     19void OgreSharedRuns::runUpdated(RenderingRunType runType, RenderingRun* run) 
     20{ 
     21        if(child1 != 0) child1->runUpdated(runType, run); 
     22        if(child2 != 0) child2->runUpdated(runType, run); 
     23         
     24 
     25        std::vector<TechniqueGroup*>::iterator it = childTechniqueGroups.begin(); 
     26        std::vector<TechniqueGroup*>::iterator itend = childTechniqueGroups.end(); 
     27 
     28        while(it != itend) 
     29        { 
     30                (*it)->runUpdated(runType, run); 
     31                it++; 
     32        } 
     33} 
    334 
    435RenderingRun* OgreSharedRuns::getRun(RenderingRunType runType) 
     
    108139        { 
    109140                runChanged( (*it).first, (*it).second ); 
    110                 runChanged( (*it).first, (*it).second ); 
    111141                it++; 
    112142        } 
     
    135165} 
    136166 
    137 bool OgreSharedRuns::haveCommonRuns(SharedRuns* r1, SharedRuns* r2) 
     167bool OgreSharedRuns::haveCommonRuns(SharedRuns* r1, SharedRuns* r2, std::vector<RenderingRunType>& commonruns) 
    138168{ 
    139169        OgreSharedRuns* run1 = (OgreSharedRuns*) r1; 
     
    143173        std::map<RenderingRunType, RenderingRun*>::iterator itend = run1->sharedRuns.end(); 
    144174 
     175        bool returnvalue = false; 
    145176        while(it != itend) 
    146177        { 
    147178                if( run2->hasOwnRun((*it).first)) 
    148                         return true; 
    149                 it++; 
    150         } 
    151  
    152         return false; 
     179                { 
     180                        if(                      run1->getRun((*it).first)->asOgreRenderingRun()-> 
     181                                canJoin( run2->getRun((*it).first)->asOgreRenderingRun() ) 
     182                           ) 
     183                        { 
     184                                returnvalue = true; 
     185                                commonruns.push_back((*it).first); 
     186                        } 
     187                } 
     188                it++; 
     189        } 
     190 
     191        return returnvalue; 
    153192} 
    154193 
    155194bool OgreSharedRuns::canJoin(SharedRuns* r1, SharedRuns* r2) 
    156195{ 
     196        std::vector<RenderingRunType> commonruns; 
    157197        //check if they have common resources 
    158         if(!haveCommonRuns(r1, r2)) 
     198        if(!haveCommonRuns(r1, r2, commonruns)) 
    159199                return false; 
    160  
     200         
     201        float MAXRAD = 0xffffffff; 
    161202        //check bounds 
    162         float MAXRAD = OgreIlluminationManager::getSingleton().getMaxJoinRadius(); 
     203        for(int i = 0; i < commonruns.size(); i++) 
     204        { 
     205          
     206         RenderingRunType type = commonruns.at(i); 
     207         float marad = OgreIlluminationManager::getSingleton().getMaxJoinRadius(type); 
     208          
     209         MAXRAD = std::min(MAXRAD, marad); 
     210        } 
    163211 
    164212        Sphere bSphere1 = ((OgreSharedRuns*) r1)->getBoundingSphere(); 
Note: See TracChangeset for help on using the changeset viewer.