@babylonjs/core 6.2.0 → 6.3.0
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.
- package/Engines/WebGPU/webgpuHardwareTexture.js +1 -1
- package/Engines/WebGPU/webgpuHardwareTexture.js.map +1 -1
- package/Engines/thinEngine.js +21 -4
- package/Engines/thinEngine.js.map +1 -1
- package/Engines/webgpuEngine.js +1 -6
- package/Engines/webgpuEngine.js.map +1 -1
- package/Gizmos/gizmo.js +1 -0
- package/Gizmos/gizmo.js.map +1 -1
- package/Materials/Node/Blocks/PBR/refractionBlock.js +2 -2
- package/Materials/Node/Blocks/PBR/refractionBlock.js.map +1 -1
- package/Materials/Node/Blocks/triPlanarBlock.d.ts +4 -0
- package/Materials/Node/Blocks/triPlanarBlock.js +44 -6
- package/Materials/Node/Blocks/triPlanarBlock.js.map +1 -1
- package/Materials/PBR/pbrMaterial.d.ts +2 -1
- package/Materials/PBR/pbrMaterial.js +3 -2
- package/Materials/PBR/pbrMaterial.js.map +1 -1
- package/Materials/PBR/pbrSubSurfaceConfiguration.js +2 -2
- package/Materials/PBR/pbrSubSurfaceConfiguration.js.map +1 -1
- package/Materials/Textures/baseTexture.d.ts +6 -0
- package/Materials/Textures/baseTexture.js +8 -0
- package/Materials/Textures/baseTexture.js.map +1 -1
- package/Materials/Textures/cubeTexture.d.ts +7 -0
- package/Materials/Textures/cubeTexture.js +25 -2
- package/Materials/Textures/cubeTexture.js.map +1 -1
- package/Materials/standardMaterial.d.ts +2 -1
- package/Materials/standardMaterial.js +3 -2
- package/Materials/standardMaterial.js.map +1 -1
- package/Misc/HighDynamicRange/cubemapToSphericalPolynomial.d.ts +4 -0
- package/Misc/HighDynamicRange/cubemapToSphericalPolynomial.js +19 -4
- package/Misc/HighDynamicRange/cubemapToSphericalPolynomial.js.map +1 -1
- package/Misc/decorators.d.ts +5 -1
- package/Misc/decorators.js +12 -4
- package/Misc/decorators.js.map +1 -1
- package/Misc/error.d.ts +1 -1
- package/Misc/error.js.map +1 -1
- package/Misc/tools.d.ts +6 -6
- package/Misc/tools.js +17 -14
- package/Misc/tools.js.map +1 -1
- package/Physics/physicsRaycastResult.js +6 -6
- package/Physics/physicsRaycastResult.js.map +1 -1
- package/Physics/v2/IPhysicsEnginePlugin.d.ts +2 -0
- package/Physics/v2/IPhysicsEnginePlugin.js.map +1 -1
- package/Physics/v2/Plugins/havokPlugin.d.ts +16 -1
- package/Physics/v2/Plugins/havokPlugin.js +43 -3
- package/Physics/v2/Plugins/havokPlugin.js.map +1 -1
- package/Physics/v2/physicsAggregate.d.ts +0 -50
- package/Physics/v2/physicsAggregate.js +3 -2
- package/Physics/v2/physicsAggregate.js.map +1 -1
- package/Physics/v2/physicsBody.d.ts +12 -0
- package/Physics/v2/physicsBody.js +17 -1
- package/Physics/v2/physicsBody.js.map +1 -1
- package/assetContainer.d.ts +2 -3
- package/assetContainer.js +13 -4
- package/assetContainer.js.map +1 -1
- package/node.d.ts +8 -0
- package/node.js +23 -1
- package/node.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"havokPlugin.js","sourceRoot":"","sources":["../../../../../../lts/core/generated/Physics/v2/Plugins/havokPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACrF,OAAO,EACH,gBAAgB,EAChB,qBAAqB,EACrB,iBAAiB,EACjB,0BAA0B,EAC1B,qBAAqB,EACrB,8BAA8B,GACjC,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAK9C,OAAO,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAEhE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAI/C,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAE5C,OAAO,EAAE,YA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AC,KAAK,CAAC,uBAAuB,CAAC,IAAI;gBACxC,OAAO,8BAA8B,CAAC,IAAI,CAAC;YAC/C,KAAK,IAAI,CAAC,KAAK,CAAC,uBAAuB,CAAC,OAAO;gBAC3C,OAAO,8BAA8B,CAAC,OAAO,CAAC;YAClD,KAAK,IAAI,CAAC,KAAK,CAAC,uBAAuB,CAAC,MAAM;gBAC1C,OAAO,8BAA8B,CAAC,MAAM,CAAC;SACpD;QAED,OAAO,8BAA8B,CAAC,IAAI,CAAC;IAC/C,CAAC;IAEO,kBAAkB,CAAC,IAAoC;QAC3D,QAAQ,IAAI,EAAE;YACV,KAAK,8BAA8B,CAAC,IAAI;gBACpC,OAAO,IAAI,CAAC,KAAK,CAAC,uBAAuB,CAAC,IAAI,CAAC;YACnD,KAAK,8BAA8B,CAAC,OAAO;gBACvC,OAAO,IAAI,CAAC,KAAK,CAAC,uBAAuB,CAAC,OAAO,CAAC;YACtD,KAAK,8BAA8B,CAAC,MAAM;gBACtC,OAAO,IAAI,CAAC,KAAK,CAAC,uBAAuB,CAAC,MAAM,CAAC;SACxD;IACL,CAAC;CACJ","sourcesContent":["import { Matrix, Quaternion, TmpVectors, Vector3 } from \"../../../Maths/math.vector\";\r\nimport {\r\n PhysicsShapeType,\r\n PhysicsConstraintType,\r\n PhysicsMotionType,\r\n PhysicsConstraintMotorType,\r\n PhysicsConstraintAxis,\r\n PhysicsConstraintAxisLimitMode,\r\n} from \"../IPhysicsEnginePlugin\";\r\nimport type { PhysicsShapeParameters, IPhysicsEnginePluginV2, PhysicsMassProperties, IPhysicsCollisionEvent } from \"../IPhysicsEnginePlugin\";\r\nimport { Logger } from \"../../../Misc/logger\";\r\nimport type { PhysicsBody } from \"../physicsBody\";\r\nimport type { PhysicsConstraint, Physics6DoFConstraint } from \"../physicsConstraint\";\r\n\r\nimport type { PhysicsMaterial } from \"../physicsMaterial\";\r\nimport { PhysicsMaterialCombineMode } from \"../physicsMaterial\";\r\n\r\nimport { PhysicsShape } from \"../physicsShape\";\r\nimport type { BoundingBox } from \"../../../Culling/boundingBox\";\r\nimport type { TransformNode } from \"../../../Meshes/transformNode\";\r\nimport type { PhysicsRaycastResult } from \"../../physicsRaycastResult\";\r\nimport { Mesh } from \"../../../Meshes/mesh\";\r\nimport type { Scene } from \"../../../scene\";\r\nimport { VertexBuffer } from \"../../../Buffers/buffer\";\r\nimport { ArrayTools } from \"../../../Misc/arrayTools\";\r\nimport { Observable } from \"../../../Misc/observable\";\r\nimport type { Nullable } from \"../../../types\";\r\ndeclare let HK: any;\r\n\r\nclass MeshAccumulator {\r\n /**\r\n * Constructor of the mesh accumulator\r\n * @param mesh - The mesh used to compute the world matrix.\r\n * @param collectIndices - use mesh indices\r\n * @param scene - The scene used to determine the right handed system.\r\n *\r\n * Merge mesh and its children so whole hierarchy can be used as a mesh shape or convex hull\r\n */\r\n public constructor(mesh: Mesh, collectIndices: boolean, scene: Scene) {\r\n const worldFromRoot = mesh.computeWorldMatrix(true);\r\n const rootScale = new Vector3();\r\n const rootOrientation = new Quaternion();\r\n const rootTranslation = new Vector3();\r\n worldFromRoot.decompose(rootScale, rootOrientation, rootTranslation);\r\n\r\n this._bodyFromWorld = Matrix.Compose(Vector3.One(), mesh.rotationQuaternion ? mesh.rotationQuaternion : Quaternion.Identity(), mesh.position);\r\n this._bodyFromWorld = this._bodyFromWorld.invert();\r\n this._isRightHanded = scene.useRightHandedSystem;\r\n this._collectIndices = collectIndices;\r\n }\r\n\r\n /**\r\n * Adds a mesh to the physics engine.\r\n * @param mesh The mesh to add.\r\n * @param includeChildren Whether to include the children of the mesh.\r\n *\r\n * This method adds a mesh to the physics engine by computing the world matrix,\r\n * multiplying it with the body from world matrix, and then transforming the\r\n * coordinates of the mesh's vertices. It also adds the indices of the mesh\r\n * to the physics engine. If includeChildren is true, it will also add the\r\n * children of the mesh to the physics engine, ignoring any children which\r\n * have a physics impostor. This is useful for creating a physics engine\r\n * that accurately reflects the mesh and its children.\r\n */\r\n public addMesh(mesh: Mesh, includeChildren: boolean): void {\r\n const indexOffset = this._vertices.length;\r\n const worldFromShape = mesh.computeWorldMatrix(true);\r\n const shapeFromBody = worldFromShape.multiply(this._bodyFromWorld);\r\n\r\n const vertexData = mesh.getVerticesData(VertexBuffer.PositionKind) || [];\r\n const numVerts = vertexData.length / 3;\r\n for (let v = 0; v < numVerts; v++) {\r\n const pos = new Vector3(vertexData[v * 3 + 0], vertexData[v * 3 + 1], vertexData[v * 3 + 2]);\r\n this._vertices.push(Vector3.TransformCoordinates(pos, shapeFromBody));\r\n }\r\n\r\n if (this._collectIndices) {\r\n const meshIndices = mesh.getIndices();\r\n if (meshIndices) {\r\n for (let i = 0; i < meshIndices.length; i += 3) {\r\n // Havok wants the correct triangle winding to enable the interior triangle optimization\r\n if (this._isRightHanded) {\r\n this._indices.push(meshIndices[i + 0] + indexOffset);\r\n this._indices.push(meshIndices[i + 1] + indexOffset);\r\n this._indices.push(meshIndices[i + 2] + indexOffset);\r\n } else {\r\n this._indices.push(meshIndices[i + 2] + indexOffset);\r\n this._indices.push(meshIndices[i + 1] + indexOffset);\r\n this._indices.push(meshIndices[i + 0] + indexOffset);\r\n }\r\n }\r\n }\r\n }\r\n\r\n if (includeChildren) {\r\n const children = mesh.getChildMeshes(false);\r\n // Ignore any children which have a physics body.\r\n // Other plugin implementations do not have this check, which appears to be\r\n // a bug, as otherwise, the mesh will have a duplicate collider\r\n children.filter((m: any) => !m.physicsBody).forEach((m: any) => this.addMesh(m, includeChildren));\r\n }\r\n }\r\n\r\n /**\r\n * Allocate and populate the vertex positions inside the physics plugin.\r\n *\r\n * @returns An array of floats, whose backing memory is inside the plugin. The array contains the\r\n * positions of the mesh vertices, where a position is defined by three floats. You must call\r\n * freeBuffer() on the returned array once you have finished with it, in order to free the\r\n * memory inside the plugin..\r\n */\r\n public getVertices(plugin: any): Float32Array {\r\n const nFloats = this._vertices.length * 3;\r\n const bytesPerFloat = 4;\r\n const nBytes = nFloats * bytesPerFloat;\r\n const bufferBegin = plugin._malloc(nBytes);\r\n\r\n const ret = new Float32Array(plugin.HEAPU8.buffer, bufferBegin, nFloats);\r\n for (let i = 0; i < this._vertices.length; i++) {\r\n ret[i * 3 + 0] = this._vertices[i].x;\r\n ret[i * 3 + 1] = this._vertices[i].y;\r\n ret[i * 3 + 2] = this._vertices[i].z;\r\n }\r\n\r\n return ret;\r\n }\r\n\r\n public freeBuffer(plugin: any, arr: Float32Array | Int32Array) {\r\n plugin._free(arr.byteOffset);\r\n }\r\n\r\n /**\r\n * Allocate and populate the triangle indices inside the physics plugin\r\n *\r\n * @returns A new Int32Array, whose backing memory is inside the plugin. The array contains the indices\r\n * of the triangle positions, where a single triangle is defined by three indices. You must call\r\n * freeBuffer() on this array once you have finished with it, to free the memory inside the plugin..\r\n */\r\n public getTriangles(plugin: any): Int32Array {\r\n const bytesPerInt = 4;\r\n const nBytes = this._indices.length * bytesPerInt;\r\n const bufferBegin = plugin._malloc(nBytes);\r\n const ret = new Int32Array(plugin.HEAPU8.buffer, bufferBegin, this._indices.length);\r\n for (let i = 0; i < this._indices.length; i++) {\r\n ret[i] = this._indices[i];\r\n }\r\n\r\n return ret;\r\n }\r\n\r\n private _isRightHanded: boolean;\r\n private _collectIndices: boolean;\r\n private _vertices: Vector3[] = []; /// Vertices in body space\r\n private _indices: number[] = [];\r\n private _bodyFromWorld: Matrix;\r\n}\r\n\r\nclass BodyPluginData {\r\n public constructor(bodyId: any) {\r\n this.hpBodyId = bodyId;\r\n this.userMassProps = { centerOfMass: undefined, mass: undefined, inertia: undefined, inertiaOrientation: undefined };\r\n }\r\n\r\n public hpBodyId: any;\r\n\r\n public worldTransformOffset: number;\r\n\r\n public userMassProps: PhysicsMassProperties;\r\n}\r\n\r\n/*\r\nclass ShapePath\r\n{\r\n public colliderId: number;\r\n public pathData: number;\r\n}\r\n*/\r\n\r\nclass ContactPoint {\r\n public bodyId: bigint = BigInt(0); //0,2\r\n //public colliderId: number = 0; //2,4\r\n //public shapePath: ShapePath = new ShapePath(); //4,8\r\n public position: Vector3 = new Vector3(); //8,11\r\n public normal: Vector3 = new Vector3(); //11,14\r\n //public triIdx: number = 0; //14,15\r\n}\r\n\r\nclass CollisionEvent {\r\n //public eventType: number = 0; //0,1\r\n public contactOnA: ContactPoint = new ContactPoint(); //1\r\n public contactOnB: ContactPoint = new ContactPoint();\r\n public impulseApplied: number = 0;\r\n\r\n static readToRef(buffer: any, offset: number, eventOut: CollisionEvent) {\r\n const intBuf = new Int32Array(buffer, offset);\r\n const floatBuf = new Float32Array(buffer, offset);\r\n const offA = 2;\r\n eventOut.contactOnA.bodyId = BigInt(intBuf[offA]); //<todo Need to get the high+low words!\r\n eventOut.contactOnA.position.set(floatBuf[offA + 8], floatBuf[offA + 9], floatBuf[offA + 10]);\r\n eventOut.contactOnA.normal.set(floatBuf[offA + 11], floatBuf[offA + 12], floatBuf[offA + 13]);\r\n const offB = 18;\r\n eventOut.contactOnB.bodyId = BigInt(intBuf[offB]);\r\n eventOut.contactOnB.position.set(floatBuf[offB + 8], floatBuf[offB + 9], floatBuf[offB + 10]);\r\n eventOut.contactOnB.normal.set(floatBuf[offB + 11], floatBuf[offB + 12], floatBuf[offB + 13]);\r\n eventOut.impulseApplied = floatBuf[offB + 13 + 2];\r\n }\r\n}\r\n\r\n/**\r\n * The Havok Physics plugin\r\n */\r\nexport class HavokPlugin implements IPhysicsEnginePluginV2 {\r\n /**\r\n * Reference to the WASM library\r\n */\r\n public _hknp: any = {};\r\n /**\r\n * Created Havok world which physics bodies are added to\r\n */\r\n public world: any;\r\n /**\r\n * Name of the plugin\r\n */\r\n public name: string = \"HavokPlugin\";\r\n /**\r\n * We only have a single raycast in-flight right now\r\n */\r\n private _queryCollector: bigint;\r\n private _fixedTimeStep: number = 1 / 60;\r\n private _timeStep: number = 1 / 60;\r\n private _tmpVec3 = ArrayTools.BuildArray(3, Vector3.Zero);\r\n private _bodies = new Map<bigint, { body: PhysicsBody; index: number }>();\r\n private _bodyBuffer: number;\r\n private _bodyCollisionObservable = new Map<bigint, Observable<IPhysicsCollisionEvent>>();\r\n /**\r\n *\r\n */\r\n public onCollisionObservable = new Observable<IPhysicsCollisionEvent>();\r\n\r\n public constructor(private _useDeltaForWorldStep: boolean = true, hpInjection: any = HK) {\r\n if (typeof hpInjection === \"function\") {\r\n Logger.Error(\"Havok is not ready. Please make sure you await HK() before using the plugin.\");\r\n return;\r\n } else {\r\n this._hknp = hpInjection;\r\n }\r\n\r\n if (!this.isSupported()) {\r\n Logger.Error(\"Havok is not available. Please make sure you included the js file.\");\r\n return;\r\n }\r\n this.world = this._hknp.HP_World_Create()[1];\r\n this._queryCollector = this._hknp.HP_QueryCollector_Create(1)[1];\r\n }\r\n /**\r\n * If this plugin is supported\r\n * @returns true if its supported\r\n */\r\n public isSupported(): boolean {\r\n return this._hknp !== undefined;\r\n }\r\n\r\n /**\r\n * Sets the gravity of the physics world.\r\n *\r\n * @param gravity - The gravity vector to set.\r\n *\r\n */\r\n public setGravity(gravity: Vector3): void {\r\n this._hknp.HP_World_SetGravity(this.world, this._bVecToV3(gravity));\r\n }\r\n\r\n /**\r\n * Sets the fixed time step for the physics engine.\r\n *\r\n * @param timeStep - The fixed time step to use for the physics engine.\r\n *\r\n */\r\n public setTimeStep(timeStep: number): void {\r\n this._fixedTimeStep = timeStep;\r\n }\r\n\r\n /**\r\n * Gets the fixed time step used by the physics engine.\r\n *\r\n * @returns The fixed time step used by the physics engine.\r\n *\r\n */\r\n public getTimeStep(): number {\r\n return this._fixedTimeStep;\r\n }\r\n\r\n /**\r\n * Executes a single step of the physics engine.\r\n *\r\n * @param delta The time delta in seconds since the last step.\r\n * @param physicsBodies An array of physics bodies to be simulated.\r\n * @returns void\r\n *\r\n * This method is useful for simulating the physics engine. It sets the physics body transformation,\r\n * steps the world, syncs the physics body, and notifies collisions. This allows for the physics engine\r\n * to accurately simulate the physics bodies in the world.\r\n */\r\n public executeStep(delta: number, physicsBodies: Array<PhysicsBody>): void {\r\n for (const physicsBody of physicsBodies) {\r\n if (physicsBody.disablePreStep) {\r\n continue;\r\n }\r\n this.setPhysicsBodyTransformation(physicsBody, physicsBody.transformNode);\r\n }\r\n\r\n this._hknp.HP_World_Step(this.world, this._useDeltaForWorldStep ? delta : this._timeStep);\r\n\r\n this._bodyBuffer = this._hknp.HP_World_GetBodyBuffer(this.world)[1];\r\n for (const physicsBody of physicsBodies) {\r\n this.sync(physicsBody);\r\n }\r\n\r\n this._notifyCollisions();\r\n }\r\n\r\n /**\r\n * Returns the version of the physics engine plugin.\r\n *\r\n * @returns The version of the physics engine plugin.\r\n *\r\n * This method is useful for determining the version of the physics engine plugin that is currently running.\r\n */\r\n public getPluginVersion(): number {\r\n return 2;\r\n }\r\n\r\n /**\r\n * Initializes a physics body with the given position and orientation.\r\n *\r\n * @param body - The physics body to initialize.\r\n * @param position - The position of the body.\r\n * @param orientation - The orientation of the body.\r\n * This code is useful for initializing a physics body with the given position and orientation.\r\n * It creates a plugin data for the body and adds it to the world. It then converts the position\r\n * and orientation to a transform and sets the body's transform to the given values.\r\n */\r\n public initBody(body: PhysicsBody, motionType: PhysicsMotionType, position: Vector3, orientation: Quaternion): void {\r\n body._pluginData = new BodyPluginData(this._hknp.HP_Body_Create()[1]);\r\n\r\n this._internalSetMotionType(body._pluginData, motionType);\r\n const transform = [this._bVecToV3(position), this._bQuatToV4(orientation)]; //<todo temp transform?\r\n this._hknp.HP_Body_SetQTransform(body._pluginData.hpBodyId, transform);\r\n\r\n this._hknp.HP_World_AddBody(this.world, body._pluginData.hpBodyId, body.startAsleep);\r\n this._bodies.set(body._pluginData.hpBodyId[0], { body: body, index: 0 });\r\n }\r\n\r\n /**\r\n * Removes a body from the world. To dispose of a body, it is necessary to remove it from the world first.\r\n *\r\n * @param body - The body to remove.\r\n */\r\n public removeBody(body: PhysicsBody): void {\r\n if (body._pluginDataInstances && body._pluginDataInstances.length > 0) {\r\n for (const instance of body._pluginDataInstances) {\r\n this._bodyCollisionObservable.delete(instance.hpBodyId[0]);\r\n this._hknp.HP_World_RemoveBody(this.world, instance.hpBodyId);\r\n }\r\n }\r\n if (body._pluginData) {\r\n this._bodyCollisionObservable.delete(body._pluginData.hpBodyId[0]);\r\n this._hknp.HP_World_RemoveBody(this.world, body._pluginData.hpBodyId);\r\n }\r\n }\r\n\r\n /**\r\n * Initializes the body instances for a given physics body and mesh.\r\n *\r\n * @param body - The physics body to initialize.\r\n * @param motionType - How the body will be handled by the engine\r\n * @param mesh - The mesh to initialize.\r\n *\r\n * This code is useful for creating a physics body from a mesh. It creates a\r\n * body instance for each instance of the mesh and adds it to the world. It also\r\n * sets the position of the body instance to the position of the mesh instance.\r\n * This allows for the physics engine to accurately simulate the mesh in the\r\n * world.\r\n */\r\n public initBodyInstances(body: PhysicsBody, motionType: PhysicsMotionType, mesh: Mesh): void {\r\n const instancesCount = mesh._thinInstanceDataStorage?.instancesCount ?? 0;\r\n const matrixData = mesh._thinInstanceDataStorage.matrixData;\r\n if (!matrixData) {\r\n return; // TODO: error handling\r\n }\r\n this._createOrUpdateBodyInstances(body, motionType, matrixData, 0, instancesCount, false);\r\n body._pluginDataInstances.forEach((bodyId, index) => {\r\n this._bodies.set(bodyId.hpBodyId[0], { body: body, index: index });\r\n });\r\n }\r\n\r\n private _createOrUpdateBodyInstances(body: PhysicsBody, motionType: PhysicsMotionType, matrixData: Float32Array, startIndex: number, endIndex: number, update: boolean): void {\r\n const rotation = TmpVectors.Quaternion[0];\r\n const rotationMatrix = Matrix.Identity();\r\n for (let i = startIndex; i < endIndex; i++) {\r\n const position = [matrixData[i * 16 + 12], matrixData[i * 16 + 13], matrixData[i * 16 + 14]];\r\n let hkbody;\r\n if (!update) {\r\n hkbody = this._hknp.HP_Body_Create()[1];\r\n } else {\r\n hkbody = body._pluginDataInstances[i].hpBodyId;\r\n }\r\n rotationMatrix.setRowFromFloats(0, matrixData[i * 16 + 0], matrixData[i * 16 + 1], matrixData[i * 16 + 2], 0);\r\n rotationMatrix.setRowFromFloats(1, matrixData[i * 16 + 4], matrixData[i * 16 + 5], matrixData[i * 16 + 6], 0);\r\n rotationMatrix.setRowFromFloats(2, matrixData[i * 16 + 8], matrixData[i * 16 + 9], matrixData[i * 16 + 10], 0);\r\n Quaternion.FromRotationMatrixToRef(rotationMatrix, rotation);\r\n const transform = [position, [rotation.x, rotation.y, rotation.z, rotation.w]];\r\n this._hknp.HP_Body_SetQTransform(hkbody, transform);\r\n if (!update) {\r\n const pluginData = new BodyPluginData(hkbody);\r\n if (body._pluginDataInstances.length) {\r\n // If an instance already exists, copy any user-provided mass properties\r\n pluginData.userMassProps = body._pluginDataInstances[0].userMassProps;\r\n }\r\n this._internalSetMotionType(pluginData, motionType);\r\n this._internalUpdateMassProperties(pluginData);\r\n body._pluginDataInstances.push(pluginData);\r\n this._hknp.HP_World_AddBody(this.world, hkbody, body.startAsleep);\r\n pluginData.worldTransformOffset = this._hknp.HP_Body_GetWorldTransformOffset(hkbody)[1];\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Update the internal body instances for a given physics body to match the instances in a mesh.\r\n * @param body the body that will be updated\r\n * @param mesh the mesh with reference instances\r\n */\r\n public updateBodyInstances(body: PhysicsBody, mesh: Mesh): void {\r\n const instancesCount = mesh._thinInstanceDataStorage?.instancesCount ?? 0;\r\n const matrixData = mesh._thinInstanceDataStorage.matrixData;\r\n if (!matrixData) {\r\n return; // TODO: error handling\r\n }\r\n const pluginInstancesCount = body._pluginDataInstances.length;\r\n const motionType = this.getMotionType(body);\r\n\r\n if (instancesCount > pluginInstancesCount) {\r\n this._createOrUpdateBodyInstances(body, motionType, matrixData, pluginInstancesCount, instancesCount, false);\r\n const firstBodyShape = this._hknp.HP_Body_GetShape(body._pluginDataInstances[0].hpBodyId)[1];\r\n for (let i = pluginInstancesCount; i < instancesCount; i++) {\r\n this._hknp.HP_Body_SetShape(body._pluginDataInstances[i].hpBodyId, firstBodyShape);\r\n this._internalUpdateMassProperties(body._pluginDataInstances[i]);\r\n this._bodies.set(body._pluginDataInstances[i].hpBodyId[0], { body: body, index: i });\r\n }\r\n } else if (instancesCount < pluginInstancesCount) {\r\n const instancesToRemove = pluginInstancesCount - instancesCount;\r\n for (let i = 0; i < instancesToRemove; i++) {\r\n const hkbody = body._pluginDataInstances.pop();\r\n this._bodies.delete(hkbody.hpBodyId[0]);\r\n this._hknp.HP_World_RemoveBody(this.world, hkbody.hpBodyId);\r\n this._hknp.HP_Body_Release(hkbody.hpBodyId);\r\n }\r\n this._createOrUpdateBodyInstances(body, motionType, matrixData, 0, instancesCount, true);\r\n }\r\n }\r\n\r\n /**\r\n * Synchronizes the transform of a physics body with its transform node.\r\n * @param body - The physics body to synchronize.\r\n *\r\n * This function is useful for keeping the physics body's transform in sync with its transform node.\r\n * This is important for ensuring that the physics body is accurately represented in the physics engine.\r\n */\r\n sync(body: PhysicsBody): void {\r\n this.syncTransform(body, body.transformNode);\r\n }\r\n\r\n /**\r\n * Synchronizes the transform of a physics body with the transform of its\r\n * corresponding transform node.\r\n *\r\n * @param body - The physics body to synchronize.\r\n * @param transformNode - The destination Transform Node.\r\n *\r\n * This code is useful for synchronizing the position and orientation of a\r\n * physics body with the position and orientation of its corresponding\r\n * transform node. This is important for ensuring that the physics body and\r\n * the transform node are in the same position and orientation in the scene.\r\n * This is necessary for the physics engine to accurately simulate the\r\n * physical behavior of the body.\r\n */\r\n syncTransform(body: PhysicsBody, transformNode: TransformNode): void {\r\n if (body._pluginDataInstances.length) {\r\n // instances\r\n const m = transformNode as Mesh;\r\n const matrixData = m._thinInstanceDataStorage.matrixData;\r\n if (!matrixData) {\r\n return; // TODO: error handling\r\n }\r\n const instancesCount = body._pluginDataInstances.length;\r\n for (let i = 0; i < instancesCount; i++) {\r\n const bufOffset = body._pluginDataInstances[i].worldTransformOffset;\r\n const transformBuffer = new Float32Array(this._hknp.HEAPU8.buffer, this._bodyBuffer + bufOffset, 16);\r\n const index = i * 16;\r\n\r\n for (let mi = 0; mi < 15; mi++) {\r\n if ((mi & 3) != 3) {\r\n matrixData[index + mi] = transformBuffer[mi];\r\n }\r\n }\r\n matrixData[index + 15] = 1;\r\n }\r\n m.thinInstanceBufferUpdated(\"matrix\");\r\n } else {\r\n try {\r\n // regular\r\n const bodyTransform = this._hknp.HP_Body_GetQTransform(body._pluginData.hpBodyId)[1];\r\n const bodyTranslation = bodyTransform[0];\r\n const bodyOrientation = bodyTransform[1];\r\n const quat = TmpVectors.Quaternion[0];\r\n transformNode.position.set(bodyTranslation[0], bodyTranslation[1], bodyTranslation[2]);\r\n quat.set(bodyOrientation[0], bodyOrientation[1], bodyOrientation[2], bodyOrientation[3]);\r\n if (transformNode.rotationQuaternion) {\r\n transformNode.rotationQuaternion.copyFrom(quat);\r\n } else {\r\n quat.toEulerAnglesToRef(transformNode.rotation);\r\n }\r\n } catch (e) {\r\n console.log(`Syncing transform failed for node ${transformNode.name}: ${e.message}...`);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Sets the shape of a physics body.\r\n * @param body - The physics body to set the shape for.\r\n * @param shape - The physics shape to set.\r\n *\r\n * This function is used to set the shape of a physics body. It is useful for\r\n * creating a physics body with a specific shape, such as a box or a sphere,\r\n * which can then be used to simulate physical interactions in a physics engine.\r\n * This function is especially useful for meshes with multiple instances, as it\r\n * will set the shape for each instance of the mesh.\r\n */\r\n public setShape(body: PhysicsBody, shape: Nullable<PhysicsShape>): void {\r\n const shapeHandle = shape && shape._pluginData ? shape._pluginData : BigInt(0);\r\n if (!(body.transformNode instanceof Mesh) || !body.transformNode._thinInstanceDataStorage?.matrixData) {\r\n this._hknp.HP_Body_SetShape(body._pluginData.hpBodyId, shapeHandle);\r\n this._internalUpdateMassProperties(body._pluginData);\r\n return;\r\n }\r\n const m = body.transformNode as Mesh;\r\n const instancesCount = m._thinInstanceDataStorage?.instancesCount ?? 0;\r\n for (let i = 0; i < instancesCount; i++) {\r\n this._hknp.HP_Body_SetShape(body._pluginDataInstances[i].hpBodyId, shapeHandle);\r\n this._internalUpdateMassProperties(body._pluginDataInstances[i]);\r\n }\r\n }\r\n\r\n /**\r\n * Returns a reference to the first instance of the plugin data for a physics body.\r\n * @param body\r\n * @param instanceIndex\r\n * @returns a reference to the first instance\r\n */\r\n private _getPluginReference(body: PhysicsBody, instanceIndex?: number): BodyPluginData {\r\n return body._pluginDataInstances?.length ? body._pluginDataInstances[instanceIndex ?? 0] : body._pluginData;\r\n }\r\n\r\n /**\r\n * Gets the shape of a physics body. This will create a new shape object\r\n *\r\n * @param body - The physics body.\r\n * @returns The shape of the physics body.\r\n *\r\n */\r\n public getShape(body: PhysicsBody): Nullable<PhysicsShape> {\r\n const pluginRef = this._getPluginReference(body);\r\n const shapePluginData = this._hknp.HP_Body_GetShape(pluginRef.hpBodyId)[1];\r\n if (shapePluginData != 0) {\r\n const scene = body.transformNode.getScene();\r\n return new PhysicsShape({ pluginData: shapePluginData }, scene);\r\n }\r\n return null;\r\n }\r\n\r\n /**\r\n * Gets the type of a physics shape.\r\n * @param shape - The physics shape to get the type for.\r\n * @returns The type of the physics shape.\r\n *\r\n */\r\n public getShapeType(shape: PhysicsShape): PhysicsShapeType {\r\n if (shape.type) {\r\n return shape.type;\r\n } else {\r\n //<todo This returns a native type!\r\n return this._hknp.HP_Shape_GetType(shape._pluginData);\r\n }\r\n }\r\n\r\n /**\r\n * Sets the event mask of a physics body.\r\n * @param body - The physics body to set the event mask for.\r\n * @param eventMask - The event mask to set.\r\n *\r\n * This function is useful for setting the event mask of a physics body, which is used to determine which events the body will respond to. This is important for ensuring that the physics engine is able to accurately simulate the behavior of the body in the game world.\r\n */\r\n public setEventMask(body: PhysicsBody, eventMask: number, instanceIndex?: number): void {\r\n this._applyToBodyOrInstances(\r\n body,\r\n (bodyPluginData) => {\r\n this._hknp.HP_Body_SetEventMask(bodyPluginData.hpBodyId, eventMask);\r\n },\r\n instanceIndex\r\n );\r\n }\r\n\r\n /**\r\n * Retrieves the event mask of a physics body.\r\n *\r\n * @param body - The physics body to retrieve the event mask from.\r\n * @returns The event mask of the physics body.\r\n *\r\n */\r\n public getEventMask(body: PhysicsBody, instanceIndex?: number): number {\r\n const pluginRef = this._getPluginReference(body, instanceIndex);\r\n return this._hknp.HP_Body_GetEventMask(pluginRef)[1];\r\n }\r\n\r\n private _fromMassPropertiesTuple(massPropsTuple: any[]): PhysicsMassProperties {\r\n return {\r\n centerOfMass: Vector3.FromArray(massPropsTuple[0]),\r\n mass: massPropsTuple[1],\r\n inertia: Vector3.FromArray(massPropsTuple[2]),\r\n inertiaOrientation: Quaternion.FromArray(massPropsTuple[3]),\r\n };\r\n }\r\n\r\n private _internalUpdateMassProperties(pluginData: BodyPluginData) {\r\n // Recompute the mass based on the shape\r\n const newProps = this._internalComputeMassProperties(pluginData);\r\n const massProps = pluginData.userMassProps;\r\n\r\n // Override the computed values with any the user has set\r\n if (massProps.centerOfMass) {\r\n newProps[0] = massProps.centerOfMass.asArray();\r\n }\r\n if (massProps.mass != undefined) {\r\n newProps[1] = massProps.mass;\r\n }\r\n if (massProps.inertia) {\r\n newProps[2] = massProps.inertia.asArray();\r\n }\r\n if (massProps.inertiaOrientation) {\r\n newProps[3] = massProps.inertiaOrientation.asArray();\r\n }\r\n this._hknp.HP_Body_SetMassProperties(pluginData.hpBodyId, newProps);\r\n }\r\n\r\n public _internalSetMotionType(pluginData: BodyPluginData, motionType: PhysicsMotionType): void {\r\n switch (motionType) {\r\n case PhysicsMotionType.STATIC:\r\n this._hknp.HP_Body_SetMotionType(pluginData.hpBodyId, this._hknp.MotionType.STATIC);\r\n break;\r\n case PhysicsMotionType.ANIMATED:\r\n this._hknp.HP_Body_SetMotionType(pluginData.hpBodyId, this._hknp.MotionType.KINEMATIC);\r\n break;\r\n case PhysicsMotionType.DYNAMIC:\r\n this._hknp.HP_Body_SetMotionType(pluginData.hpBodyId, this._hknp.MotionType.DYNAMIC);\r\n break;\r\n }\r\n }\r\n\r\n public setMotionType(body: PhysicsBody, motionType: PhysicsMotionType, instanceIndex?: number): void {\r\n this._applyToBodyOrInstances(\r\n body,\r\n (pluginData) => {\r\n this._internalSetMotionType(pluginData, motionType);\r\n },\r\n instanceIndex\r\n );\r\n }\r\n\r\n public getMotionType(body: PhysicsBody, instanceIndex?: number): PhysicsMotionType {\r\n const pluginRef = this._getPluginReference(body, instanceIndex);\r\n const type = this._hknp.HP_Body_GetMotionType(pluginRef.hpBodyId)[1];\r\n switch (type) {\r\n case this._hknp.MotionType.STATIC:\r\n return PhysicsMotionType.STATIC;\r\n case this._hknp.MotionType.KINEMATIC:\r\n return PhysicsMotionType.ANIMATED;\r\n case this._hknp.MotionType.DYNAMIC:\r\n return PhysicsMotionType.DYNAMIC;\r\n }\r\n throw new Error(\"Unknown motion type: \" + type);\r\n }\r\n\r\n private _internalComputeMassProperties(pluginData: BodyPluginData): any[] {\r\n const shapeRes = this._hknp.HP_Body_GetShape(pluginData.hpBodyId);\r\n if (shapeRes[0] == this._hknp.Result.RESULT_OK) {\r\n const shapeMass = this._hknp.HP_Shape_BuildMassProperties(shapeRes[1]);\r\n if (shapeMass[0] == this._hknp.Result.RESULT_OK) {\r\n return shapeMass[1];\r\n }\r\n }\r\n\r\n // Failed; return a unit inertia\r\n return [[0, 0, 0], 1, [1, 1, 1], [0, 0, 0, 1]];\r\n }\r\n\r\n /**\r\n * Computes the mass properties of a physics body, from it's shape\r\n *\r\n * @param body - The physics body to copmute the mass properties of\r\n */\r\n public computeMassProperties(body: PhysicsBody, instanceIndex?: number): PhysicsMassProperties {\r\n const pluginRef = this._getPluginReference(body, instanceIndex);\r\n const computed = this._internalComputeMassProperties(pluginRef);\r\n return this._fromMassPropertiesTuple(computed);\r\n }\r\n\r\n /**\r\n * Sets the mass properties of a physics body.\r\n *\r\n * @param body - The physics body to set the mass properties of.\r\n * @param massProps - The mass properties to set.\r\n * @param instanceIndex - The index of the instance to set the mass properties of. If undefined, the mass properties of all the bodies will be set.\r\n * This function is useful for setting the mass properties of a physics body,\r\n * such as its mass, inertia, and center of mass. This is important for\r\n * accurately simulating the physics of the body in the physics engine.\r\n *\r\n */\r\n public setMassProperties(body: PhysicsBody, massProps: PhysicsMassProperties, instanceIndex?: number): void {\r\n this._applyToBodyOrInstances(\r\n body,\r\n (pluginData) => {\r\n pluginData.userMassProps = massProps;\r\n this._internalUpdateMassProperties(pluginData);\r\n },\r\n instanceIndex\r\n );\r\n }\r\n /**\r\n *\r\n */\r\n public getMassProperties(body: PhysicsBody, instanceIndex?: number): PhysicsMassProperties {\r\n const pluginRef = this._getPluginReference(body, instanceIndex);\r\n const massPropsTuple = this._hknp.HP_Body_GetMassProperties(pluginRef.hpBodyId)[1];\r\n return this._fromMassPropertiesTuple(massPropsTuple);\r\n }\r\n\r\n /**\r\n * Sets the linear damping of the given body.\r\n * @param body - The body to set the linear damping for.\r\n * @param damping - The linear damping to set.\r\n *\r\n * This method is useful for controlling the linear damping of a body in a physics engine.\r\n * Linear damping is a force that opposes the motion of the body, and is proportional to the velocity of the body.\r\n * This method allows the user to set the linear damping of a body, which can be used to control the motion of the body.\r\n */\r\n public setLinearDamping(body: PhysicsBody, damping: number, instanceIndex?: number): void {\r\n this._applyToBodyOrInstances(\r\n body,\r\n (pluginData) => {\r\n this._hknp.HP_Body_SetLinearDamping(pluginData.hpBodyId, damping);\r\n },\r\n instanceIndex\r\n );\r\n }\r\n\r\n /**\r\n * Gets the linear damping of the given body.\r\n * @param body - The body to get the linear damping from.\r\n * @returns The linear damping of the given body.\r\n *\r\n * This method is useful for getting the linear damping of a body in a physics engine.\r\n * Linear damping is a force that opposes the motion of the body and is proportional to the velocity of the body.\r\n * It is used to simulate the effects of air resistance and other forms of friction.\r\n */\r\n public getLinearDamping(body: PhysicsBody, instanceIndex?: number): number {\r\n const pluginRef = this._getPluginReference(body, instanceIndex);\r\n return this._hknp.HP_Body_GetLinearDamping(pluginRef.hpBodyId)[1];\r\n }\r\n\r\n /**\r\n * Sets the angular damping of a physics body.\r\n * @param body - The physics body to set the angular damping for.\r\n * @param damping - The angular damping value to set.\r\n *\r\n * This function is useful for controlling the angular velocity of a physics body.\r\n * By setting the angular damping, the body's angular velocity will be reduced over time, allowing for more realistic physics simulations.\r\n */\r\n public setAngularDamping(body: PhysicsBody, damping: number, instanceIndex?: number): void {\r\n this._applyToBodyOrInstances(\r\n body,\r\n (pluginData) => {\r\n this._hknp.HP_Body_SetAngularDamping(pluginData.hpBodyId, damping);\r\n },\r\n instanceIndex\r\n );\r\n }\r\n\r\n /**\r\n * Gets the angular damping of a physics body.\r\n * @param body - The physics body to get the angular damping from.\r\n * @returns The angular damping of the body.\r\n *\r\n * This function is useful for retrieving the angular damping of a physics body,\r\n * which is used to control the rotational motion of the body. The angular damping is a value between 0 and 1, where 0 is no damping and 1 is full damping.\r\n */\r\n public getAngularDamping(body: PhysicsBody, instanceIndex?: number): number {\r\n const pluginRef = this._getPluginReference(body, instanceIndex);\r\n return this._hknp.HP_Body_GetAngularDamping(pluginRef.hpBodyId)[1];\r\n }\r\n\r\n /**\r\n * Sets the linear velocity of a physics body.\r\n * @param body - The physics body to set the linear velocity of.\r\n * @param linVel - The linear velocity to set.\r\n *\r\n * This function is useful for setting the linear velocity of a physics body, which is necessary for simulating\r\n * motion in a physics engine. The linear velocity is the speed and direction of the body's movement.\r\n */\r\n public setLinearVelocity(body: PhysicsBody, linVel: Vector3, instanceIndex?: number): void {\r\n this._applyToBodyOrInstances(\r\n body,\r\n (pluginData) => {\r\n this._hknp.HP_Body_SetLinearVelocity(pluginData.hpBodyId, this._bVecToV3(linVel));\r\n },\r\n instanceIndex\r\n );\r\n }\r\n\r\n /**\r\n * Gets the linear velocity of a physics body and stores it in a given vector.\r\n * @param body - The physics body to get the linear velocity from.\r\n * @param linVel - The vector to store the linear velocity in.\r\n *\r\n * This function is useful for retrieving the linear velocity of a physics body,\r\n * which can be used to determine the speed and direction of the body. This\r\n * information can be used to simulate realistic physics behavior in a game.\r\n */\r\n public getLinearVelocityToRef(body: PhysicsBody, linVel: Vector3, instanceIndex?: number): void {\r\n const pluginRef = this._getPluginReference(body, instanceIndex);\r\n const lv = this._hknp.HP_Body_GetLinearVelocity(pluginRef.hpBodyId)[1];\r\n this._v3ToBvecRef(lv, linVel);\r\n }\r\n\r\n /*\r\n * Apply an operation either to all instances of a body, if instanceIndex is not specified, or to a specific instance.\r\n */\r\n private _applyToBodyOrInstances(body: PhysicsBody, fnToApply: (pluginRef: any) => void, instanceIndex?: number): void {\r\n if (body._pluginDataInstances?.length > 0 && instanceIndex === undefined) {\r\n for (let i = 0; i < body._pluginDataInstances.length; i++) {\r\n fnToApply(body._pluginDataInstances[i]);\r\n }\r\n } else {\r\n fnToApply(this._getPluginReference(body, instanceIndex));\r\n }\r\n }\r\n\r\n /**\r\n * Applies an impulse to a physics body at a given location.\r\n * @param body - The physics body to apply the impulse to.\r\n * @param impulse - The impulse vector to apply.\r\n * @param location - The location in world space to apply the impulse.\r\n * @param instanceIndex - The index of the instance to apply the impulse to. If not specified, the impulse will be applied to all instances.\r\n *\r\n * This method is useful for applying an impulse to a physics body at a given location.\r\n * This can be used to simulate physical forces such as explosions, collisions, and gravity.\r\n */\r\n public applyImpulse(body: PhysicsBody, impulse: Vector3, location: Vector3, instanceIndex?: number): void {\r\n this._applyToBodyOrInstances(\r\n body,\r\n (pluginRef) => {\r\n this._hknp.HP_Body_ApplyImpulse(pluginRef.hpBodyId, this._bVecToV3(location), this._bVecToV3(impulse));\r\n },\r\n instanceIndex\r\n );\r\n }\r\n\r\n /**\r\n * Applies a force to a physics body at a given location.\r\n * @param body - The physics body to apply the impulse to.\r\n * @param force - The force vector to apply.\r\n * @param location - The location in world space to apply the impulse.\r\n * @param instanceIndex - The index of the instance to apply the force to. If not specified, the force will be applied to all instances.\r\n *\r\n * This method is useful for applying a force to a physics body at a given location.\r\n * This can be used to simulate physical forces such as explosions, collisions, and gravity.\r\n */\r\n public applyForce(body: PhysicsBody, force: Vector3, location: Vector3, instanceIndex?: number): void {\r\n force.scaleToRef(this.getTimeStep(), this._tmpVec3[0]);\r\n this.applyImpulse(body, this._tmpVec3[0], location, instanceIndex);\r\n }\r\n\r\n /**\r\n * Sets the angular velocity of a physics body.\r\n *\r\n * @param body - The physics body to set the angular velocity of.\r\n * @param angVel - The angular velocity to set.\r\n *\r\n * This function is useful for setting the angular velocity of a physics body in a physics engine.\r\n * This allows for more realistic simulations of physical objects, as they can be given a rotational velocity.\r\n */\r\n public setAngularVelocity(body: PhysicsBody, angVel: Vector3, instanceIndex?: number): void {\r\n this._applyToBodyOrInstances(\r\n body,\r\n (pluginRef) => {\r\n this._hknp.HP_Body_SetAngularVelocity(pluginRef.hpBodyId, this._bVecToV3(angVel));\r\n },\r\n instanceIndex\r\n );\r\n }\r\n\r\n /**\r\n * Gets the angular velocity of a body.\r\n * @param body - The body to get the angular velocity from.\r\n * @param angVel - The vector3 to store the angular velocity.\r\n *\r\n * This method is useful for getting the angular velocity of a body in a physics engine. It\r\n * takes the body and a vector3 as parameters and stores the angular velocity of the body\r\n * in the vector3. This is useful for getting the angular velocity of a body in order to\r\n * calculate the motion of the body in the physics engine.\r\n */\r\n public getAngularVelocityToRef(body: PhysicsBody, angVel: Vector3, instanceIndex?: number): void {\r\n const pluginRef = this._getPluginReference(body, instanceIndex);\r\n const av = this._hknp.HP_Body_GetAngularVelocity(pluginRef.hpBodyId)[1];\r\n this._v3ToBvecRef(av, angVel);\r\n }\r\n\r\n /**\r\n * Sets the transformation of the given physics body to the given transform node.\r\n * @param body The physics body to set the transformation for.\r\n * @param node The transform node to set the transformation from.\r\n * Sets the transformation of the given physics body to the given transform node.\r\n *\r\n * This function is useful for setting the transformation of a physics body to a\r\n * transform node, which is necessary for the physics engine to accurately simulate\r\n * the motion of the body. It also takes into account instances of the transform\r\n * node, which is necessary for accurate simulation of multiple bodies with the\r\n * same transformation.\r\n */\r\n public setPhysicsBodyTransformation(body: PhysicsBody, node: TransformNode) {\r\n const transformNode = body.transformNode;\r\n if (body.numInstances > 0) {\r\n // instances\r\n const m = transformNode as Mesh;\r\n const matrixData = m._thinInstanceDataStorage.matrixData;\r\n if (!matrixData) {\r\n return; // TODO: error handling\r\n }\r\n const instancesCount = body.numInstances;\r\n this._createOrUpdateBodyInstances(body, body.getMotionType(), matrixData, 0, instancesCount, true);\r\n } else {\r\n // regular\r\n this._hknp.HP_Body_SetQTransform(body._pluginData.hpBodyId, this._getTransformInfos(node));\r\n }\r\n }\r\n\r\n /**\r\n * Disposes a physics body.\r\n *\r\n * @param body - The physics body to dispose.\r\n *\r\n * This method is useful for releasing the resources associated with a physics body when it is no longer needed.\r\n * This is important for avoiding memory leaks in the physics engine.\r\n */\r\n public disposeBody(body: PhysicsBody): void {\r\n if (body._pluginDataInstances && body._pluginDataInstances.length > 0) {\r\n for (const instance of body._pluginDataInstances) {\r\n this._hknp.HP_Body_Release(instance.hpBodyId);\r\n instance.hpBodyId = undefined;\r\n }\r\n }\r\n if (body._pluginData) {\r\n this._hknp.HP_Body_Release(body._pluginData.hpBodyId);\r\n body._pluginData.hpBodyId = undefined;\r\n }\r\n }\r\n\r\n /**\r\n * Initializes a physics shape with the given type and parameters.\r\n * @param shape - The physics shape to initialize.\r\n * @param type - The type of shape to initialize.\r\n * @param options - The parameters for the shape.\r\n *\r\n * This code is useful for initializing a physics shape with the given type and parameters.\r\n * It allows for the creation of a sphere, box, capsule, container, cylinder, mesh, and heightfield.\r\n * Depending on the type of shape, different parameters are required.\r\n * For example, a sphere requires a radius, while a box requires extents and a rotation.\r\n */\r\n public initShape(shape: PhysicsShape, type: PhysicsShapeType, options: PhysicsShapeParameters): void {\r\n switch (type) {\r\n case PhysicsShapeType.SPHERE:\r\n {\r\n const radius = options.radius || 1;\r\n const center = options.center ? this._bVecToV3(options.center) : [0, 0, 0];\r\n shape._pluginData = this._hknp.HP_Shape_CreateSphere(center, radius)[1];\r\n }\r\n break;\r\n case PhysicsShapeType.BOX:\r\n {\r\n const rotation = options.rotation ? this._bQuatToV4(options.rotation) : [0, 0, 0, 1];\r\n const extent = options.extents ? this._bVecToV3(options.extents) : [1, 1, 1];\r\n const center = options.center ? this._bVecToV3(options.center) : [0, 0, 0];\r\n shape._pluginData = this._hknp.HP_Shape_CreateBox(center, rotation, extent)[1];\r\n }\r\n break;\r\n case PhysicsShapeType.CAPSULE:\r\n {\r\n const pointA = options.pointA ? this._bVecToV3(options.pointA) : [0, 0, 0];\r\n const pointB = options.pointB ? this._bVecToV3(options.pointB) : [0, 1, 0];\r\n const radius = options.radius || 0;\r\n shape._pluginData = this._hknp.HP_Shape_CreateCapsule(pointA, pointB, radius)[1];\r\n }\r\n break;\r\n case PhysicsShapeType.CONTAINER:\r\n {\r\n shape._pluginData = this._hknp.HP_Shape_CreateContainer()[1];\r\n }\r\n break;\r\n case PhysicsShapeType.CYLINDER:\r\n {\r\n const pointA = options.pointA ? this._bVecToV3(options.pointA) : [0, 0, 0];\r\n const pointB = options.pointB ? this._bVecToV3(options.pointB) : [0, 1, 0];\r\n const radius = options.radius || 0;\r\n shape._pluginData = this._hknp.HP_Shape_CreateCylinder(pointA, pointB, radius)[1];\r\n }\r\n break;\r\n case PhysicsShapeType.CONVEX_HULL:\r\n case PhysicsShapeType.MESH:\r\n {\r\n const mesh = options.mesh;\r\n if (mesh) {\r\n const includeChildMeshes = !!options.includeChildMeshes;\r\n const needIndices = type != PhysicsShapeType.CONVEX_HULL;\r\n const accum = new MeshAccumulator(mesh, needIndices, mesh?.getScene());\r\n accum.addMesh(mesh, includeChildMeshes);\r\n\r\n const positions = accum.getVertices(this._hknp);\r\n const numVec3s = positions.length / 3;\r\n\r\n if (type == PhysicsShapeType.CONVEX_HULL) {\r\n shape._pluginData = this._hknp.HP_Shape_CreateConvexHull(positions.byteOffset, numVec3s)[1];\r\n } else {\r\n const triangles = accum.getTriangles(this._hknp);\r\n const numTriangles = triangles.length / 3;\r\n shape._pluginData = this._hknp.HP_Shape_CreateMesh(positions.byteOffset, numVec3s, triangles.byteOffset, numTriangles)[1];\r\n accum.freeBuffer(this._hknp, triangles);\r\n }\r\n accum.freeBuffer(this._hknp, positions);\r\n } else {\r\n throw new Error(\"No mesh provided to create physics shape.\");\r\n }\r\n }\r\n break;\r\n default:\r\n throw new Error(\"Unsupported Shape Type.\");\r\n break;\r\n }\r\n }\r\n\r\n public setShapeFilterMembershipMask(shape: PhysicsShape, membershipMask: number): void {\r\n const collideWith = this._hknp.HP_Shape_GetFilterInfo(shape._pluginData)[1][1];\r\n this._hknp.HP_Shape_SetFilterInfo(shape._pluginData, [membershipMask, collideWith]);\r\n }\r\n\r\n public getShapeFilterMembershipMask(shape: PhysicsShape): number {\r\n return this._hknp.HP_Shape_GetFilterInfo(shape._pluginData)[1][0];\r\n }\r\n\r\n public setShapeFilterCollideMask(shape: PhysicsShape, collideMask: number): void {\r\n const membership = this._hknp.HP_Shape_GetFilterInfo(shape._pluginData)[1][0];\r\n this._hknp.HP_Shape_SetFilterInfo(shape._pluginData, [membership, collideMask]);\r\n }\r\n\r\n public getShapeFilterCollideMask(shape: PhysicsShape): number {\r\n return this._hknp.HP_Shape_GetFilterInfo(shape._pluginData)[1][1];\r\n }\r\n\r\n /**\r\n * Sets the material of a physics shape.\r\n * @param shape - The physics shape to set the material of.\r\n * @param material - The material to set.\r\n *\r\n */\r\n public setMaterial(shape: PhysicsShape, material: PhysicsMaterial): void {\r\n const dynamicFriction = material.friction ?? 0.5;\r\n const staticFriction = material.staticFriction ?? dynamicFriction;\r\n const restitution = material.restitution ?? 0.0;\r\n const frictionCombine = material.frictionCombine ?? PhysicsMaterialCombineMode.MINIMUM;\r\n const restitutionCombine = material.restitutionCombine ?? PhysicsMaterialCombineMode.MAXIMUM;\r\n\r\n const hpMaterial = [staticFriction, dynamicFriction, restitution, this._materialCombineToNative(frictionCombine), this._materialCombineToNative(restitutionCombine)];\r\n this._hknp.HP_Shape_SetMaterial(shape._pluginData, hpMaterial);\r\n }\r\n\r\n /**\r\n * Sets the density of a physics shape.\r\n * @param shape - The physics shape to set the density of.\r\n * @param density - The density to set.\r\n *\r\n */\r\n public setDensity(shape: PhysicsShape, density: number): void {\r\n this._hknp.HP_Shape_SetDensity(shape._pluginData, density);\r\n }\r\n\r\n /**\r\n * Calculates the density of a given physics shape.\r\n *\r\n * @param shape - The physics shape to calculate the density of.\r\n * @returns The density of the given physics shape.\r\n *\r\n */\r\n public getDensity(shape: PhysicsShape): number {\r\n return this._hknp.HP_Shape_GetDensity(shape._pluginData)[1];\r\n }\r\n\r\n /**\r\n * Gets the transform infos of a given transform node.\r\n * @param node - The transform node.\r\n * @returns An array containing the position and orientation of the node.\r\n * This code is useful for getting the position and orientation of a given transform node.\r\n * It first checks if the node has a rotation quaternion, and if not, it creates one from the node's rotation.\r\n * It then creates an array containing the position and orientation of the node and returns it.\r\n */\r\n private _getTransformInfos(node: TransformNode): any[] {\r\n let orientation = TmpVectors.Quaternion[0];\r\n if (node.rotationQuaternion) {\r\n orientation = node.rotationQuaternion;\r\n } else {\r\n const r = node.rotation;\r\n Quaternion.FromEulerAnglesToRef(r.x, r.y, r.z, orientation);\r\n }\r\n const transform = [this._bVecToV3(node.position), this._bQuatToV4(orientation)];\r\n return transform;\r\n }\r\n\r\n /**\r\n * Adds a child shape to the given shape.\r\n * @param shape - The parent shape.\r\n * @param newChild - The child shape to add.\r\n * @param childTransform - The transform of the child shape relative to the parent shape.\r\n *\r\n */\r\n public addChild(shape: PhysicsShape, newChild: PhysicsShape, translation?: Vector3, rotation?: Quaternion, scale?: Vector3): void {\r\n const transformNative = [\r\n translation ? this._bVecToV3(translation) : [0, 0, 0],\r\n rotation ? this._bQuatToV4(rotation) : [0, 0, 0, 1],\r\n scale ? this._bVecToV3(scale) : [1, 1, 1],\r\n ];\r\n this._hknp.HP_Shape_AddChild(shape._pluginData, newChild._pluginData, transformNative);\r\n }\r\n\r\n /**\r\n * Removes a child shape from a parent shape.\r\n * @param shape - The parent shape.\r\n * @param childIndex - The index of the child shape to remove.\r\n *\r\n */\r\n public removeChild(shape: PhysicsShape, childIndex: number): void {\r\n this._hknp.HP_Shape_RemoveChild(shape._pluginData, childIndex);\r\n }\r\n\r\n /**\r\n * Returns the number of children of the given shape.\r\n *\r\n * @param shape - The shape to get the number of children from.\r\n * @returns The number of children of the given shape.\r\n *\r\n */\r\n public getNumChildren(shape: PhysicsShape): number {\r\n return this._hknp.HP_Shape_GetNumChildren(shape._pluginData)[1];\r\n }\r\n\r\n /**\r\n * Calculates the bounding box of a given physics shape.\r\n *\r\n * @param shape - The physics shape to calculate the bounding box for.\r\n * @returns The calculated bounding box.\r\n *\r\n * This method is useful for physics engines as it allows to calculate the\r\n * boundaries of a given shape. Knowing the boundaries of a shape is important\r\n * for collision detection and other physics calculations.\r\n */\r\n public getBoundingBox(shape: PhysicsShape): BoundingBox {\r\n return {} as BoundingBox;\r\n }\r\n\r\n /**\r\n * Gets the geometry of a physics body.\r\n *\r\n * @param body - The physics body.\r\n * @returns An object containing the positions and indices of the body's geometry.\r\n *\r\n */\r\n public getBodyGeometry(body: PhysicsBody) {\r\n const dataInfo = body._pluginDataInstances?.length > 0 ? body._pluginDataInstances[0] : body._pluginData;\r\n const shape = this._hknp.HP_Body_GetShape(dataInfo.hpBodyId)[1];\r\n const geometryRes = this._hknp.HP_Shape_CreateDebugDisplayGeometry(shape);\r\n\r\n if (geometryRes[0] != this._hknp.Result.RESULT_OK) {\r\n return { positions: [], indices: [] };\r\n }\r\n\r\n const geometryInfo = this._hknp.HP_DebugGeometry_GetInfo(geometryRes[1])[1];\r\n const positionsInPlugin = new Float32Array(this._hknp.HEAPU8.buffer, geometryInfo[0], geometryInfo[1] * 3); // 3 floats per position\r\n const indicesInPlugin = new Uint32Array(this._hknp.HEAPU8.buffer, geometryInfo[2], geometryInfo[3] * 3); // 3 indices per triangle\r\n\r\n // HP_DebugGeometry_Release will free the buffer in the plugin. To avoid a\r\n // use-after-free, we need to make a copy of the data here.\r\n const positions = positionsInPlugin.slice(0);\r\n const indices = indicesInPlugin.slice(0);\r\n this._hknp.HP_DebugGeometry_Release(geometryRes[1]);\r\n return { positions: positions, indices: indices };\r\n }\r\n\r\n /**\r\n * Releases a physics shape from the physics engine.\r\n *\r\n * @param shape - The physics shape to be released.\r\n * @returns void\r\n *\r\n * This method is useful for releasing a physics shape from the physics engine, freeing up resources and preventing memory leaks.\r\n */\r\n public disposeShape(shape: PhysicsShape): void {\r\n this._hknp.HP_Shape_Release(shape._pluginData);\r\n shape._pluginData = undefined;\r\n }\r\n\r\n // constraint\r\n\r\n /**\r\n * Initializes a physics constraint with the given parameters.\r\n *\r\n * @param constraint - The physics constraint to be initialized.\r\n * @param body - The main body\r\n * @param childBody - The child body.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to which the constraint will be applied. If not specified, no constraint will be applied.\r\n * @param childInstanceIndex - If the child body is instanced, the index of the instance to which the constraint will be applied. If not specified, no constraint will be applied.\r\n *\r\n * This function is useful for setting up a physics constraint in a physics engine.\r\n */\r\n public initConstraint(constraint: PhysicsConstraint, body: PhysicsBody, childBody: PhysicsBody, instanceIndex?: number, childInstanceIndex?: number): void {\r\n const type = constraint.type;\r\n const options = constraint.options;\r\n if (!type || !options) {\r\n Logger.Warn(\"No constraint type or options. Constraint is invalid.\");\r\n return;\r\n }\r\n if ((body._pluginDataInstances.length > 0 && instanceIndex === undefined) || (childBody._pluginDataInstances.length > 0 && childInstanceIndex === undefined)) {\r\n Logger.Warn(\"Body is instanced but no instance index was specified. Constraint will not be applied.\");\r\n return;\r\n }\r\n\r\n const jointId = this._hknp.HP_Constraint_Create()[1];\r\n constraint._pluginData = jointId;\r\n\r\n // body parenting\r\n const bodyA = this._getPluginReference(body, instanceIndex).hpBodyId;\r\n const bodyB = this._getPluginReference(childBody, childInstanceIndex).hpBodyId;\r\n this._hknp.HP_Constraint_SetParentBody(jointId, bodyA);\r\n this._hknp.HP_Constraint_SetChildBody(jointId, bodyB);\r\n\r\n // anchors\r\n const pivotA = options.pivotA ? this._bVecToV3(options.pivotA) : this._bVecToV3(Vector3.Zero());\r\n const axisA = options.axisA ?? new Vector3(1, 0, 0);\r\n const perpAxisA = this._tmpVec3[0];\r\n axisA?.getNormalToRef(perpAxisA);\r\n this._hknp.HP_Constraint_SetAnchorInParent(jointId, pivotA, this._bVecToV3(axisA), this._bVecToV3(perpAxisA));\r\n const pivotB = options.pivotB ? this._bVecToV3(options.pivotB) : this._bVecToV3(Vector3.Zero());\r\n const axisB = options.axisB ?? new Vector3(1, 0, 0);\r\n const perpAxisB = this._tmpVec3[0];\r\n axisB.getNormalToRef(perpAxisB);\r\n this._hknp.HP_Constraint_SetAnchorInChild(jointId, pivotB, this._bVecToV3(axisB), this._bVecToV3(perpAxisB));\r\n\r\n if (type == PhysicsConstraintType.LOCK) {\r\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.LINEAR_X, this._hknp.ConstraintAxisLimitMode.LOCKED);\r\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.LINEAR_Y, this._hknp.ConstraintAxisLimitMode.LOCKED);\r\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.LINEAR_Z, this._hknp.ConstraintAxisLimitMode.LOCKED);\r\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.ANGULAR_X, this._hknp.ConstraintAxisLimitMode.LOCKED);\r\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.ANGULAR_Y, this._hknp.ConstraintAxisLimitMode.LOCKED);\r\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.ANGULAR_Z, this._hknp.ConstraintAxisLimitMode.LOCKED);\r\n } else if (type == PhysicsConstraintType.DISTANCE) {\r\n const distance = options.maxDistance || 0;\r\n const dist3d = this._hknp.ConstraintAxis.LINEAR_DISTANCE;\r\n this._hknp.HP_Constraint_SetAxisMode(jointId, dist3d, this._hknp.ConstraintAxisLimitMode.LIMITED);\r\n this._hknp.HP_Constraint_SetAxisMinLimit(jointId, dist3d, distance);\r\n this._hknp.HP_Constraint_SetAxisMaxLimit(jointId, dist3d, distance);\r\n } else if (type == PhysicsConstraintType.HINGE) {\r\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.LINEAR_X, this._hknp.ConstraintAxisLimitMode.LOCKED);\r\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.LINEAR_Y, this._hknp.ConstraintAxisLimitMode.LOCKED);\r\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.LINEAR_Z, this._hknp.ConstraintAxisLimitMode.LOCKED);\r\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.ANGULAR_Y, this._hknp.ConstraintAxisLimitMode.LOCKED);\r\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.ANGULAR_Z, this._hknp.ConstraintAxisLimitMode.LOCKED);\r\n } else if (type == PhysicsConstraintType.PRISMATIC) {\r\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.LINEAR_Y, this._hknp.ConstraintAxisLimitMode.LOCKED);\r\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.LINEAR_Z, this._hknp.ConstraintAxisLimitMode.LOCKED);\r\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.ANGULAR_X, this._hknp.ConstraintAxisLimitMode.LOCKED);\r\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.ANGULAR_Y, this._hknp.ConstraintAxisLimitMode.LOCKED);\r\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.ANGULAR_Z, this._hknp.ConstraintAxisLimitMode.LOCKED);\r\n } else if (type == PhysicsConstraintType.SLIDER) {\r\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.LINEAR_Y, this._hknp.ConstraintAxisLimitMode.LOCKED);\r\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.LINEAR_Z, this._hknp.ConstraintAxisLimitMode.LOCKED);\r\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.ANGULAR_Y, this._hknp.ConstraintAxisLimitMode.LOCKED);\r\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.ANGULAR_Z, this._hknp.ConstraintAxisLimitMode.LOCKED);\r\n } else if (type == PhysicsConstraintType.BALL_AND_SOCKET) {\r\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.LINEAR_X, this._hknp.ConstraintAxisLimitMode.LOCKED);\r\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.LINEAR_Y, this._hknp.ConstraintAxisLimitMode.LOCKED);\r\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.LINEAR_Z, this._hknp.ConstraintAxisLimitMode.LOCKED);\r\n } else if (type == PhysicsConstraintType.SIX_DOF) {\r\n const sixdofData: Physics6DoFConstraint = <Physics6DoFConstraint>constraint;\r\n for (const l of sixdofData.limits) {\r\n const axId = this._constraintAxisToNative(l.axis);\r\n if ((l.minLimit ?? -1) == 0 && (l.maxLimit ?? -1) == 0) {\r\n this._hknp.HP_Constraint_SetAxisMode(jointId, axId, this._hknp.ConstraintAxisLimitMode.LOCKED);\r\n } else {\r\n if (l.minLimit != undefined) {\r\n this._hknp.HP_Constraint_SetAxisMode(jointId, axId, this._hknp.ConstraintAxisLimitMode.LIMITED);\r\n this._hknp.HP_Constraint_SetAxisMinLimit(jointId, axId, l.minLimit);\r\n }\r\n\r\n if (l.maxLimit != undefined) {\r\n this._hknp.HP_Constraint_SetAxisMode(jointId, axId, this._hknp.ConstraintAxisLimitMode.LIMITED);\r\n this._hknp.HP_Constraint_SetAxisMaxLimit(jointId, axId, l.maxLimit);\r\n }\r\n }\r\n }\r\n } else {\r\n throw new Error(\"Unsupported Constraint Type.\");\r\n }\r\n\r\n const collisionEnabled = !!options.collision;\r\n this._hknp.HP_Constraint_SetCollisionsEnabled(jointId, collisionEnabled);\r\n this._hknp.HP_Constraint_SetEnabled(jointId, true);\r\n }\r\n\r\n /**\r\n * Adds a constraint to the physics engine.\r\n *\r\n * @param body - The main body to which the constraint is applied.\r\n * @param childBody - The body to which the constraint is applied.\r\n * @param constraint - The constraint to be applied.\r\n * * @param instanceIndex - If this body is instanced, the index of the instance to which the constraint will be applied. If not specified, no constraint will be applied.\r\n * @param childInstanceIndex - If the child body is instanced, the index of the instance to which the constraint will be applied. If not specified, no constraint will be applied.\r\n */\r\n addConstraint(body: PhysicsBody, childBody: PhysicsBody, constraint: PhysicsConstraint, instanceIndex?: number, childInstanceIndex?: number): void {\r\n //<todo It's real weird that initConstraint() is called only after adding to a body!\r\n this.initConstraint(constraint, body, childBody, instanceIndex, childInstanceIndex);\r\n }\r\n\r\n /**\r\n * Enables or disables a constraint in the physics engine.\r\n * @param constraint - The constraint to enable or disable.\r\n * @param isEnabled - Whether the constraint should be enabled or disabled.\r\n *\r\n */\r\n public setEnabled(constraint: PhysicsConstraint, isEnabled: boolean): void {\r\n this._hknp.HP_Constraint_SetEnabled(constraint._pluginData, isEnabled);\r\n }\r\n\r\n /**\r\n * Gets the enabled state of the given constraint.\r\n * @param constraint - The constraint to get the enabled state from.\r\n * @returns The enabled state of the given constraint.\r\n *\r\n */\r\n public getEnabled(constraint: PhysicsConstraint): boolean {\r\n return this._hknp.HP_Constraint_GetEnabled(constraint._pluginData)[1];\r\n }\r\n\r\n /**\r\n * Enables or disables collisions for the given constraint.\r\n * @param constraint - The constraint to enable or disable collisions for.\r\n * @param isEnabled - Whether collisions should be enabled or disabled.\r\n *\r\n */\r\n public setCollisionsEnabled(constraint: PhysicsConstraint, isEnabled: boolean): void {\r\n this._hknp.HP_Constraint_SetCollisionsEnabled(constraint._pluginData, isEnabled);\r\n }\r\n\r\n /**\r\n * Gets whether collisions are enabled for the given constraint.\r\n * @param constraint - The constraint to get collisions enabled for.\r\n * @returns Whether collisions are enabled for the given constraint.\r\n *\r\n */\r\n public getCollisionsEnabled(constraint: PhysicsConstraint): boolean {\r\n return this._hknp.HP_Constraint_GetCollisionsEnabled(constraint._pluginData)[1];\r\n }\r\n\r\n /**\r\n * Sets the friction of the given axis of the given constraint.\r\n *\r\n * @param constraint - The constraint to set the friction of.\r\n * @param axis - The axis of the constraint to set the friction of.\r\n * @param friction - The friction to set.\r\n * @returns void\r\n *\r\n */\r\n public setAxisFriction(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis, friction: number): void {\r\n this._hknp.HP_Constraint_SetAxisFriction(constraint._pluginData, this._constraintAxisToNative(axis), friction);\r\n }\r\n\r\n /**\r\n * Gets the friction value of the specified axis of the given constraint.\r\n *\r\n * @param constraint - The constraint to get the axis friction from.\r\n * @param axis - The axis to get the friction from.\r\n * @returns The friction value of the specified axis.\r\n *\r\n */\r\n public getAxisFriction(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis): number {\r\n return this._hknp.HP_Constraint_GetAxisfriction(constraint._pluginData, this._constraintAxisToNative(axis))[1];\r\n }\r\n\r\n /**\r\n * Sets the limit mode of the specified axis of the given constraint.\r\n * @param constraint - The constraint to set the axis mode of.\r\n * @param axis - The axis to set the limit mode of.\r\n * @param limitMode - The limit mode to set.\r\n */\r\n public setAxisMode(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis, limitMode: PhysicsConstraintAxisLimitMode): void {\r\n this._hknp.HP_Constraint_SetAxisMode(constraint._pluginData, this._constraintAxisToNative(axis), this._limitModeToNative(limitMode));\r\n }\r\n\r\n /**\r\n * Gets the axis limit mode of the given constraint.\r\n *\r\n * @param constraint - The constraint to get the axis limit mode from.\r\n * @param axis - The axis to get the limit mode from.\r\n * @returns The axis limit mode of the given constraint.\r\n *\r\n */\r\n public getAxisMode(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis): PhysicsConstraintAxisLimitMode {\r\n const mode = this._hknp.HP_Constraint_GetAxisMode(constraint._pluginData, this._constraintAxisToNative(axis))[1];\r\n return this._nativeToLimitMode(mode);\r\n }\r\n\r\n /**\r\n * Sets the minimum limit of the given axis of the given constraint.\r\n * @param constraint - The constraint to set the minimum limit of.\r\n * @param axis - The axis to set the minimum limit of.\r\n * @param limit - The minimum limit to set.\r\n *\r\n */\r\n public setAxisMinLimit(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis, limit: number): void {\r\n this._hknp.HP_Constraint_SetAxisMinLimit(constraint._pluginData, this._constraintAxisToNative(axis), limit);\r\n }\r\n\r\n /**\r\n * Gets the minimum limit of the specified axis of the given constraint.\r\n * @param constraint - The constraint to get the minimum limit from.\r\n * @param axis - The axis to get the minimum limit from.\r\n * @returns The minimum limit of the specified axis of the given constraint.\r\n *\r\n */\r\n public getAxisMinLimit(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis): number {\r\n return this._hknp.HP_Constraint_GetAxisMinLimit(constraint._pluginData, this._constraintAxisToNative(axis))[1];\r\n }\r\n\r\n /**\r\n * Sets the maximum limit of the given axis of the given constraint.\r\n * @param constraint - The constraint to set the maximum limit of the given axis.\r\n * @param axis - The axis to set the maximum limit of.\r\n * @param limit - The maximum limit to set.\r\n *\r\n */\r\n public setAxisMaxLimit(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis, limit: number): void {\r\n this._hknp.HP_Constraint_SetAxisMaxLimit(constraint._pluginData, this._constraintAxisToNative(axis), limit);\r\n }\r\n\r\n /**\r\n * Gets the maximum limit of the given axis of the given constraint.\r\n *\r\n * @param constraint - The constraint to get the maximum limit from.\r\n * @param axis - The axis to get the maximum limit from.\r\n * @returns The maximum limit of the given axis of the given constraint.\r\n *\r\n */\r\n public getAxisMaxLimit(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis): number {\r\n return this._hknp.HP_Constraint_GetAxisMaxLimit(constraint._pluginData, this._constraintAxisToNative(axis))[1];\r\n }\r\n\r\n /**\r\n * Sets the motor type of the given axis of the given constraint.\r\n * @param constraint - The constraint to set the motor type of.\r\n * @param axis - The axis of the constraint to set the motor type of.\r\n * @param motorType - The motor type to set.\r\n * @returns void\r\n *\r\n */\r\n public setAxisMotorType(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis, motorType: PhysicsConstraintMotorType): void {\r\n this._hknp.HP_Constraint_SetAxisMotorType(constraint._pluginData, this._constraintAxisToNative(axis), this._constraintMotorTypeToNative(motorType));\r\n }\r\n\r\n /**\r\n * Gets the motor type of the specified axis of the given constraint.\r\n * @param constraint - The constraint to get the motor type from.\r\n * @param axis - The axis of the constraint to get the motor type from.\r\n * @returns The motor type of the specified axis of the given constraint.\r\n *\r\n */\r\n public getAxisMotorType(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis): PhysicsConstraintMotorType {\r\n return this._nativeToMotorType(this._hknp.HP_Constraint_GetAxisMotorType(constraint._pluginData, this._constraintAxisToNative(axis))[1]);\r\n }\r\n\r\n /**\r\n * Sets the target of an axis motor of a constraint.\r\n *\r\n * @param constraint - The constraint to set the axis motor target of.\r\n * @param axis - The axis of the constraint to set the motor target of.\r\n * @param target - The target of the axis motor.\r\n *\r\n */\r\n public setAxisMotorTarget(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis, target: number): void {\r\n this._hknp.HP_Constraint_SetAxisMotorTarget(constraint._pluginData, this._constraintAxisToNative(axis), target);\r\n }\r\n\r\n /**\r\n * Gets the target of the motor of the given axis of the given constraint.\r\n *\r\n * @param constraint - The constraint to get the motor target from.\r\n * @param axis - The axis of the constraint to get the motor target from.\r\n * @returns The target of the motor of the given axis of the given constraint.\r\n *\r\n */\r\n public getAxisMotorTarget(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis): number {\r\n return this._hknp.HP_Constraint_GetAxisMotorTarget(constraint._pluginData, this._constraintAxisToNative(axis))[1];\r\n }\r\n\r\n /**\r\n * Sets the maximum force that can be applied by the motor of the given constraint axis.\r\n * @param constraint - The constraint to set the motor max force for.\r\n * @param axis - The axis of the constraint to set the motor max force for.\r\n * @param maxForce - The maximum force that can be applied by the motor.\r\n *\r\n */\r\n public setAxisMotorMaxForce(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis, maxForce: number): void {\r\n this._hknp.HP_Constraint_SetAxisMotorMaxForce(constraint._pluginData, this._constraintAxisToNative(axis), maxForce);\r\n }\r\n\r\n /**\r\n * Gets the maximum force of the motor of the given constraint axis.\r\n *\r\n * @param constraint - The constraint to get the motor maximum force from.\r\n * @param axis - The axis of the constraint to get the motor maximum force from.\r\n * @returns The maximum force of the motor of the given constraint axis.\r\n *\r\n */\r\n public getAxisMotorMaxForce(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis): number {\r\n return this._hknp.HP_Constraint_GetAxisMotorMaxForce(constraint._pluginData, this._constraintAxisToNative(axis))[1];\r\n }\r\n\r\n /**\r\n * Disposes a physics constraint.\r\n *\r\n * @param constraint - The physics constraint to dispose.\r\n *\r\n * This method is useful for releasing the resources associated with a physics constraint, such as\r\n * the Havok constraint, when it is no longer needed. This is important for avoiding memory leaks.\r\n */\r\n public disposeConstraint(constraint: PhysicsConstraint): void {\r\n const jointId = constraint._pluginData;\r\n this._hknp.HP_Constraint_SetEnabled(jointId, false);\r\n this._hknp.HP_Constraint_Release(jointId);\r\n constraint._pluginData = undefined;\r\n }\r\n\r\n /**\r\n * Performs a raycast from a given start point to a given end point and stores the result in a given PhysicsRaycastResult object.\r\n *\r\n * @param from - The start point of the raycast.\r\n * @param to - The end point of the raycast.\r\n * @param result - The PhysicsRaycastResult object to store the result of the raycast.\r\n *\r\n * Performs a raycast. It takes in two points, from and to, and a PhysicsRaycastResult object to store the result of the raycast.\r\n * It then performs the raycast and stores the hit data in the PhysicsRaycastResult object.\r\n */\r\n public raycast(from: Vector3, to: Vector3, result: PhysicsRaycastResult): void {\r\n const queryMembership = ~0;\r\n const queryCollideWith = ~0;\r\n const query = [this._bVecToV3(from), this._bVecToV3(to), [queryMembership, queryCollideWith]];\r\n this._hknp.HP_World_CastRayWithCollector(this.world, this._queryCollector, query);\r\n\r\n if (this._hknp.HP_QueryCollector_GetNumHits(this._queryCollector)[1] > 0) {\r\n const hitData = this._hknp.HP_QueryCollector_GetCastRayResult(this._queryCollector, 0)[1];\r\n\r\n const hitPos = hitData[1][3];\r\n const hitNormal = hitData[1][4];\r\n result.setHitData({ x: hitNormal[0], y: hitNormal[1], z: hitNormal[2] }, { x: hitPos[0], y: hitPos[1], z: hitPos[2] });\r\n result.calculateHitDistance();\r\n const hitBody = this._bodies.get(hitData[1][0][0]);\r\n result.body = hitBody?.body;\r\n result.bodyIndex = hitBody?.index;\r\n }\r\n }\r\n\r\n /**\r\n * Return the collision observable for a particular physics body.\r\n * @param body the physics body\r\n */\r\n public getCollisionObservable(body: PhysicsBody): Observable<IPhysicsCollisionEvent> {\r\n const bodyId = body._pluginData.hpBodyId[0];\r\n let observable = this._bodyCollisionObservable.get(bodyId);\r\n if (!observable) {\r\n observable = new Observable<IPhysicsCollisionEvent>();\r\n this._bodyCollisionObservable.set(bodyId, observable);\r\n }\r\n return observable;\r\n }\r\n\r\n /**\r\n * Enable collision to be reported for a body when a callback is settup on the world\r\n * @param body the physics body\r\n * @param enabled\r\n */\r\n public setCollisionCallbackEnabled(body: PhysicsBody, enabled: boolean): void {\r\n // Register for collide events by default\r\n const collideEvents = this._hknp.EventType.COLLISION_STARTED.value | this._hknp.EventType.COLLISION_CONTINUED.value | this._hknp.EventType.COLLISION_FINISHED.value;\r\n if (body._pluginDataInstances && body._pluginDataInstances.length) {\r\n body._pluginDataInstances.forEach((bodyId) => {\r\n this._hknp.HP_Body_SetEventMask(bodyId.hpBodyId, enabled ? collideEvents : 0);\r\n });\r\n } else if (body._pluginData) {\r\n this._hknp.HP_Body_SetEventMask(body._pluginData.hpBodyId, enabled ? collideEvents : 0);\r\n }\r\n }\r\n\r\n /**\r\n * Runs thru all detected collisions and filter by body\r\n */\r\n private _notifyCollisions() {\r\n let eventAddress = this._hknp.HP_World_GetCollisionEvents(this.world)[1];\r\n const event = new CollisionEvent();\r\n const worldAddr = Number(this.world);\r\n while (eventAddress) {\r\n CollisionEvent.readToRef(this._hknp.HEAPU8.buffer, eventAddress, event);\r\n event.contactOnB.position.subtractToRef(event.contactOnA.position, this._tmpVec3[0]);\r\n const distance = Vector3.Dot(this._tmpVec3[0], event.contactOnA.normal);\r\n const bodyInfoA = this._bodies.get(event.contactOnA.bodyId)!;\r\n const bodyInfoB = this._bodies.get(event.contactOnB.bodyId)!;\r\n const collisionInfo = {\r\n collider: bodyInfoA.body,\r\n colliderIndex: bodyInfoA.index,\r\n collidedAgainst: bodyInfoB.body,\r\n collidedAgainstIndex: bodyInfoB.index,\r\n point: event.contactOnA.position,\r\n distance: distance,\r\n impulse: event.impulseApplied,\r\n normal: event.contactOnA.normal,\r\n };\r\n this.onCollisionObservable.notifyObservers(collisionInfo);\r\n\r\n if (this._bodyCollisionObservable.size) {\r\n const observableA = this._bodyCollisionObservable.get(event.contactOnA.bodyId);\r\n const observableB = this._bodyCollisionObservable.get(event.contactOnB.bodyId);\r\n\r\n if (observableA) {\r\n observableA.notifyObservers(collisionInfo);\r\n } else if (observableB) {\r\n //<todo This seems like it would give unexpected results when both bodies have observers?\r\n // Flip collision info:\r\n collisionInfo.collider = bodyInfoB.body;\r\n collisionInfo.colliderIndex = bodyInfoB.index;\r\n collisionInfo.collidedAgainst = bodyInfoA.body;\r\n collisionInfo.collidedAgainstIndex = bodyInfoA.index;\r\n collisionInfo.normal = event.contactOnB.normal;\r\n observableB.notifyObservers(collisionInfo);\r\n }\r\n }\r\n\r\n eventAddress = this._hknp.HP_World_GetNextCollisionEvent(worldAddr, eventAddress);\r\n }\r\n }\r\n\r\n /**\r\n * Gets the number of bodies in the world\r\n */\r\n public get numBodies() {\r\n return this._hknp.HP_World_GetNumBodies(this.world)[1];\r\n }\r\n\r\n /**\r\n * Dispose the world and free resources\r\n */\r\n public dispose(): void {\r\n this._hknp.HP_QueryCollector_Release(this._queryCollector);\r\n this._queryCollector = BigInt(0);\r\n this._hknp.HP_World_Release(this.world);\r\n this.world = undefined;\r\n }\r\n\r\n private _v3ToBvecRef(v: any, vec3: Vector3): void {\r\n vec3.set(v[0], v[1], v[2]);\r\n }\r\n\r\n private _bVecToV3(v: any): any {\r\n return [v._x, v._y, v._z];\r\n }\r\n\r\n private _bQuatToV4(q: Quaternion): Array<number> {\r\n return [q._x, q._y, q._z, q._w];\r\n }\r\n\r\n private _constraintMotorTypeToNative(motorType: PhysicsConstraintMotorType): any {\r\n switch (motorType) {\r\n case PhysicsConstraintMotorType.POSITION:\r\n return this._hknp.ConstraintMotorType.POSITION;\r\n case PhysicsConstraintMotorType.VELOCITY:\r\n return this._hknp.ConstraintMotorType.VELOCITY;\r\n }\r\n return this._hknp.ConstraintMotorType.NONE;\r\n }\r\n\r\n private _nativeToMotorType(motorType: any): PhysicsConstraintMotorType {\r\n switch (motorType) {\r\n case this._hknp.ConstraintMotorType.POSITION:\r\n return PhysicsConstraintMotorType.POSITION;\r\n case this._hknp.ConstraintMotorType.VELOCITY:\r\n return PhysicsConstraintMotorType.VELOCITY;\r\n }\r\n return PhysicsConstraintMotorType.NONE;\r\n }\r\n\r\n private _materialCombineToNative(mat: PhysicsMaterialCombineMode): any {\r\n switch (mat) {\r\n case PhysicsMaterialCombineMode.GEOMETRIC_MEAN:\r\n return this._hknp.MaterialCombine.GEOMETRIC_MEAN;\r\n case PhysicsMaterialCombineMode.MINIMUM:\r\n return this._hknp.MaterialCombine.MINIMUM;\r\n case PhysicsMaterialCombineMode.MAXIMUM:\r\n return this._hknp.MaterialCombine.MAXIMUM;\r\n case PhysicsMaterialCombineMode.ARITHMETIC_MEAN:\r\n return this._hknp.MaterialCombine.ARITHMETIC_MEAN;\r\n case PhysicsMaterialCombineMode.MULTIPLY:\r\n return this._hknp.MaterialCombine.MULTIPLY;\r\n }\r\n }\r\n\r\n private _constraintAxisToNative(axId: PhysicsConstraintAxis): any {\r\n switch (axId) {\r\n case PhysicsConstraintAxis.LINEAR_X:\r\n return this._hknp.ConstraintAxis.LINEAR_X;\r\n case PhysicsConstraintAxis.LINEAR_Y:\r\n return this._hknp.ConstraintAxis.LINEAR_Y;\r\n case PhysicsConstraintAxis.LINEAR_Z:\r\n return this._hknp.ConstraintAxis.LINEAR_Z;\r\n case PhysicsConstraintAxis.ANGULAR_X:\r\n return this._hknp.ConstraintAxis.ANGULAR_X;\r\n case PhysicsConstraintAxis.ANGULAR_Y:\r\n return this._hknp.ConstraintAxis.ANGULAR_Y;\r\n case PhysicsConstraintAxis.ANGULAR_Z:\r\n return this._hknp.ConstraintAxis.ANGULAR_Z;\r\n case PhysicsConstraintAxis.LINEAR_DISTANCE:\r\n return this._hknp.ConstraintAxis.LINEAR_DISTANCE;\r\n }\r\n }\r\n\r\n private _nativeToLimitMode(mode: number): PhysicsConstraintAxisLimitMode {\r\n switch (mode) {\r\n case this._hknp.ConstraintAxisLimitMode.FREE:\r\n return PhysicsConstraintAxisLimitMode.FREE;\r\n case this._hknp.ConstraintAxisLimitMode.LIMITED:\r\n return PhysicsConstraintAxisLimitMode.LIMITED;\r\n case this._hknp.ConstraintAxisLimitMode.LOCKED:\r\n return PhysicsConstraintAxisLimitMode.LOCKED;\r\n }\r\n\r\n return PhysicsConstraintAxisLimitMode.FREE;\r\n }\r\n\r\n private _limitModeToNative(mode: PhysicsConstraintAxisLimitMode): any {\r\n switch (mode) {\r\n case PhysicsConstraintAxisLimitMode.FREE:\r\n return this._hknp.ConstraintAxisLimitMode.FREE;\r\n case PhysicsConstraintAxisLimitMode.LIMITED:\r\n return this._hknp.ConstraintAxisLimitMode.LIMITED;\r\n case PhysicsConstraintAxisLimitMode.LOCKED:\r\n return this._hknp.ConstraintAxisLimitMode.LOCKED;\r\n }\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"havokPlugin.js","sourceRoot":"","sources":["../../../../../../lts/core/generated/Physics/v2/Plugins/havokPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACrF,OAAO,EACH,gBAAgB,EACh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8B,CAAC,IAAI;gBACpC,OAAO,IAAI,CAAC,KAAK,CAAC,uBAAuB,CAAC,IAAI,CAAC;YACnD,KAAK,8BAA8B,CAAC,OAAO;gBACvC,OAAO,IAAI,CAAC,KAAK,CAAC,uBAAuB,CAAC,OAAO,CAAC;YACtD,KAAK,8BAA8B,CAAC,MAAM;gBACtC,OAAO,IAAI,CAAC,KAAK,CAAC,uBAAuB,CAAC,MAAM,CAAC;SACxD;IACL,CAAC;CACJ","sourcesContent":["import { Matrix, Quaternion, TmpVectors, Vector3 } from \"../../../Maths/math.vector\";\r\nimport {\r\n PhysicsShapeType,\r\n PhysicsConstraintType,\r\n PhysicsMotionType,\r\n PhysicsConstraintMotorType,\r\n PhysicsConstraintAxis,\r\n PhysicsConstraintAxisLimitMode,\r\n} from \"../IPhysicsEnginePlugin\";\r\nimport type { PhysicsShapeParameters, IPhysicsEnginePluginV2, PhysicsMassProperties, IPhysicsCollisionEvent } from \"../IPhysicsEnginePlugin\";\r\nimport { Logger } from \"../../../Misc/logger\";\r\nimport type { PhysicsBody } from \"../physicsBody\";\r\nimport type { PhysicsConstraint, Physics6DoFConstraint } from \"../physicsConstraint\";\r\nimport type { PhysicsMaterial } from \"../physicsMaterial\";\r\nimport { PhysicsMaterialCombineMode } from \"../physicsMaterial\";\r\nimport { PhysicsShape } from \"../physicsShape\";\r\nimport type { BoundingBox } from \"../../../Culling/boundingBox\";\r\nimport type { TransformNode } from \"../../../Meshes/transformNode\";\r\nimport type { PhysicsRaycastResult } from \"../../physicsRaycastResult\";\r\nimport { Mesh } from \"../../../Meshes/mesh\";\r\nimport type { Scene } from \"../../../scene\";\r\nimport { VertexBuffer } from \"../../../Buffers/buffer\";\r\nimport { ArrayTools } from \"../../../Misc/arrayTools\";\r\nimport { Observable } from \"../../../Misc/observable\";\r\nimport type { Nullable } from \"../../../types\";\r\ndeclare let HK: any;\r\n\r\nclass MeshAccumulator {\r\n /**\r\n * Constructor of the mesh accumulator\r\n * @param mesh - The mesh used to compute the world matrix.\r\n * @param collectIndices - use mesh indices\r\n * @param scene - The scene used to determine the right handed system.\r\n *\r\n * Merge mesh and its children so whole hierarchy can be used as a mesh shape or convex hull\r\n */\r\n public constructor(mesh: Mesh, collectIndices: boolean, scene: Scene) {\r\n const worldFromRoot = mesh.computeWorldMatrix(true);\r\n const rootScale = new Vector3();\r\n const rootOrientation = new Quaternion();\r\n const rootTranslation = new Vector3();\r\n worldFromRoot.decompose(rootScale, rootOrientation, rootTranslation);\r\n\r\n this._bodyFromWorld = Matrix.Compose(Vector3.One(), mesh.rotationQuaternion ? mesh.rotationQuaternion : Quaternion.Identity(), mesh.position);\r\n this._bodyFromWorld = this._bodyFromWorld.invert();\r\n this._isRightHanded = scene.useRightHandedSystem;\r\n this._collectIndices = collectIndices;\r\n }\r\n\r\n /**\r\n * Adds a mesh to the physics engine.\r\n * @param mesh The mesh to add.\r\n * @param includeChildren Whether to include the children of the mesh.\r\n *\r\n * This method adds a mesh to the physics engine by computing the world matrix,\r\n * multiplying it with the body from world matrix, and then transforming the\r\n * coordinates of the mesh's vertices. It also adds the indices of the mesh\r\n * to the physics engine. If includeChildren is true, it will also add the\r\n * children of the mesh to the physics engine, ignoring any children which\r\n * have a physics impostor. This is useful for creating a physics engine\r\n * that accurately reflects the mesh and its children.\r\n */\r\n public addMesh(mesh: Mesh, includeChildren: boolean): void {\r\n const indexOffset = this._vertices.length;\r\n const worldFromShape = mesh.computeWorldMatrix(true);\r\n const shapeFromBody = worldFromShape.multiply(this._bodyFromWorld);\r\n\r\n const vertexData = mesh.getVerticesData(VertexBuffer.PositionKind) || [];\r\n const numVerts = vertexData.length / 3;\r\n for (let v = 0; v < numVerts; v++) {\r\n const pos = new Vector3(vertexData[v * 3 + 0], vertexData[v * 3 + 1], vertexData[v * 3 + 2]);\r\n this._vertices.push(Vector3.TransformCoordinates(pos, shapeFromBody));\r\n }\r\n\r\n if (this._collectIndices) {\r\n const meshIndices = mesh.getIndices();\r\n if (meshIndices) {\r\n for (let i = 0; i < meshIndices.length; i += 3) {\r\n // Havok wants the correct triangle winding to enable the interior triangle optimization\r\n if (this._isRightHanded) {\r\n this._indices.push(meshIndices[i + 0] + indexOffset);\r\n this._indices.push(meshIndices[i + 1] + indexOffset);\r\n this._indices.push(meshIndices[i + 2] + indexOffset);\r\n } else {\r\n this._indices.push(meshIndices[i + 2] + indexOffset);\r\n this._indices.push(meshIndices[i + 1] + indexOffset);\r\n this._indices.push(meshIndices[i + 0] + indexOffset);\r\n }\r\n }\r\n }\r\n }\r\n\r\n if (includeChildren) {\r\n const children = mesh.getChildMeshes(false);\r\n // Ignore any children which have a physics body.\r\n // Other plugin implementations do not have this check, which appears to be\r\n // a bug, as otherwise, the mesh will have a duplicate collider\r\n children.filter((m: any) => !m.physicsBody).forEach((m: any) => this.addMesh(m, includeChildren));\r\n }\r\n }\r\n\r\n /**\r\n * Allocate and populate the vertex positions inside the physics plugin.\r\n *\r\n * @returns An array of floats, whose backing memory is inside the plugin. The array contains the\r\n * positions of the mesh vertices, where a position is defined by three floats. You must call\r\n * freeBuffer() on the returned array once you have finished with it, in order to free the\r\n * memory inside the plugin..\r\n */\r\n public getVertices(plugin: any): Float32Array {\r\n const nFloats = this._vertices.length * 3;\r\n const bytesPerFloat = 4;\r\n const nBytes = nFloats * bytesPerFloat;\r\n const bufferBegin = plugin._malloc(nBytes);\r\n\r\n const ret = new Float32Array(plugin.HEAPU8.buffer, bufferBegin, nFloats);\r\n for (let i = 0; i < this._vertices.length; i++) {\r\n ret[i * 3 + 0] = this._vertices[i].x;\r\n ret[i * 3 + 1] = this._vertices[i].y;\r\n ret[i * 3 + 2] = this._vertices[i].z;\r\n }\r\n\r\n return ret;\r\n }\r\n\r\n public freeBuffer(plugin: any, arr: Float32Array | Int32Array) {\r\n plugin._free(arr.byteOffset);\r\n }\r\n\r\n /**\r\n * Allocate and populate the triangle indices inside the physics plugin\r\n *\r\n * @returns A new Int32Array, whose backing memory is inside the plugin. The array contains the indices\r\n * of the triangle positions, where a single triangle is defined by three indices. You must call\r\n * freeBuffer() on this array once you have finished with it, to free the memory inside the plugin..\r\n */\r\n public getTriangles(plugin: any): Int32Array {\r\n const bytesPerInt = 4;\r\n const nBytes = this._indices.length * bytesPerInt;\r\n const bufferBegin = plugin._malloc(nBytes);\r\n const ret = new Int32Array(plugin.HEAPU8.buffer, bufferBegin, this._indices.length);\r\n for (let i = 0; i < this._indices.length; i++) {\r\n ret[i] = this._indices[i];\r\n }\r\n\r\n return ret;\r\n }\r\n\r\n private _isRightHanded: boolean;\r\n private _collectIndices: boolean;\r\n private _vertices: Vector3[] = []; /// Vertices in body space\r\n private _indices: number[] = [];\r\n private _bodyFromWorld: Matrix;\r\n}\r\n\r\nclass BodyPluginData {\r\n public constructor(bodyId: any) {\r\n this.hpBodyId = bodyId;\r\n this.userMassProps = { centerOfMass: undefined, mass: undefined, inertia: undefined, inertiaOrientation: undefined };\r\n }\r\n\r\n public hpBodyId: any;\r\n\r\n public worldTransformOffset: number;\r\n\r\n public userMassProps: PhysicsMassProperties;\r\n}\r\n\r\n/*\r\nclass ShapePath\r\n{\r\n public colliderId: number;\r\n public pathData: number;\r\n}\r\n*/\r\n\r\nclass ContactPoint {\r\n public bodyId: bigint = BigInt(0); //0,2\r\n //public colliderId: number = 0; //2,4\r\n //public shapePath: ShapePath = new ShapePath(); //4,8\r\n public position: Vector3 = new Vector3(); //8,11\r\n public normal: Vector3 = new Vector3(); //11,14\r\n //public triIdx: number = 0; //14,15\r\n}\r\n\r\nclass CollisionEvent {\r\n //public eventType: number = 0; //0,1\r\n public contactOnA: ContactPoint = new ContactPoint(); //1\r\n public contactOnB: ContactPoint = new ContactPoint();\r\n public impulseApplied: number = 0;\r\n\r\n static readToRef(buffer: any, offset: number, eventOut: CollisionEvent) {\r\n const intBuf = new Int32Array(buffer, offset);\r\n const floatBuf = new Float32Array(buffer, offset);\r\n const offA = 2;\r\n eventOut.contactOnA.bodyId = BigInt(intBuf[offA]); //<todo Need to get the high+low words!\r\n eventOut.contactOnA.position.set(floatBuf[offA + 8], floatBuf[offA + 9], floatBuf[offA + 10]);\r\n eventOut.contactOnA.normal.set(floatBuf[offA + 11], floatBuf[offA + 12], floatBuf[offA + 13]);\r\n const offB = 18;\r\n eventOut.contactOnB.bodyId = BigInt(intBuf[offB]);\r\n eventOut.contactOnB.position.set(floatBuf[offB + 8], floatBuf[offB + 9], floatBuf[offB + 10]);\r\n eventOut.contactOnB.normal.set(floatBuf[offB + 11], floatBuf[offB + 12], floatBuf[offB + 13]);\r\n eventOut.impulseApplied = floatBuf[offB + 13 + 2];\r\n }\r\n}\r\n\r\n/**\r\n * The Havok Physics plugin\r\n */\r\nexport class HavokPlugin implements IPhysicsEnginePluginV2 {\r\n /**\r\n * Reference to the WASM library\r\n */\r\n public _hknp: any = {};\r\n /**\r\n * Created Havok world which physics bodies are added to\r\n */\r\n public world: any;\r\n /**\r\n * Name of the plugin\r\n */\r\n public name: string = \"HavokPlugin\";\r\n /**\r\n * We only have a single raycast in-flight right now\r\n */\r\n private _queryCollector: bigint;\r\n private _fixedTimeStep: number = 1 / 60;\r\n private _timeStep: number = 1 / 60;\r\n private _tmpVec3 = ArrayTools.BuildArray(3, Vector3.Zero);\r\n private _bodies = new Map<bigint, { body: PhysicsBody; index: number }>();\r\n private _bodyBuffer: number;\r\n private _bodyCollisionObservable = new Map<bigint, Observable<IPhysicsCollisionEvent>>();\r\n /**\r\n *\r\n */\r\n public onCollisionObservable = new Observable<IPhysicsCollisionEvent>();\r\n\r\n public constructor(private _useDeltaForWorldStep: boolean = true, hpInjection: any = HK) {\r\n if (typeof hpInjection === \"function\") {\r\n Logger.Error(\"Havok is not ready. Please make sure you await HK() before using the plugin.\");\r\n return;\r\n } else {\r\n this._hknp = hpInjection;\r\n }\r\n\r\n if (!this.isSupported()) {\r\n Logger.Error(\"Havok is not available. Please make sure you included the js file.\");\r\n return;\r\n }\r\n this.world = this._hknp.HP_World_Create()[1];\r\n this._queryCollector = this._hknp.HP_QueryCollector_Create(1)[1];\r\n }\r\n /**\r\n * If this plugin is supported\r\n * @returns true if its supported\r\n */\r\n public isSupported(): boolean {\r\n return this._hknp !== undefined;\r\n }\r\n\r\n /**\r\n * Sets the gravity of the physics world.\r\n *\r\n * @param gravity - The gravity vector to set.\r\n *\r\n */\r\n public setGravity(gravity: Vector3): void {\r\n this._hknp.HP_World_SetGravity(this.world, this._bVecToV3(gravity));\r\n }\r\n\r\n /**\r\n * Sets the fixed time step for the physics engine.\r\n *\r\n * @param timeStep - The fixed time step to use for the physics engine.\r\n *\r\n */\r\n public setTimeStep(timeStep: number): void {\r\n this._fixedTimeStep = timeStep;\r\n }\r\n\r\n /**\r\n * Gets the fixed time step used by the physics engine.\r\n *\r\n * @returns The fixed time step used by the physics engine.\r\n *\r\n */\r\n public getTimeStep(): number {\r\n return this._fixedTimeStep;\r\n }\r\n\r\n /**\r\n * Executes a single step of the physics engine.\r\n *\r\n * @param delta The time delta in seconds since the last step.\r\n * @param physicsBodies An array of physics bodies to be simulated.\r\n * @returns void\r\n *\r\n * This method is useful for simulating the physics engine. It sets the physics body transformation,\r\n * steps the world, syncs the physics body, and notifies collisions. This allows for the physics engine\r\n * to accurately simulate the physics bodies in the world.\r\n */\r\n public executeStep(delta: number, physicsBodies: Array<PhysicsBody>): void {\r\n for (const physicsBody of physicsBodies) {\r\n if (physicsBody.disablePreStep) {\r\n continue;\r\n }\r\n this.setPhysicsBodyTransformation(physicsBody, physicsBody.transformNode);\r\n }\r\n\r\n this._hknp.HP_World_Step(this.world, this._useDeltaForWorldStep ? delta : this._timeStep);\r\n\r\n this._bodyBuffer = this._hknp.HP_World_GetBodyBuffer(this.world)[1];\r\n for (const physicsBody of physicsBodies) {\r\n this.sync(physicsBody);\r\n }\r\n\r\n this._notifyCollisions();\r\n }\r\n\r\n /**\r\n * Returns the version of the physics engine plugin.\r\n *\r\n * @returns The version of the physics engine plugin.\r\n *\r\n * This method is useful for determining the version of the physics engine plugin that is currently running.\r\n */\r\n public getPluginVersion(): number {\r\n return 2;\r\n }\r\n\r\n /**\r\n * Initializes a physics body with the given position and orientation.\r\n *\r\n * @param body - The physics body to initialize.\r\n * @param motionType - The motion type of the body.\r\n * @param position - The position of the body.\r\n * @param orientation - The orientation of the body.\r\n * This code is useful for initializing a physics body with the given position and orientation.\r\n * It creates a plugin data for the body and adds it to the world. It then converts the position\r\n * and orientation to a transform and sets the body's transform to the given values.\r\n */\r\n public initBody(body: PhysicsBody, motionType: PhysicsMotionType, position: Vector3, orientation: Quaternion): void {\r\n body._pluginData = new BodyPluginData(this._hknp.HP_Body_Create()[1]);\r\n\r\n this._internalSetMotionType(body._pluginData, motionType);\r\n const transform = [this._bVecToV3(position), this._bQuatToV4(orientation)]; //<todo temp transform?\r\n this._hknp.HP_Body_SetQTransform(body._pluginData.hpBodyId, transform);\r\n\r\n this._hknp.HP_World_AddBody(this.world, body._pluginData.hpBodyId, body.startAsleep);\r\n this._bodies.set(body._pluginData.hpBodyId[0], { body: body, index: 0 });\r\n }\r\n\r\n /**\r\n * Removes a body from the world. To dispose of a body, it is necessary to remove it from the world first.\r\n *\r\n * @param body - The body to remove.\r\n */\r\n public removeBody(body: PhysicsBody): void {\r\n if (body._pluginDataInstances && body._pluginDataInstances.length > 0) {\r\n for (const instance of body._pluginDataInstances) {\r\n this._bodyCollisionObservable.delete(instance.hpBodyId[0]);\r\n this._hknp.HP_World_RemoveBody(this.world, instance.hpBodyId);\r\n }\r\n }\r\n if (body._pluginData) {\r\n this._bodyCollisionObservable.delete(body._pluginData.hpBodyId[0]);\r\n this._hknp.HP_World_RemoveBody(this.world, body._pluginData.hpBodyId);\r\n }\r\n }\r\n\r\n /**\r\n * Initializes the body instances for a given physics body and mesh.\r\n *\r\n * @param body - The physics body to initialize.\r\n * @param motionType - How the body will be handled by the engine\r\n * @param mesh - The mesh to initialize.\r\n *\r\n * This code is useful for creating a physics body from a mesh. It creates a\r\n * body instance for each instance of the mesh and adds it to the world. It also\r\n * sets the position of the body instance to the position of the mesh instance.\r\n * This allows for the physics engine to accurately simulate the mesh in the\r\n * world.\r\n */\r\n public initBodyInstances(body: PhysicsBody, motionType: PhysicsMotionType, mesh: Mesh): void {\r\n const instancesCount = mesh._thinInstanceDataStorage?.instancesCount ?? 0;\r\n const matrixData = mesh._thinInstanceDataStorage.matrixData;\r\n if (!matrixData) {\r\n return; // TODO: error handling\r\n }\r\n this._createOrUpdateBodyInstances(body, motionType, matrixData, 0, instancesCount, false);\r\n body._pluginDataInstances.forEach((bodyId, index) => {\r\n this._bodies.set(bodyId.hpBodyId[0], { body: body, index: index });\r\n });\r\n }\r\n\r\n private _createOrUpdateBodyInstances(body: PhysicsBody, motionType: PhysicsMotionType, matrixData: Float32Array, startIndex: number, endIndex: number, update: boolean): void {\r\n const rotation = TmpVectors.Quaternion[0];\r\n const rotationMatrix = Matrix.Identity();\r\n for (let i = startIndex; i < endIndex; i++) {\r\n const position = [matrixData[i * 16 + 12], matrixData[i * 16 + 13], matrixData[i * 16 + 14]];\r\n let hkbody;\r\n if (!update) {\r\n hkbody = this._hknp.HP_Body_Create()[1];\r\n } else {\r\n hkbody = body._pluginDataInstances[i].hpBodyId;\r\n }\r\n rotationMatrix.setRowFromFloats(0, matrixData[i * 16 + 0], matrixData[i * 16 + 1], matrixData[i * 16 + 2], 0);\r\n rotationMatrix.setRowFromFloats(1, matrixData[i * 16 + 4], matrixData[i * 16 + 5], matrixData[i * 16 + 6], 0);\r\n rotationMatrix.setRowFromFloats(2, matrixData[i * 16 + 8], matrixData[i * 16 + 9], matrixData[i * 16 + 10], 0);\r\n Quaternion.FromRotationMatrixToRef(rotationMatrix, rotation);\r\n const transform = [position, [rotation.x, rotation.y, rotation.z, rotation.w]];\r\n this._hknp.HP_Body_SetQTransform(hkbody, transform);\r\n if (!update) {\r\n const pluginData = new BodyPluginData(hkbody);\r\n if (body._pluginDataInstances.length) {\r\n // If an instance already exists, copy any user-provided mass properties\r\n pluginData.userMassProps = body._pluginDataInstances[0].userMassProps;\r\n }\r\n this._internalSetMotionType(pluginData, motionType);\r\n this._internalUpdateMassProperties(pluginData);\r\n body._pluginDataInstances.push(pluginData);\r\n this._hknp.HP_World_AddBody(this.world, hkbody, body.startAsleep);\r\n pluginData.worldTransformOffset = this._hknp.HP_Body_GetWorldTransformOffset(hkbody)[1];\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Update the internal body instances for a given physics body to match the instances in a mesh.\r\n * @param body the body that will be updated\r\n * @param mesh the mesh with reference instances\r\n */\r\n public updateBodyInstances(body: PhysicsBody, mesh: Mesh): void {\r\n const instancesCount = mesh._thinInstanceDataStorage?.instancesCount ?? 0;\r\n const matrixData = mesh._thinInstanceDataStorage.matrixData;\r\n if (!matrixData) {\r\n return; // TODO: error handling\r\n }\r\n const pluginInstancesCount = body._pluginDataInstances.length;\r\n const motionType = this.getMotionType(body);\r\n\r\n if (instancesCount > pluginInstancesCount) {\r\n this._createOrUpdateBodyInstances(body, motionType, matrixData, pluginInstancesCount, instancesCount, false);\r\n const firstBodyShape = this._hknp.HP_Body_GetShape(body._pluginDataInstances[0].hpBodyId)[1];\r\n for (let i = pluginInstancesCount; i < instancesCount; i++) {\r\n this._hknp.HP_Body_SetShape(body._pluginDataInstances[i].hpBodyId, firstBodyShape);\r\n this._internalUpdateMassProperties(body._pluginDataInstances[i]);\r\n this._bodies.set(body._pluginDataInstances[i].hpBodyId[0], { body: body, index: i });\r\n }\r\n } else if (instancesCount < pluginInstancesCount) {\r\n const instancesToRemove = pluginInstancesCount - instancesCount;\r\n for (let i = 0; i < instancesToRemove; i++) {\r\n const hkbody = body._pluginDataInstances.pop();\r\n this._bodies.delete(hkbody.hpBodyId[0]);\r\n this._hknp.HP_World_RemoveBody(this.world, hkbody.hpBodyId);\r\n this._hknp.HP_Body_Release(hkbody.hpBodyId);\r\n }\r\n this._createOrUpdateBodyInstances(body, motionType, matrixData, 0, instancesCount, true);\r\n }\r\n }\r\n\r\n /**\r\n * Synchronizes the transform of a physics body with its transform node.\r\n * @param body - The physics body to synchronize.\r\n *\r\n * This function is useful for keeping the physics body's transform in sync with its transform node.\r\n * This is important for ensuring that the physics body is accurately represented in the physics engine.\r\n */\r\n sync(body: PhysicsBody): void {\r\n this.syncTransform(body, body.transformNode);\r\n }\r\n\r\n /**\r\n * Synchronizes the transform of a physics body with the transform of its\r\n * corresponding transform node.\r\n *\r\n * @param body - The physics body to synchronize.\r\n * @param transformNode - The destination Transform Node.\r\n *\r\n * This code is useful for synchronizing the position and orientation of a\r\n * physics body with the position and orientation of its corresponding\r\n * transform node. This is important for ensuring that the physics body and\r\n * the transform node are in the same position and orientation in the scene.\r\n * This is necessary for the physics engine to accurately simulate the\r\n * physical behavior of the body.\r\n */\r\n syncTransform(body: PhysicsBody, transformNode: TransformNode): void {\r\n if (body._pluginDataInstances.length) {\r\n // instances\r\n const m = transformNode as Mesh;\r\n const matrixData = m._thinInstanceDataStorage.matrixData;\r\n if (!matrixData) {\r\n return; // TODO: error handling\r\n }\r\n const instancesCount = body._pluginDataInstances.length;\r\n for (let i = 0; i < instancesCount; i++) {\r\n const bufOffset = body._pluginDataInstances[i].worldTransformOffset;\r\n const transformBuffer = new Float32Array(this._hknp.HEAPU8.buffer, this._bodyBuffer + bufOffset, 16);\r\n const index = i * 16;\r\n\r\n for (let mi = 0; mi < 15; mi++) {\r\n if ((mi & 3) != 3) {\r\n matrixData[index + mi] = transformBuffer[mi];\r\n }\r\n }\r\n matrixData[index + 15] = 1;\r\n }\r\n m.thinInstanceBufferUpdated(\"matrix\");\r\n } else {\r\n try {\r\n // regular\r\n const bodyTransform = this._hknp.HP_Body_GetQTransform(body._pluginData.hpBodyId)[1];\r\n const bodyTranslation = bodyTransform[0];\r\n const bodyOrientation = bodyTransform[1];\r\n const quat = TmpVectors.Quaternion[0];\r\n\r\n quat.set(bodyOrientation[0], bodyOrientation[1], bodyOrientation[2], bodyOrientation[3]);\r\n\r\n const parent = transformNode.parent as TransformNode;\r\n // transform position/orientation in parent space\r\n if (parent && parent.absoluteRotationQuaternion) {\r\n TmpVectors.Vector3[2].set(bodyTranslation[0], bodyTranslation[1], bodyTranslation[2]);\r\n parent.absoluteRotationQuaternion.conjugateToRef(TmpVectors.Quaternion[1]);\r\n quat.multiplyInPlace(TmpVectors.Quaternion[1]);\r\n TmpVectors.Vector3[2].subtractToRef(parent.absolutePosition, TmpVectors.Vector3[0]);\r\n const localPosition = TmpVectors.Vector3[1];\r\n TmpVectors.Vector3[0].rotateByQuaternionToRef(TmpVectors.Quaternion[1], localPosition);\r\n transformNode.position.set(localPosition.x, localPosition.y, localPosition.z); // use set so position._isDirty is true\r\n } else {\r\n transformNode.position.set(bodyTranslation[0], bodyTranslation[1], bodyTranslation[2]);\r\n }\r\n\r\n if (transformNode.rotationQuaternion) {\r\n transformNode.rotationQuaternion.copyFrom(quat);\r\n } else {\r\n quat.toEulerAnglesToRef(transformNode.rotation);\r\n }\r\n } catch (e) {\r\n console.log(`Syncing transform failed for node ${transformNode.name}: ${e.message}...`);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Sets the shape of a physics body.\r\n * @param body - The physics body to set the shape for.\r\n * @param shape - The physics shape to set.\r\n *\r\n * This function is used to set the shape of a physics body. It is useful for\r\n * creating a physics body with a specific shape, such as a box or a sphere,\r\n * which can then be used to simulate physical interactions in a physics engine.\r\n * This function is especially useful for meshes with multiple instances, as it\r\n * will set the shape for each instance of the mesh.\r\n */\r\n public setShape(body: PhysicsBody, shape: Nullable<PhysicsShape>): void {\r\n const shapeHandle = shape && shape._pluginData ? shape._pluginData : BigInt(0);\r\n if (!(body.transformNode instanceof Mesh) || !body.transformNode._thinInstanceDataStorage?.matrixData) {\r\n this._hknp.HP_Body_SetShape(body._pluginData.hpBodyId, shapeHandle);\r\n this._internalUpdateMassProperties(body._pluginData);\r\n return;\r\n }\r\n const m = body.transformNode as Mesh;\r\n const instancesCount = m._thinInstanceDataStorage?.instancesCount ?? 0;\r\n for (let i = 0; i < instancesCount; i++) {\r\n this._hknp.HP_Body_SetShape(body._pluginDataInstances[i].hpBodyId, shapeHandle);\r\n this._internalUpdateMassProperties(body._pluginDataInstances[i]);\r\n }\r\n }\r\n\r\n /**\r\n * Returns a reference to the first instance of the plugin data for a physics body.\r\n * @param body\r\n * @param instanceIndex\r\n * @returns a reference to the first instance\r\n */\r\n private _getPluginReference(body: PhysicsBody, instanceIndex?: number): BodyPluginData {\r\n return body._pluginDataInstances?.length ? body._pluginDataInstances[instanceIndex ?? 0] : body._pluginData;\r\n }\r\n\r\n /**\r\n * Gets the shape of a physics body. This will create a new shape object\r\n *\r\n * @param body - The physics body.\r\n * @returns The shape of the physics body.\r\n *\r\n */\r\n public getShape(body: PhysicsBody): Nullable<PhysicsShape> {\r\n const pluginRef = this._getPluginReference(body);\r\n const shapePluginData = this._hknp.HP_Body_GetShape(pluginRef.hpBodyId)[1];\r\n if (shapePluginData != 0) {\r\n const scene = body.transformNode.getScene();\r\n return new PhysicsShape({ pluginData: shapePluginData }, scene);\r\n }\r\n return null;\r\n }\r\n\r\n /**\r\n * Gets the type of a physics shape.\r\n * @param shape - The physics shape to get the type for.\r\n * @returns The type of the physics shape.\r\n *\r\n */\r\n public getShapeType(shape: PhysicsShape): PhysicsShapeType {\r\n if (shape.type) {\r\n return shape.type;\r\n } else {\r\n //<todo This returns a native type!\r\n return this._hknp.HP_Shape_GetType(shape._pluginData);\r\n }\r\n }\r\n\r\n /**\r\n * Sets the event mask of a physics body.\r\n * @param body - The physics body to set the event mask for.\r\n * @param eventMask - The event mask to set.\r\n *\r\n * This function is useful for setting the event mask of a physics body, which is used to determine which events the body will respond to. This is important for ensuring that the physics engine is able to accurately simulate the behavior of the body in the game world.\r\n */\r\n public setEventMask(body: PhysicsBody, eventMask: number, instanceIndex?: number): void {\r\n this._applyToBodyOrInstances(\r\n body,\r\n (bodyPluginData) => {\r\n this._hknp.HP_Body_SetEventMask(bodyPluginData.hpBodyId, eventMask);\r\n },\r\n instanceIndex\r\n );\r\n }\r\n\r\n /**\r\n * Retrieves the event mask of a physics body.\r\n *\r\n * @param body - The physics body to retrieve the event mask from.\r\n * @returns The event mask of the physics body.\r\n *\r\n */\r\n public getEventMask(body: PhysicsBody, instanceIndex?: number): number {\r\n const pluginRef = this._getPluginReference(body, instanceIndex);\r\n return this._hknp.HP_Body_GetEventMask(pluginRef)[1];\r\n }\r\n\r\n private _fromMassPropertiesTuple(massPropsTuple: any[]): PhysicsMassProperties {\r\n return {\r\n centerOfMass: Vector3.FromArray(massPropsTuple[0]),\r\n mass: massPropsTuple[1],\r\n inertia: Vector3.FromArray(massPropsTuple[2]),\r\n inertiaOrientation: Quaternion.FromArray(massPropsTuple[3]),\r\n };\r\n }\r\n\r\n private _internalUpdateMassProperties(pluginData: BodyPluginData) {\r\n // Recompute the mass based on the shape\r\n const newProps = this._internalComputeMassProperties(pluginData);\r\n const massProps = pluginData.userMassProps;\r\n\r\n // Override the computed values with any the user has set\r\n if (massProps.centerOfMass) {\r\n newProps[0] = massProps.centerOfMass.asArray();\r\n }\r\n if (massProps.mass != undefined) {\r\n newProps[1] = massProps.mass;\r\n }\r\n if (massProps.inertia) {\r\n newProps[2] = massProps.inertia.asArray();\r\n }\r\n if (massProps.inertiaOrientation) {\r\n newProps[3] = massProps.inertiaOrientation.asArray();\r\n }\r\n this._hknp.HP_Body_SetMassProperties(pluginData.hpBodyId, newProps);\r\n }\r\n\r\n public _internalSetMotionType(pluginData: BodyPluginData, motionType: PhysicsMotionType): void {\r\n switch (motionType) {\r\n case PhysicsMotionType.STATIC:\r\n this._hknp.HP_Body_SetMotionType(pluginData.hpBodyId, this._hknp.MotionType.STATIC);\r\n break;\r\n case PhysicsMotionType.ANIMATED:\r\n this._hknp.HP_Body_SetMotionType(pluginData.hpBodyId, this._hknp.MotionType.KINEMATIC);\r\n break;\r\n case PhysicsMotionType.DYNAMIC:\r\n this._hknp.HP_Body_SetMotionType(pluginData.hpBodyId, this._hknp.MotionType.DYNAMIC);\r\n break;\r\n }\r\n }\r\n\r\n public setMotionType(body: PhysicsBody, motionType: PhysicsMotionType, instanceIndex?: number): void {\r\n this._applyToBodyOrInstances(\r\n body,\r\n (pluginData) => {\r\n this._internalSetMotionType(pluginData, motionType);\r\n },\r\n instanceIndex\r\n );\r\n }\r\n\r\n public getMotionType(body: PhysicsBody, instanceIndex?: number): PhysicsMotionType {\r\n const pluginRef = this._getPluginReference(body, instanceIndex);\r\n const type = this._hknp.HP_Body_GetMotionType(pluginRef.hpBodyId)[1];\r\n switch (type) {\r\n case this._hknp.MotionType.STATIC:\r\n return PhysicsMotionType.STATIC;\r\n case this._hknp.MotionType.KINEMATIC:\r\n return PhysicsMotionType.ANIMATED;\r\n case this._hknp.MotionType.DYNAMIC:\r\n return PhysicsMotionType.DYNAMIC;\r\n }\r\n throw new Error(\"Unknown motion type: \" + type);\r\n }\r\n\r\n private _internalComputeMassProperties(pluginData: BodyPluginData): any[] {\r\n const shapeRes = this._hknp.HP_Body_GetShape(pluginData.hpBodyId);\r\n if (shapeRes[0] == this._hknp.Result.RESULT_OK) {\r\n const shapeMass = this._hknp.HP_Shape_BuildMassProperties(shapeRes[1]);\r\n if (shapeMass[0] == this._hknp.Result.RESULT_OK) {\r\n return shapeMass[1];\r\n }\r\n }\r\n\r\n // Failed; return a unit inertia\r\n return [[0, 0, 0], 1, [1, 1, 1], [0, 0, 0, 1]];\r\n }\r\n\r\n /**\r\n * Computes the mass properties of a physics body, from it's shape\r\n *\r\n * @param body - The physics body to copmute the mass properties of\r\n */\r\n public computeMassProperties(body: PhysicsBody, instanceIndex?: number): PhysicsMassProperties {\r\n const pluginRef = this._getPluginReference(body, instanceIndex);\r\n const computed = this._internalComputeMassProperties(pluginRef);\r\n return this._fromMassPropertiesTuple(computed);\r\n }\r\n\r\n /**\r\n * Sets the mass properties of a physics body.\r\n *\r\n * @param body - The physics body to set the mass properties of.\r\n * @param massProps - The mass properties to set.\r\n * @param instanceIndex - The index of the instance to set the mass properties of. If undefined, the mass properties of all the bodies will be set.\r\n * This function is useful for setting the mass properties of a physics body,\r\n * such as its mass, inertia, and center of mass. This is important for\r\n * accurately simulating the physics of the body in the physics engine.\r\n *\r\n */\r\n public setMassProperties(body: PhysicsBody, massProps: PhysicsMassProperties, instanceIndex?: number): void {\r\n this._applyToBodyOrInstances(\r\n body,\r\n (pluginData) => {\r\n pluginData.userMassProps = massProps;\r\n this._internalUpdateMassProperties(pluginData);\r\n },\r\n instanceIndex\r\n );\r\n }\r\n /**\r\n *\r\n */\r\n public getMassProperties(body: PhysicsBody, instanceIndex?: number): PhysicsMassProperties {\r\n const pluginRef = this._getPluginReference(body, instanceIndex);\r\n const massPropsTuple = this._hknp.HP_Body_GetMassProperties(pluginRef.hpBodyId)[1];\r\n return this._fromMassPropertiesTuple(massPropsTuple);\r\n }\r\n\r\n /**\r\n * Sets the linear damping of the given body.\r\n * @param body - The body to set the linear damping for.\r\n * @param damping - The linear damping to set.\r\n *\r\n * This method is useful for controlling the linear damping of a body in a physics engine.\r\n * Linear damping is a force that opposes the motion of the body, and is proportional to the velocity of the body.\r\n * This method allows the user to set the linear damping of a body, which can be used to control the motion of the body.\r\n */\r\n public setLinearDamping(body: PhysicsBody, damping: number, instanceIndex?: number): void {\r\n this._applyToBodyOrInstances(\r\n body,\r\n (pluginData) => {\r\n this._hknp.HP_Body_SetLinearDamping(pluginData.hpBodyId, damping);\r\n },\r\n instanceIndex\r\n );\r\n }\r\n\r\n /**\r\n * Gets the linear damping of the given body.\r\n * @param body - The body to get the linear damping from.\r\n * @returns The linear damping of the given body.\r\n *\r\n * This method is useful for getting the linear damping of a body in a physics engine.\r\n * Linear damping is a force that opposes the motion of the body and is proportional to the velocity of the body.\r\n * It is used to simulate the effects of air resistance and other forms of friction.\r\n */\r\n public getLinearDamping(body: PhysicsBody, instanceIndex?: number): number {\r\n const pluginRef = this._getPluginReference(body, instanceIndex);\r\n return this._hknp.HP_Body_GetLinearDamping(pluginRef.hpBodyId)[1];\r\n }\r\n\r\n /**\r\n * Sets the angular damping of a physics body.\r\n * @param body - The physics body to set the angular damping for.\r\n * @param damping - The angular damping value to set.\r\n *\r\n * This function is useful for controlling the angular velocity of a physics body.\r\n * By setting the angular damping, the body's angular velocity will be reduced over time, allowing for more realistic physics simulations.\r\n */\r\n public setAngularDamping(body: PhysicsBody, damping: number, instanceIndex?: number): void {\r\n this._applyToBodyOrInstances(\r\n body,\r\n (pluginData) => {\r\n this._hknp.HP_Body_SetAngularDamping(pluginData.hpBodyId, damping);\r\n },\r\n instanceIndex\r\n );\r\n }\r\n\r\n /**\r\n * Gets the angular damping of a physics body.\r\n * @param body - The physics body to get the angular damping from.\r\n * @returns The angular damping of the body.\r\n *\r\n * This function is useful for retrieving the angular damping of a physics body,\r\n * which is used to control the rotational motion of the body. The angular damping is a value between 0 and 1, where 0 is no damping and 1 is full damping.\r\n */\r\n public getAngularDamping(body: PhysicsBody, instanceIndex?: number): number {\r\n const pluginRef = this._getPluginReference(body, instanceIndex);\r\n return this._hknp.HP_Body_GetAngularDamping(pluginRef.hpBodyId)[1];\r\n }\r\n\r\n /**\r\n * Sets the linear velocity of a physics body.\r\n * @param body - The physics body to set the linear velocity of.\r\n * @param linVel - The linear velocity to set.\r\n *\r\n * This function is useful for setting the linear velocity of a physics body, which is necessary for simulating\r\n * motion in a physics engine. The linear velocity is the speed and direction of the body's movement.\r\n */\r\n public setLinearVelocity(body: PhysicsBody, linVel: Vector3, instanceIndex?: number): void {\r\n this._applyToBodyOrInstances(\r\n body,\r\n (pluginData) => {\r\n this._hknp.HP_Body_SetLinearVelocity(pluginData.hpBodyId, this._bVecToV3(linVel));\r\n },\r\n instanceIndex\r\n );\r\n }\r\n\r\n /**\r\n * Gets the linear velocity of a physics body and stores it in a given vector.\r\n * @param body - The physics body to get the linear velocity from.\r\n * @param linVel - The vector to store the linear velocity in.\r\n *\r\n * This function is useful for retrieving the linear velocity of a physics body,\r\n * which can be used to determine the speed and direction of the body. This\r\n * information can be used to simulate realistic physics behavior in a game.\r\n */\r\n public getLinearVelocityToRef(body: PhysicsBody, linVel: Vector3, instanceIndex?: number): void {\r\n const pluginRef = this._getPluginReference(body, instanceIndex);\r\n const lv = this._hknp.HP_Body_GetLinearVelocity(pluginRef.hpBodyId)[1];\r\n this._v3ToBvecRef(lv, linVel);\r\n }\r\n\r\n /*\r\n * Apply an operation either to all instances of a body, if instanceIndex is not specified, or to a specific instance.\r\n */\r\n private _applyToBodyOrInstances(body: PhysicsBody, fnToApply: (pluginRef: any) => void, instanceIndex?: number): void {\r\n if (body._pluginDataInstances?.length > 0 && instanceIndex === undefined) {\r\n for (let i = 0; i < body._pluginDataInstances.length; i++) {\r\n fnToApply(body._pluginDataInstances[i]);\r\n }\r\n } else {\r\n fnToApply(this._getPluginReference(body, instanceIndex));\r\n }\r\n }\r\n\r\n /**\r\n * Applies an impulse to a physics body at a given location.\r\n * @param body - The physics body to apply the impulse to.\r\n * @param impulse - The impulse vector to apply.\r\n * @param location - The location in world space to apply the impulse.\r\n * @param instanceIndex - The index of the instance to apply the impulse to. If not specified, the impulse will be applied to all instances.\r\n *\r\n * This method is useful for applying an impulse to a physics body at a given location.\r\n * This can be used to simulate physical forces such as explosions, collisions, and gravity.\r\n */\r\n public applyImpulse(body: PhysicsBody, impulse: Vector3, location: Vector3, instanceIndex?: number): void {\r\n this._applyToBodyOrInstances(\r\n body,\r\n (pluginRef) => {\r\n this._hknp.HP_Body_ApplyImpulse(pluginRef.hpBodyId, this._bVecToV3(location), this._bVecToV3(impulse));\r\n },\r\n instanceIndex\r\n );\r\n }\r\n\r\n /**\r\n * Applies a force to a physics body at a given location.\r\n * @param body - The physics body to apply the impulse to.\r\n * @param force - The force vector to apply.\r\n * @param location - The location in world space to apply the impulse.\r\n * @param instanceIndex - The index of the instance to apply the force to. If not specified, the force will be applied to all instances.\r\n *\r\n * This method is useful for applying a force to a physics body at a given location.\r\n * This can be used to simulate physical forces such as explosions, collisions, and gravity.\r\n */\r\n public applyForce(body: PhysicsBody, force: Vector3, location: Vector3, instanceIndex?: number): void {\r\n force.scaleToRef(this.getTimeStep(), this._tmpVec3[0]);\r\n this.applyImpulse(body, this._tmpVec3[0], location, instanceIndex);\r\n }\r\n\r\n /**\r\n * Sets the angular velocity of a physics body.\r\n *\r\n * @param body - The physics body to set the angular velocity of.\r\n * @param angVel - The angular velocity to set.\r\n *\r\n * This function is useful for setting the angular velocity of a physics body in a physics engine.\r\n * This allows for more realistic simulations of physical objects, as they can be given a rotational velocity.\r\n */\r\n public setAngularVelocity(body: PhysicsBody, angVel: Vector3, instanceIndex?: number): void {\r\n this._applyToBodyOrInstances(\r\n body,\r\n (pluginRef) => {\r\n this._hknp.HP_Body_SetAngularVelocity(pluginRef.hpBodyId, this._bVecToV3(angVel));\r\n },\r\n instanceIndex\r\n );\r\n }\r\n\r\n /**\r\n * Gets the angular velocity of a body.\r\n * @param body - The body to get the angular velocity from.\r\n * @param angVel - The vector3 to store the angular velocity.\r\n *\r\n * This method is useful for getting the angular velocity of a body in a physics engine. It\r\n * takes the body and a vector3 as parameters and stores the angular velocity of the body\r\n * in the vector3. This is useful for getting the angular velocity of a body in order to\r\n * calculate the motion of the body in the physics engine.\r\n */\r\n public getAngularVelocityToRef(body: PhysicsBody, angVel: Vector3, instanceIndex?: number): void {\r\n const pluginRef = this._getPluginReference(body, instanceIndex);\r\n const av = this._hknp.HP_Body_GetAngularVelocity(pluginRef.hpBodyId)[1];\r\n this._v3ToBvecRef(av, angVel);\r\n }\r\n\r\n /**\r\n * Sets the transformation of the given physics body to the given transform node.\r\n * @param body The physics body to set the transformation for.\r\n * @param node The transform node to set the transformation from.\r\n * Sets the transformation of the given physics body to the given transform node.\r\n *\r\n * This function is useful for setting the transformation of a physics body to a\r\n * transform node, which is necessary for the physics engine to accurately simulate\r\n * the motion of the body. It also takes into account instances of the transform\r\n * node, which is necessary for accurate simulation of multiple bodies with the\r\n * same transformation.\r\n */\r\n public setPhysicsBodyTransformation(body: PhysicsBody, node: TransformNode) {\r\n const transformNode = body.transformNode;\r\n if (body.numInstances > 0) {\r\n // instances\r\n const m = transformNode as Mesh;\r\n const matrixData = m._thinInstanceDataStorage.matrixData;\r\n if (!matrixData) {\r\n return; // TODO: error handling\r\n }\r\n const instancesCount = body.numInstances;\r\n this._createOrUpdateBodyInstances(body, body.getMotionType(), matrixData, 0, instancesCount, true);\r\n } else {\r\n // regular\r\n this._hknp.HP_Body_SetQTransform(body._pluginData.hpBodyId, this._getTransformInfos(node));\r\n }\r\n }\r\n\r\n /**\r\n * Sets the gravity factor of a body\r\n * @param body the physics body to set the gravity factor for\r\n * @param factor the gravity factor\r\n * @param instanceIndex the index of the instance in an instanced body\r\n */\r\n public setGravityFactor(body: PhysicsBody, factor: number, instanceIndex?: number): void {\r\n this._applyToBodyOrInstances(\r\n body,\r\n (pluginRef) => {\r\n this._hknp.HP_Body_SetGravityFactor(pluginRef.hpBodyId, factor);\r\n },\r\n instanceIndex\r\n );\r\n }\r\n\r\n /**\r\n * Get the gravity factor of a body\r\n * @param body the physics body to get the gravity factor from\r\n * @param instanceIndex the index of the instance in an instanced body. If not specified, the gravity factor of the first instance will be returned.\r\n * @returns the gravity factor\r\n */\r\n public getGravityFactor(body: PhysicsBody, instanceIndex?: number): number {\r\n const pluginRef = this._getPluginReference(body, instanceIndex);\r\n return this._hknp.HP_Body_GetGravityFactor(pluginRef.hpBodyId)[1];\r\n }\r\n\r\n /**\r\n * Disposes a physics body.\r\n *\r\n * @param body - The physics body to dispose.\r\n *\r\n * This method is useful for releasing the resources associated with a physics body when it is no longer needed.\r\n * This is important for avoiding memory leaks in the physics engine.\r\n */\r\n public disposeBody(body: PhysicsBody): void {\r\n if (body._pluginDataInstances && body._pluginDataInstances.length > 0) {\r\n for (const instance of body._pluginDataInstances) {\r\n this._hknp.HP_Body_Release(instance.hpBodyId);\r\n instance.hpBodyId = undefined;\r\n }\r\n }\r\n if (body._pluginData) {\r\n this._hknp.HP_Body_Release(body._pluginData.hpBodyId);\r\n body._pluginData.hpBodyId = undefined;\r\n }\r\n }\r\n\r\n /**\r\n * Initializes a physics shape with the given type and parameters.\r\n * @param shape - The physics shape to initialize.\r\n * @param type - The type of shape to initialize.\r\n * @param options - The parameters for the shape.\r\n *\r\n * This code is useful for initializing a physics shape with the given type and parameters.\r\n * It allows for the creation of a sphere, box, capsule, container, cylinder, mesh, and heightfield.\r\n * Depending on the type of shape, different parameters are required.\r\n * For example, a sphere requires a radius, while a box requires extents and a rotation.\r\n */\r\n public initShape(shape: PhysicsShape, type: PhysicsShapeType, options: PhysicsShapeParameters): void {\r\n switch (type) {\r\n case PhysicsShapeType.SPHERE:\r\n {\r\n const radius = options.radius || 1;\r\n const center = options.center ? this._bVecToV3(options.center) : [0, 0, 0];\r\n shape._pluginData = this._hknp.HP_Shape_CreateSphere(center, radius)[1];\r\n }\r\n break;\r\n case PhysicsShapeType.BOX:\r\n {\r\n const rotation = options.rotation ? this._bQuatToV4(options.rotation) : [0, 0, 0, 1];\r\n const extent = options.extents ? this._bVecToV3(options.extents) : [1, 1, 1];\r\n const center = options.center ? this._bVecToV3(options.center) : [0, 0, 0];\r\n shape._pluginData = this._hknp.HP_Shape_CreateBox(center, rotation, extent)[1];\r\n }\r\n break;\r\n case PhysicsShapeType.CAPSULE:\r\n {\r\n const pointA = options.pointA ? this._bVecToV3(options.pointA) : [0, 0, 0];\r\n const pointB = options.pointB ? this._bVecToV3(options.pointB) : [0, 1, 0];\r\n const radius = options.radius || 0;\r\n shape._pluginData = this._hknp.HP_Shape_CreateCapsule(pointA, pointB, radius)[1];\r\n }\r\n break;\r\n case PhysicsShapeType.CONTAINER:\r\n {\r\n shape._pluginData = this._hknp.HP_Shape_CreateContainer()[1];\r\n }\r\n break;\r\n case PhysicsShapeType.CYLINDER:\r\n {\r\n const pointA = options.pointA ? this._bVecToV3(options.pointA) : [0, 0, 0];\r\n const pointB = options.pointB ? this._bVecToV3(options.pointB) : [0, 1, 0];\r\n const radius = options.radius || 0;\r\n shape._pluginData = this._hknp.HP_Shape_CreateCylinder(pointA, pointB, radius)[1];\r\n }\r\n break;\r\n case PhysicsShapeType.CONVEX_HULL:\r\n case PhysicsShapeType.MESH:\r\n {\r\n const mesh = options.mesh;\r\n if (mesh) {\r\n const includeChildMeshes = !!options.includeChildMeshes;\r\n const needIndices = type != PhysicsShapeType.CONVEX_HULL;\r\n const accum = new MeshAccumulator(mesh, needIndices, mesh?.getScene());\r\n accum.addMesh(mesh, includeChildMeshes);\r\n\r\n const positions = accum.getVertices(this._hknp);\r\n const numVec3s = positions.length / 3;\r\n\r\n if (type == PhysicsShapeType.CONVEX_HULL) {\r\n shape._pluginData = this._hknp.HP_Shape_CreateConvexHull(positions.byteOffset, numVec3s)[1];\r\n } else {\r\n const triangles = accum.getTriangles(this._hknp);\r\n const numTriangles = triangles.length / 3;\r\n shape._pluginData = this._hknp.HP_Shape_CreateMesh(positions.byteOffset, numVec3s, triangles.byteOffset, numTriangles)[1];\r\n accum.freeBuffer(this._hknp, triangles);\r\n }\r\n accum.freeBuffer(this._hknp, positions);\r\n } else {\r\n throw new Error(\"No mesh provided to create physics shape.\");\r\n }\r\n }\r\n break;\r\n default:\r\n throw new Error(\"Unsupported Shape Type.\");\r\n break;\r\n }\r\n }\r\n\r\n public setShapeFilterMembershipMask(shape: PhysicsShape, membershipMask: number): void {\r\n const collideWith = this._hknp.HP_Shape_GetFilterInfo(shape._pluginData)[1][1];\r\n this._hknp.HP_Shape_SetFilterInfo(shape._pluginData, [membershipMask, collideWith]);\r\n }\r\n\r\n public getShapeFilterMembershipMask(shape: PhysicsShape): number {\r\n return this._hknp.HP_Shape_GetFilterInfo(shape._pluginData)[1][0];\r\n }\r\n\r\n public setShapeFilterCollideMask(shape: PhysicsShape, collideMask: number): void {\r\n const membership = this._hknp.HP_Shape_GetFilterInfo(shape._pluginData)[1][0];\r\n this._hknp.HP_Shape_SetFilterInfo(shape._pluginData, [membership, collideMask]);\r\n }\r\n\r\n public getShapeFilterCollideMask(shape: PhysicsShape): number {\r\n return this._hknp.HP_Shape_GetFilterInfo(shape._pluginData)[1][1];\r\n }\r\n\r\n /**\r\n * Sets the material of a physics shape.\r\n * @param shape - The physics shape to set the material of.\r\n * @param material - The material to set.\r\n *\r\n */\r\n public setMaterial(shape: PhysicsShape, material: PhysicsMaterial): void {\r\n const dynamicFriction = material.friction ?? 0.5;\r\n const staticFriction = material.staticFriction ?? dynamicFriction;\r\n const restitution = material.restitution ?? 0.0;\r\n const frictionCombine = material.frictionCombine ?? PhysicsMaterialCombineMode.MINIMUM;\r\n const restitutionCombine = material.restitutionCombine ?? PhysicsMaterialCombineMode.MAXIMUM;\r\n\r\n const hpMaterial = [staticFriction, dynamicFriction, restitution, this._materialCombineToNative(frictionCombine), this._materialCombineToNative(restitutionCombine)];\r\n this._hknp.HP_Shape_SetMaterial(shape._pluginData, hpMaterial);\r\n }\r\n\r\n /**\r\n * Sets the density of a physics shape.\r\n * @param shape - The physics shape to set the density of.\r\n * @param density - The density to set.\r\n *\r\n */\r\n public setDensity(shape: PhysicsShape, density: number): void {\r\n this._hknp.HP_Shape_SetDensity(shape._pluginData, density);\r\n }\r\n\r\n /**\r\n * Calculates the density of a given physics shape.\r\n *\r\n * @param shape - The physics shape to calculate the density of.\r\n * @returns The density of the given physics shape.\r\n *\r\n */\r\n public getDensity(shape: PhysicsShape): number {\r\n return this._hknp.HP_Shape_GetDensity(shape._pluginData)[1];\r\n }\r\n\r\n /**\r\n * Gets the transform infos of a given transform node.\r\n * @param node - The transform node.\r\n * @returns An array containing the position and orientation of the node.\r\n * This code is useful for getting the position and orientation of a given transform node.\r\n * It first checks if the node has a rotation quaternion, and if not, it creates one from the node's rotation.\r\n * It then creates an array containing the position and orientation of the node and returns it.\r\n */\r\n private _getTransformInfos(node: TransformNode): any[] {\r\n if (node.parent) {\r\n node.computeWorldMatrix();\r\n return [this._bVecToV3(node.absolutePosition), this._bQuatToV4(node.absoluteRotationQuaternion)];\r\n }\r\n\r\n let orientation = TmpVectors.Quaternion[0];\r\n if (node.rotationQuaternion) {\r\n orientation = node.rotationQuaternion;\r\n } else {\r\n const r = node.rotation;\r\n Quaternion.FromEulerAnglesToRef(r.x, r.y, r.z, orientation);\r\n }\r\n const transform = [this._bVecToV3(node.position), this._bQuatToV4(orientation)];\r\n return transform;\r\n }\r\n\r\n /**\r\n * Adds a child shape to the given shape.\r\n * @param shape - The parent shape.\r\n * @param newChild - The child shape to add.\r\n * @param childTransform - The transform of the child shape relative to the parent shape.\r\n *\r\n */\r\n public addChild(shape: PhysicsShape, newChild: PhysicsShape, translation?: Vector3, rotation?: Quaternion, scale?: Vector3): void {\r\n const transformNative = [\r\n translation ? this._bVecToV3(translation) : [0, 0, 0],\r\n rotation ? this._bQuatToV4(rotation) : [0, 0, 0, 1],\r\n scale ? this._bVecToV3(scale) : [1, 1, 1],\r\n ];\r\n this._hknp.HP_Shape_AddChild(shape._pluginData, newChild._pluginData, transformNative);\r\n }\r\n\r\n /**\r\n * Removes a child shape from a parent shape.\r\n * @param shape - The parent shape.\r\n * @param childIndex - The index of the child shape to remove.\r\n *\r\n */\r\n public removeChild(shape: PhysicsShape, childIndex: number): void {\r\n this._hknp.HP_Shape_RemoveChild(shape._pluginData, childIndex);\r\n }\r\n\r\n /**\r\n * Returns the number of children of the given shape.\r\n *\r\n * @param shape - The shape to get the number of children from.\r\n * @returns The number of children of the given shape.\r\n *\r\n */\r\n public getNumChildren(shape: PhysicsShape): number {\r\n return this._hknp.HP_Shape_GetNumChildren(shape._pluginData)[1];\r\n }\r\n\r\n /**\r\n * Calculates the bounding box of a given physics shape.\r\n *\r\n * @param shape - The physics shape to calculate the bounding box for.\r\n * @returns The calculated bounding box.\r\n *\r\n * This method is useful for physics engines as it allows to calculate the\r\n * boundaries of a given shape. Knowing the boundaries of a shape is important\r\n * for collision detection and other physics calculations.\r\n */\r\n public getBoundingBox(shape: PhysicsShape): BoundingBox {\r\n return {} as BoundingBox;\r\n }\r\n\r\n /**\r\n * Gets the geometry of a physics body.\r\n *\r\n * @param body - The physics body.\r\n * @returns An object containing the positions and indices of the body's geometry.\r\n *\r\n */\r\n public getBodyGeometry(body: PhysicsBody) {\r\n const dataInfo = body._pluginDataInstances?.length > 0 ? body._pluginDataInstances[0] : body._pluginData;\r\n const shape = this._hknp.HP_Body_GetShape(dataInfo.hpBodyId)[1];\r\n const geometryRes = this._hknp.HP_Shape_CreateDebugDisplayGeometry(shape);\r\n\r\n if (geometryRes[0] != this._hknp.Result.RESULT_OK) {\r\n return { positions: [], indices: [] };\r\n }\r\n\r\n const geometryInfo = this._hknp.HP_DebugGeometry_GetInfo(geometryRes[1])[1];\r\n const positionsInPlugin = new Float32Array(this._hknp.HEAPU8.buffer, geometryInfo[0], geometryInfo[1] * 3); // 3 floats per position\r\n const indicesInPlugin = new Uint32Array(this._hknp.HEAPU8.buffer, geometryInfo[2], geometryInfo[3] * 3); // 3 indices per triangle\r\n\r\n // HP_DebugGeometry_Release will free the buffer in the plugin. To avoid a\r\n // use-after-free, we need to make a copy of the data here.\r\n const positions = positionsInPlugin.slice(0);\r\n const indices = indicesInPlugin.slice(0);\r\n this._hknp.HP_DebugGeometry_Release(geometryRes[1]);\r\n return { positions: positions, indices: indices };\r\n }\r\n\r\n /**\r\n * Releases a physics shape from the physics engine.\r\n *\r\n * @param shape - The physics shape to be released.\r\n * @returns void\r\n *\r\n * This method is useful for releasing a physics shape from the physics engine, freeing up resources and preventing memory leaks.\r\n */\r\n public disposeShape(shape: PhysicsShape): void {\r\n this._hknp.HP_Shape_Release(shape._pluginData);\r\n shape._pluginData = undefined;\r\n }\r\n\r\n // constraint\r\n\r\n /**\r\n * Initializes a physics constraint with the given parameters.\r\n *\r\n * @param constraint - The physics constraint to be initialized.\r\n * @param body - The main body\r\n * @param childBody - The child body.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to which the constraint will be applied. If not specified, no constraint will be applied.\r\n * @param childInstanceIndex - If the child body is instanced, the index of the instance to which the constraint will be applied. If not specified, no constraint will be applied.\r\n *\r\n * This function is useful for setting up a physics constraint in a physics engine.\r\n */\r\n public initConstraint(constraint: PhysicsConstraint, body: PhysicsBody, childBody: PhysicsBody, instanceIndex?: number, childInstanceIndex?: number): void {\r\n const type = constraint.type;\r\n const options = constraint.options;\r\n if (!type || !options) {\r\n Logger.Warn(\"No constraint type or options. Constraint is invalid.\");\r\n return;\r\n }\r\n if ((body._pluginDataInstances.length > 0 && instanceIndex === undefined) || (childBody._pluginDataInstances.length > 0 && childInstanceIndex === undefined)) {\r\n Logger.Warn(\"Body is instanced but no instance index was specified. Constraint will not be applied.\");\r\n return;\r\n }\r\n\r\n const jointId = this._hknp.HP_Constraint_Create()[1];\r\n constraint._pluginData = jointId;\r\n\r\n // body parenting\r\n const bodyA = this._getPluginReference(body, instanceIndex).hpBodyId;\r\n const bodyB = this._getPluginReference(childBody, childInstanceIndex).hpBodyId;\r\n this._hknp.HP_Constraint_SetParentBody(jointId, bodyA);\r\n this._hknp.HP_Constraint_SetChildBody(jointId, bodyB);\r\n\r\n // anchors\r\n const pivotA = options.pivotA ? this._bVecToV3(options.pivotA) : this._bVecToV3(Vector3.Zero());\r\n const axisA = options.axisA ?? new Vector3(1, 0, 0);\r\n const perpAxisA = this._tmpVec3[0];\r\n axisA?.getNormalToRef(perpAxisA);\r\n this._hknp.HP_Constraint_SetAnchorInParent(jointId, pivotA, this._bVecToV3(axisA), this._bVecToV3(perpAxisA));\r\n const pivotB = options.pivotB ? this._bVecToV3(options.pivotB) : this._bVecToV3(Vector3.Zero());\r\n const axisB = options.axisB ?? new Vector3(1, 0, 0);\r\n const perpAxisB = this._tmpVec3[0];\r\n axisB.getNormalToRef(perpAxisB);\r\n this._hknp.HP_Constraint_SetAnchorInChild(jointId, pivotB, this._bVecToV3(axisB), this._bVecToV3(perpAxisB));\r\n\r\n if (type == PhysicsConstraintType.LOCK) {\r\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.LINEAR_X, this._hknp.ConstraintAxisLimitMode.LOCKED);\r\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.LINEAR_Y, this._hknp.ConstraintAxisLimitMode.LOCKED);\r\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.LINEAR_Z, this._hknp.ConstraintAxisLimitMode.LOCKED);\r\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.ANGULAR_X, this._hknp.ConstraintAxisLimitMode.LOCKED);\r\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.ANGULAR_Y, this._hknp.ConstraintAxisLimitMode.LOCKED);\r\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.ANGULAR_Z, this._hknp.ConstraintAxisLimitMode.LOCKED);\r\n } else if (type == PhysicsConstraintType.DISTANCE) {\r\n const distance = options.maxDistance || 0;\r\n const dist3d = this._hknp.ConstraintAxis.LINEAR_DISTANCE;\r\n this._hknp.HP_Constraint_SetAxisMode(jointId, dist3d, this._hknp.ConstraintAxisLimitMode.LIMITED);\r\n this._hknp.HP_Constraint_SetAxisMinLimit(jointId, dist3d, distance);\r\n this._hknp.HP_Constraint_SetAxisMaxLimit(jointId, dist3d, distance);\r\n } else if (type == PhysicsConstraintType.HINGE) {\r\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.LINEAR_X, this._hknp.ConstraintAxisLimitMode.LOCKED);\r\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.LINEAR_Y, this._hknp.ConstraintAxisLimitMode.LOCKED);\r\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.LINEAR_Z, this._hknp.ConstraintAxisLimitMode.LOCKED);\r\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.ANGULAR_Y, this._hknp.ConstraintAxisLimitMode.LOCKED);\r\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.ANGULAR_Z, this._hknp.ConstraintAxisLimitMode.LOCKED);\r\n } else if (type == PhysicsConstraintType.PRISMATIC) {\r\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.LINEAR_Y, this._hknp.ConstraintAxisLimitMode.LOCKED);\r\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.LINEAR_Z, this._hknp.ConstraintAxisLimitMode.LOCKED);\r\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.ANGULAR_X, this._hknp.ConstraintAxisLimitMode.LOCKED);\r\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.ANGULAR_Y, this._hknp.ConstraintAxisLimitMode.LOCKED);\r\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.ANGULAR_Z, this._hknp.ConstraintAxisLimitMode.LOCKED);\r\n } else if (type == PhysicsConstraintType.SLIDER) {\r\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.LINEAR_Y, this._hknp.ConstraintAxisLimitMode.LOCKED);\r\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.LINEAR_Z, this._hknp.ConstraintAxisLimitMode.LOCKED);\r\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.ANGULAR_Y, this._hknp.ConstraintAxisLimitMode.LOCKED);\r\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.ANGULAR_Z, this._hknp.ConstraintAxisLimitMode.LOCKED);\r\n } else if (type == PhysicsConstraintType.BALL_AND_SOCKET) {\r\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.LINEAR_X, this._hknp.ConstraintAxisLimitMode.LOCKED);\r\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.LINEAR_Y, this._hknp.ConstraintAxisLimitMode.LOCKED);\r\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.LINEAR_Z, this._hknp.ConstraintAxisLimitMode.LOCKED);\r\n } else if (type == PhysicsConstraintType.SIX_DOF) {\r\n const sixdofData: Physics6DoFConstraint = <Physics6DoFConstraint>constraint;\r\n for (const l of sixdofData.limits) {\r\n const axId = this._constraintAxisToNative(l.axis);\r\n if ((l.minLimit ?? -1) == 0 && (l.maxLimit ?? -1) == 0) {\r\n this._hknp.HP_Constraint_SetAxisMode(jointId, axId, this._hknp.ConstraintAxisLimitMode.LOCKED);\r\n } else {\r\n if (l.minLimit != undefined) {\r\n this._hknp.HP_Constraint_SetAxisMode(jointId, axId, this._hknp.ConstraintAxisLimitMode.LIMITED);\r\n this._hknp.HP_Constraint_SetAxisMinLimit(jointId, axId, l.minLimit);\r\n }\r\n\r\n if (l.maxLimit != undefined) {\r\n this._hknp.HP_Constraint_SetAxisMode(jointId, axId, this._hknp.ConstraintAxisLimitMode.LIMITED);\r\n this._hknp.HP_Constraint_SetAxisMaxLimit(jointId, axId, l.maxLimit);\r\n }\r\n }\r\n }\r\n } else {\r\n throw new Error(\"Unsupported Constraint Type.\");\r\n }\r\n\r\n const collisionEnabled = !!options.collision;\r\n this._hknp.HP_Constraint_SetCollisionsEnabled(jointId, collisionEnabled);\r\n this._hknp.HP_Constraint_SetEnabled(jointId, true);\r\n }\r\n\r\n /**\r\n * Adds a constraint to the physics engine.\r\n *\r\n * @param body - The main body to which the constraint is applied.\r\n * @param childBody - The body to which the constraint is applied.\r\n * @param constraint - The constraint to be applied.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to which the constraint will be applied. If not specified, no constraint will be applied.\r\n * @param childInstanceIndex - If the child body is instanced, the index of the instance to which the constraint will be applied. If not specified, no constraint will be applied.\r\n */\r\n addConstraint(body: PhysicsBody, childBody: PhysicsBody, constraint: PhysicsConstraint, instanceIndex?: number, childInstanceIndex?: number): void {\r\n //<todo It's real weird that initConstraint() is called only after adding to a body!\r\n this.initConstraint(constraint, body, childBody, instanceIndex, childInstanceIndex);\r\n }\r\n\r\n /**\r\n * Enables or disables a constraint in the physics engine.\r\n * @param constraint - The constraint to enable or disable.\r\n * @param isEnabled - Whether the constraint should be enabled or disabled.\r\n *\r\n */\r\n public setEnabled(constraint: PhysicsConstraint, isEnabled: boolean): void {\r\n this._hknp.HP_Constraint_SetEnabled(constraint._pluginData, isEnabled);\r\n }\r\n\r\n /**\r\n * Gets the enabled state of the given constraint.\r\n * @param constraint - The constraint to get the enabled state from.\r\n * @returns The enabled state of the given constraint.\r\n *\r\n */\r\n public getEnabled(constraint: PhysicsConstraint): boolean {\r\n return this._hknp.HP_Constraint_GetEnabled(constraint._pluginData)[1];\r\n }\r\n\r\n /**\r\n * Enables or disables collisions for the given constraint.\r\n * @param constraint - The constraint to enable or disable collisions for.\r\n * @param isEnabled - Whether collisions should be enabled or disabled.\r\n *\r\n */\r\n public setCollisionsEnabled(constraint: PhysicsConstraint, isEnabled: boolean): void {\r\n this._hknp.HP_Constraint_SetCollisionsEnabled(constraint._pluginData, isEnabled);\r\n }\r\n\r\n /**\r\n * Gets whether collisions are enabled for the given constraint.\r\n * @param constraint - The constraint to get collisions enabled for.\r\n * @returns Whether collisions are enabled for the given constraint.\r\n *\r\n */\r\n public getCollisionsEnabled(constraint: PhysicsConstraint): boolean {\r\n return this._hknp.HP_Constraint_GetCollisionsEnabled(constraint._pluginData)[1];\r\n }\r\n\r\n /**\r\n * Sets the friction of the given axis of the given constraint.\r\n *\r\n * @param constraint - The constraint to set the friction of.\r\n * @param axis - The axis of the constraint to set the friction of.\r\n * @param friction - The friction to set.\r\n * @returns void\r\n *\r\n */\r\n public setAxisFriction(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis, friction: number): void {\r\n this._hknp.HP_Constraint_SetAxisFriction(constraint._pluginData, this._constraintAxisToNative(axis), friction);\r\n }\r\n\r\n /**\r\n * Gets the friction value of the specified axis of the given constraint.\r\n *\r\n * @param constraint - The constraint to get the axis friction from.\r\n * @param axis - The axis to get the friction from.\r\n * @returns The friction value of the specified axis.\r\n *\r\n */\r\n public getAxisFriction(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis): number {\r\n return this._hknp.HP_Constraint_GetAxisFriction(constraint._pluginData, this._constraintAxisToNative(axis))[1];\r\n }\r\n\r\n /**\r\n * Sets the limit mode of the specified axis of the given constraint.\r\n * @param constraint - The constraint to set the axis mode of.\r\n * @param axis - The axis to set the limit mode of.\r\n * @param limitMode - The limit mode to set.\r\n */\r\n public setAxisMode(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis, limitMode: PhysicsConstraintAxisLimitMode): void {\r\n this._hknp.HP_Constraint_SetAxisMode(constraint._pluginData, this._constraintAxisToNative(axis), this._limitModeToNative(limitMode));\r\n }\r\n\r\n /**\r\n * Gets the axis limit mode of the given constraint.\r\n *\r\n * @param constraint - The constraint to get the axis limit mode from.\r\n * @param axis - The axis to get the limit mode from.\r\n * @returns The axis limit mode of the given constraint.\r\n *\r\n */\r\n public getAxisMode(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis): PhysicsConstraintAxisLimitMode {\r\n const mode = this._hknp.HP_Constraint_GetAxisMode(constraint._pluginData, this._constraintAxisToNative(axis))[1];\r\n return this._nativeToLimitMode(mode);\r\n }\r\n\r\n /**\r\n * Sets the minimum limit of the given axis of the given constraint.\r\n * @param constraint - The constraint to set the minimum limit of.\r\n * @param axis - The axis to set the minimum limit of.\r\n * @param limit - The minimum limit to set.\r\n *\r\n */\r\n public setAxisMinLimit(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis, limit: number): void {\r\n this._hknp.HP_Constraint_SetAxisMinLimit(constraint._pluginData, this._constraintAxisToNative(axis), limit);\r\n }\r\n\r\n /**\r\n * Gets the minimum limit of the specified axis of the given constraint.\r\n * @param constraint - The constraint to get the minimum limit from.\r\n * @param axis - The axis to get the minimum limit from.\r\n * @returns The minimum limit of the specified axis of the given constraint.\r\n *\r\n */\r\n public getAxisMinLimit(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis): number {\r\n return this._hknp.HP_Constraint_GetAxisMinLimit(constraint._pluginData, this._constraintAxisToNative(axis))[1];\r\n }\r\n\r\n /**\r\n * Sets the maximum limit of the given axis of the given constraint.\r\n * @param constraint - The constraint to set the maximum limit of the given axis.\r\n * @param axis - The axis to set the maximum limit of.\r\n * @param limit - The maximum limit to set.\r\n *\r\n */\r\n public setAxisMaxLimit(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis, limit: number): void {\r\n this._hknp.HP_Constraint_SetAxisMaxLimit(constraint._pluginData, this._constraintAxisToNative(axis), limit);\r\n }\r\n\r\n /**\r\n * Gets the maximum limit of the given axis of the given constraint.\r\n *\r\n * @param constraint - The constraint to get the maximum limit from.\r\n * @param axis - The axis to get the maximum limit from.\r\n * @returns The maximum limit of the given axis of the given constraint.\r\n *\r\n */\r\n public getAxisMaxLimit(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis): number {\r\n return this._hknp.HP_Constraint_GetAxisMaxLimit(constraint._pluginData, this._constraintAxisToNative(axis))[1];\r\n }\r\n\r\n /**\r\n * Sets the motor type of the given axis of the given constraint.\r\n * @param constraint - The constraint to set the motor type of.\r\n * @param axis - The axis of the constraint to set the motor type of.\r\n * @param motorType - The motor type to set.\r\n * @returns void\r\n *\r\n */\r\n public setAxisMotorType(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis, motorType: PhysicsConstraintMotorType): void {\r\n this._hknp.HP_Constraint_SetAxisMotorType(constraint._pluginData, this._constraintAxisToNative(axis), this._constraintMotorTypeToNative(motorType));\r\n }\r\n\r\n /**\r\n * Gets the motor type of the specified axis of the given constraint.\r\n * @param constraint - The constraint to get the motor type from.\r\n * @param axis - The axis of the constraint to get the motor type from.\r\n * @returns The motor type of the specified axis of the given constraint.\r\n *\r\n */\r\n public getAxisMotorType(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis): PhysicsConstraintMotorType {\r\n return this._nativeToMotorType(this._hknp.HP_Constraint_GetAxisMotorType(constraint._pluginData, this._constraintAxisToNative(axis))[1]);\r\n }\r\n\r\n /**\r\n * Sets the target of an axis motor of a constraint.\r\n *\r\n * @param constraint - The constraint to set the axis motor target of.\r\n * @param axis - The axis of the constraint to set the motor target of.\r\n * @param target - The target of the axis motor.\r\n *\r\n */\r\n public setAxisMotorTarget(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis, target: number): void {\r\n this._hknp.HP_Constraint_SetAxisMotorTarget(constraint._pluginData, this._constraintAxisToNative(axis), target);\r\n }\r\n\r\n /**\r\n * Gets the target of the motor of the given axis of the given constraint.\r\n *\r\n * @param constraint - The constraint to get the motor target from.\r\n * @param axis - The axis of the constraint to get the motor target from.\r\n * @returns The target of the motor of the given axis of the given constraint.\r\n *\r\n */\r\n public getAxisMotorTarget(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis): number {\r\n return this._hknp.HP_Constraint_GetAxisMotorTarget(constraint._pluginData, this._constraintAxisToNative(axis))[1];\r\n }\r\n\r\n /**\r\n * Sets the maximum force that can be applied by the motor of the given constraint axis.\r\n * @param constraint - The constraint to set the motor max force for.\r\n * @param axis - The axis of the constraint to set the motor max force for.\r\n * @param maxForce - The maximum force that can be applied by the motor.\r\n *\r\n */\r\n public setAxisMotorMaxForce(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis, maxForce: number): void {\r\n this._hknp.HP_Constraint_SetAxisMotorMaxForce(constraint._pluginData, this._constraintAxisToNative(axis), maxForce);\r\n }\r\n\r\n /**\r\n * Gets the maximum force of the motor of the given constraint axis.\r\n *\r\n * @param constraint - The constraint to get the motor maximum force from.\r\n * @param axis - The axis of the constraint to get the motor maximum force from.\r\n * @returns The maximum force of the motor of the given constraint axis.\r\n *\r\n */\r\n public getAxisMotorMaxForce(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis): number {\r\n return this._hknp.HP_Constraint_GetAxisMotorMaxForce(constraint._pluginData, this._constraintAxisToNative(axis))[1];\r\n }\r\n\r\n /**\r\n * Disposes a physics constraint.\r\n *\r\n * @param constraint - The physics constraint to dispose.\r\n *\r\n * This method is useful for releasing the resources associated with a physics constraint, such as\r\n * the Havok constraint, when it is no longer needed. This is important for avoiding memory leaks.\r\n */\r\n public disposeConstraint(constraint: PhysicsConstraint): void {\r\n const jointId = constraint._pluginData;\r\n this._hknp.HP_Constraint_SetEnabled(jointId, false);\r\n this._hknp.HP_Constraint_Release(jointId);\r\n constraint._pluginData = undefined;\r\n }\r\n\r\n /**\r\n * Performs a raycast from a given start point to a given end point and stores the result in a given PhysicsRaycastResult object.\r\n *\r\n * @param from - The start point of the raycast.\r\n * @param to - The end point of the raycast.\r\n * @param result - The PhysicsRaycastResult object to store the result of the raycast.\r\n *\r\n * Performs a raycast. It takes in two points, from and to, and a PhysicsRaycastResult object to store the result of the raycast.\r\n * It then performs the raycast and stores the hit data in the PhysicsRaycastResult object.\r\n */\r\n public raycast(from: Vector3, to: Vector3, result: PhysicsRaycastResult): void {\r\n const queryMembership = ~0;\r\n const queryCollideWith = ~0;\r\n\r\n result.reset(from, to);\r\n\r\n const query = [this._bVecToV3(from), this._bVecToV3(to), [queryMembership, queryCollideWith]];\r\n this._hknp.HP_World_CastRayWithCollector(this.world, this._queryCollector, query);\r\n\r\n if (this._hknp.HP_QueryCollector_GetNumHits(this._queryCollector)[1] > 0) {\r\n const hitData = this._hknp.HP_QueryCollector_GetCastRayResult(this._queryCollector, 0)[1];\r\n\r\n const hitPos = hitData[1][3];\r\n const hitNormal = hitData[1][4];\r\n result.setHitData({ x: hitNormal[0], y: hitNormal[1], z: hitNormal[2] }, { x: hitPos[0], y: hitPos[1], z: hitPos[2] });\r\n result.calculateHitDistance();\r\n const hitBody = this._bodies.get(hitData[1][0][0]);\r\n result.body = hitBody?.body;\r\n result.bodyIndex = hitBody?.index;\r\n }\r\n }\r\n\r\n /**\r\n * Return the collision observable for a particular physics body.\r\n * @param body the physics body\r\n */\r\n public getCollisionObservable(body: PhysicsBody): Observable<IPhysicsCollisionEvent> {\r\n const bodyId = body._pluginData.hpBodyId[0];\r\n let observable = this._bodyCollisionObservable.get(bodyId);\r\n if (!observable) {\r\n observable = new Observable<IPhysicsCollisionEvent>();\r\n this._bodyCollisionObservable.set(bodyId, observable);\r\n }\r\n return observable;\r\n }\r\n\r\n /**\r\n * Enable collision to be reported for a body when a callback is settup on the world\r\n * @param body the physics body\r\n * @param enabled\r\n */\r\n public setCollisionCallbackEnabled(body: PhysicsBody, enabled: boolean): void {\r\n // Register for collide events by default\r\n const collideEvents = this._hknp.EventType.COLLISION_STARTED.value | this._hknp.EventType.COLLISION_CONTINUED.value | this._hknp.EventType.COLLISION_FINISHED.value;\r\n if (body._pluginDataInstances && body._pluginDataInstances.length) {\r\n body._pluginDataInstances.forEach((bodyId) => {\r\n this._hknp.HP_Body_SetEventMask(bodyId.hpBodyId, enabled ? collideEvents : 0);\r\n });\r\n } else if (body._pluginData) {\r\n this._hknp.HP_Body_SetEventMask(body._pluginData.hpBodyId, enabled ? collideEvents : 0);\r\n }\r\n }\r\n\r\n /**\r\n * Runs thru all detected collisions and filter by body\r\n */\r\n private _notifyCollisions() {\r\n let eventAddress = this._hknp.HP_World_GetCollisionEvents(this.world)[1];\r\n const event = new CollisionEvent();\r\n const worldAddr = Number(this.world);\r\n while (eventAddress) {\r\n CollisionEvent.readToRef(this._hknp.HEAPU8.buffer, eventAddress, event);\r\n event.contactOnB.position.subtractToRef(event.contactOnA.position, this._tmpVec3[0]);\r\n const distance = Vector3.Dot(this._tmpVec3[0], event.contactOnA.normal);\r\n const bodyInfoA = this._bodies.get(event.contactOnA.bodyId)!;\r\n const bodyInfoB = this._bodies.get(event.contactOnB.bodyId)!;\r\n const collisionInfo = {\r\n collider: bodyInfoA.body,\r\n colliderIndex: bodyInfoA.index,\r\n collidedAgainst: bodyInfoB.body,\r\n collidedAgainstIndex: bodyInfoB.index,\r\n point: event.contactOnA.position,\r\n distance: distance,\r\n impulse: event.impulseApplied,\r\n normal: event.contactOnA.normal,\r\n };\r\n this.onCollisionObservable.notifyObservers(collisionInfo);\r\n\r\n if (this._bodyCollisionObservable.size) {\r\n const observableA = this._bodyCollisionObservable.get(event.contactOnA.bodyId);\r\n const observableB = this._bodyCollisionObservable.get(event.contactOnB.bodyId);\r\n\r\n if (observableA) {\r\n observableA.notifyObservers(collisionInfo);\r\n } else if (observableB) {\r\n //<todo This seems like it would give unexpected results when both bodies have observers?\r\n // Flip collision info:\r\n collisionInfo.collider = bodyInfoB.body;\r\n collisionInfo.colliderIndex = bodyInfoB.index;\r\n collisionInfo.collidedAgainst = bodyInfoA.body;\r\n collisionInfo.collidedAgainstIndex = bodyInfoA.index;\r\n collisionInfo.normal = event.contactOnB.normal;\r\n observableB.notifyObservers(collisionInfo);\r\n }\r\n }\r\n\r\n eventAddress = this._hknp.HP_World_GetNextCollisionEvent(worldAddr, eventAddress);\r\n }\r\n }\r\n\r\n /**\r\n * Gets the number of bodies in the world\r\n */\r\n public get numBodies() {\r\n return this._hknp.HP_World_GetNumBodies(this.world)[1];\r\n }\r\n\r\n /**\r\n * Dispose the world and free resources\r\n */\r\n public dispose(): void {\r\n this._hknp.HP_QueryCollector_Release(this._queryCollector);\r\n this._queryCollector = BigInt(0);\r\n this._hknp.HP_World_Release(this.world);\r\n this.world = undefined;\r\n }\r\n\r\n private _v3ToBvecRef(v: any, vec3: Vector3): void {\r\n vec3.set(v[0], v[1], v[2]);\r\n }\r\n\r\n private _bVecToV3(v: any): any {\r\n return [v._x, v._y, v._z];\r\n }\r\n\r\n private _bQuatToV4(q: Quaternion): Array<number> {\r\n return [q._x, q._y, q._z, q._w];\r\n }\r\n\r\n private _constraintMotorTypeToNative(motorType: PhysicsConstraintMotorType): any {\r\n switch (motorType) {\r\n case PhysicsConstraintMotorType.POSITION:\r\n return this._hknp.ConstraintMotorType.POSITION;\r\n case PhysicsConstraintMotorType.VELOCITY:\r\n return this._hknp.ConstraintMotorType.VELOCITY;\r\n }\r\n return this._hknp.ConstraintMotorType.NONE;\r\n }\r\n\r\n private _nativeToMotorType(motorType: any): PhysicsConstraintMotorType {\r\n switch (motorType) {\r\n case this._hknp.ConstraintMotorType.POSITION:\r\n return PhysicsConstraintMotorType.POSITION;\r\n case this._hknp.ConstraintMotorType.VELOCITY:\r\n return PhysicsConstraintMotorType.VELOCITY;\r\n }\r\n return PhysicsConstraintMotorType.NONE;\r\n }\r\n\r\n private _materialCombineToNative(mat: PhysicsMaterialCombineMode): any {\r\n switch (mat) {\r\n case PhysicsMaterialCombineMode.GEOMETRIC_MEAN:\r\n return this._hknp.MaterialCombine.GEOMETRIC_MEAN;\r\n case PhysicsMaterialCombineMode.MINIMUM:\r\n return this._hknp.MaterialCombine.MINIMUM;\r\n case PhysicsMaterialCombineMode.MAXIMUM:\r\n return this._hknp.MaterialCombine.MAXIMUM;\r\n case PhysicsMaterialCombineMode.ARITHMETIC_MEAN:\r\n return this._hknp.MaterialCombine.ARITHMETIC_MEAN;\r\n case PhysicsMaterialCombineMode.MULTIPLY:\r\n return this._hknp.MaterialCombine.MULTIPLY;\r\n }\r\n }\r\n\r\n private _constraintAxisToNative(axId: PhysicsConstraintAxis): any {\r\n switch (axId) {\r\n case PhysicsConstraintAxis.LINEAR_X:\r\n return this._hknp.ConstraintAxis.LINEAR_X;\r\n case PhysicsConstraintAxis.LINEAR_Y:\r\n return this._hknp.ConstraintAxis.LINEAR_Y;\r\n case PhysicsConstraintAxis.LINEAR_Z:\r\n return this._hknp.ConstraintAxis.LINEAR_Z;\r\n case PhysicsConstraintAxis.ANGULAR_X:\r\n return this._hknp.ConstraintAxis.ANGULAR_X;\r\n case PhysicsConstraintAxis.ANGULAR_Y:\r\n return this._hknp.ConstraintAxis.ANGULAR_Y;\r\n case PhysicsConstraintAxis.ANGULAR_Z:\r\n return this._hknp.ConstraintAxis.ANGULAR_Z;\r\n case PhysicsConstraintAxis.LINEAR_DISTANCE:\r\n return this._hknp.ConstraintAxis.LINEAR_DISTANCE;\r\n }\r\n }\r\n\r\n private _nativeToLimitMode(mode: number): PhysicsConstraintAxisLimitMode {\r\n switch (mode) {\r\n case this._hknp.ConstraintAxisLimitMode.FREE:\r\n return PhysicsConstraintAxisLimitMode.FREE;\r\n case this._hknp.ConstraintAxisLimitMode.LIMITED:\r\n return PhysicsConstraintAxisLimitMode.LIMITED;\r\n case this._hknp.ConstraintAxisLimitMode.LOCKED:\r\n return PhysicsConstraintAxisLimitMode.LOCKED;\r\n }\r\n\r\n return PhysicsConstraintAxisLimitMode.FREE;\r\n }\r\n\r\n private _limitModeToNative(mode: PhysicsConstraintAxisLimitMode): any {\r\n switch (mode) {\r\n case PhysicsConstraintAxisLimitMode.FREE:\r\n return this._hknp.ConstraintAxisLimitMode.FREE;\r\n case PhysicsConstraintAxisLimitMode.LIMITED:\r\n return this._hknp.ConstraintAxisLimitMode.LIMITED;\r\n case PhysicsConstraintAxisLimitMode.LOCKED:\r\n return this._hknp.ConstraintAxisLimitMode.LOCKED;\r\n }\r\n }\r\n}\r\n"]}
|