Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- template < std::size_t uMax >
- class capped_kdop
- ...
- bool isBBoxIn(const bounding_box3d& bbox, const matrix& world) const
- {
- float3 c = bbox.getCenter();
- float sizex = bbox.maxEdge.x - bbox.minEdge.x;
- float sizey = bbox.maxEdge.y - bbox.minEdge.y;
- float sizez = bbox.maxEdge.z - bbox.minEdge.z;
- float3 corners[8] =
- {
- float3((c.x - sizex * 0.5f), (c.y - sizey * 0.5f), (c.z - sizez * 0.5f)),
- float3((c.x + sizex * 0.5f), (c.y - sizey * 0.5f), (c.z - sizez * 0.5f)),
- float3((c.x - sizex * 0.5f), (c.y + sizey * 0.5f), (c.z - sizez * 0.5f)),
- float3((c.x + sizex * 0.5f), (c.y + sizey * 0.5f), (c.z - sizez * 0.5f)),
- float3((c.x - sizex * 0.5f), (c.y - sizey * 0.5f), (c.z + sizez * 0.5f)),
- float3((c.x + sizex * 0.5f), (c.y - sizey * 0.5f), (c.z + sizez * 0.5f)),
- float3((c.x - sizex * 0.5f), (c.y + sizey * 0.5f), (c.z + sizez * 0.5f)),
- float3((c.x + sizex * 0.5f), (c.y + sizey * 0.5f), (c.z + sizez * 0.5f))
- };
- for(unsigned int i = 0; i < 8; ++i)
- {
- world.transformVector(corners[i]);
- }
- for(unsigned short i = 0; i < total; ++i)
- {
- if(planes[i].getRelationWith(corners[0]) > 0.0f)
- {
- continue;
- }
- if(planes[i].getRelationWith(corners[1]) > 0.0f)
- {
- continue;
- }
- if(planes[i].getRelationWith(corners[2]) > 0.0f)
- {
- continue;
- }
- if(planes[i].getRelationWith(corners[3]) > 0.0f)
- {
- continue;
- }
- if(planes[i].getRelationWith(corners[4]) > 0.0f)
- {
- continue;
- }
- if(planes[i].getRelationWith(corners[5]) > 0.0f)
- {
- continue;
- }
- if(planes[i].getRelationWith(corners[6]) > 0.0f)
- {
- continue;
- }
- if(planes[i].getRelationWith(corners[7]) > 0.0f)
- {
- continue;
- }
- return false;
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement