commit 07e89fa7d5461b6410047c70115312793357d07a
parent ad8b543a9928bb37631fe3a0cb7c83066001f623
Author: Michael Savage <mikejsavage@gmail.com>
Date: Sat, 18 Nov 2017 16:49:51 +0200
Implicit euler integration for fireballs
Diffstat:
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/clipmap.cc b/clipmap.cc
@@ -535,7 +535,6 @@ GAME_FRAME( game_frame ) {
// TODO: this might be quite harmful
if( !game->on_ground ) {
- // TODO: rk4 integration
const float gravity = -30.0f;
game->velocity += v3( 0, 0, gravity ) * remaining_t;
@@ -736,7 +735,11 @@ GAME_FRAME( game_frame ) {
PROFILE_BLOCK( "Update fireballs" );
for( size_t i = 0; i < fireballs.elems.n; i++ ) {
Fireball * fireball = &fireballs.elems[ i ];
- Ray3 ray( fireball->pos, fireball->velocity * dt );
+
+ const float gravity = 30;
+ fireball->velocity.z -= dt * gravity;
+
+ Ray3 ray( fireball->pos, fireball->velocity );
v3 end = fireball->pos + fireball->velocity * dt;
float t;
@@ -750,9 +753,7 @@ GAME_FRAME( game_frame ) {
i--;
}
else {
- const float gravity = 9.81f;
fireball->pos = end;
- fireball->velocity.z -= dt * gravity;
immediate_sphere( fireball->pos, 4, v4( 1, 0, 0, 1 ), 4 );
}
}