Added a Clickable property for ssc objects, similar to request in feature

tracker item 1704255.
ver1_6_1
Chris Laurel 2008-01-31 20:04:01 +00:00
parent ce1252d03f
commit 4a5b66a62c
4 changed files with 31 additions and 3 deletions

View File

@ -48,6 +48,8 @@ Body::Body(PlanetarySystem* _system) :
locations(NULL),
locationsComputed(false),
referenceMarks(0),
clickable(1),
visibleAsPoint(1),
frameRefStar(NULL)
{
system = _system;
@ -827,6 +829,17 @@ Body::getFrameReferenceStar() const
}
void Body::setClickable(bool _clickable)
{
clickable = _clickable ? 1 : 0;
}
void Body::setVisibleAsPoint(bool _visibleAsPoint)
{
visibleAsPoint = _visibleAsPoint ? 1 : 0;
}
/**** Implementation of PlanetarySystem ****/
@ -997,3 +1010,4 @@ std::vector<std::string> PlanetarySystem::getCompletion(const std::string& _name
return completion;
}

View File

@ -215,6 +215,11 @@ class Body
void addLocation(Location*);
Location* findLocation(const std::string&, bool i18n = false) const;
void computeLocations();
bool isClickable() const { return clickable == 1; }
void setClickable(bool _clickable);
bool isVisibleAsPoint() const { return visibleAsPoint == 1; }
void setVisibleAsPoint(bool _visibleAsPoint);
enum
{
@ -273,6 +278,8 @@ class Body
mutable bool locationsComputed;
uint32 referenceMarks;
unsigned int clickable : 1;
unsigned int visibleAsPoint : 1;
// Only necessary until we switch to using frame hierarchy
Star* frameRefStar;

View File

@ -354,7 +354,7 @@ static Body* CreatePlanet(const string& name,
return NULL;
}
double radius = (double)body->getRadius();
double radius = (double) body->getRadius();
planetData->getNumber("Radius", radius);
body->setRadius((float) radius);
@ -388,7 +388,7 @@ static Body* CreatePlanet(const string& name,
}
else
{
if(radius < 1000.0)
if (radius < 1000.0)
classification = Body::Asteroid;
else
classification = Body::Planet;
@ -597,6 +597,12 @@ static Body* CreatePlanet(const string& name,
}
}
}
bool clickable = true;
if (planetData->getBoolean("Clickable", clickable))
{
body->setClickable(clickable);
}
return body;
}

View File

@ -317,7 +317,7 @@ static bool ApproxPlanetPickTraversal(Body* body, void* info)
PlanetPickInfo* pickInfo = (PlanetPickInfo*) info;
// Reject invisible bodies and bodies that don't exist at the current time
if (body->getClassification() == Body::Invisible || !body->extant(pickInfo->jd))
if (body->getClassification() == Body::Invisible || !body->extant(pickInfo->jd) || !body->isClickable())
return true;
Point3d bpos = body->getHeliocentricPosition(pickInfo->jd);
@ -363,6 +363,7 @@ static bool ExactPlanetPickTraversal(Body* body, void* info)
// Test for intersection with the bounding sphere
if (body->getClassification() != Body::Invisible &&
body->extant(pickInfo->jd) &&
body->isClickable() &&
testIntersection(pickInfo->pickRay, Sphered(bpos, radius), distance))
{
if (body->getModel() == InvalidResource)