Example #1
0
        /// <summary>
        ///     This method provides the skeletonID of the skeleton perfoming the defined gesture or which should be reactivated.
        ///     <param name="igsSkelId">SkeletonID stored in the IGS</param>
        ///     <returns>ID of the skeleton which was marked as tracked</returns>
        /// </summary>
        public int GetSkeletonId(int igsSkelId)
        {
            if (Bodies.Any(s => s.Id == igsSkelId))
            {
                return(igsSkelId);
            }

            if (!_bodiesLastFrame.Any(s => s.TrackingId != 0))
            {
                return(NO_BODIES_IN_FRAME);
            }

            Bodies = Strategy.Replace(Bodies);

            HashSet <int> idsSeen = new HashSet <int>();

            foreach (TrackedSkeleton s in Bodies)
            {
                idsSeen.Add(s.Id);
            }

            Bodies = Filter.Filter(_bodiesLastFrame, Bodies, igsSkelId, reader);

            //see which user was added
            foreach (TrackedSkeleton s in Bodies.Where(s => !idsSeen.Contains(s.Id)))
            {
                return(s.Id);
            }

            return(NO_GESTURE_FOUND);
        }
Example #2
0
 public bool CheckSolid(Rectangle area, uint maskBits, uint categoryBits)
 {
     return(Tiles.AnySolid(area) ||
            Bodies.Any(e => (maskBits & e.CategoryBits) != 0 &&
                       (e.MaskBits & categoryBits) != 0 &&
                       e.WorldBounds.Intersects(area) &&
                       e.Type == CollisionTypes.Solid));
 }
Example #3
0
        private void UpdateSections()
        {
            if (Bodies == null)
            {
                return;
            }
            foreach (Body b in Bodies)
            {
                GameMain.World.RemoveBody(b);
            }
            Bodies.Clear();
            bodyDebugDimensions.Clear();
#if CLIENT
            convexHulls?.ForEach(ch => ch.Remove());
            convexHulls?.Clear();
#endif

            bool hasHoles       = false;
            var  mergedSections = new List <WallSection>();
            for (int i = 0; i < Sections.Length; i++)
            {
                // if there is a gap and we have sections to merge, do it.
                if (SectionBodyDisabled(i))
                {
                    hasHoles = true;

                    if (!mergedSections.Any())
                    {
                        continue;
                    }
                    var mergedRect = GenerateMergedRect(mergedSections);
                    mergedSections.Clear();
                    CreateRectBody(mergedRect, createConvexHull: true);
                }
                else
                {
                    mergedSections.Add(Sections[i]);
                }
            }

            // take care of any leftover pieces
            if (mergedSections.Count > 0)
            {
                var mergedRect = GenerateMergedRect(mergedSections);
                CreateRectBody(mergedRect, createConvexHull: true);
            }

            //if the section has holes (or is just one big hole with no bodies),
            //we need a sensor for repairtools to be able to target the structure
            if (hasHoles || !Bodies.Any())
            {
                Body sensorBody = CreateRectBody(rect, createConvexHull: false);
                sensorBody.CollisionCategories = Physics.CollisionRepair;
                sensorBody.IsSensor            = true;
            }
        }
Example #4
0
 public bool CheckSolid(Rectangle area)
 {
     return(Tiles.AnySolid(area) ||
            Bodies.Any(e => e.WorldBounds.Intersects(area) &&
                       e.Type == CollisionTypes.Solid));
 }