Skip to content
Snippets Groups Projects
Commit 60c37c75 authored by Sebastian Pape's avatar Sebastian Pape
Browse files

Fixed some errors found in the prestudy

Wrong ray width
Wrong bounding boxes for lenses
parent 2b792399
No related branches found
No related tags found
No related merge requests found
...@@ -64,7 +64,7 @@ RT_PROGRAM void laser_caster(){ ...@@ -64,7 +64,7 @@ RT_PROGRAM void laser_caster(){
//convert to normal distrubution //convert to normal distrubution
float r = sqrtf(-2*log(random.x)); float r = sqrtf(-2*log(random.x));
float theta = 2*3.141592654f*random.y; float theta = 2*3.141592654f*random.y;
random = clamp(make_float2(r*cosf(theta), r*sinf(theta)), -4.5f, 4.5f) * laserBeamWidth/PERCENTILE; random = clamp(make_float2(r*cosf(theta), r*sinf(theta)), -4.5f, 4.5f) * laserBeamWidth * 0.5 /PERCENTILE;
ray_origin += (launch_index.z != 0) * (laser_right * random.x + laser_up * random.y); ray_origin += (launch_index.z != 0) * (laser_right * random.x + laser_up * random.y);
PerRayData_radiance_iterative prd; PerRayData_radiance_iterative prd;
......
...@@ -57,7 +57,7 @@ RT_PROGRAM void intersect(int primIdx) ...@@ -57,7 +57,7 @@ RT_PROGRAM void intersect(int primIdx)
} else{ } else{
h1.t = intersectPlane(center + orientation*(halfCylinderLength), ray, -orientation, lensRadius, scene_epsilon); h1.t = intersectPlane(center + orientation*(halfCylinderLength), ray, -orientation, lensRadius, scene_epsilon);
h1.p = ray.origin + h1.t*ray.direction; h1.p = ray.origin + h1.t*ray.direction;
h1.normal = -orientation; h1.normal = orientation;
} }
perHitData h2; perHitData h2;
...@@ -70,7 +70,7 @@ RT_PROGRAM void intersect(int primIdx) ...@@ -70,7 +70,7 @@ RT_PROGRAM void intersect(int primIdx)
} else{ } else{
h2.t = intersectPlane(center - orientation*(halfCylinderLength), ray, orientation, lensRadius, scene_epsilon); h2.t = intersectPlane(center - orientation*(halfCylinderLength), ray, orientation, lensRadius, scene_epsilon);
h2.p = ray.origin + h2.t*ray.direction; h2.p = ray.origin + h2.t*ray.direction;
h2.normal = orientation; h2.normal = -orientation;
} }
perHitData h3; perHitData h3;
......
...@@ -353,17 +353,26 @@ void Lens::SetLensSideTypes(LensSideType type1, LensSideType type2) { ...@@ -353,17 +353,26 @@ void Lens::SetLensSideTypes(LensSideType type1, LensSideType type2) {
type_2_ = type2; type_2_ = type2;
geometry_["halfCylinderLength"]->setFloat(GetCylinderLength(thickness) / 2); geometry_["halfCylinderLength"]->setFloat(GetCylinderLength(thickness) / 2);
MarkDirty();
} }
void Lens::RecalculateBoundingBox() { void Lens::RecalculateBoundingBox() {
auto o = geometry_["orientation"]->getFloat3(); auto o = geometry_["orientation"]->getFloat3();
float t = geometry_["halfCylinderLength"]->getFloat() * 2; float hc = geometry_["halfCylinderLength"]->getFloat();
float lr = geometry_["lensRadius"]->getFloat(); float lr = geometry_["lensRadius"]->getFloat();
t = GetThickness(t); float r1 = geometry_["radius"]->getFloat();
float r2 = geometry_["radius2"]->getFloat();
// thickness of the halfspheres
float halfThickness1 = r1 - sqrtf(-lr * lr + r1 * r1);
if (type_1_ == PLANE || type_1_ == CONCAVE) halfThickness1 = 0;
float halfThickness2 = r2 - sqrtf(-lr * lr + r2 * r2);
if (type_2_ == PLANE || type_2_ == CONCAVE) halfThickness2 = 0;
auto bb = auto bb = ComputeAABBFromCylinder(
ComputeAABBFromCylinder(glm::vec3(o.x, o.y, o.z), t / 2.0f, t / 2.0f, lr); glm::vec3(o.x, o.y, o.z), hc + halfThickness1, hc + halfThickness2, lr);
selector_->SetCollider(bb[0], bb[1]); selector_->SetCollider(bb[0], bb[1]);
selector_->ExternalUpdate(); selector_->ExternalUpdate();
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment