Added flight mode ('F' button)

This commit is contained in:
MihailRis
2022-03-04 17:44:14 +03:00
committed by GitHub
parent 1dd9a72fb3
commit b6c328fe1d
7 changed files with 30 additions and 9 deletions
+4 -4
View File
@@ -10,16 +10,16 @@
PhysicsSolver::PhysicsSolver(vec3 gravity) : gravity(gravity) {
}
void PhysicsSolver::step(Chunks* chunks, Hitbox* hitbox, float delta, unsigned substeps, bool shifting) {
void PhysicsSolver::step(Chunks* chunks, Hitbox* hitbox, float delta, unsigned substeps, bool shifting, float gravityScale) {
for (unsigned i = 0; i < substeps; i++){
float dt = delta / (float)substeps;
float linear_damping = hitbox->linear_damping;
vec3& pos = hitbox->position;
vec3& half = hitbox->halfsize;
vec3& vel = hitbox->velocity;
vel.x += gravity.x*dt;
vel.y += gravity.y*dt;
vel.z += gravity.z*dt;
vel.x += gravity.x*dt * gravityScale;
vel.y += gravity.y*dt * gravityScale;
vel.z += gravity.z*dt * gravityScale;
float px = pos.x;
float pz = pos.z;
+1 -1
View File
@@ -14,7 +14,7 @@ class PhysicsSolver {
vec3 gravity;
public:
PhysicsSolver(vec3 gravity);
void step(Chunks* chunks, Hitbox* hitbox, float delta, unsigned substeps, bool shifting);
void step(Chunks* chunks, Hitbox* hitbox, float delta, unsigned substeps, bool shifting, float gravityScale);
bool isBlockInside(int x, int y, int z, Hitbox* hitbox);
};