public override void FixedUpdate(RenderWindow window, float fixedDeltatime)
        {
            PlayerUpdatePacket?packet = _buffer.GetData(Id);

            if (packet.HasValue)
            {
                Position  = packet.Value.position * 0.1f + Position * 0.9f;
                Velocity  = packet.Value.velocity;
                Direction = packet.Value.direction;
            }
            else
            {
                DeletionMark = true;
            }
        }
示例#2
0
    /// <summary>
    /// Calls into the Scene Understanding APIs, to retrieve the latest scene as a byte array.
    /// </summary>
    /// <param name="enableQuads">When enabled, quad representation of scene objects is retrieved.</param>
    /// <param name="enableMeshes">When enabled, mesh representation of scene objects is retrieved.</param>
    /// <param name="enableInference">When enabled, both observed and inferred scene objects are retrieved. Otherwise, only observed scene objects are retrieved.</param>
    /// <param name="enableWorldMesh">When enabled, retrieves the world mesh.</param>
    /// <param name="lod">If world mesh is enabled, lod controls the resolution of the mesh returned.</param>
    private void RetrieveData(float boundingSphereRadiusInMeters, bool enableQuads, bool enableMeshes, bool enableInference, bool enableWorldMesh, SceneMeshLevelOfDetail lod)
    {
        Debug.Log("SceneUnderstandingManager.RetrieveData: Started.");

        System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch();
        stopwatch.Start();

        try
        {
            SceneQuerySettings querySettings;
            querySettings.EnableSceneObjectQuads         = enableQuads;
            querySettings.EnableSceneObjectMeshes        = enableMeshes;
            querySettings.EnableOnlyObservedSceneObjects = !enableInference;
            querySettings.EnableWorldMesh            = enableWorldMesh;
            querySettings.RequestedMeshLevelOfDetail = lod;

            // Ensure that the bounding radius is within the min/max range.
            boundingSphereRadiusInMeters = Mathf.Clamp(boundingSphereRadiusInMeters, MinBoundingSphereRadiusInMeters, MaxBoundingSphereRadiusInMeters);

            // Make sure the scene query has completed swap with latestSUSceneData under lock to ensure the application is always pointing to a valid scene.
            SceneBuffer serializedScene = SceneObserver.ComputeSerializedAsync(querySettings, boundingSphereRadiusInMeters).GetAwaiter().GetResult();
            lock (SUDataLock)
            {
                // The latest data queried from the device is stored in these variables
                LatestSUSceneData = new byte[serializedScene.Size];
                serializedScene.GetData(LatestSUSceneData);
                LatestSceneGuid = Guid.NewGuid();
            }
        }
        catch (Exception e)
        {
            Debug.LogException(e);
        }

        stopwatch.Stop();
        Debug.Log(string.Format("SceneUnderstandingManager.RetrieveData: Completed. Radius: {0}; Quads: {1}; Meshes: {2}; Inference: {3}; WorldMesh: {4}; LOD: {5}; Bytes: {6}; Time (secs): {7};",
                                boundingSphereRadiusInMeters,
                                enableQuads,
                                enableMeshes,
                                enableInference,
                                enableWorldMesh,
                                lod,
                                (LatestSUSceneData == null ? 0 : LatestSUSceneData.Length),
                                stopwatch.Elapsed.TotalSeconds));
    }