void ChunkManager::initTree(ChunkTree& pChild) { boost::shared_ptr<Chunk>& pChunk = pChild.getValue(); AABB bounds = pChild.getParent()->getValue()->m_bounds; vec center = bounds.CenterPoint(); vec c0 = bounds.CornerPoint(pChild.getCorner().index()); AABB b0(vec(min(c0.x, center.x), min(c0.y, center.y), min(c0.z, center.z)), vec(max(c0.x, center.x), max(c0.y, center.y), max(c0.z, center.z))); pChunk = boost::make_shared<Chunk>(b0, 1.0f/pChild.getLevel(), this); pChunk->m_pTree = &pChild; *pChunk->m_workInProgress = true; m_chunkGeneratorQueue.push(pChild.getValueCopy()); }
bool Sphere::Contains(const AABB &aabb) const { for(int i = 0; i < 8; ++i) if (!Contains(aabb.CornerPoint(i))) return false; return true; }
bool OBB::Contains(const AABB &aabb) const { // Since both AABB and OBB are convex objects, this OBB contains the AABB // if and only if it contains all its corner points. for(int i = 0; i < 8; ++i) if (!Contains(aabb.CornerPoint(i))) return false; return true; }
void ChunkManager::initTree1(ChunkTree& pChild) { boost::shared_ptr<Chunk>& pChunk = pChild.getValue(); AABB bounds = pChild.getParent()->getValue()->m_bounds; vec center = bounds.CenterPoint(); vec c0 = bounds.CornerPoint(pChild.getCorner().index()); AABB b0(vec(min(c0.x, center.x), min(c0.y, center.y), min(c0.z, center.z)), vec(max(c0.x, center.x), max(c0.y, center.y), max(c0.z, center.z))); pChunk = boost::make_shared<Chunk>(b0, 1.0f/pChild.getLevel(), this); pChunk->m_pTree = &pChild; pChunk->generateTerrain(); pChunk->generateMesh(); }
void Sphere::Enclose(const AABB &aabb) { ///@todo This might not be very optimal at all. Perhaps better to enclose the farthest point first. for(int i = 0; i < 8; ++i) Enclose(aabb.CornerPoint(i)); }