Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce lidar data discretization #296

Merged
merged 6 commits into from
Apr 24, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 27 additions & 2 deletions ogre2/src/Ogre2GpuRays.cc
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,8 @@ void Ogre2GpuRays::CreateCamera()
void Ogre2GpuRays::ConfigureCamera()
{
// horizontal gpu rays setup
this->SetHFOV(this->AngleMax() - this->AngleMin());
auto hfovAngle = this->AngleMax() - this->AngleMin();
this->SetHFOV(hfovAngle);

// vertical laser setup
double vfovAngle;
Expand All @@ -477,7 +478,31 @@ void Ogre2GpuRays::ConfigureCamera()
this->SetVFOV(vfovAngle);

// Configure first pass texture size
this->Set1stTextureSize(1024, 1024);
// Each cubemap texture covers 90 deg FOV so determine number of samples
// within the view for both horizontal and vertical FOV
unsigned int hs = static_cast<unsigned int>(
IGN_PI * 0.5 / hfovAngle.Radian() * this->RangeCount());
unsigned int vs = static_cast<unsigned int>(
IGN_PI * 0.5 / vfovAngle * this->VerticalRangeCount());

// get the max number from the two
unsigned int v = std::max(hs, vs);
// round to next highest power of 2
// https://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2
v--;
v |= v >> 1;
v |= v >> 2;
v |= v >> 4;
v |= v >> 8;
v |= v >> 16;
v++;
// limit max texture size to 1024
unsigned int min1stPassSamples = 2u;
unsigned int max1stPassSamples = 1024u;
unsigned int samples1stPass =
std::clamp(v, min1stPassSamples, max1stPassSamples);

this->Set1stTextureSize(samples1stPass, samples1stPass);

// Configure second pass texture size
this->SetRangeCount(this->RangeCount(), this->VerticalRangeCount());
Expand Down