Skip to content

Commit d446720

Browse files
authored
Merge branch 'master' into matlab-warnings
2 parents 1d75a9c + daa6e04 commit d446720

26 files changed

+201
-93
lines changed

Superbuild/GLMExternal.cmake

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,12 @@ SET_PROPERTY(DIRECTORY PROPERTY "EP_BASE" ${ep_base})
3030
# git checkout -q will silence message about detached head (harmless).
3131
ExternalProject_Add(GLM_external
3232
GIT_REPOSITORY "https://github.com/g-truc/glm.git"
33-
GIT_TAG "0.9.4.6"
33+
GIT_TAG "0.9.9.8"
3434
CONFIGURE_COMMAND ""
3535
BUILD_COMMAND ""
3636
INSTALL_COMMAND ""
3737
CMAKE_CACHE_ARGS
3838
-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}
39-
-DGLM_SWIZZLE:BOOL=ON
4039
-DGLM_FORCE_CXX03:BOOL=ON
4140
-DGLM_FORCE_RADIANS:BOOL=ON
4241
)

src/Externals/spire/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ SET(BUILD_SHARED_LIBS OFF)
4444

4545
SET(SCI_SPIRE_LIBRARY ${SPIRE_LIBRARY_NAME} CACHE INTERNAL "spire library name." FORCE)
4646

47-
ADD_DEFINITIONS(-DGLM_SWIZZLE -DGLM_FORCE_CXX03 -DGLM_FORCE_RADIANS)
47+
ADD_DEFINITIONS(-DGLM_FORCE_CXX03 -DGLM_FORCE_RADIANS)
4848

4949
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
5050

src/Externals/spire/arc-ball/ArcBall.cpp

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@
2727

2828

2929
#include "ArcBall.hpp"
30-
#include <iostream>
30+
#include <glm/gtx/vec_swizzle.hpp>
3131

3232
namespace spire {
3333

3434
//------------------------------------------------------------------------------
35-
ArcBall::ArcBall(const glm::vec3& center, glm::float_t radius, bool inverted, const glm::mat4& screenToTCS) :
35+
ArcBall::ArcBall(const glm::vec3& center, float radius, bool inverted, const glm::mat4& screenToTCS) :
3636
mScreenToTCS(screenToTCS),
3737
mCenter(center),
3838
mRadius(radius),
@@ -51,13 +51,9 @@ namespace spire {
5151
//------------------------------------------------------------------------------
5252
glm::vec3 ArcBall::mouseOnSphere(const glm::vec3& tscMouse)
5353
{
54-
glm::vec3 ballMouse;
54+
glm::vec3 ballMouse(xy(tscMouse - mCenter) / mRadius, 0.0);
5555

56-
// (m - C) / R
57-
ballMouse.x = (tscMouse.x - mCenter.x) / mRadius;
58-
ballMouse.y = (tscMouse.y - mCenter.y) / mRadius;
59-
60-
glm::float_t mag_sq = glm::dot(ballMouse, ballMouse);
56+
float mag_sq = glm::dot(ballMouse, ballMouse);
6157
if (mag_sq > 1.0)
6258
{
6359
// Since we are outside of the sphere, map to the visible boundary of the sphere.
@@ -79,26 +75,24 @@ glm::vec3 ArcBall::mouseOnSphere(const glm::vec3& tscMouse)
7975
void ArcBall::beginDrag(const glm::vec2& msc)
8076
{
8177
mQDown = mQNow;
82-
mVSphereDown = mouseOnSphere((mScreenToTCS * glm::vec4(msc, 0.0f, 1.0)).xyz());
78+
mVSphereDown = mouseOnSphere(xyz(mScreenToTCS * glm::vec4(msc, 0.0f, 1.0f)));
8379
}
8480

8581
//------------------------------------------------------------------------------
8682
void ArcBall::drag(const glm::vec2& msc)
8783
{
88-
glm::vec3 mVSphereNow = mouseOnSphere((mScreenToTCS * glm::vec4(msc, 0.0, 1.0)).xyz());
84+
glm::vec3 mVSphereNow = mouseOnSphere(xyz(mScreenToTCS * glm::vec4(msc, 0.0f, 1.0f)));
8985

9086
// Construct a quaternion from two points on the unit sphere.
9187
glm::quat mQDrag = quatFromUnitSphere(mVSphereDown, mVSphereNow);
9288
mQNow = mQDrag * mQDown;
93-
if(glm::dot(mVSphereDown, mVSphereNow) < 0.0)
94-
beginDrag(msc);
9589
}
9690

9791
//------------------------------------------------------------------------------
9892
void ArcBall::setLocationOnSphere(glm::vec3 location, glm::vec3 up)
9993
{
10094
glm::mat4 mMatNow = glm::lookAt(location, glm::vec3(0.0f), up);
101-
mQNow = glm::quat_cast(mMatNow);
95+
mQNow = glm::quat_cast(mMatNow);
10296
}
10397

10498
//------------------------------------------------------------------------------
@@ -107,7 +101,7 @@ glm::quat ArcBall::quatFromUnitSphere(const glm::vec3& from, const glm::vec3& to
107101
//TODO: check if cross is 0 before normalize. Crashes on Windows
108102
auto c = glm::cross(from, to);
109103
if (c == glm::vec3(0, 0, 0))
110-
return {};
104+
return glm::quat(1.0, 0.0, 0.0, 0.0);
111105

112106
glm::vec3 axis = glm::normalize(c);
113107

src/Externals/spire/arc-ball/ArcBall.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ class SCISHARE ArcBall
6363
/// default is 0.75.
6464
/// \param screenToTCS Transformation from screen coordinates
6565
/// to TCS. \p center and \p radius are given in TCS.
66-
ArcBall(const glm::vec3& center, glm::float_t radius, bool inverted = false,
67-
const glm::mat4& screenToTCS = glm::mat4());
66+
ArcBall(const glm::vec3& center, float radius, bool inverted = false,
67+
const glm::mat4& screenToTCS = glm::mat4(1.0f));
6868

6969
/// Initiate an arc ball drag given the mouse click in screen coordinates.
7070
/// \param mouseScreenCoords Mouse screen coordinates.
@@ -100,7 +100,7 @@ class SCISHARE ArcBall
100100
/// Transform from screen coordinates to the target coordinate system.
101101
glm::mat4 mScreenToTCS;
102102
glm::vec3 mCenter; ///< Center of the arcball in target coordinate system.
103-
glm::float_t mRadius; ///< Radius of the arcball in target coordinate system.
103+
float mRadius; ///< Radius of the arcball in target coordinate system.
104104
bool invertHemisphere;
105105

106106
glm::vec3 mVSphereDown; ///< vDown mapped to the sphere of 'mRadius' centered at 'mCenter' in TCS.

src/Externals/spire/arc-look-at/ArcLookAt.cpp

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131

3232
#include "ArcLookAt.hpp"
3333
#include <arc-ball/ArcBall.hpp>
34+
#include <glm/gtx/vec_swizzle.hpp>
35+
#include <glm/gtx/transform.hpp>
3436

3537
namespace spire {
3638

@@ -73,9 +75,9 @@ void ArcLookAt::doRotation(const glm::vec2& ssPos)
7375
}
7476

7577
//------------------------------------------------------------------------------
76-
void ArcLookAt::doZoom(glm::float_t camZoom, int zoomSpeed)
78+
void ArcLookAt::doZoom(float camZoom, int zoomSpeed)
7779
{
78-
glm::float_t prevDistance = mCamDistance;
80+
float prevDistance = mCamDistance;
7981
zoomSpeed = zoomSpeed > 1 ? zoomSpeed : 2;
8082
camZoom /= zoomSpeed;
8183
camZoom *= prevDistance;
@@ -90,11 +92,11 @@ void ArcLookAt::doZoom(const glm::vec2& ssPos)
9092
// Use distance delta from center of screen to control zoom.
9193
// Will need a new variable to control this.
9294
glm::vec2 delta = ssPos - mReferenceScreenPos;
93-
glm::float_t xScale = 4.0f;
94-
glm::float_t yScale = 4.0f;
95+
float xScale = 4.0f;
96+
float yScale = 4.0f;
9597

96-
glm::float_t prevDistance = mCamDistance;
97-
glm::float_t camZoom = mCamDistance + (delta.x) * xScale + (-delta.y) * yScale;
98+
float prevDistance = mCamDistance;
99+
float camZoom = mCamDistance + (delta.x) * xScale + (-delta.y) * yScale;
98100
mCamDistance = camZoom;
99101
if (mCamDistance <= 0)
100102
mCamDistance = prevDistance;
@@ -103,11 +105,8 @@ void ArcLookAt::doZoom(const glm::vec2& ssPos)
103105
//------------------------------------------------------------------------------
104106
glm::mat4 ArcLookAt::getWorldViewTransform() const
105107
{
106-
glm::mat4 finalTrafo;
107-
finalTrafo[3].xyz() = -mCamLookAt;
108-
finalTrafo = mArcBall->getTransformation() * finalTrafo;
109-
finalTrafo[3][2] += -mCamDistance;
110-
108+
auto finalTrafo = mArcBall->getTransformation() * glm::translate(glm::mat4(1.0f), -mCamLookAt);
109+
finalTrafo[3][2] -= mCamDistance;
111110
return finalTrafo;
112111
}
113112

src/Externals/spire/arc-look-at/ArcLookAt.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class SCISHARE ArcLookAt
7777

7878
/// Dollys the camera towards(negative) / away(positive) from the look at
7979
/// point. With vairiable zoomspeed.
80-
void doZoom(glm::float_t camZoom, int zoomSpeed = 65);
80+
void doZoom(float camZoom, int zoomSpeed = 65);
8181

8282
/// Uses a custom function to determine camera zoom. Downwards and to the
8383
/// right increases size, upwards or to the left decreases size
@@ -94,8 +94,8 @@ class SCISHARE ArcLookAt
9494
void setView(const glm::vec3& view, const glm::vec3& up);
9595

9696
/// Retrieves the camera's distance away from the look at point.
97-
glm::float_t getDistance() const {return mCamDistance;}
98-
void setDistance(const glm::float_t f) {mCamDistance = f;}
97+
float getDistance() const {return mCamDistance;}
98+
void setDistance(const float f) {mCamDistance = f;}
9999

100100
/// Retrieves the current lookat point.
101101
glm::vec3 getLookAt() const {return mCamLookAt;}
@@ -115,7 +115,7 @@ class SCISHARE ArcLookAt
115115
std::unique_ptr<spire::ArcBall> mArcBall;
116116

117117
glm::vec3 mCamLookAt {0.0f}; ///< Current lookat position.
118-
glm::float_t mCamDistance {3.0f}; ///< Distance from look-at.
118+
float mCamDistance {3.0f}; ///< Distance from look-at.
119119

120120
// The following are reference variables set when doReferenceDown is called.
121121
glm::vec2 mReferenceScreenPos;

src/Externals/spire/es-general/comp/StaticCamera.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ namespace gen {
4343
// care anything about the camera itself.
4444
struct StaticCameraData
4545
{
46-
glm::mat4 view;
47-
glm::mat4 projection;
48-
glm::mat4 viewProjection;
46+
glm::mat4 view {1.0f};
47+
glm::mat4 projection {1.0f};
48+
glm::mat4 viewProjection {1.0f};
4949

5050
// Misc variables. fovy only applies to perspective matrices.
5151
float fovy;

src/Externals/spire/es-general/comp/Transform.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ namespace gen {
3939
struct Transform
4040
{
4141
// -- Data --
42-
glm::mat4 transform;
42+
glm::mat4 transform {1.0f};
4343

4444
// -- Functions --
4545
void setPosition(const glm::vec3& pos)

src/Externals/spire/es-render/comp/CommonUniforms.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include <gl-shaders/GLShader.hpp>
3434

3535
#include <es-general/util/Math.hpp>
36+
#include <glm/gtx/vec_swizzle.hpp>
3637

3738
#include "CommonUniforms.hpp"
3839

@@ -130,7 +131,7 @@ void CommonUniforms::applyCommonUniforms(const glm::mat4& objectToWorld,
130131
case U_CAM_VIEW_VEC:
131132
{
132133
glm::mat4 view = cam.getInverseView();
133-
glm::vec3 viewVec = view[2].xyz();
134+
glm::vec3 viewVec = xyz(view[2]);
134135
vec = -viewVec; // Our projection matrix looks down negative Z.
135136
GL(glUniform3f(uniformLocation[i], vec.x, vec.y, vec.z));
136137
break;
@@ -145,7 +146,7 @@ void CommonUniforms::applyCommonUniforms(const glm::mat4& objectToWorld,
145146
case U_CAM_UP:
146147
{
147148
glm::mat4 view = cam.getInverseView();
148-
vec = view[1].xyz();
149+
vec = xyz(view[1]);
149150
GL(glUniform3f(uniformLocation[i], vec.x, vec.y, vec.z));
150151
break;
151152
}

src/Externals/spire/glm-aabb/AABB.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ AABB::AABB()
3636
setNull();
3737
}
3838

39-
AABB::AABB(const glm::vec3& center, glm::float_t radius)
39+
AABB::AABB(const glm::vec3& center, float radius)
4040
{
4141
setNull();
4242
extend(center, radius);
@@ -59,7 +59,7 @@ AABB::~AABB()
5959
{
6060
}
6161

62-
void AABB::extend(glm::float_t val)
62+
void AABB::extend(float val)
6363
{
6464
if (!isNull())
6565
{
@@ -82,7 +82,7 @@ void AABB::extend(const glm::vec3& p)
8282
}
8383
}
8484

85-
void AABB::extend(const glm::vec3& p, glm::float_t radius)
85+
void AABB::extend(const glm::vec3& p, float radius)
8686
{
8787
glm::vec3 r(radius);
8888
if (!isNull())
@@ -106,13 +106,13 @@ void AABB::extend(const AABB& aabb)
106106
}
107107
}
108108

109-
void AABB::extendDisk(const glm::vec3& c, const glm::vec3& n, glm::float_t r)
109+
void AABB::extendDisk(const glm::vec3& c, const glm::vec3& n, float r)
110110
{
111111
if (glm::length(n) < 1.e-12) { extend(c); return; }
112112
glm::vec3 norm = glm::normalize(n);
113-
glm::float_t x = sqrt(1 - norm.x) * r;
114-
glm::float_t y = sqrt(1 - norm.y) * r;
115-
glm::float_t z = sqrt(1 - norm.z) * r;
113+
float x = sqrt(1 - norm.x) * r;
114+
float y = sqrt(1 - norm.y) * r;
115+
float z = sqrt(1 - norm.z) * r;
116116
extend(c + glm::vec3(x,y,z));
117117
extend(c - glm::vec3(x,y,z));
118118
}
@@ -125,12 +125,12 @@ glm::vec3 AABB::getDiagonal() const
125125
return glm::vec3(0);
126126
}
127127

128-
glm::float_t AABB::getLongestEdge() const
128+
float AABB::getLongestEdge() const
129129
{
130130
return glm::compMax(getDiagonal());
131131
}
132132

133-
glm::float_t AABB::getShortestEdge() const
133+
float AABB::getShortestEdge() const
134134
{
135135
return glm::compMin(getDiagonal());
136136
}
@@ -140,7 +140,7 @@ glm::vec3 AABB::getCenter() const
140140
if (!isNull())
141141
{
142142
glm::vec3 d = getDiagonal();
143-
return mMin + (d * glm::float_t(0.5));
143+
return mMin + (0.5f * d);
144144
}
145145
else
146146
{
@@ -210,11 +210,11 @@ AABB::INTERSECTION_TYPE AABB::intersect(const AABB& b) const
210210
}
211211

212212

213-
bool AABB::isSimilarTo(const AABB& b, glm::float_t diff) const
213+
bool AABB::isSimilarTo(const AABB& b, float diff) const
214214
{
215215
if (isNull() || b.isNull()) return false;
216216

217-
glm::vec3 acceptable_diff=( (getDiagonal()+b.getDiagonal()) / glm::float_t(2.0))*diff;
217+
glm::vec3 acceptable_diff = ((getDiagonal()+b.getDiagonal()) * 0.5f) * diff;
218218
glm::vec3 min_diff(mMin-b.mMin);
219219
min_diff = glm::vec3(fabs(min_diff.x),fabs(min_diff.y),fabs(min_diff.z));
220220
if (min_diff.x > acceptable_diff.x) return false;

0 commit comments

Comments
 (0)