29#ifndef PXS_MATERIAL_COMBINER_H
30#define PXS_MATERIAL_COMBINER_H
32#include "PxsMaterialCore.h"
36 PX_CUDA_CALLABLE
PX_FORCE_INLINE PxReal combineScalars(PxReal a, PxReal b, PxI32 combineMode)
41 return 0.5f * (a + b);
53 PX_CUDA_CALLABLE
PX_FORCE_INLINE PxReal PxsCombineRestitution(
const PxsMaterialData& mat0,
const PxsMaterialData& mat1)
61 PX_CUDA_CALLABLE
PX_FORCE_INLINE void PxsCombineIsotropicFriction(
const PxsMaterialData& mat0,
const PxsMaterialData& mat1, PxReal& dynamicFriction, PxReal& staticFriction, PxU32& flags)
63 const PxU32 combineFlags = (mat0.flags | mat1.flags);
67 const PxI32 fictionCombineMode =
PxMax(mat0.getFrictionCombineMode(), mat1.getFrictionCombineMode());
68 PxReal dynFriction = 0.0f;
69 PxReal staFriction = 0.0f;
71 switch (fictionCombineMode)
74 dynFriction = 0.5f * (mat0.dynamicFriction + mat1.dynamicFriction);
75 staFriction = 0.5f * (mat0.staticFriction + mat1.staticFriction);
78 dynFriction =
PxMin(mat0.dynamicFriction, mat1.dynamicFriction);
79 staFriction =
PxMin(mat0.staticFriction, mat1.staticFriction);
82 dynFriction = (mat0.dynamicFriction * mat1.dynamicFriction);
83 staFriction = (mat0.staticFriction * mat1.staticFriction);
86 dynFriction =
PxMax(mat0.dynamicFriction, mat1.dynamicFriction);
87 staFriction =
PxMax(mat0.staticFriction, mat1.staticFriction);
92 const PxReal fDynFriction =
PxMax(dynFriction, 0.0f);
98 const PxReal fStaFriction = (staFriction - fDynFriction) > 0 ? staFriction : dynFriction;
100 const PxReal fStaFriction = physx::intrinsics::fsel(staFriction - fDynFriction, staFriction, fDynFriction);
102 dynamicFriction = fDynFriction;
103 staticFriction = fStaFriction;
104 flags = combineFlags;
109 dynamicFriction = 0.0f;
110 staticFriction = 0.0f;
#define PX_FORCE_INLINE
Definition PxPreprocessor.h:335
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39
PX_CUDA_CALLABLE PX_FORCE_INLINE T PxMax(T a, T b)
The return value is the greater of the two specified values.
Definition PxMath.h:72
PX_CUDA_CALLABLE PX_FORCE_INLINE T PxMin(T a, T b)
The return value is the lesser of the two specified values.
Definition PxMath.h:88
@ eMAX
Maximum: maximum(a,b)
Definition PxMaterial.h:137
@ eMULTIPLY
Multiply: a*b.
Definition PxMaterial.h:136
@ eMIN
Minimum: minimum(a,b)
Definition PxMaterial.h:135
@ eAVERAGE
Average: (a + b)/2.
Definition PxMaterial.h:134
@ eDISABLE_STRONG_FRICTION
Whether to use strong friction. The difference between "normal" and "strong" friction is that the str...
Definition PxMaterial.h:78
@ eCOMPLIANT_CONTACT
This flag has the effect of enabling an implicit spring model for the normal force computation.
Definition PxMaterial.h:98
@ eDISABLE_FRICTION
If this flag is set, friction computations are always skipped between shapes with this material and a...
Definition PxMaterial.h:57