equal
deleted
inserted
replaced
92 virtual bool intersect_all(const Ray &ray, float dist, vector<float> &allts) = 0; |
92 virtual bool intersect_all(const Ray &ray, float dist, vector<float> &allts) = 0; |
93 |
93 |
94 // normal at point P |
94 // normal at point P |
95 virtual Vector3 normal(Vector3 &P) = 0; |
95 virtual Vector3 normal(Vector3 &P) = 0; |
96 |
96 |
97 virtual BBox get_bbox(); |
97 virtual BBox get_bbox() = 0; |
98 }; |
98 }; |
99 |
99 |
100 class Sphere: public Shape |
100 class Sphere: public Shape |
101 { |
101 { |
102 float sqr_radius; |
102 float sqr_radius; |
109 sqr_radius(aradius*aradius), inv_radius(1.0f/aradius), |
109 sqr_radius(aradius*aradius), inv_radius(1.0f/aradius), |
110 center(acenter), radius(aradius) { material = amaterial; } |
110 center(acenter), radius(aradius) { material = amaterial; } |
111 bool intersect(const Ray &ray, float &dist); |
111 bool intersect(const Ray &ray, float &dist); |
112 bool intersect_all(const Ray &ray, float dist, vector<float> &allts); |
112 bool intersect_all(const Ray &ray, float dist, vector<float> &allts); |
113 Vector3 normal(Vector3 &P) { return (P - center) * inv_radius; }; |
113 Vector3 normal(Vector3 &P) { return (P - center) * inv_radius; }; |
|
114 BBox get_bbox(); |
114 }; |
115 }; |
115 |
116 |
116 class Plane: public Shape |
117 class Plane: public Shape |
117 { |
118 { |
118 public: |
119 public: |
124 Plane(const Vector3 &normal, const Vector3 &point): |
125 Plane(const Vector3 &normal, const Vector3 &point): |
125 N(normal), d(0) { /*TODO*/}; |
126 N(normal), d(0) { /*TODO*/}; |
126 bool intersect(const Ray &ray, float &dist); |
127 bool intersect(const Ray &ray, float &dist); |
127 bool intersect_all(const Ray &ray, float dist, vector<float> &allts) {return false;}; |
128 bool intersect_all(const Ray &ray, float dist, vector<float> &allts) {return false;}; |
128 Vector3 normal(Vector3 &) { return N; }; |
129 Vector3 normal(Vector3 &) { return N; }; |
|
130 BBox get_bbox(); |
129 }; |
131 }; |
130 |
132 |
131 class Triangle: public Shape |
133 class Triangle: public Shape |
132 { |
134 { |
133 int k; // dominant axis |
135 int k; // dominant axis |