Skip to content

Commit

Permalink
Merge pull request #13054 from Popov72/pointerover-meshtest
Browse files Browse the repository at this point in the history
InputManager: add a property to disable mesh checking in the onPointerOver event
  • Loading branch information
sebavan authored Oct 3, 2022
2 parents d85572e + bba76d0 commit 959a743
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/dev/core/src/Inputs/scene.inputManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -951,7 +951,7 @@ export class InputManager {
* @param pickResult - optional pickingInfo data used to find mesh
*/
public setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId: number = 0, pickResult?: Nullable<PickingInfo>): void {
if (this._meshUnderPointerId[pointerId] === mesh) {
if (this._meshUnderPointerId[pointerId] === mesh && (!mesh || !mesh._internalAbstractMeshDataInfo._pointerOverDisableMeshTesting)) {
return;
}

Expand Down
14 changes: 14 additions & 0 deletions packages/dev/core/src/Meshes/abstractMesh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ class _InternalAbstractMeshDataInfo {
public _material: Nullable<Material> = null;
public _materialForRenderPass: Array<Material | undefined>; // map a render pass id (index in the array) to a Material
public _positions: Nullable<Vector3[]> = null;
public _pointerOverDisableMeshTesting: boolean = false;
// Collisions
public _meshCollisionData = new _MeshCollisionData();
public _enableDistantPicking = false;
Expand Down Expand Up @@ -438,6 +439,19 @@ export class AbstractMesh extends TransformNode implements IDisposable, ICullabl
*/
public enablePointerMoveEvents = false;

/**
* Gets or sets the property which disables the test that is checking that the mesh under the pointer is the same than the previous time we tested for it (default: false).
* Set this property to true if you want thin instances picking to be reported accurately when moving over the mesh.
* Note that setting this property to true will incur some performance penalties when dealing with pointer events for this mesh so use it sparingly.
*/
public get pointerOverDisableMeshTesting() {
return this._internalAbstractMeshDataInfo._pointerOverDisableMeshTesting;
}

public set pointerOverDisableMeshTesting(disable: boolean) {
this._internalAbstractMeshDataInfo._pointerOverDisableMeshTesting = disable;
}

/**
* Specifies the rendering group id for this mesh (0 by default)
* @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
Expand Down

0 comments on commit 959a743

Please sign in to comment.