richardbiely / Voxelmetric

An efficient voxel framework for Unity3d

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Voxelmetric.. did no one bother checking the mesh colliders :D

XeonG opened this issue · comments

commented

So a frustrating hour testing out somethings with unity the physics....Almost thought my project with this framework was a waste of time when the only thing that made the chunks collide-able was setting them to convex making those wonderful chunk mesh colliders completely pointless..

Well they are reversed, I flipped the gravity direction and everything that fell through suddenly collided on the underside of the mesh going up :D So that's good they do kinda work...

Hopefully not a big thing to fix.

commented

Wasn't so hard 🐼

In the cubemeshcolliderbuilder.cs .... mesh collisions seems to work now
`
/*
vecs[0] = new Vector3(x[0]+dv[0], x[1]+dv[1], x[2]+dv[2])-BlockUtils.HalfBlockVector;
vecs[1] = new Vector3(x[0]+du[0]+dv[0], x[1]+du[1]+dv[1], x[2]+du[2]+dv[2])-BlockUtils.HalfBlockVector;
vecs[2] = new Vector3(x[0]+du[0], x[1]+du[1], x[2]+du[2])-BlockUtils.HalfBlockVector;
vecs[3] = new Vector3(x[0], x[1], x[2])-BlockUtils.HalfBlockVector;
*/

                            vecs[0] = new Vector3(x[0],x[1],x[2]) - BlockUtils.HalfBlockVector;
                            vecs[1] = new Vector3(x[0] + du[0],x[1] + du[1],x[2] + du[2]) - BlockUtils.HalfBlockVector;
                            vecs[2] = new Vector3(x[0] + du[0] + dv[0],x[1] + du[1] + dv[1],x[2] + du[2] + dv[2]) - BlockUtils.HalfBlockVector;
                            vecs[3] = new Vector3(x[0] + dv[0],x[1] + dv[1],x[2] + dv[2]) - BlockUtils.HalfBlockVector;

`

You're right, the 4 vertices forming a face were built in a reverse order: 3,2,1,0 instead of 0,1,2,3.

I didn't have enough time to test it properly with physX but it seems to work just like before for me.
When I implemented colliders to Voxe(lmetric) I used a simple cube for testing. Had no issues so I considered them working.

For now, I'm not closing this issue until I can verify that it really fixes physX (which I won't be able to do sooner than the next week).

commented

yeah I actually didn't fully test it out myself.... I only tested the top side block faces on the terrain surface, and it seemed like the sides of block faces worked. I'll try again inside caves and see if the underside block faces are also providing the right collision should make sure it works 100% in all cases.

commented

Somewhat related but texture uv's are also being done in reverse order, not noticeable usually until you use a texture that has obviously noticeable things like text being in reversed.

I believe this is no longer an issue. If it is, we can reopen the ticket.