2016-09-27 16:23:58 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <glm/vec2.hpp>
|
2016-10-02 18:10:43 +00:00
|
|
|
#include <glm/vec3.hpp>
|
2016-09-27 16:23:58 +00:00
|
|
|
|
|
|
|
namespace util {
|
|
|
|
|
|
|
|
float randf_0_1();
|
|
|
|
float randf_m1_1();
|
|
|
|
|
|
|
|
glm::vec2 randv2_m1_1();
|
|
|
|
glm::vec2 randv2_0_1();
|
2016-09-28 09:35:56 +00:00
|
|
|
|
|
|
|
float deg2rad(float deg);
|
|
|
|
float rad2deg(float rad);
|
2016-10-02 18:10:43 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Test for intersection in positive direction of a ray.
|
|
|
|
* TODO: support inside?
|
|
|
|
*/
|
|
|
|
class IntersectionTest {
|
|
|
|
public:
|
|
|
|
IntersectionTest();
|
|
|
|
|
|
|
|
// creates a valid intersection point at distance d
|
|
|
|
IntersectionTest(float d);
|
|
|
|
|
|
|
|
// intersection distance
|
|
|
|
float distance() const;
|
|
|
|
|
|
|
|
// returns true if there's an interseciton.
|
|
|
|
bool valid() const;
|
|
|
|
|
|
|
|
// return true if there's an intersection. then intersectionPoint is filled
|
|
|
|
// with details.
|
|
|
|
bool raySphere(
|
|
|
|
const glm::vec3 &rayPos, const glm::vec3 &rayDir,
|
|
|
|
const glm::vec3 &spherePos, float sphereRadius);
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool m_valid;
|
|
|
|
float m_distance;
|
|
|
|
};
|
2016-09-27 16:23:58 +00:00
|
|
|
}
|