Main Page Class List Class Members

- Main Page
- User's Guide
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

# sdk/extensions/authoring/source/VHACD/inc/btConvexHullComputer.h

Go to the documentation of this file.

    00001 /*
    00002 Copyright (c) 2011 Ole Kniemeyer, MAXON, www.maxon.net
    00003
    00004 This software is provided 'as-is', without any express or implied warranty.
    00005 In no event will the authors be held liable for any damages arising from the use of this software.
    00006 Permission is granted to anyone to use this software for any purpose,
    00007 including commercial applications, and to alter it and redistribute it freely,
    00008 subject to the following restrictions:
    00009
    00010 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.
    00011 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
    00012 3. This notice may not be removed or altered from any source distribution.
    00013 */
    00014
    00015 #ifndef BT_CONVEX_HULL_COMPUTER_H
    00016 #define BT_CONVEX_HULL_COMPUTER_H
    00017
    00018 #include "btAlignedObjectArray.h"
    00019 #include "btVector3.h"
    00020
    00024 class btConvexHullComputer {
    00025 private:
    00026     btScalar compute(const void* coords, bool doubleCoords, int32_t stride, int32_t count, btScalar shrink, btScalar shrinkClamp);
    00027
    00028 public:
    00029     class Edge {
    00030     private:
    00031         int32_t next;
    00032         int32_t reverse;
    00033         int32_t targetVertex;
    00034
    00035         friend class btConvexHullComputer;
    00036
    00037     public:
    00038         int32_t getSourceVertex() const
    00039         {
    00040             return (this + reverse)->targetVertex;
    00041         }
    00042
    00043         int32_t getTargetVertex() const
    00044         {
    00045             return targetVertex;
    00046         }
    00047
    00048         const Edge* getNextEdgeOfVertex() const // clockwise list of all edges of a vertex
    00049         {
    00050             return this + next;
    00051         }
    00052
    00053         const Edge* getNextEdgeOfFace() const // counter-clockwise list of all edges of a face
    00054         {
    00055             return (this + reverse)->getNextEdgeOfVertex();
    00056         }
    00057
    00058         const Edge* getReverseEdge() const
    00059         {
    00060             return this + reverse;
    00061         }
    00062     };
    00063
    00064     // Vertices of the output hull
    00065     btAlignedObjectArray<btVector3> vertices;
    00066
    00067     // Edges of the output hull
    00068     btAlignedObjectArray<Edge> edges;
    00069
    00070     // Faces of the convex hull. Each entry is an index into the "edges" array pointing to an edge of the face. Faces are planar n-gons
    00071     btAlignedObjectArray<int32_t> faces;
    00072
    00073     /*
    00074         Compute convex hull of "count" vertices stored in "coords". "stride" is the difference in bytes
    00075         between the addresses of consecutive vertices. If "shrink" is positive, the convex hull is shrunken
    00076         by that amount (each face is moved by "shrink" length units towards the center along its normal).
    00077         If "shrinkClamp" is positive, "shrink" is clamped to not exceed "shrinkClamp * innerRadius", where "innerRadius"
    00078         is the minimum distance of a face to the center of the convex hull.
    00079
    00080         The returned value is the amount by which the hull has been shrunken. If it is negative, the amount was so large
    00081         that the resulting convex hull is empty.
    00082
    00083         The output convex hull can be found in the member variables "vertices", "edges", "faces".
    00084         */
    00085     btScalar compute(const float* coords, int32_t stride, int32_t count, btScalar shrink, btScalar shrinkClamp)
    00086     {
    00087         return compute(coords, false, stride, count, shrink, shrinkClamp);
    00088     }
    00089
    00090     // same as above, but double precision
    00091     btScalar compute(const double* coords, int32_t stride, int32_t count, btScalar shrink, btScalar shrinkClamp)
    00092     {
    00093         return compute(coords, true, stride, count, shrink, shrinkClamp);
    00094     }
    00095 };
    00096
    00097 #endif //BT_CONVEX_HULL_COMPUTER_H

Copyright © 2015-2017 NVIDIA Corporation, 2701 San Tomas Expressway, Santa Clara, CA 95050 U.S.A. All rights reserved. www.nvidia.com