Last modified: 2025-04-07 10:06:13
< 2025-04-06 2025-04-08 >So I have 2 tests failing: "RewriteNoopBlend" because the blend parameters aren't being applied, and "RewriteAllPairsBlends" because it isn't rewriting the tree properly.
In the first case it was because after it does successfully set the blend radius, there is a pass through the tree in which some blends have been "removed" from the blend set, which causes it to explicitly set the blend radius back to 0. So I made it only set the parameters if it's not setting them to 0, on the basis that they start out at 0 and if anything permutes them then it should stay permuted.
Not sure that's quite right, but it passes the test.
And for "RewriteAllPairsBlends"...
Equality check failed: Expected:
"Union(Intersection(Intersection(Intersection(Union(Sphere2,Box1),Union(Sphere2,Negate(Cylinder4))),Intersection(Union(Gyroid3,Box1),Union(Gyroid3,Negate(Cylinder4)))),Union(Intersection(Sphere2,Gyroid3),Gyroid3)),Intersection(Union(Sphere2,Intersection(Box1,Negate(Cylinder4))),Intersection(Box1,Negate(Cylinder4))))"
Actual:
"Intersection(Intersection(Union(Sphere2,Box1),Union(Sphere2,Negate(Cylinder4))),Intersection(Union(Gyroid3,Box1),Union(Gyroid3,Negate(Cylinder4))))"
And this has a different blend radius on all 6 pairs, so it should definitely be rewriting such that each object is a sibling of each other object somewhere in the tree.
And in the check()
pass at the end, it is not saying "Blends not satisfied
for node: ...", which means satisfiesBlends()
is happy.
I added some logging to check()
, and I see that it only is checking
the blends against the root node. Every subsequent node has empty
set.
So:
removeHandledBlends()
thinks some blends are handled when they
actually aren'tremoveHandledBlends()
shouldn't be recursing?Stopping removeHandledBlends()
from recursing makes things worse.
So why does removeHandledBlends()
think all blends are handled?
It is deleting a blend between Box and Cylinder at a node where
left = Union(Sphere, Box)
right = Union(Sphere, Negate(Cylinder))
Ah, it's because it only iterates over the set of remaining blends, instead of the set of all possible ids that could come into the node!
So it just needs to copy the logic from satisfiesBlends()
, and maybe
those two should actually just be one function? satisfiesBlends()
is
true if the set of unhandled blends is empty?
Oh! One issue is that removeHandledBlends()
had some logic
to skip blends where one of the arguments can come out of both
children, on the basis that it can be handled deeper in the tree.
That is not right, because if it were handled deeper it would
have already been removed by a deeper removeHandledBlends()
call.
Now it is only removing 5 of the blends, but I think it is still wrong to remove 5. It should only be removing 4.
OK, fixed, I was initialising the per-surface-pair parameters to
null instead of 0.0, which was then resetting the overallBlendRadius
to null which allows the next pass to disregard it.
So now we're removing the right set of blends - but still not getting
the right answer. And doing multiple passes of rewriteTree()
doesn't
solve it.
I'm thinking I'm going to throw all this away and start again.
A node needs rewriting if it can't handle all of the blends that are asked of it. But that's still too vague. How do you know whether to distribute left or right?
< 2025-04-06 2025-04-08 >