mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-21 17:54:48 +01:00
Implement the use of the new vmap3-format by Lynx3d (mad props to you for this, and thanks for the talks earlier) + reduced Vmap size to less than one third, and improve precision + indoor/outdoor check which allows automatic unmounting of players + additional area information from WMOAreaTable.dbc, removed existing "hacks" + WMO liquid information for swimming and fishing correctly in buildings/cities/caves/instances (lava and slime WILL hurt from now on!) - buildfiles for windows are not properly done, and will need to be sorted out NOTE: Do NOT annoy Lynx3d about this, any issues with this "port" is entirely our fault ! THIS REVISION IS CONSIDERED UNSTABLE AND CONTAINS WORK IN PROGRESS - USE AT YOUR OWN RISK! --HG-- branch : trunk
106 lines
2.2 KiB
C++
106 lines
2.2 KiB
C++
/**
|
|
@file Line.h
|
|
|
|
Line class
|
|
|
|
@maintainer Morgan McGuire, http://graphics.cs.williams.edu
|
|
|
|
@created 2001-06-02
|
|
@edited 2006-02-28
|
|
*/
|
|
|
|
#ifndef G3D_LINE_H
|
|
#define G3D_LINE_H
|
|
|
|
#include "G3D/platform.h"
|
|
#include "G3D/Vector3.h"
|
|
|
|
namespace G3D {
|
|
|
|
class Plane;
|
|
|
|
/**
|
|
An infinite 3D line.
|
|
*/
|
|
class Line {
|
|
protected:
|
|
|
|
Vector3 _point;
|
|
Vector3 _direction;
|
|
|
|
Line(const Vector3& point, const Vector3& direction) {
|
|
_point = point;
|
|
_direction = direction.direction();
|
|
}
|
|
|
|
public:
|
|
|
|
/** Undefined (provided for creating Array<Line> only) */
|
|
inline Line() {}
|
|
|
|
Line(class BinaryInput& b);
|
|
|
|
void serialize(class BinaryOutput& b) const;
|
|
|
|
void deserialize(class BinaryInput& b);
|
|
|
|
virtual ~Line() {}
|
|
|
|
/**
|
|
Constructs a line from two (not equal) points.
|
|
*/
|
|
static Line fromTwoPoints(const Vector3 &point1, const Vector3 &point2) {
|
|
return Line(point1, point2 - point1);
|
|
}
|
|
|
|
/**
|
|
Creates a line from a point and a (nonzero) direction.
|
|
*/
|
|
static Line fromPointAndDirection(const Vector3& point, const Vector3& direction) {
|
|
return Line(point, direction);
|
|
}
|
|
|
|
/**
|
|
Returns the closest point on the line to point.
|
|
*/
|
|
Vector3 closestPoint(const Vector3& pt) const;
|
|
|
|
/**
|
|
Returns the distance between point and the line
|
|
*/
|
|
double distance(const Vector3& point) const {
|
|
return (closestPoint(point) - point).magnitude();
|
|
}
|
|
|
|
/** Returns a point on the line */
|
|
Vector3 point() const;
|
|
|
|
/** Returns the direction (or negative direction) of the line */
|
|
Vector3 direction() const;
|
|
|
|
/**
|
|
Returns the point where the line and plane intersect. If there
|
|
is no intersection, returns a point at infinity.
|
|
*/
|
|
Vector3 intersection(const Plane &plane) const;
|
|
|
|
|
|
/** Finds the closest point to the two lines.
|
|
|
|
@param minDist Returns the minimum distance between the lines.
|
|
|
|
@cite http://objectmix.com/graphics/133793-coordinates-closest-points-pair-skew-lines.html
|
|
*/
|
|
Vector3 closestPoint(const Line& B, float& minDist) const;
|
|
|
|
inline Vector3 closestPoint(const Line& B) const {
|
|
float m;
|
|
return closestPoint(B, m);
|
|
}
|
|
};
|
|
|
|
};// namespace
|
|
|
|
|
|
#endif
|