udGeometry

The udGeometry object provides an interface to filter Nuclideon Unlimited Detail models using geometric filters.

Typedefs

typedef uint32_t udGeometryCrc(const struct udGeometry *pGeometry)

Optional function to return a crc of ADDITIONAL data outside the structure, such as pointers in a CSG/Inverse type etc.

typedef void udGeometryDeinit(struct udGeometry *pGeometry)

This sets up pFilterOut by doing the pMatrix transform on pFilterIn (which isn’t modified)- pFilterOut needs to be deinited after this.

Enums

enum udGeometryType

The currently supported geometry types

Values:

ValueDescription
udGT_InverseAn inversion filter; flips the udGeometryTestResult of the child udGeometry node.
udGT_CircleXYA 2D Circle with an infinite Z value.
udGT_RectangleXYA 2D Rectangle with an infinite Z value.
udGT_PolygonXYA 2D Polygon with rotation (quaternion) to define the up of the polygon.
udGT_PolygonPerspectiveA 2D polygon with a perspective projection to the screen plane.
udGT_CapsuleA line with a radius from the line; forming hemispherical caps at the end of the line.
udGT_SphereA radius from a point.
udGT_HalfSpaceA binary space partition allowing 1 side of a plane.
udGT_AABBAn axis aligned box; Use with caution. OBB while less performant correctly handles transforms.
udGT_OBBAn oriented bounding box using half size and orientation.
udGT_CSGA constructed solid geometry that uses a udGeometryCSGOperation to join to child udGeometry nodes.
udGT_AttributeFilter based on attribute values (automatic pass if no attribute information passed to test function).
udGT_CountCount helper value to iterate this enum.

enum udGeometryComparator

The currently supported geometry comparator types (used in attribute filtering)

Values:

ValueDescription
udGC_EQEqual, param is tolerance (0 = none).
udGC_NENot equal, param is tolerance (0 = none).
udGC_GTGreater than, param is range limit (0 = none).
udGC_GEGreater than or Equal, param is range limit (0 = none).
udGC_LTLess rhan, param is range limit (0 = none).
udGC_LELess than or equal, param is range limit (0 = none).
udGC_AND_ANYBitwise AND, true if value AND comparands != 0, param is unused (should be zero).
udGC_AND_ALLBitwise AND, true if value AND comparands == comparand, param is unused (should be zero).

enum udGeometryVoxelNodeFlags

Values:

ValueDescription
udGVNF_NoneDefault no flags present.
udGVNF_RenderLeafThe voxel is either a leaf or being rendered as a leaf.

enum udGeometryCSGOperation

The Constructive Solid Geometry operations

Values:

ValueDescription
udGCSGO_UnionA union CSG operation; any point matching the one or the other geometry (OR operation).
udGCSGO_DifferenceA subtractive CSG operation; any point in the first geometry but not matching the second geometry (XOR operation).
udGCSGO_IntersectionAn intersection CSG operation; any point that matches both geometries (AND operation).

enum udGeometryTestResult

The results of a geometry test

Values:

ValueDescription
udGTR_RejectThe node is either totally outside of the geometry filter OR fails attribute filter.
udGTR_AcceptThe node is both totally inside of the geometry AND fully matches attribute filter (and no further tests are required).
udGTR_PartialThe node is partiall filtered, should be accepted but child nodes must be re-tested (eg overlapping the boundary of the geometry).
udGTR_CompletelyOutside
udGTR_CompletelyInside
udGTR_PartiallyOverlap

Functions

enum udGeometryTestResult udGeometryTestFunc(const struct udGeometry *pGeometry, const struct udGeometryVoxelNode *pVoxel)

The function that will be called for each node until the node is either inside or outside of the geometry.

enum udError udGeometryTransform(const struct udGeometry *pFilterIn, struct udGeometry *pFilterOut, const udDouble4x4 *pMatrix)

This sets up pFilterOut by doing the pMatrix transform on pFilterIn (which isn’t modified)- pFilterOut needs to be deinited after this.

enum udError udGeometry_InitInverse(struct udGeometry *pGeometry, const struct udGeometry *pSource)

Helper to initialise a geometry that simply inverts another primitive (CompletelyOutside <-> CompletelyInside)

ParameterDescription
pGeometryThe preallocated udGeometry to init
pSourceThe Geometry to inverse

enum udError udGeometry_InitCircleXY(struct udGeometry *pGeometry, const udDouble2 centre, double radius)

Helper to initialise a 2D circle extended to infinity in Z (elevation)

ParameterDescription
pGeometryThe preallocated udGeometry to init
centreThe centre of the Circle
radiusThe radius of the circle

enum udError udGeometry_InitRectangleXY(struct udGeometry *pGeometry, const udDouble2 point1, const udDouble2 point2)

Helper to initialise a 2D rectangle extended to infinity in Z (elevation)

ParameterDescription
pGeometryThe preallocated udGeometry to init
point1The first point to define a rectangle
point2The second point to define a rectangle

enum udError udGeometry_InitPolygonXY(struct udGeometry *pGeometry, const udDouble3 *pXYCoords, uint32_t count, const udDouble3 polygonNomal)

Helper to initialise a Polygon shape extened to infinity along a direction

ParameterDescription
pGeometryThe preallocated udGeometry to init
pXYCoordsthe list of 2D positions defining the polygon
countthe number of points in pXYCoords list
polygonNormalthe normal vector to the polygon

enum udError udGeometry_InitPolygonPerspective(struct udGeometry *pGeometry, const udDouble2 *pXYCoords, uint32_t count, udDouble4x4 projectionMatrix, udDouble4x4 cameraMatrix, double nearPlaneOffset, double farPlaneOffset)

Helper to initialise a Polygon shape extended to infinity with a perspective projection

ParameterDescription
pGeometryThe preallocated udGeometry to init
pXYCoordsthe list of 2D positions defining the polygon
countthe number of points in pXYCoords list
projectionMatrixThe model to world projection matrix
cameraMatrixThe projection matrix of world to screen
nearPlaneOffsetThe offset off the near plane to detect if voxel is visible by the camera
farPlaneOffsetThe offset off the far plane to detect if voxel is visible by the camera

enum udError udGeometry_InitCSG(struct udGeometry *pGeometry, const struct udGeometry *pGeometry1, const struct udGeometry *pGeometry2, enum udGeometryCSGOperation function)

Helper to initialise a CSG shape

ParameterDescription
pGeometryThe preallocated udGeometry to init
pGeometry1First Geometry
pGeometry2Second Geometry
functionthe function to apply to these 2 geometries (Union, Difference, Intersection)

enum udError udGeometry_InitHalfSpace(struct udGeometry *pGeometry, const udDouble3 point, const udDouble3 normal)

Helper to initialise a plane extended to infinity in the direction of its normal

ParameterDescription
pGeometryThe preallocated udGeometry to init
pointThe first point to define the space
normalThe normal vector of the defined space

enum udError udGeometry_InitCapsule(struct udGeometry *pGeometry, const udDouble3 point1, const udDouble3 point2, double radius)

Helper to initialise a Capsule

ParameterDescription
pGeometryThe preallocated udGeometry to init
point1First point to define a capsule at this position
point2Second point to define a capsule
radiusRadius of the capsule

enum udError udGeometry_InitSphere(struct udGeometry *pGeometry, const udDouble3 center, double radius)

Helper to initialise a Sphere

ParameterDescription
pGeometryThe preallocated udGeometry to init
centerThe center of the Sphere
radiusThe radius of the sphere

enum udError udGeometry_InitAABBFromMinMax(struct udGeometry *pGeometry, const udDouble3 point1, const udDouble3 point2)

Helper to initialise an Axis Aligned Box using the min and max point

ParameterDescription
pGeometryThe preallocated udGeometry to init
point1First point to define a box starting at this position
point2Last point to define a box ending at this position

enum udError udGeometry_InitAABBFromCentreExtents(struct udGeometry *pGeometry, const udDouble3 centre, const udDouble3 extents)

Helper to initialise an Axis Aligned Box using center and extents

ParameterDescription
pGeometryThe preallocated udGeometry to init
centreThe centre of the Axis Aligned Box
extentsThe dimension of the Axis Aligned Box

enum udError udGeometry_InitOBB(struct udGeometry *pGeometry, const udDouble3 centerPoint, const udDouble3 extents, const udDouble3 rotations)

Helper to initialise an arbitrarily aligned three dimensional box, centered at centerPoint, rotated about the center

ParameterDescription
pGeometryThe preallocated udGeometry to init
centerPointThe centre of the box
extentsThe distances from the center to the sides (half the size of the dimensions of the box)
rotationsThe rotations of the box in radians about x,y,z

enum udError udGeometry_InitAttributeInt64(struct udGeometry *pGeometry, enum udGeometryComparator comp, int64_t value, int64_t tolerance, enum udStdAttribute attr, const struct udAttributeDescriptor *pDesc)

Helper to initialise an attribute equality filter, testing the attribute for equality with integer based comparitors

ParameterDescription
pGeometryThe preallocated udGeometry to init
compThe type of comparison, for example udGC_EQ for equality comparison
valueValue to compare node’s attribute with
toleranceFor udGC_EQ comparisons, values +/- the tolerance is considered a match (0.0 for exact match)
attrAttribute from standard attribute set (ignored if pDesc is non-null, use udSA_Count)
pDescA descriptor for testing non-standard attributes (pass null if using a standard attribute)

enum udError udGeometry_InitAttributeFloat64(struct udGeometry *pGeometry, enum udGeometryComparator comp, double value, double tolerance, enum udStdAttribute attr, const struct udAttributeDescriptor *pDesc)

Helper to initialise an attribute equality filter, testing the attribute for equality with float based comparitors

ParameterDescription
pGeometryThe preallocated udGeometry to init
compThe type of comparison, for example udGC_EQ for equality comparison
valueValue to compare node’s attribute with
toleranceFor udGC_EQ comparisons, values +/- the tolerance is considered a match (0.0 for exact match)
attrAttribute from standard attribute set (ignored if pDesc is non-null, use udSA_Count)
pDescA descriptor for testing non-standard attributes (pass null if using a standard attribute)

void udGeometry_Deinit(struct udGeometry *pGeometry)

This cleans up internal allocations

ParameterDescription
pGeometryThe geometry to deinitialise

uint32_t udGeometry_CRC(const struct udGeometry *pGeometry)

Return a crc of the geometry (and sub-geometry in the case of CSG etc)

ParameterDescription
pGeometryPointer to geometry

Returns: The CRC of the geometry, or zero if pGeometry is null

enum udError udGeometry_HasType(const struct udGeometry *pGeometry, enum udGeometryType type)

Return true if the geometry (or sub-geometry in the case of CSG etc) contains the given type

ParameterDescription
pGeometryPointer to geometry
typeThe type of geometry to test for

Returns: udE_Success if the type is present in the geometry, otherwise udE_NotFound

enum udError udGeometry_Create(struct udGeometry **ppGeometry)

Helper to create a pointer to an allocated udGeometry struct. This is a convenience for wrapping libraries that do not need or have a concept of the underlying object It is NOT recommended to use this function in applications where creating a udGeometry struct directly is possible (either using an allocation or on stack)

ParameterDescription
ppGeometryPointer to memory location with which to return the allocated struct

void udGeometry_Destroy(struct udGeometry **ppGeometry)

Free the struct allocated by udGeometry_Create udGeometry_DeInit should be called on the struct first before calling this function. Calling this function on a udGeometry struct that was not allocated using udGeometry_Create may result in a crash

ParameterDescription
ppGeometryPointer to memory location of struct to free

Structs

struct udGeometryVoxelNode

The geometric representation of a Node in a Unlimited Detail Model.

FieldTypeDescription
minPosudDouble3The Bottom, Left, Front corner of the voxel (closest to the origin).
childSizedoubleThe half size of the voxel (which is the same size as this voxels children).
pNodeconst struct udNode \*Optional pointer to the node for testing attributes.
childDepthuint8_tOptional depth down the tree value for additional context (0=unspecified, 1=root etc).
flagsuint8_tOptional flags, set from enum udGeometryVoxelNodeFlags.

struct udGeometryCircleXY

The geometric representation of a Circle.

FieldTypeDescription
centreudDouble2The centre of the circle.
radiusdoubleThe radius of the circle.

struct udGeometryRectangleXY

The geometric representation of a Rectangle.

FieldTypeDescription
minPointudDouble2The lowest point of the rectangle.
maxPointudDouble2The highest point of the rectangle.

struct udGeometryPolygonXYZ

The geometric representation of a Polygon.

FieldTypeDescription
pointCountuint32_tThe number of points defining the polygon.
pointsListudDouble3 \*The list of points defining the polygon.
polygonNormaludDouble3The polygon normal.
rotationQuatudDoubleQuatThe rotation of the polygon compare to Z axis.

struct udGeometryPolygonPerspective

The geometric representation of a Polygon with a perspective projection.

FieldTypeDescription
pointCountuint32_tThe number of points defining the polygon.
pointsListudDouble3 \*The list of points defining the polygon.
rotationQuatudDouble4The rotation of the polygon.
worldToScreenudDouble4x4The matrix to project from World space to Screen space.
projectionMatrixudDouble4x4The matrix to project the points of the polygon.
cameraMatrixudDouble4x4The camera matrix.
normRightudDouble3The normal on the right of the plane.
normLeftudDouble3The normal on the left of the plane.
normTopudDouble3The normal on the top of the plane.
normBottomudDouble3The normal on the bottom of the plane.
nearPlanedoublethe near plane distance
farPlanedoubleThe far plane distance.

struct udGeometryCapsule

Stores the properties of a geometric capsule

FieldTypeDescription
point1udDouble3One end of the line.
point2udDouble3The other end of the line.
radiusdoubleThe radius around the line.
axisVectorudDouble3The vector of the line.
lengthdoubleThe length of the line.

struct udGeometrySphere

Stores the properties of a geometric sphere

FieldTypeDescription
centerudDouble3The center of the sphere.
radiusdoubleThe radius of the sphere.

struct udGeometryHalfSpace

Stores the properties of a geometric half space

FieldTypeDescription
planeudDouble4The parameters to define the plane (normal XYZ and offset from origin).

struct udGeometryAABB

Stores the properties of a geometric axis aligned bounding box

FieldTypeDescription
centerudDouble3The point at the center of the AABB.
extentsudDouble3The half space size of the AABB.

struct udGeometryOBB

Stores the properties of a geometric axis aligned bounding box (extending AABB)

FieldTypeDescription
centerudDouble3The point at the center of the AABB.
extentsudDouble3The half space size of the AABB.
rotationMatrixudDouble4x4The transform that represents the rotation.

struct udGeometryInverse

Stores the properties of an inversed udGeometry node

FieldTypeDescription
pInverseOfconst struct udGeometry \*The inverse geometry.
ownsintIf non-zero pInverseOf is owned by this need (and will need to be cleaned up).

struct udGeometryCSG

Stores the properties of a CSG udGeometry node

FieldTypeDescription
pFirstconst struct udGeometry \*The first geometry.
pSecondconst struct udGeometry \*The second geometry.
operationenum udGeometryCSGOperationThe operation applied to the 2 geometries.
ownsintnon zero if it owns both children

struct udGeometryAttribute

Stores the properties of a attribute udGeometry node

FieldTypeDescription
attrenum [udStdAttribute](udAttributes.md)For custom attributes this should be udSA_Count, otherwise the appropriate enum value.
descstruct [udAttributeDescriptor](udAttributes.md)Attribute descriptor.
uuint64_tAny unsigned integer typed values.
iint64_tAny signed integer typed values.
f32floatAny float typed values.
f64doubleAny double-precision typed values.
valueunion udGeometryAttribute::[anonymous]The value for the comparison, with the expected type derived from the type in the descriptor.
paramunion udGeometryAttribute::[anonymous]Optional comparitor-specific parameter, such as the tolerance when using the EQ operator. Default to zero.
compenum udGeometryComparatorThe comparison operator.

struct udGeometry

Stores the information required for all udGeometry shapes

!WARNING This struct will change drastically as udSDK shifts to programable query filters

FieldTypeDescription
pTestFuncudGeometryTestFunc \*The function to call to test the geometry.
pTransformFuncudGeometryTransform \*The function to transform this geometry using a linear matrix.
pExtraCRCFuncudGeometryCrc \*When non-null, the function to perform crc calculation on ADDITIONAL data outside the base structure that represents the geometry (0 is valid for no extra data).
pDeinitFuncudGeometryDeinit \*The function that is called when this is cleaned up.
inversestruct udGeometryInverse
circleXYstruct udGeometryCircleXY
rectangleXYstruct udGeometryRectangleXY
polygonXYZstruct udGeometryPolygonXYZ
polygonPerspectivestruct udGeometryPolygonPerspective
capsulestruct udGeometryCapsule
spherestruct udGeometrySphere
halfSpacestruct udGeometryHalfSpace
aabbstruct udGeometryAABB
obbstruct udGeometryOBB
csgstruct udGeometryCSG
attributestruct udGeometryAttribute
dataunion udGeometry::[anonymous]The geometry used.
typeenum udGeometryTypeThe type of the geometry for internal verification.