Reader implementation for SceneCache Child locations keep a refcount pointer to their parent, so they can always ask path, read global sample times, go up in the chain.
| 320 | /// Reader implementation for SceneCache |
| 321 | /// Child locations keep a refcount pointer to their parent, so they can always ask path, read global sample times, go up in the chain. |
| 322 | class SceneCache::ReaderImplementation : public SceneCache::Implementation |
| 323 | { |
| 324 | public : |
| 325 | |
| 326 | IE_CORE_DECLAREPTR( ReaderImplementation ) |
| 327 | |
| 328 | ReaderImplementation( IndexedIOPtr io, SceneCache::Implementation *parent = nullptr) : SceneCache::Implementation( io ), m_parent(static_cast< ReaderImplementation* >( parent )), m_sharedData(nullptr), m_boundSampleTimes(nullptr), m_transformSampleTimes(nullptr), m_objectSampleTimes(nullptr) |
| 329 | { |
| 330 | if ( m_parent ) |
| 331 | { |
| 332 | // use same map from the root |
| 333 | m_sharedData = m_parent->m_sharedData; |
| 334 | } |
| 335 | else |
| 336 | { |
| 337 | // only the root instance allocate the map. |
| 338 | m_sharedData = new SharedData; |
| 339 | } |
| 340 | } |
| 341 | |
| 342 | ~ReaderImplementation() override |
| 343 | { |
| 344 | if ( m_sharedData && !m_parent ) |
| 345 | { |
| 346 | delete m_sharedData; |
| 347 | } |
| 348 | } |
| 349 | |
| 350 | const SceneCache::Name &name() const |
| 351 | { |
| 352 | if ( m_parent ) |
| 353 | { |
| 354 | return m_indexedIO->currentEntryId(); |
| 355 | } |
| 356 | else |
| 357 | { |
| 358 | return SceneInterface::rootName; |
| 359 | } |
| 360 | } |
| 361 | |
| 362 | void path( SceneCache::Path &p ) const |
| 363 | { |
| 364 | if ( m_parent ) |
| 365 | { |
| 366 | m_parent->path( p ); |
| 367 | p.push_back( m_indexedIO->currentEntryId() ); |
| 368 | } |
| 369 | } |
| 370 | |
| 371 | const SampleTimes &boundSampleTimes() const |
| 372 | { |
| 373 | if ( !m_boundSampleTimes ) |
| 374 | { |
| 375 | m_boundSampleTimes = restoreSampleTimes( boundEntry ); |
| 376 | if ( !m_boundSampleTimes ) |
| 377 | { |
| 378 | m_boundSampleTimes = &g_defaults.implicitSample; |
| 379 | } |