Swizzle and implicit binding predicate fixes
dr.cross : Cast return type back to original type
- Use of swizzle operator will return a dr.jit array type. This means for example swizzling a
mi.Vector3freturns adr.*.Array3f
For implicit conversion predicate from dr.jit types, also check dimensions are compatible
- Previously types such as
Array4f->Matrix4<Color3f>would return true as we're just simply checking that the first dimension aligns
Also addresses Mitsuba issue 1280
Wouldn't it be preferable to fix this by changing swizzling so that it preserves the type when the number of array dimensions remains the same?
Somehow this patch prevents casting a Matrix<4, Float> into a Matrix<4, Color<3, Float>> as in the following example:
import mitsuba as mi
mi.set_variant('llvm_ad_rgb_polarized')
print(mi.Spectrum(mi.mueller.depolarizer(1)))
@wjakob I've updated the PR so that instead the swizzle operation returns the original type if the swizzle size is compatible
@Speierers I think I've fixed this now and added some corresponding tests related to this
There will always be a tradeoff between an "excessive" check in the implicit cast predicate, and letting it fail during the actual construction attempt. These change are fair for now, in my opinion.