当前位置: 首页>>代码示例>>C#>>正文


C# INode.IsSolid方法代码示例

本文整理汇总了C#中INode.IsSolid方法的典型用法代码示例。如果您正苦于以下问题:C# INode.IsSolid方法的具体用法?C# INode.IsSolid怎么用?C# INode.IsSolid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在INode的用法示例。


在下文中一共展示了INode.IsSolid方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ProcSubtree

    private void ProcSubtree(float tx0, float ty0, float tz0, float tx1, float ty1, float tz1, INode node,
		bool insideSolidNode, int currentDepth, int? wantedDepth,
		Coords nodeCoords)
    {
        if (!_intersectMultiple && results.Count > 0) {
            return;
        }

        if (tx1 < 0.0 || ty1 < 0.0 || tz1 < 0.0) {
            return;
        }

        if (_debug) {
            var entryDistance = Mathf.Max(tx0, ty0, tz0);

            Debug.DrawLine(_ray.origin, _ray.GetPoint(entryDistance), Color.red, 0, false);
        }

        if (wantedDepth == null) {
            if (node == null) {
                return;
            }

            if (node.IsSolid()) {
                ProcessTerminal(node, tx0, ty0, tz0);
                if (results.Count > 0) {
                    return;
                }
            }
        } else {
            if (!insideSolidNode) {
                //didn't manage to get into a solid node
                if (node == null) {
                    return;
                }

                insideSolidNode = node.IsSolid();
            }

            if (insideSolidNode && currentDepth >= wantedDepth) {
                if (currentDepth == wantedDepth) {
                    ProcessTerminal(nodeCoords, tx0, ty0, tz0);
                } else {
                    //oops, went too deep!!!
                    //trace back to wanted depth

                    var newCoords = new OctreeChildCoords[wantedDepth.Value];

                    for (var i = 0; i < newCoords.Length; ++i) {
                        newCoords[i] = nodeCoords.GetCoord(i);
                    }

                    ProcessTerminal(new Coords(newCoords), tx0, ty0,
                        tz0);
                }

                if (results.Count > 0) {
                    return;
                }
            }
        }

        if (_debug) {
            if (node != null) {
                var bounds = node.GetBounds();
                DrawBounds(bounds, Color.white);
            } else {
                //inside solid node and still going strong baby!
                var bounds = _rootNode.GetChildBounds(nodeCoords);
                DrawBounds(bounds, Color.cyan);
            }
        }

        var txm = 0.5f * (tx0 + tx1);
        var tym = 0.5f * (ty0 + ty1);
        var tzm = 0.5f * (tz0 + tz1);

        var currNode = FirstNode(tx0, ty0, tz0, txm, tym, tzm);

        while (currNode < 8) {
            var childIndex = (OctreeNode.ChildIndex) (currNode ^ _dimensionFlipFlags);
            if (!_intersectMultiple && results.Count > 0) {
                return;
            }

            var nextDepth = currentDepth + 1;
            var childCoords = new Coords(nodeCoords,
                OctreeChildCoords.FromIndex(childIndex));

            INode childNode;

            if (insideSolidNode) {
                childNode = null;
            } else {
                childNode = node.GetChild(childIndex);
            }

            switch (currNode) {
                //0= none
                //1 = only x
//.........这里部分代码省略.........
开发者ID:toxicFork,项目名称:vox,代码行数:101,代码来源:RayIntersection.cs

示例2: RayIntersection

    public RayIntersection(Transform transform, IOctree octree, Ray r, bool intersectMultiple, int? wantedDepth,
		Filter filter, bool debug = false)
    {
        _filter = filter;

        _debug = debug;
        _tree = octree;
        _rootNode = octree.GetRoot();
        if (_rootNode == null) {
            //we had a good run guys, time to call it a day
            return;
        }

        _transform = transform;
        _ray = r;
        _intersectMultiple = intersectMultiple;
        _dimensionFlipFlags = 0;

        var rootBounds = _rootNode.GetBounds();
        if (_debug) {
            DrawBounds(rootBounds, Color.gray);
        }

        var rootCenter = rootBounds.center;

        var ro = transform.InverseTransformPoint(r.origin) - rootCenter;
        var rd = transform.InverseTransformDirection(r.direction);

        var rox = ro.x;
        var roy = ro.y;
        var roz = ro.z;

        var rdx = rd.x;
        var rdy = rd.y;
        var rdz = rd.z;

        var ocMin = rootBounds.min - rootCenter;
        var ocMax = rootBounds.max - rootCenter;

        if (rdx < 0.0f) {
            rox = -rox;
            rdx = -rdx;
            _dimensionFlipFlags |= 1;
        }

        if (rdy < 0.0f) {
            roy = -roy;
            rdy = -rdy;
            _dimensionFlipFlags |= 2;
        }

        if (rdz < 0.0f) {
            roz = -roz;
            rdz = -rdz;
            _dimensionFlipFlags |= 4;
        }

        float tx0, tx1, ty0, ty1, tz0, tz1;

        if (!Mathf.Approximately(rdx, 0.0f)) {
            tx0 = (ocMin.x - rox) / rdx;
            tx1 = (ocMax.x - rox) / rdx;
        } else {
            tx0 = 99999.9f;
            tx1 = 99999.9f;
        }

        if (!Mathf.Approximately(rdy, 0.0f)) {
            ty0 = (ocMin.y - roy) / rdy;
            ty1 = (ocMax.y - roy) / rdy;
        } else {
            ty0 = 99999.9f;
            ty1 = 99999.9f;
        }

        if (!Mathf.Approximately(rdz, 0.0f)) {
            tz0 = (ocMin.z - roz) / rdz;
            tz1 = (ocMax.z - roz) / rdz;
        } else {
            tz0 = 99999.9f;
            tz1 = 99999.9f;
        }

        if (_debug) {
            Debug.DrawLine(_ray.origin, _ray.GetPoint(5000), Color.yellow);
        }

        if (Mathf.Max(tx0, ty0, tz0) < Mathf.Min(tx1, ty1, tz1)) {
            ProcSubtree(tx0, ty0, tz0, tx1, ty1, tz1, _rootNode, _rootNode.IsSolid(), 0, wantedDepth,
                _rootNode.GetCoords());
        }
    }
开发者ID:toxicFork,项目名称:vox,代码行数:92,代码来源:RayIntersection.cs


注:本文中的INode.IsSolid方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。