<commit_before>/* bzflag
 * Copyright (c) 1993 - 2004 <NAME>
 *
 * This package is free software;  you can redistribute it and/or
 * modify it under the terms of the license found in the file
 * named COPYING that should have accompanied this file.
 *
 * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 */

/*
 * Utilities for doing intersection calculations.
 */

#ifndef	BZF_INTERSECT_H
#define	BZF_INTERSECT_H

#include "common.h"
#include "Ray.h"
#include "Frustum.h"

class Extents;

enum IntersectLevel {
  Outside,
  Partial,
  Contained
};

// returns normal to 2d rect (size 2dx x 2dy) by point p
void			getNormalRect(const float* p, const float* boxPos,
					float boxAngle, float dx,
					float dy, float* n);

// true iff 2d rect (size 2dx x 2dy) intersects circle (in z = const plane)
bool			testRectCircle(const float* boxPos, float boxAngle,
					float dx, float dy,
					const float* circPos, float circRadius);

// ray r1 started at time t1 minus ray r2 started at time t2
Ray			rayMinusRay(const Ray& r1, float t1,
					const Ray& r2, float t2);

// return t at which ray passes through sphere at origin of given radius
float			rayAtDistanceFromOrigin(const Ray& r, float radius);

// return t at which ray intersects box (size 2dx x 2dy x 2dz)
// (-1 if never, 0 if starts inside).
float			timeRayHitsBlock(const Ray& r, const float* boxPos,
					float boxAngle, float dx,
					float dy, float dz);

// return t at which ray intersects pyramid (size 2dx x 2dy x dz)
// (-1 if never, 0 if starts inside).
float			timeRayHitsPyramids(const Ray& r,
					    const float* pyrPos,
					    float pyrAngle,
					    float dx, float dy, float dz,
					    bool flipZ);

// return t at which ray intersects tetra (size 2dx x 2dy x dz)<commit_msg>fix comment for ray/block check, for z the box is from 0-dz only<commit_after>/* bzflag
 * Copyright (c) 1993 - 2004 <NAME>
 *
 * This package is free software;  you can redistribute it and/or
 * modify it under the terms of the license found in the file
 * named COPYING that should have accompanied this file.
 *
 * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 */

/*
 * Utilities for doing intersection calculations.
 */

#ifndef	BZF_INTERSECT_H
#define	BZF_INTERSECT_H

#include "common.h"
#include "Ray.h"
#include "Frustum.h"

class Extents;

enum IntersectLevel {
  Outside,
  Partial,
  Contained
};

// returns normal to 2d rect (size 2dx x 2dy) by point p
void			getNormalRect(const float* p, const float* boxPos,
					float boxAngle, float dx,
					float dy, float* n);

// true iff 2d rect (size 2dx x 2dy) intersects circle (in z = const plane)
bool			testRectCircle(const float* boxPos, float boxAngle,
					float dx, float dy,
					const float* circPos, float circRadius);

// ray r1 started at time t1 minus ray r2 started at time t2
Ray			rayMinusRay(const Ray& r1, float t1,
					const Ray& r2, float t2);

// return t at which ray passes through sphere at origin of given radius
float			rayAtDistanceFromOrigin(const Ray& r, float radius);

// return t at which ray intersects box (size 2dx x 2dy x dz)
// (-1 if never, 0 if starts inside).
float			timeRayHitsBlock(const Ray& r, const float* boxPos,
					float boxAngle, float dx,
					float dy, float dz);

// return t at which ray intersects pyramid (size 2dx x 2dy x dz)
// (-1 if never, 0 if starts inside).
float			timeRayHitsPyramids(const Ray& r,
					    const float* pyrPos,
					    float pyrAngle,
					    float dx, float dy, float dz,
					    bool flipZ);

// return t at which ray intersects tetra (size 2dx x 2dy x dz)
{'fraction_non_alphanumeric': 0.08040330920372285, 'fraction_numerical': 0.017063081695966906, 'mean_word_length': 3.2941176470588234, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '614610', 'n_tokens_mistral': 1385, 'n_tokens_neox': 1201, 'n_words': 551}