In a nutshell this is the basic algorithm for the rafter module for complex roofs:

Of course the devil is the details and there are a lot of details missing in this picture.

The overall picture seems simple enough however there are a number of special cases where rafters align with ridge boards and the over simplistic boolean subtraction algorithm will not suffice. I will need to try and account for all of those special cases.

The offset is a factor of the ridgeboard, hip rafter, valley rafter or flying hip rafter width. However, as you can see in the detail below when the roof planes are not the same (asymmetric) the offset will not be symmetric and must be calculated, hence the opposing roof plane (pitch) at that edge must be known/tracked. For a ridge board edge the offset will be given by:

offset = T/(1 + tanθ/tanA)

Since the offset is only a function of the ratio of the two opposing pitches this equation should also hold for hips and valleys as well. Note that when the angles are equal the equation degenerates to T/2 as one would expect.

Once all of the offsets are determined then it is merely a matter of generating the new points for the polygon drawn in blue highlighter. Once that polygon (points) is determined it becomes the cutting polygon for the rafters. Technically it is a boolean intersection rather than a subtraction, but that is all semantics.