Skip to content

Commit

Permalink
Always spawn as 3D when there is a camera at a non-root path
Browse files Browse the repository at this point in the history
  • Loading branch information
jleibs committed Aug 28, 2023
1 parent cb5b034 commit a399c0a
Showing 1 changed file with 19 additions and 24 deletions.
43 changes: 19 additions & 24 deletions crates/re_space_view_spatial/src/space_view_3d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,31 +54,26 @@ impl SpaceViewClass for SpatialSpaceView3D {
space_origin: &EntityPath,
per_system_entities: &PerSystemEntities,
) -> AutoSpawnHeuristic {
let score = auto_spawn_heuristic(
&self.name(),
ctx,
per_system_entities,
SpatialSpaceViewKind::ThreeD,
);

if let AutoSpawnHeuristic::SpawnClassWithHighestScoreForRoot(mut score) = score {
// If there's a camera at a non-root path, make 3D view higher priority.
if per_system_entities
.get(&CamerasPart::name())
.map_or(false, |c| {
if c.contains(space_origin) {
c.len() > 1 // Need another camera!
} else {
!c.is_empty()
}
})
{
score += 100.0;
}

AutoSpawnHeuristic::SpawnClassWithHighestScoreForRoot(score)
// If there's a camera at a non-root path, always spawn as 3D view.
if per_system_entities
.get(&CamerasPart::name())
.map_or(false, |c| {
if c.contains(space_origin) {
c.len() > 1 // Need another camera!
} else {
!c.is_empty()
}
})
{
AutoSpawnHeuristic::AlwaysSpawn
} else {
score
// Otherwise, fall back on the generic spatial heuristic
auto_spawn_heuristic(
&self.name(),
ctx,
per_system_entities,
SpatialSpaceViewKind::ThreeD,
)
}
}

Expand Down

0 comments on commit a399c0a

Please sign in to comment.