Skip to content

Commit

Permalink
Changes necessary for GLM 0.9.6.1 upgrade; primarily moving things fr…
Browse files Browse the repository at this point in the history
…om glm::detail to glm::
  • Loading branch information
andrewfb committed Jan 26, 2015
1 parent 57e1c6b commit 39fe5fb
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 57 deletions.
2 changes: 1 addition & 1 deletion include/cinder/Area.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class Area {

bool contains( const ivec2 &offset ) const;
template<typename T>
bool contains( const glm::detail::tvec2<T, glm::defaultp> &offset ) const { return contains( ivec2( (int32_t)math<T>::ceil( offset. x ), (int32_t)math<T>::ceil( offset.y ) ) ); }
bool contains( const glm::tvec2<T, glm::defaultp> &offset ) const { return contains( ivec2( (int32_t)math<T>::ceil( offset. x ), (int32_t)math<T>::ceil( offset.y ) ) ); }
bool intersects( const Area &area ) const;

//! Expands the Area to include \a point in its interior
Expand Down
1 change: 0 additions & 1 deletion include/cinder/Cinder.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
#endif
#endif

#define GLM_FORCE_RADIANS
#include "glm/fwd.hpp"

#include <cstdint>
Expand Down
2 changes: 1 addition & 1 deletion include/cinder/Frustum.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class Frustum {
public:
enum { NEAR, FAR, LEFT, RIGHT, TOP, BOTTOM };

typedef glm::detail::tvec3<T, glm::defaultp> Vec3T;
typedef glm::tvec3<T, glm::defaultp> Vec3T;

public:
Frustum() {}
Expand Down
28 changes: 14 additions & 14 deletions include/cinder/Matrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,26 +80,26 @@ class ParallelTransport {
};

template<typename T>
glm::detail::tmat4x4<T,glm::defaultp> firstFrame(
const glm::detail::tvec3<T,glm::defaultp> &firstPoint,
const glm::detail::tvec3<T,glm::defaultp> &secondPoint,
const glm::detail::tvec3<T,glm::defaultp> &thirdPoint
glm::tmat4x4<T,glm::defaultp> firstFrame(
const glm::tvec3<T,glm::defaultp> &firstPoint,
const glm::tvec3<T,glm::defaultp> &secondPoint,
const glm::tvec3<T,glm::defaultp> &thirdPoint
);

template<typename T>
glm::detail::tmat4x4<T,glm::defaultp> nextFrame(
const glm::detail::tmat4x4<T,glm::defaultp> &prevMatrix,
const glm::detail::tvec3<T,glm::defaultp> &prevPoint,
const glm::detail::tvec3<T,glm::defaultp> &curPoint,
glm::detail::tvec3<T,glm::defaultp> prevTangent,
glm::detail::tvec3<T,glm::defaultp> curTangent
glm::tmat4x4<T,glm::defaultp> nextFrame(
const glm::tmat4x4<T,glm::defaultp> &prevMatrix,
const glm::tvec3<T,glm::defaultp> &prevPoint,
const glm::tvec3<T,glm::defaultp> &curPoint,
glm::tvec3<T,glm::defaultp> prevTangent,
glm::tvec3<T,glm::defaultp> curTangent
);

template<typename T>
glm::detail::tmat4x4<T,glm::defaultp> lastFrame(
const glm::detail::tmat4x4<T,glm::defaultp> &prevMatrix,
const glm::detail::tvec3<T,glm::defaultp> &prevPoint,
const glm::detail::tvec3<T,glm::defaultp> &lastPoint
glm::tmat4x4<T,glm::defaultp> lastFrame(
const glm::tmat4x4<T,glm::defaultp> &prevMatrix,
const glm::tvec3<T,glm::defaultp> &prevPoint,
const glm::tvec3<T,glm::defaultp> &lastPoint
);

} // namespace cinder
4 changes: 2 additions & 2 deletions include/cinder/MatrixAffine2.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ class MatrixAffine2
public:
typedef T TYPE;
typedef T value_type;
typedef glm::detail::tvec2<T, glm::defaultp> Vec2T;
typedef glm::detail::tvec3<T, glm::defaultp> Vec3T;
typedef glm::tvec2<T, glm::defaultp> Vec2T;
typedef glm::tvec3<T, glm::defaultp> Vec3T;

static const size_t MEM_LEN = sizeof(T)*6;

Expand Down
2 changes: 1 addition & 1 deletion include/cinder/Plane.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace cinder {
template<typename T>
class Plane {
public:
typedef glm::detail::tvec3<T, glm::defaultp> Vec3T;
typedef glm::tvec3<T, glm::defaultp> Vec3T;

Plane() {}
Plane( const Vec3T &v1, const Vec3T &v2, const Vec3T &v3 );
Expand Down
4 changes: 2 additions & 2 deletions include/cinder/Rect.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ template<typename T> class MatrixAffine2;
template<typename T>
class RectT {
public:
typedef glm::detail::tvec2<T, glm::defaultp> Vec2T;
typedef glm::tvec2<T, glm::defaultp> Vec2T;

RectT() {}
//! Initializes the rectangle to be the bounding box of \a points
Expand Down Expand Up @@ -75,7 +75,7 @@ class RectT {

//! Is a point \a pt inside the rectangle
template<typename Y>
bool contains( const glm::detail::tvec2<Y, glm::defaultp> &pt ) const { return ( pt.x >= x1 ) && ( pt.x <= x2 ) && ( pt.y >= y1 ) && ( pt.y <= y2 ); }
bool contains( const glm::tvec2<Y, glm::defaultp> &pt ) const { return ( pt.x >= x1 ) && ( pt.x <= x2 ) && ( pt.y >= y1 ) && ( pt.y <= y2 ); }
bool contains( const Vec2T &pt ) const { return ( pt.x >= x1 ) && ( pt.x <= x2 ) && ( pt.y >= y1 ) && ( pt.y <= y2 ); }
//! Returns whether \a rect intersects with this
bool intersects( const RectT &rect ) const;
Expand Down
10 changes: 5 additions & 5 deletions include/cinder/Vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,20 @@ using glm::dvec4;

//! Returns a vector which is orthogonal to \a vec
template<typename T, glm::precision P>
glm::detail::tvec3<T, P> orthogonal( const glm::detail::tvec3<T, P> &vec )
glm::tvec3<T, P> orthogonal( const glm::tvec3<T, P> &vec )
{
if( math<T>::abs( vec.y ) < (T)0.99 ) // abs(dot(u, Y)), somewhat arbitrary epsilon
return glm::detail::tvec3<T, P>( -vec.z, 0, vec.x ); // cross( this, Y )
return glm::tvec3<T, P>( -vec.z, 0, vec.x ); // cross( this, Y )
else
return glm::detail::tvec3<T, P>( 0, vec.z, -vec.y ); // cross( this, X )
return glm::tvec3<T, P>( 0, vec.z, -vec.y ); // cross( this, X )
}

template<typename T, glm::precision P>
glm::detail::tvec3<T, P> slerp( const glm::detail::tvec3<T, P> &a, const glm::detail::tvec3<T, P> &b, T t )
glm::tvec3<T, P> slerp( const glm::tvec3<T, P> &a, const glm::tvec3<T, P> &b, T t )
{
T cosAlpha, alpha, sinAlpha;
T t1, t2;
glm::detail::tvec3<T, P> result;
glm::tvec3<T, P> result;

// get cosine of angle between vectors (-1 -> 1)
cosAlpha = glm::dot( a, b );
Expand Down
56 changes: 28 additions & 28 deletions src/cinder/Matrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,30 +36,30 @@ namespace cinder {
// vectors <firstPoint,secondPoint> and <firstPoint,thirdPoint> are co-linears, an arbitrary twist value will
// be chosen.
template<typename T>
glm::detail::tmat4x4<T,glm::defaultp> firstFrame(
const glm::detail::tvec3<T,glm::defaultp> &firstPoint,
const glm::detail::tvec3<T,glm::defaultp> &secondPoint,
const glm::detail::tvec3<T,glm::defaultp> &thirdPoint
glm::tmat4x4<T,glm::defaultp> firstFrame(
const glm::tvec3<T,glm::defaultp> &firstPoint,
const glm::tvec3<T,glm::defaultp> &secondPoint,
const glm::tvec3<T,glm::defaultp> &thirdPoint
)
{
glm::detail::tvec3<T,glm::defaultp> t = normalize( secondPoint - firstPoint );
glm::tvec3<T,glm::defaultp> t = normalize( secondPoint - firstPoint );

glm::detail::tvec3<T,glm::defaultp> n = normalize( cross( t, thirdPoint - firstPoint ) );
glm::tvec3<T,glm::defaultp> n = normalize( cross( t, thirdPoint - firstPoint ) );
if( length( n ) == 0.0f ) {
int i = fabs( t[0] ) < fabs( t[1] ) ? 0 : 1;
if( fabs( t[2] ) < fabs( t[i] ) ) i = 2;

glm::detail::tvec3<T,glm::defaultp> v( (T)0.0, (T)0.0, (T)0.0 ); v[i] = (T)1.0;
glm::tvec3<T,glm::defaultp> v( (T)0.0, (T)0.0, (T)0.0 ); v[i] = (T)1.0;
n = normalize( cross( t, v ) );
}

glm::detail::tvec3<T,glm::defaultp> b = cross( t, n );
glm::tvec3<T,glm::defaultp> b = cross( t, n );

glm::detail::tmat4x4<T,glm::defaultp> M;
M[0] = glm::detail::tvec4<T,glm::defaultp>( b, 0 );
M[1] = glm::detail::tvec4<T,glm::defaultp>( n, 0 );
M[2] = glm::detail::tvec4<T,glm::defaultp>( t, 0 );
M[3] = glm::detail::tvec4<T,glm::defaultp>( firstPoint, 1 );
glm::tmat4x4<T,glm::defaultp> M;
M[0] = glm::tvec4<T,glm::defaultp>( b, 0 );
M[1] = glm::tvec4<T,glm::defaultp>( n, 0 );
M[2] = glm::tvec4<T,glm::defaultp>( t, 0 );
M[3] = glm::tvec4<T,glm::defaultp>( firstPoint, 1 );

return M;

Expand All @@ -71,15 +71,15 @@ glm::detail::tmat4x4<T,glm::defaultp> firstFrame(
// frame defined by the previously computed transformation matrix and the
// new point and tangent vector along the curve.
template<typename T>
glm::detail::tmat4x4<T,glm::defaultp> nextFrame(
const glm::detail::tmat4x4<T,glm::defaultp> &prevMatrix,
const glm::detail::tvec3<T,glm::defaultp> &prevPoint,
const glm::detail::tvec3<T,glm::defaultp> &curPoint,
glm::detail::tvec3<T,glm::defaultp> prevTangent,
glm::detail::tvec3<T,glm::defaultp> curTangent
glm::tmat4x4<T,glm::defaultp> nextFrame(
const glm::tmat4x4<T,glm::defaultp> &prevMatrix,
const glm::tvec3<T,glm::defaultp> &prevPoint,
const glm::tvec3<T,glm::defaultp> &curPoint,
glm::tvec3<T,glm::defaultp> prevTangent,
glm::tvec3<T,glm::defaultp> curTangent
)
{
glm::detail::tvec3<T,glm::defaultp> axis( 0 ); // Rotation axis.
glm::tvec3<T,glm::defaultp> axis( 0 ); // Rotation axis.
T r = 0; // Rotation angle.

if( ( length( prevTangent ) != 0 ) && ( length( curTangent ) != 0 ) ) {
Expand All @@ -95,14 +95,14 @@ glm::detail::tmat4x4<T,glm::defaultp> nextFrame(
}

if( ( length( axis ) != 0 ) && ( r != 0 ) ) {
glm::detail::tmat4x4<T,glm::defaultp> R = glm::rotate( r, axis );
glm::detail::tmat4x4<T,glm::defaultp> Tj = glm::translate( curPoint );
glm::detail::tmat4x4<T,glm::defaultp> Ti = glm::translate( -prevPoint );
glm::tmat4x4<T,glm::defaultp> R = glm::rotate( r, axis );
glm::tmat4x4<T,glm::defaultp> Tj = glm::translate( curPoint );
glm::tmat4x4<T,glm::defaultp> Ti = glm::translate( -prevPoint );

return Tj * R * Ti * prevMatrix;
}
else {
glm::detail::tmat4x4<T,glm::defaultp> Tr = glm::translate( curPoint - prevPoint );
glm::tmat4x4<T,glm::defaultp> Tr = glm::translate( curPoint - prevPoint );

return Tr * prevMatrix;
}
Expand All @@ -114,10 +114,10 @@ glm::detail::tmat4x4<T,glm::defaultp> nextFrame(
// frame defined by the previously computed transformation matrix and the
// last point along the curve.
template<typename T>
glm::detail::tmat4x4<T,glm::defaultp> lastFrame(
const glm::detail::tmat4x4<T,glm::defaultp> &prevMatrix,
const glm::detail::tvec3<T,glm::defaultp> &prevPoint,
const glm::detail::tvec3<T,glm::defaultp> &lastPoint
glm::tmat4x4<T,glm::defaultp> lastFrame(
const glm::tmat4x4<T,glm::defaultp> &prevMatrix,
const glm::tvec3<T,glm::defaultp> &prevPoint,
const glm::tvec3<T,glm::defaultp> &lastPoint
)
{
return glm::translate( lastPoint - prevPoint ) * prevMatrix;
Expand Down
4 changes: 2 additions & 2 deletions src/cinder/PolyLine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@ void PolyLineT<T>::offset( const T &offsetBy )
}

template<typename T>
T linearYatX( const glm::detail::tvec2<T, glm::defaultp> p[2], T x )
T linearYatX( const glm::tvec2<T, glm::defaultp> p[2], T x )
{
if( p[0].x == p[1].x ) return p[0].y;
return p[0].y + (p[1].y - p[0].y) * (x - p[0].x) / (p[1].x - p[0].x);
}

template<typename T>
size_t linearCrossings( const glm::detail::tvec2<T, glm::defaultp> p[2], const vec2 &pt )
size_t linearCrossings( const glm::tvec2<T, glm::defaultp> p[2], const vec2 &pt )
{
if( (p[0].x < pt.x && pt.x <= p[1].x ) ||
(p[1].x < pt.x && pt.x <= p[0].x )) {
Expand Down

0 comments on commit 39fe5fb

Please sign in to comment.