<commit_before>#include "Frustum.h"

using namespace Math;
using namespace Intersection;

Frustum::Frustum(float gap)
	: _plane(), _planeVertex(), _position(), _gap(gap)
{
}

void Frustum::Make(const Matrix &viewProjection)
{
	Matrix matInv;
	Matrix::Inverse(matInv, viewProjection);

	_planeVertex[0].x = -1.0f;	_planeVertex[0].y = -1.0f;	_planeVertex[0].z = 0.0f;
	_planeVertex[1].x =  1.0f;	_planeVertex[1].y = -1.0f;	_planeVertex[1].z = 0.0f;
	_planeVertex[2].x =  1.0f;	_planeVertex[2].y = -1.0f;	_planeVertex[2].z = 1.0f;
	_planeVertex[3].x = -1.0f;	_planeVertex[3].y = -1.0f;	_planeVertex[3].z = 1.0f;
	_planeVertex[4].x = -1.0f;	_planeVertex[4].y =  1.0f;	_planeVertex[4].z = 0.0f;
	_planeVertex[5].x =  1.0f;	_planeVertex[5].y =  1.0f;	_planeVertex[5].z = 0.0f;
	_planeVertex[6].x =  1.0f;	_planeVertex[6].y =  1.0f;	_planeVertex[6].z = 1.0f;
	_planeVertex[7].x = -1.0f;	_planeVertex[7].y =  1.0f;	_planeVertex[7].z = 1.0f;

	for(int i=0; i<8; ++i)
		Vector3::TransformCoord(_planeVertex[i], _planeVertex[i], matInv);

	_position = (_planeVertex[0] + _planeVertex[5]) / 2.0f;

	Plane::FromPoints(_plane[0], _planeVertex[4], _planeVertex[7], _planeVertex[6]);	//  (top)
	Plane::FromPoints(_plane[1], _planeVertex[0], _planeVertex[1], _planeVertex[2]);	//  (bottom)
	Plane::FromPoints(_plane[2], _planeVertex[0], _planeVertex[4], _planeVertex[5]);	//  (near)
	Plane::FromPoints(_plane[3], _planeVertex[2], _planeVertex[6], _planeVertex[7]);	//  (far)
	Plane::FromPoints(_plane[4], _planeVertex[0], _planeVertex[3], _planeVertex[7]);	//  (left)
	Plane::FromPoints(_plane[5], _planeVertex[1], _planeVertex[5], _planeVertex[6]);	//  (right)
}

bool Frustum::In(const Vector3 &v, float radius) const
{
	float dist = 0.0f;
	for(uint i=0; i<6; ++i)
	{
		dist = Plane::DotCoord(_plane[i], v);

		if(dist > (radius + _gap) )<commit_msg>Update Frustum.cpp<commit_after>#include "Frustum.h"

using namespace Math;
using namespace Intersection;

void Frustum::Make(const Matrix &viewProjection)
{
	Matrix matInv;
	Matrix::Inverse(matInv, viewProjection);

	_planeVertex[0].x = -1.0f;	_planeVertex[0].y = -1.0f;	_planeVertex[0].z = 0.0f;
	_planeVertex[1].x =  1.0f;	_planeVertex[1].y = -1.0f;	_planeVertex[1].z = 0.0f;
	_planeVertex[2].x =  1.0f;	_planeVertex[2].y = -1.0f;	_planeVertex[2].z = 1.0f;
	_planeVertex[3].x = -1.0f;	_planeVertex[3].y = -1.0f;	_planeVertex[3].z = 1.0f;
	_planeVertex[4].x = -1.0f;	_planeVertex[4].y =  1.0f;	_planeVertex[4].z = 0.0f;
	_planeVertex[5].x =  1.0f;	_planeVertex[5].y =  1.0f;	_planeVertex[5].z = 0.0f;
	_planeVertex[6].x =  1.0f;	_planeVertex[6].y =  1.0f;	_planeVertex[6].z = 1.0f;
	_planeVertex[7].x = -1.0f;	_planeVertex[7].y =  1.0f;	_planeVertex[7].z = 1.0f;

	for(int i=0; i<8; ++i)
		Vector3::TransformCoord(_planeVertex[i], _planeVertex[i], matInv);

	_position = (_planeVertex[0] + _planeVertex[5]) / 2.0f;

	Plane::FromPoints(_plane[0], _planeVertex[4], _planeVertex[7], _planeVertex[6]);	// 상 평면(top)
	Plane::FromPoints(_plane[1], _planeVertex[0], _planeVertex[1], _planeVertex[2]);	// 하 평면(bottom)
	Plane::FromPoints(_plane[2], _planeVertex[0], _planeVertex[4], _planeVertex[5]);	// 근 평면(near)
	Plane::FromPoints(_plane[3], _planeVertex[2], _planeVertex[6], _planeVertex[7]);	// 원 평면(far)
	Plane::FromPoints(_plane[4], _planeVertex[0], _planeVertex[3], _planeVertex[7]);	// 좌 평면(left)
	Plane::FromPoints(_plane[5], _planeVertex[1], _planeVertex[5], _planeVertex[6]);	// 우 평면(right)
}

bool Frustum::In(const Vector3 &v, float radius) const
{
	for(uint i=0; i<6; ++i)
	{
		float dist = Plane::DotCoord(_plane[i], v);

		if(dist > radius)
{'fraction_non_alphanumeric': 0.20396205357142858, 'fraction_numerical': 0.05970982142857143, 'mean_word_length': 5.181034482758621, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3096554', 'n_tokens_mistral': 1663, 'n_tokens_neox': 1639, 'n_words': 260}