17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-10-17 05:09:20 +02:00

refactor(track): reusable segment init, geometry rebuild, cell removal

This commit is contained in:
maj00r
2026-10-01 22:48:39 +02:00
parent 521c4f9ebb
commit e46fe6d06c
5 changed files with 282 additions and 179 deletions

View File

@@ -416,6 +416,40 @@ basic_cell::insert( TMemCell *Memorycell ) {
// NOTE: memory cells are virtual 'points' hence they don't ever expand cell range
}
// removes provided path from the cell
void
basic_cell::erase( TTrack *Path ) {
m_paths.erase(
std::remove( std::begin( m_paths ), std::end( m_paths ), Path ),
std::end( m_paths ) );
// drop the path from the animation list, the cell won't update it anymore
if( tTrackAnim == Path ) {
tTrackAnim = Path->SwitchExtension->pNextAnim;
Path->SwitchExtension->pNextAnim = nullptr;
}
else {
for( auto *track = tTrackAnim; track != nullptr; track = track->SwitchExtension->pNextAnim ) {
if( track->SwitchExtension->pNextAnim == Path ) {
track->SwitchExtension->pNextAnim = Path->SwitchExtension->pNextAnim;
Path->SwitchExtension->pNextAnim = nullptr;
break;
}
}
}
Path->RaOwnerSet( nullptr );
// TODO: update cell bounding area
}
// removes provided path from the lookup directory of the cell
void
basic_cell::unregister_end( TTrack *Path ) {
m_directories.paths.erase(
std::remove( std::begin( m_directories.paths ), std::end( m_directories.paths ), Path ),
std::end( m_directories.paths ) );
}
// removes provided model instance from the cell
void
basic_cell::erase( TAnimModel *Instance ) {