Player placed object collision handling and transform snapping

Hoping I can have a conversation about some of the best methods for handling the snapping and collision of player placed objects. In my case, it is a base building system, floors, walls, all the usual stuff. I’m hoping I can explain what I’m doing, and some good folk can explain why it’s flawed and how I could do it better, I don’t need code, just a discussion on methods.

When placing build pieces, instead of using socket locations for snap transforms, I have instead listed my snap transforms in data tables. Trace line hits an object, we find that object in the data table, then find the closest of the transforms listed under that object. Snap the new build piece to that transform. Works a treat.

Now we have the problem that sometimes the build pieces will have small amounts of clipping when at their snap locations. Obviously we have collision detection to determine if they are viable to be placed, so I’ve created another data table with collision positions that should be ignored to allow the parts to be placed. Cant use the snap table, as sometimes a part may be snapped to one piece, but colliding with a different one. The snaps and collision exclusions differ.

Now some collisions are viable at any rotation, others at set rotations, this means I need to be checking the rotation of the piece matches the collision exclusion in the data table. Which in turn means that for some locations, there are now multiple entries to account for the viable rotations.

Basically the collision exclusion tables have become very large, which is becoming a lot to iterate through, and although it is all behind a do once call, I’m getting a few hitches here and there. There are occasions that a build piece, may be colliding with 3 or 4 other build pieces, meaning we now iterate through 3 or 4 rows in the table, each with an array of 100 + transforms, to see if the part is in a viable position or not.

I’m just about to scrap this approach, although it worked extremely well on a small scale, it’s not scaling well now that I have many different piece and snap locations. I’ll likely keep the snap locations in a data table, but the collision detection needs a rework.

I hope that all makes sense, if anyone can give any feedback on suitable direction to look at moving forward, it be grateful.