Skip to content

Conversation

@DimpyRed
Copy link
Contributor

I don't expect this to get merged as is, but I feel like it's ready for code review.

@DimpyRed
Copy link
Contributor Author

I'm ready for more code review.

@DimpyRed
Copy link
Contributor Author

DimpyRed commented Aug 2, 2022

This update comes in two complimentary parts

Part one is the collision detection.
A new file, collsion.rs, has been added which gives a set of structs and functions which can find the voxel-space “footprint” an object of a certain maximum radius and position would occupy.
This footprint, which is known as the bounding box has the following attributes:

  • It is is calculated overzealously; There will be false positives, but no false negatives.
  • It is cheaply calculated
  • It consists of a set of voxel-space rectangular prisms, each one representing the set of voxels the object could be occupying in a particular chunk.

Part two adds force and velocity
The player’s character now moves as if they have a velocity. The player is pulled perpendicular to the ground-plane from the force of gravity. When touching solid ground, the player slowly floats upwards.
The server is currently unaware of velocity; the client simply adds the character's velocity to the movement inputs to simulate effect of physics.

To determine if the player is in contact with the ground, the client checks the player character’s bounding box, and if any voxel within the bounding box is not air, the player is considered to be touching the ground.

There are many issues yet to be tackled. The server has no ability to enforce the rules of physics. The current collision detecting lacks precision. The movement due to player velocity is jittery, leading to an uncomfortable viewing experiencing.

Copy link
Collaborator

@patowen patowen left a comment

Choose a reason for hiding this comment

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

I've finished looking through the PR, and it is definitely looking close to ready to merge. I tried to be as thorough as possible, which means that I have left a lot of comments. A lot of them are minor, but some require a closer look. I would recommend looking through all of my comments before making code changes in case one renders another obsolete.

for &(id, new_pos) in &msg.positions {
self.update_position(msg.latest_input, id, new_pos);
for &(id, new_pos, node_transform) in &msg.positions {
self.update_position(msg.latest_input, id, new_pos, node_transform);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure why, but with some println debugging, I've found situations in which node_transform was the identity matrix, but new_pos was different from the old position. I believe this is the main cause of the velocity redirection you noticed recently.

Rather than figuring out the root cause of this discrepancy, I believe the simplest fix would be to do this while fixing the jitter. For prototyping purposes, to simplify development, I would recommend having the client simply send the entire Position structure to the server and never have the server reposition the client. Once we have a better understanding of netcode, we can try to do things the right way.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think I made it very clear, but node_transform is only not the identity matrix when going from one node to another node.
When the player is moving around in the middle of the node, the exact scenario you are describing should be the norm.

I agree that the Client broadcasting its Position is the proper thing to do right now.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sorry, I meant that new_pos.old was different from the old pos.node. I'm aware that node_transform being the identity is correct when staying within a single node.

Copy link
Collaborator

@patowen patowen left a comment

Choose a reason for hiding this comment

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

I took another pass at your PR. It looks like most of my comments were fully addressed. I left a few comments this time for new things I noticed as well as following up on unresolved threads.


// place a small bounding box next to a dodecaherdral vertex. There should be exactly 8 chunks in contact.
#[test]
fn proper_chunks_8() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

PERPENDICULAR_VERTEX is not yet included in the proper_chunks_n tests. There should be another test added to the suite. Its associated comment should be something like

// place a small bounding box near the midpoint of a dodecahedron's edge. There should be exactly 8 chunks in contact.

The chunk coordinates should be close to any permutation of (1, 1, 0).

@Ralith
Copy link
Owner

Ralith commented Jan 21, 2024

Closing as we've now merged collision detection, drawing in part on the work here, into master. Thanks for your contribution!

@Ralith Ralith closed this Jan 21, 2024
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.

3 participants