|
|
|
@ -43,7 +43,7 @@ bool Sphere::collision(const Sphere &s) const {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Sphere::collision(const Ray &r) const {
|
|
|
|
|
return true;
|
|
|
|
|
return (r.dist(pos) <= radius);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Sphere::collision(const Box & b) const {
|
|
|
|
@ -66,26 +66,26 @@ Ray::Ray() {
|
|
|
|
|
dir.set(0.0f, 1.0f, 0.0f);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Ray::Ray(Punkt3D _pos, Punkt3D _dir) {
|
|
|
|
|
Ray::Ray(const Punkt3D &_pos, const Punkt3D &_dir) {
|
|
|
|
|
set(_pos, _dir);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Ray::set(Punkt3D _pos, Punkt3D _dir) {
|
|
|
|
|
void Ray::set(const Punkt3D &_pos, const Punkt3D &_dir) {
|
|
|
|
|
pos = _pos;
|
|
|
|
|
dir = _dir;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Ray::setFromPoints(Punkt3D a, Punkt3D b) {
|
|
|
|
|
void Ray::setFromPoints(const Punkt3D &a, const Punkt3D &b) {
|
|
|
|
|
pos = a;
|
|
|
|
|
dir = b - a;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Punkt3D Ray::get(float x) {
|
|
|
|
|
Punkt3D Ray::get(float x) const {
|
|
|
|
|
return pos + dir*x;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// TODO: Heavy Testing
|
|
|
|
|
bool Ray::onRay(Punkt3D p, int rnd) {
|
|
|
|
|
bool Ray::onRay(Punkt3D p, int rnd) const {
|
|
|
|
|
float r1 = 0.0f, r2 = 0.0f, r3 = 0.0f;
|
|
|
|
|
short fcount = 0;
|
|
|
|
|
bool g1=true, g2=true, g3=true;
|
|
|
|
@ -135,11 +135,19 @@ bool Ray::onRay(Punkt3D p, int rnd) {
|
|
|
|
|
return ((r1 == r2) == r3);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float Ray::dist(Punkt3D p) {
|
|
|
|
|
float Ray::dist(Punkt3D p) const {
|
|
|
|
|
return abs(p - get( getParam(p) ));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float Ray::getParam(Punkt3D p, bool onray) {
|
|
|
|
|
int getIntersectionParam(const std::Ray &ray, float *param1, float *param2) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int getIntersectionParam(const std::Ray &ray, segl::Punkt3D *a, segl::Punkt3D *b) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float Ray::getParam(Punkt3D p, bool onray) const {
|
|
|
|
|
if(onray) {
|
|
|
|
|
if(!onRay(p))
|
|
|
|
|
return 0.0f;
|
|
|
|
|