本文整理汇总了C++中ChunkManager::isTransparent方法的典型用法代码示例。如果您正苦于以下问题:C++ ChunkManager::isTransparent方法的具体用法?C++ ChunkManager::isTransparent怎么用?C++ ChunkManager::isTransparent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ChunkManager
的用法示例。
在下文中一共展示了ChunkManager::isTransparent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: castRay
// TODO: Should this go in chunkManager?
bool castRay(const Camera& camera, const ChunkManager& chunkManager, Coordinate& currentBlock, Coordinate& lastBlock)
{
glm::vec3 current = camera.eye;
glm::vec3 gaze = camera.gaze();
currentBlock = current;
glm::vec3 fractional = glm::fract(current);
// The direction of travel, in block coordinates
Coordinate step(glm::sign(gaze));
// The distance along gaze between consecutive blocks boundary
glm::vec3 delta = glm::length(gaze) / glm::abs(gaze);
// The distance along gaze to the first block boundary
glm::vec3 distance;
distance.x = gaze.x < 0 ? fractional.x : 1 - fractional.x;
distance.y = gaze.y < 0 ? fractional.y : 1 - fractional.y;
distance.z = gaze.z < 0 ? fractional.z : 1 - fractional.z;
distance *= delta;
do
{
// Travel the smallest distance necessary to hit the next block
// Intersects x-wall first
if (distance.x <= distance.y && distance.x <= distance.z)
{
lastBlock = currentBlock;
current += distance.x * gaze;
currentBlock.x += step.x;
distance -= glm::vec3(distance.x);
distance.x = delta.x;
}
else if (distance.y <= distance.x && distance.y <= distance.z)
{
lastBlock = currentBlock;
current += distance.y * gaze;
currentBlock.y += step.y;
distance -= glm::vec3(distance.y);
distance.y = delta.y;
}
else if (distance.z <= distance.x && distance.z <= distance.y)
{
lastBlock = currentBlock;
current += distance.z * gaze;
currentBlock.z += step.z;
distance -= glm::vec3(distance.z);
distance.z = delta.z;
}
else
{
// Numerical error?
assert(false);
}
// Only look for intersections within a certain range of the camera
if (glm::length(current - camera.eye) > MAX_TARGET_DISTANCE)
return false;
} while (chunkManager.isTransparent(currentBlock));
return true;
}