Skip to content

Commit 8803754

Browse files
fix: simplify deletion logic (#113)
Signed-off-by: Thomas Sedlmayer <tsedlmayer@pmsfit.de>
1 parent 2ebbcf8 commit 8803754

1 file changed

Lines changed: 4 additions & 54 deletions

File tree

src/index.ts

Lines changed: 4 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -755,23 +755,6 @@ function getDeletedEntities<T extends { id: { value: number } }>(
755755
}));
756756
}
757757

758-
function getDeletedSceneEntities(
759-
sceneEntities: PartialSceneEntity[],
760-
previousFrameIds: Set<number>,
761-
entityPrefix: string,
762-
timestamp: Time,
763-
): PartialSceneEntity[] {
764-
const currentIds = new Set(sceneEntities.map((entity) => entity.id));
765-
const deletedIds = Array.from(previousFrameIds).filter(
766-
(id) => !currentIds.has(generateSceneEntityId(entityPrefix, id)),
767-
);
768-
return deletedIds.map((id) => ({
769-
id: generateSceneEntityId(entityPrefix, id),
770-
timestamp,
771-
type: SceneEntityDeletionType.MATCHING_ID,
772-
}));
773-
}
774-
775758
export function activate(extensionContext: ExtensionContext): void {
776759
preloadDynamicTextures();
777760

@@ -854,25 +837,25 @@ export function activate(extensionContext: ExtensionContext): void {
854837
timestamp,
855838
);
856839
const deletionsLaneBoundaries = getDeletedEntities(
857-
osiGroundTruthReq.lane_boundary,
840+
config?.showPhysicalLanes === true ? osiGroundTruthReq.lane_boundary : [],
858841
state.previousLaneBoundaryIds,
859842
PREFIX_LANE_BOUNDARY,
860843
timestamp,
861844
);
862845
const deletionsLogicalLaneBoundaries = getDeletedEntities(
863-
osiGroundTruthReq.logical_lane_boundary,
846+
config?.showLogicalLanes === true ? osiGroundTruthReq.logical_lane_boundary : [],
864847
state.previousLogicalLaneBoundaryIds,
865848
PREFIX_LOGICAL_LANE_BOUNDARY,
866849
timestamp,
867850
);
868851
const deletionsLanes = getDeletedEntities(
869-
osiGroundTruthReq.lane,
852+
config?.showPhysicalLanes === true ? osiGroundTruthReq.lane : [],
870853
state.previousLaneIds,
871854
PREFIX_LANE,
872855
timestamp,
873856
);
874857
const deletionsLogicalLanes = getDeletedEntities(
875-
osiGroundTruthReq.logical_lane,
858+
config?.showLogicalLanes === true ? osiGroundTruthReq.logical_lane : [],
876859
state.previousLogicalLaneIds,
877860
PREFIX_LOGICAL_LANE,
878861
timestamp,
@@ -945,39 +928,6 @@ export function activate(extensionContext: ExtensionContext): void {
945928
...logicalLanes,
946929
];
947930

948-
// Frame clenup for scene entities
949-
const deletedLaneBoundaries = getDeletedSceneEntities(
950-
laneBoundaries,
951-
state.previousLaneBoundaryIds,
952-
PREFIX_LANE_BOUNDARY,
953-
timestamp,
954-
);
955-
deletions.push(...deletedLaneBoundaries);
956-
957-
const deletedLogicalLaneBoundaries = getDeletedSceneEntities(
958-
logicalLaneBoundaries,
959-
state.previousLogicalLaneBoundaryIds,
960-
PREFIX_LOGICAL_LANE_BOUNDARY,
961-
timestamp,
962-
);
963-
deletions.push(...deletedLogicalLaneBoundaries);
964-
965-
const deletedLanes = getDeletedSceneEntities(
966-
lanes,
967-
state.previousLaneIds,
968-
PREFIX_LANE,
969-
timestamp,
970-
);
971-
deletions.push(...deletedLanes);
972-
973-
const deletedLogicalLanes = getDeletedSceneEntities(
974-
logicalLanes,
975-
state.previousLogicalLaneIds,
976-
PREFIX_LOGICAL_LANE,
977-
timestamp,
978-
);
979-
deletions.push(...deletedLogicalLanes);
980-
981931
// Store lane boundaries in cache
982932
if (caching === true && updateFlags.laneBoundaries && laneBoundaryHash) {
983933
laneBoundaryCache.clear(); // keep only one lane boundary in cache

0 commit comments

Comments
 (0)