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


C# PhysxPrim.SendCollisionUpdate方法代码示例

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


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

示例1: HandleTrackedCharacterContactChange

        private void HandleTrackedCharacterContactChange(int change, PhysxPrim ourPrim, PhysX.Shape primShape, PhysxCharacter other)
        {
            HashSet<PhysX.Shape> collidingShapes;
            if (!_avatarTouchCounts.Value.TryGetValue(other, out collidingShapes))
            {
                if (change < 0)
                {
                    //we have no record of colliding with this object. therefore removing a 
                    //collision leaves no change to state
                    return;
                }

                collidingShapes = new HashSet<PhysX.Shape>();
                _avatarTouchCounts.Value[other] = collidingShapes;
            }

            if (change > 0 && !collidingShapes.Add(primShape))
            {
                //we're already colliding with this object. no change in state
                return;
            }
            else if (change < 0 && !collidingShapes.Remove(primShape))
            {
                //we weren't colliding with this object. no change in state
                return;
            }

            int newTotal = collidingShapes.Count;

            //m_log.DebugFormat("Char Contact Change: This: {0}, Other: {1}, Chg: {2}, Tot: {3}", this.SOPName, other.SOPName, change, collidingShapes.Count);

            if (newTotal == 0 && change < 0)
            {
                //we've lost all contact with this prim, notify of collision_end
                ourPrim.SendCollisionUpdate(new CollisionEventUpdate { OtherColliderLocalId = other.LocalID, Type = CollisionEventUpdateType.CharacterCollisionEnded });
                _avatarTouchCounts.Value.Remove(other);

                return;
            }

            if (newTotal == 1 && change > 0)
            {
                //we have begun colliding with a new object
                ourPrim.SendCollisionUpdate(new CollisionEventUpdate { OtherColliderLocalId = other.LocalID, Type = CollisionEventUpdateType.CharacterCollisionBegan });
            }

            return;
        }
开发者ID:digitalmystic,项目名称:halcyon,代码行数:48,代码来源:PhysxPrim.cs

示例2: ProcessContactChangeLocally

        private void ProcessContactChangeLocally(int change, PhysxPrim ourPrim, PhysxPrim other)
        {
            int current;
            if (!_touchCounts.Value.TryGetValue(other, out current))
            {
                current = 0;
            }

            int newTotal = Math.Max(current + change, 0);

            if (newTotal == 0 && current == 0)
            {
                //no change
                return;
            }

            //m_log.DebugFormat("Contact Change: This: {0}, Other: {1}, Chg: {2}, Tot: {3}", this.SOPName, other.SOPName, change, newTotal);

            if (newTotal == 0 && change < 0)
            {
                //we've lost all contact with this prim, notify of collision_end
                //NOTE: We supply the other collider's UUID here just in case the prim has been deleted
                ourPrim.SendCollisionUpdate(new CollisionEventUpdate { OtherColliderLocalId = other._localId, OtherColliderUUID = other._uuid, Type = CollisionEventUpdateType.CollisionEnded });
                _touchCounts.Value.Remove(other);
                other.OnDeleted -= new Action<PhysxPrim>(other_OnDeleted);
                _primsBeingWatchedForDeletes.Value.Remove(other);

                return;
            }

            if (newTotal == 1 && change > 0)
            {
                //we have begun colliding with a new object
                ourPrim.SendCollisionUpdate(new CollisionEventUpdate { OtherColliderLocalId = other._localId, Type = CollisionEventUpdateType.CollisionBegan });
                other.OnDeleted += new Action<PhysxPrim>(other_OnDeleted);
                _primsBeingWatchedForDeletes.Value.Add(other);
            }

            _touchCounts.Value[other] = newTotal;

            return;
        }
开发者ID:digitalmystic,项目名称:halcyon,代码行数:42,代码来源:PhysxPrim.cs


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