小编mje*_*agh的帖子

如何使用 MDL 对边界框进行命中测试

我正在尝试计算与 MDL 边界框的交集,我的代码基于 WM 的精彩文章,网址为http://metalbyexample.com/picking-hit-testing/#more-738

t0 应该是最近点的想法https://www.scratchapixel.com/lessons/3d-basic-rendering/minimal-ray-tracer-rendering-simple-shapes/ray-sphere-intersection

https://www.scratchapixel.com/lessons/3d-basic-rendering/minimal-ray-tracer-rendering-simple-shapes/ray-box-intersection

但这并没有发生

extension MDLAxisAlignedBoundingBox {

    func intersect(_ ray: Ray) -> float4? {

        var tmin = minBounds
        var tmax = maxBounds

        let inverseDirection = 1 / ray.direction

        var sign : [Int] = [(inverseDirection.x < 0) ? 1 : 0,(inverseDirection.y < 0) ? 1 : 0,(inverseDirection.z < 0) ? 1 : 0]


        var bounds : [float3] = [minBounds,maxBounds]


        var t0 = Float(minBounds.z)

        if ((tmin.x > tmax.y) || (tmin.y > tmax.x)){
            return nil
        } …
Run Code Online (Sandbox Code Playgroud)

3d swift metal metalkit

5
推荐指数
1
解决办法
539
查看次数

标签 统计

3d ×1

metal ×1

metalkit ×1

swift ×1