1/*
2 * Copyright (c) 2008-2015, NVIDIA CORPORATION. All rights reserved.
3 *
4 * NVIDIA CORPORATION and its licensors retain all intellectual property
5 * and proprietary rights in and to this software, related documentation
6 * and any modifications thereto. Any use, reproduction, disclosure or
7 * distribution of this software and related documentation without an express
8 * license agreement from NVIDIA CORPORATION is strictly prohibited.
9 */
10// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
11// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
12
13
14#ifndef PX_PHYSICS_NXHEIGHTFIELDSAMPLE
15#define PX_PHYSICS_NXHEIGHTFIELDSAMPLE
16/** \addtogroup geomutils
17@{ */
18
19#include "common/PxPhysXCommonConfig.h"
20#include "foundation/PxBitAndData.h"
21
22#ifndef PX_DOXYGEN
23namespace physx
24{
25#endif
26
27/**
28\brief Special material index values for height field samples.
29
30@see PxHeightFieldSample.materialIndex0 PxHeightFieldSample.materialIndex1
31*/
32struct PxHeightFieldMaterial
33{
34 enum Enum
35 {
36 eHOLE = 127 //!< A material indicating that the triangle should be treated as a hole in the mesh.
37 };
38};
39
40/**
41\brief Heightfield sample format.
42
43This format corresponds to the #PxHeightFieldFormat member PxHeightFieldFormat::eS16_TM.
44
45An array of heightfield samples are used when creating a PxHeightField to specify
46the elevation of the heightfield points. In addition the material and tessellation of the adjacent
47triangles are specified.
48
49@see PxHeightField PxHeightFieldDesc PxHeightFieldDesc.samples
50*/
51struct PxHeightFieldSample
52{
53//= ATTENTION! =====================================================================================
54// Changing the data layout of this class breaks the binary serialization format. See comments for
55// PX_BINARY_SERIAL_VERSION. If a modification is required, please adjust the getBinaryMetaData
56// function. If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION
57// accordingly.
58//==================================================================================================
59
60 /**
61 \brief The height of the heightfield sample
62
63 This value is scaled by PxHeightFieldGeometry::heightScale.
64
65 @see PxHeightFieldGeometry
66 */
67 PxI16 height;
68
69 /**
70 \brief The triangle material index of the quad's lower triangle + tesselation flag
71
72 An index pointing into the material table of the shape which instantiates the heightfield.
73 This index determines the material of the lower of the quad's two triangles (i.e. the quad whose
74 upper-left corner is this sample, see the Guide for illustrations).
75
76 Special values of the 7 data bits are defined by PxHeightFieldMaterial
77
78 The tesselation flag specifies which way the quad is split whose upper left corner is this sample.
79 If the flag is set, the diagonal of the quad will run from this sample to the opposite vertex; if not,
80 it will run between the other two vertices (see the Guide for illustrations).
81
82 @see PxHeightFieldGeometry materialIndex1 PxShape.setmaterials() PxShape.getMaterials()
83 */
84 PxBitAndByte materialIndex0;
85
86 PX_CUDA_CALLABLE PX_FORCE_INLINE PxU8 tessFlag() const { return PxU8(materialIndex0.isBitSet() ? 1 : 0); } // PT: explicit conversion to make sure we don't break the code
87 PX_CUDA_CALLABLE PX_FORCE_INLINE void setTessFlag() { materialIndex0.setBit(); }
88 PX_CUDA_CALLABLE PX_FORCE_INLINE void clearTessFlag() { materialIndex0.clearBit(); }
89
90 /**
91 \brief The triangle material index of the quad's upper triangle + reserved flag
92
93 An index pointing into the material table of the shape which instantiates the heightfield.
94 This index determines the material of the upper of the quad's two triangles (i.e. the quad whose
95 upper-left corner is this sample, see the Guide for illustrations).
96
97 @see PxHeightFieldGeometry materialIndex0 PxShape.setmaterials() PxShape.getMaterials()
98 */
99 PxBitAndByte materialIndex1;
100};
101
102#ifndef PX_DOXYGEN
103} // namespace physx
104#endif
105
106/** @} */
107#endif
108