Ejemplo n.º 1
0
        private void Debug_VerifyCachedBounds()
        {
            Rect3D actualBounds = M3DUtil.ComputeAxisAlignedBoundingBox(Positions);

            // The funny boolean logic below avoids asserts when the cached
            // bounds contain NaNs.  (NaN != NaN)
            bool areEqual =
                !(_cachedBounds.X <actualBounds.X || _cachedBounds.X> actualBounds.X) &&
                !(_cachedBounds.Y <actualBounds.Y || _cachedBounds.Y> actualBounds.Y) &&
                !(_cachedBounds.Z <actualBounds.Z || _cachedBounds.Z> actualBounds.Z) &&
                !(_cachedBounds.SizeX <actualBounds.SizeX || _cachedBounds.SizeX> actualBounds.SizeX) &&
                !(_cachedBounds.SizeY <actualBounds.SizeY || _cachedBounds.SizeY> actualBounds.SizeY) &&
                !(_cachedBounds.SizeZ <actualBounds.SizeZ || _cachedBounds.SizeZ> actualBounds.SizeZ);

            if (!areEqual)
            {
                if (_cachedBounds == Rect3D.Empty)
                {
                    Debug.Fail("Cached bounds are invalid. Caller needs to check for IsEmpty and call UpdateCachedBounds.");
                }
                else
                {
                    Debug.Fail("Cached bounds are invalid. We missed a call to SetCachedBoundsDirty.");
                }
            }
        }
Ejemplo n.º 2
0
        // Updates the _cachedBounds member to the current bounds of the mesh.
        // This method must be called before accessing _cachedBounds if
        // _cachedBounds.IsEmpty is true.  Otherwise the _cachedBounds are
        // current and do not need to be recomputed.  See also Debug_VerifyCachedBounds.
        private void UpdateCachedBounds()
        {
            Debug.Assert(_cachedBounds.IsEmpty,
                         "PERF: Caller should verify that bounds are dirty before recomputing.");

            _cachedBounds = M3DUtil.ComputeAxisAlignedBoundingBox(Positions);
        }