Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add multiple surface functionality for meshes in Footstep System #70

Merged
merged 2 commits into from
Feb 18, 2024

Conversation

FailSpy
Copy link
Contributor

@FailSpy FailSpy commented Feb 16, 2024

Pinging @ac-arcana here for a look, as well as @Bezoika

This is my attempt at implementing handling multiple surfaces. I don't currently have a way implemented to handle multiple MeshInstance3D children, so just go for the first one.

However, with a MeshInstance3D that has an ArrayMesh or multiple surfaces, it should work. I've tested this with as many cases I can think of, but I'm doubtless missing some.

This will try very hard to validate that there's more than one surface material needing to be thought about, and if so:

  1. Find the face the player is standing on
  2. If a face is found, note the vertices for that face, and translate the Vector3s into integers on a separate grid system
  3. Then cycle through the vertices of each "surface" of the mesh. If it matches the grid coordinates of the found face, then it marks that surface as the correct one and returns its material.

This is far from perfect in implementation, but it's surprisingly performant on my machine, curious to know how it works for others. I did a similar stress test to that video Bezoika posted of a heavily subdivided plane with two surfaces, and got an occasional stutter but really didn't feel much other than that.

There's a whole bunch of ways I could imagine optimizing it, but again, want to know how it works for others before spending the time optimizing.

This would fix #65

@FailSpy FailSpy changed the title Add multiple surface functionality for meshes Add multiple surface functionality for meshes in Footstep System Feb 16, 2024
@FailSpy
Copy link
Contributor Author

FailSpy commented Feb 16, 2024

Oh, worth noting: I also added a check for CSGCombiner3D, as that would cause a crash similarly to ArrayMeshes

It also will try to grab a parent MeshInstance3D to the Collider (RigidBody or StaticBody) before trying the children, as that generally tends to be how I layout my Godot nodes, and I know other people do similarly.

@ac-arcana
Copy link
Collaborator

I finally had time to at least read the code, looks all good to me. I would like to test it with Qodot when I get a chance as both Bezoika and myself us it.
@Bezoika have you had a chance to see if this works with Qodot?

Copy link
Owner

@Phazorknight Phazorknight left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trusting AC-Arcana's judgement and approving this.

@Phazorknight Phazorknight merged commit 1df83e1 into Phazorknight:main Feb 18, 2024
@FailSpy
Copy link
Contributor Author

FailSpy commented Feb 18, 2024

I finally had time to at least read the code, looks all good to me. I would like to test it with Qodot when I get a chance as both Bezoika and myself us it. @Bezoika have you had a chance to see if this works with Qodot?

Thanks for reviewing it. If issues do arise/are discovered with this system in particular I'm happy to jump in on those.

@FailSpy FailSpy deleted the patch-footsteps-1 branch February 18, 2024 18:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New surface material footstep system crashes on collisions with ArrayMesh
3 participants