@onerjs/core 8.51.4 → 8.51.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (173) hide show
  1. package/Animations/animatorAvatar.d.ts +2 -0
  2. package/Animations/animatorAvatar.js +163 -94
  3. package/Animations/animatorAvatar.js.map +1 -1
  4. package/Engines/constants.d.ts +10 -0
  5. package/Engines/constants.js +10 -0
  6. package/Engines/constants.js.map +1 -1
  7. package/Materials/Node/Blocks/Fragment/perturbNormalBlock.js +6 -3
  8. package/Materials/Node/Blocks/Fragment/perturbNormalBlock.js.map +1 -1
  9. package/Materials/PBR/openpbrMaterial.d.ts +8 -0
  10. package/Materials/PBR/openpbrMaterial.js +16 -0
  11. package/Materials/PBR/openpbrMaterial.js.map +1 -1
  12. package/Materials/PBR/pbrBaseMaterial.d.ts +1 -0
  13. package/Materials/PBR/pbrBaseMaterial.js +8 -0
  14. package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
  15. package/Materials/Textures/Procedurals/proceduralTexture.d.ts +6 -0
  16. package/Materials/Textures/Procedurals/proceduralTexture.js +3 -1
  17. package/Materials/Textures/Procedurals/proceduralTexture.js.map +1 -1
  18. package/Materials/Textures/index.d.ts +1 -0
  19. package/Materials/Textures/index.js +1 -0
  20. package/Materials/Textures/index.js.map +1 -1
  21. package/Materials/Textures/textureMerger.js +1 -0
  22. package/Materials/Textures/textureMerger.js.map +1 -1
  23. package/Materials/Textures/textureProcessor.d.ts +315 -0
  24. package/Materials/Textures/textureProcessor.js +792 -0
  25. package/Materials/Textures/textureProcessor.js.map +1 -0
  26. package/Materials/material.d.ts +24 -0
  27. package/Materials/material.js +39 -0
  28. package/Materials/material.js.map +1 -1
  29. package/Materials/standardMaterial.d.ts +1 -0
  30. package/Materials/standardMaterial.js +6 -0
  31. package/Materials/standardMaterial.js.map +1 -1
  32. package/Physics/v2/characterController.d.ts +104 -7
  33. package/Physics/v2/characterController.js +355 -7
  34. package/Physics/v2/characterController.js.map +1 -1
  35. package/Shaders/ShadersInclude/bumpFragment.js +3 -3
  36. package/Shaders/ShadersInclude/bumpFragment.js.map +1 -1
  37. package/Shaders/ShadersInclude/bumpFragmentMainFunctions.js +5 -1
  38. package/Shaders/ShadersInclude/bumpFragmentMainFunctions.js.map +1 -1
  39. package/Shaders/ShadersInclude/defaultFragmentDeclaration.js +3 -0
  40. package/Shaders/ShadersInclude/defaultFragmentDeclaration.js.map +1 -1
  41. package/Shaders/ShadersInclude/defaultUboDeclaration.js +1 -1
  42. package/Shaders/ShadersInclude/defaultUboDeclaration.js.map +1 -1
  43. package/Shaders/ShadersInclude/defaultVertexDeclaration.js +1 -1
  44. package/Shaders/ShadersInclude/defaultVertexDeclaration.js.map +1 -1
  45. package/Shaders/ShadersInclude/openpbrAmbientOcclusionData.js +1 -1
  46. package/Shaders/ShadersInclude/openpbrAmbientOcclusionData.js.map +1 -1
  47. package/Shaders/ShadersInclude/openpbrBackgroundTransmission.js +1 -1
  48. package/Shaders/ShadersInclude/openpbrBackgroundTransmission.js.map +1 -1
  49. package/Shaders/ShadersInclude/openpbrBaseLayerData.js +14 -14
  50. package/Shaders/ShadersInclude/openpbrBaseLayerData.js.map +1 -1
  51. package/Shaders/ShadersInclude/openpbrCoatLayerData.js +6 -6
  52. package/Shaders/ShadersInclude/openpbrCoatLayerData.js.map +1 -1
  53. package/Shaders/ShadersInclude/openpbrDirectLighting.js +1 -1
  54. package/Shaders/ShadersInclude/openpbrDirectLighting.js.map +1 -1
  55. package/Shaders/ShadersInclude/openpbrEnvironmentLighting.js +1 -1
  56. package/Shaders/ShadersInclude/openpbrEnvironmentLighting.js.map +1 -1
  57. package/Shaders/ShadersInclude/openpbrFragmentDeclaration.js +3 -0
  58. package/Shaders/ShadersInclude/openpbrFragmentDeclaration.js.map +1 -1
  59. package/Shaders/ShadersInclude/openpbrFuzzLayerData.js +3 -3
  60. package/Shaders/ShadersInclude/openpbrFuzzLayerData.js.map +1 -1
  61. package/Shaders/ShadersInclude/openpbrNormalMapFragment.js +4 -4
  62. package/Shaders/ShadersInclude/openpbrNormalMapFragment.js.map +1 -1
  63. package/Shaders/ShadersInclude/openpbrSubsurfaceLayerData.js +7 -3
  64. package/Shaders/ShadersInclude/openpbrSubsurfaceLayerData.js.map +1 -1
  65. package/Shaders/ShadersInclude/openpbrThinFilmLayerData.js +2 -2
  66. package/Shaders/ShadersInclude/openpbrThinFilmLayerData.js.map +1 -1
  67. package/Shaders/ShadersInclude/openpbrTransmissionLayerData.js +5 -5
  68. package/Shaders/ShadersInclude/openpbrTransmissionLayerData.js.map +1 -1
  69. package/Shaders/ShadersInclude/openpbrUboDeclaration.js +1 -1
  70. package/Shaders/ShadersInclude/openpbrUboDeclaration.js.map +1 -1
  71. package/Shaders/ShadersInclude/openpbrVertexDeclaration.js +1 -1
  72. package/Shaders/ShadersInclude/openpbrVertexDeclaration.js.map +1 -1
  73. package/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents.js +1 -1
  74. package/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents.js.map +1 -1
  75. package/Shaders/ShadersInclude/pbrBlockLightmapInit.js +1 -1
  76. package/Shaders/ShadersInclude/pbrBlockLightmapInit.js.map +1 -1
  77. package/Shaders/ShadersInclude/pbrFragmentDeclaration.js +3 -0
  78. package/Shaders/ShadersInclude/pbrFragmentDeclaration.js.map +1 -1
  79. package/Shaders/ShadersInclude/pbrHelperFunctions.js +4 -0
  80. package/Shaders/ShadersInclude/pbrHelperFunctions.js.map +1 -1
  81. package/Shaders/ShadersInclude/pbrUboDeclaration.js +1 -1
  82. package/Shaders/ShadersInclude/pbrUboDeclaration.js.map +1 -1
  83. package/Shaders/ShadersInclude/pbrVertexDeclaration.js +1 -1
  84. package/Shaders/ShadersInclude/pbrVertexDeclaration.js.map +1 -1
  85. package/Shaders/ShadersInclude/textureRepetitionFunctions.d.ts +5 -0
  86. package/Shaders/ShadersInclude/textureRepetitionFunctions.js +52 -0
  87. package/Shaders/ShadersInclude/textureRepetitionFunctions.js.map +1 -0
  88. package/Shaders/default.fragment.d.ts +1 -0
  89. package/Shaders/default.fragment.js +8 -6
  90. package/Shaders/default.fragment.js.map +1 -1
  91. package/Shaders/geometry.fragment.js +3 -3
  92. package/Shaders/geometry.fragment.js.map +1 -1
  93. package/Shaders/openpbr.fragment.d.ts +1 -0
  94. package/Shaders/openpbr.fragment.js +4 -2
  95. package/Shaders/openpbr.fragment.js.map +1 -1
  96. package/Shaders/pbr.fragment.d.ts +1 -0
  97. package/Shaders/pbr.fragment.js +24 -22
  98. package/Shaders/pbr.fragment.js.map +1 -1
  99. package/Shaders/textureProcessor.fragment.d.ts +5 -0
  100. package/Shaders/textureProcessor.fragment.js +156 -0
  101. package/Shaders/textureProcessor.fragment.js.map +1 -0
  102. package/ShadersWGSL/ShadersInclude/bumpFragment.js +3 -3
  103. package/ShadersWGSL/ShadersInclude/bumpFragment.js.map +1 -1
  104. package/ShadersWGSL/ShadersInclude/bumpFragmentMainFunctions.js +5 -1
  105. package/ShadersWGSL/ShadersInclude/bumpFragmentMainFunctions.js.map +1 -1
  106. package/ShadersWGSL/ShadersInclude/defaultUboDeclaration.js +1 -1
  107. package/ShadersWGSL/ShadersInclude/defaultUboDeclaration.js.map +1 -1
  108. package/ShadersWGSL/ShadersInclude/openpbrAmbientOcclusionData.js +1 -1
  109. package/ShadersWGSL/ShadersInclude/openpbrAmbientOcclusionData.js.map +1 -1
  110. package/ShadersWGSL/ShadersInclude/openpbrBackgroundTransmission.js +1 -1
  111. package/ShadersWGSL/ShadersInclude/openpbrBackgroundTransmission.js.map +1 -1
  112. package/ShadersWGSL/ShadersInclude/openpbrBaseLayerData.js +15 -15
  113. package/ShadersWGSL/ShadersInclude/openpbrBaseLayerData.js.map +1 -1
  114. package/ShadersWGSL/ShadersInclude/openpbrCoatLayerData.js +7 -7
  115. package/ShadersWGSL/ShadersInclude/openpbrCoatLayerData.js.map +1 -1
  116. package/ShadersWGSL/ShadersInclude/openpbrDirectLighting.js +1 -1
  117. package/ShadersWGSL/ShadersInclude/openpbrDirectLighting.js.map +1 -1
  118. package/ShadersWGSL/ShadersInclude/openpbrEnvironmentLighting.js +1 -1
  119. package/ShadersWGSL/ShadersInclude/openpbrEnvironmentLighting.js.map +1 -1
  120. package/ShadersWGSL/ShadersInclude/openpbrFuzzLayerData.js +4 -4
  121. package/ShadersWGSL/ShadersInclude/openpbrFuzzLayerData.js.map +1 -1
  122. package/ShadersWGSL/ShadersInclude/openpbrIblFunctions.js +3 -3
  123. package/ShadersWGSL/ShadersInclude/openpbrIblFunctions.js.map +1 -1
  124. package/ShadersWGSL/ShadersInclude/openpbrNormalMapFragment.js +4 -4
  125. package/ShadersWGSL/ShadersInclude/openpbrNormalMapFragment.js.map +1 -1
  126. package/ShadersWGSL/ShadersInclude/openpbrSubsurfaceLayerData.js +7 -3
  127. package/ShadersWGSL/ShadersInclude/openpbrSubsurfaceLayerData.js.map +1 -1
  128. package/ShadersWGSL/ShadersInclude/openpbrThinFilmLayerData.js +2 -2
  129. package/ShadersWGSL/ShadersInclude/openpbrThinFilmLayerData.js.map +1 -1
  130. package/ShadersWGSL/ShadersInclude/openpbrTransmissionLayerData.js +6 -6
  131. package/ShadersWGSL/ShadersInclude/openpbrTransmissionLayerData.js.map +1 -1
  132. package/ShadersWGSL/ShadersInclude/openpbrUboDeclaration.js +1 -1
  133. package/ShadersWGSL/ShadersInclude/openpbrUboDeclaration.js.map +1 -1
  134. package/ShadersWGSL/ShadersInclude/pbrBlockFinalUnlitComponents.js +1 -1
  135. package/ShadersWGSL/ShadersInclude/pbrBlockFinalUnlitComponents.js.map +1 -1
  136. package/ShadersWGSL/ShadersInclude/pbrBlockLightmapInit.js +1 -1
  137. package/ShadersWGSL/ShadersInclude/pbrBlockLightmapInit.js.map +1 -1
  138. package/ShadersWGSL/ShadersInclude/pbrHelperFunctions.js +4 -0
  139. package/ShadersWGSL/ShadersInclude/pbrHelperFunctions.js.map +1 -1
  140. package/ShadersWGSL/ShadersInclude/pbrUboDeclaration.js +1 -1
  141. package/ShadersWGSL/ShadersInclude/pbrUboDeclaration.js.map +1 -1
  142. package/ShadersWGSL/ShadersInclude/textureRepetitionFunctions.d.ts +5 -0
  143. package/ShadersWGSL/ShadersInclude/textureRepetitionFunctions.js +52 -0
  144. package/ShadersWGSL/ShadersInclude/textureRepetitionFunctions.js.map +1 -0
  145. package/ShadersWGSL/default.fragment.d.ts +1 -0
  146. package/ShadersWGSL/default.fragment.js +8 -6
  147. package/ShadersWGSL/default.fragment.js.map +1 -1
  148. package/ShadersWGSL/geometry.fragment.js +3 -3
  149. package/ShadersWGSL/geometry.fragment.js.map +1 -1
  150. package/ShadersWGSL/openpbr.fragment.d.ts +1 -0
  151. package/ShadersWGSL/openpbr.fragment.js +5 -3
  152. package/ShadersWGSL/openpbr.fragment.js.map +1 -1
  153. package/ShadersWGSL/openpbr.vertex.js +1 -1
  154. package/ShadersWGSL/openpbr.vertex.js.map +1 -1
  155. package/ShadersWGSL/pbr.fragment.d.ts +1 -0
  156. package/ShadersWGSL/pbr.fragment.js +24 -22
  157. package/ShadersWGSL/pbr.fragment.js.map +1 -1
  158. package/ShadersWGSL/textureProcessor.fragment.d.ts +5 -0
  159. package/ShadersWGSL/textureProcessor.fragment.js +161 -0
  160. package/ShadersWGSL/textureProcessor.fragment.js.map +1 -0
  161. package/SmartAssets/index.d.ts +2 -0
  162. package/SmartAssets/index.js +2 -0
  163. package/SmartAssets/index.js.map +1 -0
  164. package/SmartAssets/smartAssetManager.d.ts +156 -0
  165. package/SmartAssets/smartAssetManager.js +531 -0
  166. package/SmartAssets/smartAssetManager.js.map +1 -0
  167. package/SmartAssets/smartAssetSerializer.d.ts +61 -0
  168. package/SmartAssets/smartAssetSerializer.js +97 -0
  169. package/SmartAssets/smartAssetSerializer.js.map +1 -0
  170. package/index.d.ts +1 -0
  171. package/index.js +1 -0
  172. package/index.js.map +1 -1
  173. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"characterController.js","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AM,CAAC;IAClB,CAAC;CACJ","sourcesContent":["import { Vector3, Quaternion, Matrix, TmpVectors } from \"../../Maths/math.vector\";\r\nimport { type Scene } from \"../../scene\";\r\nimport { type DeepImmutableObject } from \"../../types\";\r\nimport { PhysicsBody } from \"./physicsBody\";\r\nimport { PhysicsShapeCapsule, type PhysicsShape } from \"./physicsShape\";\r\nimport { PhysicsMotionType } from \"./IPhysicsEnginePlugin\";\r\nimport { type HavokPlugin } from \"./Plugins/havokPlugin\";\r\nimport { BuildArray } from \"../../Misc/arrayTools\";\r\nimport { TransformNode } from \"../../Meshes/transformNode\";\r\nimport { Observable } from \"../../Misc/observable\";\r\n\r\n/**\r\n * Shape properties for the character controller\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport interface CharacterShapeOptions {\r\n /**\r\n * optional shape used for collision detection\r\n */\r\n shape?: PhysicsShape;\r\n /**\r\n * capsule height for the capsule shape if no shape is provided\r\n */\r\n capsuleHeight?: number;\r\n /**\r\n * capsule radius for the capsule shape if no shape is provided\r\n */\r\n capsuleRadius?: number;\r\n}\r\n\r\n/**\r\n * Collision event data for the character controller\r\n */\r\nexport interface ICharacterControllerCollisionEvent {\r\n /**\r\n * The collider physics body\r\n */\r\n collider: PhysicsBody;\r\n /**\r\n *\r\n */\r\n colliderIndex: number;\r\n /**\r\n * Separation force applied to the collider\r\n */\r\n impulse: Vector3;\r\n /**\r\n * Position where the impulse is applied\r\n */\r\n impulsePosition: Vector3;\r\n}\r\n\r\n/**\r\n * State of the character on the surface\r\n */\r\nexport const enum CharacterSupportedState {\r\n UNSUPPORTED,\r\n SLIDING,\r\n SUPPORTED,\r\n}\r\n\r\n/**\r\n * Surface information computed by checkSupport method\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport interface CharacterSurfaceInfo {\r\n /**\r\n * Indicates whether the surface is dynamic.\r\n * A dynamic surface is one that can change its properties over time,\r\n * such as moving platforms or surfaces that can be affected by external forces.\r\n * surfaceInfo.supportedState is always CharacterSupportedState.SUPPORTED when isSurfaceDynamic is true.\r\n */\r\n isSurfaceDynamic: boolean;\r\n /**\r\n * The supported state of the character on the surface.\r\n */\r\n supportedState: CharacterSupportedState;\r\n /**\r\n * The average normal vector of the surface.\r\n * This vector is perpendicular to the surface and points outwards.\r\n */\r\n averageSurfaceNormal: Vector3;\r\n /**\r\n * The average velocity of the surface.\r\n * This vector represents the speed and direction in which the surface is moving.\r\n */\r\n averageSurfaceVelocity: Vector3;\r\n /**\r\n * The average angular velocity of the surface.\r\n */\r\n averageAngularSurfaceVelocity: Vector3;\r\n}\r\n\r\ninterface IContact {\r\n /** @internal */\r\n position: Vector3;\r\n /** @internal */\r\n normal: Vector3;\r\n /** @internal */\r\n distance: number;\r\n /** @internal */\r\n fraction: number;\r\n /** @internal */\r\n bodyB: { body: PhysicsBody; index: number };\r\n /** @internal */\r\n allowedPenetration: number;\r\n}\r\n\r\ninterface ISurfaceConstraintInfo {\r\n /** @internal */\r\n planeNormal: Vector3;\r\n /** @internal */\r\n planeDistance: number;\r\n /** @internal */\r\n velocity: Vector3;\r\n /** @internal */\r\n angularVelocity: Vector3;\r\n /** @internal */\r\n staticFriction: number;\r\n /** @internal */\r\n extraUpStaticFriction: number;\r\n /** @internal */\r\n extraDownStaticFriction: number;\r\n /** @internal */\r\n dynamicFriction: number;\r\n /** @internal */\r\n priority: number;\r\n}\r\n\r\nconst enum SurfaceConstraintInteractionStatus {\r\n OK,\r\n FAILURE_3D,\r\n FAILURE_2D,\r\n}\r\ninterface ISurfaceConstraintInteraction {\r\n /** @internal */\r\n touched: boolean;\r\n /** @internal */\r\n stopped: boolean;\r\n /** @internal */\r\n surfaceTime: number;\r\n /** @internal */\r\n penaltyDistance: number;\r\n /** @internal */\r\n status: SurfaceConstraintInteractionStatus;\r\n}\r\n\r\n/** @internal */\r\nclass SimplexSolverOutput {\r\n /** @internal */\r\n public position: Vector3;\r\n /** @internal */\r\n public velocity: Vector3;\r\n /** @internal */\r\n public deltaTime: number;\r\n /** @internal */\r\n public planeInteractions: ISurfaceConstraintInteraction[];\r\n}\r\n\r\n/** @internal */\r\nclass SimplexSolverActivePlanes {\r\n /** @internal */\r\n public index: number;\r\n /** @internal */\r\n public constraint: ISurfaceConstraintInfo;\r\n /** @internal */\r\n public interaction: ISurfaceConstraintInteraction;\r\n\r\n /** @internal */\r\n public copyFrom(other: SimplexSolverActivePlanes) {\r\n this.index = other.index;\r\n this.constraint = other.constraint;\r\n this.interaction = other.interaction;\r\n }\r\n}\r\n\r\n/** @internal */\r\nclass SimplexSolverInfo {\r\n /** @internal */\r\n public supportPlanes: Array<SimplexSolverActivePlanes> = new Array<SimplexSolverActivePlanes>(4);\r\n /** @internal */\r\n public numSupportPlanes: number = 0;\r\n /** @internal */\r\n public currentTime: number = 0;\r\n /** @internal */\r\n public inputConstraints: ISurfaceConstraintInfo[];\r\n /** @internal */\r\n public outputInteractions: ISurfaceConstraintInteraction[];\r\n /** @internal */\r\n public getOutput(constraint: ISurfaceConstraintInfo): ISurfaceConstraintInteraction {\r\n return this.outputInteractions[this.inputConstraints.indexOf(constraint)]; //<todo.eoin This is O(1) in C++! Equivalent in TS?\r\n }\r\n}\r\n\r\n/** @internal */\r\nfunction ContactFromCast(hp: HavokPlugin, cp: any /*ContactPoint*/, castPath: Vector3, hitFraction: number, keepDistance: number): IContact {\r\n const bodyMap = (hp as any)._bodies;\r\n\r\n const normal = Vector3.FromArray(cp[4]);\r\n const dist = -hitFraction * castPath.dot(normal);\r\n return {\r\n position: Vector3.FromArray(cp[3]),\r\n normal: normal,\r\n distance: dist,\r\n fraction: hitFraction,\r\n bodyB: bodyMap.get(cp[0][0])!,\r\n allowedPenetration: Math.min(Math.max(keepDistance - dist, 0.0), keepDistance),\r\n };\r\n}\r\n\r\n/**\r\n * Character controller using physics\r\n */\r\nexport class PhysicsCharacterController {\r\n private _position: Vector3;\r\n private _orientation: Quaternion = Quaternion.Identity();\r\n private _velocity: Vector3;\r\n private _lastVelocity: Vector3;\r\n private _shape: PhysicsShape;\r\n private _body: PhysicsBody;\r\n private _transformNode: TransformNode;\r\n private _ownShape: boolean;\r\n private _manifold: IContact[] = [];\r\n private _lastDisplacement: Vector3;\r\n private _contactAngleSensitivity = 10.0;\r\n private _lastInvDeltaTime: number;\r\n protected _scene: Scene;\r\n private _tmpMatrix = new Matrix();\r\n private _tmpVecs: Vector3[] = BuildArray(32, Vector3.Zero);\r\n\r\n /**\r\n * minimum distance to make contact\r\n * default 0.05\r\n */\r\n public keepDistance: number = 0.05;\r\n /**\r\n * maximum distance to keep contact\r\n * default 0.1\r\n */\r\n public keepContactTolerance: number = 0.1;\r\n /**\r\n * maximum number of raycast per integration starp\r\n * default 10\r\n */\r\n public maxCastIterations: number = 10;\r\n /**\r\n * speed when recovery from penetration\r\n * default 1.0\r\n */\r\n public penetrationRecoverySpeed = 1.0;\r\n /**\r\n * friction with static surfaces\r\n * default 0\r\n */\r\n public staticFriction = 0;\r\n /**\r\n * friction with dynamic surfaces\r\n * default 1\r\n */\r\n public dynamicFriction = 1;\r\n /**\r\n * cosine value of slope angle that can be climbed\r\n * computed as `Math.cos(Math.PI * (angleInDegree / 180.0));`\r\n * default 0.5 (value for a 60deg angle)\r\n */\r\n public maxSlopeCosine = 0.5;\r\n /**\r\n * character maximum speed\r\n * default 10\r\n */\r\n public maxCharacterSpeedForSolver = 10.0;\r\n /**\r\n * up vector\r\n */\r\n public up = new Vector3(0, 1, 0);\r\n /**\r\n * Strength when pushing other bodies\r\n * default 1e38\r\n */\r\n public characterStrength = 1e38;\r\n\r\n /**\r\n * Acceleration factor. A value of 1 means reaching max velocity immediately\r\n */\r\n public acceleration = 0.05;\r\n\r\n /**\r\n * maximum acceleration in world space coordinate\r\n */\r\n public maxAcceleration = 50;\r\n\r\n /**\r\n * character mass\r\n * default 0\r\n */\r\n public characterMass = 0;\r\n\r\n /**\r\n * The height of the character's step.\r\n * The character will automatically step up onto stairs and obstacles that are below this height.\r\n * default 0.5\r\n */\r\n public stepHeight = 0.5;\r\n\r\n /**\r\n * Observable for trigger entered and trigger exited events\r\n */\r\n public onTriggerCollisionObservable = new Observable<ICharacterControllerCollisionEvent>();\r\n\r\n private _startCollector: any;\r\n private _castCollector: any;\r\n\r\n // If the difference between the cast displacement and the simplex solver output position is less than this\r\n // value (per component), do not do a second cast to check if it's possible to reach the output position.\r\n private _displacementEps = 1e-4;\r\n\r\n /**\r\n * The transformNode of the controller\r\n */\r\n public get transformNode() {\r\n return this._transformNode;\r\n }\r\n\r\n /**\r\n * instanciate a new characterController\r\n * @param position Initial position\r\n * @param characterShapeOptions character physics shape options\r\n * @param scene Scene\r\n */\r\n public constructor(position: Vector3, characterShapeOptions: CharacterShapeOptions, scene: Scene) {\r\n this._position = position.clone();\r\n this._velocity = Vector3.Zero();\r\n this._lastVelocity = Vector3.Zero();\r\n const r = characterShapeOptions.capsuleRadius ?? 0.6;\r\n const h = characterShapeOptions.capsuleHeight ?? 1.8;\r\n this._tmpVecs[0].set(0, h * 0.5 - r, 0);\r\n this._tmpVecs[1].set(0, -h * 0.5 + r, 0);\r\n this._ownShape = !characterShapeOptions.shape;\r\n this._shape = characterShapeOptions.shape ?? new PhysicsShapeCapsule(this._tmpVecs[0], this._tmpVecs[1], r, scene);\r\n this._transformNode = new TransformNode(\"CCTransformNode\", scene);\r\n this._transformNode.position.copyFrom(this._position);\r\n this._body = new PhysicsBody(this._transformNode, PhysicsMotionType.ANIMATED, false, scene);\r\n this._body.setMassProperties({ inertia: Vector3.ZeroReadOnly });\r\n this._body.shape = this._shape;\r\n this._body.disablePreStep = false;\r\n this._lastInvDeltaTime = 1.0 / 60.0;\r\n this._lastDisplacement = Vector3.Zero();\r\n this._scene = scene;\r\n\r\n const hk = this._scene.getPhysicsEngine()!.getPhysicsPlugin() as HavokPlugin;\r\n const hknp = hk._hknp;\r\n\r\n this._startCollector = hknp.HP_QueryCollector_Create(16)[1];\r\n this._castCollector = hknp.HP_QueryCollector_Create(16)[1];\r\n }\r\n\r\n /**\r\n * Dispose the character controller\r\n */\r\n public dispose() {\r\n if (this._ownShape) {\r\n this._shape.dispose();\r\n }\r\n this._body.dispose();\r\n this._transformNode.dispose();\r\n\r\n const hk = this._scene.getPhysicsEngine()!.getPhysicsPlugin() as HavokPlugin;\r\n const hknp = hk._hknp;\r\n hknp.HP_QueryCollector_Release(this._startCollector);\r\n hknp.HP_QueryCollector_Release(this._castCollector);\r\n }\r\n\r\n /**\r\n * Get shape used for collision\r\n */\r\n public get shape() {\r\n return this._shape;\r\n }\r\n\r\n /**\r\n * Set shape used for collision\r\n */\r\n public set shape(value: PhysicsShape) {\r\n if (this._ownShape) {\r\n this._shape.dispose();\r\n }\r\n this._shape = value;\r\n this._body.shape = this._shape;\r\n this._ownShape = false;\r\n }\r\n\r\n /**\r\n * Character position\r\n * @returns Character position\r\n */\r\n public getPosition(): Vector3 {\r\n return this._position;\r\n }\r\n\r\n /**\r\n * Teleport character to a new position\r\n * @param position new position\r\n */\r\n public setPosition(position: Vector3) {\r\n this._position.copyFrom(position);\r\n this._transformNode.position.copyFrom(this._position);\r\n }\r\n\r\n /**\r\n * Character velocity\r\n * @returns Character velocity vector\r\n */\r\n public getVelocity(): Vector3 {\r\n return this._velocity;\r\n }\r\n\r\n /**\r\n * Set velocity vector\r\n * @param velocity vector\r\n */\r\n public setVelocity(velocity: Vector3) {\r\n this._velocity.copyFrom(velocity);\r\n }\r\n\r\n protected _validateManifold() {\r\n const newManifold = [];\r\n for (let i = 0; i < this._manifold.length; i++) {\r\n if (!this._manifold[i].bodyB.body.isDisposed) {\r\n newManifold.push(this._manifold[i]);\r\n }\r\n }\r\n this._manifold = newManifold;\r\n }\r\n\r\n private _getPointVelocityToRef(body: { body: PhysicsBody; index: number }, pointWorld: Vector3, result: Vector3) {\r\n //<todo does this really not exist in body interface?\r\n const comWorld = this._tmpVecs[10];\r\n this._getComWorldToRef(body, comWorld);\r\n const relPos = this._tmpVecs[11];\r\n pointWorld.subtractToRef(comWorld, relPos);\r\n const av = this._tmpVecs[12];\r\n body.body.getAngularVelocityToRef(av, body.index);\r\n const arm = this._tmpVecs[13];\r\n Vector3.CrossToRef(av, relPos, arm);\r\n arm.addToRef(body.body.getLinearVelocity(body.index), result);\r\n }\r\n\r\n protected _compareContacts(contactA: IContact, contactB: IContact): number {\r\n const angSquared = (1.0 - contactA.normal.dot(contactB.normal)) * this._contactAngleSensitivity * this._contactAngleSensitivity;\r\n const planeDistSquared = (contactA.distance - contactB.distance) * (contactA.distance * contactB.distance);\r\n\r\n const p1Vel = this._tmpVecs[7];\r\n this._getPointVelocityToRef(contactA.bodyB, contactA.position, p1Vel);\r\n const p2Vel = this._tmpVecs[8];\r\n this._getPointVelocityToRef(contactB.bodyB, contactB.position, p2Vel);\r\n const velocityDiff = this._tmpVecs[9];\r\n p1Vel.subtractToRef(p2Vel, velocityDiff);\r\n const velocityDiffSquared = velocityDiff.lengthSquared();\r\n\r\n const fitness = angSquared * 10.0 + velocityDiffSquared * 0.1 + planeDistSquared;\r\n return fitness;\r\n }\r\n\r\n protected _findContact(referenceContact: IContact, contactList: IContact[], threshold: number) {\r\n let bestIdx = -1;\r\n let bestFitness = threshold;\r\n for (let i = 0; i < contactList.length; i++) {\r\n const fitness = this._compareContacts(referenceContact, contactList[i]);\r\n if (fitness < bestFitness) {\r\n bestFitness = fitness;\r\n bestIdx = i;\r\n }\r\n }\r\n return bestIdx;\r\n }\r\n\r\n protected _updateManifold(startCollector: any /*HP_CollectorId*/, castCollector: any /*HP_CollectorId*/, castPath: Vector3): number {\r\n const hk = this._scene.getPhysicsEngine()!.getPhysicsPlugin() as HavokPlugin;\r\n const hknp = hk._hknp;\r\n\r\n const numProximityHits = hknp.HP_QueryCollector_GetNumHits(startCollector)[1];\r\n if (numProximityHits > 0) {\r\n const newContacts = [];\r\n let minDistance = 1e38;\r\n const bodyMap = (<any>hk)._bodies;\r\n for (let i = 0; i < numProximityHits; i++) {\r\n const [distance, , contactWorld] = hknp.HP_QueryCollector_GetShapeProximityResult(startCollector, i)[1];\r\n minDistance = Math.min(minDistance, distance);\r\n newContacts.push({\r\n position: Vector3.FromArray(contactWorld[3]),\r\n normal: Vector3.FromArray(contactWorld[4]),\r\n distance: distance,\r\n fraction: 0,\r\n bodyB: bodyMap.get(contactWorld[0][0])!,\r\n allowedPenetration: Math.min(Math.max(this.keepDistance - distance, 0.0), this.keepDistance),\r\n });\r\n }\r\n\r\n for (let i = this._manifold.length - 1; i >= 0; i--) {\r\n const currentContact = this._manifold[i];\r\n const bestMatch = this._findContact(currentContact, newContacts, 1.1);\r\n if (bestMatch >= 0) {\r\n const newAllowedPenetration = Math.min(Math.max(this.keepDistance - newContacts[bestMatch].distance, 0.0), currentContact.allowedPenetration);\r\n this._manifold[i] = newContacts[bestMatch];\r\n this._manifold[i].allowedPenetration = newAllowedPenetration;\r\n newContacts.splice(bestMatch, 1);\r\n } else {\r\n this._manifold.splice(i, 1);\r\n }\r\n }\r\n\r\n const closestContactIndex = newContacts.findIndex((c) => c.distance == minDistance);\r\n if (closestContactIndex >= 0) {\r\n const bestMatch = this._findContact(newContacts[closestContactIndex], this._manifold, 0.1);\r\n if (bestMatch >= 0) {\r\n const newAllowedPenetration = Math.min(\r\n Math.max(this.keepDistance - newContacts[closestContactIndex].distance, 0.0),\r\n this._manifold[bestMatch].allowedPenetration\r\n );\r\n this._manifold[bestMatch] = newContacts[closestContactIndex];\r\n this._manifold[bestMatch].allowedPenetration = newAllowedPenetration;\r\n } else {\r\n this._manifold.push(newContacts[closestContactIndex]);\r\n }\r\n }\r\n } else {\r\n // No start hits; clear manifold completely\r\n this._manifold.length = 0;\r\n }\r\n\r\n let numHitBodies = 0; //< == CASTCOLLECTOR_HIT_SINGLE_BODY\r\n // Process shape cast results if any\r\n const numCastHits = hknp.HP_QueryCollector_GetNumHits(castCollector)[1];\r\n if (numCastHits > 0) {\r\n let closestHitBody = null;\r\n for (let i = 0; i < numCastHits; i++) {\r\n const [fraction, , hitWorld] = hknp.HP_QueryCollector_GetShapeCastResult(castCollector, i)[1];\r\n if (closestHitBody == null) {\r\n const contact = ContactFromCast(hk, hitWorld, castPath, fraction, this.keepDistance);\r\n closestHitBody = hitWorld[0][0];\r\n const bestMatch = this._findContact(contact, this._manifold, 0.1);\r\n if (bestMatch == -1) {\r\n this._manifold.push(contact);\r\n }\r\n\r\n if (contact.bodyB.body.getMotionType(contact.bodyB.index) == PhysicsMotionType.STATIC) {\r\n // The closest body is static, so it cannot move away from CC and we don't need to look any further.\r\n break;\r\n }\r\n } else if (closestHitBody._pluginData && hitWorld[0] != closestHitBody._pluginData.hpBodyId) {\r\n numHitBodies++;\r\n break;\r\n }\r\n }\r\n }\r\n\r\n // Remove from the manifold contacts that are too similar as the simplex does not handle parallel planes\r\n for (let e1 = this._manifold.length - 1; e1 >= 0; e1--) {\r\n let e2 = e1 - 1;\r\n for (; e2 >= 0; e2--) {\r\n const fitness = this._compareContacts(this._manifold[e1], this._manifold[e2]);\r\n if (fitness < 0.1) {\r\n break;\r\n }\r\n }\r\n if (e2 >= 0) {\r\n this._manifold.slice(e1, 1);\r\n }\r\n }\r\n\r\n return numHitBodies;\r\n }\r\n\r\n // Store previous positions per body for velocity calculation\r\n protected _bodyPositionTracking = new Map();\r\n\r\n protected _createSurfaceConstraint(dt: number, contact: IContact, timeTravelled: number): ISurfaceConstraintInfo {\r\n const constraint = {\r\n //let distance = contact.distance - this.keepDistance;\r\n planeNormal: contact.normal.clone(),\r\n planeDistance: contact.distance,\r\n staticFriction: this.staticFriction,\r\n dynamicFriction: this.dynamicFriction,\r\n extraUpStaticFriction: 0,\r\n extraDownStaticFriction: 0,\r\n velocity: Vector3.Zero(),\r\n angularVelocity: Vector3.Zero(),\r\n priority: 0,\r\n };\r\n\r\n const maxSlopeCosEps = 0.1;\r\n const maxSlopeCosine = Math.max(this.maxSlopeCosine, maxSlopeCosEps);\r\n const normalDotUp = contact.normal.dot(this.up);\r\n\r\n const contactPosition = contact.position.clone();\r\n if (normalDotUp > maxSlopeCosine) {\r\n const com = this.getPosition();\r\n const contactArm = this._tmpVecs[20];\r\n contact.position.subtractToRef(com, contactArm);\r\n const scale = contact.normal.dot(contactArm);\r\n contactPosition.x = com.x + this.up.x * scale;\r\n contactPosition.y = com.y + this.up.y * scale;\r\n contactPosition.z = com.z + this.up.z * scale;\r\n }\r\n\r\n const motionType = contact.bodyB.body.getMotionType(contact.bodyB.index);\r\n if (motionType != PhysicsMotionType.STATIC) {\r\n //<todo Need hknpMotionUtil::predictPontVelocity\r\n }\r\n\r\n const shift = constraint.velocity.dot(constraint.planeNormal) * timeTravelled;\r\n constraint.planeDistance -= shift;\r\n\r\n if (motionType == PhysicsMotionType.STATIC) {\r\n constraint.priority = 2;\r\n } else if (motionType == PhysicsMotionType.ANIMATED) {\r\n const bodyTransformNode = contact.bodyB.body.transformNode;\r\n const bodyId = bodyTransformNode.uniqueId;\r\n\r\n // Retrieve tracking data\r\n let tracking = this._bodyPositionTracking.get(bodyId);\r\n\r\n const currentFrameWorldMatrix = contact.bodyB.body.transformNode.getWorldMatrix();\r\n const frameId = this._scene.getFrameId();\r\n\r\n if (!tracking) {\r\n // Initialize tracking\r\n tracking = {\r\n prevWorldMatrix: currentFrameWorldMatrix.clone(),\r\n frameId: frameId,\r\n };\r\n this._bodyPositionTracking.set(bodyId, tracking);\r\n } else {\r\n // Only calculate velocity if this contact existed in the previous frame\r\n // This avoids huge delta spikes when first making contact or after gaps\r\n if (tracking.frameId + 1 === frameId) {\r\n const previousFrameWorldMatrix = tracking.prevWorldMatrix;\r\n\r\n const currentFrameWorldMatrixInverse = TmpVectors.Matrix[1];\r\n\r\n currentFrameWorldMatrix.invertToRef(currentFrameWorldMatrixInverse);\r\n\r\n const characterPosition = this.getPosition();\r\n // compute characterPosition in body local space at previous frame\r\n const characterLocalPosition = this._tmpVecs[21];\r\n Vector3.TransformCoordinatesToRef(characterPosition, currentFrameWorldMatrixInverse, characterLocalPosition);\r\n\r\n const characterWorldPosition = this._tmpVecs[22];\r\n Vector3.TransformCoordinatesToRef(characterLocalPosition, previousFrameWorldMatrix, characterWorldPosition);\r\n const playerDeltaPosition = this._tmpVecs[23];\r\n characterPosition.subtractToRef(characterWorldPosition, playerDeltaPosition);\r\n\r\n constraint.velocity.copyFrom(playerDeltaPosition);\r\n constraint.velocity.scaleInPlace(1 / dt);\r\n constraint.priority = 1;\r\n }\r\n tracking.prevWorldMatrix.copyFrom(currentFrameWorldMatrix);\r\n tracking.frameId = frameId;\r\n }\r\n }\r\n\r\n return constraint;\r\n }\r\n\r\n protected _addMaxSlopePlane(maxSlopeCos: number, up: Vector3, index: number, constraints: ISurfaceConstraintInfo[], allowedPenetration: number): boolean {\r\n const verticalComponent = constraints[index].planeNormal.dot(up);\r\n if (verticalComponent > 0.01 && verticalComponent < maxSlopeCos) {\r\n const newConstraint = {\r\n planeNormal: constraints[index].planeNormal.clone(),\r\n planeDistance: constraints[index].planeDistance,\r\n velocity: constraints[index].velocity.clone(),\r\n angularVelocity: constraints[index].angularVelocity.clone(),\r\n priority: constraints[index].priority,\r\n dynamicFriction: constraints[index].dynamicFriction,\r\n staticFriction: constraints[index].staticFriction,\r\n extraDownStaticFriction: constraints[index].extraDownStaticFriction,\r\n extraUpStaticFriction: constraints[index].extraUpStaticFriction,\r\n };\r\n const distance = newConstraint.planeDistance;\r\n newConstraint.planeNormal.subtractInPlace(up.scale(verticalComponent));\r\n newConstraint.planeNormal.normalize();\r\n if (distance >= 0) {\r\n newConstraint.planeDistance = distance * newConstraint.planeNormal.dot(constraints[index].planeNormal);\r\n } else {\r\n const penetrationToResolve = Math.min(0, distance + allowedPenetration);\r\n newConstraint.planeDistance = penetrationToResolve / newConstraint.planeNormal.dot(constraints[index].planeNormal);\r\n constraints[index].planeDistance = 0;\r\n this._resolveConstraintPenetration(newConstraint, this.penetrationRecoverySpeed);\r\n }\r\n constraints.push(newConstraint);\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n protected _resolveConstraintPenetration(constraint: ISurfaceConstraintInfo, penetrationRecoverySpeed: number) {\r\n // If penetrating we add extra velocity to push the character back out\r\n const eps = 1e-6;\r\n if (constraint.planeDistance < -eps) {\r\n constraint.planeNormal.scaleToRef(constraint.planeDistance * penetrationRecoverySpeed, this._tmpVecs[6]);\r\n constraint.velocity.subtractInPlace(this._tmpVecs[6]);\r\n }\r\n }\r\n\r\n protected _createConstraintsFromManifold(dt: number, timeTravelled: number): ISurfaceConstraintInfo[] {\r\n const constraints = [];\r\n for (let i = 0; i < this._manifold.length; i++) {\r\n const surfaceConstraint = this._createSurfaceConstraint(dt, this._manifold[i], timeTravelled);\r\n constraints.push(surfaceConstraint);\r\n this._addMaxSlopePlane(this.maxSlopeCosine, this.up, i, constraints, this._manifold[i].allowedPenetration);\r\n this._resolveConstraintPenetration(surfaceConstraint, this.penetrationRecoverySpeed);\r\n }\r\n return constraints;\r\n }\r\n\r\n protected _simplexSolverSortInfo(info: SimplexSolverInfo) {\r\n // simple bubble sort by (priority,velocity)\r\n for (let i = 0; i < info.numSupportPlanes - 1; i++) {\r\n for (let j = i + 1; j < info.numSupportPlanes; j++) {\r\n const p0 = info.supportPlanes[i];\r\n const p1 = info.supportPlanes[j];\r\n if (p0.constraint.priority < p1.constraint.priority) {\r\n continue;\r\n }\r\n if (p0.constraint.priority == p1.constraint.priority) {\r\n const vel0 = p0.constraint.velocity.lengthSquared();\r\n const vel1 = p1.constraint.velocity.lengthSquared();\r\n if (vel0 < vel1) {\r\n continue;\r\n }\r\n }\r\n info.supportPlanes[i] = p1;\r\n info.supportPlanes[j] = p0;\r\n }\r\n }\r\n }\r\n\r\n protected _simplexSolverSolve1d(info: SimplexSolverInfo, sci: ISurfaceConstraintInfo, velocityIn: Vector3, velocityOut: Vector3) {\r\n const eps = 1e-5;\r\n const groundVelocity = sci.velocity;\r\n const relativeVelocity = this._tmpVecs[22];\r\n velocityIn.subtractToRef(groundVelocity, relativeVelocity);\r\n\r\n const planeVel = relativeVelocity.dot(sci.planeNormal);\r\n\r\n const origVelocity2 = relativeVelocity.lengthSquared();\r\n relativeVelocity.subtractInPlace(sci.planeNormal.scale(planeVel));\r\n {\r\n const vp2 = planeVel * planeVel;\r\n // static friction is active if\r\n // velProjPlane * friction > |(velParallel)|\r\n // vplane * f > vpar\r\n // vp * f > vpar\r\n // vp2 * f2 > vpar2\r\n const extraStaticFriction = relativeVelocity.dot(this.up) > 0 ? sci.extraUpStaticFriction : sci.extraDownStaticFriction;\r\n if (extraStaticFriction > 0) {\r\n const horizontal = this.up.cross(sci.planeNormal);\r\n const hor2 = horizontal.lengthSquared();\r\n let horVel = 0.0;\r\n if (hor2 > eps) {\r\n horizontal.scaleInPlace(1 / Math.sqrt(hor2));\r\n\r\n horVel = relativeVelocity.dot(horizontal);\r\n\r\n // horizontal component\r\n {\r\n const horVel2 = horVel * horVel;\r\n const f2 = sci.staticFriction * sci.staticFriction;\r\n if (vp2 * f2 >= horVel2) {\r\n relativeVelocity.subtractInPlace(horizontal.scale(horVel));\r\n horVel = 0;\r\n }\r\n }\r\n }\r\n\r\n // vert component\r\n {\r\n const vertVel2 = origVelocity2 - horVel * horVel - vp2;\r\n const f2 = (sci.staticFriction + extraStaticFriction) * (sci.staticFriction + extraStaticFriction);\r\n if (vp2 * f2 >= vertVel2) {\r\n if (horVel == 0.0) {\r\n velocityOut.copyFrom(groundVelocity);\r\n return;\r\n }\r\n }\r\n }\r\n } else {\r\n // static friction is active if\r\n // velProjPlane * friction > |(vel-velProjPlane)|\r\n // vp * f > rvProj\r\n //\r\n // -> vp * f >= rvProj\r\n // -> vp * f >= sqrt( vel^2 - vp^2 )\r\n // -> vp^2 ( f^2 + 1 ) >= vel^2\r\n const f2 = sci.staticFriction * sci.staticFriction;\r\n if (vp2 * (1 + f2) >= origVelocity2) {\r\n velocityOut.copyFrom(groundVelocity);\r\n return;\r\n }\r\n }\r\n }\r\n\r\n if (sci.dynamicFriction < 1) {\r\n // apply dynamic friction 0 = conserve input velocity 1 = clip against normal\r\n const velOut2 = relativeVelocity.lengthSquared();\r\n if (velOut2 >= eps) {\r\n if (velOut2 > 1e-4 * origVelocity2) {\r\n let f = Math.sqrt(origVelocity2 / velOut2);\r\n f = sci.dynamicFriction + (1 - sci.dynamicFriction) * f;\r\n relativeVelocity.scaleInPlace(f);\r\n const p = sci.planeNormal.dot(relativeVelocity);\r\n relativeVelocity.subtractInPlace(sci.planeNormal.scale(p));\r\n }\r\n }\r\n }\r\n velocityOut.copyFrom(relativeVelocity);\r\n velocityOut.addInPlace(groundVelocity);\r\n }\r\n\r\n protected _simplexSolverSolveTest1d(sci: ISurfaceConstraintInfo, velocityIn: Vector3): boolean {\r\n const eps = 1e-3;\r\n const relativeVelocity = this._tmpVecs[23];\r\n velocityIn.subtractToRef(sci.velocity, relativeVelocity);\r\n return relativeVelocity.dot(sci.planeNormal) < -eps;\r\n }\r\n\r\n protected _simplexSolverSolve2d(\r\n info: SimplexSolverInfo,\r\n maxSurfaceVelocity: Vector3,\r\n sci0: ISurfaceConstraintInfo,\r\n sci1: ISurfaceConstraintInfo,\r\n velocityIn: Vector3,\r\n velocityOut: Vector3\r\n ) {\r\n const eps = 1e-5;\r\n const axis = sci0.planeNormal.cross(sci1.planeNormal);\r\n const axisLen2 = axis.lengthSquared();\r\n\r\n let solveSequentially: boolean = false;\r\n let axisVel: Vector3 | null;\r\n\r\n // eslint-disable-next-line no-constant-condition\r\n while (true) {\r\n // Check for parallel planes\r\n if (axisLen2 <= eps || solveSequentially) {\r\n info.getOutput(sci0).status = SurfaceConstraintInteractionStatus.FAILURE_2D;\r\n info.getOutput(sci1).status = SurfaceConstraintInteractionStatus.FAILURE_2D;\r\n\r\n if (sci0.priority > sci1.priority) {\r\n this._simplexSolverSolve1d(info, sci1, velocityIn, velocityOut);\r\n this._simplexSolverSolve1d(info, sci0, velocityIn, velocityOut);\r\n } else {\r\n this._simplexSolverSolve1d(info, sci0, velocityIn, velocityOut);\r\n this._simplexSolverSolve1d(info, sci1, velocityIn, velocityOut);\r\n }\r\n return;\r\n }\r\n\r\n const invAxisLen = 1.0 / Math.sqrt(axisLen2);\r\n axis.scaleInPlace(invAxisLen);\r\n\r\n // Calculate the velocity of the free axis\r\n {\r\n const r0 = sci0.planeNormal.cross(sci1.planeNormal);\r\n const r1 = sci1.planeNormal.cross(axis);\r\n const r2 = axis.cross(sci0.planeNormal);\r\n\r\n const sVel = sci0.velocity.add(sci1.velocity);\r\n\r\n const t = this._tmpVecs[2];\r\n t.set(0.5 * axis.dot(sVel), sci0.planeNormal.dot(sci0.velocity), sci1.planeNormal.dot(sci1.velocity));\r\n const m = Matrix.FromValues(r0.x, r1.x, r2.x, 0, r0.y, r1.y, r2.y, 0, r0.z, r1.z, r2.z, 0, 0, 0, 0, 1);\r\n axisVel = Vector3.TransformNormal(t, m);\r\n axisVel.scaleInPlace(invAxisLen);\r\n\r\n if (Math.abs(axisVel.x) > maxSurfaceVelocity.x || Math.abs(axisVel.y) > maxSurfaceVelocity.y || Math.abs(axisVel.z) > maxSurfaceVelocity.z) {\r\n solveSequentially = true;\r\n } else {\r\n break;\r\n }\r\n }\r\n }\r\n\r\n const groundVelocity = axisVel;\r\n const relativeVelocity = this._tmpVecs[24];\r\n velocityIn.subtractToRef(groundVelocity, relativeVelocity);\r\n\r\n const vel2 = relativeVelocity.lengthSquared();\r\n const axisVert = this.up.dot(axis);\r\n let axisProjVelocity = relativeVelocity.dot(axis);\r\n\r\n let staticFriction = sci0.staticFriction + sci1.staticFriction;\r\n if (axisVert * axisProjVelocity > 0) {\r\n staticFriction += (sci0.extraUpStaticFriction + sci1.extraUpStaticFriction) * axisVert;\r\n } else {\r\n staticFriction += (sci0.extraDownStaticFriction + sci1.extraDownStaticFriction) * axisVert;\r\n }\r\n staticFriction *= 0.5;\r\n\r\n const dynamicFriction = (sci0.dynamicFriction + sci1.dynamicFriction) * 0.5;\r\n // static friction is active if\r\n // |vel-axisProjVelocity|(rv) * friction(f) > axisProjVelocity(av)\r\n // -> sqrt( vel2 - av2 ) * f > av\r\n // -> (vel2 - av2) * f2 > av2\r\n const f2 = staticFriction * staticFriction;\r\n const av2 = axisProjVelocity * axisProjVelocity;\r\n if ((vel2 - av2) * f2 >= av2) {\r\n // static friction kicks in\r\n velocityOut.copyFrom(groundVelocity);\r\n return;\r\n }\r\n\r\n if (dynamicFriction < 1) {\r\n // apply dynamic friction\r\n if (axisProjVelocity * axisProjVelocity > 1e-4 * vel2) {\r\n const tmp = 1.0 / axisProjVelocity;\r\n const f = Math.abs(tmp) * Math.sqrt(vel2) * (1.0 - dynamicFriction) + dynamicFriction;\r\n axisProjVelocity *= f;\r\n }\r\n }\r\n velocityOut.copyFrom(groundVelocity);\r\n velocityOut.addInPlace(axis.scale(axisProjVelocity));\r\n }\r\n\r\n protected _simplexSolverSolve3d(\r\n info: SimplexSolverInfo,\r\n maxSurfaceVelocity: Vector3,\r\n sci0: ISurfaceConstraintInfo,\r\n sci1: ISurfaceConstraintInfo,\r\n sci2: ISurfaceConstraintInfo,\r\n allowResort: boolean,\r\n velocityIn: Vector3,\r\n velocityOut: Vector3\r\n ) {\r\n const eps = 1e-5;\r\n // Calculate the velocity of the point axis\r\n let pointVel: Vector3 | null;\r\n {\r\n const r0 = sci1.planeNormal.cross(sci2.planeNormal);\r\n const r1 = sci2.planeNormal.cross(sci0.planeNormal);\r\n const r2 = sci0.planeNormal.cross(sci1.planeNormal);\r\n\r\n const det = r0.dot(sci0.planeNormal);\r\n let solveSequentially: boolean = false;\r\n // eslint-disable-next-line no-constant-condition\r\n while (true) {\r\n if (Math.abs(det) < eps || solveSequentially) {\r\n if (allowResort) {\r\n this._simplexSolverSortInfo(info);\r\n sci0 = info.supportPlanes[0].constraint;\r\n sci1 = info.supportPlanes[1].constraint;\r\n sci2 = info.supportPlanes[2].constraint;\r\n }\r\n info.getOutput(sci0).status = SurfaceConstraintInteractionStatus.FAILURE_3D;\r\n info.getOutput(sci1).status = SurfaceConstraintInteractionStatus.FAILURE_3D;\r\n info.getOutput(sci2).status = SurfaceConstraintInteractionStatus.FAILURE_3D;\r\n\r\n const oldNum = info.numSupportPlanes;\r\n this._simplexSolverSolve2d(info, maxSurfaceVelocity, sci0, sci1, velocityIn, velocityOut);\r\n if (oldNum == info.numSupportPlanes) {\r\n this._simplexSolverSolve2d(info, maxSurfaceVelocity, sci0, sci2, velocityIn, velocityOut);\r\n }\r\n if (oldNum == info.numSupportPlanes) {\r\n this._simplexSolverSolve2d(info, maxSurfaceVelocity, sci1, sci2, velocityIn, velocityOut);\r\n }\r\n\r\n return;\r\n }\r\n\r\n const t = this._tmpVecs[2];\r\n t.set(sci0.planeNormal.dot(sci0.velocity), sci1.planeNormal.dot(sci1.velocity), sci2.planeNormal.dot(sci2.velocity));\r\n const m = Matrix.FromValues(r0.x, r0.y, r0.z, 0, r1.x, r1.y, r1.z, 0, r2.x, r2.y, r2.z, 0, 0, 0, 0, 1);\r\n pointVel = Vector3.TransformNormal(t, m);\r\n pointVel.scaleInPlace(1 / det);\r\n if (Math.abs(pointVel.x) > maxSurfaceVelocity.x || Math.abs(pointVel.y) > maxSurfaceVelocity.y || Math.abs(pointVel.z) > maxSurfaceVelocity.z) {\r\n solveSequentially = true;\r\n } else {\r\n break;\r\n }\r\n }\r\n }\r\n velocityOut.copyFrom(pointVel);\r\n }\r\n\r\n protected _simplexSolverExamineActivePlanes(info: SimplexSolverInfo, maxSurfaceVelocity: Vector3, velocityIn: Vector3, velocityOut: Vector3) {\r\n // eslint-disable-next-line no-constant-condition\r\n while (true) {\r\n switch (info.numSupportPlanes) {\r\n case 1: {\r\n const sci = info.supportPlanes[0].constraint;\r\n this._simplexSolverSolve1d(info, sci, velocityIn, velocityOut);\r\n return;\r\n }\r\n case 2: {\r\n const velocity = Vector3.Zero();\r\n this._simplexSolverSolve1d(info, info.supportPlanes[1].constraint, velocityIn, velocity);\r\n const plane0Used = this._simplexSolverSolveTest1d(info.supportPlanes[0].constraint, velocity);\r\n if (!plane0Used) {\r\n // Only need plane 1, so remove plane 0\r\n info.supportPlanes[0].copyFrom(info.supportPlanes[1]);\r\n info.numSupportPlanes = 1;\r\n velocityOut.copyFrom(velocity);\r\n } else {\r\n this._simplexSolverSolve2d(info, maxSurfaceVelocity, info.supportPlanes[0].constraint, info.supportPlanes[1].constraint, velocityIn, velocityOut);\r\n }\r\n return;\r\n }\r\n case 3: {\r\n // Try to drop both planes\r\n {\r\n const velocity = Vector3.Zero();\r\n this._simplexSolverSolve1d(info, info.supportPlanes[2].constraint, velocityIn, velocityOut);\r\n\r\n const plane0Used = this._simplexSolverSolveTest1d(info.supportPlanes[0].constraint, velocity);\r\n if (!plane0Used) {\r\n const plane1Used = this._simplexSolverSolveTest1d(info.supportPlanes[1].constraint, velocity);\r\n if (!plane1Used) {\r\n velocityOut.copyFrom(velocity);\r\n info.supportPlanes[0].copyFrom(info.supportPlanes[2]);\r\n info.numSupportPlanes = 1;\r\n continue;\r\n }\r\n }\r\n }\r\n\r\n // Try to drop plane 0 or 1\r\n {\r\n let droppedAPlane = false;\r\n for (let testPlane = 0; testPlane < 2; testPlane++) {\r\n const velocity = Vector3.Zero();\r\n this._simplexSolverSolve2d(\r\n info,\r\n maxSurfaceVelocity,\r\n info.supportPlanes[testPlane].constraint,\r\n info.supportPlanes[2].constraint,\r\n velocityIn,\r\n velocityOut\r\n );\r\n const planeUsed = this._simplexSolverSolveTest1d(info.supportPlanes[1 - testPlane].constraint, velocity);\r\n if (!planeUsed) {\r\n info.supportPlanes[0].copyFrom(info.supportPlanes[testPlane]);\r\n info.supportPlanes[1].copyFrom(info.supportPlanes[2]);\r\n info.numSupportPlanes--;\r\n droppedAPlane = true;\r\n break;\r\n }\r\n }\r\n\r\n if (droppedAPlane) {\r\n continue;\r\n }\r\n }\r\n\r\n // Otherwise, try and solve all three planes:\r\n this._simplexSolverSolve3d(\r\n info,\r\n maxSurfaceVelocity,\r\n info.supportPlanes[0].constraint,\r\n info.supportPlanes[1].constraint,\r\n info.supportPlanes[2].constraint,\r\n true,\r\n velocityIn,\r\n velocityOut\r\n );\r\n return;\r\n }\r\n case 4: {\r\n this._simplexSolverSortInfo(info);\r\n let droppedAPlane = false;\r\n\r\n for (let i = 0; i < 3; i++) {\r\n const velocity = Vector3.Zero();\r\n this._simplexSolverSolve3d(\r\n info,\r\n maxSurfaceVelocity,\r\n info.supportPlanes[(i + 1) % 3].constraint,\r\n info.supportPlanes[(i + 2) % 3].constraint,\r\n info.supportPlanes[3].constraint,\r\n false,\r\n velocityIn,\r\n velocity\r\n );\r\n const planeUsed = this._simplexSolverSolveTest1d(info.supportPlanes[i].constraint, velocity);\r\n if (!planeUsed) {\r\n info.supportPlanes[i].copyFrom(info.supportPlanes[2]);\r\n info.supportPlanes[2].copyFrom(info.supportPlanes[3]);\r\n info.numSupportPlanes = 3;\r\n droppedAPlane = true;\r\n break;\r\n }\r\n }\r\n\r\n if (droppedAPlane) {\r\n continue;\r\n }\r\n\r\n // Nothing can be dropped so we've failed to solve\r\n // Now we try all 3d combinations\r\n {\r\n const velocity = velocityIn.clone();\r\n const sci0 = info.supportPlanes[0].constraint;\r\n const sci1 = info.supportPlanes[1].constraint;\r\n const sci2 = info.supportPlanes[2].constraint;\r\n const sci3 = info.supportPlanes[3].constraint;\r\n const oldNum = info.numSupportPlanes;\r\n if (oldNum == info.numSupportPlanes) {\r\n this._simplexSolverSolve3d(info, maxSurfaceVelocity, sci0, sci1, sci2, false, velocity, velocity);\r\n // eslint-disable-next-line no-dupe-else-if\r\n } else if (oldNum == info.numSupportPlanes) {\r\n this._simplexSolverSolve3d(info, maxSurfaceVelocity, sci0, sci1, sci3, false, velocity, velocity);\r\n // eslint-disable-next-line no-dupe-else-if\r\n } else if (oldNum == info.numSupportPlanes) {\r\n this._simplexSolverSolve3d(info, maxSurfaceVelocity, sci0, sci2, sci3, false, velocity, velocity);\r\n // eslint-disable-next-line no-dupe-else-if\r\n } else if (oldNum == info.numSupportPlanes) {\r\n this._simplexSolverSolve3d(info, maxSurfaceVelocity, sci1, sci2, sci3, false, velocity, velocity);\r\n }\r\n\r\n velocityOut.copyFrom(velocity);\r\n }\r\n\r\n // Search a plane to drop\r\n {\r\n // Search the highest penalty value\r\n let maxStatus = SurfaceConstraintInteractionStatus.OK;\r\n for (let i = 0; i < 4; i++) {\r\n maxStatus = Math.max(maxStatus, info.supportPlanes[i].interaction.status);\r\n }\r\n\r\n // Remove the place with the lowest priority and the highest penalty\r\n let i = 0;\r\n for (; i < 4; i++) {\r\n if (maxStatus == info.supportPlanes[i].interaction.status) {\r\n info.supportPlanes[i].copyFrom(info.supportPlanes[3]);\r\n break;\r\n }\r\n info.numSupportPlanes--;\r\n }\r\n }\r\n\r\n // Clear penalty flags for the other planes\r\n for (let i = 0; i < 3; i++) {\r\n info.supportPlanes[i].interaction.status = SurfaceConstraintInteractionStatus.OK;\r\n }\r\n\r\n continue;\r\n }\r\n }\r\n }\r\n }\r\n\r\n protected _simplexSolverSolve(\r\n constraints: ISurfaceConstraintInfo[],\r\n velocity: Vector3,\r\n deltaTime: number,\r\n minDeltaTime: number,\r\n up: Vector3,\r\n maxSurfaceVelocity: Vector3\r\n ): SimplexSolverOutput {\r\n const eps = 1e-6;\r\n const output = new SimplexSolverOutput();\r\n output.position = Vector3.Zero();\r\n output.velocity = velocity.clone();\r\n output.planeInteractions = [];\r\n let remainingTime = deltaTime;\r\n\r\n for (let i = 0; i < constraints.length; i++) {\r\n output.planeInteractions.push({\r\n touched: false,\r\n stopped: false,\r\n surfaceTime: 0,\r\n penaltyDistance: 0,\r\n status: SurfaceConstraintInteractionStatus.OK,\r\n });\r\n }\r\n\r\n const info = new SimplexSolverInfo();\r\n info.inputConstraints = constraints;\r\n info.outputInteractions = output.planeInteractions;\r\n info.supportPlanes[0] = new SimplexSolverActivePlanes();\r\n info.supportPlanes[1] = new SimplexSolverActivePlanes();\r\n info.supportPlanes[2] = new SimplexSolverActivePlanes();\r\n info.supportPlanes[3] = new SimplexSolverActivePlanes();\r\n\r\n while (remainingTime > 0) {\r\n // search for a plane which collides our current direction\r\n let hitIndex = -1;\r\n let minCollisionTime = remainingTime;\r\n for (let i = 0; i < constraints.length; i++) {\r\n // Do not search existing active planes\r\n if (info.numSupportPlanes >= 1 && info.supportPlanes[0].index == i) {\r\n continue;\r\n }\r\n if (info.numSupportPlanes >= 2 && info.supportPlanes[1].index == i) {\r\n continue;\r\n }\r\n if (info.numSupportPlanes >= 3 && info.supportPlanes[2].index == i) {\r\n continue;\r\n }\r\n if (output.planeInteractions[i].status != SurfaceConstraintInteractionStatus.OK) {\r\n continue;\r\n }\r\n\r\n // Try to find the plane with the shortest time to move\r\n const sci = constraints[i];\r\n const relativeVel = this._tmpVecs[25];\r\n output.velocity.subtractToRef(sci.velocity, relativeVel);\r\n const relativeProjectedVel = -relativeVel.dot(sci.planeNormal);\r\n // if projected velocity is pointing away skip it\r\n if (relativeProjectedVel <= 0) {\r\n continue;\r\n }\r\n\r\n // Calculate the time of impact\r\n const relativePos = this._tmpVecs[26];\r\n sci.velocity.scaleToRef(info.currentTime, this._tmpVecs[27]);\r\n output.position.subtractToRef(this._tmpVecs[27], relativePos);\r\n let projectedPos = sci.planeNormal.dot(relativePos);\r\n\r\n // treat penetrations\r\n const penaltyDist = output.planeInteractions[i].penaltyDistance;\r\n if (penaltyDist < eps) {\r\n projectedPos = 0;\r\n }\r\n projectedPos += penaltyDist;\r\n\r\n // check for new hit\r\n if (projectedPos < minCollisionTime * relativeProjectedVel) {\r\n minCollisionTime = projectedPos / relativeProjectedVel;\r\n hitIndex = i;\r\n }\r\n }\r\n\r\n // integrate: Walk to our hitPosition we must walk more than 10 microseconds into the future to consider it valid.\r\n const minAcceptableCollisionTime = 1e-4;\r\n if (minCollisionTime > minAcceptableCollisionTime) {\r\n info.currentTime += minCollisionTime;\r\n remainingTime -= minCollisionTime;\r\n output.position.addInPlace(output.velocity.scale(minCollisionTime));\r\n for (let i = 0; i < info.numSupportPlanes; i++) {\r\n info.supportPlanes[i].interaction.surfaceTime += minCollisionTime;\r\n info.supportPlanes[i].interaction.touched = true;\r\n }\r\n\r\n output.deltaTime = info.currentTime;\r\n if (info.currentTime > minDeltaTime) {\r\n return output;\r\n }\r\n }\r\n\r\n // If we have no hit than we are done\r\n if (hitIndex < 0) {\r\n output.deltaTime = deltaTime;\r\n break;\r\n }\r\n\r\n // Add our hit to our current list of active planes\r\n const supportPlane = info.supportPlanes[info.numSupportPlanes++];\r\n supportPlane.constraint = constraints[hitIndex];\r\n supportPlane.interaction = output.planeInteractions[hitIndex];\r\n supportPlane.interaction.penaltyDistance = (supportPlane.interaction.penaltyDistance + eps) * 2.0;\r\n supportPlane.index = hitIndex;\r\n\r\n // Move our character along the current set of active planes\r\n this._simplexSolverExamineActivePlanes(info, maxSurfaceVelocity, velocity, output.velocity);\r\n }\r\n\r\n return output;\r\n }\r\n\r\n /**\r\n * Compute a CharacterSurfaceInfo from current state and a direction\r\n * @param deltaTime frame delta time in seconds. When using scene.deltaTime divide by 1000.0\r\n * @param direction direction to check, usually gravity direction\r\n * @returns a CharacterSurfaceInfo object\r\n */\r\n public checkSupport(deltaTime: number, direction: Vector3): CharacterSurfaceInfo {\r\n const surfaceInfo = {\r\n isSurfaceDynamic: false,\r\n supportedState: CharacterSupportedState.UNSUPPORTED,\r\n averageSurfaceNormal: Vector3.Zero(),\r\n averageSurfaceVelocity: Vector3.Zero(),\r\n averageAngularSurfaceVelocity: Vector3.Zero(),\r\n };\r\n this.checkSupportToRef(deltaTime, direction, surfaceInfo);\r\n return surfaceInfo;\r\n }\r\n\r\n /**\r\n * Compute a CharacterSurfaceInfo from current state and a direction\r\n * @param deltaTime frame delta time in seconds. When using scene.deltaTime divide by 1000.0\r\n * @param direction direction to check, usually gravity direction\r\n * @param surfaceInfo output for surface info\r\n */\r\n public checkSupportToRef(deltaTime: number, direction: Vector3, surfaceInfo: CharacterSurfaceInfo): void {\r\n const eps = 1e-4;\r\n\r\n this._validateManifold();\r\n const constraints = this._createConstraintsFromManifold(deltaTime, 0.0);\r\n const storedVelocities: Vector3[] = [];\r\n // Remove velocities and friction to make this a query of the static geometry\r\n for (let i = 0; i < constraints.length; i++) {\r\n storedVelocities.push(constraints[i].velocity.clone());\r\n constraints[i].velocity.setAll(0);\r\n }\r\n\r\n const maxSurfaceVelocity = this._tmpVecs[3];\r\n maxSurfaceVelocity.set(this.maxCharacterSpeedForSolver, this.maxCharacterSpeedForSolver, this.maxCharacterSpeedForSolver);\r\n const output = this._simplexSolverSolve(constraints, direction, deltaTime, deltaTime, this.up, maxSurfaceVelocity);\r\n\r\n surfaceInfo.averageSurfaceVelocity.setAll(0);\r\n surfaceInfo.averageAngularSurfaceVelocity.setAll(0);\r\n surfaceInfo.averageSurfaceNormal.setAll(0);\r\n surfaceInfo.isSurfaceDynamic = false;\r\n\r\n // If the constraints did not affect the character movement then it is unsupported and we can finish\r\n if (output.velocity.equalsWithEpsilon(direction, eps)) {\r\n surfaceInfo.supportedState = CharacterSupportedState.UNSUPPORTED;\r\n return;\r\n }\r\n\r\n // Check how was the input velocity modified to determine if the character is supported or sliding\r\n if (output.velocity.lengthSquared() < eps) {\r\n surfaceInfo.supportedState = CharacterSupportedState.SUPPORTED;\r\n } else {\r\n output.velocity.normalize();\r\n const angleSin = output.velocity.dot(direction);\r\n const cosSqr = 1 - angleSin * angleSin;\r\n if (cosSqr < this.maxSlopeCosine * this.maxSlopeCosine) {\r\n surfaceInfo.supportedState = CharacterSupportedState.SLIDING;\r\n } else {\r\n surfaceInfo.supportedState = CharacterSupportedState.SUPPORTED;\r\n }\r\n }\r\n\r\n // Add all supporting constraints to the ground information\r\n let numTouching = 0;\r\n for (let i = -0; i < constraints.length; i++) {\r\n if (output.planeInteractions[i].touched && constraints[i].planeNormal.dot(direction) < -0.08) {\r\n surfaceInfo.averageSurfaceNormal.addInPlace(constraints[i].planeNormal);\r\n surfaceInfo.averageSurfaceVelocity.addInPlace(storedVelocities[i]);\r\n surfaceInfo.averageAngularSurfaceVelocity.addInPlace(constraints[i].angularVelocity);\r\n numTouching++;\r\n }\r\n }\r\n\r\n if (numTouching > 0) {\r\n surfaceInfo.averageSurfaceNormal.normalize();\r\n surfaceInfo.averageSurfaceVelocity.scaleInPlace(1 / numTouching);\r\n surfaceInfo.averageAngularSurfaceVelocity.scaleInPlace(1 / numTouching);\r\n }\r\n\r\n // isSurfaceDynamic update\r\n if (surfaceInfo.supportedState == CharacterSupportedState.SUPPORTED) {\r\n for (let i = 0; i < this._manifold.length; i++) {\r\n const manifold = this._manifold[i];\r\n const bodyB = manifold.bodyB;\r\n\r\n if (this._manifold[i].normal.dot(direction) < -0.08 && bodyB.body.getMotionType(0) == PhysicsMotionType.DYNAMIC) {\r\n surfaceInfo.isSurfaceDynamic = true;\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n\r\n protected _castWithCollectors(startPos: Vector3, endPos: Vector3, castCollector: any /*HP_CollectorId*/, startCollector?: any /*HP_CollectorId*/) {\r\n const hk = this._scene.getPhysicsEngine()!.getPhysicsPlugin() as HavokPlugin;\r\n const hknp = hk._hknp;\r\n\r\n const startNative = [startPos.x, startPos.y, startPos.z];\r\n const orientation = [this._orientation.x, this._orientation.y, this._orientation.z, this._orientation.w];\r\n if (startCollector != null) {\r\n const query /*: ShapeProximityInput*/ = [\r\n this._shape._pluginData,\r\n startNative,\r\n orientation,\r\n this.keepDistance + this.keepContactTolerance, // max distance\r\n false, // should hit triggers\r\n [this._body._pluginData.hpBodyId[0]],\r\n ];\r\n hknp.HP_World_ShapeProximityWithCollector(hk.world, startCollector, query);\r\n }\r\n\r\n {\r\n const query /*: ShapeCastInput*/ = [\r\n this._shape._pluginData,\r\n orientation,\r\n startNative,\r\n [endPos.x, endPos.y, endPos.z],\r\n false, // should hit triggers\r\n [this._body._pluginData.hpBodyId[0]],\r\n ];\r\n hknp.HP_World_ShapeCastWithCollector(hk.world, castCollector, query);\r\n }\r\n }\r\n\r\n protected _resolveContacts(deltaTime: number, gravity: Vector3) {\r\n const eps = 1e-12;\r\n //<todo object interactions out\r\n for (let i = 0; i < this._manifold.length; i++) {\r\n const contact = this._manifold[i];\r\n const bodyB = this._manifold[i].bodyB;\r\n\r\n //<todo test if bodyB is another character with a proxy body\r\n\r\n // Skip fixed or keyframed bodies as we won't apply impulses to them\r\n if (bodyB.body.getMotionType(bodyB.index) != PhysicsMotionType.DYNAMIC) {\r\n continue;\r\n }\r\n\r\n // Calculate and apply impulse on contacted body\r\n {\r\n //<todo input/output for callbacks\r\n let inputObjectMassInv: number;\r\n let inputObjectImpulse: number;\r\n let outputObjectImpulse = Vector3.Zero();\r\n const outputImpulsePosition = contact.position;\r\n\r\n // Calculate relative normal velocity of the contact point in the contacted body\r\n const pointRelVel = this._tmpVecs[19];\r\n this._getPointVelocityToRef(bodyB, contact.position, pointRelVel);\r\n pointRelVel.subtractInPlace(this._velocity);\r\n const inputProjectedVelocity = pointRelVel.dot(contact.normal);\r\n const dampFactor = 0.9;\r\n\r\n // Change velocity\r\n let deltaVelocity = -inputProjectedVelocity * dampFactor;\r\n\r\n // Apply an extra impulse if the collision is actually penetrating\r\n if (contact.distance < 0) {\r\n const recoveryTau = 0.4;\r\n deltaVelocity += (contact.distance * recoveryTau) / deltaTime;\r\n }\r\n\r\n // Apply impulse if required to keep bodies apart\r\n if (deltaVelocity < 0) {\r\n // Calculate the impulse magnitude\r\n const invInertia = this._getInverseInertiaWorld(bodyB);\r\n const comWorld = this._tmpVecs[15];\r\n this._getComWorldToRef(bodyB, comWorld);\r\n const r = this._tmpVecs[16];\r\n contact.position.subtractToRef(comWorld, r);\r\n const jacAng = this._tmpVecs[17];\r\n Vector3.CrossToRef(r, contact.normal, jacAng);\r\n const rc = this._tmpVecs[18];\r\n Vector3.TransformNormalToRef(jacAng, invInertia, rc);\r\n inputObjectMassInv = rc.dot(jacAng) + this._getInvMass(bodyB);\r\n inputObjectImpulse = deltaVelocity / inputObjectMassInv;\r\n\r\n // Clamp impulse magnitude if required and apply it to the normal direction\r\n const maxPushImpulse = -this.characterStrength * deltaTime;\r\n if (inputObjectImpulse < maxPushImpulse) {\r\n inputObjectImpulse = maxPushImpulse;\r\n }\r\n outputObjectImpulse = contact.normal.scale(inputObjectImpulse);\r\n }\r\n\r\n // Add gravity\r\n {\r\n // Calculate effect of gravity on the velocity of the character in the contact normal direction\r\n let relVelN = contact.normal.dot(gravity.scale(deltaTime));\r\n // If it is a separating contact subtract the separation velocity\r\n if (inputProjectedVelocity < 0) {\r\n relVelN -= inputProjectedVelocity;\r\n }\r\n // If the resulting velocity is negative an impulse is applied to stop the character from falling into\r\n // the contacted body\r\n if (relVelN < -eps) {\r\n outputObjectImpulse.addInPlace(contact.normal.scale(this.characterMass * relVelN));\r\n }\r\n }\r\n\r\n //<todo Fire callback to allow user to change impulse + use the info / play sounds\r\n\r\n const triggerCollisionInfo: ICharacterControllerCollisionEvent = {\r\n collider: bodyB.body,\r\n colliderIndex: bodyB.index,\r\n impulse: outputObjectImpulse,\r\n impulsePosition: outputImpulsePosition,\r\n };\r\n this.onTriggerCollisionObservable.notifyObservers(triggerCollisionInfo);\r\n\r\n bodyB.body.applyImpulse(outputObjectImpulse, outputImpulsePosition, bodyB.index);\r\n }\r\n }\r\n }\r\n\r\n protected _getInverseInertiaWorld(body: { body: PhysicsBody; index: number }): DeepImmutableObject<Matrix> {\r\n const mp = body.body.getMassProperties(body.index);\r\n if (!mp.inertia || !mp.inertiaOrientation) {\r\n return Matrix.IdentityReadOnly;\r\n }\r\n const invOrientation = Matrix.FromQuaternionToRef(mp.inertiaOrientation, TmpVectors.Matrix[0]).invert();\r\n const it = TmpVectors.Matrix[1];\r\n\r\n const ir = invOrientation.getRowToRef(0, TmpVectors.Vector4[0]);\r\n it.setRowFromFloats(0, mp.inertia.x * ir.x, mp.inertia.x * ir.y, mp.inertia.x * ir.z, 0);\r\n invOrientation.getRowToRef(1, ir);\r\n it.setRowFromFloats(0, mp.inertia.y * ir.x, mp.inertia.y * ir.y, mp.inertia.y * ir.z, 0);\r\n invOrientation.getRowToRef(2, ir);\r\n it.setRowFromFloats(0, mp.inertia.z * ir.x, mp.inertia.z * ir.y, mp.inertia.z * ir.z, 0);\r\n invOrientation.multiplyToRef(it, this._tmpMatrix);\r\n return this._tmpMatrix;\r\n }\r\n\r\n protected _getComWorldToRef(body: { body: PhysicsBody; index: number }, result: Vector3) {\r\n const mp = body.body.getMassProperties(body.index);\r\n Vector3.TransformCoordinatesToRef(mp.centerOfMass!, body.body.transformNode.getWorldMatrix(), result);\r\n }\r\n\r\n protected _getInvMass(body: { body: PhysicsBody; index: number }): number {\r\n return 1 / body.body.getMassProperties(body.index).mass!;\r\n }\r\n\r\n protected _integrateManifolds(deltaTime: number, gravity: Vector3): void {\r\n const hk = this._scene.getPhysicsEngine()!.getPhysicsPlugin() as HavokPlugin;\r\n const epsSqrd = 1e-8;\r\n\r\n let newVelocity = Vector3.Zero();\r\n let remainingTime = deltaTime;\r\n\r\n // Make sure that contact with bodies that have been removed since the call to checkSupport() are removed from the\r\n // manifold\r\n this._validateManifold();\r\n\r\n for (let iter = 0; iter < this.maxCastIterations && remainingTime > 1e-5; iter++) {\r\n this._castWithCollectors(this._position, this._position.add(this._lastDisplacement), this._castCollector, this._startCollector);\r\n const updateResult = this._updateManifold(this._startCollector, this._castCollector, this._lastDisplacement);\r\n\r\n // Create surface constraints from the manifold contacts.\r\n const constraints = this._createConstraintsFromManifold(deltaTime, deltaTime - remainingTime);\r\n const maxSurfaceVelocity = this._tmpVecs[3];\r\n maxSurfaceVelocity.set(this.maxCharacterSpeedForSolver, this.maxCharacterSpeedForSolver, this.maxCharacterSpeedForSolver);\r\n const minDeltaTime = this._velocity.lengthSquared() == 0 ? 0.0 : (0.5 * this.keepDistance) / this._velocity.length();\r\n const solveResults = this._simplexSolverSolve(constraints, this._velocity, remainingTime, minDeltaTime, this.up, maxSurfaceVelocity);\r\n const newDisplacement = solveResults.position;\r\n const solverDeltaTime = solveResults.deltaTime;\r\n newVelocity = solveResults.velocity;\r\n\r\n this._resolveContacts(deltaTime, gravity);\r\n\r\n let newContactIndex = -1;\r\n // todo if (updateResult == hit multiple bodies) ... cast again\r\n\r\n // If castCollector had hits on different bodies (so we're not sure if some non-closest body could be in our way) OR\r\n // the simplex has given an output direction different from the cast guess\r\n // we re-cast to check we can move there. There is no need to get the start points again.\r\n if (updateResult != 0 || (newDisplacement.lengthSquared() > epsSqrd && !this._lastDisplacement.equalsWithEpsilon(newDisplacement, this._displacementEps))) {\r\n this._castWithCollectors(this._position, this._position.add(newDisplacement), this._castCollector, this._startCollector);\r\n const hknp = hk._hknp;\r\n const numCastHits = hknp.HP_QueryCollector_GetNumHits(this._castCollector)[1];\r\n // Find the first contact that isn't already in the manifold\r\n if (numCastHits > 0) {\r\n //<todo sortHits()\r\n for (let i = 0; i < numCastHits; i++) {\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n const [fraction, _hitLocal, hitWorld] = hknp.HP_QueryCollector_GetShapeCastResult(this._castCollector, i)[1];\r\n const newContact = ContactFromCast(hk, hitWorld, newDisplacement, fraction, this.keepDistance);\r\n if (this._findContact(newContact, this._manifold, 0.1) == -1) {\r\n //<todo fireContactAdded\r\n newContactIndex = this._manifold.length;\r\n this._manifold.push(newContact);\r\n //<todo updateTriggersSeen()\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n\r\n if (newContactIndex >= 0) {\r\n const newContact = this._manifold[newContactIndex];\r\n const displacementLengthInv = 1.0 / newDisplacement.length();\r\n const angleBetweenMovementAndSurface = newDisplacement.dot(newContact.normal) * displacementLengthInv;\r\n const keepDistanceAlongMovement = this.keepDistance / -angleBetweenMovementAndSurface;\r\n const distance = newContact.fraction;\r\n let fraction = distance - keepDistanceAlongMovement * displacementLengthInv;\r\n fraction = Math.min(Math.max(fraction, 0.0), 1.0);\r\n\r\n newDisplacement.scaleToRef(fraction, this._tmpVecs[31]);\r\n this._position.addInPlace(this._tmpVecs[31]);\r\n remainingTime -= solverDeltaTime * fraction;\r\n } else {\r\n this._position.addInPlace(newDisplacement);\r\n remainingTime -= solverDeltaTime;\r\n }\r\n this._lastDisplacement.copyFrom(newDisplacement);\r\n }\r\n\r\n this._velocity.copyFrom(newVelocity);\r\n this._transformNode.position.copyFrom(this._position);\r\n }\r\n\r\n /**\r\n * Move the character with collisions\r\n * @param displacement defines the requested displacement vector\r\n */\r\n public moveWithCollisions(displacement: Vector3): void {\r\n if (this._scene.deltaTime == undefined) {\r\n return;\r\n }\r\n const deltaTime = this._scene.deltaTime / 1000.0;\r\n const invDeltaTime = 1 / deltaTime;\r\n\r\n displacement.scaleToRef(1 / deltaTime, this._velocity);\r\n this._lastDisplacement.copyFrom(displacement);\r\n\r\n this._lastVelocity.copyFrom(this._velocity);\r\n this._lastInvDeltaTime = invDeltaTime;\r\n\r\n this._integrateManifolds(deltaTime, Vector3.ZeroReadOnly);\r\n }\r\n\r\n /**\r\n * Update internal state. Must be called once per frame\r\n * @param deltaTime frame delta time in seconds. When using scene.deltaTime divide by 1000.0\r\n * @param surfaceInfo surface information returned by checkSupport\r\n * @param gravity gravity applied to the character. Can be different that world gravity\r\n */\r\n public integrate(deltaTime: number, surfaceInfo: CharacterSurfaceInfo, gravity: Vector3) {\r\n const invDeltaTime = 1 / deltaTime;\r\n const remainingTime = deltaTime;\r\n\r\n // Choose the first cast direction. If velocity hasn't changed from the previous integrate, guess that the\r\n // displacement will be the same as last integrate, scaled by relative step length. Otherwise, guess based\r\n // on current velocity.\r\n {\r\n const tolerance = this._displacementEps * invDeltaTime;\r\n if (this._velocity.equalsWithEpsilon(this._lastVelocity, tolerance)) {\r\n this._lastDisplacement.scaleInPlace(remainingTime * this._lastInvDeltaTime);\r\n } else {\r\n const displacementVelocity = this._velocity;\r\n if (surfaceInfo.supportedState == CharacterSupportedState.SUPPORTED) {\r\n const relativeVelocity = this._tmpVecs[28];\r\n this._velocity.subtractToRef(surfaceInfo.averageSurfaceVelocity, relativeVelocity);\r\n const normalDotVelocity = surfaceInfo.averageSurfaceNormal.dot(relativeVelocity);\r\n if (normalDotVelocity < 0) {\r\n relativeVelocity.subtractInPlace(surfaceInfo.averageSurfaceNormal.scale(normalDotVelocity));\r\n displacementVelocity.copyFrom(relativeVelocity);\r\n displacementVelocity.addInPlace(surfaceInfo.averageSurfaceVelocity);\r\n }\r\n }\r\n this._lastDisplacement.copyFrom(displacementVelocity);\r\n this._lastDisplacement.scaleInPlace(remainingTime);\r\n }\r\n this._lastVelocity.copyFrom(this._velocity);\r\n this._lastInvDeltaTime = invDeltaTime;\r\n }\r\n\r\n this._integrateManifolds(deltaTime, gravity);\r\n }\r\n\r\n /**\r\n * Helper function to calculate velocity based on surface informations and current velocity state and target\r\n * @param deltaTime frame delta time in seconds. When using scene.deltaTime divide by 1000.0\r\n * @param forwardWorld character forward in world coordinates\r\n * @param surfaceNormal surface normal direction\r\n * @param currentVelocity current velocity\r\n * @param surfaceVelocity velocity induced by the surface\r\n * @param desiredVelocity desired character velocity\r\n * @param upWorld up vector in world space\r\n * @param result resulting velocity vector\r\n * @returns boolean true if result has been computed\r\n */\r\n public calculateMovementToRef(\r\n deltaTime: number,\r\n forwardWorld: Vector3,\r\n surfaceNormal: Vector3,\r\n currentVelocity: Vector3,\r\n surfaceVelocity: Vector3,\r\n desiredVelocity: Vector3,\r\n upWorld: Vector3,\r\n result: Vector3\r\n ): boolean {\r\n const eps = 1e-5;\r\n let binorm = forwardWorld.cross(upWorld);\r\n if (binorm.lengthSquared() < eps) {\r\n return false;\r\n }\r\n binorm.normalize();\r\n const tangent = binorm.cross(surfaceNormal);\r\n tangent.normalize();\r\n binorm = tangent.cross(surfaceNormal);\r\n binorm.normalize();\r\n\r\n const surfaceFrame = Matrix.FromValues(\r\n tangent.x,\r\n tangent.y,\r\n tangent.z,\r\n 0,\r\n binorm.x,\r\n binorm.y,\r\n binorm.z,\r\n 0,\r\n surfaceNormal.x,\r\n surfaceNormal.y,\r\n surfaceNormal.z,\r\n 0,\r\n 0,\r\n 0,\r\n 0,\r\n 1\r\n );\r\n const invSurfaceFrame = surfaceFrame.clone().invert();\r\n\r\n currentVelocity.subtractToRef(surfaceVelocity, this._tmpVecs[29]);\r\n const relative = this._tmpVecs[30];\r\n Vector3.TransformNormalToRef(this._tmpVecs[29], invSurfaceFrame, relative);\r\n\r\n const sideVec = upWorld.cross(forwardWorld);\r\n const fwd = desiredVelocity.dot(forwardWorld);\r\n const side = desiredVelocity.dot(sideVec);\r\n const len = desiredVelocity.length();\r\n\r\n const desiredVelocitySF = this._tmpVecs[4];\r\n desiredVelocitySF.set(-fwd, side, 0);\r\n desiredVelocitySF.normalize();\r\n desiredVelocitySF.scaleInPlace(len);\r\n const diff = this._tmpVecs[5];\r\n desiredVelocitySF.subtractToRef(relative, diff);\r\n\r\n // Clamp it by maxAcceleration and limit it by gain.\r\n {\r\n const lenSq = diff.lengthSquared();\r\n const maxVelocityDelta = this.maxAcceleration * deltaTime;\r\n let tmp: number;\r\n if (lenSq * this.acceleration * this.acceleration > maxVelocityDelta * maxVelocityDelta) {\r\n tmp = maxVelocityDelta / Math.sqrt(lenSq);\r\n } else {\r\n tmp = this.acceleration;\r\n }\r\n diff.scaleInPlace(tmp);\r\n }\r\n\r\n relative.addInPlace(diff);\r\n\r\n // Transform back to world space and apply\r\n Vector3.TransformNormalToRef(relative, surfaceFrame, result);\r\n\r\n // Add back in the surface velocity\r\n result.addInPlace(surfaceVelocity);\r\n return true;\r\n }\r\n\r\n /**\r\n * Helper function to calculate velocity based on surface informations and current velocity state and target\r\n * @param deltaTime frame delta time in seconds. When using scene.deltaTime divide by 1000.0\r\n * @param forwardWorld character forward in world coordinates\r\n * @param surfaceNormal surface normal direction\r\n * @param currentVelocity current velocity\r\n * @param surfaceVelocity velocity induced by the surface\r\n * @param desiredVelocity desired character velocity\r\n * @param upWorld up vector in world space\r\n * @returns a new velocity vector\r\n */\r\n public calculateMovement(\r\n deltaTime: number,\r\n forwardWorld: Vector3,\r\n surfaceNormal: Vector3,\r\n currentVelocity: Vector3,\r\n surfaceVelocity: Vector3,\r\n desiredVelocity: Vector3,\r\n upWorld: Vector3\r\n ): Vector3 {\r\n const result = new Vector3(0, 0, 0);\r\n this.calculateMovementToRef(deltaTime, forwardWorld, surfaceNormal, currentVelocity, surfaceVelocity, desiredVelocity, upWorld, result);\r\n return result;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"characterController.js","sourceRoot":"","sources":["../../../../../dev/core/src/Physics/v2/characterController.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAGlF,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAqB,MAAM,gBAAgB,CAAC;AAGxE,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AA2CnD;;GAEG;AACH,MAAM,CAAN,IAAkB,uBAIjB;AAJD,WAAkB,uBAAuB;IACrC,mFAAW,CAAA;IACX,2EAAO,CAAA;IACP,+EAAS,CAAA;AACb,CAAC,EAJiB,uBAAuB,KAAvB,uBAAuB,QAIxC;AAsED,IAAW,kCAIV;AAJD,WAAW,kCAAkC;IACzC,uFAAE,CAAA;IACF,uGAAU,CAAA;IACV,uGAAU,CAAA;AACd,CAAC,EAJU,kCAAkC,KAAlC,kCAAkC,QAI5C;AAcD,gBAAgB;AAChB,MAAM,mBAAmB;CASxB;AAED,gBAAgB;AAChB,MAAM,yBAAyB;IAQ3B,gBAAgB;IACT,QAAQ,CAAC,KAAgC;QAC5C,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;QACzB,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC,UAAU,CAAC;QACnC,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC,WAAW,CAAC;IACzC,CAAC;CACJ;AAED,gBAAgB;AAChB,MAAM,iBAAiB;IAAvB;QACI,gBAAgB;QACT,kBAAa,GAAqC,IAAI,KAAK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C,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QACpC,IAAI,CAAC,sBAAsB,CAAC,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,eAAe,EAAE,eAAe,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;QACxI,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ","sourcesContent":["import { Vector3, Quaternion, Matrix, TmpVectors } from \"../../Maths/math.vector\";\r\nimport { type Scene } from \"../../scene\";\r\nimport { type DeepImmutableObject } from \"../../types\";\r\nimport { PhysicsBody } from \"./physicsBody\";\r\nimport { PhysicsShapeCapsule, type PhysicsShape } from \"./physicsShape\";\r\nimport { PhysicsMotionType } from \"./IPhysicsEnginePlugin\";\r\nimport { type HavokPlugin } from \"./Plugins/havokPlugin\";\r\nimport { BuildArray } from \"../../Misc/arrayTools\";\r\nimport { TransformNode } from \"../../Meshes/transformNode\";\r\nimport { Observable } from \"../../Misc/observable\";\r\n\r\n/**\r\n * Shape properties for the character controller\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport interface CharacterShapeOptions {\r\n /**\r\n * optional shape used for collision detection\r\n */\r\n shape?: PhysicsShape;\r\n /**\r\n * capsule height for the capsule shape if no shape is provided\r\n */\r\n capsuleHeight?: number;\r\n /**\r\n * capsule radius for the capsule shape if no shape is provided\r\n */\r\n capsuleRadius?: number;\r\n}\r\n\r\n/**\r\n * Collision event data for the character controller\r\n */\r\nexport interface ICharacterControllerCollisionEvent {\r\n /**\r\n * The collider physics body\r\n */\r\n collider: PhysicsBody;\r\n /**\r\n * Index of the collider in instances\r\n */\r\n colliderIndex: number;\r\n /**\r\n * Separation force applied to the collider\r\n */\r\n impulse: Vector3;\r\n /**\r\n * Position where the impulse is applied\r\n */\r\n impulsePosition: Vector3;\r\n}\r\n\r\n/**\r\n * State of the character on the surface\r\n */\r\nexport const enum CharacterSupportedState {\r\n UNSUPPORTED,\r\n SLIDING,\r\n SUPPORTED,\r\n}\r\n\r\n/**\r\n * Surface information computed by checkSupport method\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport interface CharacterSurfaceInfo {\r\n /**\r\n * Indicates whether the surface is dynamic.\r\n * A dynamic surface is one that can change its properties over time,\r\n * such as moving platforms or surfaces that can be affected by external forces.\r\n * surfaceInfo.supportedState is always CharacterSupportedState.SUPPORTED when isSurfaceDynamic is true.\r\n */\r\n isSurfaceDynamic: boolean;\r\n /**\r\n * The supported state of the character on the surface.\r\n */\r\n supportedState: CharacterSupportedState;\r\n /**\r\n * The average normal vector of the surface.\r\n * This vector is perpendicular to the surface and points outwards.\r\n */\r\n averageSurfaceNormal: Vector3;\r\n /**\r\n * The average velocity of the surface.\r\n * This vector represents the speed and direction in which the surface is moving.\r\n */\r\n averageSurfaceVelocity: Vector3;\r\n /**\r\n * The average angular velocity of the surface.\r\n */\r\n averageAngularSurfaceVelocity: Vector3;\r\n}\r\n\r\ninterface IContact {\r\n /** @internal */\r\n position: Vector3;\r\n /** @internal */\r\n normal: Vector3;\r\n /** @internal */\r\n distance: number;\r\n /** @internal */\r\n fraction: number;\r\n /** @internal */\r\n bodyB: { body: PhysicsBody; index: number };\r\n /** @internal */\r\n allowedPenetration: number;\r\n}\r\n\r\ninterface ISurfaceConstraintInfo {\r\n /** @internal */\r\n planeNormal: Vector3;\r\n /** @internal */\r\n planeDistance: number;\r\n /** @internal */\r\n velocity: Vector3;\r\n /** @internal */\r\n angularVelocity: Vector3;\r\n /** @internal */\r\n staticFriction: number;\r\n /** @internal */\r\n extraUpStaticFriction: number;\r\n /** @internal */\r\n extraDownStaticFriction: number;\r\n /** @internal */\r\n dynamicFriction: number;\r\n /** @internal */\r\n priority: number;\r\n}\r\n\r\nconst enum SurfaceConstraintInteractionStatus {\r\n OK,\r\n FAILURE_3D,\r\n FAILURE_2D,\r\n}\r\ninterface ISurfaceConstraintInteraction {\r\n /** @internal */\r\n touched: boolean;\r\n /** @internal */\r\n stopped: boolean;\r\n /** @internal */\r\n surfaceTime: number;\r\n /** @internal */\r\n penaltyDistance: number;\r\n /** @internal */\r\n status: SurfaceConstraintInteractionStatus;\r\n}\r\n\r\n/** @internal */\r\nclass SimplexSolverOutput {\r\n /** @internal */\r\n public position: Vector3;\r\n /** @internal */\r\n public velocity: Vector3;\r\n /** @internal */\r\n public deltaTime: number;\r\n /** @internal */\r\n public planeInteractions: ISurfaceConstraintInteraction[];\r\n}\r\n\r\n/** @internal */\r\nclass SimplexSolverActivePlanes {\r\n /** @internal */\r\n public index: number;\r\n /** @internal */\r\n public constraint: ISurfaceConstraintInfo;\r\n /** @internal */\r\n public interaction: ISurfaceConstraintInteraction;\r\n\r\n /** @internal */\r\n public copyFrom(other: SimplexSolverActivePlanes) {\r\n this.index = other.index;\r\n this.constraint = other.constraint;\r\n this.interaction = other.interaction;\r\n }\r\n}\r\n\r\n/** @internal */\r\nclass SimplexSolverInfo {\r\n /** @internal */\r\n public supportPlanes: Array<SimplexSolverActivePlanes> = new Array<SimplexSolverActivePlanes>(4);\r\n /** @internal */\r\n public numSupportPlanes: number = 0;\r\n /** @internal */\r\n public currentTime: number = 0;\r\n /** @internal */\r\n public inputConstraints: ISurfaceConstraintInfo[];\r\n /** @internal */\r\n public outputInteractions: ISurfaceConstraintInteraction[];\r\n /** @internal */\r\n public getOutput(constraint: ISurfaceConstraintInfo): ISurfaceConstraintInteraction {\r\n return this.outputInteractions[this.inputConstraints.indexOf(constraint)]; //<todo.eoin This is O(1) in C++! Equivalent in TS?\r\n }\r\n}\r\n\r\n/** @internal */\r\nfunction ContactFromCast(hp: HavokPlugin, cp: any /*ContactPoint*/, castPath: Vector3, hitFraction: number, keepDistance: number): IContact {\r\n const bodyMap = (hp as any)._bodies;\r\n\r\n const normal = Vector3.FromArray(cp[4]);\r\n const dist = -hitFraction * castPath.dot(normal);\r\n return {\r\n position: Vector3.FromArray(cp[3]),\r\n normal: normal,\r\n distance: dist,\r\n fraction: hitFraction,\r\n bodyB: bodyMap.get(cp[0][0])!,\r\n allowedPenetration: Math.min(Math.max(keepDistance - dist, 0.0), keepDistance),\r\n };\r\n}\r\n\r\n/**\r\n * Character controller using physics\r\n */\r\nexport class PhysicsCharacterController {\r\n private _position: Vector3;\r\n private _orientation: Quaternion = Quaternion.Identity();\r\n private _velocity: Vector3;\r\n private _lastVelocity: Vector3;\r\n private _shape: PhysicsShape;\r\n private _body: PhysicsBody;\r\n private _transformNode: TransformNode;\r\n private _ownShape: boolean;\r\n private _manifold: IContact[] = [];\r\n private _stepUpSavedManifold: IContact[] = [];\r\n private _lastDisplacement: Vector3;\r\n private _contactAngleSensitivity = 10.0;\r\n private _lastInvDeltaTime: number;\r\n protected _scene: Scene;\r\n private _tmpMatrix = new Matrix();\r\n private _tmpVecs: Vector3[] = BuildArray(32, Vector3.Zero);\r\n\r\n /**\r\n * minimum distance to make contact\r\n * default 0.05\r\n */\r\n public keepDistance: number = 0.05;\r\n /**\r\n * maximum distance to keep contact\r\n * default 0.1\r\n */\r\n public keepContactTolerance: number = 0.1;\r\n /**\r\n * maximum number of raycast per integration starp\r\n * default 10\r\n */\r\n public maxCastIterations: number = 10;\r\n /**\r\n * speed when recovery from penetration\r\n * default 1.0\r\n */\r\n public penetrationRecoverySpeed = 1.0;\r\n /**\r\n * friction with static surfaces\r\n * default 0\r\n */\r\n public staticFriction = 0;\r\n /**\r\n * friction with dynamic surfaces\r\n * default 1\r\n */\r\n public dynamicFriction = 1;\r\n /**\r\n * cosine value of slope angle that can be climbed\r\n * computed as `Math.cos(Math.PI * (angleInDegree / 180.0));`\r\n * default 0.5 (value for a 60deg angle)\r\n */\r\n public maxSlopeCosine = 0.5;\r\n /**\r\n * Maximum height the character can automatically step up onto a walkable surface.\r\n * When greater than 0 the controller enforces this as a strict cap on step climbing,\r\n * independent of the collision shape's geometry:\r\n *\r\n * - Obstacles whose top is at most maxStepHeight above the character's foot are\r\n * climbed (either rolled over naturally by the capsule, or snapped up via the\r\n * step-up sweep when the simplex would otherwise be blocked).\r\n * - Obstacles taller than maxStepHeight are blocked, even ones the capsule's\r\n * rounded bottom would otherwise glide over.\r\n *\r\n * This is enforced by demoting any \"walkable\" contact that sits more than\r\n * maxStepHeight above the foot into an extra horizontal wall constraint, so the\r\n * step-height limit does not depend on the capsule radius. As a documented side\r\n * effect, slopes whose contact rises above maxStepHeight (roughly when\r\n * `capsuleRadius * (1 - cos(slopeAngle)) > maxStepHeight`) are also treated as\r\n * walls. Pick maxStepHeight large enough to clear the slope angles you want to\r\n * remain walkable, or rely on `maxSlopeCosine` alone (with maxStepHeight = 0)\r\n * when the rounded-capsule riding behavior is acceptable.\r\n *\r\n * Step-up only triggers against STATIC and ANIMATED bodies. Dynamic bodies fall\r\n * through to normal contact resolution and pushing behavior.\r\n *\r\n * Thin walls / fences with floor behind them are not considered steppable: the\r\n * landing must be measurably higher than the starting position along `up`.\r\n *\r\n * The foot is computed as `position - up * footOffset`. Override `footOffset` if\r\n * you supply a custom collision shape whose center is not at half-height.\r\n *\r\n * Assumes `up` is a unit vector.\r\n *\r\n * default 0 (disabled)\r\n */\r\n public maxStepHeight = 0;\r\n /**\r\n * Distance from the body's `position` to the character's foot along `up`.\r\n * Used by `maxStepHeight` to measure how high a contact sits above the foot.\r\n * Defaults to half the capsule height passed at construction. Override when\r\n * supplying a custom collision shape whose center is not at half-height.\r\n */\r\n public footOffset: number;\r\n /**\r\n * character maximum speed\r\n * default 10\r\n */\r\n public maxCharacterSpeedForSolver = 10.0;\r\n /**\r\n * up vector\r\n */\r\n public up = new Vector3(0, 1, 0);\r\n /**\r\n * Strength when pushing other bodies\r\n * default 1e38\r\n */\r\n public characterStrength = 1e38;\r\n\r\n /**\r\n * Acceleration factor. A value of 1 means reaching max velocity immediately\r\n */\r\n public acceleration = 0.05;\r\n\r\n /**\r\n * maximum acceleration in world space coordinate\r\n */\r\n public maxAcceleration = 50;\r\n\r\n /**\r\n * character mass\r\n * default 0\r\n */\r\n public characterMass = 0;\r\n\r\n /**\r\n * Observable for trigger entered and trigger exited events\r\n */\r\n public onTriggerCollisionObservable = new Observable<ICharacterControllerCollisionEvent>();\r\n\r\n private _startCollector: any;\r\n private _castCollector: any;\r\n\r\n // If the difference between the cast displacement and the simplex solver output position is less than this\r\n // value (per component), do not do a second cast to check if it's possible to reach the output position.\r\n private _displacementEps = 1e-4;\r\n\r\n /**\r\n * The transformNode of the controller\r\n */\r\n public get transformNode() {\r\n return this._transformNode;\r\n }\r\n\r\n /**\r\n * instanciate a new characterController\r\n * @param position Initial position\r\n * @param characterShapeOptions character physics shape options\r\n * @param scene Scene\r\n */\r\n public constructor(position: Vector3, characterShapeOptions: CharacterShapeOptions, scene: Scene) {\r\n this._position = position.clone();\r\n this._velocity = Vector3.Zero();\r\n this._lastVelocity = Vector3.Zero();\r\n const r = characterShapeOptions.capsuleRadius ?? 0.6;\r\n const h = characterShapeOptions.capsuleHeight ?? 1.8;\r\n this.footOffset = h * 0.5;\r\n this._tmpVecs[0].set(0, h * 0.5 - r, 0);\r\n this._tmpVecs[1].set(0, -h * 0.5 + r, 0);\r\n this._ownShape = !characterShapeOptions.shape;\r\n this._shape = characterShapeOptions.shape ?? new PhysicsShapeCapsule(this._tmpVecs[0], this._tmpVecs[1], r, scene);\r\n this._transformNode = new TransformNode(\"CCTransformNode\", scene);\r\n this._transformNode.position.copyFrom(this._position);\r\n this._body = new PhysicsBody(this._transformNode, PhysicsMotionType.ANIMATED, false, scene);\r\n this._body.setMassProperties({ inertia: Vector3.ZeroReadOnly });\r\n this._body.shape = this._shape;\r\n this._body.disablePreStep = false;\r\n this._lastInvDeltaTime = 1.0 / 60.0;\r\n this._lastDisplacement = Vector3.Zero();\r\n this._scene = scene;\r\n\r\n const hk = this._scene.getPhysicsEngine()!.getPhysicsPlugin() as HavokPlugin;\r\n const hknp = hk._hknp;\r\n\r\n this._startCollector = hknp.HP_QueryCollector_Create(16)[1];\r\n this._castCollector = hknp.HP_QueryCollector_Create(16)[1];\r\n }\r\n\r\n /**\r\n * Dispose the character controller\r\n */\r\n public dispose() {\r\n if (this._ownShape) {\r\n this._shape.dispose();\r\n }\r\n this._body.dispose();\r\n this._transformNode.dispose();\r\n\r\n const hk = this._scene.getPhysicsEngine()!.getPhysicsPlugin() as HavokPlugin;\r\n const hknp = hk._hknp;\r\n hknp.HP_QueryCollector_Release(this._startCollector);\r\n hknp.HP_QueryCollector_Release(this._castCollector);\r\n }\r\n\r\n /**\r\n * Get shape used for collision\r\n */\r\n public get shape() {\r\n return this._shape;\r\n }\r\n\r\n /**\r\n * Set shape used for collision\r\n */\r\n public set shape(value: PhysicsShape) {\r\n if (this._ownShape) {\r\n this._shape.dispose();\r\n }\r\n this._shape = value;\r\n this._body.shape = this._shape;\r\n this._ownShape = false;\r\n }\r\n\r\n /**\r\n * Character position\r\n * @returns Character position\r\n */\r\n public getPosition(): Vector3 {\r\n return this._position;\r\n }\r\n\r\n /**\r\n * Teleport character to a new position\r\n * @param position new position\r\n */\r\n public setPosition(position: Vector3) {\r\n this._position.copyFrom(position);\r\n this._transformNode.position.copyFrom(this._position);\r\n }\r\n\r\n /**\r\n * Character velocity\r\n * @returns Character velocity vector\r\n */\r\n public getVelocity(): Vector3 {\r\n return this._velocity;\r\n }\r\n\r\n /**\r\n * Set velocity vector\r\n * @param velocity vector\r\n */\r\n public setVelocity(velocity: Vector3) {\r\n this._velocity.copyFrom(velocity);\r\n }\r\n\r\n protected _validateManifold() {\r\n const newManifold = [];\r\n for (let i = 0; i < this._manifold.length; i++) {\r\n if (!this._manifold[i].bodyB.body.isDisposed) {\r\n newManifold.push(this._manifold[i]);\r\n }\r\n }\r\n this._manifold = newManifold;\r\n }\r\n\r\n private _getPointVelocityToRef(body: { body: PhysicsBody; index: number }, pointWorld: Vector3, result: Vector3) {\r\n //<todo does this really not exist in body interface?\r\n const comWorld = this._tmpVecs[10];\r\n this._getComWorldToRef(body, comWorld);\r\n const relPos = this._tmpVecs[11];\r\n pointWorld.subtractToRef(comWorld, relPos);\r\n const av = this._tmpVecs[12];\r\n body.body.getAngularVelocityToRef(av, body.index);\r\n const arm = this._tmpVecs[13];\r\n Vector3.CrossToRef(av, relPos, arm);\r\n arm.addToRef(body.body.getLinearVelocity(body.index), result);\r\n }\r\n\r\n protected _compareContacts(contactA: IContact, contactB: IContact): number {\r\n const angSquared = (1.0 - contactA.normal.dot(contactB.normal)) * this._contactAngleSensitivity * this._contactAngleSensitivity;\r\n const planeDistSquared = (contactA.distance - contactB.distance) * (contactA.distance * contactB.distance);\r\n\r\n const p1Vel = this._tmpVecs[7];\r\n this._getPointVelocityToRef(contactA.bodyB, contactA.position, p1Vel);\r\n const p2Vel = this._tmpVecs[8];\r\n this._getPointVelocityToRef(contactB.bodyB, contactB.position, p2Vel);\r\n const velocityDiff = this._tmpVecs[9];\r\n p1Vel.subtractToRef(p2Vel, velocityDiff);\r\n const velocityDiffSquared = velocityDiff.lengthSquared();\r\n\r\n const fitness = angSquared * 10.0 + velocityDiffSquared * 0.1 + planeDistSquared;\r\n return fitness;\r\n }\r\n\r\n protected _findContact(referenceContact: IContact, contactList: IContact[], threshold: number) {\r\n let bestIdx = -1;\r\n let bestFitness = threshold;\r\n for (let i = 0; i < contactList.length; i++) {\r\n const fitness = this._compareContacts(referenceContact, contactList[i]);\r\n if (fitness < bestFitness) {\r\n bestFitness = fitness;\r\n bestIdx = i;\r\n }\r\n }\r\n return bestIdx;\r\n }\r\n\r\n protected _updateManifold(startCollector: any /*HP_CollectorId*/, castCollector: any /*HP_CollectorId*/, castPath: Vector3): number {\r\n const hk = this._scene.getPhysicsEngine()!.getPhysicsPlugin() as HavokPlugin;\r\n const hknp = hk._hknp;\r\n\r\n const numProximityHits = hknp.HP_QueryCollector_GetNumHits(startCollector)[1];\r\n if (numProximityHits > 0) {\r\n const newContacts = [];\r\n let minDistance = 1e38;\r\n const bodyMap = (<any>hk)._bodies;\r\n for (let i = 0; i < numProximityHits; i++) {\r\n const [distance, , contactWorld] = hknp.HP_QueryCollector_GetShapeProximityResult(startCollector, i)[1];\r\n minDistance = Math.min(minDistance, distance);\r\n newContacts.push({\r\n position: Vector3.FromArray(contactWorld[3]),\r\n normal: Vector3.FromArray(contactWorld[4]),\r\n distance: distance,\r\n fraction: 0,\r\n bodyB: bodyMap.get(contactWorld[0][0])!,\r\n allowedPenetration: Math.min(Math.max(this.keepDistance - distance, 0.0), this.keepDistance),\r\n });\r\n }\r\n\r\n for (let i = this._manifold.length - 1; i >= 0; i--) {\r\n const currentContact = this._manifold[i];\r\n const bestMatch = this._findContact(currentContact, newContacts, 1.1);\r\n if (bestMatch >= 0) {\r\n const newAllowedPenetration = Math.min(Math.max(this.keepDistance - newContacts[bestMatch].distance, 0.0), currentContact.allowedPenetration);\r\n this._manifold[i] = newContacts[bestMatch];\r\n this._manifold[i].allowedPenetration = newAllowedPenetration;\r\n newContacts.splice(bestMatch, 1);\r\n } else {\r\n this._manifold.splice(i, 1);\r\n }\r\n }\r\n\r\n const closestContactIndex = newContacts.findIndex((c) => c.distance == minDistance);\r\n if (closestContactIndex >= 0) {\r\n const bestMatch = this._findContact(newContacts[closestContactIndex], this._manifold, 0.1);\r\n if (bestMatch >= 0) {\r\n const newAllowedPenetration = Math.min(\r\n Math.max(this.keepDistance - newContacts[closestContactIndex].distance, 0.0),\r\n this._manifold[bestMatch].allowedPenetration\r\n );\r\n this._manifold[bestMatch] = newContacts[closestContactIndex];\r\n this._manifold[bestMatch].allowedPenetration = newAllowedPenetration;\r\n } else {\r\n this._manifold.push(newContacts[closestContactIndex]);\r\n }\r\n }\r\n } else {\r\n // No start hits; clear manifold completely\r\n this._manifold.length = 0;\r\n }\r\n\r\n let numHitBodies = 0; //< == CASTCOLLECTOR_HIT_SINGLE_BODY\r\n // Process shape cast results if any\r\n const numCastHits = hknp.HP_QueryCollector_GetNumHits(castCollector)[1];\r\n if (numCastHits > 0) {\r\n let closestHitBody = null;\r\n for (let i = 0; i < numCastHits; i++) {\r\n const [fraction, , hitWorld] = hknp.HP_QueryCollector_GetShapeCastResult(castCollector, i)[1];\r\n if (closestHitBody == null) {\r\n const contact = ContactFromCast(hk, hitWorld, castPath, fraction, this.keepDistance);\r\n closestHitBody = hitWorld[0][0];\r\n const bestMatch = this._findContact(contact, this._manifold, 0.1);\r\n if (bestMatch == -1) {\r\n this._manifold.push(contact);\r\n }\r\n\r\n if (contact.bodyB.body.getMotionType(contact.bodyB.index) == PhysicsMotionType.STATIC) {\r\n // The closest body is static, so it cannot move away from CC and we don't need to look any further.\r\n break;\r\n }\r\n } else if (closestHitBody._pluginData && hitWorld[0] != closestHitBody._pluginData.hpBodyId) {\r\n numHitBodies++;\r\n break;\r\n }\r\n }\r\n }\r\n\r\n // Remove from the manifold contacts that are too similar as the simplex does not handle parallel planes\r\n for (let e1 = this._manifold.length - 1; e1 >= 0; e1--) {\r\n let e2 = e1 - 1;\r\n for (; e2 >= 0; e2--) {\r\n const fitness = this._compareContacts(this._manifold[e1], this._manifold[e2]);\r\n if (fitness < 0.1) {\r\n break;\r\n }\r\n }\r\n if (e2 >= 0) {\r\n this._manifold.slice(e1, 1);\r\n }\r\n }\r\n\r\n return numHitBodies;\r\n }\r\n\r\n // Store previous positions per body for velocity calculation\r\n protected _bodyPositionTracking = new Map();\r\n\r\n protected _createSurfaceConstraint(dt: number, contact: IContact, timeTravelled: number): ISurfaceConstraintInfo {\r\n const constraint = {\r\n //let distance = contact.distance - this.keepDistance;\r\n planeNormal: contact.normal.clone(),\r\n planeDistance: contact.distance,\r\n staticFriction: this.staticFriction,\r\n dynamicFriction: this.dynamicFriction,\r\n extraUpStaticFriction: 0,\r\n extraDownStaticFriction: 0,\r\n velocity: Vector3.Zero(),\r\n angularVelocity: Vector3.Zero(),\r\n priority: 0,\r\n };\r\n\r\n const maxSlopeCosEps = 0.1;\r\n const maxSlopeCosine = Math.max(this.maxSlopeCosine, maxSlopeCosEps);\r\n const normalDotUp = contact.normal.dot(this.up);\r\n\r\n const contactPosition = contact.position.clone();\r\n if (normalDotUp > maxSlopeCosine) {\r\n const com = this.getPosition();\r\n const contactArm = this._tmpVecs[20];\r\n contact.position.subtractToRef(com, contactArm);\r\n const scale = contact.normal.dot(contactArm);\r\n contactPosition.x = com.x + this.up.x * scale;\r\n contactPosition.y = com.y + this.up.y * scale;\r\n contactPosition.z = com.z + this.up.z * scale;\r\n }\r\n\r\n const motionType = contact.bodyB.body.getMotionType(contact.bodyB.index);\r\n if (motionType != PhysicsMotionType.STATIC) {\r\n //<todo Need hknpMotionUtil::predictPontVelocity\r\n }\r\n\r\n const shift = constraint.velocity.dot(constraint.planeNormal) * timeTravelled;\r\n constraint.planeDistance -= shift;\r\n\r\n if (motionType == PhysicsMotionType.STATIC) {\r\n constraint.priority = 2;\r\n } else if (motionType == PhysicsMotionType.ANIMATED) {\r\n const bodyTransformNode = contact.bodyB.body.transformNode;\r\n const bodyId = bodyTransformNode.uniqueId;\r\n\r\n // Retrieve tracking data\r\n let tracking = this._bodyPositionTracking.get(bodyId);\r\n\r\n const currentFrameWorldMatrix = contact.bodyB.body.transformNode.getWorldMatrix();\r\n const frameId = this._scene.getFrameId();\r\n\r\n if (!tracking) {\r\n // Initialize tracking\r\n tracking = {\r\n prevWorldMatrix: currentFrameWorldMatrix.clone(),\r\n frameId: frameId,\r\n };\r\n this._bodyPositionTracking.set(bodyId, tracking);\r\n } else {\r\n // Only calculate velocity if this contact existed in the previous frame\r\n // This avoids huge delta spikes when first making contact or after gaps\r\n if (tracking.frameId + 1 === frameId) {\r\n const previousFrameWorldMatrix = tracking.prevWorldMatrix;\r\n\r\n const currentFrameWorldMatrixInverse = TmpVectors.Matrix[1];\r\n\r\n currentFrameWorldMatrix.invertToRef(currentFrameWorldMatrixInverse);\r\n\r\n const characterPosition = this.getPosition();\r\n // compute characterPosition in body local space at previous frame\r\n const characterLocalPosition = this._tmpVecs[21];\r\n Vector3.TransformCoordinatesToRef(characterPosition, currentFrameWorldMatrixInverse, characterLocalPosition);\r\n\r\n const characterWorldPosition = this._tmpVecs[22];\r\n Vector3.TransformCoordinatesToRef(characterLocalPosition, previousFrameWorldMatrix, characterWorldPosition);\r\n const playerDeltaPosition = this._tmpVecs[23];\r\n characterPosition.subtractToRef(characterWorldPosition, playerDeltaPosition);\r\n\r\n constraint.velocity.copyFrom(playerDeltaPosition);\r\n constraint.velocity.scaleInPlace(1 / dt);\r\n constraint.priority = 1;\r\n }\r\n tracking.prevWorldMatrix.copyFrom(currentFrameWorldMatrix);\r\n tracking.frameId = frameId;\r\n }\r\n }\r\n\r\n return constraint;\r\n }\r\n\r\n protected _addMaxSlopePlane(maxSlopeCos: number, up: Vector3, index: number, constraints: ISurfaceConstraintInfo[], allowedPenetration: number): boolean {\r\n const verticalComponent = constraints[index].planeNormal.dot(up);\r\n if (verticalComponent > 0.01 && verticalComponent < maxSlopeCos) {\r\n const newConstraint = {\r\n planeNormal: constraints[index].planeNormal.clone(),\r\n planeDistance: constraints[index].planeDistance,\r\n velocity: constraints[index].velocity.clone(),\r\n angularVelocity: constraints[index].angularVelocity.clone(),\r\n priority: constraints[index].priority,\r\n dynamicFriction: constraints[index].dynamicFriction,\r\n staticFriction: constraints[index].staticFriction,\r\n extraDownStaticFriction: constraints[index].extraDownStaticFriction,\r\n extraUpStaticFriction: constraints[index].extraUpStaticFriction,\r\n };\r\n const distance = newConstraint.planeDistance;\r\n newConstraint.planeNormal.subtractInPlace(up.scale(verticalComponent));\r\n newConstraint.planeNormal.normalize();\r\n if (distance >= 0) {\r\n newConstraint.planeDistance = distance * newConstraint.planeNormal.dot(constraints[index].planeNormal);\r\n } else {\r\n const penetrationToResolve = Math.min(0, distance + allowedPenetration);\r\n newConstraint.planeDistance = penetrationToResolve / newConstraint.planeNormal.dot(constraints[index].planeNormal);\r\n constraints[index].planeDistance = 0;\r\n this._resolveConstraintPenetration(newConstraint, this.penetrationRecoverySpeed);\r\n }\r\n constraints.push(newConstraint);\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n /**\r\n * Adds an extra horizontal wall constraint when a \"walkable\" contact sits more than\r\n * `maxStepHeight` above the character's foot along `up`. Mirrors the structure of\r\n * `_addMaxSlopePlane` but gates on contact height rather than slope steepness.\r\n *\r\n * This makes `maxStepHeight` a strict cap on step climbing independent of the\r\n * capsule's curved bottom: without this, the rounded hemisphere produces an up-tilted\r\n * (walkable) contact normal for any obstacle shorter than the capsule radius, and\r\n * the simplex rides over it regardless of `maxStepHeight`.\r\n * @param constraints constraint list being assembled for the current manifold\r\n * @param contact source manifold contact backing `constraints[index]`\r\n * @param index index of the constraint in `constraints` whose contact is under test\r\n * @param allowedPenetration allowed penetration distance for this contact\r\n * @returns true if an extra wall constraint was appended\r\n */\r\n protected _addStepHeightWallPlane(constraints: ISurfaceConstraintInfo[], contact: IContact, index: number, allowedPenetration: number): boolean {\r\n const verticalComponent = constraints[index].planeNormal.dot(this.up);\r\n // Skip near-flat (≈1) contacts (don't demote plain ground) and near-horizontal\r\n // contacts (already wall-like — the regular constraint handles them).\r\n if (verticalComponent <= 0.01 || verticalComponent >= 1 - 1e-3) {\r\n return false;\r\n }\r\n // Height of the contact point above the character's foot, projected onto `up`.\r\n const contactDelta = this._tmpVecs[24];\r\n contact.position.subtractToRef(this._position, contactDelta);\r\n const stepHeight = contactDelta.dot(this.up) + this.footOffset;\r\n if (stepHeight <= this.maxStepHeight) {\r\n return false;\r\n }\r\n const newConstraint = {\r\n planeNormal: constraints[index].planeNormal.clone(),\r\n planeDistance: constraints[index].planeDistance,\r\n velocity: constraints[index].velocity.clone(),\r\n angularVelocity: constraints[index].angularVelocity.clone(),\r\n priority: constraints[index].priority,\r\n dynamicFriction: constraints[index].dynamicFriction,\r\n staticFriction: constraints[index].staticFriction,\r\n extraDownStaticFriction: constraints[index].extraDownStaticFriction,\r\n extraUpStaticFriction: constraints[index].extraUpStaticFriction,\r\n };\r\n const distance = newConstraint.planeDistance;\r\n const stepWallVerticalProjection = TmpVectors.Vector3[0];\r\n this.up.scaleToRef(verticalComponent, stepWallVerticalProjection);\r\n newConstraint.planeNormal.subtractInPlace(stepWallVerticalProjection);\r\n newConstraint.planeNormal.normalize();\r\n if (distance >= 0) {\r\n newConstraint.planeDistance = distance * newConstraint.planeNormal.dot(constraints[index].planeNormal);\r\n } else {\r\n const penetrationToResolve = Math.min(0, distance + allowedPenetration);\r\n newConstraint.planeDistance = penetrationToResolve / newConstraint.planeNormal.dot(constraints[index].planeNormal);\r\n constraints[index].planeDistance = 0;\r\n this._resolveConstraintPenetration(newConstraint, this.penetrationRecoverySpeed);\r\n }\r\n constraints.push(newConstraint);\r\n return true;\r\n }\r\n\r\n protected _resolveConstraintPenetration(constraint: ISurfaceConstraintInfo, penetrationRecoverySpeed: number) {\r\n // If penetrating we add extra velocity to push the character back out\r\n const eps = 1e-6;\r\n if (constraint.planeDistance < -eps) {\r\n constraint.planeNormal.scaleToRef(constraint.planeDistance * penetrationRecoverySpeed, this._tmpVecs[6]);\r\n constraint.velocity.subtractInPlace(this._tmpVecs[6]);\r\n }\r\n }\r\n\r\n protected _createConstraintsFromManifold(dt: number, timeTravelled: number): ISurfaceConstraintInfo[] {\r\n const constraints = [];\r\n for (let i = 0; i < this._manifold.length; i++) {\r\n const surfaceConstraint = this._createSurfaceConstraint(dt, this._manifold[i], timeTravelled);\r\n constraints.push(surfaceConstraint);\r\n const slopeDemoted = this._addMaxSlopePlane(this.maxSlopeCosine, this.up, i, constraints, this._manifold[i].allowedPenetration);\r\n // Step-height filter: when the contact sits above the foot by more than\r\n // `maxStepHeight`, add an extra horizontal wall constraint so the simplex\r\n // cannot ride over the contact via the capsule's rounded bottom. Skip when\r\n // the slope check already added a wall for the same contact.\r\n if (!slopeDemoted && this.maxStepHeight > 0) {\r\n this._addStepHeightWallPlane(constraints, this._manifold[i], i, this._manifold[i].allowedPenetration);\r\n }\r\n this._resolveConstraintPenetration(surfaceConstraint, this.penetrationRecoverySpeed);\r\n }\r\n return constraints;\r\n }\r\n\r\n protected _simplexSolverSortInfo(info: SimplexSolverInfo) {\r\n // simple bubble sort by (priority,velocity)\r\n for (let i = 0; i < info.numSupportPlanes - 1; i++) {\r\n for (let j = i + 1; j < info.numSupportPlanes; j++) {\r\n const p0 = info.supportPlanes[i];\r\n const p1 = info.supportPlanes[j];\r\n if (p0.constraint.priority < p1.constraint.priority) {\r\n continue;\r\n }\r\n if (p0.constraint.priority == p1.constraint.priority) {\r\n const vel0 = p0.constraint.velocity.lengthSquared();\r\n const vel1 = p1.constraint.velocity.lengthSquared();\r\n if (vel0 < vel1) {\r\n continue;\r\n }\r\n }\r\n info.supportPlanes[i] = p1;\r\n info.supportPlanes[j] = p0;\r\n }\r\n }\r\n }\r\n\r\n protected _simplexSolverSolve1d(info: SimplexSolverInfo, sci: ISurfaceConstraintInfo, velocityIn: Vector3, velocityOut: Vector3) {\r\n const eps = 1e-5;\r\n const groundVelocity = sci.velocity;\r\n const relativeVelocity = this._tmpVecs[22];\r\n velocityIn.subtractToRef(groundVelocity, relativeVelocity);\r\n\r\n const planeVel = relativeVelocity.dot(sci.planeNormal);\r\n\r\n const origVelocity2 = relativeVelocity.lengthSquared();\r\n relativeVelocity.subtractInPlace(sci.planeNormal.scale(planeVel));\r\n {\r\n const vp2 = planeVel * planeVel;\r\n // static friction is active if\r\n // velProjPlane * friction > |(velParallel)|\r\n // vplane * f > vpar\r\n // vp * f > vpar\r\n // vp2 * f2 > vpar2\r\n const extraStaticFriction = relativeVelocity.dot(this.up) > 0 ? sci.extraUpStaticFriction : sci.extraDownStaticFriction;\r\n if (extraStaticFriction > 0) {\r\n const horizontal = this.up.cross(sci.planeNormal);\r\n const hor2 = horizontal.lengthSquared();\r\n let horVel = 0.0;\r\n if (hor2 > eps) {\r\n horizontal.scaleInPlace(1 / Math.sqrt(hor2));\r\n\r\n horVel = relativeVelocity.dot(horizontal);\r\n\r\n // horizontal component\r\n {\r\n const horVel2 = horVel * horVel;\r\n const f2 = sci.staticFriction * sci.staticFriction;\r\n if (vp2 * f2 >= horVel2) {\r\n relativeVelocity.subtractInPlace(horizontal.scale(horVel));\r\n horVel = 0;\r\n }\r\n }\r\n }\r\n\r\n // vert component\r\n {\r\n const vertVel2 = origVelocity2 - horVel * horVel - vp2;\r\n const f2 = (sci.staticFriction + extraStaticFriction) * (sci.staticFriction + extraStaticFriction);\r\n if (vp2 * f2 >= vertVel2) {\r\n if (horVel == 0.0) {\r\n velocityOut.copyFrom(groundVelocity);\r\n return;\r\n }\r\n }\r\n }\r\n } else {\r\n // static friction is active if\r\n // velProjPlane * friction > |(vel-velProjPlane)|\r\n // vp * f > rvProj\r\n //\r\n // -> vp * f >= rvProj\r\n // -> vp * f >= sqrt( vel^2 - vp^2 )\r\n // -> vp^2 ( f^2 + 1 ) >= vel^2\r\n const f2 = sci.staticFriction * sci.staticFriction;\r\n if (vp2 * (1 + f2) >= origVelocity2) {\r\n velocityOut.copyFrom(groundVelocity);\r\n return;\r\n }\r\n }\r\n }\r\n\r\n if (sci.dynamicFriction < 1) {\r\n // apply dynamic friction 0 = conserve input velocity 1 = clip against normal\r\n const velOut2 = relativeVelocity.lengthSquared();\r\n if (velOut2 >= eps) {\r\n if (velOut2 > 1e-4 * origVelocity2) {\r\n let f = Math.sqrt(origVelocity2 / velOut2);\r\n f = sci.dynamicFriction + (1 - sci.dynamicFriction) * f;\r\n relativeVelocity.scaleInPlace(f);\r\n const p = sci.planeNormal.dot(relativeVelocity);\r\n relativeVelocity.subtractInPlace(sci.planeNormal.scale(p));\r\n }\r\n }\r\n }\r\n velocityOut.copyFrom(relativeVelocity);\r\n velocityOut.addInPlace(groundVelocity);\r\n }\r\n\r\n protected _simplexSolverSolveTest1d(sci: ISurfaceConstraintInfo, velocityIn: Vector3): boolean {\r\n const eps = 1e-3;\r\n const relativeVelocity = this._tmpVecs[23];\r\n velocityIn.subtractToRef(sci.velocity, relativeVelocity);\r\n return relativeVelocity.dot(sci.planeNormal) < -eps;\r\n }\r\n\r\n protected _simplexSolverSolve2d(\r\n info: SimplexSolverInfo,\r\n maxSurfaceVelocity: Vector3,\r\n sci0: ISurfaceConstraintInfo,\r\n sci1: ISurfaceConstraintInfo,\r\n velocityIn: Vector3,\r\n velocityOut: Vector3\r\n ) {\r\n const eps = 1e-5;\r\n const axis = sci0.planeNormal.cross(sci1.planeNormal);\r\n const axisLen2 = axis.lengthSquared();\r\n\r\n let solveSequentially: boolean = false;\r\n let axisVel: Vector3 | null;\r\n\r\n // eslint-disable-next-line no-constant-condition\r\n while (true) {\r\n // Check for parallel planes\r\n if (axisLen2 <= eps || solveSequentially) {\r\n info.getOutput(sci0).status = SurfaceConstraintInteractionStatus.FAILURE_2D;\r\n info.getOutput(sci1).status = SurfaceConstraintInteractionStatus.FAILURE_2D;\r\n\r\n if (sci0.priority > sci1.priority) {\r\n this._simplexSolverSolve1d(info, sci1, velocityIn, velocityOut);\r\n this._simplexSolverSolve1d(info, sci0, velocityIn, velocityOut);\r\n } else {\r\n this._simplexSolverSolve1d(info, sci0, velocityIn, velocityOut);\r\n this._simplexSolverSolve1d(info, sci1, velocityIn, velocityOut);\r\n }\r\n return;\r\n }\r\n\r\n const invAxisLen = 1.0 / Math.sqrt(axisLen2);\r\n axis.scaleInPlace(invAxisLen);\r\n\r\n // Calculate the velocity of the free axis\r\n {\r\n const r0 = sci0.planeNormal.cross(sci1.planeNormal);\r\n const r1 = sci1.planeNormal.cross(axis);\r\n const r2 = axis.cross(sci0.planeNormal);\r\n\r\n const sVel = sci0.velocity.add(sci1.velocity);\r\n\r\n const t = this._tmpVecs[2];\r\n t.set(0.5 * axis.dot(sVel), sci0.planeNormal.dot(sci0.velocity), sci1.planeNormal.dot(sci1.velocity));\r\n const m = Matrix.FromValues(r0.x, r1.x, r2.x, 0, r0.y, r1.y, r2.y, 0, r0.z, r1.z, r2.z, 0, 0, 0, 0, 1);\r\n axisVel = Vector3.TransformNormal(t, m);\r\n axisVel.scaleInPlace(invAxisLen);\r\n\r\n if (Math.abs(axisVel.x) > maxSurfaceVelocity.x || Math.abs(axisVel.y) > maxSurfaceVelocity.y || Math.abs(axisVel.z) > maxSurfaceVelocity.z) {\r\n solveSequentially = true;\r\n } else {\r\n break;\r\n }\r\n }\r\n }\r\n\r\n const groundVelocity = axisVel;\r\n const relativeVelocity = this._tmpVecs[24];\r\n velocityIn.subtractToRef(groundVelocity, relativeVelocity);\r\n\r\n const vel2 = relativeVelocity.lengthSquared();\r\n const axisVert = this.up.dot(axis);\r\n let axisProjVelocity = relativeVelocity.dot(axis);\r\n\r\n let staticFriction = sci0.staticFriction + sci1.staticFriction;\r\n if (axisVert * axisProjVelocity > 0) {\r\n staticFriction += (sci0.extraUpStaticFriction + sci1.extraUpStaticFriction) * axisVert;\r\n } else {\r\n staticFriction += (sci0.extraDownStaticFriction + sci1.extraDownStaticFriction) * axisVert;\r\n }\r\n staticFriction *= 0.5;\r\n\r\n const dynamicFriction = (sci0.dynamicFriction + sci1.dynamicFriction) * 0.5;\r\n // static friction is active if\r\n // |vel-axisProjVelocity|(rv) * friction(f) > axisProjVelocity(av)\r\n // -> sqrt( vel2 - av2 ) * f > av\r\n // -> (vel2 - av2) * f2 > av2\r\n const f2 = staticFriction * staticFriction;\r\n const av2 = axisProjVelocity * axisProjVelocity;\r\n if ((vel2 - av2) * f2 >= av2) {\r\n // static friction kicks in\r\n velocityOut.copyFrom(groundVelocity);\r\n return;\r\n }\r\n\r\n if (dynamicFriction < 1) {\r\n // apply dynamic friction\r\n if (axisProjVelocity * axisProjVelocity > 1e-4 * vel2) {\r\n const tmp = 1.0 / axisProjVelocity;\r\n const f = Math.abs(tmp) * Math.sqrt(vel2) * (1.0 - dynamicFriction) + dynamicFriction;\r\n axisProjVelocity *= f;\r\n }\r\n }\r\n velocityOut.copyFrom(groundVelocity);\r\n velocityOut.addInPlace(axis.scale(axisProjVelocity));\r\n }\r\n\r\n protected _simplexSolverSolve3d(\r\n info: SimplexSolverInfo,\r\n maxSurfaceVelocity: Vector3,\r\n sci0: ISurfaceConstraintInfo,\r\n sci1: ISurfaceConstraintInfo,\r\n sci2: ISurfaceConstraintInfo,\r\n allowResort: boolean,\r\n velocityIn: Vector3,\r\n velocityOut: Vector3\r\n ) {\r\n const eps = 1e-5;\r\n // Calculate the velocity of the point axis\r\n let pointVel: Vector3 | null;\r\n {\r\n const r0 = sci1.planeNormal.cross(sci2.planeNormal);\r\n const r1 = sci2.planeNormal.cross(sci0.planeNormal);\r\n const r2 = sci0.planeNormal.cross(sci1.planeNormal);\r\n\r\n const det = r0.dot(sci0.planeNormal);\r\n let solveSequentially: boolean = false;\r\n // eslint-disable-next-line no-constant-condition\r\n while (true) {\r\n if (Math.abs(det) < eps || solveSequentially) {\r\n if (allowResort) {\r\n this._simplexSolverSortInfo(info);\r\n sci0 = info.supportPlanes[0].constraint;\r\n sci1 = info.supportPlanes[1].constraint;\r\n sci2 = info.supportPlanes[2].constraint;\r\n }\r\n info.getOutput(sci0).status = SurfaceConstraintInteractionStatus.FAILURE_3D;\r\n info.getOutput(sci1).status = SurfaceConstraintInteractionStatus.FAILURE_3D;\r\n info.getOutput(sci2).status = SurfaceConstraintInteractionStatus.FAILURE_3D;\r\n\r\n const oldNum = info.numSupportPlanes;\r\n this._simplexSolverSolve2d(info, maxSurfaceVelocity, sci0, sci1, velocityIn, velocityOut);\r\n if (oldNum == info.numSupportPlanes) {\r\n this._simplexSolverSolve2d(info, maxSurfaceVelocity, sci0, sci2, velocityIn, velocityOut);\r\n }\r\n if (oldNum == info.numSupportPlanes) {\r\n this._simplexSolverSolve2d(info, maxSurfaceVelocity, sci1, sci2, velocityIn, velocityOut);\r\n }\r\n\r\n return;\r\n }\r\n\r\n const t = this._tmpVecs[2];\r\n t.set(sci0.planeNormal.dot(sci0.velocity), sci1.planeNormal.dot(sci1.velocity), sci2.planeNormal.dot(sci2.velocity));\r\n const m = Matrix.FromValues(r0.x, r0.y, r0.z, 0, r1.x, r1.y, r1.z, 0, r2.x, r2.y, r2.z, 0, 0, 0, 0, 1);\r\n pointVel = Vector3.TransformNormal(t, m);\r\n pointVel.scaleInPlace(1 / det);\r\n if (Math.abs(pointVel.x) > maxSurfaceVelocity.x || Math.abs(pointVel.y) > maxSurfaceVelocity.y || Math.abs(pointVel.z) > maxSurfaceVelocity.z) {\r\n solveSequentially = true;\r\n } else {\r\n break;\r\n }\r\n }\r\n }\r\n velocityOut.copyFrom(pointVel);\r\n }\r\n\r\n protected _simplexSolverExamineActivePlanes(info: SimplexSolverInfo, maxSurfaceVelocity: Vector3, velocityIn: Vector3, velocityOut: Vector3) {\r\n // eslint-disable-next-line no-constant-condition\r\n while (true) {\r\n switch (info.numSupportPlanes) {\r\n case 1: {\r\n const sci = info.supportPlanes[0].constraint;\r\n this._simplexSolverSolve1d(info, sci, velocityIn, velocityOut);\r\n return;\r\n }\r\n case 2: {\r\n const velocity = Vector3.Zero();\r\n this._simplexSolverSolve1d(info, info.supportPlanes[1].constraint, velocityIn, velocity);\r\n const plane0Used = this._simplexSolverSolveTest1d(info.supportPlanes[0].constraint, velocity);\r\n if (!plane0Used) {\r\n // Only need plane 1, so remove plane 0\r\n info.supportPlanes[0].copyFrom(info.supportPlanes[1]);\r\n info.numSupportPlanes = 1;\r\n velocityOut.copyFrom(velocity);\r\n } else {\r\n this._simplexSolverSolve2d(info, maxSurfaceVelocity, info.supportPlanes[0].constraint, info.supportPlanes[1].constraint, velocityIn, velocityOut);\r\n }\r\n return;\r\n }\r\n case 3: {\r\n // Try to drop both planes\r\n {\r\n const velocity = Vector3.Zero();\r\n this._simplexSolverSolve1d(info, info.supportPlanes[2].constraint, velocityIn, velocityOut);\r\n\r\n const plane0Used = this._simplexSolverSolveTest1d(info.supportPlanes[0].constraint, velocity);\r\n if (!plane0Used) {\r\n const plane1Used = this._simplexSolverSolveTest1d(info.supportPlanes[1].constraint, velocity);\r\n if (!plane1Used) {\r\n velocityOut.copyFrom(velocity);\r\n info.supportPlanes[0].copyFrom(info.supportPlanes[2]);\r\n info.numSupportPlanes = 1;\r\n continue;\r\n }\r\n }\r\n }\r\n\r\n // Try to drop plane 0 or 1\r\n {\r\n let droppedAPlane = false;\r\n for (let testPlane = 0; testPlane < 2; testPlane++) {\r\n const velocity = Vector3.Zero();\r\n this._simplexSolverSolve2d(\r\n info,\r\n maxSurfaceVelocity,\r\n info.supportPlanes[testPlane].constraint,\r\n info.supportPlanes[2].constraint,\r\n velocityIn,\r\n velocityOut\r\n );\r\n const planeUsed = this._simplexSolverSolveTest1d(info.supportPlanes[1 - testPlane].constraint, velocity);\r\n if (!planeUsed) {\r\n info.supportPlanes[0].copyFrom(info.supportPlanes[testPlane]);\r\n info.supportPlanes[1].copyFrom(info.supportPlanes[2]);\r\n info.numSupportPlanes--;\r\n droppedAPlane = true;\r\n break;\r\n }\r\n }\r\n\r\n if (droppedAPlane) {\r\n continue;\r\n }\r\n }\r\n\r\n // Otherwise, try and solve all three planes:\r\n this._simplexSolverSolve3d(\r\n info,\r\n maxSurfaceVelocity,\r\n info.supportPlanes[0].constraint,\r\n info.supportPlanes[1].constraint,\r\n info.supportPlanes[2].constraint,\r\n true,\r\n velocityIn,\r\n velocityOut\r\n );\r\n return;\r\n }\r\n case 4: {\r\n this._simplexSolverSortInfo(info);\r\n let droppedAPlane = false;\r\n\r\n for (let i = 0; i < 3; i++) {\r\n const velocity = Vector3.Zero();\r\n this._simplexSolverSolve3d(\r\n info,\r\n maxSurfaceVelocity,\r\n info.supportPlanes[(i + 1) % 3].constraint,\r\n info.supportPlanes[(i + 2) % 3].constraint,\r\n info.supportPlanes[3].constraint,\r\n false,\r\n velocityIn,\r\n velocity\r\n );\r\n const planeUsed = this._simplexSolverSolveTest1d(info.supportPlanes[i].constraint, velocity);\r\n if (!planeUsed) {\r\n info.supportPlanes[i].copyFrom(info.supportPlanes[2]);\r\n info.supportPlanes[2].copyFrom(info.supportPlanes[3]);\r\n info.numSupportPlanes = 3;\r\n droppedAPlane = true;\r\n break;\r\n }\r\n }\r\n\r\n if (droppedAPlane) {\r\n continue;\r\n }\r\n\r\n // Nothing can be dropped so we've failed to solve\r\n // Now we try all 3d combinations\r\n {\r\n const velocity = velocityIn.clone();\r\n const sci0 = info.supportPlanes[0].constraint;\r\n const sci1 = info.supportPlanes[1].constraint;\r\n const sci2 = info.supportPlanes[2].constraint;\r\n const sci3 = info.supportPlanes[3].constraint;\r\n const oldNum = info.numSupportPlanes;\r\n if (oldNum == info.numSupportPlanes) {\r\n this._simplexSolverSolve3d(info, maxSurfaceVelocity, sci0, sci1, sci2, false, velocity, velocity);\r\n // eslint-disable-next-line no-dupe-else-if\r\n } else if (oldNum == info.numSupportPlanes) {\r\n this._simplexSolverSolve3d(info, maxSurfaceVelocity, sci0, sci1, sci3, false, velocity, velocity);\r\n // eslint-disable-next-line no-dupe-else-if\r\n } else if (oldNum == info.numSupportPlanes) {\r\n this._simplexSolverSolve3d(info, maxSurfaceVelocity, sci0, sci2, sci3, false, velocity, velocity);\r\n // eslint-disable-next-line no-dupe-else-if\r\n } else if (oldNum == info.numSupportPlanes) {\r\n this._simplexSolverSolve3d(info, maxSurfaceVelocity, sci1, sci2, sci3, false, velocity, velocity);\r\n }\r\n\r\n velocityOut.copyFrom(velocity);\r\n }\r\n\r\n // Search a plane to drop\r\n {\r\n // Search the highest penalty value\r\n let maxStatus = SurfaceConstraintInteractionStatus.OK;\r\n for (let i = 0; i < 4; i++) {\r\n maxStatus = Math.max(maxStatus, info.supportPlanes[i].interaction.status);\r\n }\r\n\r\n // Remove the place with the lowest priority and the highest penalty\r\n let i = 0;\r\n for (; i < 4; i++) {\r\n if (maxStatus == info.supportPlanes[i].interaction.status) {\r\n info.supportPlanes[i].copyFrom(info.supportPlanes[3]);\r\n break;\r\n }\r\n info.numSupportPlanes--;\r\n }\r\n }\r\n\r\n // Clear penalty flags for the other planes\r\n for (let i = 0; i < 3; i++) {\r\n info.supportPlanes[i].interaction.status = SurfaceConstraintInteractionStatus.OK;\r\n }\r\n\r\n continue;\r\n }\r\n }\r\n }\r\n }\r\n\r\n protected _simplexSolverSolve(\r\n constraints: ISurfaceConstraintInfo[],\r\n velocity: Vector3,\r\n deltaTime: number,\r\n minDeltaTime: number,\r\n up: Vector3,\r\n maxSurfaceVelocity: Vector3\r\n ): SimplexSolverOutput {\r\n const eps = 1e-6;\r\n const output = new SimplexSolverOutput();\r\n output.position = Vector3.Zero();\r\n output.velocity = velocity.clone();\r\n output.planeInteractions = [];\r\n let remainingTime = deltaTime;\r\n\r\n for (let i = 0; i < constraints.length; i++) {\r\n output.planeInteractions.push({\r\n touched: false,\r\n stopped: false,\r\n surfaceTime: 0,\r\n penaltyDistance: 0,\r\n status: SurfaceConstraintInteractionStatus.OK,\r\n });\r\n }\r\n\r\n const info = new SimplexSolverInfo();\r\n info.inputConstraints = constraints;\r\n info.outputInteractions = output.planeInteractions;\r\n info.supportPlanes[0] = new SimplexSolverActivePlanes();\r\n info.supportPlanes[1] = new SimplexSolverActivePlanes();\r\n info.supportPlanes[2] = new SimplexSolverActivePlanes();\r\n info.supportPlanes[3] = new SimplexSolverActivePlanes();\r\n\r\n while (remainingTime > 0) {\r\n // search for a plane which collides our current direction\r\n let hitIndex = -1;\r\n let minCollisionTime = remainingTime;\r\n for (let i = 0; i < constraints.length; i++) {\r\n // Do not search existing active planes\r\n if (info.numSupportPlanes >= 1 && info.supportPlanes[0].index == i) {\r\n continue;\r\n }\r\n if (info.numSupportPlanes >= 2 && info.supportPlanes[1].index == i) {\r\n continue;\r\n }\r\n if (info.numSupportPlanes >= 3 && info.supportPlanes[2].index == i) {\r\n continue;\r\n }\r\n if (output.planeInteractions[i].status != SurfaceConstraintInteractionStatus.OK) {\r\n continue;\r\n }\r\n\r\n // Try to find the plane with the shortest time to move\r\n const sci = constraints[i];\r\n const relativeVel = this._tmpVecs[25];\r\n output.velocity.subtractToRef(sci.velocity, relativeVel);\r\n const relativeProjectedVel = -relativeVel.dot(sci.planeNormal);\r\n // if projected velocity is pointing away skip it\r\n if (relativeProjectedVel <= 0) {\r\n continue;\r\n }\r\n\r\n // Calculate the time of impact\r\n const relativePos = this._tmpVecs[26];\r\n sci.velocity.scaleToRef(info.currentTime, this._tmpVecs[27]);\r\n output.position.subtractToRef(this._tmpVecs[27], relativePos);\r\n let projectedPos = sci.planeNormal.dot(relativePos);\r\n\r\n // treat penetrations\r\n const penaltyDist = output.planeInteractions[i].penaltyDistance;\r\n if (penaltyDist < eps) {\r\n projectedPos = 0;\r\n }\r\n projectedPos += penaltyDist;\r\n\r\n // check for new hit\r\n if (projectedPos < minCollisionTime * relativeProjectedVel) {\r\n minCollisionTime = projectedPos / relativeProjectedVel;\r\n hitIndex = i;\r\n }\r\n }\r\n\r\n // integrate: Walk to our hitPosition we must walk more than 10 microseconds into the future to consider it valid.\r\n const minAcceptableCollisionTime = 1e-4;\r\n if (minCollisionTime > minAcceptableCollisionTime) {\r\n info.currentTime += minCollisionTime;\r\n remainingTime -= minCollisionTime;\r\n output.position.addInPlace(output.velocity.scale(minCollisionTime));\r\n for (let i = 0; i < info.numSupportPlanes; i++) {\r\n info.supportPlanes[i].interaction.surfaceTime += minCollisionTime;\r\n info.supportPlanes[i].interaction.touched = true;\r\n }\r\n\r\n output.deltaTime = info.currentTime;\r\n if (info.currentTime > minDeltaTime) {\r\n return output;\r\n }\r\n }\r\n\r\n // If we have no hit than we are done\r\n if (hitIndex < 0) {\r\n output.deltaTime = deltaTime;\r\n break;\r\n }\r\n\r\n // Add our hit to our current list of active planes\r\n const supportPlane = info.supportPlanes[info.numSupportPlanes++];\r\n supportPlane.constraint = constraints[hitIndex];\r\n supportPlane.interaction = output.planeInteractions[hitIndex];\r\n supportPlane.interaction.penaltyDistance = (supportPlane.interaction.penaltyDistance + eps) * 2.0;\r\n supportPlane.index = hitIndex;\r\n\r\n // Move our character along the current set of active planes\r\n this._simplexSolverExamineActivePlanes(info, maxSurfaceVelocity, velocity, output.velocity);\r\n }\r\n\r\n return output;\r\n }\r\n\r\n /**\r\n * Compute a CharacterSurfaceInfo from current state and a direction\r\n * @param deltaTime frame delta time in seconds. When using scene.deltaTime divide by 1000.0\r\n * @param direction direction to check, usually gravity direction\r\n * @returns a CharacterSurfaceInfo object\r\n */\r\n public checkSupport(deltaTime: number, direction: Vector3): CharacterSurfaceInfo {\r\n const surfaceInfo = {\r\n isSurfaceDynamic: false,\r\n supportedState: CharacterSupportedState.UNSUPPORTED,\r\n averageSurfaceNormal: Vector3.Zero(),\r\n averageSurfaceVelocity: Vector3.Zero(),\r\n averageAngularSurfaceVelocity: Vector3.Zero(),\r\n };\r\n this.checkSupportToRef(deltaTime, direction, surfaceInfo);\r\n return surfaceInfo;\r\n }\r\n\r\n /**\r\n * Compute a CharacterSurfaceInfo from current state and a direction\r\n * @param deltaTime frame delta time in seconds. When using scene.deltaTime divide by 1000.0\r\n * @param direction direction to check, usually gravity direction\r\n * @param surfaceInfo output for surface info\r\n */\r\n public checkSupportToRef(deltaTime: number, direction: Vector3, surfaceInfo: CharacterSurfaceInfo): void {\r\n const eps = 1e-4;\r\n\r\n this._validateManifold();\r\n const constraints = this._createConstraintsFromManifold(deltaTime, 0.0);\r\n const storedVelocities: Vector3[] = [];\r\n // Remove velocities and friction to make this a query of the static geometry\r\n for (let i = 0; i < constraints.length; i++) {\r\n storedVelocities.push(constraints[i].velocity.clone());\r\n constraints[i].velocity.setAll(0);\r\n }\r\n\r\n const maxSurfaceVelocity = this._tmpVecs[3];\r\n maxSurfaceVelocity.set(this.maxCharacterSpeedForSolver, this.maxCharacterSpeedForSolver, this.maxCharacterSpeedForSolver);\r\n const output = this._simplexSolverSolve(constraints, direction, deltaTime, deltaTime, this.up, maxSurfaceVelocity);\r\n\r\n surfaceInfo.averageSurfaceVelocity.setAll(0);\r\n surfaceInfo.averageAngularSurfaceVelocity.setAll(0);\r\n surfaceInfo.averageSurfaceNormal.setAll(0);\r\n surfaceInfo.isSurfaceDynamic = false;\r\n\r\n // If the constraints did not affect the character movement then it is unsupported and we can finish\r\n if (output.velocity.equalsWithEpsilon(direction, eps)) {\r\n surfaceInfo.supportedState = CharacterSupportedState.UNSUPPORTED;\r\n return;\r\n }\r\n\r\n // Check how was the input velocity modified to determine if the character is supported or sliding\r\n if (output.velocity.lengthSquared() < eps) {\r\n surfaceInfo.supportedState = CharacterSupportedState.SUPPORTED;\r\n } else {\r\n output.velocity.normalize();\r\n const angleSin = output.velocity.dot(direction);\r\n const cosSqr = 1 - angleSin * angleSin;\r\n if (cosSqr < this.maxSlopeCosine * this.maxSlopeCosine) {\r\n surfaceInfo.supportedState = CharacterSupportedState.SLIDING;\r\n } else {\r\n surfaceInfo.supportedState = CharacterSupportedState.SUPPORTED;\r\n }\r\n }\r\n\r\n // Add all supporting constraints to the ground information\r\n let numTouching = 0;\r\n for (let i = -0; i < constraints.length; i++) {\r\n if (output.planeInteractions[i].touched && constraints[i].planeNormal.dot(direction) < -0.08) {\r\n surfaceInfo.averageSurfaceNormal.addInPlace(constraints[i].planeNormal);\r\n surfaceInfo.averageSurfaceVelocity.addInPlace(storedVelocities[i]);\r\n surfaceInfo.averageAngularSurfaceVelocity.addInPlace(constraints[i].angularVelocity);\r\n numTouching++;\r\n }\r\n }\r\n\r\n if (numTouching > 0) {\r\n surfaceInfo.averageSurfaceNormal.normalize();\r\n surfaceInfo.averageSurfaceVelocity.scaleInPlace(1 / numTouching);\r\n surfaceInfo.averageAngularSurfaceVelocity.scaleInPlace(1 / numTouching);\r\n }\r\n\r\n // isSurfaceDynamic update\r\n if (surfaceInfo.supportedState == CharacterSupportedState.SUPPORTED) {\r\n for (let i = 0; i < this._manifold.length; i++) {\r\n const manifold = this._manifold[i];\r\n const bodyB = manifold.bodyB;\r\n\r\n if (this._manifold[i].normal.dot(direction) < -0.08 && bodyB.body.getMotionType(0) == PhysicsMotionType.DYNAMIC) {\r\n surfaceInfo.isSurfaceDynamic = true;\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n\r\n protected _castWithCollectors(startPos: Vector3, endPos: Vector3, castCollector: any /*HP_CollectorId*/, startCollector?: any /*HP_CollectorId*/) {\r\n const hk = this._scene.getPhysicsEngine()!.getPhysicsPlugin() as HavokPlugin;\r\n const hknp = hk._hknp;\r\n\r\n const startNative = [startPos.x, startPos.y, startPos.z];\r\n const orientation = [this._orientation.x, this._orientation.y, this._orientation.z, this._orientation.w];\r\n if (startCollector != null) {\r\n const query /*: ShapeProximityInput*/ = [\r\n this._shape._pluginData,\r\n startNative,\r\n orientation,\r\n this.keepDistance + this.keepContactTolerance, // max distance\r\n false, // should hit triggers\r\n [this._body._pluginData.hpBodyId[0]],\r\n ];\r\n hknp.HP_World_ShapeProximityWithCollector(hk.world, startCollector, query);\r\n }\r\n\r\n {\r\n const query /*: ShapeCastInput*/ = [\r\n this._shape._pluginData,\r\n orientation,\r\n startNative,\r\n [endPos.x, endPos.y, endPos.z],\r\n false, // should hit triggers\r\n [this._body._pluginData.hpBodyId[0]],\r\n ];\r\n hknp.HP_World_ShapeCastWithCollector(hk.world, castCollector, query);\r\n }\r\n }\r\n\r\n /**\r\n * Rebuild the contact manifold from a proximity query at the given position.\r\n * Used by step-up to validate a candidate landing without the merging logic of `_updateManifold`,\r\n * which is not suited to a zero-length cast.\r\n * @param position position at which to run the proximity query\r\n */\r\n protected _refreshManifoldAtPosition(position: Vector3): void {\r\n const hk = this._scene.getPhysicsEngine()!.getPhysicsPlugin() as HavokPlugin;\r\n const hknp = hk._hknp;\r\n const bodyMap = (hk as any)._bodies;\r\n\r\n const startNative = [position.x, position.y, position.z];\r\n const orientation = [this._orientation.x, this._orientation.y, this._orientation.z, this._orientation.w];\r\n const query /*: ShapeProximityInput*/ = [\r\n this._shape._pluginData,\r\n startNative,\r\n orientation,\r\n this.keepDistance + this.keepContactTolerance,\r\n false,\r\n [this._body._pluginData.hpBodyId[0]],\r\n ];\r\n hknp.HP_World_ShapeProximityWithCollector(hk.world, this._startCollector, query);\r\n\r\n this._manifold.length = 0;\r\n const numHits = hknp.HP_QueryCollector_GetNumHits(this._startCollector)[1];\r\n for (let i = 0; i < numHits; i++) {\r\n const [distance, , contactWorld] = hknp.HP_QueryCollector_GetShapeProximityResult(this._startCollector, i)[1];\r\n this._manifold.push({\r\n position: Vector3.FromArray(contactWorld[3]),\r\n normal: Vector3.FromArray(contactWorld[4]),\r\n distance: distance,\r\n fraction: 0,\r\n bodyB: bodyMap.get(contactWorld[0][0])!,\r\n allowedPenetration: Math.min(Math.max(this.keepDistance - distance, 0.0), this.keepDistance),\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * Search the simplex solver output for a constraint that blocks horizontal motion:\r\n * touched by the solver, non-walkable along `up`, and opposing the requested horizontal direction.\r\n * @param simplexOutput output of `_simplexSolverSolve`\r\n * @param constraints constraint array passed to the solver\r\n * @param horizDir normalized horizontal direction of intent\r\n * @returns the index of the first matching constraint, or -1\r\n */\r\n protected _findBlockingConstraintIndex(simplexOutput: SimplexSolverOutput, constraints: ISurfaceConstraintInfo[], horizDir: Vector3): number {\r\n const oppositionEps = 1e-3;\r\n const ceilingThreshold = -0.5;\r\n const maxSlopeCosEps = 0.1;\r\n const maxSlope = Math.max(this.maxSlopeCosine, maxSlopeCosEps);\r\n for (let i = 0; i < constraints.length; i++) {\r\n if (!simplexOutput.planeInteractions[i].touched) {\r\n continue;\r\n }\r\n const n = constraints[i].planeNormal;\r\n const normalDotUp = n.dot(this.up);\r\n if (normalDotUp >= maxSlope) {\r\n continue;\r\n }\r\n if (normalDotUp <= ceilingThreshold) {\r\n continue;\r\n }\r\n if (n.dot(horizDir) > -oppositionEps) {\r\n continue;\r\n }\r\n return i;\r\n }\r\n return -1;\r\n }\r\n\r\n /**\r\n * Iterate hits in the cast collector to find the closest one.\r\n * @returns object with fraction, normal, body and index of the closest hit; null if there were no hits\r\n */\r\n protected _getClosestCastHit(): { fraction: number; normal: Vector3; body: { body: PhysicsBody; index: number } | null } | null {\r\n const hk = this._scene.getPhysicsEngine()!.getPhysicsPlugin() as HavokPlugin;\r\n const hknp = hk._hknp;\r\n const bodyMap = (hk as any)._bodies;\r\n const numHits = hknp.HP_QueryCollector_GetNumHits(this._castCollector)[1];\r\n if (numHits <= 0) {\r\n return null;\r\n }\r\n let bestFrac = Number.POSITIVE_INFINITY;\r\n const bestNormal = TmpVectors.Vector3[0];\r\n let hasBestNormal = false;\r\n let bestBody: { body: PhysicsBody; index: number } | null = null;\r\n for (let i = 0; i < numHits; i++) {\r\n const [frac, , hitWorld] = hknp.HP_QueryCollector_GetShapeCastResult(this._castCollector, i)[1];\r\n if (frac < bestFrac) {\r\n bestFrac = frac;\r\n Vector3.FromArrayToRef(hitWorld[4], 0, bestNormal);\r\n hasBestNormal = true;\r\n bestBody = bodyMap.get(hitWorld[0][0]) ?? null;\r\n }\r\n }\r\n if (!hasBestNormal) {\r\n return null;\r\n }\r\n return { fraction: bestFrac, normal: bestNormal.clone(), body: bestBody };\r\n }\r\n\r\n /**\r\n * Attempt a step-up sweep when the character is blocked by a vertical-ish obstacle.\r\n * Runs three shape casts (up, forward, down) and, if a valid walkable landing is found,\r\n * commits a new position, refreshes the manifold and updates `_lastDisplacement`.\r\n *\r\n * Caller responsibilities on success:\r\n * - subtract the returned time from `remainingTime`\r\n * - skip `_resolveContacts`, the recast block and the position update for the iteration\r\n * (the step is a teleport, not a contact-resolution motion)\r\n *\r\n * @param remainingTime time budget left in the current `_integrateManifolds` iteration\r\n * @param inputVelocity character velocity at the start of the integration call\r\n * @param simplexOutput output of the iteration's simplex solve\r\n * @param constraints constraint array passed to the solver\r\n * @returns time consumed by the step on success, -1 on failure (no state mutated)\r\n */\r\n protected _tryStepUp(remainingTime: number, inputVelocity: Vector3, simplexOutput: SimplexSolverOutput, constraints: ISurfaceConstraintInfo[]): number {\r\n const eps = 1e-4;\r\n const stepHeight = this.maxStepHeight;\r\n if (stepHeight <= 0 || remainingTime <= 0) {\r\n return -1;\r\n }\r\n\r\n // 1. Intended horizontal displacement (assumes `up` is unit-length)\r\n const upUnit = this.up;\r\n const upDotVel = inputVelocity.dot(upUnit);\r\n const horizVel = this._tmpVecs[28];\r\n upUnit.scaleToRef(upDotVel, this._tmpVecs[29]);\r\n inputVelocity.subtractToRef(this._tmpVecs[29], horizVel);\r\n const horizVelLenSqr = horizVel.lengthSquared();\r\n if (horizVelLenSqr < eps * eps) {\r\n return -1;\r\n }\r\n const horizVelLen = Math.sqrt(horizVelLenSqr);\r\n const horizDir = this._tmpVecs[30];\r\n horizVel.scaleToRef(1 / horizVelLen, horizDir);\r\n const horizDist = horizVelLen * remainingTime;\r\n if (horizDist <= eps) {\r\n return -1;\r\n }\r\n\r\n // 2. Solver must have hit a blocking, non-walkable, opposing constraint\r\n if (this._findBlockingConstraintIndex(simplexOutput, constraints, horizDir) < 0) {\r\n return -1;\r\n }\r\n\r\n // 3. Up-cast: find available head-room up to stepHeight\r\n const upEnd = this._tmpVecs[31];\r\n upUnit.scaleToRef(stepHeight, upEnd);\r\n upEnd.addInPlace(this._position);\r\n this._castWithCollectors(this._position, upEnd, this._castCollector);\r\n const upHit = this._getClosestCastHit();\r\n let stepClear = stepHeight;\r\n if (upHit != null) {\r\n if (upHit.body && upHit.body.body.getMotionType(upHit.body.index) === PhysicsMotionType.DYNAMIC) {\r\n return -1;\r\n }\r\n stepClear = Math.max(0, upHit.fraction * stepHeight - this.keepDistance);\r\n }\r\n if (stepClear <= eps) {\r\n return -1;\r\n }\r\n\r\n // 4. Forward-cast: sweep from the elevated position by the requested horizontal distance\r\n const elevated = upUnit.scale(stepClear);\r\n elevated.addInPlace(this._position);\r\n const fwdEnd = horizDir.scale(horizDist);\r\n fwdEnd.addInPlace(elevated);\r\n this._castWithCollectors(elevated, fwdEnd, this._castCollector);\r\n let fwdFrac = 1.0;\r\n const fwdHit = this._getClosestCastHit();\r\n if (fwdHit != null) {\r\n if (fwdHit.body && fwdHit.body.body.getMotionType(fwdHit.body.index) === PhysicsMotionType.DYNAMIC) {\r\n return -1;\r\n }\r\n fwdFrac = fwdHit.fraction;\r\n }\r\n // Backoff by keepDistance along horizDir\r\n const fwdFracAdjusted = Math.max(0, Math.min(1, fwdFrac - this.keepDistance / horizDist));\r\n if (fwdFracAdjusted <= eps) {\r\n return -1;\r\n }\r\n const fwdEndAdjusted = horizDir.scale(horizDist * fwdFracAdjusted);\r\n fwdEndAdjusted.addInPlace(elevated);\r\n\r\n // 5. Down-cast: drop from forward position to find walkable landing\r\n const downDist = stepClear + 2 * this.keepDistance;\r\n const downEnd = upUnit.scale(-downDist);\r\n downEnd.addInPlace(fwdEndAdjusted);\r\n this._castWithCollectors(fwdEndAdjusted, downEnd, this._castCollector);\r\n const downHit = this._getClosestCastHit();\r\n if (downHit == null) {\r\n // No ground found within reach: stepping into the void (e.g., over a fence). Reject.\r\n return -1;\r\n }\r\n if (downHit.body == null) {\r\n return -1;\r\n }\r\n const landingMotion = downHit.body.body.getMotionType(downHit.body.index);\r\n if (landingMotion === PhysicsMotionType.DYNAMIC) {\r\n return -1;\r\n }\r\n const maxSlopeCosEps = 0.1;\r\n const landingNormalDotUp = downHit.normal.dot(upUnit);\r\n if (landingNormalDotUp < Math.max(this.maxSlopeCosine, maxSlopeCosEps)) {\r\n return -1;\r\n }\r\n\r\n // Landing position = downStart - upUnit * (downFrac * downDist - keepDistance)\r\n const landingDrop = downHit.fraction * downDist - this.keepDistance;\r\n const landingPos = TmpVectors.Vector3[0];\r\n upUnit.scaleToRef(-landingDrop, landingPos);\r\n landingPos.addInPlace(fwdEndAdjusted);\r\n\r\n // Thin-wall guard: landing must be measurably higher than where we started.\r\n const landingDelta = TmpVectors.Vector3[1];\r\n landingPos.subtractToRef(this._position, landingDelta);\r\n const heightDelta = landingDelta.dot(upUnit);\r\n if (heightDelta < eps) {\r\n return -1;\r\n }\r\n\r\n // 6. Snapshot manifold, refresh at landing, validate no unacceptable penetration\r\n const savedManifold = this._stepUpSavedManifold;\r\n savedManifold.length = this._manifold.length;\r\n for (let i = 0; i < this._manifold.length; i++) {\r\n savedManifold[i] = this._manifold[i];\r\n }\r\n this._refreshManifoldAtPosition(landingPos);\r\n const maxSlope = Math.max(this.maxSlopeCosine, maxSlopeCosEps);\r\n for (let i = 0; i < this._manifold.length; i++) {\r\n const c = this._manifold[i];\r\n if (c.normal.dot(upUnit) < maxSlope && c.distance < -this.keepDistance) {\r\n // Penetrating a non-walkable surface at landing — reject and restore manifold\r\n this._manifold.length = savedManifold.length;\r\n for (let j = 0; j < savedManifold.length; j++) {\r\n this._manifold[j] = savedManifold[j];\r\n }\r\n return -1;\r\n }\r\n }\r\n\r\n // 7. Commit\r\n const displacement = landingPos.subtract(this._position);\r\n this._lastDisplacement.copyFrom(displacement);\r\n this._position.copyFrom(landingPos);\r\n\r\n return remainingTime * fwdFracAdjusted;\r\n }\r\n\r\n protected _resolveContacts(deltaTime: number, gravity: Vector3) {\r\n const eps = 1e-12;\r\n //<todo object interactions out\r\n for (let i = 0; i < this._manifold.length; i++) {\r\n const contact = this._manifold[i];\r\n const bodyB = this._manifold[i].bodyB;\r\n\r\n //<todo test if bodyB is another character with a proxy body\r\n\r\n // Skip fixed or keyframed bodies as we won't apply impulses to them\r\n if (bodyB.body.getMotionType(bodyB.index) != PhysicsMotionType.DYNAMIC) {\r\n continue;\r\n }\r\n\r\n // Calculate and apply impulse on contacted body\r\n {\r\n //<todo input/output for callbacks\r\n let inputObjectMassInv: number;\r\n let inputObjectImpulse: number;\r\n let outputObjectImpulse = Vector3.Zero();\r\n const outputImpulsePosition = contact.position;\r\n\r\n // Calculate relative normal velocity of the contact point in the contacted body\r\n const pointRelVel = this._tmpVecs[19];\r\n this._getPointVelocityToRef(bodyB, contact.position, pointRelVel);\r\n pointRelVel.subtractInPlace(this._velocity);\r\n const inputProjectedVelocity = pointRelVel.dot(contact.normal);\r\n const dampFactor = 0.9;\r\n\r\n // Change velocity\r\n let deltaVelocity = -inputProjectedVelocity * dampFactor;\r\n\r\n // Apply an extra impulse if the collision is actually penetrating\r\n if (contact.distance < 0) {\r\n const recoveryTau = 0.4;\r\n deltaVelocity += (contact.distance * recoveryTau) / deltaTime;\r\n }\r\n\r\n // Apply impulse if required to keep bodies apart\r\n if (deltaVelocity < 0) {\r\n // Calculate the impulse magnitude\r\n const invInertia = this._getInverseInertiaWorld(bodyB);\r\n const comWorld = this._tmpVecs[15];\r\n this._getComWorldToRef(bodyB, comWorld);\r\n const r = this._tmpVecs[16];\r\n contact.position.subtractToRef(comWorld, r);\r\n const jacAng = this._tmpVecs[17];\r\n Vector3.CrossToRef(r, contact.normal, jacAng);\r\n const rc = this._tmpVecs[18];\r\n Vector3.TransformNormalToRef(jacAng, invInertia, rc);\r\n inputObjectMassInv = rc.dot(jacAng) + this._getInvMass(bodyB);\r\n inputObjectImpulse = deltaVelocity / inputObjectMassInv;\r\n\r\n // Clamp impulse magnitude if required and apply it to the normal direction\r\n const maxPushImpulse = -this.characterStrength * deltaTime;\r\n if (inputObjectImpulse < maxPushImpulse) {\r\n inputObjectImpulse = maxPushImpulse;\r\n }\r\n outputObjectImpulse = contact.normal.scale(inputObjectImpulse);\r\n }\r\n\r\n // Add gravity\r\n {\r\n // Calculate effect of gravity on the velocity of the character in the contact normal direction\r\n let relVelN = contact.normal.dot(gravity.scale(deltaTime));\r\n // If it is a separating contact subtract the separation velocity\r\n if (inputProjectedVelocity < 0) {\r\n relVelN -= inputProjectedVelocity;\r\n }\r\n // If the resulting velocity is negative an impulse is applied to stop the character from falling into\r\n // the contacted body\r\n if (relVelN < -eps) {\r\n outputObjectImpulse.addInPlace(contact.normal.scale(this.characterMass * relVelN));\r\n }\r\n }\r\n\r\n //<todo Fire callback to allow user to change impulse + use the info / play sounds\r\n\r\n const triggerCollisionInfo: ICharacterControllerCollisionEvent = {\r\n collider: bodyB.body,\r\n colliderIndex: bodyB.index,\r\n impulse: outputObjectImpulse,\r\n impulsePosition: outputImpulsePosition,\r\n };\r\n this.onTriggerCollisionObservable.notifyObservers(triggerCollisionInfo);\r\n\r\n bodyB.body.applyImpulse(outputObjectImpulse, outputImpulsePosition, bodyB.index);\r\n }\r\n }\r\n }\r\n\r\n protected _getInverseInertiaWorld(body: { body: PhysicsBody; index: number }): DeepImmutableObject<Matrix> {\r\n const mp = body.body.getMassProperties(body.index);\r\n if (!mp.inertia || !mp.inertiaOrientation) {\r\n return Matrix.IdentityReadOnly;\r\n }\r\n const invOrientation = Matrix.FromQuaternionToRef(mp.inertiaOrientation, TmpVectors.Matrix[0]).invert();\r\n const it = TmpVectors.Matrix[1];\r\n\r\n const ir = invOrientation.getRowToRef(0, TmpVectors.Vector4[0]);\r\n it.setRowFromFloats(0, mp.inertia.x * ir.x, mp.inertia.x * ir.y, mp.inertia.x * ir.z, 0);\r\n invOrientation.getRowToRef(1, ir);\r\n it.setRowFromFloats(0, mp.inertia.y * ir.x, mp.inertia.y * ir.y, mp.inertia.y * ir.z, 0);\r\n invOrientation.getRowToRef(2, ir);\r\n it.setRowFromFloats(0, mp.inertia.z * ir.x, mp.inertia.z * ir.y, mp.inertia.z * ir.z, 0);\r\n invOrientation.multiplyToRef(it, this._tmpMatrix);\r\n return this._tmpMatrix;\r\n }\r\n\r\n protected _getComWorldToRef(body: { body: PhysicsBody; index: number }, result: Vector3) {\r\n const mp = body.body.getMassProperties(body.index);\r\n Vector3.TransformCoordinatesToRef(mp.centerOfMass!, body.body.transformNode.getWorldMatrix(), result);\r\n }\r\n\r\n protected _getInvMass(body: { body: PhysicsBody; index: number }): number {\r\n return 1 / body.body.getMassProperties(body.index).mass!;\r\n }\r\n\r\n protected _integrateManifolds(deltaTime: number, gravity: Vector3): void {\r\n const hk = this._scene.getPhysicsEngine()!.getPhysicsPlugin() as HavokPlugin;\r\n const epsSqrd = 1e-8;\r\n\r\n let newVelocity = Vector3.Zero();\r\n let remainingTime = deltaTime;\r\n // Snapshot of the input velocity, used to preserve user intent if a step-up succeeds\r\n // and the loop exits without running another full solver pass.\r\n const inputVelocity = this._velocity;\r\n let didStepUp = false;\r\n\r\n // Make sure that contact with bodies that have been removed since the call to checkSupport() are removed from the\r\n // manifold\r\n this._validateManifold();\r\n\r\n for (let iter = 0; iter < this.maxCastIterations && remainingTime > 1e-5; iter++) {\r\n this._castWithCollectors(this._position, this._position.add(this._lastDisplacement), this._castCollector, this._startCollector);\r\n const updateResult = this._updateManifold(this._startCollector, this._castCollector, this._lastDisplacement);\r\n\r\n // Create surface constraints from the manifold contacts.\r\n const constraints = this._createConstraintsFromManifold(deltaTime, deltaTime - remainingTime);\r\n const maxSurfaceVelocity = this._tmpVecs[3];\r\n maxSurfaceVelocity.set(this.maxCharacterSpeedForSolver, this.maxCharacterSpeedForSolver, this.maxCharacterSpeedForSolver);\r\n const minDeltaTime = this._velocity.lengthSquared() == 0 ? 0.0 : (0.5 * this.keepDistance) / this._velocity.length();\r\n const solveResults = this._simplexSolverSolve(constraints, this._velocity, remainingTime, minDeltaTime, this.up, maxSurfaceVelocity);\r\n const newDisplacement = solveResults.position;\r\n const solverDeltaTime = solveResults.deltaTime;\r\n newVelocity = solveResults.velocity;\r\n\r\n // Attempt step-up at most once per integrate() call when blocked by a vertical-ish obstacle.\r\n if (!didStepUp && this.maxStepHeight > 0) {\r\n const timeConsumed = this._tryStepUp(remainingTime, inputVelocity, solveResults, constraints);\r\n if (timeConsumed >= 0) {\r\n remainingTime -= timeConsumed;\r\n // Preserve original input velocity so the final `_velocity` reflects user intent\r\n // even if the loop exits without another solver pass.\r\n newVelocity = inputVelocity;\r\n didStepUp = true;\r\n // Skip the normal contact resolution / recast / integrate-position block:\r\n // step-up is a teleport that already updated position, manifold and lastDisplacement.\r\n continue;\r\n }\r\n }\r\n\r\n this._resolveContacts(deltaTime, gravity);\r\n\r\n let newContactIndex = -1;\r\n // todo if (updateResult == hit multiple bodies) ... cast again\r\n\r\n // If castCollector had hits on different bodies (so we're not sure if some non-closest body could be in our way) OR\r\n // the simplex has given an output direction different from the cast guess\r\n // we re-cast to check we can move there. There is no need to get the start points again.\r\n if (updateResult != 0 || (newDisplacement.lengthSquared() > epsSqrd && !this._lastDisplacement.equalsWithEpsilon(newDisplacement, this._displacementEps))) {\r\n this._castWithCollectors(this._position, this._position.add(newDisplacement), this._castCollector, this._startCollector);\r\n const hknp = hk._hknp;\r\n const numCastHits = hknp.HP_QueryCollector_GetNumHits(this._castCollector)[1];\r\n // Find the first contact that isn't already in the manifold\r\n if (numCastHits > 0) {\r\n //<todo sortHits()\r\n for (let i = 0; i < numCastHits; i++) {\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n const [fraction, _hitLocal, hitWorld] = hknp.HP_QueryCollector_GetShapeCastResult(this._castCollector, i)[1];\r\n const newContact = ContactFromCast(hk, hitWorld, newDisplacement, fraction, this.keepDistance);\r\n if (this._findContact(newContact, this._manifold, 0.1) == -1) {\r\n //<todo fireContactAdded\r\n newContactIndex = this._manifold.length;\r\n this._manifold.push(newContact);\r\n //<todo updateTriggersSeen()\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n\r\n if (newContactIndex >= 0) {\r\n const newContact = this._manifold[newContactIndex];\r\n const displacementLengthInv = 1.0 / newDisplacement.length();\r\n const angleBetweenMovementAndSurface = newDisplacement.dot(newContact.normal) * displacementLengthInv;\r\n const keepDistanceAlongMovement = this.keepDistance / -angleBetweenMovementAndSurface;\r\n const distance = newContact.fraction;\r\n let fraction = distance - keepDistanceAlongMovement * displacementLengthInv;\r\n fraction = Math.min(Math.max(fraction, 0.0), 1.0);\r\n\r\n newDisplacement.scaleToRef(fraction, this._tmpVecs[31]);\r\n this._position.addInPlace(this._tmpVecs[31]);\r\n remainingTime -= solverDeltaTime * fraction;\r\n } else {\r\n this._position.addInPlace(newDisplacement);\r\n remainingTime -= solverDeltaTime;\r\n }\r\n this._lastDisplacement.copyFrom(newDisplacement);\r\n }\r\n\r\n this._velocity.copyFrom(newVelocity);\r\n this._transformNode.position.copyFrom(this._position);\r\n }\r\n\r\n /**\r\n * Move the character with collisions\r\n * @param displacement defines the requested displacement vector\r\n */\r\n public moveWithCollisions(displacement: Vector3): void {\r\n if (this._scene.deltaTime == undefined) {\r\n return;\r\n }\r\n const deltaTime = this._scene.deltaTime / 1000.0;\r\n const invDeltaTime = 1 / deltaTime;\r\n\r\n displacement.scaleToRef(1 / deltaTime, this._velocity);\r\n this._lastDisplacement.copyFrom(displacement);\r\n\r\n this._lastVelocity.copyFrom(this._velocity);\r\n this._lastInvDeltaTime = invDeltaTime;\r\n\r\n this._integrateManifolds(deltaTime, Vector3.ZeroReadOnly);\r\n }\r\n\r\n /**\r\n * Update internal state. Must be called once per frame\r\n * @param deltaTime frame delta time in seconds. When using scene.deltaTime divide by 1000.0\r\n * @param surfaceInfo surface information returned by checkSupport\r\n * @param gravity gravity applied to the character. Can be different that world gravity\r\n */\r\n public integrate(deltaTime: number, surfaceInfo: CharacterSurfaceInfo, gravity: Vector3) {\r\n const invDeltaTime = 1 / deltaTime;\r\n const remainingTime = deltaTime;\r\n\r\n // Choose the first cast direction. If velocity hasn't changed from the previous integrate, guess that the\r\n // displacement will be the same as last integrate, scaled by relative step length. Otherwise, guess based\r\n // on current velocity.\r\n {\r\n const tolerance = this._displacementEps * invDeltaTime;\r\n if (this._velocity.equalsWithEpsilon(this._lastVelocity, tolerance)) {\r\n this._lastDisplacement.scaleInPlace(remainingTime * this._lastInvDeltaTime);\r\n } else {\r\n const displacementVelocity = this._velocity;\r\n if (surfaceInfo.supportedState == CharacterSupportedState.SUPPORTED) {\r\n const relativeVelocity = this._tmpVecs[28];\r\n this._velocity.subtractToRef(surfaceInfo.averageSurfaceVelocity, relativeVelocity);\r\n const normalDotVelocity = surfaceInfo.averageSurfaceNormal.dot(relativeVelocity);\r\n if (normalDotVelocity < 0) {\r\n relativeVelocity.subtractInPlace(surfaceInfo.averageSurfaceNormal.scale(normalDotVelocity));\r\n displacementVelocity.copyFrom(relativeVelocity);\r\n displacementVelocity.addInPlace(surfaceInfo.averageSurfaceVelocity);\r\n }\r\n }\r\n this._lastDisplacement.copyFrom(displacementVelocity);\r\n this._lastDisplacement.scaleInPlace(remainingTime);\r\n }\r\n this._lastVelocity.copyFrom(this._velocity);\r\n this._lastInvDeltaTime = invDeltaTime;\r\n }\r\n\r\n this._integrateManifolds(deltaTime, gravity);\r\n }\r\n\r\n /**\r\n * Helper function to calculate velocity based on surface informations and current velocity state and target\r\n * @param deltaTime frame delta time in seconds. When using scene.deltaTime divide by 1000.0\r\n * @param forwardWorld character forward in world coordinates\r\n * @param surfaceNormal surface normal direction\r\n * @param currentVelocity current velocity\r\n * @param surfaceVelocity velocity induced by the surface\r\n * @param desiredVelocity desired character velocity\r\n * @param upWorld up vector in world space\r\n * @param result resulting velocity vector\r\n * @returns boolean true if result has been computed\r\n */\r\n public calculateMovementToRef(\r\n deltaTime: number,\r\n forwardWorld: Vector3,\r\n surfaceNormal: Vector3,\r\n currentVelocity: Vector3,\r\n surfaceVelocity: Vector3,\r\n desiredVelocity: Vector3,\r\n upWorld: Vector3,\r\n result: Vector3\r\n ): boolean {\r\n const eps = 1e-5;\r\n let binorm = forwardWorld.cross(upWorld);\r\n if (binorm.lengthSquared() < eps) {\r\n return false;\r\n }\r\n binorm.normalize();\r\n const tangent = binorm.cross(surfaceNormal);\r\n tangent.normalize();\r\n binorm = tangent.cross(surfaceNormal);\r\n binorm.normalize();\r\n\r\n const surfaceFrame = Matrix.FromValues(\r\n tangent.x,\r\n tangent.y,\r\n tangent.z,\r\n 0,\r\n binorm.x,\r\n binorm.y,\r\n binorm.z,\r\n 0,\r\n surfaceNormal.x,\r\n surfaceNormal.y,\r\n surfaceNormal.z,\r\n 0,\r\n 0,\r\n 0,\r\n 0,\r\n 1\r\n );\r\n const invSurfaceFrame = surfaceFrame.clone().invert();\r\n\r\n currentVelocity.subtractToRef(surfaceVelocity, this._tmpVecs[29]);\r\n const relative = this._tmpVecs[30];\r\n Vector3.TransformNormalToRef(this._tmpVecs[29], invSurfaceFrame, relative);\r\n\r\n const sideVec = upWorld.cross(forwardWorld);\r\n const fwd = desiredVelocity.dot(forwardWorld);\r\n const side = desiredVelocity.dot(sideVec);\r\n const len = desiredVelocity.length();\r\n\r\n const desiredVelocitySF = this._tmpVecs[4];\r\n desiredVelocitySF.set(-fwd, side, 0);\r\n desiredVelocitySF.normalize();\r\n desiredVelocitySF.scaleInPlace(len);\r\n const diff = this._tmpVecs[5];\r\n desiredVelocitySF.subtractToRef(relative, diff);\r\n\r\n // Clamp it by maxAcceleration and limit it by gain.\r\n {\r\n const lenSq = diff.lengthSquared();\r\n const maxVelocityDelta = this.maxAcceleration * deltaTime;\r\n let tmp: number;\r\n if (lenSq * this.acceleration * this.acceleration > maxVelocityDelta * maxVelocityDelta) {\r\n tmp = maxVelocityDelta / Math.sqrt(lenSq);\r\n } else {\r\n tmp = this.acceleration;\r\n }\r\n diff.scaleInPlace(tmp);\r\n }\r\n\r\n relative.addInPlace(diff);\r\n\r\n // Transform back to world space and apply\r\n Vector3.TransformNormalToRef(relative, surfaceFrame, result);\r\n\r\n // Add back in the surface velocity\r\n result.addInPlace(surfaceVelocity);\r\n return true;\r\n }\r\n\r\n /**\r\n * Helper function to calculate velocity based on surface informations and current velocity state and target\r\n * @param deltaTime frame delta time in seconds. When using scene.deltaTime divide by 1000.0\r\n * @param forwardWorld character forward in world coordinates\r\n * @param surfaceNormal surface normal direction\r\n * @param currentVelocity current velocity\r\n * @param surfaceVelocity velocity induced by the surface\r\n * @param desiredVelocity desired character velocity\r\n * @param upWorld up vector in world space\r\n * @returns a new velocity vector\r\n */\r\n public calculateMovement(\r\n deltaTime: number,\r\n forwardWorld: Vector3,\r\n surfaceNormal: Vector3,\r\n currentVelocity: Vector3,\r\n surfaceVelocity: Vector3,\r\n desiredVelocity: Vector3,\r\n upWorld: Vector3\r\n ): Vector3 {\r\n const result = new Vector3(0, 0, 0);\r\n this.calculateMovementToRef(deltaTime, forwardWorld, surfaceNormal, currentVelocity, surfaceVelocity, desiredVelocity, upWorld, result);\r\n return result;\r\n }\r\n}\r\n"]}