|
|
|
@ -83,125 +83,6 @@ wlsc_watch_process(struct wlsc_process *process) |
|
|
|
|
wl_list_insert(&child_process_list, &process->link); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
WL_EXPORT void |
|
|
|
|
wlsc_matrix_init(struct wlsc_matrix *matrix) |
|
|
|
|
{ |
|
|
|
|
static const struct wlsc_matrix identity = { |
|
|
|
|
{ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 } |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
memcpy(matrix, &identity, sizeof identity); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void |
|
|
|
|
wlsc_matrix_multiply(struct wlsc_matrix *m, const struct wlsc_matrix *n) |
|
|
|
|
{ |
|
|
|
|
struct wlsc_matrix tmp; |
|
|
|
|
const GLfloat *row, *column; |
|
|
|
|
div_t d; |
|
|
|
|
int i, j; |
|
|
|
|
|
|
|
|
|
for (i = 0; i < 16; i++) { |
|
|
|
|
tmp.d[i] = 0; |
|
|
|
|
d = div(i, 4); |
|
|
|
|
row = m->d + d.quot * 4; |
|
|
|
|
column = n->d + d.rem; |
|
|
|
|
for (j = 0; j < 4; j++) |
|
|
|
|
tmp.d[i] += row[j] * column[j * 4]; |
|
|
|
|
} |
|
|
|
|
memcpy(m, &tmp, sizeof tmp); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
WL_EXPORT void |
|
|
|
|
wlsc_matrix_translate(struct wlsc_matrix *matrix, GLfloat x, GLfloat y, GLfloat z) |
|
|
|
|
{ |
|
|
|
|
struct wlsc_matrix translate = { |
|
|
|
|
{ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, x, y, z, 1 } |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
wlsc_matrix_multiply(matrix, &translate); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
WL_EXPORT void |
|
|
|
|
wlsc_matrix_scale(struct wlsc_matrix *matrix, GLfloat x, GLfloat y, GLfloat z) |
|
|
|
|
{ |
|
|
|
|
struct wlsc_matrix scale = { |
|
|
|
|
{ x, 0, 0, 0, 0, y, 0, 0, 0, 0, z, 0, 0, 0, 0, 1 } |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
wlsc_matrix_multiply(matrix, &scale); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void |
|
|
|
|
wlsc_matrix_transform(struct wlsc_matrix *matrix, struct wlsc_vector *v) |
|
|
|
|
{ |
|
|
|
|
int i, j; |
|
|
|
|
struct wlsc_vector t; |
|
|
|
|
|
|
|
|
|
for (i = 0; i < 4; i++) { |
|
|
|
|
t.f[i] = 0; |
|
|
|
|
for (j = 0; j < 4; j++) |
|
|
|
|
t.f[i] += v->f[j] * matrix->d[i + j * 4]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
*v = t; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
WL_EXPORT void |
|
|
|
|
wlsc_spring_init(struct wlsc_spring *spring, |
|
|
|
|
double k, double current, double target) |
|
|
|
|
{ |
|
|
|
|
spring->k = k; |
|
|
|
|
spring->friction = 400.0; |
|
|
|
|
spring->current = current; |
|
|
|
|
spring->previous = current; |
|
|
|
|
spring->target = target; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
WL_EXPORT void |
|
|
|
|
wlsc_spring_update(struct wlsc_spring *spring, uint32_t msec) |
|
|
|
|
{ |
|
|
|
|
double force, v, current, step; |
|
|
|
|
|
|
|
|
|
step = 0.01; |
|
|
|
|
while (4 < msec - spring->timestamp) { |
|
|
|
|
current = spring->current; |
|
|
|
|
v = current - spring->previous; |
|
|
|
|
force = spring->k * (spring->target - current) / 10.0 + |
|
|
|
|
(spring->previous - current) - v * spring->friction; |
|
|
|
|
|
|
|
|
|
spring->current = |
|
|
|
|
current + (current - spring->previous) + |
|
|
|
|
force * step * step; |
|
|
|
|
spring->previous = current; |
|
|
|
|
|
|
|
|
|
#if 0 |
|
|
|
|
if (spring->current >= 1.0) { |
|
|
|
|
#ifdef TWEENER_BOUNCE |
|
|
|
|
spring->current = 2.0 - spring->current; |
|
|
|
|
spring->previous = 2.0 - spring->previous; |
|
|
|
|
#else |
|
|
|
|
spring->current = 1.0; |
|
|
|
|
spring->previous = 1.0; |
|
|
|
|
#endif |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (spring->current <= 0.0) { |
|
|
|
|
spring->current = 0.0; |
|
|
|
|
spring->previous = 0.0; |
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
spring->timestamp += 4; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
WL_EXPORT int |
|
|
|
|
wlsc_spring_done(struct wlsc_spring *spring) |
|
|
|
|
{ |
|
|
|
|
return fabs(spring->previous - spring->target) < 0.0002 && |
|
|
|
|
fabs(spring->current - spring->target) < 0.0002; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void |
|
|
|
|
surface_handle_buffer_destroy(struct wl_listener *listener, |
|
|
|
|
struct wl_resource *resource, uint32_t time) |
|
|
|
|