include/geometry/PxMeshQuery.h

File members: include/geometry/PxMeshQuery.h

// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//  * Redistributions of source code must retain the above copyright
//    notice, this list of conditions and the following disclaimer.
//  * Redistributions in binary form must reproduce the above copyright
//    notice, this list of conditions and the following disclaimer in the
//    documentation and/or other materials provided with the distribution.
//  * Neither the name of NVIDIA CORPORATION nor the names of its
//    contributors may be used to endorse or promote products derived
//    from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.

#ifndef PX_MESH_QUERY_H
#define PX_MESH_QUERY_H

#include "common/PxPhysXCommonConfig.h"
#include "geometry/PxGeometryHit.h"
#include "geometry/PxGeometryQueryFlags.h"
#include "geometry/PxReportCallback.h"

#if !PX_DOXYGEN
namespace physx
{
#endif

class PxGeometry;
class PxConvexMeshGeometry;
class PxTriangleMeshGeometry;
class PxHeightFieldGeometry;

class PxTriangle;

    struct PxMeshMeshQueryFlag
    {
        enum Enum
        {
            eDEFAULT            = 0,
            eDISCARD_COPLANAR   = (1<<0),
            eRESERVED           = (1<<1),
            eRESERVED1          = (1<<1),
            eRESERVED2          = (1<<2),
            eRESERVED3          = (1<<3)
        };
    };

    PX_FLAGS_TYPEDEF(PxMeshMeshQueryFlag, PxU32)

class PxMeshQuery
{
public:

    PX_PHYSX_COMMON_API static void getTriangle(const PxTriangleMeshGeometry& triGeom, const PxTransform& transform, PxTriangleID triangleIndex, PxTriangle& triangle, PxU32* vertexIndices=NULL, PxU32* adjacencyIndices=NULL);

    PX_PHYSX_COMMON_API static void getTriangle(const PxHeightFieldGeometry& hfGeom, const PxTransform& transform, PxTriangleID triangleIndex, PxTriangle& triangle, PxU32* vertexIndices=NULL, PxU32* adjacencyIndices=NULL);

    PX_PHYSX_COMMON_API static PxU32 findOverlapTriangleMesh(   const PxGeometry& geom, const PxTransform& geomPose,
                                                                const PxTriangleMeshGeometry& meshGeom, const PxTransform& meshPose,
                                                                PxU32* results, PxU32 maxResults, PxU32 startIndex, bool& overflow,
                                                                PxGeometryQueryFlags queryFlags = PxGeometryQueryFlag::eDEFAULT);

    PX_PHYSX_COMMON_API static bool findOverlapTriangleMesh(PxReportCallback<PxGeomIndexPair>& callback,
                                                            const PxTriangleMeshGeometry& meshGeom0, const PxTransform& meshPose0,
                                                            const PxTriangleMeshGeometry& meshGeom1, const PxTransform& meshPose1,
                                                            PxGeometryQueryFlags queryFlags = PxGeometryQueryFlag::eDEFAULT,
                                                            PxMeshMeshQueryFlags meshMeshFlags = PxMeshMeshQueryFlag::eDEFAULT,
                                                            float tolerance = 0.0f);

    PX_PHYSX_COMMON_API static PxU32 findOverlapHeightField(const PxGeometry& geom, const PxTransform& geomPose,
                                                            const PxHeightFieldGeometry& hfGeom, const PxTransform& hfPose,
                                                            PxU32* results, PxU32 maxResults, PxU32 startIndex, bool& overflow,
                                                            PxGeometryQueryFlags queryFlags = PxGeometryQueryFlag::eDEFAULT);

    PX_PHYSX_COMMON_API static bool sweep(const PxVec3& unitDir,
                            const PxReal distance,
                            const PxGeometry& geom,
                            const PxTransform& pose,
                            PxU32 triangleCount,
                            const PxTriangle* triangles,
                            PxGeomSweepHit& sweepHit,
                            PxHitFlags hitFlags = PxHitFlag::eDEFAULT,
                            const PxU32* cachedIndex = NULL,
                            const PxReal inflation = 0.0f,
                            bool doubleSided = false,
                            PxGeometryQueryFlags queryFlags = PxGeometryQueryFlag::eDEFAULT);
};

#if !PX_DOXYGEN
}
#endif

#endif