added Shape::IntersectList for returning a list of intersection points instead of intersections distances; build currently broken; need to update Scene to take into effect this change
git-svn-id: svn://anubis/fart/trunk@56 7f9b0f55-74a9-4bce-be96-3c2cd072584d
This commit is contained in:
parent
47cf177a15
commit
83bb409ef9
@ -6,12 +6,15 @@
|
||||
#include "util/Ray.h"
|
||||
#include "util/Vector.h"
|
||||
#include "util/Transform.h"
|
||||
#include <vector>
|
||||
|
||||
class Shape
|
||||
{
|
||||
public:
|
||||
typedef std::vector<Vector> IntersectList;
|
||||
|
||||
Shape();
|
||||
virtual Solver::Result intersect(const Ray & ray) = 0;
|
||||
virtual IntersectList intersect(const Ray & ray) = 0;
|
||||
virtual Vector getNormalAt(const Vector & pt) = 0;
|
||||
|
||||
void setTransform(Transform & t)
|
||||
|
@ -11,11 +11,11 @@ Sphere::Sphere(double radius)
|
||||
m_radius2 = radius * radius;
|
||||
}
|
||||
|
||||
Solver::Result Sphere::intersect(const Ray & ray)
|
||||
Shape::IntersectList Sphere::intersect(const Ray & ray)
|
||||
{
|
||||
Ray ray_inv = m_inverse.transform_ray(ray);
|
||||
|
||||
Solver::Result res;
|
||||
IntersectList res;
|
||||
QuadraticSolver solver(1.0,
|
||||
2 * ( ray_inv.getOrigin()[0] * ray_inv.getDirection()[0]
|
||||
+ ray_inv.getOrigin()[1] * ray_inv.getDirection()[1]
|
||||
@ -29,7 +29,8 @@ Solver::Result Sphere::intersect(const Ray & ray)
|
||||
{
|
||||
if (quadSolutions.results[i] >= 0.0)
|
||||
{
|
||||
res.results[res.numResults++] = quadSolutions.results[i];
|
||||
res.push_back(m_transform.transform_point(
|
||||
ray_inv[quadSolutions.results[i]]));
|
||||
}
|
||||
}
|
||||
return res;
|
||||
|
@ -8,7 +8,7 @@ class Sphere : public Shape
|
||||
{
|
||||
public:
|
||||
Sphere(double radius);
|
||||
Solver::Result intersect(const Ray & ray);
|
||||
IntersectList intersect(const Ray & ray);
|
||||
Vector getNormalAt(const Vector & pt);
|
||||
|
||||
private:
|
||||
|
Loading…
x
Reference in New Issue
Block a user