Fixed sphere-ray collision
This commit is contained in:
parent
71be63329c
commit
1442cf02d5
|
@ -65,14 +65,13 @@ Punkt3D Sphere::getPos() const {
|
||||||
int Sphere::getIntersectionParam(const Ray &ray, float *param1, float *param2) {
|
int Sphere::getIntersectionParam(const Ray &ray, float *param1, float *param2) {
|
||||||
int numerg;
|
int numerg;
|
||||||
// ax^2 + bx + c = 0
|
// ax^2 + bx + c = 0
|
||||||
segl::Punkt3D ehv(1.0f, 1.0f, 1.0f);
|
float a = ray.dir * ray.dir;
|
||||||
float a = ray.dir*ehv;
|
float b = 2 * ray.dir * (ray.pos - pos);
|
||||||
float b = 2*(ray.pos*ehv + pos*ehv);
|
float c = ray.pos * ray.pos - 2 * ray.pos * pos + pos * pos - radius * radius;
|
||||||
float c = ray.pos*ray.pos + pos*pos - 2*(ray.pos*pos) - radius*radius;
|
|
||||||
|
|
||||||
float p = b/a;
|
float p = b/a;
|
||||||
float q = c/a;
|
float q = c/a;
|
||||||
|
std::cout << p << " " << q << std::endl;
|
||||||
if((p*p)/4.0f<q) {
|
if((p*p)/4.0f<q) {
|
||||||
numerg = 0;
|
numerg = 0;
|
||||||
} else if((p*p)/4.0f==q) {
|
} else if((p*p)/4.0f==q) {
|
||||||
|
|
Loading…
Reference in New Issue