Beispiel #1
0
void SceneMainLoop::_flush_transform_notifications() {

	SelfList<Node>* n = xform_change_list.first();
	while(n) {

		Node *node=n->self();
		SelfList<Node>* nx = n->next();
		xform_change_list.remove(n);
		n=nx;
		node->notification(NOTIFICATION_TRANSFORM_CHANGED);
	}
}
Beispiel #2
0
void ResourceLoader::reload_translation_remaps() {

	if (ResourceCache::lock) {
		ResourceCache::lock->read_lock();
	}

	List<Resource *> to_reload;
	SelfList<Resource> *E = remapped_list.first();

	while (E) {
		to_reload.push_back(E->self());
		E = E->next();
	}

	if (ResourceCache::lock) {
		ResourceCache::lock->read_unlock();
	}

	//now just make sure to not delete any of these resources while changing locale..
	while (to_reload.front()) {
		to_reload.front()->get()->reload_from_file();
		to_reload.pop_front();
	}
}
Beispiel #3
0
bool AStar::_solve(Point *begin_point, Point *end_point) {

	pass++;

	SelfList<Point>::List open_list;

	bool found_route = false;

	for (Set<Point *>::Element *E = begin_point->neighbours.front(); E; E = E->next()) {

		Point *n = E->get();
		n->prev_point = begin_point;
		n->distance = _compute_cost(begin_point->id, n->id) * n->weight_scale;
		n->last_pass = pass;
		open_list.add(&n->list);
	}

	while (true) {

		if (open_list.first() == NULL) {
			// No path found
			break;
		}
		// Check open list

		SelfList<Point> *least_cost_point = open_list.first();
		real_t least_cost = Math_INF;

		// TODO: Cache previous results
		for (SelfList<Point> *E = open_list.first(); E; E = E->next()) {

			Point *p = E->self();

			real_t cost = p->distance;
			cost += _estimate_cost(p->id, end_point->id);

			if (cost < least_cost) {
				least_cost_point = E;
				least_cost = cost;
			}
		}

		Point *p = least_cost_point->self();
		if (p == end_point) {
			found_route = true;
			break;
		}

		for (Set<Point *>::Element *E = p->neighbours.front(); E; E = E->next()) {

			Point *e = E->get();

			real_t distance = _compute_cost(p->id, e->id) * e->weight_scale + p->distance;

			if (e->last_pass == pass) {
				// Already visited, is this cheaper?

				if (e->distance > distance) {
					e->prev_point = p;
					e->distance = distance;
				}
			} else {
				// Add to open neighbours

				e->prev_point = p;
				e->distance = distance;
				e->last_pass = pass; // Mark as used
				open_list.add(&e->list);
			}
		}

		open_list.remove(least_cost_point);
	}

	// Clear the openf list
	while (open_list.first()) {
		open_list.remove(open_list.first());
	}

	return found_route;
}