RavEngine
Loading...
Searching...
No Matches
DyCorrelationBuffer.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 DY_CORRELATION_BUFFER_H
30#define DY_CORRELATION_BUFFER_H
31
32#include "foundation/PxSimpleTypes.h"
33#include "foundation/PxVec3.h"
34#include "foundation/PxTransform.h"
35#include "foundation/PxBounds3.h"
36#include "geomutils/PxContactBuffer.h"
37
38#include "PxvConfig.h"
39#include "DyFrictionPatch.h"
40
41namespace physx
42{
43
44struct PxcNpWorkUnit;
45struct PxsMaterialInfo;
46
47namespace Dy
48{
49
51{
52 static const PxU32 MAX_FRICTION_PATCHES = 32;
53 static const PxU16 LIST_END = 0xffff;
54
56 {
57 PxU16 start;
58 PxU16 next;
59 PxU8 flags;
60 PxU8 count;
61 PxReal staticFriction, dynamicFriction, restitution;
62 PxBounds3 patchBounds;
63 };
64
65 // we can have as many contact patches as contacts, unfortunately
66 ContactPatchData contactPatches[PxContactBuffer::MAX_CONTACTS];
67
68 FrictionPatch PX_ALIGN(16, frictionPatches[MAX_FRICTION_PATCHES]);
69 PxVec3 PX_ALIGN(16, frictionPatchWorldNormal[MAX_FRICTION_PATCHES]);
70 PxBounds3 patchBounds[MAX_FRICTION_PATCHES];
71
72 PxU32 frictionPatchContactCounts[MAX_FRICTION_PATCHES];
73 PxU32 correlationListHeads[MAX_FRICTION_PATCHES+1];
74
75 // contact IDs are only used to identify auxiliary contact data when velocity
76 // targets have been set.
77 PxU16 contactID[MAX_FRICTION_PATCHES][2];
78
79 PxU32 contactPatchCount, frictionPatchCount;
80
81};
82
83bool createContactPatches(CorrelationBuffer& fb, const PxContactPoint* cb, PxU32 contactCount, PxReal normalTolerance);
84
85bool correlatePatches(CorrelationBuffer& fb,
86 const PxContactPoint* cb,
87 const PxTransform& bodyFrame0,
88 const PxTransform& bodyFrame1,
89 PxReal normalTolerance,
90 PxU32 startContactPatchIndex,
91 PxU32 startFrictionPatchIndex);
92
93void growPatches(CorrelationBuffer& fb,
94 const PxContactPoint* buffer,
95 const PxTransform& bodyFrame0,
96 const PxTransform& bodyFrame1,
97 PxU32 frictionPatchStartIndex,
98 PxReal frictionOffsetThreshold);
99
100}
101
102}
103
104#endif
Class representing 3D range or axis aligned bounding box.
Definition PxBounds3.h:58
class representing a rigid euclidean transform as a quaternion and a vector
Definition PxTransform.h:49
3 Element vector class.
Definition PxVec3.h:50
#define PX_ALIGN(alignment, decl)
Definition PxPreprocessor.h:402
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39
Definition DyCorrelationBuffer.h:56
Definition DyCorrelationBuffer.h:51
Definition DyFrictionPatch.h:43
Definition PxContactPoint.h:40