17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-05 21:49:10 +01:00

GLES fixes, update GLM, build fixes

This commit is contained in:
milek7
2018-10-17 16:00:26 +02:00
parent d16d96f2b2
commit 2ffdb35d0f
403 changed files with 32998 additions and 28034 deletions

View File

@@ -1,13 +1,12 @@
/// @ref gtx_intersect
/// @file glm/gtx/intersect.inl
namespace glm
{
template <typename genType>
template<typename genType>
GLM_FUNC_QUALIFIER bool intersectRayPlane
(
genType const & orig, genType const & dir,
genType const & planeOrig, genType const & planeNormal,
genType const& orig, genType const& dir,
genType const& planeOrig, genType const& planeNormal,
typename genType::value_type & intersectionDistance
)
{
@@ -23,51 +22,79 @@ namespace glm
return false;
}
template <typename genType>
template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER bool intersectRayTriangle
(
genType const & orig, genType const & dir,
genType const & v0, genType const & v1, genType const & v2,
genType & baryPosition
vec<3, T, Q> const& orig, vec<3, T, Q> const& dir,
vec<3, T, Q> const& vert0, vec<3, T, Q> const& vert1, vec<3, T, Q> const& vert2,
vec<2, T, Q>& baryPosition, T& distance
)
{
genType e1 = v1 - v0;
genType e2 = v2 - v0;
// find vectors for two edges sharing vert0
vec<3, T, Q> const edge1 = vert1 - vert0;
vec<3, T, Q> const edge2 = vert2 - vert0;
genType p = glm::cross(dir, e2);
// begin calculating determinant - also used to calculate U parameter
vec<3, T, Q> const p = glm::cross(dir, edge2);
typename genType::value_type a = glm::dot(e1, p);
// if determinant is near zero, ray lies in plane of triangle
T const det = glm::dot(edge1, p);
typename genType::value_type Epsilon = std::numeric_limits<typename genType::value_type>::epsilon();
if(a < Epsilon && a > -Epsilon)
return false;
vec<3, T, Q> Perpendicular(0);
typename genType::value_type f = typename genType::value_type(1.0f) / a;
if(det > std::numeric_limits<T>::epsilon())
{
// calculate distance from vert0 to ray origin
vec<3, T, Q> const dist = orig - vert0;
genType s = orig - v0;
baryPosition.x = f * glm::dot(s, p);
if(baryPosition.x < typename genType::value_type(0.0f))
return false;
if(baryPosition.x > typename genType::value_type(1.0f))
return false;
// calculate U parameter and test bounds
baryPosition.x = glm::dot(dist, p);
if(baryPosition.x < static_cast<T>(0) || baryPosition.x > det)
return false;
genType q = glm::cross(s, e1);
baryPosition.y = f * glm::dot(dir, q);
if(baryPosition.y < typename genType::value_type(0.0f))
return false;
if(baryPosition.y + baryPosition.x > typename genType::value_type(1.0f))
return false;
// prepare to test V parameter
Perpendicular = glm::cross(dist, edge1);
baryPosition.z = f * glm::dot(e2, q);
// calculate V parameter and test bounds
baryPosition.y = glm::dot(dir, Perpendicular);
if((baryPosition.y < static_cast<T>(0)) || ((baryPosition.x + baryPosition.y) > det))
return false;
}
else if(det < -std::numeric_limits<T>::epsilon())
{
// calculate distance from vert0 to ray origin
vec<3, T, Q> const dist = orig - vert0;
return baryPosition.z >= typename genType::value_type(0.0f);
// calculate U parameter and test bounds
baryPosition.x = glm::dot(dist, p);
if((baryPosition.x > static_cast<T>(0)) || (baryPosition.x < det))
return false;
// prepare to test V parameter
Perpendicular = glm::cross(dist, edge1);
// calculate V parameter and test bounds
baryPosition.y = glm::dot(dir, Perpendicular);
if((baryPosition.y > static_cast<T>(0)) || (baryPosition.x + baryPosition.y < det))
return false;
}
else
return false; // ray is parallel to the plane of the triangle
T inv_det = static_cast<T>(1) / det;
// calculate distance, ray intersects triangle
distance = glm::dot(edge2, Perpendicular) * inv_det;
baryPosition *= inv_det;
return true;
}
template <typename genType>
template<typename genType>
GLM_FUNC_QUALIFIER bool intersectLineTriangle
(
genType const & orig, genType const & dir,
genType const & vert0, genType const & vert1, genType const & vert2,
genType const& orig, genType const& dir,
genType const& vert0, genType const& vert1, genType const& vert2,
genType & position
)
{
@@ -76,36 +103,36 @@ namespace glm
genType edge1 = vert1 - vert0;
genType edge2 = vert2 - vert0;
genType pvec = cross(dir, edge2);
genType Perpendicular = cross(dir, edge2);
float det = dot(edge1, pvec);
float det = dot(edge1, Perpendicular);
if (det > -Epsilon && det < Epsilon)
return false;
float inv_det = typename genType::value_type(1) / det;
typename genType::value_type inv_det = typename genType::value_type(1) / det;
genType tvec = orig - vert0;
genType Tengant = orig - vert0;
position.y = dot(tvec, pvec) * inv_det;
position.y = dot(Tengant, Perpendicular) * inv_det;
if (position.y < typename genType::value_type(0) || position.y > typename genType::value_type(1))
return false;
genType qvec = cross(tvec, edge1);
genType Cotengant = cross(Tengant, edge1);
position.z = dot(dir, qvec) * inv_det;
position.z = dot(dir, Cotengant) * inv_det;
if (position.z < typename genType::value_type(0) || position.y + position.z > typename genType::value_type(1))
return false;
position.x = dot(edge2, qvec) * inv_det;
position.x = dot(edge2, Cotengant) * inv_det;
return true;
}
template <typename genType>
template<typename genType>
GLM_FUNC_QUALIFIER bool intersectRaySphere
(
genType const & rayStarting, genType const & rayNormalizedDirection,
genType const & sphereCenter, const typename genType::value_type sphereRadiusSquered,
genType const& rayStarting, genType const& rayNormalizedDirection,
genType const& sphereCenter, const typename genType::value_type sphereRadiusSquered,
typename genType::value_type & intersectionDistance
)
{
@@ -122,11 +149,11 @@ namespace glm
return intersectionDistance > Epsilon;
}
template <typename genType>
template<typename genType>
GLM_FUNC_QUALIFIER bool intersectRaySphere
(
genType const & rayStarting, genType const & rayNormalizedDirection,
genType const & sphereCenter, const typename genType::value_type sphereRadius,
genType const& rayStarting, genType const& rayNormalizedDirection,
genType const& sphereCenter, const typename genType::value_type sphereRadius,
genType & intersectionPosition, genType & intersectionNormal
)
{
@@ -140,12 +167,12 @@ namespace glm
return false;
}
template <typename genType>
template<typename genType>
GLM_FUNC_QUALIFIER bool intersectLineSphere
(
genType const & point0, genType const & point1,
genType const & sphereCenter, typename genType::value_type sphereRadius,
genType & intersectionPoint1, genType & intersectionNormal1,
genType const& point0, genType const& point1,
genType const& sphereCenter, typename genType::value_type sphereRadius,
genType & intersectionPoint1, genType & intersectionNormal1,
genType & intersectionPoint2, genType & intersectionNormal2
)
{