44 lines
1,009 B
C++
44 lines
1,009 B
C++
#pragma once
|
|
|
|
#include <glm/vec2.hpp>
|
|
#include <glm/vec3.hpp>
|
|
|
|
namespace util {
|
|
|
|
float randf_0_1();
|
|
float randf_m1_1();
|
|
|
|
glm::vec2 randv2_m1_1();
|
|
glm::vec2 randv2_0_1();
|
|
|
|
float deg2rad(float deg);
|
|
float rad2deg(float rad);
|
|
|
|
/**
|
|
* 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;
|
|
};
|
|
}
|