Debug problems

This commit is contained in:
hal8174 2025-09-13 21:44:54 +02:00
parent 0a9748a1b7
commit 479cf89e8d
Signed by: hal8174
SSH key fingerprint: SHA256:NN98ZYwnrreQLSOV/g+amY7C3yL/mS1heD7bi5t6PPw
5 changed files with 18 additions and 7 deletions

View file

@ -66,6 +66,10 @@ impl AABB {
&& pos.z <= self.max.z
}
pub fn contains_aabb(self, aabb: Self) -> bool {
self.contains_point(aabb.min) && self.contains_point(aabb.max)
}
pub fn size(self) -> Dir3 {
Dir3::new(
self.max.x - self.min.x,
@ -92,7 +96,7 @@ impl AABB {
Float::min(Float::max(t_min_z, t_max_z), max),
);
if t_min < t_max {
if t_min <= t_max {
Some(t_min)
} else {
None

View file

@ -57,7 +57,8 @@ impl BasicCamera {
pos: Pos3::new(tm.get(3, 0), tm.get(3, 1), tm.get(3, 2)),
dir: Dir3::new(tm.get(2, 0), tm.get(2, 1), tm.get(2, 2)),
h: l * Dir3::new(tm.get(0, 0), tm.get(0, 1), tm.get(0, 2)),
v: l * Dir3::new(tm.get(1, 0), tm.get(1, 1), tm.get(1, 2)),
v: l * ((height as Float) / (width as Float))
* Dir3::new(tm.get(1, 0), tm.get(1, 1), tm.get(1, 2)),
}
}
pub fn from_look_at(

View file

@ -30,7 +30,8 @@ AttributeBegin
"rgb tex1" [.1 .1 .1] "rgb tex2" [.8 .8 .8]
Material "diffuse" "texture reflectance" "checks"
Translate 0 0 -1
Shape "bilinearmesh"
Shape "trianglemesh"
"integer indices" [ 0 1 2 1 3 2 ]
"point3 P" [ -20 -20 0 20 -20 0 -20 20 0 20 20 0 ]
"point2 uv" [ 0 0 1 0 1 1 0 1 ]
AttributeEnd

View file

@ -64,7 +64,7 @@ impl<T: BvhData> Bvh<T> {
unreachable!()
};
if count <= min {
if count <= Index::max(1, min) {
return;
}
@ -86,6 +86,9 @@ impl<T: BvhData> Bvh<T> {
let left_aabb = data.get_aabb_range(start..(start + mid));
let right_aabb = data.get_aabb_range((start + mid)..(start + count));
assert!(aabb.contains_aabb(left_aabb));
assert!(aabb.contains_aabb(right_aabb));
let i = bvh.len() as Index;
bvh[node] = Node::Inner {
left: i,

View file

@ -242,16 +242,18 @@ fn main() {
Float::to_radians(fov),
);
// dbg!(&c);
// let c = BasicCamera::from_look_at(
// args.width,
// args.height,
// Pos3::new(-0.3, 0.5, -0.5),
// Pos3::new(0.0, 0.75, 0.0),
// Pos3::new(3.0, 5.0, -5.0),
// Pos3::new(0.0, 0.075, 0.0),
// Dir3::new(0.0, 1.0, 0.0),
// Float::to_radians(2.0 * 37.0),
// );
// dbg!(c);
// dbg!(&c);
let s = &pbrt.scene;