Start raycast implementation

This commit is contained in:
bloeys
2022-02-16 08:17:49 +04:00
parent d118b82ce6
commit d143660a1f
5 changed files with 65 additions and 0 deletions

View File

@ -3,11 +3,39 @@
#include "CPxPvdSceneClient.h"
#include "CPxActor.h"
#include "CPxVec3.h"
#include "CPxShape.h"
#include "CPxRigidActor.h"
#ifdef __cplusplus
extern "C" {
#endif
struct CPxRaycastHit
{
//CPxHitFlags flags; //!< Hit flags specifying which members contain valid values.
struct CPxVec3 position; //!< World-space hit position (flag: #PxHitFlag::ePOSITION)
struct CPxVec3 normal; //!< World-space hit normal (flag: #PxHitFlag::eNORMAL)
/**
\brief Distance to hit.
\note If the eMTD flag is used, distance will be a negative value if shapes are overlapping indicating the penetration depth.
\note Otherwise, this value will be >= 0 */
CPxF32 distance;
CPxReal u, v;
CPxU32 faceIndex;
struct CPxShape shape;
struct CPxRigidActor actor;
};
struct CPxRaycastBuffer
{
struct CPxRaycastHit block;
struct CPxRaycastHit* touches;
CPxU32 nbTouches;
bool hasBlock;
};
struct CPxScene
{
void* obj;
@ -22,6 +50,7 @@ extern "C" {
CPxAPI bool CPxScene_fetchCollision(CSTRUCT CPxScene*, bool block);
CPxAPI void CPxScene_advance(CSTRUCT CPxScene*);
CPxAPI bool CPxScene_fetchResults(CSTRUCT CPxScene*, bool block, CPxU32* errorState);
CPxAPI bool CPxScene_raycast(CSTRUCT CPxScene* cs, CSTRUCT CPxVec3* origin, CSTRUCT CPxVec3* unitDir, CPxReal distance, CSTRUCT CPxRaycastBuffer** hitRet);
/// <summary>
/// Creates a scratch buffer thats a multiple of 16K to be used by the scene when running CPxScene_simulate.