Scene trianglePickingPredicate?

ok, this feels like a dumb question but I couldn’t find a neat solution somehow and beating against the wall leaves me even more tired.

repro: Babylon.js Playground

I have a large terrain (ie, the ground in repro). In my use case, pointermove drops my fps so by design, I made my ground not pickable by default and toggle it when needed. It works great. But pointermove now triggers when mousing over the occluded part of the sphere. So ideally, I’m looking to have renderOverlay only trigger when user mouse-over the unoccluded part of the sphere and still keep the ground not pickable. What mesh property can I use in the predicate ? Or is there a way for me to insert a custom trianglePredicate in the scene to filter out pickedPoint.y > 0?

1 Like

Your case is becoming pretty complex and I guess I would normally solve it by manually picking and such which can help with the trianglePredicate.

Or you could split your mesh in 2 to have on pickable and one unpickable part ?

3 Likes

PG: https://playground.babylonjs.com/#G8E6K3#1

Managed to get the trianglepicking predicate in, but the action manager doesn’t seem to recognize it. What should I do to get the action manager to use my pickinfo for triggering? Or do I have to ditch action managers and process everything in my own pointermove observable loop? If so, wouldn’t there be 2 pointermoves triggering in the scene every mouse move (bjs default+user custom)? Is there a way to switch the default off?

1 Like

Maybe in your custom picking you can register a boolean in your scene with true/false depending on your pick result and use this as your actions conditions.

After in you prefer to build your own custom code it might be simpler to manage and you should in this case not have overhead cause only the meshes with actionManager would go through the process.

1 Like

Like this ? https://playground.babylonjs.com/#G8E6K3#2

The trigger only ever fires once and its not firing with respect to the condition…hmm

1 Like

Writing it this way would make it better: https://playground.babylonjs.com/#G8E6K3#3

But it still wont be enough cause basically nothing will be checked as long as you do not truly go outside the full mesh.

So your best bet is full custom code which is by far simpler to write as well:
https://playground.babylonjs.com/#G8E6K3#6

1 Like

I want to avoid the custom code in the obs. When the number of spheres/objects grow, said custom code becomes monolithic very quickly. Hence the reason for action manager. I’m going to investigate if its worth a PR for scene.trianglePickingPredicate and modify pointerMove events in the input manager to take advantage of it.

ok, it works. added into scene.ts
public tpp: (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
modified inputmanager.ts this._onPointerMove

var pickResult;
if (!scene.tpp) {
	pickResult = scene.pick(this._unTranslatedPointerX, this._unTranslatedPointerY, scene.pointerMovePredicate, false, scene.cameraToUseForPointers);
} else {
	pickResult = scene.pick(this._unTranslatedPointerX, this._unTranslatedPointerY, scene.pointerMovePredicate, false, scene.cameraToUseForPointers, scene.tpp);
}

I think this is back compat? Now, the biggest question is: I don’t think tpp is the the best param name ever, so looking for suggestions ! And scene.ts already uses trianglePredicate and trianglePickingPredicate everywhere. What’s a better name than tpp? hmm…

I would call it pointerMoveTrianglePredicate and place it to undefined by default, so that you can remove the if in input manager :slight_smile:

1 Like

done and done…but lint failed and my eyes are not seeing where the problem is. I need a feature request for old people with bad eyes, automatic lint correction when PR.requester.eyes.age === "old".

edit: nvm, I found the magic command…ehehehe

Perfect thanks a lot @phaselock !!!

1 Like