示例#1
0
bool NzLight::FrustumCull(const NzFrustumf& frustum)
{
	switch (m_type)
	{
		case nzLightType_Directional:
			return true; // Toujours visible

		case nzLightType_Point:
			if (!m_derivedUpdated)
				UpdateDerived();

			// Un test sphérique est bien plus rapide et précis que celui de la bounding box
			return frustum.Contains(NzSpheref(m_derivedPosition, m_radius));

		case nzLightType_Spot:
			if (!m_boundingVolumeUpdated)
				UpdateBoundingVolume();

			return frustum.Contains(m_boundingVolume);
	}

	NazaraError("Invalid light type (0x" + NzString::Number(m_type, 16) + ')');
	return false;
}
示例#2
0
	{
		NzFrustumf frustum;
		frustum.Build(NzFromDegrees(90.f), 1.f, 1.f, 1000.f, NzVector3f::Zero(), NzVector3f::UnitX());

		WHEN("We ask for intersection with objects outside the frustum")
		{
			THEN("These results are expected")
			{
				NzBoundingVolumef bv(NzVector3f::Zero(), NzVector3f::Unit());
				bv.Update(NzMatrix4f::Identity());
				REQUIRE(nzIntersectionSide_Outside == frustum.Intersect(bv));
				REQUIRE(nzIntersectionSide_Outside == frustum.Intersect(NzBoxf(NzVector3f::Zero(), NzVector3f::Unit() * 0.9f)));
				NzOrientedBoxf obb(NzVector3f::Zero(), NzVector3f::Unit() * 0.9f);
				obb.Update(NzMatrix4f::Identity());
				REQUIRE(nzIntersectionSide_Outside == frustum.Intersect(obb));
				REQUIRE(nzIntersectionSide_Outside == frustum.Intersect(NzSpheref(NzVector3f::Zero(), 0.5f)));
				NzVector3f tmp = NzVector3f::Zero();
				REQUIRE(nzIntersectionSide_Outside == frustum.Intersect(&tmp, 1));
				tmp = NzVector3f::UnitX() * -10.f;
				REQUIRE(nzIntersectionSide_Outside == frustum.Intersect(&tmp, 1));
			}
		}

		WHEN("We ask for intersection with objects inside the frustum")
		{
			THEN("These results are expected")
			{
				NzBoundingVolumef bv(500.f, -0.5f, -0.5f, 1.f, 1.f, 1.f);
				bv.Update(NzMatrix4f::Identity());

				REQUIRE(nzIntersectionSide_Inside == frustum.Intersect(bv));