File: Tests_Detour.cpp

package info (click to toggle)
recastnavigation 1.5.1%2Bgit20210215.e75adf8-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, trixie
  • size: 3,964 kB
  • sloc: cpp: 41,226; ansic: 2,674; xml: 182; makefile: 21
file content (33 lines) | stat: -rw-r--r-- 773 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include "catch.hpp"

#include "DetourCommon.h"

TEST_CASE("dtRandomPointInConvexPoly")
{
	SECTION("Properly works when the argument 's' is 1.0f")
	{
		const float pts[] = {
			0, 0, 0,
			0, 0, 1,
			1, 0, 0,
		};
		const int npts = 3;
		float areas[6];
		float out[3];

		dtRandomPointInConvexPoly(pts, npts, areas, 0.0f, 1.0f, out);
		REQUIRE(out[0] == Approx(0));
		REQUIRE(out[1] == Approx(0));
		REQUIRE(out[2] == Approx(1));

		dtRandomPointInConvexPoly(pts, npts, areas, 0.5f, 1.0f, out);
		REQUIRE(out[0] == Approx(1.0f / 2));
		REQUIRE(out[1] == Approx(0));
		REQUIRE(out[2] == Approx(1.0f / 2));

		dtRandomPointInConvexPoly(pts, npts, areas, 1.0f, 1.0f, out);
		REQUIRE(out[0] == Approx(1));
		REQUIRE(out[1] == Approx(0));
		REQUIRE(out[2] == Approx(0));
	}
}