This commit is contained in:
bjorn 2024-01-20 21:58:03 -08:00
parent 30cb0c19a0
commit f8158744f9
2 changed files with 7 additions and 6 deletions

View File

@ -13,7 +13,7 @@
#define MOVESPEED 3.f
#define SPRINTSPEED 15.f
#define SLOW_MOVESPEED 0.5f
#define SLOWSPEED .5f
#define MOVESMOOTH 30.f
#define TURNSPEED .005f
#define TURNSMOOTH 30.f
@ -463,7 +463,7 @@ static double simulator_update(void) {
velocity[0] = (left ? -1.f : right ? 1.f : 0.f);
velocity[1] = (down ? -1.f : up ? 1.f : 0.f);
velocity[2] = (front ? -1.f : back ? 1.f : 0.f);
vec3_scale(velocity, sprint ? SPRINTSPEED : (slow ? SLOW_MOVESPEED : MOVESPEED));
vec3_scale(velocity, sprint ? SPRINTSPEED : (slow ? SLOWSPEED : MOVESPEED));
vec3_lerp(state.velocity, velocity, 1.f - expf(-MOVESMOOTH * state.dt));
vec3_scale(vec3_init(velocity, state.velocity), state.dt);

View File

@ -113,10 +113,11 @@ static void queryCallback(void* d, dGeomID a, dGeomID b) {
// XXX slow, but probably fine (tag names are not on any critical path), could switch to hashing if needed
static uint32_t findTag(World* world, const char* name) {
if (name == NULL) { return NO_TAG; }
for (uint32_t i = 0; i < MAX_TAGS && world->tags[i]; i++) {
if (!strcmp(world->tags[i], name)) {
return i;
if (name) {
for (uint32_t i = 0; i < MAX_TAGS && world->tags[i]; i++) {
if (!strcmp(world->tags[i], name)) {
return i;
}
}
}
return NO_TAG;