public void MultipleDisposeCallsDoNotCauseAnException()
        {
            using (var physics = CreatePhysicsAndScene())
            {
                const int rows = 25, columns = 25;
                var       samples = HeightFieldTestUtil.CreateSampleGrid(rows, columns);

                var heightFieldDesc = new HeightFieldDesc()
                {
                    NumberOfRows    = rows,
                    NumberOfColumns = columns,
                    Samples         = samples
                };

                var cooking = physics.Physics.CreateCooking();

                var  stream     = new MemoryStream();
                bool cookResult = cooking.CookHeightField(heightFieldDesc, stream);

                stream.Position = 0;

                HeightField heightField = physics.Physics.CreateHeightField(stream);

                Assert.IsFalse(heightField.Disposed);

                // Dispose
                heightField.Dispose();
                Assert.IsTrue(heightField.Disposed);

                // Dispose again
                heightField.Dispose();
                Assert.IsTrue(heightField.Disposed);
            }
        }
Esempio n. 2
0
        public void SetupHeightField()
        {
            _physics = CreatePhysicsAndScene();

            const int rows = 25, columns = 40;
            var       samples = HeightFieldTestUtil.CreateSampleGrid(rows, columns);

            var heightFieldDesc = new HeightFieldDesc()
            {
                NumberOfRows        = rows,
                NumberOfColumns     = columns,
                Samples             = samples,
                Thickness           = 4.2f,
                ConvexEdgeThreshold = 6.6f,
                Flags = HeightFieldFlag.NoBoundaryEdges
            };

            var cooking = _physics.Physics.CreateCooking();

            var  stream     = new MemoryStream();
            bool cookResult = cooking.CookHeightField(heightFieldDesc, stream);

            stream.Position = 0;

            _heightField = _physics.Physics.CreateHeightField(stream);

            Assert.IsNotNull(_heightField);
            Assert.IsFalse(_heightField.Disposed);
        }
        public void CreateAndDisposeHeightField()
        {
            using (var physics = CreatePhysicsAndScene())
            {
                const int rows = 25, columns = 25;
                var       samples = HeightFieldTestUtil.CreateSampleGrid(rows, columns);

                var heightFieldDesc = new HeightFieldDesc
                {
                    NumberOfRows    = rows,
                    NumberOfColumns = columns,
                    Samples         = samples
                };

                var cooking = physics.Physics.CreateCooking();

                var  stream     = new MemoryStream();
                bool cookResult = cooking.CookHeightField(heightFieldDesc, stream);

                stream.Position = 0;

                HeightField heightField;
                using (heightField = physics.Physics.CreateHeightField(stream))
                {
                    Assert.IsNotNull(heightField);
                    Assert.IsFalse(heightField.Disposed);
                }

                Assert.IsTrue(heightField.Disposed);
            }
        }
Esempio n. 4
0
        public void MultipleInstancesAreValid()
        {
            using (var physics = CreatePhysicsAndScene())
            {
                // A
                {
                    const int rows = 25, columns = 25;
                    var       samples = HeightFieldTestUtil.CreateSampleGrid(rows, columns);

                    var heightFieldDesc = new HeightFieldDesc()
                    {
                        NumberOfRows    = rows,
                        NumberOfColumns = columns,
                        Samples         = samples
                    };

                    HeightField heightField = physics.Physics.CreateHeightField(heightFieldDesc);
                }

                // B
                {
                    const int rows = 25, columns = 25;
                    var       samples = HeightFieldTestUtil.CreateSampleGrid(rows, columns);

                    var heightFieldDesc = new HeightFieldDesc()
                    {
                        NumberOfRows    = rows,
                        NumberOfColumns = columns,
                        Samples         = samples
                    };

                    HeightField heightField = physics.Physics.CreateHeightField(heightFieldDesc);
                }
            }
        }
Esempio n. 5
0
        public void MultipleDisposeCallsDoNotCauseAnException()
        {
            using (var physics = CreatePhysicsAndScene())
            {
                const int rows = 25, columns = 25;
                var       samples = HeightFieldTestUtil.CreateSampleGrid(rows, columns);

                var heightFieldDesc = new HeightFieldDesc()
                {
                    NumberOfRows    = rows,
                    NumberOfColumns = columns,
                    Samples         = samples
                };

                HeightField heightField = physics.Physics.CreateHeightField(heightFieldDesc);

                Assert.IsFalse(heightField.Disposed);

                // Dispose
                heightField.Dispose();
                Assert.IsTrue(heightField.Disposed);

                // Dispose again
                heightField.Dispose();
                Assert.IsTrue(heightField.Disposed);
            }
        }
        public void MultipleInstancesAreValid()
        {
            using (var physics = CreatePhysicsAndScene())
            {
                // A
                {
                    const int rows = 25, columns = 25;
                    var       samples = HeightFieldTestUtil.CreateSampleGrid(rows, columns);

                    var heightFieldDesc = new HeightFieldDesc()
                    {
                        NumberOfRows    = rows,
                        NumberOfColumns = columns,
                        Samples         = samples
                    };

                    var cooking = physics.Physics.CreateCooking();

                    var  stream     = new MemoryStream();
                    bool cookResult = cooking.CookHeightField(heightFieldDesc, stream);

                    stream.Position = 0;

                    HeightField heightField = physics.Physics.CreateHeightField(stream);
                }

                // B
                {
                    const int rows = 25, columns = 25;
                    var       samples = HeightFieldTestUtil.CreateSampleGrid(rows, columns);

                    var heightFieldDesc = new HeightFieldDesc()
                    {
                        NumberOfRows    = rows,
                        NumberOfColumns = columns,
                        Samples         = samples
                    };

                    var cooking = physics.Physics.CreateCooking();

                    var  stream     = new MemoryStream();
                    bool cookResult = cooking.CookHeightField(heightFieldDesc, stream);

                    stream.Position = 0;

                    HeightField heightField = physics.Physics.CreateHeightField(stream);
                }
            }
        }
Esempio n. 7
0
        public void GetHeightFieldGeometry()
        {
            var material = _physics.Physics.CreateMaterial(0.5f, 0.5f, 0.1f);

            const int rows = 25, columns = 25;
            var       samples = HeightFieldTestUtil.CreateSampleGrid(rows, columns);

            var heightFieldDesc = new HeightFieldDesc()
            {
                NumberOfRows    = rows,
                NumberOfColumns = columns,
                Samples         = samples
            };

            var cooking = _physics.Physics.CreateCooking();

            var  stream     = new MemoryStream();
            bool cookResult = cooking.CookHeightField(heightFieldDesc, stream);

            stream.Position = 0;

            var heightField = _physics.Physics.CreateHeightField(stream);

            Assert.IsNotNull(heightField);

            var heightFieldGeometry = new HeightFieldGeometry
                                      (
                heightField: heightField,
                flags: MeshGeometryFlag.DoubleSided,
                heightFieldScale: 2.3f,
                rowScale: 1.2f,
                columnScale: 1.9f
                                      );

            var shape = _actor.CreateShape(heightFieldGeometry, material);

            //

            var retrievedHeightfieldGeom = shape.GetHeightFieldGeometry();

            Assert.IsNotNull(retrievedHeightfieldGeom);
            Assert.AreEqual(heightField, retrievedHeightfieldGeom.HeightField);
            Assert.AreEqual(retrievedHeightfieldGeom.ColumnScale, 1.9f);
            Assert.AreEqual(retrievedHeightfieldGeom.RowScale, 1.2f);
            Assert.AreEqual(retrievedHeightfieldGeom.HeightFieldFlags, MeshGeometryFlag.DoubleSided);
        }
        public void SetupHeightField()
        {
            _physics = CreatePhysicsAndScene();

            const int rows = 25, columns = 40;
            var       samples = HeightFieldTestUtil.CreateSampleGrid(rows, columns);

            var heightFieldDesc = new HeightFieldDesc()
            {
                NumberOfRows        = rows,
                NumberOfColumns     = columns,
                Samples             = samples,
                Thickness           = 4.2f,
                ConvexEdgeThreshold = 6.6f,
                Flags = HeightFieldFlag.NoBoundaryEdges
            };

            _heightField = _physics.Physics.CreateHeightField(heightFieldDesc);

            Assert.IsNotNull(_heightField);
            Assert.IsFalse(_heightField.Disposed);
        }
Esempio n. 9
0
        public void CreateAndDisposeHeightField()
        {
            using (var physics = CreatePhysicsAndScene())
            {
                const int rows = 25, columns = 25;
                var       samples = HeightFieldTestUtil.CreateSampleGrid(rows, columns);

                var heightFieldDesc = new HeightFieldDesc()
                {
                    NumberOfRows    = rows,
                    NumberOfColumns = columns,
                    Samples         = samples
                };

                HeightField heightField;
                using (heightField = physics.Physics.CreateHeightField(heightFieldDesc))
                {
                    Assert.IsNotNull(heightField);
                    Assert.IsFalse(heightField.Disposed);
                }

                Assert.IsTrue(heightField.Disposed);
            }
        }