-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
33 changed files
with
1,601 additions
and
843 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#include "misc/shapes/Cone.h" | ||
|
||
namespace ne { | ||
|
||
Cone::Cone(const glm::vec3& location, float height, const glm::vec3& direction, float bottomRadius) { | ||
this->location = location; | ||
this->height = height; | ||
this->direction = direction; | ||
this->bottomRadius = bottomRadius; | ||
} | ||
|
||
bool Cone::isBehindPlane(const Plane& plane) const { | ||
// Source: Real-time collision detection, Christer Ericson (2005). | ||
|
||
// Calculate an intermediate vector which is parallel but opposite to plane's normal and perpendicular | ||
// to the cone's direction. | ||
glm::vec3 m = glm::cross(glm::cross(plane.normal, direction), direction); | ||
|
||
// Calculate the point Q that is on the base (bottom) of the cone that is farthest away from the plane | ||
// in the direction of plane's normal. | ||
glm::vec3 Q = location + direction * height - m * bottomRadius; | ||
|
||
// The cone is behind the plane if both cone's tip and Q are behind the plane. | ||
return plane.isPointBehindPlane(location) && plane.isPointBehindPlane(Q); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#include "misc/shapes/Sphere.h" | ||
|
||
namespace ne { | ||
|
||
Sphere::Sphere(const glm::vec3& center, float radius) { | ||
this->center = center; | ||
this->radius = radius; | ||
} | ||
|
||
bool Sphere::isBehindPlane(const Plane& plane) const { | ||
// Source: Real-time collision detection, Christer Ericson (2005). | ||
return glm::dot(plane.normal, center) - plane.distanceFromOrigin < -radius; | ||
} | ||
|
||
} |
Oops, something went wrong.