public ClothSimulator(ClothMeshModifier meshModifier, ClothSetting setting)
        {
            _meshModifier = meshModifier;
            _setting      = setting;

            var vertexCount = meshModifier.vertexCount;

            _predictPositions = new NativeList <float3>(vertexCount, Allocator.Persistent);
            _predictPositions.AddRange(meshModifier.vertices);

            _velocities = new NativeList <float3>(vertexCount, Allocator.Persistent);
            _velocities.Resize(vertexCount, NativeArrayOptions.ClearMemory);

            _pinConstraints = new NativeList <PinConstraintInfo>(vertexCount, Allocator.Persistent);
            _pinConstraints.Resize(vertexCount, NativeArrayOptions.ClearMemory);

            _collisionConstraints = new NativeList <CollisionConstraintInfo>(vertexCount, Allocator.Persistent);
            _collisionConstraints.Resize(vertexCount, NativeArrayOptions.ClearMemory);

            _constraintTypes = new NativeList <ConstraintType>(vertexCount, Allocator.Persistent);
            _constraintTypes.Resize(vertexCount, NativeArrayOptions.ClearMemory);

            _positionCorrects = new NativeArray <float3>(vertexCount, Allocator.Persistent);

            _colliderDescGroups = new CollidersGroup(Allocator.Persistent);

            _rigidBodyForceApplys = new NativeList <RigidBodyForceApply>(vertexCount * 8, Allocator.Persistent);

            this.BuildMasses();
            this.BuildDistConstraints();
            this.BuildBendConstraints();
        }
예제 #2
0
        public override void FillColliderDesc(CollidersGroup collidersGroup)
        {
            RigidbodyDesc rigidbodyDesc = default(RigidbodyDesc);
            float         mass          = 0;

            if (_rigidbody && !_rigidbody.isKinematic)
            {
                mass = _rigidbody.mass;
                rigidbodyDesc.mass     = _rigidbody.mass;
                rigidbodyDesc.velocity = _rigidbody.velocity;
            }

            collidersGroup.AddCapsule(this.desc, rigidbodyDesc, this.entityId);
        }
 public virtual void FillColliderDesc(CollidersGroup collidersGroup)
 {
 }