Ignore:
Timestamp:
02/20/06 19:06:03 (19 years ago)
Author:
mattausch
Message:

added ogre dependencies and patched ogre sources

File:
1 edited

Legend:

Unmodified
Added
Removed
  • OGRE/trunk/ogre_changes/OgreMain/src/OgreSceneManager.cpp

    r343 r657  
    375375    // Subclasses could do something smarter 
    376376    destList.clear(); 
    377     Real squaredRadius = radius * radius; 
    378377 
    379378    SceneLightList::iterator i, iend; 
     
    396395                // only add in-range lights 
    397396                Real range = lt->getAttenuationRange(); 
    398                 if ((lt->tempSquareDist - squaredRadius) <= (range * range)) 
     397                Real maxDist = range + radius; 
     398                if (lt->tempSquareDist <= Math::Sqr(maxDist)) 
    399399                { 
    400400                    destList.push_back(lt); 
     
    554554    mSkyBoxEnabled = mSkyPlaneEnabled = mSkyDomeEnabled = false;  
    555555 
     556        // Clear render queue, empty completely 
     557        if (mRenderQueue) 
     558                mRenderQueue->clear(true); 
     559 
    556560} 
    557561//----------------------------------------------------------------------- 
     
    593597    AutoTrackingSceneNodes::iterator ai, aiend; 
    594598    aiend = mAutoTrackingSceneNodes.end(); 
    595     for (ai = mAutoTrackingSceneNodes.begin(); ai != aiend; ++ai) 
    596     { 
    597         SceneNode* n = *ai; 
     599    for (ai = mAutoTrackingSceneNodes.begin(); ai != aiend; ) 
     600    { 
     601                // Pre-increment incase we delete 
     602                AutoTrackingSceneNodes::iterator curri = ai++; 
     603        SceneNode* n = *curri; 
    598604        // Tracking this node 
    599605        if (n->getAutoTrackTarget() == i->second) 
     
    601607            // turn off, this will notify SceneManager to remove 
    602608            n->setAutoTracking(false); 
    603             // no need to reset iterator since set erase does not invalidate 
    604609        } 
    605610        // node is itself a tracker 
    606611        else if (n == i->second) 
    607612        { 
    608             mAutoTrackingSceneNodes.erase(ai); 
     613            mAutoTrackingSceneNodes.erase(curri); 
    609614        } 
    610615    } 
     
    814819    if (thisFrameNumber != lastFrameNumber) 
    815820    { 
     821        // Update controllers  
     822        ControllerManager::getSingleton().updateAllControllers(); 
    816823        // Update animations 
    817824        _applySceneAnimations(); 
    818         // Update controllers  
    819         ControllerManager::getSingleton().updateAllControllers(); 
    820825        lastFrameNumber = thisFrameNumber; 
    821826    } 
     
    868873    } 
    869874 
     875    // Tell params about viewport 
     876    mAutoParamDataSource.setCurrentViewport(vp); 
    870877    // Set the viewport 
    871878    setViewport(vp); 
     
    14091416            { 
    14101417                // Someone requested we skip this queue 
    1411                 continue; 
     1418                break; 
    14121419            } 
    14131420 
     
    17131720            mShadowReceiverPass->_load(); 
    17141721 
    1715             if (l->getCastShadows() && pGroup->getShadowsEnabled()) 
     1722            if (l->getCastShadows()) 
    17161723            { 
    17171724                renderTextureShadowReceiverQueueGroupObjects(pGroup); 
     
    18761883        { 
    18771884            // Ordinary pass 
     1885            if (pGroup->getShadowsEnabled()) 
    18781886            renderModulativeTextureShadowedQueueGroupObjects(pGroup); 
     1887                        else 
     1888                                renderBasicQueueGroupObjects(pGroup); 
    18791889        } 
    18801890    } 
     
    21182128{ 
    21192129    mAmbientLight = colour; 
    2120     mDestRenderSystem->setAmbientLight(colour.r, colour.g, colour.b); 
    21212130} 
    21222131//----------------------------------------------------------------------- 
     
    26562665    { 
    26572666        createShadowTextures(mShadowTextureSize, mShadowTextureCount, mShadowTextureFormat); 
     2667    } 
     2668    else 
     2669    { 
     2670        // Destroy shadow textures to optimise resource usage 
     2671        destroyShadowTextures(); 
    26582672    } 
    26592673 
     
    27642778        const Vector3* corners = camera->getWorldSpaceCorners(); 
    27652779        Vector3 min, max; 
    2766         Vector3 extrude = light->getDirection() * -mShadowDirLightExtrudeDist; 
     2780        Vector3 extrude = light->getDerivedDirection() * -mShadowDirLightExtrudeDist; 
    27672781        // do first corner 
    27682782        min = max = corners[0]; 
     
    27922806    else 
    27932807    { 
    2794         Sphere s(light->getPosition(), light->getAttenuationRange()); 
     2808        Sphere s(light->getDerivedPosition(), light->getAttenuationRange()); 
    27952809        // eliminate early if camera cannot see light sphere 
    27962810        if (camera->isVisible(s)) 
     
    28752889        { 
    28762890            mShadowDebugPass = matDebug->getTechnique(0)->getPass(0); 
     2891 
     2892            if (mDestRenderSystem->getCapabilities()->hasCapability(RSC_VERTEX_PROGRAM)) 
     2893            { 
     2894                mInfiniteExtrusionParams = mShadowDebugPass->getVertexProgramParameters(); 
     2895            } 
    28772896        } 
    28782897    } 
     
    29152934        { 
    29162935            mShadowStencilPass = matStencil->getTechnique(0)->getPass(0); 
     2936 
     2937            if (mDestRenderSystem->getCapabilities()->hasCapability(RSC_VERTEX_PROGRAM)) 
     2938            { 
     2939                mFiniteExtrusionParams = mShadowStencilPass->getVertexProgramParameters(); 
     2940            } 
    29172941        } 
    29182942    } 
     
    30293053Pass* SceneManager::deriveShadowCasterPass(Pass* pass) 
    30303054{ 
     3055        Pass* retPass = 0; 
    30313056    switch (mShadowTechnique) 
    30323057    { 
    30333058    case SHADOWTYPE_TEXTURE_MODULATIVE: 
    3034                 if (mShadowTextureCustomCasterPass) 
     3059                retPass = mShadowTextureCustomCasterPass ?  
     3060                        mShadowTextureCustomCasterPass : mShadowCasterPlainBlackPass; 
     3061 
     3062 
     3063                // Special case alpha-blended passes 
     3064                if ((pass->getSourceBlendFactor() == SBF_SOURCE_ALPHA &&  
     3065                        pass->getDestBlendFactor() == SBF_ONE_MINUS_SOURCE_ALPHA)  
     3066                        || pass->getAlphaRejectFunction() != CMPF_ALWAYS_PASS) 
    30353067                { 
    3036                         // Caster pass has been customised 
     3068                        // Alpha blended passes must retain their transparency 
     3069                        retPass->setAlphaRejectSettings(pass->getAlphaRejectFunction(),  
     3070                                pass->getAlphaRejectValue()); 
     3071                        retPass->setSceneBlending(pass->getSourceBlendFactor(), pass->getDestBlendFactor()); 
     3072                        retPass->getParent()->getParent()->setTransparencyCastsShadows(true); 
     3073 
     3074                        // So we allow the texture units, but override the colour functions 
     3075                        // Copy texture state, shift up one since 0 is shadow texture 
     3076                        size_t origPassTUCount = pass->getNumTextureUnitStates(); 
     3077                        for (size_t t = 0; t < origPassTUCount; ++t) 
     3078                        { 
     3079                                TextureUnitState* tex; 
     3080                                if (retPass->getNumTextureUnitStates() <= t) 
     3081                                { 
     3082                                        tex = retPass->createTextureUnitState(); 
     3083                                } 
     3084                                else 
     3085                                { 
     3086                                        tex = retPass->getTextureUnitState(t); 
     3087                                } 
     3088                                // copy base state 
     3089                                (*tex) = *(pass->getTextureUnitState(t)); 
     3090                                // override colour function 
     3091                                tex->setColourOperationEx(LBX_SOURCE1, LBS_MANUAL, LBS_CURRENT, 
     3092                                        mShadowColour); 
     3093 
     3094                        } 
     3095                        // Remove any extras 
     3096                        while (retPass->getNumTextureUnitStates() > origPassTUCount) 
     3097                        { 
     3098                                retPass->removeTextureUnitState(origPassTUCount); 
     3099                        } 
     3100 
     3101                } 
     3102                else 
     3103                { 
     3104                        // reset 
     3105                        retPass->setSceneBlending(SBF_ONE, SBF_ZERO); 
     3106                        retPass->setAlphaRejectFunction(CMPF_ALWAYS_PASS); 
     3107                        while (retPass->getNumTextureUnitStates() > 0) 
     3108                        { 
     3109                                retPass->removeTextureUnitState(0); 
     3110                        } 
     3111                } 
     3112 
     3113                // Propagate culling modes 
     3114                retPass->setCullingMode(pass->getCullingMode()); 
     3115                retPass->setManualCullingMode(pass->getManualCullingMode()); 
     3116 
    30373117 
    30383118                        if (!pass->getShadowCasterVertexProgramName().empty()) 
    30393119                        { 
    30403120                                // Have to merge the shadow caster vertex program in 
    3041                                 mShadowTextureCustomCasterPass->setVertexProgram( 
     3121                        retPass->setVertexProgram( 
    30423122                                        pass->getShadowCasterVertexProgramName()); 
    3043                                 const GpuProgramPtr& prg = mShadowTextureCustomCasterPass->getVertexProgram(); 
     3123                        const GpuProgramPtr& prg = retPass->getVertexProgram(); 
    30443124                                // Load this program if not done already 
    30453125                                if (!prg->isLoaded()) 
    30463126                                        prg->load(); 
    30473127                                // Copy params 
    3048                                 mShadowTextureCustomCasterPass->setVertexProgramParameters( 
     3128                        retPass->setVertexProgramParameters( 
    30493129                                        pass->getShadowCasterVertexProgramParameters()); 
     3130                        if (retPass == mShadowTextureCustomCasterPass) 
     3131                        { 
    30503132                                // mark that we've overridden the standard 
    30513133                                mShadowTextureCasterVPDirty = true; 
     3134                        } 
    30523135                                // Also have to hack the light autoparams, that is done later 
    30533136                        } 
    3054                         else if (mShadowTextureCasterVPDirty) 
     3137                else  
     3138                { 
     3139                        retPass->setVertexProgram(StringUtil::BLANK); 
     3140                        if (mShadowTextureCasterVPDirty) 
    30553141                        { 
    30563142                                // reset 
     
    30653151                                mShadowTextureCasterVPDirty = false; 
    30663152                        } 
    3067                         return mShadowTextureCustomCasterPass; 
    30683153                } 
    3069                 else 
    3070                 { 
    3071                         // Standard pass 
    3072                         if (pass->hasVertexProgram()) 
    3073                         { 
    3074                                 // Have to merge the shadow caster vertex program in 
    3075                                 // This may in fact be blank, in which case it falls back on  
    3076                                 // fixed function 
    3077                                 mShadowCasterPlainBlackPass->setVertexProgram( 
    3078                                         pass->getShadowCasterVertexProgramName()); 
    3079                                 // Did this result in a new vertex program? 
    3080                                 if (mShadowCasterPlainBlackPass->hasVertexProgram()) 
    3081                                 { 
    3082                                         const GpuProgramPtr& prg = mShadowCasterPlainBlackPass->getVertexProgram(); 
    3083                                         // Load this program if not done already 
    3084                                         if (!prg->isLoaded()) 
    3085                                                 prg->load(); 
    3086                                         // Copy params 
    3087                                         mShadowCasterPlainBlackPass->setVertexProgramParameters( 
    3088                                                 pass->getShadowCasterVertexProgramParameters()); 
    3089                                 } 
    3090                                 // Also have to hack the light autoparams, that is done later 
    3091                         } 
    3092                         else if (mShadowCasterPlainBlackPass->hasVertexProgram()) 
    3093                         { 
    3094                                 // reset 
    3095                                 mShadowCasterPlainBlackPass->setVertexProgram(""); 
    3096                         } 
    3097                         return mShadowCasterPlainBlackPass; 
    3098                 } 
     3154                return retPass; 
    30993155    default: 
    31003156        return pass; 
     
    33013357        { 
    33023358        ShadowCaster* caster = *si; 
    3303                 bool zfailAlgo = false; 
     3359                bool zfailAlgo = camera->isCustomNearClipPlaneEnabled(); 
    33043360                unsigned long flags = 0; 
    33053361 
     
    37053761 
    37063762    // destroy existing 
    3707     ShadowTextureList::iterator i, iend; 
    3708     iend = mShadowTextures.end(); 
    3709     for (i = mShadowTextures.begin(); i != iend; ++i) 
    3710     { 
    3711         RenderTexture* r = *i; 
    3712         // remove camera and destroy texture 
    3713         removeCamera(r->getViewport(0)->getCamera()); 
    3714         mDestRenderSystem->destroyRenderTexture(r->getName()); 
    3715     } 
    3716     mShadowTextures.clear(); 
     3763        destroyShadowTextures(); 
    37173764 
    37183765    // Recreate shadow textures 
     
    37623809 
    37633810    } 
     3811} 
     3812//--------------------------------------------------------------------- 
     3813void SceneManager::destroyShadowTextures(void) 
     3814{ 
     3815    ShadowTextureList::iterator i, iend; 
     3816    iend = mShadowTextures.end(); 
     3817    for (i = mShadowTextures.begin(); i != iend; ++i) 
     3818    { 
     3819        RenderTexture* r = *i; 
     3820        // remove camera and destroy texture 
     3821        removeCamera(r->getViewport(0)->getCamera()); 
     3822        mDestRenderSystem->destroyRenderTexture(r->getName()); 
     3823    } 
     3824    mShadowTextures.clear(); 
    37643825} 
    37653826//--------------------------------------------------------------------- 
Note: See TracChangeset for help on using the changeset viewer.