void BroadPhase2DHashGrid::move(ID p_id, const Rect2& p_aabb) {


	Map<ID,Element>::Element *E=element_map.find(p_id);
	ERR_FAIL_COND(!E);

	Element &e=E->get();

	if (p_aabb==e.aabb)
		return;


	if (p_aabb!=Rect2()) {

		_enter_grid(&e,p_aabb,e._static);
	}

	if (e.aabb!=Rect2()) {

		_exit_grid(&e,e.aabb,e._static);
	}

	e.aabb=p_aabb;

	_check_motion(&e);

	e.aabb=p_aabb;

}
Ejemplo n.º 2
0
void BroadPhase2DHashGrid::set_static(ID p_id, bool p_static) {

	Map<ID, Element>::Element *E = element_map.find(p_id);
	ERR_FAIL_COND(!E);

	Element &e = E->get();

	if (e._static == p_static)
		return;

	if (e.aabb != Rect2())
		_exit_grid(&e, e.aabb, e._static);

	e._static = p_static;

	if (e.aabb != Rect2()) {
		_enter_grid(&e, e.aabb, e._static);
		_check_motion(&e);
	}
}