Add print statements to hopefully help with debugging.
This commit is contained in:
parent
89f7d5c948
commit
5bccef1f4f
1 changed files with 16 additions and 5 deletions
|
@ -60,8 +60,10 @@ namespace curry {
|
||||||
const vec2f& parTo,
|
const vec2f& parTo,
|
||||||
const WorldGrid& parWorld
|
const WorldGrid& parWorld
|
||||||
) {
|
) {
|
||||||
|
std::cout << "---------------- collision test start --------------------\n";
|
||||||
const vec2f direction = parTo - parFrom;
|
const vec2f direction = parTo - parFrom;
|
||||||
std::cout << "direction: " << direction << ' ';
|
std::cout << "direction: " << direction << ' ';
|
||||||
|
std::cout << "src_tile=" << pixel_to_world_tile(parWorld, parFrom) << '\n';
|
||||||
if (direction == 0.0f)
|
if (direction == 0.0f)
|
||||||
return parTo;
|
return parTo;
|
||||||
|
|
||||||
|
@ -69,24 +71,28 @@ namespace curry {
|
||||||
const vec2us length = check_tiles_count(parObjectSize, direction);
|
const vec2us length = check_tiles_count(parObjectSize, direction);
|
||||||
std::cout << "side_offset: " << side_offset << " length: " << length << '\n';
|
std::cout << "side_offset: " << side_offset << " length: " << length << '\n';
|
||||||
const vec2us dest_tile = pixel_to_world_tile(parWorld, parTo);
|
const vec2us dest_tile = pixel_to_world_tile(parWorld, parTo);
|
||||||
vec2us stop_at = pixel_to_world_tile(parWorld, parFrom);
|
const vec2f pix_side_offset =
|
||||||
|
make_pixel_side_offset(parWorld.tile_size(), side_offset, direction);
|
||||||
|
vec2us stop_at = pixel_to_world_tile(parWorld, parFrom + pix_side_offset);
|
||||||
vec2f tile_relative_offs = parTo - world_tile_to_pixel(parWorld, dest_tile);
|
vec2f tile_relative_offs = parTo - world_tile_to_pixel(parWorld, dest_tile);
|
||||||
assert(tile_relative_offs < vector_cast<vec2f>(parWorld.tile_size()));
|
assert(tile_relative_offs < vector_cast<vec2f>(parWorld.tile_size()));
|
||||||
|
|
||||||
auto forward_callback = [=,&parWorld,&stop_at,&tile_relative_offs](vec2us tile) {
|
auto forward_callback = [=,&parWorld,&stop_at,&tile_relative_offs](vec2us tile) {
|
||||||
for (auto curr_pos : vwr::increasing_sequence_range<vec2us>(tile, tile + parObjectSize)) {
|
std::cout << "\t------------------- callback invoked ---------------\n";
|
||||||
|
for (auto curr_pos : vwr::increasing_sequence_range<vec2us>(tile, tile + length)) {
|
||||||
|
std::cout << "\ttesting " << curr_pos << " (stop_at=" << stop_at << ", tile=" << tile << ")\n";
|
||||||
const bool walkable = parWorld.tile_property(parWorld.tile(curr_pos)).walkable;
|
const bool walkable = parWorld.tile_property(parWorld.tile(curr_pos)).walkable;
|
||||||
if (not walkable) {
|
if (not walkable) {
|
||||||
|
std::cout << "\t*not* walkable!\n";
|
||||||
tile_relative_offs = vec2f(0.0f);
|
tile_relative_offs = vec2f(0.0f);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stop_at = tile - side_offset;
|
stop_at = tile;
|
||||||
|
std::cout << "\tstop_at set to " << stop_at << " and returning from callback\n";
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
const vec2f pix_side_offset =
|
|
||||||
make_pixel_side_offset(parWorld.tile_size(), side_offset, direction);
|
|
||||||
for_each_voxel_under_segment(
|
for_each_voxel_under_segment(
|
||||||
parFrom + pix_side_offset,
|
parFrom + pix_side_offset,
|
||||||
parTo + pix_side_offset,
|
parTo + pix_side_offset,
|
||||||
|
@ -95,7 +101,12 @@ namespace curry {
|
||||||
forward_callback,
|
forward_callback,
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
|
std::cout << "loop done\n";
|
||||||
|
|
||||||
|
std::cout << "world_tile_to_pixel() = " << world_tile_to_pixel(parWorld, stop_at) <<
|
||||||
|
" tile_relative_offs: " << tile_relative_offs <<
|
||||||
|
" pix_side_offset: " << pix_side_offset << '\n';
|
||||||
|
std::cout << "returning " << world_tile_to_pixel(parWorld, stop_at) + tile_relative_offs - pix_side_offset << '\n';
|
||||||
return world_tile_to_pixel(parWorld, stop_at) + tile_relative_offs - pix_side_offset;
|
return world_tile_to_pixel(parWorld, stop_at) + tile_relative_offs - pix_side_offset;
|
||||||
}
|
}
|
||||||
} //namespace curry
|
} //namespace curry
|
||||||
|
|
Loading…
Reference in a new issue