diff --git a/include/openspace/engine/wrapper/sgctwindowwrapper.h b/include/openspace/engine/wrapper/sgctwindowwrapper.h index 2b6ab89b61..7a07e2e5b2 100644 --- a/include/openspace/engine/wrapper/sgctwindowwrapper.h +++ b/include/openspace/engine/wrapper/sgctwindowwrapper.h @@ -42,7 +42,7 @@ public: bool windowHasResized() const override; double averageDeltaTime() const override; - double deltaTime() const override; + double deltaTime() const override; glm::vec2 mousePosition() const override; uint32_t mouseButtons(int maxNumber) const override; glm::ivec2 currentWindowSize() const override; diff --git a/include/openspace/engine/wrapper/windowwrapper.h b/include/openspace/engine/wrapper/windowwrapper.h index 567a419417..cb931bc87c 100644 --- a/include/openspace/engine/wrapper/windowwrapper.h +++ b/include/openspace/engine/wrapper/windowwrapper.h @@ -79,11 +79,11 @@ public: */ virtual double averageDeltaTime() const; - /** - * Returns the frametime in seconds. On default, this method returns 0.0. - * \return The frametime in seconds - */ - virtual double deltaTime() const; + /** + * Returns the frametime in seconds. On default, this method returns 0.0. + * \return The frametime in seconds + */ + virtual double deltaTime() const; /** * Returns the location of the mouse cursor in pixel screen coordinates. On default, diff --git a/include/openspace/rendering/renderengine.h b/include/openspace/rendering/renderengine.h index d33d3ede7f..bd25619d07 100644 --- a/include/openspace/rendering/renderengine.h +++ b/include/openspace/rendering/renderengine.h @@ -68,15 +68,15 @@ public: Post }; - enum class FrametimeType { - DtTimeAvg = 0, - FPS, - FPSAvg - }; + enum class FrametimeType { + DtTimeAvg = 0, + FPS, + FPSAvg + }; static const std::string KeyFontMono; static const std::string KeyFontLight; - static const std::vector FrametimeTypes; + static const std::vector FrametimeTypes; RenderEngine(); ~RenderEngine(); @@ -104,7 +104,7 @@ public: void takeScreenshot(); void toggleInfoText(bool b); - void toggleFrametimeType(int t); + void toggleFrametimeType(int t); // Performance measurements void setPerformanceMeasurements(bool performanceMeasurements); @@ -207,7 +207,7 @@ private: ghoul::Dictionary _resolveData; ScreenLog* _log; - FrametimeType _frametimeType; + FrametimeType _frametimeType; bool _showInfo; bool _showLog; diff --git a/include/openspace/util/transformationmanager.h b/include/openspace/util/transformationmanager.h index 61378c816a..abc6cfb741 100644 --- a/include/openspace/util/transformationmanager.h +++ b/include/openspace/util/transformationmanager.h @@ -41,16 +41,16 @@ namespace openspace { #ifdef OPENSPACE_MODULE_KAMELEON_ENABLED #endif class TransformationManager : public ghoul::Singleton { - friend class ghoul::Singleton; + friend class ghoul::Singleton; public: - TransformationManager(); - ~TransformationManager(); + TransformationManager(); + ~TransformationManager(); - glm::dmat3 frameTransformationMatrix(std::string from, std::string to, double ephemerisTime) const; + glm::dmat3 frameTransformationMatrix(std::string from, std::string to, double ephemerisTime) const; private: - glm::dmat3 kameleonTransformationMatrix(std::string from, std::string to, double ephemerisTime) const; + glm::dmat3 kameleonTransformationMatrix(std::string from, std::string to, double ephemerisTime) const; #ifdef OPENSPACE_MODULE_KAMELEON_ENABLED std::shared_ptr _kameleon; diff --git a/modules/base/shaders/atmosphere_fs.glsl b/modules/base/shaders/atmosphere_fs.glsl index 3dcd2ca5f7..efbccdc3a7 100644 --- a/modules/base/shaders/atmosphere_fs.glsl +++ b/modules/base/shaders/atmosphere_fs.glsl @@ -205,7 +205,7 @@ float phaseFunctionR(float mu) { // Mie phase function float phaseFunctionM(float mu) { - return 1.5 * 1.0 / (4.0 * M_PI) * (1.0 - mieG*mieG) * pow(1.0 + (mieG*mieG) - 2.0*mieG*mu, -3.0/2.0) * (1.0 + mu * mu) / (2.0 + mieG*mieG); + return 1.5 * 1.0 / (4.0 * M_PI) * (1.0 - mieG*mieG) * pow(1.0 + (mieG*mieG) - 2.0*mieG*mu, -3.0/2.0) * (1.0 + mu * mu) / (2.0 + mieG*mieG); } float opticalDepth(float H, float r, float mu, float d) { @@ -225,7 +225,7 @@ vec4 texture4D(sampler3D table, float r, float mu, float muS, float nu) float rmu = r * mu; float delta = rmu * rmu - r * r + Rg * Rg; vec4 cst = rmu < 0.0 && delta > 0.0 ? vec4(1.0, 0.0, 0.0, 0.5 - 0.5 / float(RES_MU)) : vec4(-1.0, H * H, H, 0.5 + 0.5 / float(RES_MU)); - float uR = 0.5 / float(RES_R) + rho / H * (1.0 - 1.0 / float(RES_R)); + float uR = 0.5 / float(RES_R) + rho / H * (1.0 - 1.0 / float(RES_R)); float uMu = cst.w + (rmu * cst.x + sqrt(delta + cst.y)) / (rho + cst.z) * (0.5 - 1.0 / float(RES_MU)); float uMuS = 0.5 / float(RES_MU_S) + (atan(max(muS, -0.1975) * tan(1.26 * 1.1)) / 1.1 + (1.0 - 0.26)) * 0.5 * (1.0 - 1.0 / float(RES_MU_S)); float lerp = (nu + 1.0) / 2.0 * (float(RES_NU) - 1.0); @@ -240,18 +240,18 @@ vec3 analyticTransmittance(float r, float mu, float d) { } vec3 getMie(vec4 rayMie) { - return rayMie.rgb * rayMie.a / max(rayMie.r, 1e-4) * (betaR.r / betaR); + return rayMie.rgb * rayMie.a / max(rayMie.r, 1e-4) * (betaR.r / betaR); } vec2 getTransmittanceUV(float r, float mu) { float uR, uMu; - uR = sqrt((r - Rg) / (Rt - Rg)); - uMu = atan((mu + 0.15) / (1.0 + 0.15) * tan(1.5)) / 1.5; + uR = sqrt((r - Rg) / (Rt - Rg)); + uMu = atan((mu + 0.15) / (1.0 + 0.15) * tan(1.5)) / 1.5; return vec2(uMu, uR); } vec3 transmittanceFromTexture(float r, float mu) { - vec2 uv = getTransmittanceUV(r, mu); + vec2 uv = getTransmittanceUV(r, mu); return texture(transmittanceTexture, uv).rgb; } diff --git a/modules/base/shaders/deltaJ_calc_fs.glsl b/modules/base/shaders/deltaJ_calc_fs.glsl index c170ff6ccb..b087cd7b11 100644 --- a/modules/base/shaders/deltaJ_calc_fs.glsl +++ b/modules/base/shaders/deltaJ_calc_fs.glsl @@ -59,9 +59,9 @@ void getMuMuSNu(const float r, vec4 dhdH, out float mu, out float mu_s, out floa } vec3 transmittanceFromTexture(const float r, const float mu) { - float u_r = sqrt((r - Rg) / (Rt - Rg)); + float u_r = sqrt((r - Rg) / (Rt - Rg)); // See Colliene to understand the different mapping. - float u_mu = atan((mu + 0.15) / (1.0 + 0.15) * tan(1.5)) / 1.5; + float u_mu = atan((mu + 0.15) / (1.0 + 0.15) * tan(1.5)) / 1.5; return texture(transmittanceTexture, vec2(u_mu, u_r)).rgb; } @@ -106,7 +106,7 @@ vec4 texture4D(sampler3D table, const float r, const float mu, float rmu = r * mu; float delta = rmu * rmu - r * r + Rg * Rg; vec4 cst = rmu < 0.0 && delta > 0.0 ? vec4(1.0, 0.0, 0.0, 0.5 - 0.5 / float(RES_MU)) : vec4(-1.0, H * H, H, 0.5 + 0.5 / float(RES_MU)); - float u_r = 0.5 / float(RES_R) + rho / H * (1.0 - 1.0 / float(RES_R)); + float u_r = 0.5 / float(RES_R) + rho / H * (1.0 - 1.0 / float(RES_R)); float u_mu = cst.w + (rmu * cst.x + sqrt(delta + cst.y)) / (rho + cst.z) * (0.5 - 1.0 / float(RES_MU)); float u_mu_s = 0.5 / float(RES_MU_S) + (atan(max(mu_s, -0.1975) * tan(1.26 * 1.1)) / 1.1 + (1.0 - 0.26)) * 0.5 * (1.0 - 1.0 / float(RES_MU_S)); float lerp = (nu + 1.0) / 2.0 * (float(RES_NU) - 1.0); diff --git a/modules/base/shaders/imageplane_vs.glsl b/modules/base/shaders/imageplane_vs.glsl index 43ba44216d..e98713c544 100644 --- a/modules/base/shaders/imageplane_vs.glsl +++ b/modules/base/shaders/imageplane_vs.glsl @@ -37,7 +37,7 @@ out float s; void main() { - vec4 position = vec4(in_position.xyz * pow(10, in_position.w), 1); + vec4 position = vec4(in_position.xyz * pow(10, in_position.w), 1); vec4 positionClipSpace = modelViewProjectionTransform * position; // Write output diff --git a/modules/base/shaders/inScattering_calc_fs.glsl b/modules/base/shaders/inScattering_calc_fs.glsl index 5144c92bce..1eec8a78e2 100644 --- a/modules/base/shaders/inScattering_calc_fs.glsl +++ b/modules/base/shaders/inScattering_calc_fs.glsl @@ -59,9 +59,9 @@ void getMuMuSNu(const float r, vec4 dhdH, out float mu, out float mu_s, out floa } vec3 transmittanceFromTexture(const float r, const float mu) { - float u_r = sqrt((r - Rg) / (Rt - Rg)); + float u_r = sqrt((r - Rg) / (Rt - Rg)); // See Colliene to understand the different mapping. - float u_mu = atan((mu + 0.15) / (1.0 + 0.15) * tan(1.5)) / 1.5; + float u_mu = atan((mu + 0.15) / (1.0 + 0.15) * tan(1.5)) / 1.5; return texture(transmittanceTexture, vec2(u_mu, u_r)).rgb; } diff --git a/modules/base/shaders/inScattering_sup_calc_fs.glsl b/modules/base/shaders/inScattering_sup_calc_fs.glsl index 71f5943c04..13551e5abe 100644 --- a/modules/base/shaders/inScattering_sup_calc_fs.glsl +++ b/modules/base/shaders/inScattering_sup_calc_fs.glsl @@ -59,7 +59,7 @@ vec4 texture4D(sampler3D table, float r, float mu, float muS, float nu) float rmu = r * mu; float delta = rmu * rmu - r * r + Rg * Rg; vec4 cst = rmu < 0.0 && delta > 0.0 ? vec4(1.0, 0.0, 0.0, 0.5 - 0.5 / float(RES_MU)) : vec4(-1.0, H * H, H, 0.5 + 0.5 / float(RES_MU)); - float uR = 0.5 / float(RES_R) + rho / H * (1.0 - 1.0 / float(RES_R)); + float uR = 0.5 / float(RES_R) + rho / H * (1.0 - 1.0 / float(RES_R)); float uMu = cst.w + (rmu * cst.x + sqrt(delta + cst.y)) / (rho + cst.z) * (0.5 - 1.0 / float(RES_MU)); float uMuS = 0.5 / float(RES_MU_S) + (atan(max(muS, -0.1975) * tan(1.26 * 1.1)) / 1.1 + (1.0 - 0.26)) * 0.5 * (1.0 - 1.0 / float(RES_MU_S)); float lerp = (nu + 1.0) / 2.0 * (float(RES_NU) - 1.0); @@ -82,9 +82,9 @@ float limit(float r, float mu) { } vec3 transmittanceFromTexture(const float r, const float mu) { - float u_r = sqrt((r - Rg) / (Rt - Rg)); + float u_r = sqrt((r - Rg) / (Rt - Rg)); // See Colliene to understand the different mapping. - float u_mu = atan((mu + 0.15) / (1.0 + 0.15) * tan(1.5)) / 1.5; + float u_mu = atan((mu + 0.15) / (1.0 + 0.15) * tan(1.5)) / 1.5; return texture(transmittanceTexture, vec2(u_mu, u_r)).rgb; } diff --git a/modules/base/shaders/irradiance_calc_fs.glsl b/modules/base/shaders/irradiance_calc_fs.glsl index 62d0a2122c..329fe2de7d 100644 --- a/modules/base/shaders/irradiance_calc_fs.glsl +++ b/modules/base/shaders/irradiance_calc_fs.glsl @@ -37,9 +37,9 @@ void getRAndMu(out float r, out float mu) { } vec3 transmittance(const float r, const float mu) { - float u_r = sqrt((r - Rg) / (Rt - Rg)); + float u_r = sqrt((r - Rg) / (Rt - Rg)); // See Colliene to understand the different mapping. - float u_mu = atan((mu + 0.15) / (1.0 + 0.15) * tan(1.5)) / 1.5; + float u_mu = atan((mu + 0.15) / (1.0 + 0.15) * tan(1.5)) / 1.5; return texture(transmittanceTexture, vec2(u_mu, u_r)).rgb; } diff --git a/modules/base/shaders/irradiance_sup_calc_fs.glsl b/modules/base/shaders/irradiance_sup_calc_fs.glsl index dceedff870..cf87003e1c 100644 --- a/modules/base/shaders/irradiance_sup_calc_fs.glsl +++ b/modules/base/shaders/irradiance_sup_calc_fs.glsl @@ -57,7 +57,7 @@ vec4 texture4D(sampler3D table, const float r, const float mu, float rmu = r * mu; float delta = rmu * rmu - r * r + Rg * Rg; vec4 cst = rmu < 0.0 && delta > 0.0 ? vec4(1.0, 0.0, 0.0, 0.5 - 0.5 / float(RES_MU)) : vec4(-1.0, H * H, H, 0.5 + 0.5 / float(RES_MU)); - float uR = 0.5 / float(RES_R) + rho / H * (1.0 - 1.0 / float(RES_R)); + float uR = 0.5 / float(RES_R) + rho / H * (1.0 - 1.0 / float(RES_R)); float uMu = cst.w + (rmu * cst.x + sqrt(delta + cst.y)) / (rho + cst.z) * (0.5 - 1.0 / float(RES_MU)); float uMuS = 0.5 / float(RES_MU_S) + (atan(max(muS, -0.1975) * tan(1.26 * 1.1)) / 1.1 + (1.0 - 0.26)) * 0.5 * (1.0 - 1.0 / float(RES_MU_S)); float lerp = (nu + 1.0) / 2.0 * (float(RES_NU) - 1.0); diff --git a/modules/debugging/rendering/debugshader_fs.glsl b/modules/debugging/rendering/debugshader_fs.glsl index c5ba8102c8..5a395b10e7 100644 --- a/modules/debugging/rendering/debugshader_fs.glsl +++ b/modules/debugging/rendering/debugshader_fs.glsl @@ -31,8 +31,8 @@ in vec4 fs_vertexPosition; uniform vec4 color; Fragment getFragment(){ - Fragment frag; - frag.color = color; - frag.depth = fs_vertexPosition.w; - return frag; + Fragment frag; + frag.color = color; + frag.depth = fs_vertexPosition.w; + return frag; } \ No newline at end of file diff --git a/modules/debugging/rendering/debugshader_vs.glsl b/modules/debugging/rendering/debugshader_vs.glsl index 88be6de0f5..b68e20f682 100644 --- a/modules/debugging/rendering/debugshader_vs.glsl +++ b/modules/debugging/rendering/debugshader_vs.glsl @@ -31,6 +31,6 @@ layout(location = 0) in vec4 vertexPositionClippingSpace; out vec4 fs_vertexPosition; void main(){ - fs_vertexPosition = z_normalization(vertexPositionClippingSpace); - gl_Position = fs_vertexPosition; + fs_vertexPosition = z_normalization(vertexPositionClippingSpace); + gl_Position = fs_vertexPosition; } \ No newline at end of file diff --git a/modules/globebrowsing/chunk/culling.cpp b/modules/globebrowsing/chunk/culling.cpp index ff352f58fb..88a3d802dd 100644 --- a/modules/globebrowsing/chunk/culling.cpp +++ b/modules/globebrowsing/chunk/culling.cpp @@ -44,7 +44,7 @@ namespace { namespace openspace { ////////////////////////////////////////////////////////////////////////////////////// - // FRUSTUM CULLER // + // FRUSTUM CULLER // ////////////////////////////////////////////////////////////////////////////////////// FrustumCuller::FrustumCuller(const AABB3 viewFrustum) : _viewFrustum(viewFrustum){ @@ -81,7 +81,7 @@ namespace openspace { ////////////////////////////////////////////////////////////////////////////////////// - // HORIZON CULLER // + // HORIZON CULLER // ////////////////////////////////////////////////////////////////////////////////////// HorizonCuller::HorizonCuller() { diff --git a/modules/globebrowsing/geometry/angle.h b/modules/globebrowsing/geometry/angle.h index 38af821533..18996b0abf 100644 --- a/modules/globebrowsing/geometry/angle.h +++ b/modules/globebrowsing/geometry/angle.h @@ -36,137 +36,137 @@ template class Angle { public: - ////////////////////////////////////////////////////////////////////////////////////// - // STATIC CONSTANTS // - ////////////////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////////////// + // STATIC CONSTANTS // + ////////////////////////////////////////////////////////////////////////////////////// - static const T PI; - static const T EPSILON; + static const T PI; + static const T EPSILON; - - /** = 0 radians = 0 degrees = no revolution */ - static const Angle ZERO; + + /** = 0 radians = 0 degrees = no revolution */ + static const Angle ZERO; - /** = PI/2 radians = 90 degrees = quarter of a revolution */ - static const Angle QUARTER; + /** = PI/2 radians = 90 degrees = quarter of a revolution */ + static const Angle QUARTER; - /** = PI radians = 180 degrees = half a revolution */ - static const Angle HALF; + /** = PI radians = 180 degrees = half a revolution */ + static const Angle HALF; - /** = 2PI radians = 360 degrees = a full revolution */ - static const Angle FULL; + /** = 2PI radians = 360 degrees = a full revolution */ + static const Angle FULL; - ////////////////////////////////////////////////////////////////////////////////////// - // Factory Methods // - ////////////////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////////////// + // Factory Methods // + ////////////////////////////////////////////////////////////////////////////////////// - static Angle fromRadians(T radians); - static Angle fromDegrees(T degrees); - static Angle fromRevolutions(T revs); + static Angle fromRadians(T radians); + static Angle fromDegrees(T degrees); + static Angle fromRevolutions(T revs); public: - /** Copy constructor */ - Angle(const Angle& other); + /** Copy constructor */ + Angle(const Angle& other); private: - /** Private constructor. Use factory methods to avoid unit confusion */ - Angle(T rad); + /** Private constructor. Use factory methods to avoid unit confusion */ + Angle(T rad); - ////////////////////////////////////////////////////////////////////////////////////// - // Conversions // - ////////////////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////////////// + // Conversions // + ////////////////////////////////////////////////////////////////////////////////////// public: - inline T asRadians() const; - inline T asDegrees() const; - inline T asRevolutions() const; + inline T asRadians() const; + inline T asDegrees() const; + inline T asRevolutions() const; - ////////////////////////////////////////////////////////////////////////////////////// - // Operators (boilerplate, I know.. /eb) // - ////////////////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////////////// + // Operators (boilerplate, I know.. /eb) // + ////////////////////////////////////////////////////////////////////////////////////// - Angle operator+(const Angle& rhs) const; - Angle operator-(const Angle& rhs) const; - Angle operator*(T rhs) const; - Angle operator/(T rhs) const; + Angle operator+(const Angle& rhs) const; + Angle operator-(const Angle& rhs) const; + Angle operator*(T rhs) const; + Angle operator/(T rhs) const; - Angle operator-() const; + Angle operator-() const; - void operator+=(const Angle& rhs); - void operator-=(const Angle& rhs); - void operator*=(T rhs); - void operator/=(T rhs); + void operator+=(const Angle& rhs); + void operator-=(const Angle& rhs); + void operator*=(T rhs); + void operator/=(T rhs); - bool operator<(const Angle& rhs) const; - bool operator<=(const Angle& rhs) const; - bool operator>(const Angle& rhs) const; - bool operator>=(const Angle& rhs) const; - bool operator==(const Angle& rhs) const; - bool operator!=(const Angle& rhs) const; + bool operator<(const Angle& rhs) const; + bool operator<=(const Angle& rhs) const; + bool operator>(const Angle& rhs) const; + bool operator>=(const Angle& rhs) const; + bool operator==(const Angle& rhs) const; + bool operator!=(const Angle& rhs) const; - ////////////////////////////////////////////////////////////////////////////////////// - // Chainable Relative Mutators // - ////////////////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////////////// + // Chainable Relative Mutators // + ////////////////////////////////////////////////////////////////////////////////////// - /** - * Normalizes the angle to the interval [0, 2pi[ - */ - Angle& normalize(); + /** + * Normalizes the angle to the interval [0, 2pi[ + */ + Angle& normalize(); - /** - * Normalizes the angle to the interval [center - pi, center + pi[ - */ - Angle& normalizeAround(const Angle& center); + /** + * Normalizes the angle to the interval [center - pi, center + pi[ + */ + Angle& normalizeAround(const Angle& center); - /** - * Clamps the angle to the interval [min, max]. - * Default arguments are [0, 2pi]. - */ - Angle& clamp(const Angle& min = ZERO, const Angle& max = FULL); + /** + * Clamps the angle to the interval [min, max]. + * Default arguments are [0, 2pi]. + */ + Angle& clamp(const Angle& min = ZERO, const Angle& max = FULL); - Angle& abs(); + Angle& abs(); - ////////////////////////////////////////////////////////////////////////////////////// - // Chainable Relative Factory Methods // - ////////////////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////////////// + // Chainable Relative Factory Methods // + ////////////////////////////////////////////////////////////////////////////////////// - /** - * Returns a new angle normalized to the interval [0, 2pi[ - */ - Angle getNormalized() const; + /** + * Returns a new angle normalized to the interval [0, 2pi[ + */ + Angle getNormalized() const; - /** - * Returns a new angle normalized to the interval [center - pi, center + pi[ - */ - Angle getNormalizedAround(const Angle& center) const; + /** + * Returns a new angle normalized to the interval [center - pi, center + pi[ + */ + Angle getNormalizedAround(const Angle& center) const; - /** - * Returns a new angle clamped to the interval [min, max]. - * Default arguments are [0, 2pi]. - */ - Angle getClamped(const Angle& min = ZERO, const Angle& max = FULL) const; + /** + * Returns a new angle clamped to the interval [min, max]. + * Default arguments are [0, 2pi]. + */ + Angle getClamped(const Angle& min = ZERO, const Angle& max = FULL) const; - Angle getAbs() const; - + Angle getAbs() const; + private: - T _radians; + T _radians; }; diff --git a/modules/globebrowsing/geometry/angle.inl b/modules/globebrowsing/geometry/angle.inl index a4cc312198..0478f94257 100644 --- a/modules/globebrowsing/geometry/angle.inl +++ b/modules/globebrowsing/geometry/angle.inl @@ -61,10 +61,10 @@ const Angle Angle::FULL = Angle::fromRadians(2*PI); ////////////////////////////////////////////////////////////////////////////////////////// template Angle::Angle(const Angle& other) - : _radians(other._radians) { } + : _radians(other._radians) { } template Angle::Angle(T radians) - : _radians(radians) { } + : _radians(radians) { } @@ -75,17 +75,17 @@ template Angle::Angle(T radians) template Angle Angle::fromRadians(T rads) { - return Angle(rads); + return Angle(rads); } template Angle Angle::fromDegrees(T degrees) { - return Angle(degrees * PI / 180.0); + return Angle(degrees * PI / 180.0); } template Angle Angle::fromRevolutions(T revs) { - return Angle(revs * 2 * PI); + return Angle(revs * 2 * PI); } @@ -96,17 +96,17 @@ Angle Angle::fromRevolutions(T revs) { template T Angle::asRadians() const { - return _radians; + return _radians; } template T Angle::asDegrees() const { - return _radians * 180.0 / PI; + return _radians * 180.0 / PI; } template T Angle::asRevolutions() const { - return _radians / (2 * PI); + return _radians / (2 * PI); } @@ -117,49 +117,49 @@ T Angle::asRevolutions() const { template Angle Angle::operator+(const Angle& rhs) const{ - return Angle(_radians + rhs._radians); + return Angle(_radians + rhs._radians); } template Angle Angle::operator-(const Angle& rhs) const{ - return Angle(_radians - rhs._radians); + return Angle(_radians - rhs._radians); } template Angle Angle::operator*(T multiplier) const{ - return Angle(_radians * multiplier); + return Angle(_radians * multiplier); } template Angle Angle::operator/(T divisor) const{ - return Angle(_radians / divisor); + return Angle(_radians / divisor); } template Angle Angle::operator-() const { - return Angle(-_radians); + return Angle(-_radians); } template void Angle::operator+=(const Angle& rhs){ - _radians += rhs._radians; + _radians += rhs._radians; } template void Angle::operator-=(const Angle& rhs){ - _radians -= rhs._radians; + _radians -= rhs._radians; } template void Angle::operator*=(T multiplier){ - _radians *= multiplier; + _radians *= multiplier; } template void Angle::operator/=(T divisor){ - _radians /= divisor; + _radians /= divisor; } @@ -167,32 +167,32 @@ void Angle::operator/=(T divisor){ template bool Angle::operator<(const Angle& rhs) const{ - return _radians < rhs._radians; + return _radians < rhs._radians; } template bool Angle::operator<=(const Angle& rhs) const{ - return _radians <= rhs._radians; + return _radians <= rhs._radians; } template bool Angle::operator>(const Angle& rhs) const{ - return _radians > rhs._radians; + return _radians > rhs._radians; } template bool Angle::operator>=(const Angle& rhs) const{ - return _radians >= rhs._radians; + return _radians >= rhs._radians; } template bool Angle::operator==(const Angle& rhs) const{ - return _radians == rhs._radians; + return _radians == rhs._radians; } template bool Angle::operator!=(const Angle& rhs) const{ - return _radians != rhs._radians; + return _radians != rhs._radians; } @@ -203,38 +203,38 @@ bool Angle::operator!=(const Angle& rhs) const{ template Angle& Angle::normalize() { - // this will cause _radians to be in value range ]-2pi, 2pi[ - _radians = fmod(_radians, 2*PI); + // this will cause _radians to be in value range ]-2pi, 2pi[ + _radians = fmod(_radians, 2*PI); - // ensure _radians are positive, ie in value range [0, 2pi[ - if (_radians < 0.0){ - _radians += 2 * PI; - } + // ensure _radians are positive, ie in value range [0, 2pi[ + if (_radians < 0.0){ + _radians += 2 * PI; + } - return *this; + return *this; } template Angle& Angle::normalizeAround(const Angle& center) { - _radians -= center._radians + PI; - normalize(); - _radians += center._radians - PI; - return *this; + _radians -= center._radians + PI; + normalize(); + _radians += center._radians - PI; + return *this; } template Angle& Angle::clamp(const Angle& min, const Angle& max) { - _radians = _radians < min._radians ? min._radians - : _radians > max._radians ? max._radians - : _radians; - return *this; + _radians = _radians < min._radians ? min._radians + : _radians > max._radians ? max._radians + : _radians; + return *this; } template Angle& Angle::abs(){ - _radians = glm::abs(_radians); - return *this; + _radians = glm::abs(_radians); + return *this; } @@ -245,24 +245,24 @@ Angle& Angle::abs(){ template Angle Angle::getNormalized() const { - return Angle(*this).normalize(); + return Angle(*this).normalize(); } template Angle Angle::getNormalizedAround(const Angle& center) const { - return Angle(*this).normalizeAround(center); + return Angle(*this).normalizeAround(center); } template Angle Angle::getClamped(const Angle& min, const Angle& max) const { - return Angle(*this).clamp(min, max); + return Angle(*this).clamp(min, max); } template Angle Angle::getAbs() const { - return Angle(*this).abs(); + return Angle(*this).abs(); } } // namespace openspace diff --git a/modules/globebrowsing/geometry/ellipsoid.cpp b/modules/globebrowsing/geometry/ellipsoid.cpp index 9c8fc8270f..2dc96f427d 100644 --- a/modules/globebrowsing/geometry/ellipsoid.cpp +++ b/modules/globebrowsing/geometry/ellipsoid.cpp @@ -143,8 +143,8 @@ namespace openspace { { Vec3 normal = geodeticSurfaceNormalForGeocentricallyProjectedPoint(p); return Geodetic2( - asin(normal.z / length(normal)), // Latitude - atan2(normal.y, normal.x)); // Longitude + asin(normal.z / length(normal)), // Latitude + atan2(normal.y, normal.x)); // Longitude } Vec3 Ellipsoid::cartesianSurfacePosition(const Geodetic2& geodetic2) const diff --git a/modules/globebrowsing/geometry/geodetic2.cpp b/modules/globebrowsing/geometry/geodetic2.cpp index 66279858eb..4b0eb79519 100644 --- a/modules/globebrowsing/geometry/geodetic2.cpp +++ b/modules/globebrowsing/geometry/geodetic2.cpp @@ -36,7 +36,7 @@ namespace { namespace openspace { ////////////////////////////////////////////////////////////////////////////////////// - // GEODETIC2 // + // GEODETIC2 // ////////////////////////////////////////////////////////////////////////////////////// Geodetic2::Geodetic2() @@ -84,7 +84,7 @@ namespace openspace { ////////////////////////////////////////////////////////////////////////////////////// - // GEODETICPATCH // + // GEODETICPATCH // ////////////////////////////////////////////////////////////////////////////////////// GeodeticPatch::GeodeticPatch( diff --git a/modules/globebrowsing/geometry/geodetic2.h b/modules/globebrowsing/geometry/geodetic2.h index 5286ed8995..60e2fbca16 100644 --- a/modules/globebrowsing/geometry/geodetic2.h +++ b/modules/globebrowsing/geometry/geodetic2.h @@ -88,7 +88,7 @@ struct Geodetic3 { ////////////////////////////////////////////////////////////////////////////////////// -// GEODETICPATCH // +// GEODETICPATCH // ////////////////////////////////////////////////////////////////////////////////////// class GeodeticPatch { public: @@ -108,7 +108,7 @@ public: void setCenter(const Geodetic2&); - void setHalfSize(const Geodetic2&); + void setHalfSize(const Geodetic2&); /** returns the latitude boundary which is closest to the equator diff --git a/modules/globebrowsing/globebrowsingmodule.cpp b/modules/globebrowsing/globebrowsingmodule.cpp index 510938e4cc..c4bdc00a2b 100644 --- a/modules/globebrowsing/globebrowsingmodule.cpp +++ b/modules/globebrowsing/globebrowsingmodule.cpp @@ -35,33 +35,33 @@ namespace openspace { - GlobeBrowsingModule::GlobeBrowsingModule() - : OpenSpaceModule("GlobeBrowsing") + GlobeBrowsingModule::GlobeBrowsingModule() + : OpenSpaceModule("GlobeBrowsing") {} void GlobeBrowsingModule::internalInitialize() { - /* - auto fRenderable = FactoryManager::ref().factory(); - ghoul_assert(fRenderable, "Renderable factory was not created"); + /* + auto fRenderable = FactoryManager::ref().factory(); + ghoul_assert(fRenderable, "Renderable factory was not created"); - fRenderable->registerClass("Planet"); - fRenderable->registerClass("RenderableTestPlanet"); - //fRenderable->registerClass("PlanetTestGeometry"); + fRenderable->registerClass("Planet"); + fRenderable->registerClass("RenderableTestPlanet"); + //fRenderable->registerClass("PlanetTestGeometry"); - auto fPlanetGeometry = FactoryManager::ref().factory(); - ghoul_assert(fPlanetGeometry, "Planet test geometry factory was not created"); - fPlanetGeometry->registerClass("SimpleSphereTest"); + auto fPlanetGeometry = FactoryManager::ref().factory(); + ghoul_assert(fPlanetGeometry, "Planet test geometry factory was not created"); + fPlanetGeometry->registerClass("SimpleSphereTest"); - */ + */ - auto fRenderable = FactoryManager::ref().factory(); - ghoul_assert(fRenderable, "Renderable factory was not created"); + auto fRenderable = FactoryManager::ref().factory(); + ghoul_assert(fRenderable, "Renderable factory was not created"); - fRenderable->registerClass("RenderableGlobe"); + fRenderable->registerClass("RenderableGlobe"); } } // namespace openspace diff --git a/modules/globebrowsing/globebrowsingmodule.h b/modules/globebrowsing/globebrowsingmodule.h index 0ecb7b593c..95c0ef2039 100644 --- a/modules/globebrowsing/globebrowsingmodule.h +++ b/modules/globebrowsing/globebrowsingmodule.h @@ -31,7 +31,7 @@ namespace openspace { class GlobeBrowsingModule : public OpenSpaceModule { public: - GlobeBrowsingModule(); + GlobeBrowsingModule(); protected: void internalInitialize() override; diff --git a/modules/globebrowsing/meshes/basicgrid.cpp b/modules/globebrowsing/meshes/basicgrid.cpp index f9eb432b40..98061deb00 100644 --- a/modules/globebrowsing/meshes/basicgrid.cpp +++ b/modules/globebrowsing/meshes/basicgrid.cpp @@ -25,39 +25,39 @@ #include namespace { - const std::string _loggerCat = "BasicGrid"; + const std::string _loggerCat = "BasicGrid"; } namespace openspace { BasicGrid::BasicGrid( - unsigned int xSegments, - unsigned int ySegments, - TriangleSoup::Positions usePositions, - TriangleSoup::TextureCoordinates useTextureCoordinates, - TriangleSoup::Normals useNormals) - : Grid( - xSegments, - ySegments, - usePositions, - useTextureCoordinates, - useNormals) + unsigned int xSegments, + unsigned int ySegments, + TriangleSoup::Positions usePositions, + TriangleSoup::TextureCoordinates useTextureCoordinates, + TriangleSoup::Normals useNormals) + : Grid( + xSegments, + ySegments, + usePositions, + useTextureCoordinates, + useNormals) { - _geometry = std::unique_ptr(new TriangleSoup( - CreateElements(xSegments, ySegments), - usePositions, - useTextureCoordinates, - useNormals)); + _geometry = std::unique_ptr(new TriangleSoup( + CreateElements(xSegments, ySegments), + usePositions, + useTextureCoordinates, + useNormals)); - if (usePositions == TriangleSoup::Positions::Yes) { - _geometry->setVertexPositions(CreatePositions(_xSegments, _ySegments)); - } - if (useTextureCoordinates == TriangleSoup::TextureCoordinates::Yes) { - _geometry->setVertexTextureCoordinates(CreateTextureCoordinates(_xSegments, _ySegments)); - } - if (useNormals == TriangleSoup::Normals::Yes) { - _geometry->setVertexNormals(CreateNormals(_xSegments, _ySegments)); - } + if (usePositions == TriangleSoup::Positions::Yes) { + _geometry->setVertexPositions(CreatePositions(_xSegments, _ySegments)); + } + if (useTextureCoordinates == TriangleSoup::TextureCoordinates::Yes) { + _geometry->setVertexTextureCoordinates(CreateTextureCoordinates(_xSegments, _ySegments)); + } + if (useNormals == TriangleSoup::Normals::Yes) { + _geometry->setVertexNormals(CreateNormals(_xSegments, _ySegments)); + } } BasicGrid::~BasicGrid() @@ -66,110 +66,110 @@ BasicGrid::~BasicGrid() } int BasicGrid::xSegments() const { - return _xSegments; + return _xSegments; } int BasicGrid::ySegments() const { - return _ySegments; + return _ySegments; } void BasicGrid::validate(int xSegments, int ySegments) { - ghoul_assert(xSegments > 0 && ySegments > 0, - "Resolution must be at least 1x1. (" << xSegments << ", " << ySegments << ")"); + ghoul_assert(xSegments > 0 && ySegments > 0, + "Resolution must be at least 1x1. (" << xSegments << ", " << ySegments << ")"); } inline size_t BasicGrid::numElements(int xSegments, int ySegments){ - return 3 * 2 * xSegments * ySegments; + return 3 * 2 * xSegments * ySegments; } inline size_t BasicGrid::numVertices(int xSegments, int ySegments) { - return (xSegments + 1) * (ySegments + 1); + return (xSegments + 1) * (ySegments + 1); } std::vector BasicGrid::CreateElements(int xSegments, int ySegments) { - validate(xSegments, ySegments); + validate(xSegments, ySegments); - std::vector elements; - elements.reserve(numElements(xSegments, ySegments)); - for (unsigned int y = 0; y < ySegments; y++) { - for (unsigned int x = 0; x < xSegments; x++) { + std::vector elements; + elements.reserve(numElements(xSegments, ySegments)); + for (unsigned int y = 0; y < ySegments; y++) { + for (unsigned int x = 0; x < xSegments; x++) { - // x v01---v11 x .. - // | / | - // x v00---v10 x .. - // - // x x x x .. - // : : : : + // x v01---v11 x .. + // | / | + // x v00---v10 x .. + // + // x x x x .. + // : : : : - GLuint v00 = (y + 0) * (xSegments + 1) + x + 0; - GLuint v10 = (y + 0) * (xSegments + 1) + x + 1; - GLuint v01 = (y + 1) * (xSegments + 1) + x + 0; - GLuint v11 = (y + 1) * (xSegments + 1) + x + 1; + GLuint v00 = (y + 0) * (xSegments + 1) + x + 0; + GLuint v10 = (y + 0) * (xSegments + 1) + x + 1; + GLuint v01 = (y + 1) * (xSegments + 1) + x + 0; + GLuint v11 = (y + 1) * (xSegments + 1) + x + 1; - // add upper triangle - elements.push_back(v00); - elements.push_back(v10); - elements.push_back(v11); + // add upper triangle + elements.push_back(v00); + elements.push_back(v10); + elements.push_back(v11); - // add lower triangle - elements.push_back(v00); - elements.push_back(v11); - elements.push_back(v01); - } - } + // add lower triangle + elements.push_back(v00); + elements.push_back(v11); + elements.push_back(v01); + } + } - return elements; + return elements; } std::vector BasicGrid::CreatePositions( - int xSegments, - int ySegments) + int xSegments, + int ySegments) { - validate(xSegments, ySegments); - std::vector positions; - positions.reserve(numVertices(xSegments, ySegments)); + validate(xSegments, ySegments); + std::vector positions; + positions.reserve(numVertices(xSegments, ySegments)); - // Copy from 2d texture coordinates and use as template to create positions - std::vector templateTextureCoords = CreateTextureCoordinates(xSegments, ySegments); - for (unsigned int i = 0; i < templateTextureCoords.size(); i++) - { - positions.push_back(glm::vec4( - templateTextureCoords[i], - 0.0f, - 1.0f - )); - } - return positions; + // Copy from 2d texture coordinates and use as template to create positions + std::vector templateTextureCoords = CreateTextureCoordinates(xSegments, ySegments); + for (unsigned int i = 0; i < templateTextureCoords.size(); i++) + { + positions.push_back(glm::vec4( + templateTextureCoords[i], + 0.0f, + 1.0f + )); + } + return positions; } std::vector BasicGrid::CreateTextureCoordinates(int xSegments, int ySegments){ - validate(xSegments, ySegments); - std::vector textureCoordinates; - textureCoordinates.reserve(numVertices(xSegments, ySegments)); + validate(xSegments, ySegments); + std::vector textureCoordinates; + textureCoordinates.reserve(numVertices(xSegments, ySegments)); - for (unsigned int y = 0; y < ySegments + 1; y++) { - for (unsigned int x = 0; x < xSegments + 1; x++) { - textureCoordinates.push_back(glm::vec2( - static_cast(x) / static_cast(xSegments), - static_cast(y) / static_cast(ySegments) - )); - } - } - return textureCoordinates; + for (unsigned int y = 0; y < ySegments + 1; y++) { + for (unsigned int x = 0; x < xSegments + 1; x++) { + textureCoordinates.push_back(glm::vec2( + static_cast(x) / static_cast(xSegments), + static_cast(y) / static_cast(ySegments) + )); + } + } + return textureCoordinates; } std::vector BasicGrid::CreateNormals(int xSegments, int ySegments) { - validate(xSegments, ySegments); - std::vector normals; - normals.reserve(numVertices(xSegments, ySegments)); + validate(xSegments, ySegments); + std::vector normals; + normals.reserve(numVertices(xSegments, ySegments)); - for (unsigned int y = 0; y < ySegments + 1; y++) { - for (unsigned int x = 0; x < xSegments + 1; x++) { - normals.push_back(glm::vec3(0, 0, 1)); - } - } + for (unsigned int y = 0; y < ySegments + 1; y++) { + for (unsigned int x = 0; x < xSegments + 1; x++) { + normals.push_back(glm::vec3(0, 0, 1)); + } + } - return normals; + return normals; } }// namespace openspace \ No newline at end of file diff --git a/modules/globebrowsing/meshes/basicgrid.h b/modules/globebrowsing/meshes/basicgrid.h index bfa8935f53..8bfcf4e263 100644 --- a/modules/globebrowsing/meshes/basicgrid.h +++ b/modules/globebrowsing/meshes/basicgrid.h @@ -37,38 +37,38 @@ namespace openspace { class BasicGrid : public Grid { public: - /** - \param xSegments is the number of grid cells in the x direction. - \param ySegments is the number of grid cells in the y direction. - \param usePositions determines whether or not to upload any vertex position data - to the GPU. - \param useTextureCoordinates determines whether or not to upload any vertex texture - coordinate data to the GPU. - \param useNormals determines whether or not to upload any vertex normal data - to the GPU. - */ - BasicGrid( - unsigned int xSegments, - unsigned int ySegments, - TriangleSoup::Positions usePositions, - TriangleSoup::TextureCoordinates useTextureCoordinates, - TriangleSoup::Normals useNormals); - ~BasicGrid(); + /** + \param xSegments is the number of grid cells in the x direction. + \param ySegments is the number of grid cells in the y direction. + \param usePositions determines whether or not to upload any vertex position data + to the GPU. + \param useTextureCoordinates determines whether or not to upload any vertex texture + coordinate data to the GPU. + \param useNormals determines whether or not to upload any vertex normal data + to the GPU. + */ + BasicGrid( + unsigned int xSegments, + unsigned int ySegments, + TriangleSoup::Positions usePositions, + TriangleSoup::TextureCoordinates useTextureCoordinates, + TriangleSoup::Normals useNormals); + ~BasicGrid(); - virtual int xSegments() const; - virtual int ySegments() const; + virtual int xSegments() const; + virtual int ySegments() const; private: - virtual std::vector CreateElements( int xRes, int yRes); - virtual std::vector CreatePositions( int xRes, int yRes); - virtual std::vector CreateTextureCoordinates( int xRes, int yRes); - virtual std::vector CreateNormals( int xRes, int yRes); + virtual std::vector CreateElements( int xRes, int yRes); + virtual std::vector CreatePositions( int xRes, int yRes); + virtual std::vector CreateTextureCoordinates( int xRes, int yRes); + virtual std::vector CreateNormals( int xRes, int yRes); - void validate(int xSegments, int ySegments); + void validate(int xSegments, int ySegments); - inline size_t numElements(int xSegments, int ySegments); - inline size_t numVertices(int xSegments, int ySegments); + inline size_t numElements(int xSegments, int ySegments); + inline size_t numVertices(int xSegments, int ySegments); }; } // namespace openspace #endif // __BASICGRIDGEOMETRY_H__ \ No newline at end of file diff --git a/modules/globebrowsing/meshes/clipmapgrid.cpp b/modules/globebrowsing/meshes/clipmapgrid.cpp index 98b4799041..771f6c89d9 100644 --- a/modules/globebrowsing/meshes/clipmapgrid.cpp +++ b/modules/globebrowsing/meshes/clipmapgrid.cpp @@ -27,17 +27,17 @@ #include namespace { - const std::string _loggerCat = "ClipMapGrid"; + const std::string _loggerCat = "ClipMapGrid"; } namespace openspace { ////////////////////////////////////////////////////////////////////////////////////////// -// CLIPMAP GRID (Abstract class) // +// CLIPMAP GRID (Abstract class) // ////////////////////////////////////////////////////////////////////////////////////////// ClipMapGrid::ClipMapGrid(unsigned int segments) - : Grid(segments, segments, TriangleSoup::Positions::No, TriangleSoup::TextureCoordinates::Yes, TriangleSoup::Normals::No) + : Grid(segments, segments, TriangleSoup::Positions::No, TriangleSoup::TextureCoordinates::Yes, TriangleSoup::Normals::No) { } @@ -48,31 +48,31 @@ ClipMapGrid::~ClipMapGrid() } int ClipMapGrid::xSegments() const { - return segments(); + return segments(); } int ClipMapGrid::ySegments() const { - return segments(); + return segments(); } int ClipMapGrid::segments() const { - return _xSegments; + return _xSegments; } ////////////////////////////////////////////////////////////////////////////////////////// -// OUTER CLIPMAP GRID // +// OUTER CLIPMAP GRID // ////////////////////////////////////////////////////////////////////////////////////////// OuterClipMapGrid::OuterClipMapGrid(unsigned int segments) : ClipMapGrid(segments) { - _geometry = std::unique_ptr(new TriangleSoup( - CreateElements(segments, segments), - TriangleSoup::Positions::No, - TriangleSoup::TextureCoordinates::Yes, - TriangleSoup::Normals::No)); + _geometry = std::unique_ptr(new TriangleSoup( + CreateElements(segments, segments), + TriangleSoup::Positions::No, + TriangleSoup::TextureCoordinates::Yes, + TriangleSoup::Normals::No)); - _geometry->setVertexTextureCoordinates(CreateTextureCoordinates(segments, segments)); + _geometry->setVertexTextureCoordinates(CreateTextureCoordinates(segments, segments)); } OuterClipMapGrid::~OuterClipMapGrid() @@ -82,254 +82,254 @@ OuterClipMapGrid::~OuterClipMapGrid() size_t OuterClipMapGrid::numElements(int segments) { - int numElementsInTotalSquare = 6 * (segments + 1) * (segments + 1); - int numElementsInHole = 6 * (segments / 4 * segments / 4); - return numElementsInTotalSquare - numElementsInHole; + int numElementsInTotalSquare = 6 * (segments + 1) * (segments + 1); + int numElementsInHole = 6 * (segments / 4 * segments / 4); + return numElementsInTotalSquare - numElementsInHole; } size_t OuterClipMapGrid::numVerticesBottom(int segments) { - return (segments + 1 + 2) * (segments / 4 + 1 + 1); + return (segments + 1 + 2) * (segments / 4 + 1 + 1); } size_t OuterClipMapGrid::numVerticesLeft(int segments) { - return (segments / 4 + 1 + 1) * (segments / 2 + 1); + return (segments / 4 + 1 + 1) * (segments / 2 + 1); } size_t OuterClipMapGrid::numVerticesRight(int segments) { - return (segments / 4 + 1 + 1) * (segments / 2 + 1); + return (segments / 4 + 1 + 1) * (segments / 2 + 1); } size_t OuterClipMapGrid::numVerticesTop(int segments) { - return (segments + 1 + 2) * (segments / 4 + 1 + 1); + return (segments + 1 + 2) * (segments / 4 + 1 + 1); } size_t OuterClipMapGrid::numVertices(int segments) { - return numVerticesBottom(segments) + - numVerticesLeft(segments) + - numVerticesRight(segments) + - numVerticesTop(segments); + return numVerticesBottom(segments) + + numVerticesLeft(segments) + + numVerticesRight(segments) + + numVerticesTop(segments); } void OuterClipMapGrid::validate(int xRes, int yRes) { - - ghoul_assert(xRes == yRes, - "segments must be equal in x and in y. "); - int segments = xRes; - ghoul_assert(segments >= 8, - "segments must be at least 8. (" << segments << ")"); - ghoul_assert(segments == pow(2, int(log2(segments))), - "segments must be a power of 2. (" << segments << ")"); + + ghoul_assert(xRes == yRes, + "segments must be equal in x and in y. "); + int segments = xRes; + ghoul_assert(segments >= 8, + "segments must be at least 8. (" << segments << ")"); + ghoul_assert(segments == pow(2, int(log2(segments))), + "segments must be a power of 2. (" << segments << ")"); } std::vector OuterClipMapGrid::CreateElements(int xRes, int yRes) { - validate(xRes, yRes); - int segments = xRes; - std::vector elements; - elements.reserve(numElements(segments)); - - // The clipmap geometry is built up by four parts as follows: - // 0 = Bottom part - // 1 = Left part - // 2 = Right part - // 3 = Top part - // - // 33333333 - // 33333333 - // 11 22 - // 11 22 - // 00000000 - // 00000000 + validate(xRes, yRes); + int segments = xRes; + std::vector elements; + elements.reserve(numElements(segments)); + + // The clipmap geometry is built up by four parts as follows: + // 0 = Bottom part + // 1 = Left part + // 2 = Right part + // 3 = Top part + // + // 33333333 + // 33333333 + // 11 22 + // 11 22 + // 00000000 + // 00000000 - // x v01---v11 x .. - // | / | - // x v00---v10 x .. - // - // x x x x .. - // : : : : + // x v01---v11 x .. + // | / | + // x v00---v10 x .. + // + // x x x x .. + // : : : : - unsigned int previousVerts[4]; - previousVerts[0] = 0; - previousVerts[1] = previousVerts[0] + numVerticesBottom(segments); - previousVerts[2] = previousVerts[1] + numVerticesLeft(segments); - previousVerts[3] = previousVerts[2] + numVerticesRight(segments); + unsigned int previousVerts[4]; + previousVerts[0] = 0; + previousVerts[1] = previousVerts[0] + numVerticesBottom(segments); + previousVerts[2] = previousVerts[1] + numVerticesLeft(segments); + previousVerts[3] = previousVerts[2] + numVerticesRight(segments); - // Build the bottom part of the clipmap geometry - for (unsigned int y = 0; y < segments / 4 + 1; y++) { - for (unsigned int x = 0; x < segments + 2; x++) { - GLuint v00 = previousVerts[0] + (y + 0) * (segments + 3) + x + 0; - GLuint v10 = previousVerts[0] + (y + 0) * (segments + 3) + x + 1; - GLuint v01 = previousVerts[0] + (y + 1) * (segments + 3) + x + 0; - GLuint v11 = previousVerts[0] + (y + 1) * (segments + 3) + x + 1; + // Build the bottom part of the clipmap geometry + for (unsigned int y = 0; y < segments / 4 + 1; y++) { + for (unsigned int x = 0; x < segments + 2; x++) { + GLuint v00 = previousVerts[0] + (y + 0) * (segments + 3) + x + 0; + GLuint v10 = previousVerts[0] + (y + 0) * (segments + 3) + x + 1; + GLuint v01 = previousVerts[0] + (y + 1) * (segments + 3) + x + 0; + GLuint v11 = previousVerts[0] + (y + 1) * (segments + 3) + x + 1; - elements.push_back(v00); - elements.push_back(v10); - elements.push_back(v11); + elements.push_back(v00); + elements.push_back(v10); + elements.push_back(v11); - elements.push_back(v00); - elements.push_back(v11); - elements.push_back(v01); - } - } + elements.push_back(v00); + elements.push_back(v11); + elements.push_back(v01); + } + } - // Build the left part of the clipmap geometry - for (unsigned int y = 0; y < segments / 2; y++) { - for (unsigned int x = 0; x < segments / 4 + 1; x++) { - GLuint v00 = previousVerts[1] + (y + 0) * (segments / 4 + 2) + x + 0; - GLuint v10 = previousVerts[1] + (y + 0) * (segments / 4 + 2) + x + 1; - GLuint v01 = previousVerts[1] + (y + 1) * (segments / 4 + 2) + x + 0; - GLuint v11 = previousVerts[1] + (y + 1) * (segments / 4 + 2) + x + 1; + // Build the left part of the clipmap geometry + for (unsigned int y = 0; y < segments / 2; y++) { + for (unsigned int x = 0; x < segments / 4 + 1; x++) { + GLuint v00 = previousVerts[1] + (y + 0) * (segments / 4 + 2) + x + 0; + GLuint v10 = previousVerts[1] + (y + 0) * (segments / 4 + 2) + x + 1; + GLuint v01 = previousVerts[1] + (y + 1) * (segments / 4 + 2) + x + 0; + GLuint v11 = previousVerts[1] + (y + 1) * (segments / 4 + 2) + x + 1; - elements.push_back(v00); - elements.push_back(v10); - elements.push_back(v11); + elements.push_back(v00); + elements.push_back(v10); + elements.push_back(v11); - elements.push_back(v00); - elements.push_back(v11); - elements.push_back(v01); - } - } + elements.push_back(v00); + elements.push_back(v11); + elements.push_back(v01); + } + } - // Build the left part of the clipmap geometry - for (unsigned int y = 0; y < segments / 2; y++) { - for (unsigned int x = 0; x < segments / 4 + 1; x++) { - GLuint v00 = previousVerts[2] + (y + 0) * (segments / 4 + 2) + x + 0; - GLuint v10 = previousVerts[2] + (y + 0) * (segments / 4 + 2) + x + 1; - GLuint v01 = previousVerts[2] + (y + 1) * (segments / 4 + 2) + x + 0; - GLuint v11 = previousVerts[2] + (y + 1) * (segments / 4 + 2) + x + 1; + // Build the left part of the clipmap geometry + for (unsigned int y = 0; y < segments / 2; y++) { + for (unsigned int x = 0; x < segments / 4 + 1; x++) { + GLuint v00 = previousVerts[2] + (y + 0) * (segments / 4 + 2) + x + 0; + GLuint v10 = previousVerts[2] + (y + 0) * (segments / 4 + 2) + x + 1; + GLuint v01 = previousVerts[2] + (y + 1) * (segments / 4 + 2) + x + 0; + GLuint v11 = previousVerts[2] + (y + 1) * (segments / 4 + 2) + x + 1; - elements.push_back(v00); - elements.push_back(v10); - elements.push_back(v11); + elements.push_back(v00); + elements.push_back(v10); + elements.push_back(v11); - elements.push_back(v00); - elements.push_back(v11); - elements.push_back(v01); - } - } + elements.push_back(v00); + elements.push_back(v11); + elements.push_back(v01); + } + } - // Build the left part of the clipmap geometry - for (unsigned int y = 0; y < segments / 4 + 1; y++) { - for (unsigned int x = 0; x < segments + 2; x++) { - GLuint v00 = previousVerts[3] + (y + 0) * (segments + 3) + x + 0; - GLuint v10 = previousVerts[3] + (y + 0) * (segments + 3) + x + 1; - GLuint v01 = previousVerts[3] + (y + 1) * (segments + 3) + x + 0; - GLuint v11 = previousVerts[3] + (y + 1) * (segments + 3) + x + 1; + // Build the left part of the clipmap geometry + for (unsigned int y = 0; y < segments / 4 + 1; y++) { + for (unsigned int x = 0; x < segments + 2; x++) { + GLuint v00 = previousVerts[3] + (y + 0) * (segments + 3) + x + 0; + GLuint v10 = previousVerts[3] + (y + 0) * (segments + 3) + x + 1; + GLuint v01 = previousVerts[3] + (y + 1) * (segments + 3) + x + 0; + GLuint v11 = previousVerts[3] + (y + 1) * (segments + 3) + x + 1; - elements.push_back(v00); - elements.push_back(v10); - elements.push_back(v11); + elements.push_back(v00); + elements.push_back(v10); + elements.push_back(v11); - elements.push_back(v00); - elements.push_back(v11); - elements.push_back(v01); - } - } - return elements; + elements.push_back(v00); + elements.push_back(v11); + elements.push_back(v01); + } + } + return elements; } std::vector OuterClipMapGrid::CreatePositions(int xRes, int yRes) { - validate(xRes, yRes); - int segments = xRes; - std::vector positions; - positions.reserve(numVertices(segments)); - std::vector templateTextureCoords = CreateTextureCoordinates(xRes, yRes); + validate(xRes, yRes); + int segments = xRes; + std::vector positions; + positions.reserve(numVertices(segments)); + std::vector templateTextureCoords = CreateTextureCoordinates(xRes, yRes); - // Copy from 2d texture coordinates and use as template to create positions - for (unsigned int i = 0; i < templateTextureCoords.size(); i++) { - positions.push_back( - glm::vec4( - templateTextureCoords[i].x, - templateTextureCoords[i].y, - 0, - 1)); - } + // Copy from 2d texture coordinates and use as template to create positions + for (unsigned int i = 0; i < templateTextureCoords.size(); i++) { + positions.push_back( + glm::vec4( + templateTextureCoords[i].x, + templateTextureCoords[i].y, + 0, + 1)); + } - return positions; + return positions; } std::vector OuterClipMapGrid::CreateTextureCoordinates(int xRes, int yRes){ - validate(xRes, yRes); - int segments = xRes; - std::vector textureCoordinates; - textureCoordinates.reserve(numVertices(segments)); + validate(xRes, yRes); + int segments = xRes; + std::vector textureCoordinates; + textureCoordinates.reserve(numVertices(segments)); - // Build the bottom part of the clipmap geometry - for (int y = -1; y < segments / 4 + 1; y++) { - for (int x = -1; x < segments + 2; x++) { - textureCoordinates.push_back(glm::vec2( - static_cast(x) / segments, - static_cast(y) / segments)); - } - } - - // Build the left part of the clipmap geometry - for (int y = segments / 4; y < 3 * segments / 4 + 1; y++) { - for (int x = -1; x < segments / 4 + 1; x++) { - textureCoordinates.push_back(glm::vec2( - static_cast(x) / segments, - static_cast(y) / segments)); - } - } - - // Build the right part of the clipmap geometry - for (int y = segments / 4; y < 3 * segments / 4 + 1; y++) { - for (int x = 3 * segments / 4; x < segments + 2; x++) { - float u = static_cast(x) / segments; - float v = static_cast(y) / segments; - textureCoordinates.push_back(glm::vec2(u, v)); - } - } - - // Build the top part of the clipmap geometry - for (int y = 3 * segments / 4; y < segments + 2; y++) { - for (int x = -1; x < segments + 2; x++) { - textureCoordinates.push_back(glm::vec2( - static_cast(x) / segments, - static_cast(y) / segments)); - } - } - - return textureCoordinates; + // Build the bottom part of the clipmap geometry + for (int y = -1; y < segments / 4 + 1; y++) { + for (int x = -1; x < segments + 2; x++) { + textureCoordinates.push_back(glm::vec2( + static_cast(x) / segments, + static_cast(y) / segments)); + } + } + + // Build the left part of the clipmap geometry + for (int y = segments / 4; y < 3 * segments / 4 + 1; y++) { + for (int x = -1; x < segments / 4 + 1; x++) { + textureCoordinates.push_back(glm::vec2( + static_cast(x) / segments, + static_cast(y) / segments)); + } + } + + // Build the right part of the clipmap geometry + for (int y = segments / 4; y < 3 * segments / 4 + 1; y++) { + for (int x = 3 * segments / 4; x < segments + 2; x++) { + float u = static_cast(x) / segments; + float v = static_cast(y) / segments; + textureCoordinates.push_back(glm::vec2(u, v)); + } + } + + // Build the top part of the clipmap geometry + for (int y = 3 * segments / 4; y < segments + 2; y++) { + for (int x = -1; x < segments + 2; x++) { + textureCoordinates.push_back(glm::vec2( + static_cast(x) / segments, + static_cast(y) / segments)); + } + } + + return textureCoordinates; } std::vector OuterClipMapGrid::CreateNormals(int xRes, int yRes) { - validate(xRes, yRes); - int segments = xRes; - std::vector normals; - normals.reserve(numVertices(segments)); + validate(xRes, yRes); + int segments = xRes; + std::vector normals; + normals.reserve(numVertices(segments)); - for (int y = -1; y < segments + 2; y++) { - for (int x = -1; x < segments + 2; x++) { - normals.push_back(glm::vec3(0, 0, 1)); - } - } + for (int y = -1; y < segments + 2; y++) { + for (int x = -1; x < segments + 2; x++) { + normals.push_back(glm::vec3(0, 0, 1)); + } + } - return normals; + return normals; } ////////////////////////////////////////////////////////////////////////////////////////// -// INNER CLIPMAP GRID // +// INNER CLIPMAP GRID // ////////////////////////////////////////////////////////////////////////////////////////// InnerClipMapGrid::InnerClipMapGrid(unsigned int segments) - : ClipMapGrid(segments) + : ClipMapGrid(segments) { - _geometry = std::unique_ptr(new TriangleSoup( - CreateElements(segments, segments), - TriangleSoup::Positions::No, - TriangleSoup::TextureCoordinates::Yes, - TriangleSoup::Normals::No)); + _geometry = std::unique_ptr(new TriangleSoup( + CreateElements(segments, segments), + TriangleSoup::Positions::No, + TriangleSoup::TextureCoordinates::Yes, + TriangleSoup::Normals::No)); - _geometry->setVertexTextureCoordinates(CreateTextureCoordinates(segments, segments)); + _geometry->setVertexTextureCoordinates(CreateTextureCoordinates(segments, segments)); } InnerClipMapGrid::~InnerClipMapGrid() @@ -339,109 +339,109 @@ InnerClipMapGrid::~InnerClipMapGrid() size_t InnerClipMapGrid::numElements(int segments) { - return segments * segments * 6; + return segments * segments * 6; } size_t InnerClipMapGrid::numVertices(int segments) { - return (segments + 1) * (segments + 1); + return (segments + 1) * (segments + 1); } void InnerClipMapGrid::validate(int xRes, int yRes) { - ghoul_assert(xRes == yRes, - "segments must be equal in x and in y. "); - int segments = xRes; - ghoul_assert(segments >= 1, - "segments must be at least 1. (" << segments << ")"); + ghoul_assert(xRes == yRes, + "segments must be equal in x and in y. "); + int segments = xRes; + ghoul_assert(segments >= 1, + "segments must be at least 1. (" << segments << ")"); } std::vector InnerClipMapGrid::CreateElements(int xRes, int yRes) { - validate(xRes, yRes); - int segments = xRes; - std::vector elements; - elements.reserve(numElements(segments)); + validate(xRes, yRes); + int segments = xRes; + std::vector elements; + elements.reserve(numElements(segments)); - // x v01---v11 x .. - // | / | - // x v00---v10 x .. - // - // x x x x .. - // : : : : + // x v01---v11 x .. + // | / | + // x v00---v10 x .. + // + // x x x x .. + // : : : : - for (unsigned int y = 0; y < segments + 2; y++) { - for (unsigned int x = 0; x < segments + 2; x++) { - GLuint v00 = (y + 0) * (segments + 3) + x + 0; - GLuint v10 = (y + 0) * (segments + 3) + x + 1; - GLuint v01 = (y + 1) * (segments + 3) + x + 0; - GLuint v11 = (y + 1) * (segments + 3) + x + 1; + for (unsigned int y = 0; y < segments + 2; y++) { + for (unsigned int x = 0; x < segments + 2; x++) { + GLuint v00 = (y + 0) * (segments + 3) + x + 0; + GLuint v10 = (y + 0) * (segments + 3) + x + 1; + GLuint v01 = (y + 1) * (segments + 3) + x + 0; + GLuint v11 = (y + 1) * (segments + 3) + x + 1; - elements.push_back(v00); - elements.push_back(v10); - elements.push_back(v11); + elements.push_back(v00); + elements.push_back(v10); + elements.push_back(v11); - elements.push_back(v00); - elements.push_back(v11); - elements.push_back(v01); - } - } + elements.push_back(v00); + elements.push_back(v11); + elements.push_back(v01); + } + } - return elements; + return elements; } std::vector InnerClipMapGrid::CreatePositions(int xRes, int yRes) { - validate(xRes, yRes); - int segments = xRes; - std::vector positions; - positions.reserve(numVertices(segments)); - std::vector templateTextureCoords = CreateTextureCoordinates(xRes, yRes); + validate(xRes, yRes); + int segments = xRes; + std::vector positions; + positions.reserve(numVertices(segments)); + std::vector templateTextureCoords = CreateTextureCoordinates(xRes, yRes); - // Copy from 2d texture coordinates and use as template to create positions - for (unsigned int i = 0; i < templateTextureCoords.size(); i++) { - positions.push_back( - glm::vec4( - templateTextureCoords[i].x, - templateTextureCoords[i].y, - 0, - 1)); - } + // Copy from 2d texture coordinates and use as template to create positions + for (unsigned int i = 0; i < templateTextureCoords.size(); i++) { + positions.push_back( + glm::vec4( + templateTextureCoords[i].x, + templateTextureCoords[i].y, + 0, + 1)); + } - return positions; + return positions; } std::vector InnerClipMapGrid::CreateTextureCoordinates(int xRes, int yRes) { - validate(xRes, yRes); - int segments = xRes; - std::vector textureCoordinates; - textureCoordinates.reserve(numVertices(segments)); + validate(xRes, yRes); + int segments = xRes; + std::vector textureCoordinates; + textureCoordinates.reserve(numVertices(segments)); - // Build the bottom part of the clipmap geometry - for (int y = -1; y < segments + 2; y++) { - for (int x = -1; x < segments + 2; x++) { - textureCoordinates.push_back(glm::vec2( - static_cast(x) / segments, - static_cast(y) / segments)); - } - } + // Build the bottom part of the clipmap geometry + for (int y = -1; y < segments + 2; y++) { + for (int x = -1; x < segments + 2; x++) { + textureCoordinates.push_back(glm::vec2( + static_cast(x) / segments, + static_cast(y) / segments)); + } + } - return textureCoordinates; + return textureCoordinates; } std::vector InnerClipMapGrid::CreateNormals(int xRes, int yRes) { - validate(xRes, yRes); - int segments = xRes; - std::vector normals; - normals.reserve(numVertices(segments)); + validate(xRes, yRes); + int segments = xRes; + std::vector normals; + normals.reserve(numVertices(segments)); - for (int y = -1; y < segments + 2; y++) { - for (int x = -1; x < segments + 2; x++) { - normals.push_back(glm::vec3(0, 0, 1)); - } - } + for (int y = -1; y < segments + 2; y++) { + for (int x = -1; x < segments + 2; x++) { + normals.push_back(glm::vec3(0, 0, 1)); + } + } - return normals; + return normals; } diff --git a/modules/globebrowsing/meshes/clipmapgrid.h b/modules/globebrowsing/meshes/clipmapgrid.h index 7f580f02fd..80a68030d8 100644 --- a/modules/globebrowsing/meshes/clipmapgrid.h +++ b/modules/globebrowsing/meshes/clipmapgrid.h @@ -33,7 +33,7 @@ namespace openspace { ////////////////////////////////////////////////////////////////////////////////////////// -// CLIPMAP GRID (Abstract class) // +// CLIPMAP GRID (Abstract class) // ////////////////////////////////////////////////////////////////////////////////////////// /** @@ -48,23 +48,23 @@ snap to the outer layers grid cells. class ClipMapGrid : public Grid { public: - ClipMapGrid(unsigned int segments); + ClipMapGrid(unsigned int segments); - ~ClipMapGrid(); + ~ClipMapGrid(); - virtual int xSegments() const; - virtual int ySegments() const; + virtual int xSegments() const; + virtual int ySegments() const; - /** - Returns the segments of the grid. A ClipMapGrid must have the segments in x and - y direction equal so this function works as a wrapper for xSegments() and - ySegments(). - */ - int segments() const; + /** + Returns the segments of the grid. A ClipMapGrid must have the segments in x and + y direction equal so this function works as a wrapper for xSegments() and + ySegments(). + */ + int segments() const; }; ////////////////////////////////////////////////////////////////////////////////////////// -// OUTER CLIPMAP GRID // +// OUTER CLIPMAP GRID // ////////////////////////////////////////////////////////////////////////////////////////// /** @@ -75,30 +75,30 @@ a smaller ClipMapGrid of half the size can fit. class OuterClipMapGrid : public ClipMapGrid { public: - OuterClipMapGrid(unsigned int segments); + OuterClipMapGrid(unsigned int segments); - ~OuterClipMapGrid(); + ~OuterClipMapGrid(); protected: - virtual std::vector CreateElements(int xSegments, int ySegments); - virtual std::vector CreatePositions(int xSegments, int ySegments); - virtual std::vector CreateTextureCoordinates(int xSegments, int ySegments); - virtual std::vector CreateNormals(int xSegments, int ySegments); + virtual std::vector CreateElements(int xSegments, int ySegments); + virtual std::vector CreatePositions(int xSegments, int ySegments); + virtual std::vector CreateTextureCoordinates(int xSegments, int ySegments); + virtual std::vector CreateNormals(int xSegments, int ySegments); private: - void validate(int xSegments, int ySegments); + void validate(int xSegments, int ySegments); - static size_t numVerticesBottom(int segments); - static size_t numVerticesLeft(int segments); - static size_t numVerticesRight(int segments); - static size_t numVerticesTop(int segments); + static size_t numVerticesBottom(int segments); + static size_t numVerticesLeft(int segments); + static size_t numVerticesRight(int segments); + static size_t numVerticesTop(int segments); - static size_t numElements(int segments); - static size_t numVertices(int segments); + static size_t numElements(int segments); + static size_t numVertices(int segments); }; ////////////////////////////////////////////////////////////////////////////////////////// -// INNER CLIPMAP GRID // +// INNER CLIPMAP GRID // ////////////////////////////////////////////////////////////////////////////////////////// /** @@ -109,20 +109,20 @@ a whole where a smaller ClipMapGrid can be positioned. class InnerClipMapGrid : public ClipMapGrid { public: - InnerClipMapGrid(unsigned int segments); + InnerClipMapGrid(unsigned int segments); - ~InnerClipMapGrid(); + ~InnerClipMapGrid(); private: - virtual std::vector CreateElements( int xSegments, int ySegments); - virtual std::vector CreatePositions(int xSegments, int ySegments); - virtual std::vector CreateTextureCoordinates(int xSegments, int ySegments); - virtual std::vector CreateNormals(int xSegments, int ySegments); + virtual std::vector CreateElements( int xSegments, int ySegments); + virtual std::vector CreatePositions(int xSegments, int ySegments); + virtual std::vector CreateTextureCoordinates(int xSegments, int ySegments); + virtual std::vector CreateNormals(int xSegments, int ySegments); - void validate(int xSegments, int ySegments); + void validate(int xSegments, int ySegments); - static size_t numElements(int segments); - static size_t numVertices(int segments); + static size_t numElements(int segments); + static size_t numVertices(int segments); }; } // namespace openspace diff --git a/modules/globebrowsing/meshes/grid.cpp b/modules/globebrowsing/meshes/grid.cpp index cc3a848ce4..414b81eecd 100644 --- a/modules/globebrowsing/meshes/grid.cpp +++ b/modules/globebrowsing/meshes/grid.cpp @@ -25,19 +25,19 @@ #include namespace { - const std::string _loggerCat = "Grid"; + const std::string _loggerCat = "Grid"; } namespace openspace { - Grid::Grid( - int xSegments, - int ySegments, - TriangleSoup::Positions usePositions, - TriangleSoup::TextureCoordinates useTextures, - TriangleSoup::Normals useNormals) - : _xSegments(xSegments) - , _ySegments(ySegments) + Grid::Grid( + int xSegments, + int ySegments, + TriangleSoup::Positions usePositions, + TriangleSoup::TextureCoordinates useTextures, + TriangleSoup::Normals useNormals) + : _xSegments(xSegments) + , _ySegments(ySegments) { } @@ -49,7 +49,7 @@ Grid::~Grid() TriangleSoup& Grid::geometry() { - return *_geometry; + return *_geometry; } }// namespace openspace \ No newline at end of file diff --git a/modules/globebrowsing/meshes/grid.h b/modules/globebrowsing/meshes/grid.h index b78eddbd73..3d9860a521 100644 --- a/modules/globebrowsing/meshes/grid.h +++ b/modules/globebrowsing/meshes/grid.h @@ -37,38 +37,38 @@ namespace openspace { class Grid { public: - Grid( - int xSegments, - int ySegments, - TriangleSoup::Positions usePositions = TriangleSoup::Positions::No, - TriangleSoup::TextureCoordinates useTextures = TriangleSoup::TextureCoordinates::No, - TriangleSoup::Normals useNormals = TriangleSoup::Normals::No); - ~Grid(); + Grid( + int xSegments, + int ySegments, + TriangleSoup::Positions usePositions = TriangleSoup::Positions::No, + TriangleSoup::TextureCoordinates useTextures = TriangleSoup::TextureCoordinates::No, + TriangleSoup::Normals useNormals = TriangleSoup::Normals::No); + ~Grid(); - TriangleSoup& geometry(); + TriangleSoup& geometry(); - /** - Returns the number of grid cells in the x direction. Hence the number of vertices - in the x direction is xResolution + 1. - */ - virtual int xSegments() const = 0; - - /** - Returns the number of grid cells in the y direction. Hence the number of vertices - in the y direction is xResolution + 1. - */ - virtual int ySegments() const = 0; + /** + Returns the number of grid cells in the x direction. Hence the number of vertices + in the x direction is xResolution + 1. + */ + virtual int xSegments() const = 0; + + /** + Returns the number of grid cells in the y direction. Hence the number of vertices + in the y direction is xResolution + 1. + */ + virtual int ySegments() const = 0; protected: - virtual std::vector CreateElements( int xSegments, int ySegments) = 0; - virtual std::vector CreatePositions( int xSegments, int ySegments) = 0; - virtual std::vector CreateTextureCoordinates( int xSegments, int ySegments) = 0; - virtual std::vector CreateNormals( int xSegments, int ySegments) = 0; + virtual std::vector CreateElements( int xSegments, int ySegments) = 0; + virtual std::vector CreatePositions( int xSegments, int ySegments) = 0; + virtual std::vector CreateTextureCoordinates( int xSegments, int ySegments) = 0; + virtual std::vector CreateNormals( int xSegments, int ySegments) = 0; - std::unique_ptr _geometry; + std::unique_ptr _geometry; - const int _xSegments; - const int _ySegments; + const int _xSegments; + const int _ySegments; }; } // namespace openspace #endif // __GRIDGEOMETRY_H__ \ No newline at end of file diff --git a/modules/globebrowsing/meshes/skirtedgrid.cpp b/modules/globebrowsing/meshes/skirtedgrid.cpp index 6603a13179..7a130204e6 100644 --- a/modules/globebrowsing/meshes/skirtedgrid.cpp +++ b/modules/globebrowsing/meshes/skirtedgrid.cpp @@ -98,7 +98,7 @@ namespace openspace { // | / | // x v00---v10 x .. // - // x x x x .. + // x x x x .. // : : : : GLuint v00 = (y + 0) * (xSegments + 2 + 1) + x + 0; diff --git a/modules/globebrowsing/meshes/skirtedgrid.h b/modules/globebrowsing/meshes/skirtedgrid.h index 253f024424..4f8b5339ea 100644 --- a/modules/globebrowsing/meshes/skirtedgrid.h +++ b/modules/globebrowsing/meshes/skirtedgrid.h @@ -60,10 +60,10 @@ public: virtual int ySegments() const; private: - virtual std::vector CreateElements(int xRes, int yRes); - virtual std::vector CreatePositions(int xRes, int yRes); - virtual std::vector CreateTextureCoordinates(int xRes, int yRes); - virtual std::vector CreateNormals(int xRes, int yRes); + virtual std::vector CreateElements(int xRes, int yRes); + virtual std::vector CreatePositions(int xRes, int yRes); + virtual std::vector CreateTextureCoordinates(int xRes, int yRes); + virtual std::vector CreateNormals(int xRes, int yRes); void validate(int xSegments, int ySegments); diff --git a/modules/globebrowsing/meshes/trianglesoup.cpp b/modules/globebrowsing/meshes/trianglesoup.cpp index d064a1ad2f..ee1a7bf90c 100644 --- a/modules/globebrowsing/meshes/trianglesoup.cpp +++ b/modules/globebrowsing/meshes/trianglesoup.cpp @@ -25,154 +25,154 @@ #include namespace { - const std::string _loggerCat = "TriangleSoup"; + const std::string _loggerCat = "TriangleSoup"; } namespace openspace { TriangleSoup::TriangleSoup(std::vector elements, - Positions usePositions, TextureCoordinates useTextures, Normals useNormals) - : _vaoID(0) - ,_vertexBufferID(0) - ,_elementBufferID(0) - ,_useVertexPositions(usePositions == Positions::Yes) - ,_useTextureCoordinates(useTextures == TextureCoordinates::Yes) - ,_useVertexNormals(useNormals == Normals::Yes) + Positions usePositions, TextureCoordinates useTextures, Normals useNormals) + : _vaoID(0) + ,_vertexBufferID(0) + ,_elementBufferID(0) + ,_useVertexPositions(usePositions == Positions::Yes) + ,_useTextureCoordinates(useTextures == TextureCoordinates::Yes) + ,_useVertexNormals(useNormals == Normals::Yes) { - setElements(elements); + setElements(elements); } TriangleSoup::~TriangleSoup() { - glDeleteBuffers(1, &_vertexBufferID); - glDeleteBuffers(1, &_elementBufferID); - glDeleteVertexArrays(1, &_vaoID); + glDeleteBuffers(1, &_vertexBufferID); + glDeleteBuffers(1, &_elementBufferID); + glDeleteVertexArrays(1, &_vaoID); } void TriangleSoup::setVertexPositions(std::vector positions) { - _useVertexPositions = true; - _gpuDataNeedUpdate = true; - _vertexData.resize(positions.size()); - for (size_t i = 0; i < positions.size(); i++) - { - _vertexData[i].position[0] = static_cast(positions[i].x); - _vertexData[i].position[1] = static_cast(positions[i].y); - _vertexData[i].position[2] = static_cast(positions[i].z); - _vertexData[i].position[3] = static_cast(positions[i].w); - } + _useVertexPositions = true; + _gpuDataNeedUpdate = true; + _vertexData.resize(positions.size()); + for (size_t i = 0; i < positions.size(); i++) + { + _vertexData[i].position[0] = static_cast(positions[i].x); + _vertexData[i].position[1] = static_cast(positions[i].y); + _vertexData[i].position[2] = static_cast(positions[i].z); + _vertexData[i].position[3] = static_cast(positions[i].w); + } } void TriangleSoup::setVertexTextureCoordinates(std::vector textures) { - _useTextureCoordinates = true; - _gpuDataNeedUpdate = true; - _vertexData.resize(textures.size()); - for (size_t i = 0; i < textures.size(); i++) - { - _vertexData[i].texture[0] = static_cast(textures[i].s); - _vertexData[i].texture[1] = static_cast(textures[i].t); - } + _useTextureCoordinates = true; + _gpuDataNeedUpdate = true; + _vertexData.resize(textures.size()); + for (size_t i = 0; i < textures.size(); i++) + { + _vertexData[i].texture[0] = static_cast(textures[i].s); + _vertexData[i].texture[1] = static_cast(textures[i].t); + } } void TriangleSoup::setVertexNormals(std::vector normals) { - _useVertexNormals = true; - _gpuDataNeedUpdate = true; - _vertexData.resize(normals.size()); - for (size_t i = 0; i < normals.size(); i++) - { - _vertexData[i].normal[0] = static_cast(normals[i].x); - _vertexData[i].normal[1] = static_cast(normals[i].y); - _vertexData[i].normal[2] = static_cast(normals[i].z); - } + _useVertexNormals = true; + _gpuDataNeedUpdate = true; + _vertexData.resize(normals.size()); + for (size_t i = 0; i < normals.size(); i++) + { + _vertexData[i].normal[0] = static_cast(normals[i].x); + _vertexData[i].normal[1] = static_cast(normals[i].y); + _vertexData[i].normal[2] = static_cast(normals[i].z); + } } void TriangleSoup::setElements(std::vector elements) { - _elementData.resize(elements.size()); - _gpuDataNeedUpdate = true; - for (size_t i = 0; i < elements.size(); i++) - { - _elementData[i] = static_cast(elements[i]); - } + _elementData.resize(elements.size()); + _gpuDataNeedUpdate = true; + for (size_t i = 0; i < elements.size(); i++) + { + _elementData[i] = static_cast(elements[i]); + } } bool TriangleSoup::updateDataInGPU() { - // Create VAO - if (_vaoID == 0) - glGenVertexArrays(1, &_vaoID); + // Create VAO + if (_vaoID == 0) + glGenVertexArrays(1, &_vaoID); - // Create VBOs - if (_vertexBufferID == 0 && _vertexData.size() > 0) { - glGenBuffers(1, &_vertexBufferID); - if (_vertexBufferID == 0) { - LERROR("Could not create vertex buffer"); - return false; - } - } - if (_elementBufferID == 0 && _elementData.size() > 0) { - glGenBuffers(1, &_elementBufferID); - if (_elementBufferID == 0) { - LERROR("Could not create vertex element buffer"); - return false; - } - } + // Create VBOs + if (_vertexBufferID == 0 && _vertexData.size() > 0) { + glGenBuffers(1, &_vertexBufferID); + if (_vertexBufferID == 0) { + LERROR("Could not create vertex buffer"); + return false; + } + } + if (_elementBufferID == 0 && _elementData.size() > 0) { + glGenBuffers(1, &_elementBufferID); + if (_elementBufferID == 0) { + LERROR("Could not create vertex element buffer"); + return false; + } + } - // First VAO setup - glBindVertexArray(_vaoID); + // First VAO setup + glBindVertexArray(_vaoID); - // Vertex buffer - glBindBuffer(GL_ARRAY_BUFFER, _vertexBufferID); - glBufferData( - GL_ARRAY_BUFFER, - _vertexData.size() * sizeof(Vertex), - &_vertexData[0], - GL_STATIC_DRAW); + // Vertex buffer + glBindBuffer(GL_ARRAY_BUFFER, _vertexBufferID); + glBufferData( + GL_ARRAY_BUFFER, + _vertexData.size() * sizeof(Vertex), + &_vertexData[0], + GL_STATIC_DRAW); - // Positions at location 0 - if (_useVertexPositions) { - glEnableVertexAttribArray(0); - glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(Vertex), - reinterpret_cast(offsetof(Vertex, position))); - } - // Textures at location 1 - if (_useTextureCoordinates) { - glEnableVertexAttribArray(1); - glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), - reinterpret_cast(offsetof(Vertex, texture))); - } - // Normals at location 2 - if (_useVertexNormals) { - glEnableVertexAttribArray(2); - glVertexAttribPointer(2, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), - reinterpret_cast(offsetof(Vertex, normal))); - } + // Positions at location 0 + if (_useVertexPositions) { + glEnableVertexAttribArray(0); + glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(Vertex), + reinterpret_cast(offsetof(Vertex, position))); + } + // Textures at location 1 + if (_useTextureCoordinates) { + glEnableVertexAttribArray(1); + glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), + reinterpret_cast(offsetof(Vertex, texture))); + } + // Normals at location 2 + if (_useVertexNormals) { + glEnableVertexAttribArray(2); + glVertexAttribPointer(2, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), + reinterpret_cast(offsetof(Vertex, normal))); + } - // Element buffer - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _elementBufferID); - glBufferData( - GL_ELEMENT_ARRAY_BUFFER, - _elementData.size() * sizeof(GLint), - &_elementData[0], - GL_STATIC_DRAW); + // Element buffer + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _elementBufferID); + glBufferData( + GL_ELEMENT_ARRAY_BUFFER, + _elementData.size() * sizeof(GLint), + &_elementData[0], + GL_STATIC_DRAW); - glBindVertexArray(0); + glBindVertexArray(0); _gpuDataNeedUpdate = false; - return true; + return true; } void TriangleSoup::drawUsingActiveProgram() { - if (_gpuDataNeedUpdate) { - updateDataInGPU(); - } - glBindVertexArray(_vaoID); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _elementBufferID); - glDrawElements(GL_TRIANGLES, _elementData.size(), GL_UNSIGNED_INT, 0); - glBindVertexArray(0); + if (_gpuDataNeedUpdate) { + updateDataInGPU(); + } + glBindVertexArray(_vaoID); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _elementBufferID); + glDrawElements(GL_TRIANGLES, _elementData.size(), GL_UNSIGNED_INT, 0); + glBindVertexArray(0); } } // namespace openspace \ No newline at end of file diff --git a/modules/globebrowsing/meshes/trianglesoup.h b/modules/globebrowsing/meshes/trianglesoup.h index 23b3e6d04f..37a00dee3a 100644 --- a/modules/globebrowsing/meshes/trianglesoup.h +++ b/modules/globebrowsing/meshes/trianglesoup.h @@ -35,67 +35,67 @@ namespace openspace { /** - Class to hold vertex data and handling OpenGL interfacing and rendering. A Geometry - has all data needed such as position buffer and normal buffer but all data is not - necessarily needed for all purpouses so the Geometry can disable use of normals for - example. + Class to hold vertex data and handling OpenGL interfacing and rendering. A Geometry + has all data needed such as position buffer and normal buffer but all data is not + necessarily needed for all purpouses so the Geometry can disable use of normals for + example. */ - // TODO : Possibly render triangle strips in this class instead of triangles since - // that is faster + // TODO : Possibly render triangle strips in this class instead of triangles since + // that is faster class TriangleSoup { public: - enum class Positions { Yes, No }; - enum class TextureCoordinates { Yes, No }; - enum class Normals { Yes, No }; + enum class Positions { Yes, No }; + enum class TextureCoordinates { Yes, No }; + enum class Normals { Yes, No }; - TriangleSoup( - std::vector elements, // At least elements are required - Positions usePositions = Positions::No, - TextureCoordinates useTextures = TextureCoordinates::No, - Normals useNormals = Normals::No); - ~TriangleSoup(); + TriangleSoup( + std::vector elements, // At least elements are required + Positions usePositions = Positions::No, + TextureCoordinates useTextures = TextureCoordinates::No, + Normals useNormals = Normals::No); + ~TriangleSoup(); - // Setters - void setVertexPositions(std::vector positions); - void setVertexTextureCoordinates(std::vector textures); - void setVertexNormals(std::vector normals); - void setElements(std::vector elements); + // Setters + void setVertexPositions(std::vector positions); + void setVertexTextureCoordinates(std::vector textures); + void setVertexNormals(std::vector normals); + void setElements(std::vector elements); - - void drawUsingActiveProgram(); + + void drawUsingActiveProgram(); protected: - // Determines what attribute data is in use - bool _useVertexPositions; - bool _useTextureCoordinates; - bool _useVertexNormals; + // Determines what attribute data is in use + bool _useVertexPositions; + bool _useTextureCoordinates; + bool _useVertexNormals; - typedef struct { - public: - GLfloat position[4]; - GLfloat texture[2]; - GLfloat normal[3]; - private: - GLubyte padding[28]; // Pads the struct out to 64 bytes for performance increase - } Vertex; + typedef struct { + public: + GLfloat position[4]; + GLfloat texture[2]; + GLfloat normal[3]; + private: + GLubyte padding[28]; // Pads the struct out to 64 bytes for performance increase + } Vertex; - // Vertex data - std::vector _vertexData; - std::vector _elementData; + // Vertex data + std::vector _vertexData; + std::vector _elementData; private: - bool updateDataInGPU(); + bool updateDataInGPU(); - // GL handles - GLuint _vaoID; - GLuint _vertexBufferID; - GLuint _elementBufferID; + // GL handles + GLuint _vaoID; + GLuint _vertexBufferID; + GLuint _elementBufferID; - bool _gpuDataNeedUpdate; + bool _gpuDataNeedUpdate; }; } // namespace openspace diff --git a/modules/globebrowsing/other/distanceswitch.cpp b/modules/globebrowsing/other/distanceswitch.cpp index aa1fe9ad73..aa18752e40 100644 --- a/modules/globebrowsing/other/distanceswitch.cpp +++ b/modules/globebrowsing/other/distanceswitch.cpp @@ -26,7 +26,7 @@ #include namespace { - const std::string _loggerCat = "DistanceSwitch"; + const std::string _loggerCat = "DistanceSwitch"; } namespace openspace { @@ -40,59 +40,59 @@ DistanceSwitch::~DistanceSwitch() { } bool DistanceSwitch::initialize() { - for (int i = 0; i < _renderables.size(); ++i) { - _renderables[i]->initialize(); - } - return true; + for (int i = 0; i < _renderables.size(); ++i) { + _renderables[i]->initialize(); + } + return true; } bool DistanceSwitch::deinitialize() { - for (int i = 0; i < _renderables.size(); ++i) { - _renderables[i]->deinitialize(); - } - return true; + for (int i = 0; i < _renderables.size(); ++i) { + _renderables[i]->deinitialize(); + } + return true; } bool DistanceSwitch::isReady() const { - return true; + return true; } void DistanceSwitch::render(const RenderData& data) { - if (_maxDistances.size() == 0) { - return; - } + if (_maxDistances.size() == 0) { + return; + } - pss pssDistanceToCamera = (data.camera.position() - data.position).length(); - double distanceToCamera = pssDistanceToCamera.lengthd(); + pss pssDistanceToCamera = (data.camera.position() - data.position).length(); + double distanceToCamera = pssDistanceToCamera.lengthd(); - if (distanceToCamera > _maxDistances.back()) { - return; - } + if (distanceToCamera > _maxDistances.back()) { + return; + } - // linear search through nodes to find which Renderable to render - for (int i = 0; i < _renderables.size(); ++i) { - if (distanceToCamera < _maxDistances[i]) { - _renderables[i]->render(data); - return; - } - } + // linear search through nodes to find which Renderable to render + for (int i = 0; i < _renderables.size(); ++i) { + if (distanceToCamera < _maxDistances[i]) { + _renderables[i]->render(data); + return; + } + } } void DistanceSwitch::update(const UpdateData& data) { - for (int i = 0; i < _renderables.size(); ++i) { - _renderables[i]->update(data); - } + for (int i = 0; i < _renderables.size(); ++i) { + _renderables[i]->update(data); + } } void DistanceSwitch::addSwitchValue(std::shared_ptr renderable, double maxDistance) { - ghoul_assert(maxDistance > 0, "Renderable must have a positive maxDistance"); - if (_maxDistances.size() > 0){ - ghoul_assert(maxDistance > _maxDistances.back(), - "Renderables must be inserted in ascending order wrt distance"); - } - _renderables.push_back(renderable); - _maxDistances.push_back(maxDistance); + ghoul_assert(maxDistance > 0, "Renderable must have a positive maxDistance"); + if (_maxDistances.size() > 0){ + ghoul_assert(maxDistance > _maxDistances.back(), + "Renderables must be inserted in ascending order wrt distance"); + } + _renderables.push_back(renderable); + _maxDistances.push_back(maxDistance); } } // namespace openspace diff --git a/modules/globebrowsing/other/distanceswitch.h b/modules/globebrowsing/other/distanceswitch.h index 1ad5d0d773..32f3b40377 100644 --- a/modules/globebrowsing/other/distanceswitch.h +++ b/modules/globebrowsing/other/distanceswitch.h @@ -38,36 +38,36 @@ namespace openspace { /** - Selects a specific Renderable to be used for rendering, based on distance to the - camera + Selects a specific Renderable to be used for rendering, based on distance to the + camera */ class DistanceSwitch { public: - DistanceSwitch(); - virtual ~DistanceSwitch(); + DistanceSwitch(); + virtual ~DistanceSwitch(); - bool initialize(); - bool deinitialize(); - bool isReady() const; + bool initialize(); + bool deinitialize(); + bool isReady() const; - /** - Picks the first Renderable with the associated maxDistance greater than the - current distance to the camera - */ - void render(const RenderData& data); - void update(const UpdateData& data); + /** + Picks the first Renderable with the associated maxDistance greater than the + current distance to the camera + */ + void render(const RenderData& data); + void update(const UpdateData& data); - /** - Adds a new renderable (first argument) which may be rendered only if the distance - to the camera is less than maxDistance (second argument) - */ - void addSwitchValue(std::shared_ptr renderable, double maxDistance); + /** + Adds a new renderable (first argument) which may be rendered only if the distance + to the camera is less than maxDistance (second argument) + */ + void addSwitchValue(std::shared_ptr renderable, double maxDistance); private: - + - std::vector> _renderables; - std::vector _maxDistances; + std::vector> _renderables; + std::vector _maxDistances; }; } // openspace diff --git a/modules/globebrowsing/other/lrucache.inl b/modules/globebrowsing/other/lrucache.inl index bd0e970cc5..2ff72383b0 100644 --- a/modules/globebrowsing/other/lrucache.inl +++ b/modules/globebrowsing/other/lrucache.inl @@ -38,13 +38,13 @@ namespace openspace { : _cacheSize(size) { } template - LRUCache::~LRUCache() { + LRUCache::~LRUCache() { // Clean up list and map! } ////////////////////////////// - // PUBLIC INTERFACE // + // PUBLIC INTERFACE // ////////////////////////////// template @@ -94,7 +94,7 @@ namespace openspace { ////////////////////////////// - // PRIVATE HELPERS // + // PRIVATE HELPERS // ////////////////////////////// template void LRUCache::clean() diff --git a/modules/globebrowsing/shaders/globalchunkedlodpatch_fs.glsl b/modules/globebrowsing/shaders/globalchunkedlodpatch_fs.glsl index 9fee4cc8df..9a90381e25 100644 --- a/modules/globebrowsing/shaders/globalchunkedlodpatch_fs.glsl +++ b/modules/globebrowsing/shaders/globalchunkedlodpatch_fs.glsl @@ -26,14 +26,14 @@ #include "fragment.glsl" Fragment getFragment() { - Fragment frag; - frag.color = getTileFragColor(); + Fragment frag; + frag.color = getTileFragColor(); #if SHOW_CHUNK_EDGES - frag.color += patchBorderOverlay(fs_uv, vec3(0,1,0), 0.005); + frag.color += patchBorderOverlay(fs_uv, vec3(0,1,0), 0.005); #endif // SHOW_CHUNK_EDGES - frag.depth = fs_position.w; - return frag; + frag.depth = fs_position.w; + return frag; } diff --git a/modules/globebrowsing/shaders/globalchunkedlodpatch_vs.glsl b/modules/globebrowsing/shaders/globalchunkedlodpatch_vs.glsl index b0ef5f6320..7e63750f93 100644 --- a/modules/globebrowsing/shaders/globalchunkedlodpatch_vs.glsl +++ b/modules/globebrowsing/shaders/globalchunkedlodpatch_vs.glsl @@ -46,35 +46,35 @@ out vec3 ellipsoidNormalCameraSpace; out LevelWeights levelWeights; PositionNormalPair globalInterpolation() { - vec2 lonLatInput; - lonLatInput.y = minLatLon.y + lonLatScalingFactor.y * in_uv.y; // Lat - lonLatInput.x = minLatLon.x + lonLatScalingFactor.x * in_uv.x; // Lon - PositionNormalPair positionPairModelSpace = geodetic2ToCartesian(lonLatInput.y, lonLatInput.x, radiiSquared); - return positionPairModelSpace; + vec2 lonLatInput; + lonLatInput.y = minLatLon.y + lonLatScalingFactor.y * in_uv.y; // Lat + lonLatInput.x = minLatLon.x + lonLatScalingFactor.x * in_uv.x; // Lon + PositionNormalPair positionPairModelSpace = geodetic2ToCartesian(lonLatInput.y, lonLatInput.x, radiiSquared); + return positionPairModelSpace; } void main() { - PositionNormalPair pair = globalInterpolation(); - float distToVertexOnEllipsoid = length(pair.position - cameraPosition); + PositionNormalPair pair = globalInterpolation(); + float distToVertexOnEllipsoid = length(pair.position - cameraPosition); - float levelInterpolationParameter = getLevelInterpolationParameter(chunkLevel, distanceScaleFactor, distToVertexOnEllipsoid); + float levelInterpolationParameter = getLevelInterpolationParameter(chunkLevel, distanceScaleFactor, distToVertexOnEllipsoid); - // use level weight for height sampling, and output to fragment shader - levelWeights = getLevelWeights(levelInterpolationParameter); + // use level weight for height sampling, and output to fragment shader + levelWeights = getLevelWeights(levelInterpolationParameter); - // Get the height value - float height = getTileVertexHeight(in_uv, levelWeights); + // Get the height value + float height = getTileVertexHeight(in_uv, levelWeights); - // Apply skirts - height -= getTileVertexSkirtLength(); - - // Add the height in the direction of the normal - pair.position += pair.normal * height; - vec4 positionClippingSpace = modelViewProjectionTransform * vec4(pair.position, 1); + // Apply skirts + height -= getTileVertexSkirtLength(); + + // Add the height in the direction of the normal + pair.position += pair.normal * height; + vec4 positionClippingSpace = modelViewProjectionTransform * vec4(pair.position, 1); - // Write output - fs_uv = in_uv; - fs_position = z_normalization(positionClippingSpace); - gl_Position = fs_position; - ellipsoidNormalCameraSpace = mat3(modelViewTransform) * pair.normal; + // Write output + fs_uv = in_uv; + fs_position = z_normalization(positionClippingSpace); + gl_Position = fs_position; + ellipsoidNormalCameraSpace = mat3(modelViewTransform) * pair.normal; } \ No newline at end of file diff --git a/modules/globebrowsing/shaders/localchunkedlodpatch_fs.glsl b/modules/globebrowsing/shaders/localchunkedlodpatch_fs.glsl index 6210a9dc6d..7776e071db 100644 --- a/modules/globebrowsing/shaders/localchunkedlodpatch_fs.glsl +++ b/modules/globebrowsing/shaders/localchunkedlodpatch_fs.glsl @@ -26,14 +26,14 @@ #include "fragment.glsl" Fragment getFragment() { - Fragment frag; - frag.color = getTileFragColor(); + Fragment frag; + frag.color = getTileFragColor(); #if SHOW_CHUNK_EDGES - frag.color += patchBorderOverlay(fs_uv, vec3(1,0,0), 0.005); + frag.color += patchBorderOverlay(fs_uv, vec3(1,0,0), 0.005); #endif // SHOW_CHUNK_EDGES - frag.depth = fs_position.w; - return frag; + frag.depth = fs_position.w; + return frag; } diff --git a/modules/globebrowsing/shaders/localchunkedlodpatch_vs.glsl b/modules/globebrowsing/shaders/localchunkedlodpatch_vs.glsl index effe154b4e..748f60ae2b 100644 --- a/modules/globebrowsing/shaders/localchunkedlodpatch_vs.glsl +++ b/modules/globebrowsing/shaders/localchunkedlodpatch_vs.glsl @@ -49,39 +49,39 @@ out LevelWeights levelWeights; vec3 bilinearInterpolation(vec2 uv) { - vec3 p0 = (1 - uv.x) * p00 + uv.x * p10; - vec3 p1 = (1 - uv.x) * p01 + uv.x * p11; - vec3 p = (1 - uv.y) * p0 + uv.y * p1; - return p; + vec3 p0 = (1 - uv.x) * p00 + uv.x * p10; + vec3 p1 = (1 - uv.x) * p01 + uv.x * p11; + vec3 p = (1 - uv.y) * p0 + uv.y * p1; + return p; } void main() { - // Position in cameraspace - vec3 p = bilinearInterpolation(in_uv); - + // Position in cameraspace + vec3 p = bilinearInterpolation(in_uv); + // Calculate desired level based on distance to the vertex on the ellipsoid // Before any heightmapping is done - float distToVertexOnEllipsoid = length(p); - float levelInterpolationParameter = getLevelInterpolationParameter(chunkLevel, distanceScaleFactor, distToVertexOnEllipsoid); + float distToVertexOnEllipsoid = length(p); + float levelInterpolationParameter = getLevelInterpolationParameter(chunkLevel, distanceScaleFactor, distToVertexOnEllipsoid); - // use level weight for height sampling, and output to fragment shader - levelWeights = getLevelWeights(levelInterpolationParameter); + // use level weight for height sampling, and output to fragment shader + levelWeights = getLevelWeights(levelInterpolationParameter); - // Get the height value - float height = getTileVertexHeight(in_uv, levelWeights); + // Get the height value + float height = getTileVertexHeight(in_uv, levelWeights); - // Apply skirts - height -= getTileVertexSkirtLength(); - - // Translate the point along normal - p += patchNormalCameraSpace * height; + // Apply skirts + height -= getTileVertexSkirtLength(); + + // Translate the point along normal + p += patchNormalCameraSpace * height; - vec4 positionClippingSpace = projectionTransform * vec4(p, 1); - - // Write output - fs_uv = in_uv; - fs_position = z_normalization(positionClippingSpace); - gl_Position = fs_position; - ellipsoidNormalCameraSpace = patchNormalCameraSpace; + vec4 positionClippingSpace = projectionTransform * vec4(p, 1); + + // Write output + fs_uv = in_uv; + fs_position = z_normalization(positionClippingSpace); + gl_Position = fs_position; + ellipsoidNormalCameraSpace = patchNormalCameraSpace; } \ No newline at end of file diff --git a/modules/globebrowsing/tile/layeredtextureshaderprovider.h b/modules/globebrowsing/tile/layeredtextureshaderprovider.h index f8490937e8..4c6ac01561 100644 --- a/modules/globebrowsing/tile/layeredtextureshaderprovider.h +++ b/modules/globebrowsing/tile/layeredtextureshaderprovider.h @@ -33,7 +33,7 @@ #include ////////////////////////////////////////////////////////////////////////////////////////// -// LAYERED TEXTURE SHADER PROVIDER // +// LAYERED TEXTURE SHADER PROVIDER // ////////////////////////////////////////////////////////////////////////////////////////// namespace openspace { diff --git a/modules/globebrowsing/tile/tiledataset.cpp b/modules/globebrowsing/tile/tiledataset.cpp index 08e02a7c2a..a28a79e8c2 100644 --- a/modules/globebrowsing/tile/tiledataset.cpp +++ b/modules/globebrowsing/tile/tiledataset.cpp @@ -662,8 +662,8 @@ namespace openspace { dataDest, // Where to put data io.write.region.numPixels.x, // width to write x in destination io.write.region.numPixels.y, // width to write y in destination - _dataLayout.gdalType, // Type - _dataLayout.bytesPerPixel, // Pixel spacing + _dataLayout.gdalType, // Type + _dataLayout.bytesPerPixel, // Pixel spacing -io.write.bytesPerLine); // Line spacing } diff --git a/modules/globebrowsing/tile/tileprovider/cachingtileprovider.h b/modules/globebrowsing/tile/tileprovider/cachingtileprovider.h index e36acf67c4..f06c7e774b 100644 --- a/modules/globebrowsing/tile/tileprovider/cachingtileprovider.h +++ b/modules/globebrowsing/tile/tileprovider/cachingtileprovider.h @@ -38,7 +38,7 @@ ////////////////////////////////////////////////////////////////////////////////////////// -// TILE PROVIDER // +// TILE PROVIDER // ////////////////////////////////////////////////////////////////////////////////////////// diff --git a/modules/globebrowsing/tile/tileprovider/chunkindextileprovider.h b/modules/globebrowsing/tile/tileprovider/chunkindextileprovider.h index 30b9e1ddb7..5e8215d985 100644 --- a/modules/globebrowsing/tile/tileprovider/chunkindextileprovider.h +++ b/modules/globebrowsing/tile/tileprovider/chunkindextileprovider.h @@ -40,7 +40,7 @@ ////////////////////////////////////////////////////////////////////////////////////////// -// TILE PROVIDER // +// TILE PROVIDER // ////////////////////////////////////////////////////////////////////////////////////////// diff --git a/modules/globebrowsing/tile/tileprovider/temporaltileprovider.h b/modules/globebrowsing/tile/tileprovider/temporaltileprovider.h index f4d61dfc03..211becda87 100644 --- a/modules/globebrowsing/tile/tileprovider/temporaltileprovider.h +++ b/modules/globebrowsing/tile/tileprovider/temporaltileprovider.h @@ -41,7 +41,7 @@ ////////////////////////////////////////////////////////////////////////////////////////// -// TILE PROVIDER // +// TILE PROVIDER // ////////////////////////////////////////////////////////////////////////////////////////// namespace openspace { diff --git a/modules/globebrowsing/tile/tileprovider/tileprovider.h b/modules/globebrowsing/tile/tileprovider/tileprovider.h index 69bd55e8b2..eac5587fd0 100644 --- a/modules/globebrowsing/tile/tileprovider/tileprovider.h +++ b/modules/globebrowsing/tile/tileprovider/tileprovider.h @@ -45,7 +45,7 @@ ////////////////////////////////////////////////////////////////////////////////////////// -// TILE PROVIDER // +// TILE PROVIDER // ////////////////////////////////////////////////////////////////////////////////////////// diff --git a/modules/iswa/rendering/iswakameleongroup.h b/modules/iswa/rendering/iswakameleongroup.h index c200ea0d46..ce5a7cd9c2 100644 --- a/modules/iswa/rendering/iswakameleongroup.h +++ b/modules/iswa/rendering/iswakameleongroup.h @@ -28,10 +28,10 @@ namespace openspace{ class IswaKameleonGroup : public IswaDataGroup{ public: - IswaKameleonGroup(std::string name, std::string type); - ~IswaKameleonGroup(); + IswaKameleonGroup(std::string name, std::string type); + ~IswaKameleonGroup(); - virtual void clearGroup(); + virtual void clearGroup(); std::vector fieldlineValue(); void setFieldlineInfo(std::string fieldlineIndexFile, std::string kameleonPath); diff --git a/modules/iswa/util/dataprocessor.cpp b/modules/iswa/util/dataprocessor.cpp index 5e7e80e50f..3639899a94 100644 --- a/modules/iswa/util/dataprocessor.cpp +++ b/modules/iswa/util/dataprocessor.cpp @@ -27,7 +27,7 @@ #include namespace { - const std::string _loggerCat = "DataProcessor"; + const std::string _loggerCat = "DataProcessor"; } namespace openspace { diff --git a/modules/iswa/util/dataprocessorkameleon.h b/modules/iswa/util/dataprocessorkameleon.h index 1a8f97cbe3..482242f7e2 100644 --- a/modules/iswa/util/dataprocessorkameleon.h +++ b/modules/iswa/util/dataprocessorkameleon.h @@ -43,12 +43,12 @@ public: private: void initializeKameleonWrapper(std::string kwPath); - std::shared_ptr _kw; - std::string _kwPath; - std::vector _loadedVariables; - bool _initialized; - float _slice; - // std::vector _data; + std::shared_ptr _kw; + std::string _kwPath; + std::vector _loadedVariables; + bool _initialized; + float _slice; + // std::vector _data; }; }// namespace diff --git a/modules/iswa/util/dataprocessortext.h b/modules/iswa/util/dataprocessortext.h index ac575a0f70..b3fb53323c 100644 --- a/modules/iswa/util/dataprocessortext.h +++ b/modules/iswa/util/dataprocessortext.h @@ -38,9 +38,9 @@ public: virtual std::vector processData(std::string data, properties::SelectionProperty& dataOptions, glm::size3_t& dimensions) override; private: - // void initialize(int numOptions); - // void add(std::vector>& optionValues, std::vector& sum); - // void calculateFilterValues(std::vector selectedOptions); + // void initialize(int numOptions); + // void add(std::vector>& optionValues, std::vector& sum); + // void calculateFilterValues(std::vector selectedOptions); }; }// namespace diff --git a/modules/multiresvolume/shaders/boundsVs.glsl b/modules/multiresvolume/shaders/boundsVs.glsl index 3345b7a597..dbaaf3875e 100644 --- a/modules/multiresvolume/shaders/boundsVs.glsl +++ b/modules/multiresvolume/shaders/boundsVs.glsl @@ -35,11 +35,11 @@ out vec4 worldPosition; #include "PowerScaling/powerScaling_vs.hglsl" void main() { - vPosition = vertPosition.xyz; + vPosition = vertPosition.xyz; - worldPosition = vec4(vertPosition.xyz, 0.0); - vec4 position = pscTransform(worldPosition, modelTransform); + worldPosition = vec4(vertPosition.xyz, 0.0); + vec4 position = pscTransform(worldPosition, modelTransform); - // project the position to view space + // project the position to view space gl_Position = z_normalization(viewProjection * position); } diff --git a/src/engine/wrapper/sgctwindowwrapper.cpp b/src/engine/wrapper/sgctwindowwrapper.cpp index 34499a8cd5..abe92d0ebe 100644 --- a/src/engine/wrapper/sgctwindowwrapper.cpp +++ b/src/engine/wrapper/sgctwindowwrapper.cpp @@ -63,7 +63,7 @@ double SGCTWindowWrapper::averageDeltaTime() const { } double SGCTWindowWrapper::deltaTime() const { - return sgct::Engine::instance()->getDt(); + return sgct::Engine::instance()->getDt(); } glm::vec2 SGCTWindowWrapper::mousePosition() const { diff --git a/src/engine/wrapper/windowwrapper.cpp b/src/engine/wrapper/windowwrapper.cpp index 34bc146096..c8e754145d 100644 --- a/src/engine/wrapper/windowwrapper.cpp +++ b/src/engine/wrapper/windowwrapper.cpp @@ -47,7 +47,7 @@ double WindowWrapper::averageDeltaTime() const { } double WindowWrapper::deltaTime() const { - return 0.0; + return 0.0; } glm::vec2 WindowWrapper::mousePosition() const { diff --git a/src/interaction/interactionhandler.cpp b/src/interaction/interactionhandler.cpp index 8b9cf6038a..66c5a8ea39 100644 --- a/src/interaction/interactionhandler.cpp +++ b/src/interaction/interactionhandler.cpp @@ -302,7 +302,7 @@ void InteractionHandler::orbit(const float &dx, const float &dy, const float &dz } //new camera position - relative = origin + relative_focus_coordinate; + relative = origin + relative_focus_coordinate; psc target = relative + relative_focus_coordinate * dist * zoomSpeed; diff --git a/src/rendering/renderengine.cpp b/src/rendering/renderengine.cpp index 2eb287d18b..2b42a22e4e 100644 --- a/src/rendering/renderengine.cpp +++ b/src/rendering/renderengine.cpp @@ -107,9 +107,9 @@ namespace openspace { const std::string RenderEngine::KeyFontMono = "Mono"; const std::string RenderEngine::KeyFontLight = "Light"; const std::vector RenderEngine::FrametimeTypes({ - RenderEngine::FrametimeType::DtTimeAvg, - RenderEngine::FrametimeType::FPS, - RenderEngine::FrametimeType::FPSAvg + RenderEngine::FrametimeType::DtTimeAvg, + RenderEngine::FrametimeType::FPS, + RenderEngine::FrametimeType::FPSAvg }); RenderEngine::RenderEngine() @@ -126,7 +126,7 @@ RenderEngine::RenderEngine() , _fadeDuration(2.f) , _currentFadeTime(0.f) , _fadeDirection(0) - , _frametimeType(FrametimeType::DtTimeAvg) + , _frametimeType(FrametimeType::DtTimeAvg) // , _sgctRenderStatisticsVisible(false) { _onScreenInformation = { @@ -735,12 +735,12 @@ scripting::LuaLibrary RenderEngine::luaLibrary() { "bool", "Toggles the showing of render information on-screen text" }, - { - "toggleFrametimeType", - &luascriptfunctions::toggleFrametimeType, - "int", - "Toggle showing FPS or Average Frametime in heads up info" - }, + { + "toggleFrametimeType", + &luascriptfunctions::toggleFrametimeType, + "int", + "Toggle showing FPS or Average Frametime in heads up info" + }, { "setPerformanceMeasurement", &luascriptfunctions::setPerformanceMeasurement, diff --git a/src/rendering/renderengine_lua.inl b/src/rendering/renderengine_lua.inl index c52df95ca4..66e6452981 100644 --- a/src/rendering/renderengine_lua.inl +++ b/src/rendering/renderengine_lua.inl @@ -104,16 +104,16 @@ int showRenderInformation(lua_State* L) { * Cycle through showing FPS or Average Frametime in heads up info */ int toggleFrametimeType(lua_State* L) { - int nArguments = lua_gettop(L); - if (nArguments != 1) - return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments); + int nArguments = lua_gettop(L); + if (nArguments != 1) + return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments); - const int type = lua_type(L, -1); - if (type != LUA_TNUMBER) - return luaL_error(L, "Expected argument of type 'number'"); - int t = lua_tonumber(L, -1); - OsEng.renderEngine().toggleFrametimeType(t); - return 0; + const int type = lua_type(L, -1); + if (type != LUA_TNUMBER) + return luaL_error(L, "Expected argument of type 'number'"); + int t = lua_tonumber(L, -1); + OsEng.renderEngine().toggleFrametimeType(t); + return 0; } /** diff --git a/src/util/camera.cpp b/src/util/camera.cpp index f03bc6856b..b270b2adec 100644 --- a/src/util/camera.cpp +++ b/src/util/camera.cpp @@ -36,7 +36,7 @@ namespace openspace { ////////////////////////////////////////////////////////////////////////////////////// - // CAMERA // + // CAMERA // ////////////////////////////////////////////////////////////////////////////////////// namespace { @@ -246,7 +246,7 @@ namespace openspace { } ////////////////////////////////////////////////////////////////////////////////////// - // SGCT INTERNAL // + // SGCT INTERNAL // ////////////////////////////////////////////////////////////////////////////////////// Camera::SgctInternal::SgctInternal() : _viewMatrix() diff --git a/src/util/powerscaledscalar.cpp b/src/util/powerscaledscalar.cpp index 82c305379b..4828e3d97d 100644 --- a/src/util/powerscaledscalar.cpp +++ b/src/util/powerscaledscalar.cpp @@ -77,7 +77,7 @@ float PowerScaledScalar::lengthf() const { } double PowerScaledScalar::lengthd() const { - return static_cast(_data[0]) * pow(k, static_cast(_data[1])); + return static_cast(_data[0]) * pow(k, static_cast(_data[1])); } PowerScaledScalar& PowerScaledScalar::operator=(const PowerScaledScalar &rhs) {