SpiderPig Posted July 20, 2023 Share Posted July 20, 2023 Haven't had time to put together an example yet, but here's a video of the issue and the collider I'm using is attached as well as the .obj it was generated from. This has been happening since the fix for Mesh Colliders. Before then this shape didn't work at all. The video is just a player controller getting stuck inside this collider and when it does collide, it jitters a lot. Physics.zip Quote Link to comment Share on other sites More sharing options...
Josh Posted July 20, 2023 Share Posted July 20, 2023 It appears to be loading correctly. Maybe the faces are all backwards, either in the shape, or they could be getting flipped in my loader... Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
SpiderPig Posted July 20, 2023 Author Share Posted July 20, 2023 Good point, they might be backwards - I'll check... Quote Link to comment Share on other sites More sharing options...
Josh Posted July 20, 2023 Share Posted July 20, 2023 It looks like the top and bottom have the opposite orientation as the sides, although I can't say for sure which is right. Maybe the physics system has a different handedness than the renderer... Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
SpiderPig Posted July 20, 2023 Author Share Posted July 20, 2023 Yeah these are the normals shown in blender, they appear correct. I might remove the top and bottoms caps, although I don't know what that means if something does collide at the top or bottom... Quote Link to comment Share on other sites More sharing options...
Josh Posted July 20, 2023 Share Posted July 20, 2023 Okay, I fixed a bug in the OBJ loader that was flipping some faces. However, I do not know if the handedness of the physics matches the handedness of the renderer... 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
SpiderPig Posted July 20, 2023 Author Share Posted July 20, 2023 What is handedness? Quote Link to comment Share on other sites More sharing options...
Josh Posted July 20, 2023 Share Posted July 20, 2023 The direction a polygon faces, given three indices in order. It can be one direction or the other. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
SpiderPig Posted July 20, 2023 Author Share Posted July 20, 2023 Oh right, I thought it was called winding. Quote Link to comment Share on other sites More sharing options...
Solution Josh Posted July 20, 2023 Solution Share Posted July 20, 2023 I'm assuming that's the problem. I just uploaded an update that flips the direction of faces in mesh colliders. 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
SpiderPig Posted July 20, 2023 Author Share Posted July 20, 2023 Just confirming that seems to have fixed it, thanks. 1 Quote Link to comment Share on other sites More sharing options...
SpiderPig Posted July 23, 2023 Author Share Posted July 23, 2023 I'm not sure if the flip of faces for mesh colliders was right or not. This is the order I add vertices. It's the exact same order as I use for rendering. 3 vertices per face. If I reverse the order I add these vertices the collision works, I just want to confirm that this is how things should be before I make changes to my code? collision_patch->AddVertex(p[0].x - position_offset.x, p[0].y - position_offset.y, p[0].z - position_offset.z); collision_patch->AddVertex(p[1].x - position_offset.x, p[1].y - position_offset.y, p[1].z - position_offset.z); collision_patch->AddVertex(p[2].x - position_offset.x, p[2].y - position_offset.y, p[2].z - position_offset.z); All those vertices are added to a vector in order and I build a mesh collider like this; I could just reverse the order here too, but still, just checking. vector<vector<Vec3>> faces; auto total_faces = vertices.size() / 3; faces.resize(total_faces); int id = 0; for (int f = 0; f < total_faces; f++) { vector<Vec3> v; v.reserve(3); v.emplace_back(vertices[id]); v.emplace_back(vertices[id + 1]); v.emplace_back(vertices[id + 2]); faces[f] = v; id += 3; } collider = CreateMeshCollider(faces); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.