Lots of little tweaks as I figure out the octree. Fixed bug regarding the selects in the kernel dictating material texturing

This commit is contained in:
MitchellHansen
2017-08-19 00:04:10 -07:00
parent 4642ab8f0b
commit 9f764f4cbd
4 changed files with 48 additions and 27 deletions

View File

@@ -130,7 +130,7 @@ int main() {
LightPrototype prototype(
sf::Vector3f(100.0f, 100.0f, 75.0f),
sf::Vector3f(-1.0f, -1.0f, -1.5f),
sf::Vector4f(0.2f, 0.9f, 0.0f, 1.0f)
sf::Vector4f(0.4f, 0.4f, 0.4f, 1.0f)
);
std::shared_ptr<LightHandle> handle(light_controller.create_light(prototype));

View File

@@ -157,7 +157,7 @@ std::vector<std::tuple<sf::Vector3i, char>> Map::CastRayOctree(
sf::Vector3i voxel(*cam_pos);
// THIS DOES NOT HAVE TO RETURN TRUE ON FOUND
// This function when passed a "air" voxel will return as far down
// This function when passed an "air" voxel will return as far down
// the IDX stack as it could go. We use this oct-level to determine
// our first position and jump. Updating it as we go
OctState traversal_state = octree->GetVoxel(voxel);
@@ -210,21 +210,28 @@ std::vector<std::tuple<sf::Vector3i, char>> Map::CastRayOctree(
delta_t *= static_cast<float>(jump_power);
// offset is how far we are into a voxel, enables sub voxel movement
// Intersection T is the collection of the next intersection points
// for all 3 axis XYZ.
// TODO: start here
// Whats the issue?
// Using traversal_scale
// set intersection t to the current hierarchy level each time we change levels
// and use that to step
// Intersection T is the collection of the next intersection points
// for all 3 axis XYZ. We take the full positive cardinality when
// subtracting the floor, so we must transfer the sign over from
// the voxel step
sf::Vector3f intersection_t(
delta_t.x * (cam_pos->y - floor(cam_pos->x)) * voxel_step.x,
delta_t.y * (cam_pos->x - floor(cam_pos->y)) * voxel_step.y,
delta_t.z * (cam_pos->z - floor(cam_pos->z)) * voxel_step.z
);
// for negative values, wrap around the delta_t
// When we transfer the sign over, we get the correct direction of
// the offset, but we merely transposed over the value instead of mirroring
// it over the axis like we want. So here, isless returns a boolean if intersection_t
// is less than 0 which dictates whether or not we subtract the delta which in effect
// mirrors the offset
intersection_t.x -= delta_t.x * (std::isless(intersection_t.x, 0.0f));
intersection_t.y -= delta_t.y * (std::isless(intersection_t.y, 0.0f));
intersection_t.z -= delta_t.z * (std::isless(intersection_t.z, 0.0f));
@@ -273,7 +280,7 @@ std::vector<std::tuple<sf::Vector3i, char>> Map::CastRayOctree(
// If we hit a voxel
//voxel_data = map[voxel.x + (*map_dim).x * (voxel.y + (*map_dim).z * (voxel.z))];
voxel_data = getVoxel(voxel);
// voxel_data = getVoxel(voxel);
travel_path.push_back(std::make_tuple(voxel, voxel_data));
if (voxel_data != 0)

View File

@@ -234,7 +234,7 @@ void Old_Map::generate_terrain() {
for (int y = 0; y < dimensions.y; y++) {
// for (int z = 0; z < dimensions.z; z++) {
//if (rand() % 1000 < 1)
voxel_data[x + dimensions.x * (y + dimensions.z * 1)] = 5;
voxel_data[x + dimensions.x * (y + dimensions.z * 1)] = 6;
// }
}
}