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


C# OpenMetaverse.ApproxEquals方法代码示例

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


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

示例1: CheckSyncVelocity

        private VelocityStatus CheckSyncVelocity(OpenMetaverse.Vector3 posDiff)
        {
            VelocityStatus status = VelocityStatus.NoChange;

            //check my angular and linear velocity
            OpenMetaverse.Vector3 newVel = PhysUtil.PhysxVectorToOmv(_dynActor.LinearVelocity);

            if (newVel != _velocity)
            {
                if (newVel == OpenMetaverse.Vector3.Zero)
                {
                    // we need to assume there is no acceleration acting on the prim anymore
                    // or our objects will float away instead of coming to rest in their final movement
                    _acceleration = OpenMetaverse.Vector3.Zero;
                    _velocity = OpenMetaverse.Vector3.Zero;
                    _lastAccelVelUpdate = 0;
                    status |= VelocityStatus.Zeroed;
                }
                else
                {
                    //try to get a semi-accurate FPS to send the viewer the correct acceleration
                    ulong tickCountNow = Util.GetLongTickCount();
                    ulong timeDiff = tickCountNow - _lastAccelVelUpdate;

                    float fps;
                    if (_lastAccelVelUpdate == 0 || timeDiff <= 0)
                    {
                        fps = NOMINAL_FPS;
                    }
                    else
                    {
                        fps = 1.0f / (timeDiff * 0.001f);
                    }

                    var lastAccel = _acceleration;
                    var newAccel = (newVel - _velocity) * fps;

                    _velocity = newVel;

                    if (!lastAccel.ApproxEquals(newAccel, ACCEL_COMPARISON_TOLERANCE * _velocity.Length()))
                    {
                        //m_log.DebugFormat("Vel: {0} Accel: {1} Fps: {2}", _velocity, newAccel, fps);
                        _acceleration = newAccel;
                        status |= VelocityStatus.Changed;
                    }
                    
                    
                    _lastAccelVelUpdate = tickCountNow;
                }

                
            }
            else
            {
                if (_velocity != OpenMetaverse.Vector3.Zero)
                {
                    _acceleration = OpenMetaverse.Vector3.Zero;
                    _lastAccelVelUpdate = Util.GetLongTickCount();
                    status |= VelocityStatus.Changed;
                }
            }

            if (status != VelocityStatus.NoChange)
            {
                _angularVelocity = PhysUtil.PhysxVectorToOmv(_dynActor.AngularVelocity);
            }
            else
            {
                OpenMetaverse.Vector3 newAngVel = PhysUtil.PhysxVectorToOmv(_dynActor.AngularVelocity);
                //m_log.DebugFormat("AngVel: {0}, NewAngVel: {1}", _angularVelocity, newAngVel);

                if (newAngVel == OpenMetaverse.Vector3.Zero)
                {
                    if (newAngVel != _angularVelocity)
                    {
                        _angularVelocity = OpenMetaverse.Vector3.Zero;
                        status |= VelocityStatus.AngularChanged;
                    }
                }
                else if (!newAngVel.ApproxEquals(_angularVelocity, ANGULAR_VELOCITY_COMPARISON_TOLERANCE * _angularVelocity.Length()))
                {
                    //Console.Out.WriteLine("Ang: {0}", _angularVelocity);
                    _angularVelocity = newAngVel;
                    status |= VelocityStatus.AngularChanged;
                }
                else
                {
                    //Angular velocity hasnt changed or zeroed. BUT if angular velocity is set and
                    //the center of mass isnt at 0,0,0 and POS has changed we need to send an update
                    if (!_centerOfMassNearlyZero && !posDiff.ApproxEquals(OpenMetaverse.Vector3.Zero, POS_ANGULAR_VEL_TOLERANCE))
                    {
                        _angularVelocity = newAngVel;

                        status |= VelocityStatus.AngularPosChanged;
                        _useAngularVelocity = false;
                    }
                    else
                    {
                        if (_useAngularVelocity == false)
                        {
//.........这里部分代码省略.........
开发者ID:digitalmystic,项目名称:halcyon,代码行数:101,代码来源:PhysxPrim.cs


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