Пример #1
0
void CheckWeights(const glm::ivec2& size,
                  Buffer<glm::vec2>& buffer,
                  FluidSim& sim,
                  float error = 1e-6)
{
  std::vector<glm::vec2> pixels(size.x * size.y);
  CopyTo(buffer, pixels);

  for (int i = 1; i < size.x - 1; i++)
  {
    for (int j = 1; j < size.y - 1; j++)
    {
      int index = i + size.x * j;
      EXPECT_NEAR(sim.matrix(index - 1, index), pixels[index].x, error);
      EXPECT_NEAR(sim.matrix(index, index - size.x), pixels[index].y, error);
    }
  }
}
Пример #2
0
void PrintDiagonal(const glm::ivec2& size, FluidSim& sim)
{
  for (int j = 0; j < size.y; j++)
  {
    for (int i = 0; i < size.x; i++)
    {
      int index = i + size.x * j;
      std::cout << "(" << sim.matrix(index, index) << ")";
    }
    std::cout << std::endl;
  }
}
Пример #3
0
void CheckDiagonal(const glm::ivec2& size, Buffer<float>& buffer, FluidSim& sim, float error = 1e-6)
{
  std::vector<float> pixels(size.x * size.y);
  CopyTo(buffer, pixels);

  for (int i = 0; i < size.x; i++)
  {
    for (int j = 0; j < size.y; j++)
    {
      int index = i + size.x * j;
      EXPECT_NEAR(sim.matrix(index, index), pixels[index], error);
    }
  }
}