blob: bc06b42b627cd3789e929ea3959796f6b91098c5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
#pragma once
#include <time.h>
#include <math.h>
#include "typedef.h"
inline F64 t_nows() {
struct timespec ts;
clock_gettime( CLOCK_MONOTONIC, &ts );
return (F64)ts.tv_sec + (F64)ts.tv_nsec * 1e-9;
}
inline F32 fade_alpha( F64 since, F64 now ) {
if( since <= 0.0 )
return 0.0f;
F64 a = ( now - since - 0.30 ) / 0.30;
if( a < 0.0 ) a = 0.0;
if( a > 1.0 ) a = 1.0;
return (F32)a;
}
inline F32 vec_dist( F32 x1, F32 y1, F32 z1, F32 x2, F32 y2, F32 z2 ) {
F32 dx = x1 - x2;
F32 dy = y1 - y2;
F32 dz = z1 - z2;
return sqrtf( dx * dx + dy * dy + dz * dz );
}
|