updated shapes/Cyl::getNormalAt(), added Cyl.h to shapes/Shape.h include list
git-svn-id: svn://anubis/fart/trunk@133 7f9b0f55-74a9-4bce-be96-3c2cd072584d
This commit is contained in:
parent
39e77678ee
commit
2b1603cf26
@ -87,9 +87,7 @@ Shape::IntersectList Cyl::intersect(const Ray & ray)
|
|||||||
double b = m_bottom_radius;
|
double b = m_bottom_radius;
|
||||||
QuadraticSolver solver(Rdx * Rdx + Rdy * Rdy - m2 * Rdz * Rdz,
|
QuadraticSolver solver(Rdx * Rdx + Rdy * Rdy - m2 * Rdz * Rdz,
|
||||||
2.0 * (R0x*Rdx + R0y*Rdy - m2*R0z*Rdz - m*Rdz*b),
|
2.0 * (R0x*Rdx + R0y*Rdy - m2*R0z*Rdz - m*Rdz*b),
|
||||||
R0x*R0x + R0y*R0y
|
R0x*R0x + R0y*R0y - m2*R0z*R0z - b*b - 2*m*R0z*b);
|
||||||
- m2*R0z*R0z - b*b - 2*m*R0z*b
|
|
||||||
);
|
|
||||||
|
|
||||||
Solver::Result solutions = solver.solve();
|
Solver::Result solutions = solver.solve();
|
||||||
for (int i = 0; i < solutions.numResults; i++)
|
for (int i = 0; i < solutions.numResults; i++)
|
||||||
@ -123,6 +121,19 @@ Vector Cyl::getNormalAt(const Vector & pt)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if (m_slope == 0.0)
|
||||||
|
{
|
||||||
|
normal = Vector(local_pt[0], local_pt[1], 0.0);
|
||||||
|
normal.normalize();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
double norm_slope = -1.0 / m_slope;
|
||||||
|
double z = sqrt(local_pt[0]*local_pt[0] + local_pt[1]*local_pt[1])
|
||||||
|
* norm_slope;
|
||||||
|
normal = Vector(local_pt[0], local_pt[1], z);
|
||||||
|
normal.normalize();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return m_transform.transform_normal(normal);
|
return m_transform.transform_normal(normal);
|
||||||
|
@ -40,9 +40,10 @@ class Shape
|
|||||||
refptr<Material> m_material;
|
refptr<Material> m_material;
|
||||||
};
|
};
|
||||||
|
|
||||||
#include "Sphere.h"
|
|
||||||
#include "Plane.h"
|
|
||||||
#include "Box.h"
|
#include "Box.h"
|
||||||
|
#include "Cyl.h"
|
||||||
|
#include "Plane.h"
|
||||||
|
#include "Sphere.h"
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user