Skip to content

Conversation

@plexoos
Copy link
Member

@plexoos plexoos commented Jul 30, 2025

No description provided.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cpp-linter Review

Used clang-format v16.0.6

Click here for the full clang-format patch
diff --git a/CSG/csg_intersect_leaf_newcone.h b/CSG/csg_intersect_leaf_newcone.h
index 740ac5a..9801725 100644
--- a/CSG/csg_intersect_leaf_newcone.h
+++ b/CSG/csg_intersect_leaf_newcone.h
@@ -101,2 +101,2 @@ void intersect_leaf_newcone( bool& valid_isect, float4& isect, const quad& q0, c
-    const float t_cand = fminf(roots) ; 
-    
+    const float t_cand = fminf(roots) ;
+
@@ -104 +104 @@ void intersect_leaf_newcone( bool& valid_isect, float4& isect, const quad& q0, c
-    float3 n = normalize(make_float3(intersection_point.x, intersection_point.y, (z0 - intersection_point.z)*tth2));
+    float3 n = normalize(make_float3(intersection_point.x, intersection_point.y, (z0 - intersection_point.z) * tth2));
@@ -111,2 +110,0 @@ void intersect_leaf_newcone( bool& valid_isect, float4& isect, const quad& q0, c
-
-

Have any feedback or feature suggestions? Share it here.

@plexoos plexoos force-pushed the workaround-for-open-cones branch from d561f7b to 628d53b Compare August 18, 2025 23:55
@plexoos plexoos force-pushed the workaround-for-open-cones branch from 628d53b to b26739f Compare September 3, 2025 14:56
@github-actions github-actions bot dismissed their stale review September 3, 2025 14:57

outdated suggestion

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cpp-linter Review

Used clang-format v18.1.3

Click here for the full clang-format patch
diff --git a/CSG/csg_intersect_leaf_newcone.h b/CSG/csg_intersect_leaf_newcone.h
index 740ac5a..9801725 100644
--- a/CSG/csg_intersect_leaf_newcone.h
+++ b/CSG/csg_intersect_leaf_newcone.h
@@ -101,2 +101,2 @@ void intersect_leaf_newcone( bool& valid_isect, float4& isect, const quad& q0, c
-    const float t_cand = fminf(roots) ; 
-    
+    const float t_cand = fminf(roots) ;
+
@@ -104 +104 @@ void intersect_leaf_newcone( bool& valid_isect, float4& isect, const quad& q0, c
-    float3 n = normalize(make_float3(intersection_point.x, intersection_point.y, (z0 - intersection_point.z)*tth2));
+    float3 n = normalize(make_float3(intersection_point.x, intersection_point.y, (z0 - intersection_point.z) * tth2));
@@ -111,2 +110,0 @@ void intersect_leaf_newcone( bool& valid_isect, float4& isect, const quad& q0, c
-
-

Have any feedback or feature suggestions? Share it here.

@github-actions github-actions bot dismissed their stale review September 3, 2025 15:01

outdated suggestion

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cpp-linter Review

Used clang-format v18.1.3

Click here for the full clang-format patch
diff --git a/CSG/csg_intersect_leaf_newcone.h b/CSG/csg_intersect_leaf_newcone.h
index 2967d49..3bc042d 100644
--- a/CSG/csg_intersect_leaf_newcone.h
+++ b/CSG/csg_intersect_leaf_newcone.h
@@ -101 +101 @@ void intersect_leaf_newcone( bool& valid_isect, float4& isect, const quad& q0, c
-    const float t_cand = fminf(roots) ;
+    const float t_cand = fminf(roots);
@@ -111,2 +110,0 @@ void intersect_leaf_newcone( bool& valid_isect, float4& isect, const quad& q0, c
-
-

Have any feedback or feature suggestions? Share it here.

@plexoos plexoos force-pushed the workaround-for-open-cones branch from 77c33d5 to 5cb7458 Compare October 13, 2025 17:09
@github-actions github-actions bot dismissed their stale review October 13, 2025 17:10

outdated suggestion

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cpp-linter Review

Used clang-format v18.1.3

Click here for the full clang-format patch
diff --git a/CSG/csg_intersect_leaf_newcone.h b/CSG/csg_intersect_leaf_newcone.h
index 2967d49..3bc042d 100644
--- a/CSG/csg_intersect_leaf_newcone.h
+++ b/CSG/csg_intersect_leaf_newcone.h
@@ -101 +101 @@ void intersect_leaf_newcone( bool& valid_isect, float4& isect, const quad& q0, c
-    const float t_cand = fminf(roots) ;
+    const float t_cand = fminf(roots);
@@ -111,2 +110,0 @@ void intersect_leaf_newcone( bool& valid_isect, float4& isect, const quad& q0, c
-
-

Have any feedback or feature suggestions? Share it here.

}
isect.w = t_cand ;
}
const float t_cand = fminf(roots) ;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-format suggestion

Suggested change
const float t_cand = fminf(roots) ;
const float t_cand = fminf(roots);

Copilot AI review requested due to automatic review settings December 5, 2025 20:26
@plexoos plexoos force-pushed the workaround-for-open-cones branch from 5cb7458 to 94857f9 Compare December 5, 2025 20:26
@github-actions github-actions bot dismissed their stale review December 5, 2025 20:27

outdated suggestion

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cpp-linter Review

Used clang-format v18.1.3

Click here for the full clang-format patch
diff --git a/CSG/csg_intersect_leaf_newcone.h b/CSG/csg_intersect_leaf_newcone.h
index 2967d49..3bc042d 100644
--- a/CSG/csg_intersect_leaf_newcone.h
+++ b/CSG/csg_intersect_leaf_newcone.h
@@ -101 +101 @@ void intersect_leaf_newcone( bool& valid_isect, float4& isect, const quad& q0, c
-    const float t_cand = fminf(roots) ;
+    const float t_cand = fminf(roots);
@@ -111,2 +110,0 @@ void intersect_leaf_newcone( bool& valid_isect, float4& isect, const quad& q0, c
-
-

Have any feedback or feature suggestions? Share it here.

}
isect.w = t_cand ;
}
const float t_cand = fminf(roots) ;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-format suggestion

Suggested change
const float t_cand = fminf(roots) ;
const float t_cand = fminf(roots);

Comment on lines 111 to 116


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-format suggestion

Please remove the line(s)

  • 111
  • 112

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request attempts to fix incorrect ray intersections with open cones by simplifying the intersection logic. However, the implementation introduces several critical bugs that will cause incorrect rendering behavior.

Key changes:

  • Removed validation logic that checks if t_cand represents a valid intersection
  • Eliminated cap-specific normal calculations (normals for end cap intersections)
  • Simplified to always compute cone surface normals regardless of intersection type

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 103 to 109
float3 intersection_point = make_float3(o.x + t_cand * d.x, o.y + t_cand * d.y, o.z + t_cand * d.z);
float3 n = normalize(make_float3(intersection_point.x, intersection_point.y, (z0 - intersection_point.z) * tth2));

isect.x = n.x;
isect.y = n.y;
isect.z = n.z;
isect.w = t_cand;
Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The valid_isect output parameter is never set, which will cause incorrect behavior in calling code. All other intersection functions (e.g., intersect_leaf_sphere, intersect_leaf_cylinder) validate t_cand and set valid_isect = t_cand > t_min && t_cand < RT_DEFAULT_MAX before populating the intersection result. Without this check, invalid intersections (when all roots are disqualified and t_cand == RT_DEFAULT_MAX) will be processed as valid.

Suggested change
float3 intersection_point = make_float3(o.x + t_cand * d.x, o.y + t_cand * d.y, o.z + t_cand * d.z);
float3 n = normalize(make_float3(intersection_point.x, intersection_point.y, (z0 - intersection_point.z) * tth2));
isect.x = n.x;
isect.y = n.y;
isect.z = n.z;
isect.w = t_cand;
valid_isect = t_cand > t_min && t_cand < RT_DEFAULT_MAX ;
if (valid_isect)
{
float3 intersection_point = make_float3(o.x + t_cand * d.x, o.y + t_cand * d.y, o.z + t_cand * d.z);
float3 n = normalize(make_float3(intersection_point.x, intersection_point.y, (z0 - intersection_point.z) * tth2));
isect.x = n.x;
isect.y = n.y;
isect.z = n.z;
isect.w = t_cand;
}
else
{
isect = make_float4(0.f, 0.f, 0.f, RT_DEFAULT_MAX);
}

Copilot uses AI. Check for mistakes.
Comment on lines 104 to 105
float3 n = normalize(make_float3(intersection_point.x, intersection_point.y, (z0 - intersection_point.z) * tth2));

Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The normal calculation always uses the cone surface formula, even when the intersection is with a cap (t_cand == t_cap1 or t_cap2). The removed code correctly handled cap normals as (0, 0, ±1), which point along the z-axis. Using the cone surface normal formula for cap intersections will produce incorrect normals. Cap intersections should be detected and handled separately, as done in the original code and in intersect_leaf_cylinder (line 79).

Suggested change
float3 n = normalize(make_float3(intersection_point.x, intersection_point.y, (z0 - intersection_point.z) * tth2));
float3 n;
if (t_cand == t_cap1) {
n = make_float3(0.f, 0.f, -1.f); // lower cap normal
} else if (t_cand == t_cap2) {
n = make_float3(0.f, 0.f, 1.f); // upper cap normal
} else {
n = normalize(make_float3(intersection_point.x, intersection_point.y, (z0 - intersection_point.z) * tth2));
}

Copilot uses AI. Check for mistakes.
Comment on lines 103 to 109
float3 intersection_point = make_float3(o.x + t_cand * d.x, o.y + t_cand * d.y, o.z + t_cand * d.z);
float3 n = normalize(make_float3(intersection_point.x, intersection_point.y, (z0 - intersection_point.z) * tth2));

isect.x = n.x;
isect.y = n.y;
isect.z = n.z;
isect.w = t_cand;
Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When t_cand == RT_DEFAULT_MAX (no valid intersection found), the normal calculation can produce undefined results. Specifically, if the intersection point computed with RT_DEFAULT_MAX happens to be at or near the cone apex (where x=0, y=0, z=z0), the vector passed to normalize() will be zero or near-zero, causing normalization of a zero-length vector. The computation should only proceed if t_cand represents a valid intersection (i.e., t_cand < RT_DEFAULT_MAX).

Suggested change
float3 intersection_point = make_float3(o.x + t_cand * d.x, o.y + t_cand * d.y, o.z + t_cand * d.z);
float3 n = normalize(make_float3(intersection_point.x, intersection_point.y, (z0 - intersection_point.z) * tth2));
isect.x = n.x;
isect.y = n.y;
isect.z = n.z;
isect.w = t_cand;
if (t_cand < RT_DEFAULT_MAX)
{
float3 intersection_point = make_float3(o.x + t_cand * d.x, o.y + t_cand * d.y, o.z + t_cand * d.z);
float3 n = normalize(make_float3(intersection_point.x, intersection_point.y, (z0 - intersection_point.z) * tth2));
isect.x = n.x;
isect.y = n.y;
isect.z = n.z;
isect.w = t_cand;
valid_isect = true;
}
else
{
isect.x = 0.f;
isect.y = 0.f;
isect.z = 0.f;
isect.w = RT_DEFAULT_MAX;
valid_isect = false;
}

Copilot uses AI. Check for mistakes.
@plexoos
Copy link
Member Author

plexoos commented Dec 8, 2025

@ggalgoczi Are you going to run this workaround by Simon?

@ggalgoczi
Copy link
Contributor

Will ask him about it later on, after finished with the photon leakage. However this is a special case of a cone in question here. I think for now we should not merge since it opens up even closed cones.

@plexoos plexoos force-pushed the workaround-for-open-cones branch from 94857f9 to 1ec9ad7 Compare December 18, 2025 16:19
@github-actions
Copy link
Contributor

Cpp-Linter Report ⚠️

Some files did not pass the configured checks!

clang-format (v18.1.3) reports: 1 file(s) not formatted
  • CSG/csg_intersect_leaf_newcone.h

Have any feedback or feature suggestions? Share it here.

@github-actions github-actions bot dismissed their stale review December 18, 2025 16:19

outdated suggestion

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cpp-linter Review

Used clang-format v18.1.3

Click here for the full clang-format patch
diff --git a/CSG/csg_intersect_leaf_newcone.h b/CSG/csg_intersect_leaf_newcone.h
index 371c713..a4e7aa3 100644
--- a/CSG/csg_intersect_leaf_newcone.h
+++ b/CSG/csg_intersect_leaf_newcone.h
@@ -101,2 +101,2 @@ void intersect_leaf_newcone( bool& valid_isect, float4& isect, const quad& q0, c
-    const float t_cand = fminf(roots) ; 
-    
+    const float t_cand = fminf(roots) ;
+
@@ -107 +107,2 @@ void intersect_leaf_newcone( bool& valid_isect, float4& isect, const quad& q0, c
-        float3 n = normalize(make_float3(intersection_point.x, intersection_point.y, (z0 - intersection_point.z)*tth2));
+        float3 n =
+            normalize(make_float3(intersection_point.x, intersection_point.y, (z0 - intersection_point.z) * tth2));

Have any feedback or feature suggestions? Share it here.

Comment on lines 101 to 102
const float t_cand = fminf(roots) ;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-format suggestion

Suggested change
const float t_cand = fminf(roots) ;
const float t_cand = fminf(roots) ;

}
isect.w = t_cand ;
float3 intersection_point = make_float3(o.x + t_cand * d.x, o.y + t_cand * d.y, o.z + t_cand * d.z);
float3 n = normalize(make_float3(intersection_point.x, intersection_point.y, (z0 - intersection_point.z)*tth2));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-format suggestion

Suggested change
float3 n = normalize(make_float3(intersection_point.x, intersection_point.y, (z0 - intersection_point.z)*tth2));
float3 n =
normalize(make_float3(intersection_point.x, intersection_point.y, (z0 - intersection_point.z) * tth2));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants