aboutsummaryrefslogtreecommitdiff
path: root/externals/g3dlite/G3D.lib/source/Cone.cpp
diff options
context:
space:
mode:
authorXanadu <none@none>2010-07-20 02:49:28 +0200
committerXanadu <none@none>2010-07-20 02:49:28 +0200
commit79622802f397258ee0f34327ba3ae6977ca3e7ff (patch)
tree1868946c234ab9ee256a6b7766a15713eae94235 /externals/g3dlite/G3D.lib/source/Cone.cpp
parent7dd2dc91816ab8b3bc3b99a1b1c99c7ea314d5a8 (diff)
parentf906976837502fa5aa81b982b901d1509f5aa0c4 (diff)
Merge. Revision history for source files should be all back now.
--HG-- branch : trunk rename : sql/CMakeLists.txt => sql/tools/CMakeLists.txt rename : src/server/game/Pools/PoolHandler.cpp => src/server/game/Pools/PoolMgr.cpp rename : src/server/game/Pools/PoolHandler.h => src/server/game/Pools/PoolMgr.h rename : src/server/game/PrecompiledHeaders/NixCorePCH.cpp => src/server/game/PrecompiledHeaders/gamePCH.cpp rename : src/server/game/PrecompiledHeaders/NixCorePCH.h => src/server/game/PrecompiledHeaders/gamePCH.h
Diffstat (limited to 'externals/g3dlite/G3D.lib/source/Cone.cpp')
-rw-r--r--externals/g3dlite/G3D.lib/source/Cone.cpp79
1 files changed, 0 insertions, 79 deletions
diff --git a/externals/g3dlite/G3D.lib/source/Cone.cpp b/externals/g3dlite/G3D.lib/source/Cone.cpp
deleted file mode 100644
index 99b29b5b0af..00000000000
--- a/externals/g3dlite/G3D.lib/source/Cone.cpp
+++ /dev/null
@@ -1,79 +0,0 @@
-/**
- @file Cone.cpp
-
- Cone class
-
- @maintainer Morgan McGuire, matrix@graphics3d.com
-
- @created 2001-07-09
- @edited 2006-01-29
-*/
-
-#include "G3D/platform.h"
-#include "G3D/Cone.h"
-#include "G3D/Line.h"
-#include "G3D/Sphere.h"
-#include "G3D/Box.h"
-
-namespace G3D {
-
-Cone::Cone(const Vector3 &tip, const Vector3 &direction, float angle) {
- this->tip = tip;
- this->direction = direction.direction();
- this->angle = angle;
-
- debugAssert(angle >= 0);
- debugAssert(angle <= pi());
-}
-
-/**
- Forms the smallest cone that contains the box. Undefined if
- the tip is inside or on the box.
- */
-Cone::Cone(const Vector3& tip, const Box& box) {
- this->tip = tip;
- this->direction = (box.center() - tip).direction();
-
- // Find the biggest angle
- float smallestDotProduct = direction.dot((box.corner(0) - tip).direction());
-
- for (int i = 1; i < 8; ++i) {
- float dp = direction.dot((box.corner(i) - tip).direction());
-
- debugAssert(dp > 0);
-
- if (dp < smallestDotProduct) {
- smallestDotProduct = dp;
- }
- }
-
- angle = acosf(smallestDotProduct);
-}
-
-
-bool Cone::intersects(const Sphere& b) const {
- // If the bounding sphere contains the tip, then
- // they definitely touch.
- if (b.contains(this->tip)) {
- return true;
- }
-
- // Move the tip backwards, effectively making the cone bigger
- // to account for the radius of the sphere.
-
- Vector3 tip = this->tip - direction * b.radius / sinf(angle);
-
- return Cone(tip, direction, angle).contains(b.center);
-}
-
-
-bool Cone::contains(const Vector3& v) const {
-
- Vector3 d = (v - tip).direction();
-
- float x = d.dot(direction);
-
- return (x > 0) && (x >= cosf(angle));
-}
-
-}; // namespace