static void gp_stroke_path_animation_preprocess_gaps(tGpTimingData *gtd, RNG *rng, int *nbr_gaps, float *tot_gaps_time)
{
	int i;
	float delta_time = 0.0f;
	
	for (i = 0; i < gtd->num_points; i++) {
		if (gtd->times[i] < 0 && i) {
			(*nbr_gaps)++;
			gtd->times[i] = -gtd->times[i] - delta_time;
			delta_time += gtd->times[i] - gtd->times[i - 1];
			gtd->times[i] = -gtd->times[i - 1]; /* Temp marker, values *have* to be different! */
		}
		else {
			gtd->times[i] -= delta_time;
		}
	}
	gtd->tot_time -= delta_time;
	
	*tot_gaps_time = (float)(*nbr_gaps) * gtd->gap_duration;
	gtd->tot_time += *tot_gaps_time;
	if (G.debug & G_DEBUG) {
		printf("%f, %f, %f, %d\n", gtd->tot_time, delta_time, *tot_gaps_time, *nbr_gaps);
	}
	if (gtd->gap_randomness > 0.0f) {
		BLI_rng_srandom(rng, gtd->seed);
	}
}
Esempio n. 2
0
static void precalculate_effector(EffectorCache *eff)
{
	unsigned int cfra = (unsigned int)(eff->scene->r.cfra >= 0 ? eff->scene->r.cfra : -eff->scene->r.cfra);
	if (!eff->pd->rng)
		eff->pd->rng = BLI_rng_new(eff->pd->seed + cfra);
	else
		BLI_rng_srandom(eff->pd->rng, eff->pd->seed + cfra);

	if (eff->pd->forcefield == PFIELD_GUIDE && eff->ob->type==OB_CURVE) {
		Curve *cu= eff->ob->data;
		if (cu->flag & CU_PATH) {
			if (eff->ob->curve_cache == NULL || eff->ob->curve_cache->path==NULL || eff->ob->curve_cache->path->data==NULL)
				BKE_displist_make_curveTypes(eff->scene, eff->ob, 0);

			if (eff->ob->curve_cache->path && eff->ob->curve_cache->path->data) {
				where_on_path(eff->ob, 0.0, eff->guide_loc, eff->guide_dir, NULL, &eff->guide_radius, NULL);
				mul_m4_v3(eff->ob->obmat, eff->guide_loc);
				mul_mat3_m4_v3(eff->ob->obmat, eff->guide_dir);
			}
		}
	}
	else if (eff->pd->shape == PFIELD_SHAPE_SURFACE) {
		eff->surmd = (SurfaceModifierData *)modifiers_findByType( eff->ob, eModifierType_Surface );
		if (eff->ob->type == OB_CURVE)
			eff->flag |= PE_USE_NORMAL_DATA;
	}
	else if (eff->psys)
		psys_update_particle_tree(eff->psys, eff->scene->r.cfra);

	/* Store object velocity */
	if (eff->ob) {
		float old_vel[3];

		BKE_object_where_is_calc_time(eff->scene, eff->ob, cfra - 1.0f);
		copy_v3_v3(old_vel, eff->ob->obmat[3]);
		BKE_object_where_is_calc_time(eff->scene, eff->ob, cfra);
		sub_v3_v3v3(eff->velocity, eff->ob->obmat[3], old_vel);
	}
}
Esempio n. 3
0
void BKE_brush_system_init(void)
{
	brush_rng = BLI_rng_new(0);
	BLI_rng_srandom(brush_rng, 31415682);
}