aboutsummaryrefslogtreecommitdiff
path: root/tests/testS3DVertex.cpp
blob: aacbb5f50a969fe50bcc98342ba499f94ac19a46 (plain)
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include "testUtils.h"
#include "irrlicht.h"
#include <assert.h>

using namespace irr;
using namespace core;
using namespace video;

// S3DVertex has operators which are used sometimes in sorting for example on loading meshes
bool testSorting()
{
	// Some test-values which did fail in the past.
	// See http://irrlicht.sourceforge.net/phpBB2/viewtopic.php?t=33391&highlight=
	core::map<video::S3DVertex, int> testmap;
	video::S3DVertex v;
	v.Pos = core::vector3df(1.000000f, -1.000000f, 1.000000f);
	v.Normal = core::vector3df(0.577350f, -0.577350f, 0.577350f);
	v.Color = SColor(255,204,204,204);
	v.TCoords = core::vector2d<f32>(0.f, 0.f);
	testmap.insert(v, 0);

	v.Pos = core::vector3df(-1.000000f, -1.000000f, 1.000000f);
	v.Normal = core::vector3df(-0.577350f, -0.577350f, 0.577350f);
	v.Color = SColor(255,204,204,204);
	v.TCoords = core::vector2d<f32>(0.f, 0.f);
	testmap.insert(v, 1);

	v.Pos = core::vector3df(1.000000f, 1.000000f, 1.000000f);
	v.Normal = core::vector3df(0.577350f, 0.577350f, 0.577350f);
	v.Color = SColor(255,204,204,204);
	v.TCoords = core::vector2d<f32>(0.f, 0.f);
	testmap.insert(v, 2);

	v.Pos = core::vector3df(1.000000f, -1.000000f, 1.000000f);
	v.Normal = core::vector3df(0.577350f, -0.577350f, 0.577350f);
	v.Color = SColor(255,204,204,204);
	v.TCoords = core::vector2d<f32>(0.f, 0.f);

	core::map<video::S3DVertex, int>::Node* n = testmap.find(v);	// look for the vertex just inserted
	return n ? true : false;
}

bool testS3DVertex(void)
{
	bool result = true;
	result &= testSorting();
	return result;
}