#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <math.h>
#include <float.h>
#include <stdarg.h>
#include <setjmp.h>
#include "cd_hull.h"
Go to the source code of this file.
Classes | |
class | ConvexDecomposition::Array< Type > |
class | ConvexDecomposition::ArrayRet< Type > |
class | ConvexDecomposition::ConvexH |
class | ConvexDecomposition::Coplanar |
class | ConvexDecomposition::double2 |
class | ConvexDecomposition::double3 |
class | ConvexDecomposition::double3x3 |
class | ConvexDecomposition::double4 |
class | ConvexDecomposition::double4x4 |
class | ConvexDecomposition::EdgeFlag |
class | ConvexDecomposition::ConvexH::HalfEdge |
class | ConvexDecomposition::int3 |
class | ConvexDecomposition::int4 |
class | ConvexDecomposition::PHullResult |
class | ConvexDecomposition::Plane |
class | ConvexDecomposition::PlaneFlag |
class | ConvexDecomposition::Quaternion |
class | ConvexDecomposition::Tri |
class | ConvexDecomposition::VertFlag |
Namespaces | |
namespace | ConvexDecomposition |
Defines | |
#define | COPLANAR (0) |
#define | DEG2RAD (PI / 180.0f) |
#define | EPSILON 0.000001f |
#define | NX_ALLOC(x, y) malloc(x) |
#define | NX_FREE(x) free(x) |
#define | OFFSET(Class, Member) (((char*) (&(((Class*)NULL)-> Member )))- ((char*)NULL)) |
#define | OVER (2) |
#define | PAPERWIDTH (0.001f) |
#define | PI (3.1415926535897932384626433832795f) |
#define | RAD2DEG (180.0f / PI) |
#define | REAL double |
#define | REAL3 double3 |
#define | SPLIT (OVER|UNDER) |
#define | SQRT_OF_2 (1.4142135f) |
#define | STANDALONE 1 |
#define | TSCALE1 (1.0f/4.0f) |
#define | UNDER (1) |
#define | VOLUME_EPSILON (1e-20f) |
Typedefs | |
typedef ConvexH::HalfEdge | ConvexDecomposition::HalfEdge |
Functions | |
int | ConvexDecomposition::above (double3 *vertices, const int3 &t, const double3 &p, double epsilon) |
static void | ConvexDecomposition::AddPoint (unsigned int &vcount, double *p, double x, double y, double z) |
static double | ConvexDecomposition::area2 (const double3 &v0, const double3 &v1, const double3 &v2) |
int | ConvexDecomposition::argmin (double a[], int n) |
int | ConvexDecomposition::AssertIntact (ConvexH &convex) |
int | ConvexDecomposition::b2b (const int3 &a, const int3 &b) |
void | ConvexDecomposition::b2bfix (Tri *s, Tri *t) |
int | ConvexDecomposition::BoxInside (const double3 &p, const double3 &bmin, const double3 &bmax) |
int | ConvexDecomposition::BoxIntersect (const double3 &v0, const double3 &v1, const double3 &bmin, const double3 &bmax, double3 *impact) |
int | ConvexDecomposition::calchull (double3 *verts, int verts_count, int *&tris_out, int &tris_count, int vlimit) |
int | ConvexDecomposition::calchullgen (double3 *verts, int verts_count, int vlimit) |
int | ConvexDecomposition::calchullpbev (double3 *verts, int verts_count, int vlimit, Array< Plane > &planes, double bevangle) |
static int | ConvexDecomposition::candidateplane (Plane *planes, int planes_count, ConvexH *convex, double epsilon) |
void | ConvexDecomposition::checkit (Tri *t) |
double | ConvexDecomposition::clampf (double a) |
double3 | ConvexDecomposition::cmul (const double3 &a, const double3 &b) |
double4 | ConvexDecomposition::cmul (const double4 &a, const double4 &b) |
bool | ConvexDecomposition::ComputeHull (unsigned int vcount, const double *vertices, PHullResult &result, unsigned int maxverts, double inflate) |
ConvexH * | ConvexDecomposition::ConvexHCrop (ConvexH &convex, const Plane &slice) |
ConvexH * | ConvexDecomposition::ConvexHDup (ConvexH *src) |
ConvexH * | ConvexDecomposition::ConvexHMakeCube (const REAL3 &bmin, const REAL3 &bmax) |
int | ConvexDecomposition::coplanar (const Plane &a, const Plane &b) |
double3 | ConvexDecomposition::cross (const double3 &a, const double3 &b) |
double | ConvexDecomposition::Determinant (const double3x3 &m) |
double | ConvexDecomposition::DistanceBetweenLines (const double3 &ustart, const double3 &udir, const double3 &vstart, const double3 &vdir, double3 *upoint=NULL, double3 *vpoint=NULL) |
double | ConvexDecomposition::dot (const double3 &a, const double3 &b) |
double | ConvexDecomposition::dot (const Quaternion &a, const Quaternion &b) |
Tri * | ConvexDecomposition::extrudable (double epsilon) |
void | ConvexDecomposition::extrude (Tri *t0, int v) |
int4 | ConvexDecomposition::FindSimplex (double3 *verts, int verts_count, Array< int > &allow) |
double | ConvexDecomposition::GetDist (double px, double py, double pz, const double *p2) |
int | ConvexDecomposition::hasedge (const int3 &t, int a, int b) |
int | ConvexDecomposition::hasvert (const int3 &t, int v) |
bool | ConvexDecomposition::hasVolume (double3 *verts, int p0, int p1, int p2, int p3) |
double4 | ConvexDecomposition::Homogenize (const double3 &v3, const double &w=1.0f) |
double | ConvexDecomposition::Interpolate (const double &f0, const double &f1, double alpha) |
double3 | ConvexDecomposition::Interpolate (const double3 &v0, const double3 &v1, double alpha) |
Quaternion | ConvexDecomposition::Interpolate (const Quaternion &q0, const Quaternion &q1, double alpha) |
double3x3 | ConvexDecomposition::Inverse (const double3x3 &a) |
double4x4 | ConvexDecomposition::Inverse (const double4x4 &m) |
Quaternion | ConvexDecomposition::Inverse (const Quaternion &q) |
int | ConvexDecomposition::isa (const int3 &a, const int3 &b) |
double3 | ConvexDecomposition::LineProject (const double3 &p0, const double3 &p1, const double3 &a) |
double | ConvexDecomposition::LineProjectTime (const double3 &p0, const double3 &p1, const double3 &a) |
double | ConvexDecomposition::magnitude (const double3 &v) |
double4x4 | ConvexDecomposition::MatrixFromQuatVec (const Quaternion &q, const double3 &v) |
double4x4 | ConvexDecomposition::MatrixLookAt (const double3 &eye, const double3 &at, const double3 &up) |
double4x4 | ConvexDecomposition::MatrixPerspectiveFov (double fovy, double Aspect, double zn, double zf) |
double4x4 | ConvexDecomposition::MatrixRigidInverse (const double4x4 &m) |
double4x4 | ConvexDecomposition::MatrixRotationZ (const double angle_radians) |
double4x4 | ConvexDecomposition::MatrixTranslation (const double3 &t) |
double4x4 | ConvexDecomposition::MatrixTranspose (const double4x4 &m) |
template<class T > | |
T | ConvexDecomposition::Max (const T &a, const T &b) |
template<class T > | |
int | ConvexDecomposition::maxdir (const T *p, int count, const T &dir) |
template<class T > | |
int | ConvexDecomposition::maxdirfiltered (const T *p, int count, const T &dir, Array< int > &allow) |
template<class T > | |
int | ConvexDecomposition::maxdirsterid (const T *p, int count, const T &dir, Array< int > &allow) |
template<class T > | |
T | ConvexDecomposition::Min (const T &a, const T &b) |
double3 | ConvexDecomposition::normalize (const double3 &v) |
Quaternion | ConvexDecomposition::normalize (Quaternion a) |
double3 | ConvexDecomposition::NormalOf (const double3 *vert, const int n) |
int | ConvexDecomposition::operator!= (const double3 &a, const double3 &b) |
double3 | ConvexDecomposition::operator* (const double3 &v, const double s) |
double3 | ConvexDecomposition::operator* (const double s, const double3 &v) |
double3 | ConvexDecomposition::operator* (const double3 &v, const double3x3 &m) |
double3 | ConvexDecomposition::operator* (const double3x3 &m, const double3 &v) |
double3x3 | ConvexDecomposition::operator* (const double3x3 &m, const double &s) |
double3x3 | ConvexDecomposition::operator* (const double3x3 &ma, const double3x3 &mb) |
double4 | ConvexDecomposition::operator* (const double4 &v, double s) |
double4 | ConvexDecomposition::operator* (double s, const double4 &v) |
double4x4 | ConvexDecomposition::operator* (const double4x4 &a, const double4x4 &b) |
double4 | ConvexDecomposition::operator* (const double4 &v, const double4x4 &m) |
Quaternion | ConvexDecomposition::operator* (const Quaternion &a, double s) |
Quaternion | ConvexDecomposition::operator* (const Quaternion &a, const Quaternion &b) |
double3 | ConvexDecomposition::operator* (const Quaternion &q, const double3 &v) |
double3 | ConvexDecomposition::operator* (const double3 &v, const Quaternion &q) |
double3 & | ConvexDecomposition::operator*= (double3 &v, const double s) |
double3x3 & | ConvexDecomposition::operator*= (double3x3 &a, const double &s) |
Quaternion & | ConvexDecomposition::operator*= (Quaternion &a, double s) |
double2 | ConvexDecomposition::operator+ (const double2 &a, const double2 &b) |
double3 | ConvexDecomposition::operator+ (const double3 &a, const double3 &b) |
double3x3 | ConvexDecomposition::operator+ (const double3x3 &a, const double3x3 &b) |
double4 | ConvexDecomposition::operator+ (const double4 &a, const double4 &b) |
Quaternion | ConvexDecomposition::operator+ (const Quaternion &a, const Quaternion &b) |
double3 & | ConvexDecomposition::operator+= (double3 &a, const double3 &b) |
double3x3 & | ConvexDecomposition::operator+= (double3x3 &a, const double3x3 &b) |
double2 | ConvexDecomposition::operator- (const double2 &a, const double2 &b) |
double3 | ConvexDecomposition::operator- (const double3 &a, const double3 &b) |
double3 | ConvexDecomposition::operator- (const double3 &v) |
double3x3 | ConvexDecomposition::operator- (const double3x3 &a, const double3x3 &b) |
double4 | ConvexDecomposition::operator- (const double4 &a, const double4 &b) |
double3 & | ConvexDecomposition::operator-= (double3 &a, const double3 &b) |
double3x3 & | ConvexDecomposition::operator-= (double3x3 &a, const double3x3 &b) |
double3 | ConvexDecomposition::operator/ (const double3 &v, const double s) |
double3x3 | ConvexDecomposition::operator/ (const double3x3 &a, const double &s) |
double3 & | ConvexDecomposition::operator/= (double3 &v, const double s) |
int | ConvexDecomposition::operator== (const double3 &a, const double3 &b) |
int | ConvexDecomposition::operator== (const double4 &a, const double4 &b) |
int | ConvexDecomposition::operator== (const double4x4 &a, const double4x4 &b) |
int | ConvexDecomposition::operator== (const Plane &a, const Plane &b) |
int | ConvexDecomposition::operator== (const int3 &a, const int3 &b) |
double3 | ConvexDecomposition::orth (const double3 &v) |
static int | ConvexDecomposition::overhull (Plane *planes, int planes_count, double3 *verts, int verts_count, int maxplanes, double3 *&verts_out, int &verts_count_out, int *&faces_out, int &faces_count_out, double inflate) |
static int | ConvexDecomposition::overhullv (double3 *verts, int verts_count, int maxplanes, double3 *&verts_out, int &verts_count_out, int *&faces_out, int &faces_count_out, double inflate, double bevangle, int vlimit) |
double | ConvexDecomposition::Pitch (const Quaternion &q) |
double | ConvexDecomposition::Pitch (const double3 &v) |
Plane | ConvexDecomposition::PlaneFlip (const Plane &plane) |
double3 | ConvexDecomposition::PlaneLineIntersection (const Plane &plane, const double3 &p0, const double3 &p1) |
double3 | ConvexDecomposition::PlaneProject (const Plane &plane, const double3 &point) |
int | ConvexDecomposition::PlaneTest (const Plane &p, const REAL3 &v) |
int | ConvexDecomposition::PolyHit (const double3 *vert, const int n, const double3 &v0, const double3 &v1, double3 *impact=NULL, double3 *normal=NULL) |
void | ConvexDecomposition::ReleaseHull (PHullResult &result) |
void | ConvexDecomposition::removeb2b (Tri *s, Tri *t) |
double | ConvexDecomposition::Roll (Quaternion q) |
int3 | ConvexDecomposition::roll3 (int3 a) |
Quaternion | ConvexDecomposition::RotationArc (double3 v0, double3 v1) |
double | ConvexDecomposition::Round (double a, double precision) |
double3 | ConvexDecomposition::Round (const double3 &a, double precision) |
double3 | ConvexDecomposition::safenormalize (const double3 &v) |
int | ConvexDecomposition::shareedge (const int3 &a, const int3 &b) |
Quaternion | ConvexDecomposition::slerp (Quaternion a, const Quaternion &b, double interp) |
int | ConvexDecomposition::SplitTest (ConvexH &convex, const Plane &plane) |
double | ConvexDecomposition::sqr (double a) |
template<class T > | |
void | ConvexDecomposition::Swap (T &a, T &b) |
ConvexH * | ConvexDecomposition::test_btbq () |
ConvexH * | ConvexDecomposition::test_cube () |
double3 | ConvexDecomposition::ThreePlaneIntersection (const Plane &p0, const Plane &p1, const Plane &p2) |
double3x3 | ConvexDecomposition::Transpose (const double3x3 &m) |
double3 | ConvexDecomposition::TriNormal (const double3 &v0, const double3 &v1, const double3 &v2) |
double3 | ConvexDecomposition::vabs (const double3 &v) |
double3 | ConvexDecomposition::VectorMax (const double3 &a, const double3 &b) |
double3 | ConvexDecomposition::VectorMin (const double3 &a, const double3 &b) |
Quaternion | ConvexDecomposition::VirtualTrackBall (const double3 &cop, const double3 &cor, const double3 &dir0, const double3 &dir1) |
double | ConvexDecomposition::Yaw (const Quaternion &q) |
double | ConvexDecomposition::Yaw (const double3 &v) |
Quaternion | ConvexDecomposition::YawPitchRoll (double yaw, double pitch, double roll) |
Variables | |
int | ConvexDecomposition::countpolyhit = 0 |
double | ConvexDecomposition::minadjangle = 3.0f |
double | ConvexDecomposition::planetestepsilon = PAPERWIDTH |
static Array< Tri * > | ConvexDecomposition::tris |
#define COPLANAR (0) |
Definition at line 1642 of file cd_hull.cpp.
Definition at line 315 of file cd_hull.cpp.
#define EPSILON 0.000001f |
#define NX_ALLOC | ( | x, | |
y | |||
) | malloc(x) |
Definition at line 76 of file cd_hull.cpp.
#define NX_FREE | ( | x | ) | free(x) |
Definition at line 77 of file cd_hull.cpp.
#define OFFSET | ( | Class, | |
Member | |||
) | (((char*) (&(((Class*)NULL)-> Member )))- ((char*)NULL)) |
Definition at line 318 of file cd_hull.cpp.
#define OVER (2) |
Definition at line 1644 of file cd_hull.cpp.
#define PAPERWIDTH (0.001f) |
Definition at line 1646 of file cd_hull.cpp.
#define PI (3.1415926535897932384626433832795f) |
Definition at line 312 of file cd_hull.cpp.
#define RAD2DEG (180.0f / PI) |
Definition at line 316 of file cd_hull.cpp.
#define REAL double |
Definition at line 1640 of file cd_hull.cpp.
#define REAL3 double3 |
Definition at line 1639 of file cd_hull.cpp.
Definition at line 1645 of file cd_hull.cpp.
#define SQRT_OF_2 (1.4142135f) |
Definition at line 317 of file cd_hull.cpp.
#define STANDALONE 1 |
Copyright (c) 2007 by John W. Ratcliff mailto:jratcliff@infiniplex.net
Portions of this source has been released with the PhysXViewer application, as well as Rocket, CreateDynamics, ODF, and as a number of sample code snippets.
If you find this code useful or you are feeling particularily generous I would ask that you please go to http://www.amillionpixels.us and make a donation to Troy DeMolay.
DeMolay is a youth group for young men between the ages of 12 and 21. It teaches strong moral principles, as well as leadership skills and public speaking. The donations page uses the 'pay for pixels' paradigm where, in this case, a pixel is only a single penny. Donations can be made for as small as $4 or as high as a $100 block. Each person who donates will get a link to their own site as well as acknowledgement on the donations blog located here http://www.amillionpixels.blogspot.com/
If you wish to contact me you can use the following methods:
Skype Phone: 636-486-4040 (let it ring a long time while it goes through switches) Skype ID: jratcliff63367 Yahoo: jratcliff63367 AOL: jratcliff1961 email: jratcliff@infiniplex.net Personal website: http://jratcliffscarab.blogspot.com Coding Website: http://codesuppository.blogspot.com FundRaising Blog: http://amillionpixels.blogspot.com Fundraising site: http://www.amillionpixels.us New Temple Site: http://newtemple.blogspot.com
The MIT license:
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Definition at line 69 of file cd_hull.cpp.
#define TSCALE1 (1.0f/4.0f) |
#define UNDER (1) |
Definition at line 1643 of file cd_hull.cpp.
#define VOLUME_EPSILON (1e-20f) |
Definition at line 1647 of file cd_hull.cpp.