testS3DVertex.cpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #include "testUtils.h"
  2. #include "irrlicht.h"
  3. using namespace irr;
  4. using namespace core;
  5. using namespace video;
  6. // S3DVertex has operators which are used sometimes in sorting for example on loading meshes
  7. bool testSorting()
  8. {
  9. // Some test-values which did fail in the past.
  10. // See http://irrlicht.sourceforge.net/phpBB2/viewtopic.php?t=33391&highlight=
  11. core::map<video::S3DVertex, int> testmap;
  12. video::S3DVertex v;
  13. v.Pos = core::vector3df(1.000000f, -1.000000f, 1.000000f);
  14. v.Normal = core::vector3df(0.577350f, -0.577350f, 0.577350f);
  15. v.Color = SColor(255,204,204,204);
  16. v.TCoords = core::vector2d<f32>(0.f, 0.f);
  17. testmap.insert(v, 0);
  18. v.Pos = core::vector3df(-1.000000f, -1.000000f, 1.000000f);
  19. v.Normal = core::vector3df(-0.577350f, -0.577350f, 0.577350f);
  20. v.Color = SColor(255,204,204,204);
  21. v.TCoords = core::vector2d<f32>(0.f, 0.f);
  22. testmap.insert(v, 1);
  23. v.Pos = core::vector3df(1.000000f, 1.000000f, 1.000000f);
  24. v.Normal = core::vector3df(0.577350f, 0.577350f, 0.577350f);
  25. v.Color = SColor(255,204,204,204);
  26. v.TCoords = core::vector2d<f32>(0.f, 0.f);
  27. testmap.insert(v, 2);
  28. v.Pos = core::vector3df(1.000000f, -1.000000f, 1.000000f);
  29. v.Normal = core::vector3df(0.577350f, -0.577350f, 0.577350f);
  30. v.Color = SColor(255,204,204,204);
  31. v.TCoords = core::vector2d<f32>(0.f, 0.f);
  32. core::map<video::S3DVertex, int>::Node* n = testmap.find(v); // look for the vertex just inserted
  33. return n ? true : false;
  34. }
  35. bool testS3DVertex(void)
  36. {
  37. bool result = true;
  38. result &= testSorting();
  39. return result;
  40. }