PhysXCookingParams.cpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #include <System/PhysXCookingParams.h>
  9. namespace PhysX
  10. {
  11. namespace PxCooking
  12. {
  13. //! Return PxCookingParams better suited for use at run-time, these parameters will improve cooking time.
  14. //! Reference: https://docs.nvidia.com/gameworks/content/gameworkslibrary/physx/guide/Manual/Geometry.html#triangle-meshes
  15. physx::PxCookingParams GetRealTimeCookingParams()
  16. {
  17. physx::PxCookingParams params{ physx::PxTolerancesScale() };
  18. // disable mesh cleaning - perform mesh validation on development configurations
  19. params.meshPreprocessParams |= physx::PxMeshPreprocessingFlag::eDISABLE_CLEAN_MESH;
  20. // disable edge pre-compute, edges are set for each triangle, slows contact generation
  21. params.meshPreprocessParams |= physx::PxMeshPreprocessingFlag::eDISABLE_ACTIVE_EDGES_PRECOMPUTE;
  22. return params;
  23. }
  24. //! Return PxCookingParams better suited for use at edit-time, these parameters will
  25. //! increase cooking time but improve accuracy/precision.
  26. physx::PxCookingParams GetEditTimeCookingParams()
  27. {
  28. physx::PxCookingParams params{ physx::PxTolerancesScale() };
  29. // when set, mesh welding is performed - clean mesh must be enabled
  30. params.meshPreprocessParams |= physx::PxMeshPreprocessingFlag::eWELD_VERTICES;
  31. // note: default value in PxCookingParams is 0.0f;
  32. const float physx_CookWeldTolerance = 0.0001f;
  33. params.meshWeldTolerance = physx_CookWeldTolerance;
  34. return params;
  35. }
  36. }
  37. }