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


C# BroadPhaseEntry.UpdateBoundingBox方法代码示例

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


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

示例1: Add

        /// <summary>
        /// Adds an entry to the broad phase.
        /// </summary>
        /// <param name="entry">Entry to add.</param>
        public override void Add(BroadPhaseEntry entry)
        {
            base.Add(entry);
            //Entities do not set up their own bounding box before getting stuck in here.  If they're all zeroed out, the tree will be horrible.
            Vector3 offset;
            Vector3.Subtract(ref entry.boundingBox.Max, ref entry.boundingBox.Min, out offset);
            if (offset.X * offset.Y * offset.Z == 0)
                entry.UpdateBoundingBox();
            //binary search for the approximately correct location.  This helps prevent large first-frame sort times.
            int minIndex = 0; //inclusive
            int maxIndex = entries.Count; //exclusive
            int index = 0;
            while (maxIndex - minIndex > 0)
            {
                index = (maxIndex + minIndex) / 2;
                if (entries.Elements[index].boundingBox.Min.X > entry.boundingBox.Min.X)
                    maxIndex = index;
                else if (entries.Elements[index].boundingBox.Min.X < entry.boundingBox.Min.X)
                    minIndex = ++index;
                else
                    break; //Found an equal value!

            }
            entries.Insert(index, entry);
        }
开发者ID:karrtmomil,项目名称:coms437_assignment2,代码行数:29,代码来源:SortAndSweep1D.cs

示例2: Add

 /// <summary>
 /// Adds an entry to the broad phase.
 /// </summary>
 /// <param name="entry">Entry to add.</param>
 public override void Add(BroadPhaseEntry entry)
 {
     base.Add(entry);
     //Entities do not set up their own bounding box before getting stuck in here.  If they're all zeroed out, the tree will be horrible.
     System.Numerics.Vector3 offset;
     Vector3Ex.Subtract(ref entry.boundingBox.Max, ref entry.boundingBox.Min, out offset);
     if (offset.X * offset.Y * offset.Z == 0)
         entry.UpdateBoundingBox();
     var newEntry = entryPool.Take();
     newEntry.Initialize(entry);
     entries.Add(newEntry);
     //Add the object to the grid.
     for (int i = newEntry.previousMin.Y; i <= newEntry.previousMax.Y; i++)
     {
         for (int j = newEntry.previousMin.Z; j <= newEntry.previousMax.Z; j++)
         {
             var index = new Int2 {Y = i, Z = j};
             cellSet.Add(ref index, newEntry);
         }
     }
 }
开发者ID:Raverenx,项目名称:GameEngine,代码行数:25,代码来源:Grid2DSortAndSweep.cs


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