include/cooking/PxSDFDesc.h
File members: include/cooking/PxSDFDesc.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_SDF_DESC_H
#define PX_SDF_DESC_H
#include "PxPhysXConfig.h"
#include "geometry/PxSimpleTriangleMesh.h"
#include "foundation/PxBounds3.h"
#if !PX_DOXYGEN
namespace physx
{
#endif
class PxSDFBuilder;
struct PxDim3
{
PxU32 x, y, z;
};
class PxSdfBitsPerSubgridPixel
{
public:
enum Enum
{
e8_BIT_PER_PIXEL = 1,
e16_BIT_PER_PIXEL = 2,
e32_BIT_PER_PIXEL = 4
};
};
class PxSDFDesc
{
public:
PxBoundedData sdf;
PxDim3 dims;
PxVec3 meshLower;
PxReal spacing;
PxU32 subgridSize;
PxSdfBitsPerSubgridPixel::Enum bitsPerSubgridPixel;
PxDim3 sdfSubgrids3DTexBlockDim;
PxBoundedData sdfSubgrids;
PxBoundedData sdfStartSlots;
PxReal subgridsMinSdfValue;
PxReal subgridsMaxSdfValue;
PxBounds3 sdfBounds;
PxReal narrowBandThicknessRelativeToSdfBoundsDiagonal;
PxU32 numThreadsForSdfConstruction;
PxSimpleTriangleMesh baseMesh;
PxSDFBuilder* sdfBuilder;
PX_INLINE PxSDFDesc();
PX_INLINE bool isValid() const;
};
PX_INLINE PxSDFDesc::PxSDFDesc()
{
sdf.data = NULL;
dims.x = 0;
dims.y = 0;
dims.z = 0;
spacing = 0;
meshLower = PxVec3(PxZero);
subgridSize = 0;
subgridsMinSdfValue = 0.0f;
subgridsMaxSdfValue = 0.0f;
sdfBounds = PxBounds3::empty();
bitsPerSubgridPixel = PxSdfBitsPerSubgridPixel::e16_BIT_PER_PIXEL;
narrowBandThicknessRelativeToSdfBoundsDiagonal = 0.01f;
numThreadsForSdfConstruction = 1;
sdfBuilder = NULL;
}
PX_INLINE bool PxSDFDesc::isValid() const
{
// Check validity of user's input(if any)
if (sdf.data)
{
if (dims.x < 1 || dims.y < 1 || dims.z < 1)
return false;
if (!meshLower.isFinite())
return false;
if (spacing <= 0)
return false;
}
return true;
}
#if !PX_DOXYGEN
} // namespace physx
#endif
#endif