From d518743c59448bd1695a4e16b3a767548995e060 Mon Sep 17 00:00:00 2001 From: Chris Laurel Date: Fri, 12 Dec 2003 05:53:37 +0000 Subject: [PATCH] Make pick functions ignore bodies that aren't extant at the current simulation time. --- src/celengine/universe.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/celengine/universe.cpp b/src/celengine/universe.cpp index 3631bc3f8..cf422c8ed 100644 --- a/src/celengine/universe.cpp +++ b/src/celengine/universe.cpp @@ -274,8 +274,8 @@ static bool ApproxPlanetPickTraversal(Body* body, void* info) { PlanetPickInfo* pickInfo = (PlanetPickInfo*) info; - // Reject invisible bodies - if (body->getClassification() == Body::Invisible) + // Reject invisible bodies and bodies that don't exist at the current time + if (body->getClassification() == Body::Invisible || !body->extant(pickInfo->jd)) return true; Point3d bpos = body->getHeliocentricPosition(pickInfo->jd); @@ -318,6 +318,7 @@ static bool ExactPlanetPickTraversal(Body* body, void* info) // Test for intersection with the bounding sphere if (body->getClassification() != Body::Invisible && + body->extant(pickInfo->jd) && testIntersection(pickInfo->pickRay, Sphered(bpos, radius), distance)) { if (body->getMesh() == InvalidResource) @@ -425,7 +426,7 @@ Selection Universe::pickPlanet(SolarSystem& solarSystem, // sufficiently close to the pickRay solarSystem.getPlanets()->traverse(ApproxPlanetPickTraversal, - (void*) &pickInfo); + (void*) &pickInfo); if (pickInfo.closestBody == closestBody) return Selection(closestBody); // Nothing else around, select the body and return