Format
This commit is contained in:
parent
e2d03642f4
commit
394ff3b0ae
7 changed files with 20 additions and 20 deletions
|
@ -9,7 +9,7 @@ CappedCylinder::CappedCylinder(const Vector3 &base, const Vector3 &direction, do
|
||||||
}
|
}
|
||||||
|
|
||||||
int CappedCylinder::findRayIntersection(const InfiniteRay &ray, Vector3 *first_intersection,
|
int CappedCylinder::findRayIntersection(const InfiniteRay &ray, Vector3 *first_intersection,
|
||||||
Vector3 *second_intersection) const {
|
Vector3 *second_intersection) const {
|
||||||
if (not container.checkRayIntersection(ray)) {
|
if (not container.checkRayIntersection(ray)) {
|
||||||
// We don't hit the containing sphere at all
|
// We don't hit the containing sphere at all
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -34,8 +34,8 @@ int CappedCylinder::findRayIntersection(const InfiniteRay &ray, Vector3 *first_i
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else // count == 1
|
} else {
|
||||||
{
|
// count == 1
|
||||||
if (checkPointProjection(first_intersection)) {
|
if (checkPointProjection(first_intersection)) {
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -9,7 +9,7 @@ InfiniteCylinder::InfiniteCylinder(const InfiniteRay &axis, double radius) : axi
|
||||||
}
|
}
|
||||||
|
|
||||||
int InfiniteCylinder::findRayIntersection(const InfiniteRay &ray, Vector3 *first_intersection,
|
int InfiniteCylinder::findRayIntersection(const InfiniteRay &ray, Vector3 *first_intersection,
|
||||||
Vector3 *second_intersection) const {
|
Vector3 *second_intersection) const {
|
||||||
/*
|
/*
|
||||||
* Original algorithm has been altered, because it didn't work with non-(0,0,0) axis origin.
|
* Original algorithm has been altered, because it didn't work with non-(0,0,0) axis origin.
|
||||||
* Maybe some optimizations could be made from this.
|
* Maybe some optimizations could be made from this.
|
||||||
|
|
|
@ -60,19 +60,19 @@ bool SpaceSegment::intersectBoundingBox(const SpaceSegment &bbox) const {
|
||||||
double tmax = min(min(max(t1, t2), max(t3, t4)), max(t5, t6));
|
double tmax = min(min(max(t1, t2), max(t3, t4)), max(t5, t6));
|
||||||
|
|
||||||
// if tmax < 0, ray (line) is intersecting AABB, but whole AABB is behing us
|
// if tmax < 0, ray (line) is intersecting AABB, but whole AABB is behing us
|
||||||
//double t;
|
// double t;
|
||||||
if (tmax < 0.0) {
|
if (tmax < 0.0) {
|
||||||
//t = tmax;
|
// t = tmax;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if tmin > tmax, ray doesn't intersect AABB
|
// if tmin > tmax, ray doesn't intersect AABB
|
||||||
if (tmin > tmax) {
|
if (tmin > tmax) {
|
||||||
//t = tmax;
|
// t = tmax;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//t = tmin;
|
// t = tmin;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ int Sphere::checkRayIntersection(const InfiniteRay &ray) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
int Sphere::findRayIntersection(const InfiniteRay &ray, Vector3 *first_intersection,
|
int Sphere::findRayIntersection(const InfiniteRay &ray, Vector3 *first_intersection,
|
||||||
Vector3 *second_intersection) const {
|
Vector3 *second_intersection) const {
|
||||||
Vector3 L = ray.getOrigin().sub(center);
|
Vector3 L = ray.getOrigin().sub(center);
|
||||||
double b = 2.0 * ray.getDirection().dotProduct(L);
|
double b = 2.0 * ray.getDirection().dotProduct(L);
|
||||||
double c = L.dotProduct(L) - radius2;
|
double c = L.dotProduct(L) - radius2;
|
||||||
|
|
|
@ -10,13 +10,13 @@
|
||||||
VegetationModelDefinition::VegetationModelDefinition(DefinitionNode *parent) : DefinitionNode(parent, "model") {
|
VegetationModelDefinition::VegetationModelDefinition(DefinitionNode *parent) : DefinitionNode(parent, "model") {
|
||||||
solid_material = new SurfaceMaterial(Color(0.2, 0.15, 0.15));
|
solid_material = new SurfaceMaterial(Color(0.2, 0.15, 0.15));
|
||||||
solid_material->reflection = 0.002;
|
solid_material->reflection = 0.002;
|
||||||
solid_material->shininess = 2.0;
|
solid_material->shininess = 1.0;
|
||||||
solid_material->hardness = 0.3;
|
solid_material->hardness = 0.3;
|
||||||
solid_material->validate();
|
solid_material->validate();
|
||||||
|
|
||||||
foliage_material = new SurfaceMaterial(Color(0.4, 0.8, 0.45));
|
foliage_material = new SurfaceMaterial(Color(0.4, 0.8, 0.45));
|
||||||
foliage_material->reflection = 0.007;
|
foliage_material->reflection = 0.007;
|
||||||
foliage_material->shininess = 12.0;
|
foliage_material->shininess = 2.0;
|
||||||
foliage_material->hardness = 0.2;
|
foliage_material->hardness = 0.2;
|
||||||
foliage_material->validate();
|
foliage_material->validate();
|
||||||
|
|
||||||
|
|
|
@ -169,14 +169,14 @@ const int deltaSRUnit = 5;
|
||||||
const int deltaSMUnit = 6;
|
const int deltaSMUnit = 6;
|
||||||
const int deltaJUnit = 7;
|
const int deltaJUnit = 7;
|
||||||
|
|
||||||
unsigned int reflectanceTexture; // unit 0, ground reflectance texture
|
unsigned int reflectanceTexture; // unit 0, ground reflectance texture
|
||||||
unsigned int transmittanceTexture; // unit 1, T table
|
unsigned int transmittanceTexture; // unit 1, T table
|
||||||
unsigned int irradianceTexture; // unit 2, E table
|
unsigned int irradianceTexture; // unit 2, E table
|
||||||
unsigned int inscatterTexture; // unit 3, S table
|
unsigned int inscatterTexture; // unit 3, S table
|
||||||
unsigned int deltaETexture; // unit 4, deltaE table
|
unsigned int deltaETexture; // unit 4, deltaE table
|
||||||
unsigned int deltaSRTexture; // unit 5, deltaS table (Rayleigh part)
|
unsigned int deltaSRTexture; // unit 5, deltaS table (Rayleigh part)
|
||||||
unsigned int deltaSMTexture; // unit 6, deltaS table (Mie part)
|
unsigned int deltaSMTexture; // unit 6, deltaS table (Mie part)
|
||||||
unsigned int deltaJTexture; // unit 7, deltaJ table
|
unsigned int deltaJTexture; // unit 7, deltaJ table
|
||||||
|
|
||||||
unsigned int transmittanceProg;
|
unsigned int transmittanceProg;
|
||||||
unsigned int irradiance1Prog;
|
unsigned int irradiance1Prog;
|
||||||
|
|
|
@ -34,8 +34,8 @@ TEST(InfiniteCylinder, getRayIntersection2) {
|
||||||
int intersect_count;
|
int intersect_count;
|
||||||
Vector3 p1, p2;
|
Vector3 p1, p2;
|
||||||
|
|
||||||
intersect_count = cylinder.findRayIntersection(
|
intersect_count =
|
||||||
InfiniteRay::fromPoints(Vector3(0.0, 1.5, 0.0), Vector3(0.0, 1.5, 2.0)), &p1, &p2);
|
cylinder.findRayIntersection(InfiniteRay::fromPoints(Vector3(0.0, 1.5, 0.0), Vector3(0.0, 1.5, 2.0)), &p1, &p2);
|
||||||
EXPECT_EQ(2, intersect_count);
|
EXPECT_EQ(2, intersect_count);
|
||||||
EXPECT_VECTOR3_COORDS(p1, 0.0, 1.5, 0.5);
|
EXPECT_VECTOR3_COORDS(p1, 0.0, 1.5, 0.5);
|
||||||
EXPECT_VECTOR3_COORDS(p2, 0.0, 1.5, 1.5);
|
EXPECT_VECTOR3_COORDS(p2, 0.0, 1.5, 1.5);
|
||||||
|
|
Loading…
Reference in a new issue