8. Temporal Weight Commands

8.1. mass

gest_mass the global mass to an absolute value. Should be in range -120 to 120. 120 is a number chosen for it's divisibility properties.

<<funcdefs>>=
void gest_mass(gest_d *g, SKFLT mass);
<<funcs>>=
void gest_mass(gest_d *g, SKFLT mass)
{
    action_mass(g, g->curtarget, mass);
}

8.2. inertia

gest_inertia sets the inertia to be a absolute value.

<<funcdefs>>=
void gest_inertia(gest_d *g, SKFLT inertia);
<<funcs>>=
void gest_inertia(gest_d *g, SKFLT inertia)
{
    action_inertia(g, g->curtarget, inertia);
}

8.3. shrink/grow

gest_shrink and gest_grow cause the mass to shrink and grow by a percentage value.

<<funcdefs>>=
int gest_shrink(gest_d *g, SKFLT amt);
int gest_grow(gest_d *g, SKFLT amt);
<<funcs>>=
static void grow_mass(gest_d *g, void *ud, int pos)
{
    SKFLT *amt;
    amt = (SKFLT *) ud;
    g->mass += g->mass * (*amt);
}

int gest_grow(gest_d *g, SKFLT amt)
{
    SKFLT *pamt;
    gest_target *t;

    if (g->curtarget == NULL) return 1;

    t = g->curtarget;

    pamt= gest_alloc(g, sizeof(SKFLT));
    *pamt = amt;

    append_action(g, t, grow_mass, pamt);
    return 0;
}

static void shrink_mass(gest_d *g, void *ud, int pos)
{
    SKFLT *amt;
    amt = (SKFLT *) ud;
    g->mass -= g->mass * (*amt);
}

int gest_shrink(gest_d *g, SKFLT amt)
{
    SKFLT *pamt;
    gest_target *t;

    if (g->curtarget == NULL) return 1;

    t = g->curtarget;

    pamt= gest_alloc(g, sizeof(SKFLT));
    *pamt = amt;

    append_action(g, t, shrink_mass, pamt);
    return 0;
}



prev | home | next