/* * All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or * its licensors. * * For complete copyright and license terms please see the LICENSE at the root of this * distribution (the "License"). All use of this software is governed by the License, * or, if provided, by the license below or the license accompanying this file. Do not * remove or modify any license notices. This file is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * */ #pragma once #include #include #include namespace NvCloth { //! Manages motion and separation constraints for cloth. class ClothConstraints { public: AZ_TYPE_INFO(ClothConstraints, "{EB14ED7C-37FD-4CA3-9137-EC6590712E50}"); static AZStd::unique_ptr Create( const AZStd::vector& motionConstraintsData, const float motionConstraintsMaxDistance, const AZStd::vector& backstopData, const float backstopMaxRadius, const float backstopMaxBackOffset, const float backstopMaxFrontOffset, const AZStd::vector& simParticles, const AZStd::vector& simIndices, const AZStd::vector& meshRemappedVertices); ClothConstraints() = default; void CalculateConstraints( const AZStd::vector& simParticles, const AZStd::vector& simIndices); const AZStd::vector& GetMotionConstraints() const; const AZStd::vector& GetSeparationConstraints() const; void SetMotionConstraintMaxDistance(float distance); void SetBackstopMaxRadius(float radius); void SetBackstopMaxOffsets(float backOffset, float frontOffset); private: void CalculateMotionConstraints(); void CalculateSeparationConstraints(); AZ::Vector3 CalculateBackstopSpherePosition( const AZ::Vector3& position, const AZ::Vector3& normal, float offset, float radius) const; // Simulation Particles AZStd::vector m_simParticles; // Motion constraints data AZStd::vector m_motionConstraintsData; float m_motionConstraintsMaxDistance = 0.0f; // Backstop data AZStd::vector m_backstopData; float m_backstopMaxRadius = 0.0f; float m_backstopMaxBackOffset = 0.0f; float m_backstopMaxFrontOffset = 0.0f; AZStd::vector m_normals; // The current positions and radius of motion constraints. AZStd::vector m_motionConstraints; // The current positions and radius of separation constraints. AZStd::vector m_separationConstraints; }; } // namespace NvCloth