Fixed sphere-ray collision

master
Sebastian 15 年前
父節點 71be63329c
當前提交 1442cf02d5

@ -65,14 +65,13 @@ Punkt3D Sphere::getPos() const {
int Sphere::getIntersectionParam(const Ray &ray, float *param1, float *param2) {
int numerg;
// ax^2 + bx + c = 0
segl::Punkt3D ehv(1.0f, 1.0f, 1.0f);
float a = ray.dir*ehv;
float b = 2*(ray.pos*ehv + pos*ehv);
float c = ray.pos*ray.pos + pos*pos - 2*(ray.pos*pos) - radius*radius;
float a = ray.dir * ray.dir;
float b = 2 * ray.dir * (ray.pos - pos);
float c = ray.pos * ray.pos - 2 * ray.pos * pos + pos * pos - radius * radius;
float p = b/a;
float q = c/a;
std::cout << p << " " << q << std::endl;
if((p*p)/4.0f<q) {
numerg = 0;
} else if((p*p)/4.0f==q) {

載入中…
取消
儲存