How would I resize a box collider to fit new mesh info? [Brain's melted]

------------- MAIN POST STARTS HERE ------------------------------

Hey all,

Title says that my brain’s metled… that’s true.

Over last few days been learning and implementing the Sutherland-Hodgman clipping systems to slice meshes on the fly.

However, once I’ve split one object into two (each with half of the original mesh) I’m still left with a full original sized box collider ON BOTH OBJECTS.

How do I go about resizing this?

As I said, just finished learning this, and debugged the bug(ger) so I need a break, some caffeine, and (since this is a new aspect of the small project) some help…

------------- MAIN POST OVER------------------------------------
------------- FURTHER INFO STARTS HERE -----------------
FURTHER INFO:
When I’m slicing the objects I’m not changing the origin - so both objects have an off-center origin point. This leaves the object ‘floating’. Not sure how to adjust for this.

I was looking into ‘bounds’, but it says that they’re axis aligned so don’t think they will work, is that right?

I’ve tried deleting and re-adding the box colliders. However this produces a box collider with full scale size of 1, meaning it’s bigger than the new meshes.

POSSIBLE SOLUTION (please slap me if this was the solution all along):
Should I just run a script that finds that highest and lowest points of the mesh then realign the box colliders centre and size around this? (Of course would do the same for the width). Is there a better solution?

Concerned about overhead of my coding here, especially as slicing a primitive sphere or capsule is intesive enough as it is (full visual/input lockup for 2 seconds or so).

P.S. Sorry for the stinky post :frowning:

Have you tried calling Mesh.RecalculateBounds() on the new objects? Then re-creating the box colliders may work as you expect.

Hi @Edy - thanks for the reply.

Yeah I did, but… I’ve realised that I was screwing up the look of the triangles because was using each vertex for multiple DIFFERENT FACING triangles. Sorted that, so might try with the resizing/readding the colliders again.

In the meantime I’ve gotten around the issue with using a mesh collider. However when I start adding loads and loads of these simple slices meshes I’m going to start a resource issue. And when I tried a mesh collider with a sliced sphere and capsule it just wouldn’t do it.

But I will try the recalculate again now that I’ve sorted the looks a bit (no idea if this multiple use of verts would cause an issue, but it’d be good to sort an answer…)