Skip to content

Commit

Permalink
Support configurable pick tolerance
Browse files Browse the repository at this point in the history
  • Loading branch information
levinli303 committed Oct 10, 2020
1 parent 12db304 commit d2bcb62
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/celestia/celestiacore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ void CelestiaCore::mouseButtonUp(float x, float y, int button)
setViewChanged();

// Four pixel tolerance for picking
float pickTolerance = sim->getActiveObserver()->getFOV() / height * 4.0f;
float pickTolerance = sim->getActiveObserver()->getFOV() / height * this->pickTolerance;

if (resizeSplit != nullptr)
{
Expand Down Expand Up @@ -2181,6 +2181,16 @@ void CelestiaCore::setSafeAreaInsets(int left, int top, int right, int bottom)
safeAreaInsets = { left, top, right, bottom };
}

float CelestiaCore::getPickTolerance() const
{
return pickTolerance;
}

void CelestiaCore::setPickTolerance(float newPickTolerance)
{
pickTolerance = newPickTolerance;
}

// Return true if anything changed that requires re-rendering. Otherwise, we
// can skip rendering, keep the GPU idle, and save power.
bool CelestiaCore::viewUpdateRequired() const
Expand Down
4 changes: 4 additions & 0 deletions src/celestia/celestiacore.h
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,8 @@ class CelestiaCore // : public Watchable<CelestiaCore>
int getDistanceToScreen() const;
void setDistanceToScreen(int);
void setSafeAreaInsets(int left, int top, int right, int bottom);
float getPickTolerance() const;
void setPickTolerance(float);

void setFOVFromZoom();
void setZoomFromFOV();
Expand Down Expand Up @@ -467,6 +469,8 @@ class CelestiaCore // : public Watchable<CelestiaCore>
int screenDpi{ 96 };
int distanceToScreen{ 400 };

float pickTolerance { 4.0f };

unique_ptr<ViewportEffect> viewportEffect { nullptr };
bool isViewportEffectUsed { false };

Expand Down

0 comments on commit d2bcb62

Please sign in to comment.