MultiMaterial Solid Particle System Breaks Picking

When using a SolidParticleSystem with enableMultiMaterial = true, picking doesn’t work correctly when using .pickedParticles as a lookup.

https://www.babylonjs-playground.com/##FV07BC

I guess this is due to the sub meshes involved.

(If you set enableMultiMaterial: false in the above Playground, picking will work again).

Is there any temporary workaround for this?

Pinging @jerome

@jerome

As I needed to find a quick fix for this for my work, I came up with a solution by creating my own indices to particle lookup rather than using .pickedParticles.

This playground shows it working. The relevant comments start with // ***

https://www.babylonjs-playground.com/#P1D4TZ

After reading the code for SolidParticle I had to use the private variable particle._ind to achieve that, so I don’t think it’s a good solution.

sps.multiMaterialPickedParticle(pickingInfo) or something like that would be better.

1 Like

Amended version that will work with any shape. Using a Box to test

https://www.babylonjs-playground.com/#P1D4TZ#2

1 Like

Nice fix.
Well, you’re right, this feature doesn’t work correctly for MultiMaterials. I’ll have a look how to fix this, maybe this next week.

Working on it

[EDIT] done. Now, the fixing will work even with MultiMaterials by using the new method sps.pickedParticle(pickingInfo) returning {idx: number, faceId: number}
idx being the particle index
faceId being the picked face index within the particle geometry

PR soon

2 Likes