<commit_before>#include "./frustum_optimizer.h"
#include <limits>
#include <algorithm>
#include "./nodes.h"

FrustumOptimizer::FrustumOptimizer(std::shared_ptr<Nodes> nodes) : nodes(nodes)
{
}

void FrustumOptimizer::update(Eigen::Matrix4f viewMatrix)
{
  float min = std::numeric_limits<float>::max();
  float max = -min;
  for (auto node : nodes->getNodes())
  {
    auto obb = node->getObb();
    if (!obb.isInitialized())
      continue;

    for (int i = 0; i < 8; ++i)
    {
      auto point = obb.corners[i];

      Eigen::Vector4f transformed = mul(viewMatrix, point);

      if (transformed.z() < min)
        min = transformed.z();

      if (transformed.z() > max)
        max = transformed.z();
    }
  }

  near = std::max(0.001f, -max - 0.1f);
  far = -min + 0.1f;
}

float FrustumOptimizer::getNear()
{
  return near;
}

float FrustumOptimizer::getFar()
{
  return far;
}
<commit_msg>MSVC compatibility - avoid near, far, min and max as variable names.<commit_after>#include "./frustum_optimizer.h"
#include <limits>
#include <algorithm>
#include "./nodes.h"

FrustumOptimizer::FrustumOptimizer(std::shared_ptr<Nodes> nodes) : nodes(nodes)
{
}

void FrustumOptimizer::update(Eigen::Matrix4f viewMatrix)
{
  float fmin = std::numeric_limits<float>::max();
  float fmax = -fmin;
  for (auto node : nodes->getNodes())
  {
    auto obb = node->getObb();
    if (!obb.isInitialized())
      continue;

    for (int i = 0; i < 8; ++i)
    {
      auto point = obb.corners[i];

      Eigen::Vector4f transformed = mul(viewMatrix, point);

      if (transformed.z() < fmin)
        fmin = transformed.z();

      if (transformed.z() > fmax)
        fmax = transformed.z();
    }
  }

  m_near = std::max(0.001f, -fmax - 0.1f);
  m_far = -fmin + 0.1f;
}

float FrustumOptimizer::getNear()
{
  return m_near;
}

float FrustumOptimizer::getFar()
{
  return m_far;
}

{'fraction_non_alphanumeric': 0.16363636363636364, 'fraction_numerical': 0.012834224598930482, 'mean_word_length': 3.271689497716895, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2101395', 'n_tokens_mistral': 734, 'n_tokens_neox': 701, 'n_words': 148}