Ejemplo n.º 1
0
sanguis::creator::grid_crange
sanguis::collision::impl::make_range(
	sanguis::creator::grid const &_grid,
	sanguis::collision::center const _center,
	sanguis::collision::radius const _radius
)
{
	sanguis::creator::difference_type const tile_size(
		fcppt::cast::to_signed(
			sanguis::creator::tile_size::value
		)
	);

	sanguis::creator::min const lower(
		fcppt::container::grid::clamped_min(
			fcppt::math::vector::structure_cast<
				sanguis::creator::signed_pos,
				fcppt::cast::float_to_int_fun
			>(
				fcppt::math::vector::map(
					_center.get()
					-
					_radius.get()
					,
					fcppt::boost_units_value{}
				)
			)
			/
			tile_size
		)
	);

	sanguis::creator::sup const upper(
		fcppt::container::grid::clamped_sup_signed(
			fcppt::math::vector::ceil_div_signed(
				fcppt::math::vector::structure_cast<
					sanguis::creator::signed_pos,
					fcppt::cast::float_to_int_fun
				>(
					fcppt::math::vector::map(
						_center.get()
						+
						_radius.get()
						,
						fcppt::boost_units_value{}
					)
				),
				tile_size
			),
			_grid.size()
		)
	);

	return
		fcppt::container::grid::make_pos_ref_crange_start_end(
			_grid,
			lower,
			upper
		);
}
Ejemplo n.º 2
0
sanguis::creator::pos
sanguis::collision::impl::world::simple::grid_position(
	sanguis::collision::center const _center
)
{
	return
		fcppt::math::vector::to_unsigned(
			fcppt::math::vector::structure_cast<
				sanguis::creator::signed_pos,
				fcppt::cast::float_to_int_fun
			>(
				fcppt::math::vector::map(
					_center.get(),
					fcppt::boost_units_value{}
				)
			)
		)
		/
		sanguis::creator::tile_size::value;
}