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


C# Geom.FindDNC方法代码示例

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


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

示例1: Update

        /// <summary>
        /// Updates this instance.
        /// </summary>
        public void Update()
        {
            //Iterate all the geoms and check against the next
            for (int i = 0; i < _physicsSimulator.geomList.Count - 1; i++)
            {
                for (int j = i + 1; j < _physicsSimulator.geomList.Count; j++)
                {
                    _geometryA = _physicsSimulator.geomList[i];
                    _geometryB = _physicsSimulator.geomList[j];

                    if (!_geometryA.body.Enabled || !_geometryB.body.Enabled)
                        continue;

                    if ((_geometryA.CollisionGroup == _geometryB.CollisionGroup) &&
                        _geometryA.CollisionGroup != 0 && _geometryB.CollisionGroup != 0)
                        continue;

                    if (!_geometryA.CollisionEnabled || !_geometryB.CollisionEnabled)
                        continue;

                    if (_geometryA.body.isStatic && _geometryB.body.isStatic)
                        continue;

                    if (_geometryA.body == _geometryB.body)
                        continue;

                    if (((_geometryA.CollisionCategories & _geometryB.CollidesWith) == CollisionCategory.None) &
                        ((_geometryB.CollisionCategories & _geometryA.CollidesWith) == CollisionCategory.None))
                        continue;

                    if (_geometryA.FindDNC(_geometryB) || _geometryB.FindDNC(_geometryA))
                    {
                        continue;
                    }

                    //Assume intersection
                    bool intersection = true;

                    //Check if there is no intersection
                    if (_geometryA.AABB.min.X > _geometryB.AABB.max.X || _geometryB.AABB.min.X > _geometryA.AABB.max.X)
                        intersection = false;
                    else if (_geometryA.AABB.min.Y > _geometryB.AABB.Max.Y || _geometryB.AABB.min.Y > _geometryA.AABB.Max.Y)
                        intersection = false;

                    //Call the OnBroadPhaseCollision event first. If the user aborts the collision
                    //it will not create an arbiter
                    if (OnBroadPhaseCollision != null)
                        intersection = OnBroadPhaseCollision(_geometryA, _geometryB);

                    //If the user aborted the intersection, continue to the next geometry.
                    if (!intersection)
                        continue;

                    Arbiter arbiter = _physicsSimulator.arbiterPool.Fetch();
                    arbiter.ConstructArbiter(_geometryA, _geometryB, _physicsSimulator);

                    if (!_physicsSimulator.arbiterList.Contains(arbiter))
                        _physicsSimulator.arbiterList.Add(arbiter);
                    else
                        _physicsSimulator.arbiterPool.Insert(arbiter);
                }
            }
        }
开发者ID:braahyan,项目名称:Platformer,代码行数:66,代码来源:BruteForceCollider.cs


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