ref: 91ccd6aefd806490c9b0f7b8bd02d7fdc54e1c55
parent: 09141d3f09a12a1ef37e11e9c47073e6de5dbfaf
author: gek169 <gek169>
date: Sat May 8 12:10:10 EDT 2021
Automatic commit.
--- a/include-demo/chadphys.h
+++ b/include-demo/chadphys.h
@@ -30,7 +30,7 @@
body->mass = 0;
body->bounciness = 0;
body->friction = 0.99; //The amount of coplanar velocity preserved in collisions.
- body->airfriction = 1.0;
+ body->airfriction = 0.99;
body->a = (vec3){.d[0] = 0,.d[1] = 0,.d[2] = 0};
body->localt = identitymat4();
}
@@ -126,7 +126,6 @@
static inline void stepPhysWorld(phys_world* world, const long collisioniter){
for(long i = 0; i < world->nbodies; i++)
if(world->bodies[i] && world->bodies[i]->mass > 0){
- unsigned long n_scale_iter = 0;
phys_body* body = world->bodies[i];
vec3 bodypos = addv3(downv4(body->shape.c),body->v);
body->shape.c.d[0] = bodypos.d[0];
@@ -134,11 +133,12 @@
body->shape.c.d[2] = bodypos.d[2];
body->v = addv3(body->v, body->a);
body->v = addv3(body->v, world->g);
- while(dotv3(body->v, body->v) > world->ms && n_scale_iter < 100) {
- body->v = scalev3(0.9, body->v); n_scale_iter++;
+ if( (dotv3(body->v, body->v) > world->ms * world->ms)){
+ body->v = normalizev3(body->v);
+ body->v = scalev3(world->ms, body->v);
}
+ body->v = scalev3(body->airfriction, body->v);
if(world->is_2d) {body->shape.c.d[2] = 0;}
-
}
//Resolve collisions (if any)