Пример #1
0
        public void JointDataCreateStiffSpringTest()
        {
            var positionAinA = new float3(0.0f, 1.0f, 2.0f);
            var positionBinB = new float3(1.0f, 0.0f, 3.0f);
            var minDistance  = 1.0f;
            var maxDistance  = 10.0f;

            var jointDataRef = JointData.CreateStiffSpring(positionAinA, positionBinB, minDistance, maxDistance);

            var jointData = jointDataRef.Value;

            Assert.AreEqual(positionAinA, jointData.AFromJoint.Translation);
            Assert.AreEqual(positionBinB, jointData.BFromJoint.Translation);
            Assert.AreEqual(1, jointData.Version);
            Assert.AreEqual(1, jointData.NumConstraints);

            var constraint = jointDataRef.Value.Constraints[0];

            Assert.AreEqual(new bool3(true), constraint.ConstrainedAxes);
            Assert.AreEqual(ConstraintType.Linear, constraint.Type);
            Assert.AreEqual(1.0f, constraint.Min);
            Assert.AreEqual(10.0f, constraint.Max);
            Assert.AreEqual(Constraint.DefaultSpringFrequency, constraint.SpringFrequency);
            Assert.AreEqual(Constraint.DefaultSpringDamping, constraint.SpringDamping);
        }
Пример #2
0
        public override unsafe void Create(EntityManager entityManager)
        {
            if (AutoSetConnected)
            {
                PositionLocal = math.transform(math.inverse(worldFromA), math.transform(worldFromB, PositionInConnectedEntity));
            }

            CreateJointEntity(JointData.CreateStiffSpring(
                                  PositionLocal, PositionInConnectedEntity,
                                  MinDistance, MaxDistance),
                              entityManager);
        }