Jump to content

Collision Issue


SpiderPig
 Share

Go to solution Solved by Josh,

Recommended Posts

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

Link to comment
Share on other sites

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...

Untitled.thumb.jpg.f8a167b6306cb9440548fc427f817dc5.jpg

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

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...

image.thumb.jpeg.71d2f1baacf193432ecf2d5007f84c5e.jpeg

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

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...

  • Thanks 1

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

I'm not sure if the flip of faces for mesh colliders was right or not.

CollisionIssue.gif.28b55838fdbdff58b4453ef26c77b6c7.gif

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);

 

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...