Path: blob/master/thirdparty/embree/include/embree4/rtcore_geometry.h
9905 views
// Copyright 2009-2021 Intel Corporation1// SPDX-License-Identifier: Apache-2.023#pragma once45#include "rtcore_buffer.h"6#include "rtcore_quaternion.h"78RTC_NAMESPACE_BEGIN910/* Opaque scene type */11typedef struct RTCSceneTy* RTCScene;1213/* Opaque geometry type */14typedef struct RTCGeometryTy* RTCGeometry;1516/* Types of geometries */17enum RTCGeometryType18{19RTC_GEOMETRY_TYPE_TRIANGLE = 0, // triangle mesh20RTC_GEOMETRY_TYPE_QUAD = 1, // quad (triangle pair) mesh21RTC_GEOMETRY_TYPE_GRID = 2, // grid mesh2223RTC_GEOMETRY_TYPE_SUBDIVISION = 8, // Catmull-Clark subdivision surface2425RTC_GEOMETRY_TYPE_CONE_LINEAR_CURVE = 15, // Cone linear curves - discontinuous at edge boundaries26RTC_GEOMETRY_TYPE_ROUND_LINEAR_CURVE = 16, // Round (rounded cone like) linear curves27RTC_GEOMETRY_TYPE_FLAT_LINEAR_CURVE = 17, // flat (ribbon-like) linear curves2829RTC_GEOMETRY_TYPE_ROUND_BEZIER_CURVE = 24, // round (tube-like) Bezier curves30RTC_GEOMETRY_TYPE_FLAT_BEZIER_CURVE = 25, // flat (ribbon-like) Bezier curves31RTC_GEOMETRY_TYPE_NORMAL_ORIENTED_BEZIER_CURVE = 26, // flat normal-oriented Bezier curves3233RTC_GEOMETRY_TYPE_ROUND_BSPLINE_CURVE = 32, // round (tube-like) B-spline curves34RTC_GEOMETRY_TYPE_FLAT_BSPLINE_CURVE = 33, // flat (ribbon-like) B-spline curves35RTC_GEOMETRY_TYPE_NORMAL_ORIENTED_BSPLINE_CURVE = 34, // flat normal-oriented B-spline curves3637RTC_GEOMETRY_TYPE_ROUND_HERMITE_CURVE = 40, // round (tube-like) Hermite curves38RTC_GEOMETRY_TYPE_FLAT_HERMITE_CURVE = 41, // flat (ribbon-like) Hermite curves39RTC_GEOMETRY_TYPE_NORMAL_ORIENTED_HERMITE_CURVE = 42, // flat normal-oriented Hermite curves4041RTC_GEOMETRY_TYPE_SPHERE_POINT = 50,42RTC_GEOMETRY_TYPE_DISC_POINT = 51,43RTC_GEOMETRY_TYPE_ORIENTED_DISC_POINT = 52,4445RTC_GEOMETRY_TYPE_ROUND_CATMULL_ROM_CURVE = 58, // round (tube-like) Catmull-Rom curves46RTC_GEOMETRY_TYPE_FLAT_CATMULL_ROM_CURVE = 59, // flat (ribbon-like) Catmull-Rom curves47RTC_GEOMETRY_TYPE_NORMAL_ORIENTED_CATMULL_ROM_CURVE = 60, // flat normal-oriented Catmull-Rom curves4849RTC_GEOMETRY_TYPE_USER = 120, // user-defined geometry50RTC_GEOMETRY_TYPE_INSTANCE = 121, // scene instance51RTC_GEOMETRY_TYPE_INSTANCE_ARRAY = 122, // scene instance array52};5354/* Interpolation modes for subdivision surfaces */55enum RTCSubdivisionMode56{57RTC_SUBDIVISION_MODE_NO_BOUNDARY = 0,58RTC_SUBDIVISION_MODE_SMOOTH_BOUNDARY = 1,59RTC_SUBDIVISION_MODE_PIN_CORNERS = 2,60RTC_SUBDIVISION_MODE_PIN_BOUNDARY = 3,61RTC_SUBDIVISION_MODE_PIN_ALL = 4,62};6364/* Curve segment flags */65enum RTCCurveFlags66{67RTC_CURVE_FLAG_NEIGHBOR_LEFT = (1 << 0), // left segments exists68RTC_CURVE_FLAG_NEIGHBOR_RIGHT = (1 << 1) // right segment exists69};7071/* Arguments for RTCBoundsFunction */72struct RTCBoundsFunctionArguments73{74void* geometryUserPtr;75unsigned int primID;76unsigned int timeStep;77struct RTCBounds* bounds_o;78};7980/* Bounding callback function */81typedef void (*RTCBoundsFunction)(const struct RTCBoundsFunctionArguments* args);8283/* Arguments for RTCIntersectFunctionN */84struct RTCIntersectFunctionNArguments85{86int* valid;87void* geometryUserPtr;88unsigned int primID;89struct RTCRayQueryContext* context;90struct RTCRayHitN* rayhit;91unsigned int N;92unsigned int geomID;93};9495/* Arguments for RTCOccludedFunctionN */96struct RTCOccludedFunctionNArguments97{98int* valid;99void* geometryUserPtr;100unsigned int primID;101struct RTCRayQueryContext* context;102struct RTCRayN* ray;103unsigned int N;104unsigned int geomID;105};106107/* Arguments for RTCDisplacementFunctionN */108struct RTCDisplacementFunctionNArguments109{110void* geometryUserPtr;111RTCGeometry geometry;112unsigned int primID;113unsigned int timeStep;114const float* u;115const float* v;116const float* Ng_x;117const float* Ng_y;118const float* Ng_z;119float* P_x;120float* P_y;121float* P_z;122unsigned int N;123};124125/* Displacement mapping callback function */126typedef void (*RTCDisplacementFunctionN)(const struct RTCDisplacementFunctionNArguments* args);127128/* Creates a new geometry of specified type. */129RTC_API RTCGeometry rtcNewGeometry(RTCDevice device, enum RTCGeometryType type);130131/* Retains the geometry (increments the reference count). */132RTC_API void rtcRetainGeometry(RTCGeometry geometry);133134/* Releases the geometry (decrements the reference count) */135RTC_API void rtcReleaseGeometry(RTCGeometry geometry);136137/* Commits the geometry. */138RTC_API void rtcCommitGeometry(RTCGeometry geometry);139140141/* Enables the geometry. */142RTC_API void rtcEnableGeometry(RTCGeometry geometry);143144/* Disables the geometry. */145RTC_API void rtcDisableGeometry(RTCGeometry geometry);146147148/* Sets the number of motion blur time steps of the geometry. */149RTC_API void rtcSetGeometryTimeStepCount(RTCGeometry geometry, unsigned int timeStepCount);150151/* Sets the motion blur time range of the geometry. */152RTC_API void rtcSetGeometryTimeRange(RTCGeometry geometry, float startTime, float endTime);153154/* Sets the number of vertex attributes of the geometry. */155RTC_API void rtcSetGeometryVertexAttributeCount(RTCGeometry geometry, unsigned int vertexAttributeCount);156157/* Sets the ray mask of the geometry. */158RTC_API void rtcSetGeometryMask(RTCGeometry geometry, unsigned int mask);159160/* Sets the build quality of the geometry. */161RTC_API void rtcSetGeometryBuildQuality(RTCGeometry geometry, enum RTCBuildQuality quality);162163/* Sets the maximal curve or point radius scale allowed by min-width feature. */164RTC_API void rtcSetGeometryMaxRadiusScale(RTCGeometry geometry, float maxRadiusScale);165166167/* Sets a geometry buffer. */168RTC_API void rtcSetGeometryBuffer(RTCGeometry geometry, enum RTCBufferType type, unsigned int slot, enum RTCFormat format, RTCBuffer buffer, size_t byteOffset, size_t byteStride, size_t itemCount);169170/* Sets a shared geometry buffer. */171RTC_API void rtcSetSharedGeometryBuffer(RTCGeometry geometry, enum RTCBufferType type, unsigned int slot, enum RTCFormat format, const void* ptr, size_t byteOffset, size_t byteStride, size_t itemCount);172173/* Sets a shared host/device geometry buffer pair. */174RTC_API void rtcSetSharedGeometryBufferHostDevice(RTCGeometry geometry, enum RTCBufferType bufferType, unsigned int slot, enum RTCFormat format, const void* ptr, const void* dptr, size_t byteOffset, size_t byteStride, size_t itemCount);175176/* Creates and sets a new geometry buffer. */177RTC_API void* rtcSetNewGeometryBuffer(RTCGeometry geometry, enum RTCBufferType type, unsigned int slot, enum RTCFormat format, size_t byteStride, size_t itemCount);178179/* Creates and sets a new host/device geometry buffer pair. */180RTC_API void rtcSetNewGeometryBufferHostDevice(RTCGeometry geometry, enum RTCBufferType bufferType, unsigned int slot, enum RTCFormat format, size_t byteStride, size_t itemCount, void** ptr, void** dptr);181182/* Returns the pointer to the data of a buffer. */183RTC_API void* rtcGetGeometryBufferData(RTCGeometry geometry, enum RTCBufferType type, unsigned int slot);184185/* Returns a pointer to the buffer data on the device. Returns the same pointer as186rtcGetGeometryBufferData if the device is no SYCL device or if Embree is executed on a187system with unified memory (e.g., iGPUs). */188RTC_API void* rtcGetGeometryBufferDataDevice(RTCGeometry geometry, enum RTCBufferType type, unsigned int slot);189190/* Updates a geometry buffer. */191RTC_API void rtcUpdateGeometryBuffer(RTCGeometry geometry, enum RTCBufferType type, unsigned int slot);192193/* Sets the intersection filter callback function of the geometry. */194RTC_API void rtcSetGeometryIntersectFilterFunction(RTCGeometry geometry, RTCFilterFunctionN filter);195196/* Sets the occlusion filter callback function of the geometry. */197RTC_API void rtcSetGeometryOccludedFilterFunction(RTCGeometry geometry, RTCFilterFunctionN filter);198199/* Enables argument version of intersection or occlusion filter function. */200RTC_API void rtcSetGeometryEnableFilterFunctionFromArguments(RTCGeometry geometry, bool enable);201202/* Sets the user-defined data pointer of the geometry. */203RTC_API void rtcSetGeometryUserData(RTCGeometry geometry, void* ptr);204205/* Gets the user-defined data pointer of the geometry. */206RTC_API void* rtcGetGeometryUserData(RTCGeometry geometry);207208/* Set the point query callback function of a geometry. */209RTC_API void rtcSetGeometryPointQueryFunction(RTCGeometry geometry, RTCPointQueryFunction pointQuery);210211/* Sets the number of primitives of a user geometry. */212RTC_API void rtcSetGeometryUserPrimitiveCount(RTCGeometry geometry, unsigned int userPrimitiveCount);213214/* Sets the bounding callback function to calculate bounding boxes for user primitives. */215RTC_API void rtcSetGeometryBoundsFunction(RTCGeometry geometry, RTCBoundsFunction bounds, void* userPtr);216217/* Set the intersect callback function of a user geometry. */218RTC_API void rtcSetGeometryIntersectFunction(RTCGeometry geometry, RTCIntersectFunctionN intersect);219220/* Set the occlusion callback function of a user geometry. */221RTC_API void rtcSetGeometryOccludedFunction(RTCGeometry geometry, RTCOccludedFunctionN occluded);222223/* Invokes the intersection filter from the intersection callback function. */224RTC_SYCL_API void rtcInvokeIntersectFilterFromGeometry(const struct RTCIntersectFunctionNArguments* args, const struct RTCFilterFunctionNArguments* filterArgs);225226/* Invokes the occlusion filter from the occlusion callback function. */227RTC_SYCL_API void rtcInvokeOccludedFilterFromGeometry(const struct RTCOccludedFunctionNArguments* args, const struct RTCFilterFunctionNArguments* filterArgs);228229/* Sets the instanced scene of an instance geometry. */230RTC_API void rtcSetGeometryInstancedScene(RTCGeometry geometry, RTCScene scene);231232/* Sets the instanced scenes of an instance array geometry. */233RTC_API void rtcSetGeometryInstancedScenes(RTCGeometry geometry, RTCScene* scenes, size_t numScenes);234235/* Sets the transformation of an instance for the specified time step. */236RTC_API void rtcSetGeometryTransform(RTCGeometry geometry, unsigned int timeStep, enum RTCFormat format, const void* xfm);237238/* Sets the transformation quaternion of an instance for the specified time step. */239RTC_API void rtcSetGeometryTransformQuaternion(RTCGeometry geometry, unsigned int timeStep, const struct RTCQuaternionDecomposition* qd);240241/* Returns the interpolated transformation of an instance for the specified time. */242RTC_API void rtcGetGeometryTransform(RTCGeometry geometry, float time, enum RTCFormat format, void* xfm);243244/*245* Returns the interpolated transformation of the instPrimID'th instance of an246* instance array for the specified time. If geometry is an regular instance,247* instPrimID must be 0.248*/249RTC_API void rtcGetGeometryTransformEx(RTCGeometry geometry, unsigned int instPrimID, float time, enum RTCFormat format, void* xfm);250251/* Sets the uniform tessellation rate of the geometry. */252RTC_API void rtcSetGeometryTessellationRate(RTCGeometry geometry, float tessellationRate);253254/* Sets the number of topologies of a subdivision surface. */255RTC_API void rtcSetGeometryTopologyCount(RTCGeometry geometry, unsigned int topologyCount);256257/* Sets the subdivision interpolation mode. */258RTC_API void rtcSetGeometrySubdivisionMode(RTCGeometry geometry, unsigned int topologyID, enum RTCSubdivisionMode mode);259260/* Binds a vertex attribute to a topology of the geometry. */261RTC_API void rtcSetGeometryVertexAttributeTopology(RTCGeometry geometry, unsigned int vertexAttributeID, unsigned int topologyID);262263/* Sets the displacement callback function of a subdivision surface. */264RTC_API void rtcSetGeometryDisplacementFunction(RTCGeometry geometry, RTCDisplacementFunctionN displacement);265266/* Returns the first half edge of a face. */267RTC_API unsigned int rtcGetGeometryFirstHalfEdge(RTCGeometry geometry, unsigned int faceID);268269/* Returns the face the half edge belongs to. */270RTC_API unsigned int rtcGetGeometryFace(RTCGeometry geometry, unsigned int edgeID);271272/* Returns next half edge. */273RTC_API unsigned int rtcGetGeometryNextHalfEdge(RTCGeometry geometry, unsigned int edgeID);274275/* Returns previous half edge. */276RTC_API unsigned int rtcGetGeometryPreviousHalfEdge(RTCGeometry geometry, unsigned int edgeID);277278/* Returns opposite half edge. */279RTC_API unsigned int rtcGetGeometryOppositeHalfEdge(RTCGeometry geometry, unsigned int topologyID, unsigned int edgeID);280281282/* Arguments for rtcInterpolate */283struct RTCInterpolateArguments284{285RTCGeometry geometry;286unsigned int primID;287float u;288float v;289enum RTCBufferType bufferType;290unsigned int bufferSlot;291float* P;292float* dPdu;293float* dPdv;294float* ddPdudu;295float* ddPdvdv;296float* ddPdudv;297unsigned int valueCount;298};299300/* Interpolates vertex data to some u/v location and optionally calculates all derivatives. */301RTC_API void rtcInterpolate(const struct RTCInterpolateArguments* args);302303/* Interpolates vertex data to some u/v location. */304RTC_FORCEINLINE void rtcInterpolate0(RTCGeometry geometry, unsigned int primID, float u, float v, enum RTCBufferType bufferType, unsigned int bufferSlot, float* P, unsigned int valueCount)305{306struct RTCInterpolateArguments args;307args.geometry = geometry;308args.primID = primID;309args.u = u;310args.v = v;311args.bufferType = bufferType;312args.bufferSlot = bufferSlot;313args.P = P;314args.dPdu = NULL;315args.dPdv = NULL;316args.ddPdudu = NULL;317args.ddPdvdv = NULL;318args.ddPdudv = NULL;319args.valueCount = valueCount;320rtcInterpolate(&args);321}322323/* Interpolates vertex data to some u/v location and calculates first order derivatives. */324RTC_FORCEINLINE void rtcInterpolate1(RTCGeometry geometry, unsigned int primID, float u, float v, enum RTCBufferType bufferType, unsigned int bufferSlot,325float* P, float* dPdu, float* dPdv, unsigned int valueCount)326{327struct RTCInterpolateArguments args;328args.geometry = geometry;329args.primID = primID;330args.u = u;331args.v = v;332args.bufferType = bufferType;333args.bufferSlot = bufferSlot;334args.P = P;335args.dPdu = dPdu;336args.dPdv = dPdv;337args.ddPdudu = NULL;338args.ddPdvdv = NULL;339args.ddPdudv = NULL;340args.valueCount = valueCount;341rtcInterpolate(&args);342}343344/* Interpolates vertex data to some u/v location and calculates first and second order derivatives. */345RTC_FORCEINLINE void rtcInterpolate2(RTCGeometry geometry, unsigned int primID, float u, float v, enum RTCBufferType bufferType, unsigned int bufferSlot,346float* P, float* dPdu, float* dPdv, float* ddPdudu, float* ddPdvdv, float* ddPdudv, unsigned int valueCount)347{348struct RTCInterpolateArguments args;349args.geometry = geometry;350args.primID = primID;351args.u = u;352args.v = v;353args.bufferType = bufferType;354args.bufferSlot = bufferSlot;355args.P = P;356args.dPdu = dPdu;357args.dPdv = dPdv;358args.ddPdudu = ddPdudu;359args.ddPdvdv = ddPdvdv;360args.ddPdudv = ddPdudv;361args.valueCount = valueCount;362rtcInterpolate(&args);363}364365/* Arguments for rtcInterpolateN */366struct RTCInterpolateNArguments367{368RTCGeometry geometry;369const void* valid;370const unsigned int* primIDs;371const float* u;372const float* v;373unsigned int N;374enum RTCBufferType bufferType;375unsigned int bufferSlot;376float* P;377float* dPdu;378float* dPdv;379float* ddPdudu;380float* ddPdvdv;381float* ddPdudv;382unsigned int valueCount;383};384385/* Interpolates vertex data to an array of u/v locations. */386RTC_API void rtcInterpolateN(const struct RTCInterpolateNArguments* args);387388/* RTCGrid primitive for grid mesh */389struct RTCGrid390{391unsigned int startVertexID;392unsigned int stride;393unsigned short width,height; // max is a 32k x 32k grid394};395396RTC_NAMESPACE_END397398399400401