コード例 #1
0
        private void BuildOccluders()
        {
            // Build occluders.
            var occluderNodes = _model.GetSubtree()
                                .OfType <DROccluderNodeContent>()
                                .ToList();

            foreach (var occluderNode in occluderNodes)
            {
                BuildOccluder(occluderNode);
            }

            foreach (var occluderNode in occluderNodes)
            {
                ValidateOccluder(occluderNode);
            }

            // If possible, assign occluder to parent mesh and remove occluder node.
            foreach (var occluderNode in occluderNodes)
            {
                if (occluderNode.Parent is DRMeshNodeContent &&
                    Pose.AreNumericallyEqual(occluderNode.PoseLocal, Pose.Identity) &&
                    Vector3.AreNumericallyEqual(occluderNode.ScaleLocal, Vector3.One) &&
                    (occluderNode.Children == null || occluderNode.Children.Count == 0))
                {
                    var meshNode = (DRMeshNodeContent)occluderNode.Parent;
                    meshNode.Mesh.Occluder = occluderNode.Occluder;
                    meshNode.Children.Remove(occluderNode);
                }
            }
        }
コード例 #2
0
        public void AreNumericallyEqual()
        {
            var a = new Pose(new Vector3(1, 2, 3), new Matrix(1, 2, 3, 4, 5, 6, 7, 8, 9));
            var b = a;

            Assert.AreEqual(true, Pose.AreNumericallyEqual(a, b));
            Assert.AreEqual(true, Pose.AreNumericallyEqual(b, a));

            b = AddToAllComponents(a, Numeric.EpsilonF / 10);
            Assert.AreEqual(true, Pose.AreNumericallyEqual(a, b));
            Assert.AreEqual(true, Pose.AreNumericallyEqual(b, a));
            Assert.AreEqual(true, Pose.AreNumericallyEqual(a, b, Numeric.EpsilonF));
            Assert.AreEqual(true, Pose.AreNumericallyEqual(b, a, Numeric.EpsilonF));

            b = AddToAllComponents(a, Numeric.EpsilonF * 10);
            Assert.AreEqual(false, Pose.AreNumericallyEqual(a, b));
            Assert.AreEqual(false, Pose.AreNumericallyEqual(b, a));
            Assert.AreEqual(false, Pose.AreNumericallyEqual(a, b, Numeric.EpsilonF));
            Assert.AreEqual(false, Pose.AreNumericallyEqual(b, a, Numeric.EpsilonF));
            Assert.AreEqual(true, Pose.AreNumericallyEqual(a, b, Numeric.EpsilonF * 100));
            Assert.AreEqual(true, Pose.AreNumericallyEqual(b, a, Numeric.EpsilonF * 100));

            b             = a;
            b.Position.X -= 0.001f;
            Assert.AreEqual(false, Pose.AreNumericallyEqual(a, b));
            Assert.AreEqual(false, Pose.AreNumericallyEqual(b, a));
            Assert.AreEqual(false, Pose.AreNumericallyEqual(a, b, Numeric.EpsilonF));
            Assert.AreEqual(false, Pose.AreNumericallyEqual(b, a, Numeric.EpsilonF));
            Assert.AreEqual(true, Pose.AreNumericallyEqual(a, b, 0.01f));
            Assert.AreEqual(true, Pose.AreNumericallyEqual(b, a, 0.01f));

            b             = a;
            b.Position.Y -= 0.001f;
            Assert.AreEqual(false, Pose.AreNumericallyEqual(a, b));
            Assert.AreEqual(false, Pose.AreNumericallyEqual(b, a));
            Assert.AreEqual(false, Pose.AreNumericallyEqual(a, b, Numeric.EpsilonF));
            Assert.AreEqual(false, Pose.AreNumericallyEqual(b, a, Numeric.EpsilonF));
            Assert.AreEqual(true, Pose.AreNumericallyEqual(a, b, 0.01f));
            Assert.AreEqual(true, Pose.AreNumericallyEqual(b, a, 0.01f));

            b             = a;
            b.Position.Z -= 0.001f;
            Assert.AreEqual(false, Pose.AreNumericallyEqual(a, b));
            Assert.AreEqual(false, Pose.AreNumericallyEqual(b, a));
            Assert.AreEqual(false, Pose.AreNumericallyEqual(a, b, Numeric.EpsilonF));
            Assert.AreEqual(false, Pose.AreNumericallyEqual(b, a, Numeric.EpsilonF));
            Assert.AreEqual(true, Pose.AreNumericallyEqual(a, b, 0.01f));
            Assert.AreEqual(true, Pose.AreNumericallyEqual(b, a, 0.01f));

            b = a;
            b.Orientation.M00 -= 0.001f;
            Assert.AreEqual(false, Pose.AreNumericallyEqual(a, b));
            Assert.AreEqual(false, Pose.AreNumericallyEqual(b, a));
            Assert.AreEqual(false, Pose.AreNumericallyEqual(a, b, Numeric.EpsilonF));
            Assert.AreEqual(false, Pose.AreNumericallyEqual(b, a, Numeric.EpsilonF));
            Assert.AreEqual(true, Pose.AreNumericallyEqual(a, b, 0.01f));
            Assert.AreEqual(true, Pose.AreNumericallyEqual(b, a, 0.01f));

            b = a;
            b.Orientation.M01 -= 0.001f;
            Assert.AreEqual(false, Pose.AreNumericallyEqual(a, b));
            Assert.AreEqual(false, Pose.AreNumericallyEqual(b, a));
            Assert.AreEqual(false, Pose.AreNumericallyEqual(a, b, Numeric.EpsilonF));
            Assert.AreEqual(false, Pose.AreNumericallyEqual(b, a, Numeric.EpsilonF));
            Assert.AreEqual(true, Pose.AreNumericallyEqual(a, b, 0.01f));
            Assert.AreEqual(true, Pose.AreNumericallyEqual(b, a, 0.01f));

            b = a;
            b.Orientation.M02 -= 0.001f;
            Assert.AreEqual(false, Pose.AreNumericallyEqual(a, b));
            Assert.AreEqual(false, Pose.AreNumericallyEqual(b, a));
            Assert.AreEqual(false, Pose.AreNumericallyEqual(a, b, Numeric.EpsilonF));
            Assert.AreEqual(false, Pose.AreNumericallyEqual(b, a, Numeric.EpsilonF));
            Assert.AreEqual(true, Pose.AreNumericallyEqual(a, b, 0.01f));
            Assert.AreEqual(true, Pose.AreNumericallyEqual(b, a, 0.01f));

            b = a;
            b.Orientation.M10 -= 0.001f;
            Assert.AreEqual(false, Pose.AreNumericallyEqual(a, b));
            Assert.AreEqual(false, Pose.AreNumericallyEqual(b, a));
            Assert.AreEqual(false, Pose.AreNumericallyEqual(a, b, Numeric.EpsilonF));
            Assert.AreEqual(false, Pose.AreNumericallyEqual(b, a, Numeric.EpsilonF));
            Assert.AreEqual(true, Pose.AreNumericallyEqual(a, b, 0.01f));
            Assert.AreEqual(true, Pose.AreNumericallyEqual(b, a, 0.01f));

            b = a;
            b.Orientation.M11 -= 0.001f;
            Assert.AreEqual(false, Pose.AreNumericallyEqual(a, b));
            Assert.AreEqual(false, Pose.AreNumericallyEqual(b, a));
            Assert.AreEqual(false, Pose.AreNumericallyEqual(a, b, Numeric.EpsilonF));
            Assert.AreEqual(false, Pose.AreNumericallyEqual(b, a, Numeric.EpsilonF));
            Assert.AreEqual(true, Pose.AreNumericallyEqual(a, b, 0.01f));
            Assert.AreEqual(true, Pose.AreNumericallyEqual(b, a, 0.01f));

            b = a;
            b.Orientation.M12 -= 0.001f;
            Assert.AreEqual(false, Pose.AreNumericallyEqual(a, b));
            Assert.AreEqual(false, Pose.AreNumericallyEqual(b, a));
            Assert.AreEqual(false, Pose.AreNumericallyEqual(a, b, Numeric.EpsilonF));
            Assert.AreEqual(false, Pose.AreNumericallyEqual(b, a, Numeric.EpsilonF));
            Assert.AreEqual(true, Pose.AreNumericallyEqual(a, b, 0.01f));
            Assert.AreEqual(true, Pose.AreNumericallyEqual(b, a, 0.01f));

            b = a;
            b.Orientation.M20 -= 0.001f;
            Assert.AreEqual(false, Pose.AreNumericallyEqual(a, b));
            Assert.AreEqual(false, Pose.AreNumericallyEqual(b, a));
            Assert.AreEqual(false, Pose.AreNumericallyEqual(a, b, Numeric.EpsilonF));
            Assert.AreEqual(false, Pose.AreNumericallyEqual(b, a, Numeric.EpsilonF));
            Assert.AreEqual(true, Pose.AreNumericallyEqual(a, b, 0.01f));
            Assert.AreEqual(true, Pose.AreNumericallyEqual(b, a, 0.01f));

            b = a;
            b.Orientation.M21 -= 0.001f;
            Assert.AreEqual(false, Pose.AreNumericallyEqual(a, b));
            Assert.AreEqual(false, Pose.AreNumericallyEqual(b, a));
            Assert.AreEqual(false, Pose.AreNumericallyEqual(a, b, Numeric.EpsilonF));
            Assert.AreEqual(false, Pose.AreNumericallyEqual(b, a, Numeric.EpsilonF));
            Assert.AreEqual(true, Pose.AreNumericallyEqual(a, b, 0.01f));
            Assert.AreEqual(true, Pose.AreNumericallyEqual(b, a, 0.01f));

            b = a;
            b.Orientation.M22 -= 0.001f;
            Assert.AreEqual(false, Pose.AreNumericallyEqual(a, b));
            Assert.AreEqual(false, Pose.AreNumericallyEqual(b, a));
            Assert.AreEqual(false, Pose.AreNumericallyEqual(a, b, Numeric.EpsilonF));
            Assert.AreEqual(false, Pose.AreNumericallyEqual(b, a, Numeric.EpsilonF));
            Assert.AreEqual(true, Pose.AreNumericallyEqual(a, b, 0.01f));
            Assert.AreEqual(true, Pose.AreNumericallyEqual(b, a, 0.01f));
        }