Allow raycasts to query real mesh geometry instead of the collision mesh

In the project I develop, to allow our players to customize their characters we use a painting system which relies on raycasting to detect which part the user clicks on. This benefits from PreciseConvexDecomposition to mitigate as many errors as possible with what people see vs. what raycasting hits in the in-experience character editor.

Naturally, models with high collision fidelity are not feasible for standard gameplay given that the combined triangle count often sits around or exceeds 10,000 triangles, so the game benefits from using lower collision qualities to assist with hit standard detection in the game during play-time. As a result of this, we have two models for every character - they are identical, save for the CollisionFidelity property of all included meshes. One model has Hull/Default, the other PreciseConvexDecomposition.

As a consequence of this design choice, the file size of the place becomes unnecessarily large. This has become such a problem that this solution now causes the place to exceed Roblox’s file size limit, making it flat out impossible to save to the cloud or publish. The high quality collision models take up about 60MB (edit: this is the total size of all 191 models’ collisions combined).

Being able to abandon these alternate collision qualities would be extremely useful as it would allow me to optimize models for gameplay without the drawbacks of poor raycast hit detection, and would ensure that the experience is suitable for users from both a quality and performance perspective simultaneously.

8 Likes

You’re describing a very particular proposed solution here and it might not be the only one to solve the problem. Another example solution may be a property you specify on raycasts to use the mesh data of objects in the scene directly rather than using the simplified representation for physics. This proposed solution would also have more applications where it could be useful.

Recommend to retitle your posts and introduction after the problem rather than the proposed solution. The problem being: you need to distinguish between the rendering mesh and the physics mesh of objects to accomplish certain gameplay features more easily.

4 Likes

Absolutely correct. I’ve made the necessary edits. I knew something felt a little off but I just didn’t really know how else to articulate a solution to what I wanted. This should help.

Hi there!
Would it be possible to get an example place with 60MB per model? This has us scratching our heads a bit since we did a quick calculation and for a 20K triangle mesh (which is the internal max triangle count per model) we expect in the worst case no more than 5Mb of collision data generated for precise collision geometry (and even this is a very loose upper bound on collision geometry size - basically you get it by assuming that for some reason you get one convex per one triangle of the mesh, which would be a super inefficient decomposition).

You may have misread - it’s 60MB for all the models in total, not per model. There are 191 models with varying amounts of polygons. I would get the number myself but I don’t think MeshPart has a property for triangle count. Would you still like the test place?

Edit: I’ve edited OP to make that more clear now.