2014-07-14 01:11:15 +00:00
|
|
|
/********************************************************************************
|
2015-02-15 20:56:45 +00:00
|
|
|
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
|
|
|
|
* Copyright (c) 2010-2015 Daniel Chappuis *
|
2014-07-14 01:11:15 +00:00
|
|
|
*********************************************************************************
|
|
|
|
* *
|
|
|
|
* This software is provided 'as-is', without any express or implied warranty. *
|
|
|
|
* In no event will the authors be held liable for any damages arising from the *
|
|
|
|
* use of this software. *
|
|
|
|
* *
|
|
|
|
* Permission is granted to anyone to use this software for any purpose, *
|
|
|
|
* including commercial applications, and to alter it and redistribute it *
|
|
|
|
* freely, subject to the following restrictions: *
|
|
|
|
* *
|
|
|
|
* 1. The origin of this software must not be misrepresented; you must not claim *
|
|
|
|
* that you wrote the original software. If you use this software in a *
|
|
|
|
* product, an acknowledgment in the product documentation would be *
|
|
|
|
* appreciated but is not required. *
|
|
|
|
* *
|
|
|
|
* 2. Altered source versions must be plainly marked as such, and must not be *
|
|
|
|
* misrepresented as being the original software. *
|
|
|
|
* *
|
|
|
|
* 3. This notice may not be removed or altered from any source distribution. *
|
|
|
|
* *
|
|
|
|
********************************************************************************/
|
|
|
|
|
|
|
|
#ifndef REACTPHYSICS3D_RAY_H
|
|
|
|
#define REACTPHYSICS3D_RAY_H
|
|
|
|
|
|
|
|
// Libraries
|
|
|
|
#include "Vector3.h"
|
|
|
|
|
|
|
|
/// ReactPhysics3D namespace
|
|
|
|
namespace reactphysics3d {
|
|
|
|
|
|
|
|
// Class Ray
|
|
|
|
/**
|
2014-10-21 20:26:40 +00:00
|
|
|
* This structure represents a 3D ray represented by two points.
|
|
|
|
* The ray goes from point1 to point1 + maxFraction * (point2 - point1).
|
|
|
|
* The points are specified in world-space coordinates.
|
2014-07-14 01:11:15 +00:00
|
|
|
*/
|
|
|
|
struct Ray {
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
// -------------------- Attributes -------------------- //
|
|
|
|
|
2014-10-21 20:26:40 +00:00
|
|
|
/// First point of the ray (origin)
|
|
|
|
Vector3 point1;
|
2014-07-14 01:11:15 +00:00
|
|
|
|
2014-10-21 20:26:40 +00:00
|
|
|
/// Second point of the ray
|
|
|
|
Vector3 point2;
|
|
|
|
|
|
|
|
/// Maximum fraction value
|
|
|
|
decimal maxFraction;
|
2014-07-14 01:11:15 +00:00
|
|
|
|
|
|
|
// -------------------- Methods -------------------- //
|
|
|
|
|
|
|
|
/// Constructor with arguments
|
2014-10-21 20:26:40 +00:00
|
|
|
Ray(const Vector3& p1, const Vector3& p2, decimal maxFrac = decimal(1.0))
|
|
|
|
: point1(p1), point2(p2), maxFraction(maxFrac) {
|
2014-07-21 21:08:18 +00:00
|
|
|
|
|
|
|
}
|
2014-07-14 01:11:15 +00:00
|
|
|
|
|
|
|
/// Copy-constructor
|
2014-10-21 20:26:40 +00:00
|
|
|
Ray(const Ray& ray) : point1(ray.point1), point2(ray.point2), maxFraction(ray.maxFraction) {
|
2014-07-21 21:08:18 +00:00
|
|
|
|
|
|
|
}
|
2014-07-14 01:11:15 +00:00
|
|
|
|
|
|
|
/// Destructor
|
2014-07-21 21:08:18 +00:00
|
|
|
~Ray() {
|
|
|
|
|
|
|
|
}
|
2014-07-14 01:11:15 +00:00
|
|
|
|
|
|
|
/// Overloaded assignment operator
|
2014-07-21 21:08:18 +00:00
|
|
|
Ray& operator=(const Ray& ray) {
|
|
|
|
if (&ray != this) {
|
2014-10-21 20:26:40 +00:00
|
|
|
point1 = ray.point1;
|
|
|
|
point2 = ray.point2;
|
|
|
|
maxFraction = ray.maxFraction;
|
2014-07-21 21:08:18 +00:00
|
|
|
}
|
|
|
|
return *this;
|
|
|
|
}
|
2014-07-14 01:11:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|