include/shapes.h
branchpyrit
changeset 84 6f7fe14782c2
parent 82 930a2d3ecaed
child 85 907a634e5c02
equal deleted inserted replaced
83:e3a2a5b26abb 84:6f7fe14782c2
    52 	Shape() {};
    52 	Shape() {};
    53 	virtual ~Shape() {};
    53 	virtual ~Shape() {};
    54 
    54 
    55 	// first intersection point
    55 	// first intersection point
    56 	virtual bool intersect(const Ray &ray, Float &dist) const = 0;
    56 	virtual bool intersect(const Ray &ray, Float &dist) const = 0;
       
    57 
       
    58 	virtual void intersect_packet(const RayPacket &rays, __m128 &dists, bool *results)
       
    59 	{
       
    60 		results[0] = intersect(rays[0], ((float*)&dists)[0]);
       
    61 		results[1] = intersect(rays[1], ((float*)&dists)[1]);
       
    62 		results[2] = intersect(rays[2], ((float*)&dists)[2]);
       
    63 		results[3] = intersect(rays[3], ((float*)&dists)[3]);
       
    64 	};
    57 
    65 
    58 	// all intersections (only for CSG)
    66 	// all intersections (only for CSG)
    59 	virtual bool intersect_all(const Ray &ray, Float dist, vector<Float> &allts) const = 0;
    67 	virtual bool intersect_all(const Ray &ray, Float dist, vector<Float> &allts) const = 0;
    60 
    68 
    61 	// intersection with AABB
    69 	// intersection with AABB
    93 	bool intersect_all(const Ray &ray, Float dist, vector<Float> &allts) const;
   101 	bool intersect_all(const Ray &ray, Float dist, vector<Float> &allts) const;
    94 	bool intersect_bbox(const BBox &bbox) const;
   102 	bool intersect_bbox(const BBox &bbox) const;
    95 	const Vector3 normal(const Vector3 &P) const { return (P - center) * inv_radius; };
   103 	const Vector3 normal(const Vector3 &P) const { return (P - center) * inv_radius; };
    96 	BBox get_bbox() const;
   104 	BBox get_bbox() const;
    97 	const Vector3 getCenter() const { return center; };
   105 	const Vector3 getCenter() const { return center; };
    98 	const Float getRadius() const { return radius; };
   106 	Float getRadius() const { return radius; };
    99 	ostream & dump(ostream &st) const;
   107 	ostream & dump(ostream &st) const;
   100 };
   108 };
   101 
   109 
   102 /**
   110 /**
   103  * box shape
   111  * box shape