<commit_before>/*
    Copyright (C) 2002 by <NAME>

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public
    License along with this library; if not, write to the Free
    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "cssysdef.h"
#include "csgeom/math2d.h"
#include "csgeom/math3d.h"
#include "csgeom/polyclip.h"
#include "csgeom/poly2d.h"
#include "csgeom/vector3.h"
#include "csutil/garray.h"
#include "iengine/camera.h"
#include "iengine/engine.h"
#include "ivideo/graph3d.h"
#include "ivideo/material.h"
#include "ivideo/vbufmgr.h"
#include "iengine/material.h"
#include "iengine/rview.h"
#include "ivideo/txtmgr.h"
#include "igraphic/image.h"
#include "iutil/objreg.h"
#include "iutil/vfs.h"
#include "imap/ldrctxt.h"
#include "csgfx/rgbpixel.h"
#include "bcterr.h"
#include "quadtree.h"
#include "qint.h"
#include "qsqrt.h"
#include "ivaria/reporter.h"
#include "quadtree.h"

bool Inside (csBox3 bbox, csVector3 *point)
{
  if ( ( point->x <= bbox.MaxX () ) && ( point->x >= bbox.MinX () ) 
    && ( point->z <= bbox.MaxZ () ) && ( point->z >= bbox.MinZ () )
    && ( point->y <= bbox.MaxY () ) )
    return true;
  else
    return false;
}


void csColQuad::HeightTest (csVector3  *point, 
		int &hits)
{
  if ( Inside (bbox, point) )
  {
    int i;
    for (i = 0; i < num_blocks; i++)
    {
      if ( Inside (blocks[i]->bbox, point) )
      {
        if ( point->y < (blocks[i]->bbox.MaxY () + 0.2f) )
        {
          point->y = blocks[i]->bbox.MaxY () + 0.2f;
          hits += 1;
        }
      }			
    }
    if (children[0])
    {
      for (i = 0; i < 4; i++)
        children[i]->HeightTest (point, hits);
    }
  }	
}

void csColQuad::HeightTestExt (csVector3  *point, 
    int &hits)
{
  return; // don't use yet
}

void csColQuad::HeightTestExact (csVector3  *point, 
    int &hits)
{
  if ( Inside (bbox, point) )
  {
    int i;
    for (i = 0; i < num_blocks; i++)
    {
      if ( Inside (blocks[i]->bbox, point) )
      {
        if (point->y <= blocks[i]->bbox.MaxY ())
        {
          csVector3 newpoint;
          float u, v;
          csVector3 temp[4];
  u = ( point->x - blocks[i]->bbox.MinX () )
    / (blocks[i]->bbox.MaxX () - blocks[i]->bbox.MinX ());
  v = (blocks[i]->bbox.MaxZ () - point->z)
    / (blocks[i]->bbox.MaxZ () - blocks[i]->bbox.MinZ ());
          if (u < 0.0f) u = -u;
          if (v < 0.0f) v = -v;
          if (u > 1.0f) u = 1.0f;
          if (v > 1.0f) v = 1.0f;
          temp[0] = BezierControlCompute (v, blocks[i]->verts, 4);
          temp[1] = BezierControlCompute (v, &blocks[i]->verts[1], 4);
          temp[2] = BezierControlCompute (v, &blocks[i]->verts[2], 4);
          temp[3] = BezierControlCompute (v, &blocks[i]->verts[3], 4);
          newpoint =  BezierCompute (u, temp);
          if ( (newpoint.y > point->y) || 
               (point->y < (newpoint.y + 1.0f)))
          {
            point->y = newpoint.y + 1.0f;
            hits += 1;
          }
          //point->y = newpoint.y + 10.0f;
        }
      }			
    }<commit_msg>no message<commit_after>/*
    Copyright (C) 2002 by <NAME>

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public
    License along with this library; if not, write to the Free
    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "cssysdef.h"
#include "csgeom/math2d.h"
#include "csgeom/math3d.h"
#include "csgeom/polyclip.h"
#include "csgeom/poly2d.h"
#include "csgeom/vector3.h"
#include "csutil/garray.h"
#include "iengine/camera.h"
#include "iengine/engine.h"
#include "ivideo/graph3d.h"
#include "ivideo/material.h"
#include "ivideo/vbufmgr.h"
#include "iengine/material.h"
#include "iengine/rview.h"
#include "ivideo/txtmgr.h"
#include "igraphic/image.h"
#include "iutil/objreg.h"
#include "iutil/vfs.h"
#include "imap/ldrctxt.h"
#include "csgfx/rgbpixel.h"
#include "bcterr.h"
#include "quadtree.h"
#include "qint.h"
#include "qsqrt.h"
#include "ivaria/reporter.h"
#include "quadtree.h"

bool Inside (csBox3 bbox, csVector3 *point)
{
  if ( ( point->x <= bbox.MaxX () ) && ( point->x >= bbox.MinX () ) 
    && ( point->z <= bbox.MaxZ () ) && ( point->z >= bbox.MinZ () )
    && ( point->y <= bbox.MaxY () ) )
    return true;
  else
    return false;
}


void csColQuad::HeightTest (csVector3  *point, 
		int &hits)
{
  if ( Inside (bbox, point) )
  {
    int i;
    for (i = 0; i < num_blocks; i++)
    {
      if ( Inside (blocks[i]->bbox, point) )
      {
        if ( point->y < (blocks[i]->bbox.MaxY () + 0.2f) )
        {
          point->y = blocks[i]->bbox.MaxY () + 0.2f;
          hits += 1;
        }
      }			
    }
    if (children[0])
    {
      for (i = 0; i < 4; i++)
        children[i]->HeightTest (point, hits);
    }
  }	
}

void csColQuad::HeightTestExt (csVector3  *point, 
    int &hits)
{
  return; // don't use yet
}

void csColQuad::HeightTestExact (csVector3  *point, 
    int &hits)
{
  if ( Inside (bbox, point) )
  {
    int i;
    for (i = 0; i < num_blocks; i++)
    {
      if ( Inside (blocks[i]->bbox, point) )
      {
        if (point->y <= blocks[i]->bbox.MaxY ())
        {
          csVector3 newpoint;
          float u, v;
          csVector3 temp[4];
  u = ( point->x - blocks[i]->bbox.MinX () )
    / (blocks[i]->bbox.MaxX () - blocks[i]->bbox.MinX ());
  v = (blocks[i]->bbox.MaxZ () - point->z)
    / (blocks[i]->bbox.MaxZ () - blocks[i]->bbox.MinZ ());
          if (u < 0.0f) u = -u;
          if (v < 0.0f) v = -v;
          if (u > 1.0f) u = 1.0f;
          if (v > 1.0f) v = 1.0f;
          temp[0] = BezierControlCompute (v, blocks[i]->verts, 4);
          temp[1] = BezierControlCompute (v, &blocks[i]->verts[1], 4);
          temp[2] = BezierControlCompute (v, &blocks[i]->verts[2], 4);
          temp[3] = BezierControlCompute (v, &blocks[i]->verts[3], 4);
          newpoint =  BezierCompute (u, temp);
          if ( (newpoint.y > point->y) || 
               (point->y < (newpoint.y + 2.0f)))
          {
            point->y = newpoint.y + 2.0f;
            hits += 1;
          }
          //point->y = newpoint.y + 10.0f;
        }
      }			
    }
{'fraction_non_alphanumeric': 0.16070185210973403, 'fraction_numerical': 0.018660353711182288, 'mean_word_length': 2.3342618384401113, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 75, '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': '5093997', 'n_tokens_mistral': 2742, 'n_tokens_neox': 2668, 'n_words': 693}