aboutsummaryrefslogtreecommitdiff
path: root/APEX_1.4/common/include/ApexCollision.h
blob: 45f1cf51e59778f0bb001456659f55ab55d33b4a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
 * Copyright (c) 2008-2017, NVIDIA CORPORATION.  All rights reserved.
 *
 * NVIDIA CORPORATION and its licensors retain all intellectual property
 * and proprietary rights in and to this software, related documentation
 * and any modifications thereto.  Any use, reproduction, disclosure or
 * distribution of this software and related documentation without an express
 * license agreement from NVIDIA CORPORATION is strictly prohibited.
 */


#ifndef APEX_COLLISION_H
#define APEX_COLLISION_H

#include "ApexDefs.h"

#include "ApexUsingNamespace.h"
#include "PxVec3.h"
#include "PxMat33.h"

namespace nvidia
{
namespace apex
{



struct Segment
{
	PxVec3 p0;
	PxVec3 p1;
};

struct Capsule : Segment
{
	float radius;
};

struct Triangle
{
	Triangle(const PxVec3& a, const PxVec3& b, const PxVec3& c) : v0(a), v1(b), v2(c) {}
	PxVec3 v0;
	PxVec3 v1;
	PxVec3 v2;
};

struct Box
{
	PxVec3	center;
	PxVec3	extents;
	PxMat33	rot;
};


bool capsuleCapsuleIntersection(const Capsule& worldCaps0, const Capsule& worldCaps1, float tolerance = 1.2);
bool boxBoxIntersection(const Box& worldBox0, const Box& worldBox1);

float APEX_pointTriangleSqrDst(const Triangle& triangle, const PxVec3& position);
float APEX_segmentSegmentSqrDist(const Segment& seg0, const Segment& seg1, float* s, float* t);
float APEX_pointSegmentSqrDist(const Segment& seg, const PxVec3& point, float* param = 0);
uint32_t APEX_RayCapsuleIntersect(const PxVec3& origin, const PxVec3& dir, const Capsule& capsule, float s[2]);

bool APEX_RayTriangleIntersect(const PxVec3& orig, const PxVec3& dir, const PxVec3& a, const PxVec3& b, const PxVec3& c, float& t, float& u, float& v);

} // namespace apex
} // namespace nvidia


#endif // APEX_COLLISION_H