| 591 | } |
| 592 | |
| 593 | bool PostEffect::onAdd() |
| 594 | { |
| 595 | if( !Parent::onAdd() ) |
| 596 | return false; |
| 597 | |
| 598 | LightManager::smActivateSignal.notify( this, &PostEffect::_onLMActivate ); |
| 599 | mUpdateShader = true; |
| 600 | |
| 601 | // Grab the script path. |
| 602 | Torque::Path scriptPath( Con::getVariable( "$Con::File" ) ); |
| 603 | scriptPath.setFileName( String::EmptyString ); |
| 604 | scriptPath.setExtension( String::EmptyString ); |
| 605 | |
| 606 | // Find additional textures |
| 607 | for (S32 i = 0; i < NumTextures; i++) |
| 608 | { |
| 609 | mTextureType[i] = NormalTextureType; |
| 610 | String texFilename = getTexture(i); |
| 611 | |
| 612 | // Skip empty stages or ones with variable or target names. |
| 613 | if (texFilename.isEmpty() || |
| 614 | texFilename[0] == '$' || |
| 615 | texFilename[0] == '#') |
| 616 | continue; |
| 617 | |
| 618 | mTextureProfile[i] = (mTexSRGB[i]) ? &PostFxTextureSRGBProfile : &PostFxTextureProfile; |
| 619 | _setTexture(texFilename, i); |
| 620 | } |
| 621 | |
| 622 | // Is the target a named target? |
| 623 | if ( mTargetName.isNotEmpty() && mTargetName[0] == '#' ) |
| 624 | { |
| 625 | mNamedTarget.registerWithName( mTargetName.substr( 1 ) ); |
| 626 | mNamedTarget.getTextureDelegate().bind( this, &PostEffect::_getTargetTexture ); |
| 627 | } |
| 628 | if ( mTargetDepthStencilName.isNotEmpty() && mTargetDepthStencilName[0] == '#' ) |
| 629 | mNamedTargetDepthStencil.registerWithName( mTargetDepthStencilName.substr( 1 ) ); |
| 630 | |
| 631 | if (mNamedTarget.isRegistered() || mNamedTargetDepthStencil.isRegistered()) |
| 632 | GFXTextureManager::addEventDelegate( this, &PostEffect::_onTextureEvent ); |
| 633 | |
| 634 | // Call onAdd in script |
| 635 | onAdd_callback(); |
| 636 | |
| 637 | // Should we start enabled? |
| 638 | if ( mEnabled ) |
| 639 | { |
| 640 | mEnabled = false; |
| 641 | enable(); |
| 642 | } |
| 643 | |
| 644 | getSet()->addObject( this ); |
| 645 | |
| 646 | return true; |
| 647 | } |
| 648 | |
| 649 | void PostEffect::onRemove() |
| 650 | { |
nothing calls this directly
no test coverage detected