Program Listing for include/geometry/PxGeometryHit.h

↰ Return to documentation for include/geometry/PxGeometryHit.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-2022 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_GEOMETRY_HIT_H
#define PX_GEOMETRY_HIT_H

#include "foundation/PxVec3.h"
#include "foundation/PxFlags.h"
#include "common/PxPhysXCommonConfig.h"

#if !PX_DOXYGEN
namespace physx
{
#endif

struct PxHitFlag
{
    enum Enum
    {
        ePOSITION                   = (1<<0),
        eNORMAL                     = (1<<1),
        eUV                         = (1<<3),
        eASSUME_NO_INITIAL_OVERLAP  = (1<<4),
        eANY_HIT                    = (1<<5),
        eMESH_MULTIPLE              = (1<<6),
        eMESH_ANY                   = eANY_HIT,
        eMESH_BOTH_SIDES            = (1<<7),
        ePRECISE_SWEEP              = (1<<8),
        eMTD                        = (1<<9),
        eFACE_INDEX                 = (1<<10),

        eDEFAULT                    = ePOSITION|eNORMAL|eFACE_INDEX,

        eMODIFIABLE_FLAGS           = eMESH_MULTIPLE|eMESH_BOTH_SIDES|eASSUME_NO_INITIAL_OVERLAP|ePRECISE_SWEEP
    };
};

PX_FLAGS_TYPEDEF(PxHitFlag, PxU16)


struct PxQueryHit
{
    PX_INLINE           PxQueryHit() : faceIndex(0xFFFFffff) {}

    PxU32               faceIndex;
};

struct PxLocationHit : PxQueryHit
{
    PX_INLINE           PxLocationHit() : flags(0), position(PxVec3(0)), normal(PxVec3(0)), distance(PX_MAX_REAL)   {}

    PX_INLINE bool      hadInitialOverlap() const { return (distance <= 0.0f); }

    // the following fields are set in accordance with the #PxHitFlags
    PxHitFlags          flags;
    PxVec3              position;
    PxVec3              normal;

    PxF32               distance;
};

struct PxGeomRaycastHit : PxLocationHit
{
    PX_INLINE           PxGeomRaycastHit() : u(0.0f), v(0.0f)   {}

    // the following fields are set in accordance with the #PxHitFlags

    PxReal  u, v;
};

struct PxGeomOverlapHit : PxQueryHit
{
    PX_INLINE           PxGeomOverlapHit() {}
};

struct PxGeomSweepHit : PxLocationHit
{
    PX_INLINE           PxGeomSweepHit() {}
};

struct PxGeomIndexPair
{
    PX_FORCE_INLINE PxGeomIndexPair()                                                   {}
    PX_FORCE_INLINE PxGeomIndexPair(PxU32   _id0, PxU32 _id1) : id0(_id0), id1(_id1)    {}

    PxU32   id0, id1;
};

#if !PX_DOXYGEN
} // namespace physx
#endif

#endif