| 160 | } |
| 161 | |
| 162 | bool ProjectedShadow::_updateDecal( const SceneRenderState *state ) |
| 163 | { |
| 164 | PROFILE_SCOPE( ProjectedShadow_UpdateDecal ); |
| 165 | |
| 166 | if ( !LIGHTMGR ) |
| 167 | return false; |
| 168 | |
| 169 | // Get the position of the decal first. |
| 170 | const Box3F &objBox = mParentObject->getObjBox(); |
| 171 | const Point3F boxCenter = objBox.getCenter(); |
| 172 | Point3F decalPos = boxCenter; |
| 173 | const MatrixF &renderTransform = mParentObject->getRenderTransform(); |
| 174 | { |
| 175 | // Set up the decal position. |
| 176 | // We use the object space box center |
| 177 | // multiplied by the render transform |
| 178 | // of the object to ensure we benefit |
| 179 | // from interpolation. |
| 180 | MatrixF t( renderTransform ); |
| 181 | t.setColumn(2,Point3F::UnitZ); |
| 182 | t.mulP( decalPos ); |
| 183 | } |
| 184 | |
| 185 | if ( mDecalInstance ) |
| 186 | { |
| 187 | mDecalInstance->mPosition = decalPos; |
| 188 | if ( !shouldRender( state ) ) |
| 189 | return false; |
| 190 | } |
| 191 | |
| 192 | // Get the sunlight for the shadow projection. |
| 193 | // We want the LightManager to return NULL if it can't |
| 194 | // get the "real" sun, so we specify false for the useDefault parameter. |
| 195 | LightInfo *lights[4] = {0}; |
| 196 | LightQuery query; |
| 197 | query.init( mParentObject->getWorldSphere() ); |
| 198 | query.getLights( lights, 4 ); |
| 199 | |
| 200 | Point3F pos = renderTransform.getPosition(); |
| 201 | |
| 202 | Point3F lightDir( 0, 0, 0 ); |
| 203 | Point3F tmp( 0, 0, 0 ); |
| 204 | F32 weight = 0; |
| 205 | F32 range = 0; |
| 206 | U32 lightCount = 0; |
| 207 | F32 dist = 0; |
| 208 | F32 fade = 0; |
| 209 | for ( U32 i = 0; i < 4; i++ ) |
| 210 | { |
| 211 | // If we got a NULL light, |
| 212 | // we're at the end of the list. |
| 213 | if ( !lights[i] ) |
| 214 | break; |
| 215 | |
| 216 | if ( !lights[i]->getCastShadows() ) |
| 217 | continue; |
| 218 | |
| 219 | if ( lights[i]->getType() != LightInfo::Point ) |
nothing calls this directly
no test coverage detected