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

Enhance Entity Physics Calculation #897

Merged
merged 4 commits into from Apr 16, 2018

Conversation

Projects
None yet
4 participants
@XuZhen86
Contributor

XuZhen86 commented Apr 11, 2018

This pull request tries to solve the problem that entity trajectory is glitchy, especially when the player breaks a block and the item drops.

The major problem is, in GlowEntity.pulsePhysics(), only one case of the formula is used. According to Wiki, there are actually two cases used on different entities.

Note that when thrown objects and arrows are simulated, the drag is applied before the acceleration, rather than after; this is why their terminal velocities are whole numbers while the others aren't.
Entity

This issue caused the server-side trajectory of many entities differ from the client-side trajectory. The glitchy happens when after the client animated the anticipated trajectory of the second tick, the server sends a different location of the second tick. The difference is significant enough that the client has to "glitch" the entity to the location the server sent. Because for each tick, the anticipated location and the server-calculated location is different, the client has to "glitch" every tick.

Works done:

  1. Rewrite GlowEntity.pulsePhysics() to include the missing formula and enhance readability
  2. Correct entity physics parameter according to Wiki
  3. Small fixes

Known issues:

  1. Entity still "vibrates" on the floor

To-do:

  1. Implement terminal velocity for entities.
  2. Use bounding box interception to calculate the exact location where the entity touches the floor. This should solve the "vibration" problem.
  3. Fix anything broken caused by 2?
Enhance Entity Physics Calculation
1. Rewrite GlowEntity.pulsePhysics() to include the missing formula and enhance readability
2. Correct entity physics parameter according to Wiki
3. Small fixes

@momothereal momothereal self-requested a review Apr 11, 2018


// The previous calculation always gives a non-negative zOffset
// This adds a 50% chance of offsetZ being negative
if (tlr.nextInt(2) == 0) {

This comment has been minimized.

@momothereal

momothereal Apr 11, 2018

Member

Use nextBoolean instead

XuZhen86 added some commits Apr 11, 2018

@mastercoms mastercoms merged commit 56fdf0c into GlowstoneMC:dev Apr 16, 2018

2 checks passed

ci/circleci: build Your tests passed on CircleCI!
Details
license/cla Contributor License Agreement is signed.
Details
@Pr0methean

This comment has been minimized.

Contributor

Pr0methean commented Apr 16, 2018

I don't think terminal velocity has to be implemented separately. Isn't it just the vertical velocity at which gravity and drag happen to cancel out, like in real life?

@XuZhen86

This comment has been minimized.

Contributor

XuZhen86 commented Apr 16, 2018

You are right. I was thinking about this but did not have a chance to verify. It's looks more obvious when you say they can cancel out like in real life.

Note that when thrown objects and arrows are simulated, the drag is applied before the acceleration, rather than after; this is why their terminal velocities are whole numbers while the others aren't.

XuZhen86 added a commit to Glowminers/Glowstone that referenced this pull request Apr 16, 2018

Update K/D/A Table in README.md (2018/04/16)
Shane McConkey:
Kill: GlowstoneMC#888

Xu Zhen:
Kill: GlowstoneMC#897
Assist: Jordan Murray
@Pr0methean

This comment has been minimized.

Contributor

Pr0methean commented Apr 16, 2018

Actually, I'm not 100% sure I'm right, because the discrete-step nature of the physics model may cause artifacts that I'm not aware of. For example, if terminal velocity is overshot on one tick, then it will be undershot on the next. Hopefully the amount of overshoot or undershoot goes to zero asymptotically, but I'm not 100% sure that's the case; maybe there are period-2 attractors.

@momothereal

This comment has been minimized.

Member

momothereal commented Apr 26, 2018

Thank you for your valuable contributions to the project so far 😃. We have invited you as a member of the Glowstone Project organization; you should receive an email from Github shortly.

In addition, we'd like to invite you to join our Discord server, where you'll be granted the Developer role. Thanks!

@XuZhen86

This comment has been minimized.

Contributor

XuZhen86 commented May 2, 2018

Hello, momothereal. After carefully considering your invitation, I decide not to join the Glowstone Project organization. My reason is, as I'm becoming a Junior in Software Engineering with heavy course works in the next semester, I will not have enough time to fulfill my responsibility as an active developer on Github. Therefore, I appreciate you giving me a chance to step up from a contributor, but I just don't want to see the moment I have to step down because I can't do much in this project.

We as a team, Glowminers, chose Glowstone as our project for the Intro to Software Eng class. During the semester, we learn the basics of software development by contributing on Github. Glowstone taught us more than we expected and we had a great time working on the project and of course, with you developers. Our team secured the initiative in the class by fixing and merging 14 bug fixes, which is far more than any other team.

That being said, it is time for the team to say goodbye to Glowstone. The class gave us a chance to do real contribution on GitHub and we are glad to see, at the end of this semester, the difference we made to GitHub and Glowstone. We will make contribution to Glowstone individually but not as a team. In all, we will recommend Glowstone to the students in Intro to Software Eng class next semester and we look forward to contribute to Glowstone in the future!

@momothereal

This comment has been minimized.

Member

momothereal commented May 2, 2018

Hey!

As a CompSci student as well I concur about the course load 😄. We're really glad you guys chose Glowstone for your term project, and we're looking forward to hear from future students in your program. Thank you for the effort you've put into this project, and we hope to see more from you all in the future.

Membership inside the Glowstone project does not imply any responsibilities when it comes to time spent, activity, contributions, etc. Members of the project are trusted for their own discipline, code quality, and for understanding the core goal of the project. That said, we understand if you prefer not carrying the title for personal reasons. However, we're always open if you decide to change your mind! :)

Again, thank you for your exceptional work, and we're looking forward to hearing from members of your team in the future!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment