Main Page Class List Class Members

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

- File List
- File Members

# sdk/extensions/authoring/source/NvBlastExtTriangleProcessor.h

Go to the documentation of this file.

    00001 // This code contains NVIDIA Confidential Information and is disclosed to you
    00002 // under a form of NVIDIA software license agreement provided separately to you.
    00003 //
    00004 // Notice
    00005 // NVIDIA Corporation and its licensors retain all intellectual property and
    00006 // proprietary rights in and to this software and related documentation and
    00007 // any modifications thereto. Any use, reproduction, disclosure, or
    00008 // distribution of this software and related documentation without an express
    00009 // license agreement from NVIDIA Corporation is strictly prohibited.
    00010 //
    00011 // ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
    00012 // NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
    00013 // THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
    00014 // MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
    00015 //
    00016 // Information and code furnished is believed to be accurate and reliable.
    00017 // However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
    00018 // information or for any infringement of patents or other rights of third parties that may
    00019 // result from its use. No license is granted by implication or otherwise under any patent
    00020 // or patent rights of NVIDIA Corporation. Details are subject to change without notice.
    00021 // This code supersedes and replaces all information previously supplied.
    00022 // NVIDIA Corporation products are not authorized for use as critical
    00023 // components in life support devices or systems without express written approval of
    00024 // NVIDIA Corporation.
    00025 //
    00026 // Copyright (c) 2016-2020 NVIDIA Corporation. All rights reserved.
    00027
    00028
    00029 #ifndef NVBLASTEXTTRIANGLEPROCESSOR_H
    00030 #define NVBLASTEXTTRIANGLEPROCESSOR_H
    00031
    00032 #include <PxVec2.h>
    00033 #include <PxVec3.h>
    00034 #include <vector>
    00035 #include <algorithm>
    00036
    00037 using namespace physx;
    00038
    00039
    00040 namespace Nv
    00041 {
    00042 namespace Blast
    00043 {
    00044
    00048 struct TrPrcTriangle
    00049 {
    00050     PxVec3 points[3];
    00051     TrPrcTriangle(PxVec3 a = PxVec3(0.0f), PxVec3 b = PxVec3(0.0f), PxVec3 c = PxVec3(0.0f))
    00052     {
    00053         points[0] = a;
    00054         points[1] = b;
    00055         points[2] = c;
    00056     }
    00057
    00058     TrPrcTriangle& operator=(const TrPrcTriangle& b)
    00059     {
    00060         points[0] = b.points[0];
    00061         points[1] = b.points[1];
    00062         points[2] = b.points[2];
    00063         return *this;
    00064     }
    00065
    00066     TrPrcTriangle(const TrPrcTriangle& b)
    00067     {
    00068         points[0] = b.points[0];
    00069         points[1] = b.points[1];
    00070         points[2] = b.points[2];
    00071     }
    00072     PxVec3 getNormal() const
    00073     {
    00074         return (points[1] - points[0]).cross(points[2] - points[0]);
    00075     }
    00076 };
    00077
    00081 struct TrPrcTriangle2d
    00082 {
    00083     PxVec2 points[3];
    00084     TrPrcTriangle2d(PxVec2 a = PxVec2(0.0f), PxVec2 b = PxVec2(0.0f), PxVec2 c = PxVec2(0.0f))
    00085     {
    00086         points[0] = a;
    00087         points[1] = b;
    00088         points[2] = c;
    00089     }
    00090
    00091     TrPrcTriangle2d operator=(const TrPrcTriangle2d& b)
    00092     {
    00093         points[0] = b.points[0];
    00094         points[1] = b.points[1];
    00095         points[2] = b.points[2];
    00096         return *this;
    00097     }
    00098
    00099     TrPrcTriangle2d(const TrPrcTriangle2d& b)
    00100     {
    00101         points[0] = b.points[0];
    00102         points[1] = b.points[1];
    00103         points[2] = b.points[2];
    00104     }
    00105 };
    00106
    00107 class TriangleProcessor
    00108 {
    00109   public:
    00110     TriangleProcessor(){};
    00111     ~TriangleProcessor() {}
    00112
    00113
    00124     uint32_t getTriangleIntersection(TrPrcTriangle& a, TrPrcTriangle2d& aProjected, TrPrcTriangle& b, PxVec3& centroid,
    00125                                      std::vector<PxVec3>& intersectionBuffer, PxVec3 normal);
    00126
    00133     bool triangleBoundingBoxIntersection(TrPrcTriangle2d& a, TrPrcTriangle2d& b);
    00134
    00135
    00142     uint32_t isPointInside(const PxVec2& point, const TrPrcTriangle2d& triangle);
    00143
    00153     uint32_t getSegmentIntersection(const PxVec2& s1, const PxVec2& e1, const PxVec2& s2, const PxVec2& e2, PxF32& t1);
    00154
    00158     void sortToCCW(std::vector<PxVec3>& points, PxVec3& normal);
    00159
    00166     void buildConvexHull(std::vector<PxVec3>& points, std::vector<PxVec3>& convexHull, const PxVec3& normal);
    00167 };
    00168
    00169 }  // namespace Blast
    00170 }  // namespace Nv
    00171
    00172
    00173 #endif  // NVBLASTEXTTRIANGLEPROCESSOR_H

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