-------------------------------------------------------------------------------------- Description: Adds a new object to be an impostor. Arguments: object - Object to be an impostor hash - Current object hash Return Value: true If the object was added (or was already added before) false If the billboard atlas is full of the max number of re-renderings is exceeded ----------------------------------
| 232 | // false If the billboard atlas is full of the max number of re-renderings is exceeded |
| 233 | // -------------------------------------------------------------------------------------- |
| 234 | bool Tr2ImpostorManager::Add( ITr2ImpostorSource* object, const ITr2ImpostorSource::ImpostorHash& hash ) |
| 235 | { |
| 236 | if( !m_rt || !m_rt->IsValid() ) |
| 237 | { |
| 238 | return false; |
| 239 | } |
| 240 | |
| 241 | Vector3 up = TransformNormal( Vector3( 0, 1, 0 ), Tr2Renderer::GetInverseViewTransform() ); |
| 242 | |
| 243 | auto found = m_objects.find( object ); |
| 244 | if( found != m_objects.end() ) |
| 245 | { |
| 246 | found->second.hash = hash; |
| 247 | found->second.renderPriority = object->GetRenderPriority( found->second.oldHash, hash ); |
| 248 | found->second.used = true; |
| 249 | return true; |
| 250 | } |
| 251 | |
| 252 | if( m_renderQueue.size() >= m_maxUpdates ) |
| 253 | { |
| 254 | return false; |
| 255 | } |
| 256 | |
| 257 | Impostor impostor; |
| 258 | if( !m_atlas.Reserve( impostor.texcoord ) ) |
| 259 | { |
| 260 | return false; |
| 261 | } |
| 262 | |
| 263 | impostor.hash = hash; |
| 264 | impostor.used = true; |
| 265 | impostor.renderPriority = std::numeric_limits<float>::max(); |
| 266 | impostor.render = true; |
| 267 | |
| 268 | m_objects[object] = impostor; |
| 269 | |
| 270 | m_renderQueue.push_back( object ); |
| 271 | return true; |
| 272 | } |
| 273 | |
| 274 | // -------------------------------------------------------------------------------------- |
| 275 | // Description: |
no test coverage detected