RavEngine
Loading...
Searching...
No Matches
PxSamplingExt.h
1// Redistribution and use in source and binary forms, with or without
2// modification, are permitted provided that the following conditions
3// are met:
4// * Redistributions of source code must retain the above copyright
5// notice, this list of conditions and the following disclaimer.
6// * Redistributions in binary form must reproduce the above copyright
7// notice, this list of conditions and the following disclaimer in the
8// documentation and/or other materials provided with the distribution.
9// * Neither the name of NVIDIA CORPORATION nor the names of its
10// contributors may be used to endorse or promote products derived
11// from this software without specific prior written permission.
12//
13// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
14// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24//
25// Copyright (c) 2008-2022 NVIDIA Corporation. All rights reserved.
26// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
27// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
28
29#ifndef PX_SAMPLING_EXT_H
30#define PX_SAMPLING_EXT_H
35#include "foundation/PxArray.h"
36#include "geometry/PxGeometry.h"
37#include "foundation/PxUserAllocated.h"
38#include "geometry/PxSimpleTriangleMesh.h"
39
40#if !PX_DOXYGEN
41namespace physx
42{
43#endif
44
49{
50public:
64 static void poissonSample(const PxSimpleTriangleMesh& mesh, PxReal r, PxArray<PxVec3>& result, PxReal rVolume = 0.0f, PxArray<PxI32>* triangleIds = NULL, PxArray<PxVec3>* barycentricCoordinates = NULL,
65 const PxBounds3* axisAlignedBox = NULL, const PxQuat* boxOrientation = NULL, PxU32 maxNumSamples = 0, PxU32 numSampleAttemptsAroundPoint = 30);
66
80 static void poissonSample(const PxGeometry& geometry, const PxTransform& transform, const PxBounds3& worldBounds, PxReal r, PxArray<PxVec3>& result, PxReal rVolume = 0.0f,
81 const PxBounds3* axisAlignedBox = NULL, const PxQuat* boxOrientation = NULL, PxU32 maxNumSamples = 0, PxU32 numSampleAttemptsAroundPoint = 30);
82};
83
88{
89public:
93 virtual void setSamplingRadius(PxReal samplingRadius) = 0;
94
98 virtual void addSamples(const PxArray<PxVec3>& samples) = 0;
99
104 virtual PxU32 removeSamples(const PxArray<PxVec3>& samples) = 0;
105
111 virtual void addSamplesInSphere(const PxVec3& sphereCenter, PxReal sphereRadius, bool createVolumeSamples = false) = 0;
112
118 virtual void addSamplesInBox(const PxBounds3& axisAlignedBox, const PxQuat& boxOrientation, bool createVolumeSamples = false) = 0;
119
123 virtual const PxArray<PxVec3>& getSamples() const = 0;
124
125 virtual ~PxPoissonSampler() { }
126};
127
128
137PxPoissonSampler* PxCreateShapeSampler(const PxGeometry& geometry, const PxTransform& transform, const PxBounds3& worldBounds, PxReal initialSamplingRadius, PxI32 numSampleAttemptsAroundPoint = 30);
138
139
144{
145public:
149 virtual const PxArray<PxI32>& getSampleTriangleIds() const = 0;
150
154 virtual const PxArray<PxVec3>& getSampleBarycentrics() const = 0;
155
159 virtual bool isPointInTriangleMesh(const PxVec3& p) = 0;
160
162};
163
164
174PxTriangleMeshPoissonSampler* PxCreateTriangleMeshSampler(const PxU32* triangles, PxU32 numTriangles, const PxVec3* vertices, PxU32 numVertices, PxReal initialSamplingRadius, PxI32 numSampleAttemptsAroundPoint = 30);
175
176
177#if !PX_DOXYGEN
178} // namespace physx
179#endif
180
182#endif
Definition PxArray.h:53
Class representing 3D range or axis aligned bounding box.
Definition PxBounds3.h:58
A geometry object.
Definition PxGeometry.h:79
Sampler to generate Poisson Samples locally on a triangle mesh or a shape. For every local addition o...
Definition PxSamplingExt.h:88
virtual void addSamplesInBox(const PxBounds3 &axisAlignedBox, const PxQuat &boxOrientation, bool createVolumeSamples=false)=0
virtual const PxArray< PxVec3 > & getSamples() const =0
virtual void addSamples(const PxArray< PxVec3 > &samples)=0
virtual void addSamplesInSphere(const PxVec3 &sphereCenter, PxReal sphereRadius, bool createVolumeSamples=false)=0
virtual PxU32 removeSamples(const PxArray< PxVec3 > &samples)=0
virtual void setSamplingRadius(PxReal samplingRadius)=0
This is a quaternion class. For more information on quaternion mathematics consult a mathematics sour...
Definition PxQuat.h:50
utility functions to sample vertices on or inside a triangle mesh or other geometries
Definition PxSamplingExt.h:49
static void poissonSample(const PxSimpleTriangleMesh &mesh, PxReal r, PxArray< PxVec3 > &result, PxReal rVolume=0.0f, PxArray< PxI32 > *triangleIds=NULL, PxArray< PxVec3 > *barycentricCoordinates=NULL, const PxBounds3 *axisAlignedBox=NULL, const PxQuat *boxOrientation=NULL, PxU32 maxNumSamples=0, PxU32 numSampleAttemptsAroundPoint=30)
Definition ExtSampling.cpp:1383
A structure describing a triangle mesh.
Definition PxSimpleTriangleMesh.h:83
class representing a rigid euclidean transform as a quaternion and a vector
Definition PxTransform.h:49
Sampler to generate Poisson Samples on a triangle mesh.
Definition PxSamplingExt.h:144
virtual const PxArray< PxI32 > & getSampleTriangleIds() const =0
virtual const PxArray< PxVec3 > & getSampleBarycentrics() const =0
virtual bool isPointInTriangleMesh(const PxVec3 &p)=0
Definition PxUserAllocated.h:43
3 Element vector class.
Definition PxVec3.h:50
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39
PxPoissonSampler * PxCreateShapeSampler(const PxGeometry &geometry, const PxTransform &transform, const PxBounds3 &worldBounds, PxReal initialSamplingRadius, PxI32 numSampleAttemptsAroundPoint=30)
Definition ExtSampling.cpp:527
PxTriangleMeshPoissonSampler * PxCreateTriangleMeshSampler(const PxU32 *triangles, PxU32 numTriangles, const PxVec3 *vertices, PxU32 numVertices, PxReal initialSamplingRadius, PxI32 numSampleAttemptsAroundPoint=30)
Definition ExtSampling.cpp:532