SoftBodyCreator.h 1.9 KB

12345678910111213141516171819202122232425262728293031
  1. // Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
  2. // SPDX-FileCopyrightText: 2023 Jorrit Rouwe
  3. // SPDX-License-Identifier: MIT
  4. #pragma once
  5. #include <Jolt/Physics/SoftBody/SoftBodySharedSettings.h>
  6. namespace SoftBodyCreator
  7. {
  8. /// Create a square cloth
  9. /// @param inGridSizeX Number of points along the X axis
  10. /// @param inGridSizeZ Number of points along the Z axis
  11. /// @param inGridSpacing Distance between points
  12. /// @param inVertexGetInvMass Function that determines the inverse mass of each vertex
  13. Ref<SoftBodySharedSettings> CreateCloth(uint inGridSizeX = 30, uint inGridSizeZ = 30, float inGridSpacing = 0.75f, const function<float(uint, uint)> &inVertexGetInvMass = [](uint, uint) { return 1.0f; }, const function<Vec3(uint, uint)> &inVertexPerturbation = [](uint, uint) { return Vec3::sZero(); }, SoftBodySharedSettings::EBendType inBendType = SoftBodySharedSettings::EBendType::None, const SoftBodySharedSettings::VertexAttributes &inVertexAttributes = { 1.0e-5f, 1.0e-5f, 1.0e-5f });
  14. /// Same as above but fixates the corners of the cloth
  15. Ref<SoftBodySharedSettings> CreateClothWithFixatedCorners(uint inGridSizeX = 30, uint inGridSizeZ = 30, float inGridSpacing = 0.75f);
  16. /// Create a cube
  17. /// @param inGridSize Number of points along each axis
  18. /// @param inGridSpacing Distance between points
  19. Ref<SoftBodySharedSettings> CreateCube(uint inGridSize = 5, float inGridSpacing = 0.5f);
  20. /// Create a hollow sphere
  21. /// @param inRadius Radius of the sphere
  22. /// @param inNumTheta Number of segments in the theta direction
  23. /// @param inNumPhi Number of segments in the phi direction
  24. Ref<SoftBodySharedSettings> CreateSphere(float inRadius = 1.0f, uint inNumTheta = 10, uint inNumPhi = 20, SoftBodySharedSettings::EBendType inBendType = SoftBodySharedSettings::EBendType::None, const SoftBodySharedSettings::VertexAttributes &inVertexAttributes = { 1.0e-4f, 1.0e-4f, 1.0e-3f });
  25. };