source: GTP/trunk/App/Games/Jungle_Rumble/src/physic/physics/include/NxIntersectionSegmentCapsule.h @ 1378

Revision 1378, 2.4 KB checked in by giegl, 18 years ago (diff)

GTPD - Jungle Rumble - integrate into GTP SVN structure

Line 
1#ifndef NX_INTERSECTION_SEGMENT_CAPSULE
2#define NX_INTERSECTION_SEGMENT_CAPSULE
3/** \addtogroup physics
4  @{
5*/
6
7#include "Nxp.h"
8#include "NxCapsule.h"
9#include "NxSegment.h"
10#include "PhysXLoader.h"
11
12//namespace NxCollision {
13
14        /**
15        \brief Ray-capsule intersection test.
16       
17        Returns number of intersection points (0,1 or 2) and corresponding parameters along the ray.
18
19        \warning #NxCreatePhysicsSDK() must be called before using this function.
20
21        \param[in] origin Origin of ray. <b>Range:</b> position vector
22        \param[in] dir Direction of ray. <b>Range:</b> direction vector
23        \param[in] capsule Capsule to test. <b>Range:</b> see #NxCapsule
24        \param[out] t Parameter of intersection on the ray.
25
26        \return Number of intersection points.
27
28        <b>Platform:</b>
29        \li PC SW: Yes
30        \li PPU  : Yes
31        \li PS3  : Yes
32        \li XB360: Yes
33
34        @see NxRay NxCapsule
35        */
36        NX_INLINE NxU32 NX_CALL_CONV NxRayCapsuleIntersect(const NxVec3& origin, const NxVec3& dir,
37                const NxCapsule& capsule, NxReal t[2])
38                {
39                return NxGetUtilLib()->NxRayCapsuleIntersect(origin,dir,capsule,t);
40                }
41
42        /**
43        \brief Segment-capsule intersection test.
44       
45        Returns number of intersection points (0,1 or 2) and corresponding parameters along the ray.
46
47        \warning #NxCreatePhysicsSDK() must be called before using this function.
48
49        \param[in] segment Line segment. <b>Range:</b> See #NxSegment
50        \param[in] capsule Capsule to test. <b>Range:</b> See #NxCapsule
51        \param[out] nbImpacts Number of intersection point (0, 1 or 2)
52        \param[out] t Parameter of intersection on the ray.
53
54        <b>Platform:</b>
55        \li PC SW: Yes
56        \li PPU  : Yes
57        \li PS3  : Yes
58        \li XB360: Yes
59
60        @see NxSegement NxCapsule
61        */
62        NX_INLINE void NxSegmentCapsuleIntersect(const NxSegment& segment, const NxCapsule& capsule, NxU32* nbImpacts,
63                NxReal t[2])
64                {
65                NxReal s[2];
66                NxU32 numISec = NxRayCapsuleIntersect(segment.p0, segment.computeDirection(), capsule,s);
67
68                NxU32 numClip = 0;
69                for(NxU32 i = 0; i < numISec; i++)
70                        {
71                        if ( 0.0f <= s[i] && s[i] <= 1.0f ) t[numClip++] = s[i];
72                        }
73
74                *nbImpacts = numClip;
75                }
76//}
77
78/** @} */
79#endif
80
81
82//AGCOPYRIGHTBEGIN
83///////////////////////////////////////////////////////////////////////////
84// Copyright © 2005 AGEIA Technologies.
85// All rights reserved. www.ageia.com
86///////////////////////////////////////////////////////////////////////////
87//AGCOPYRIGHTEND
88
Note: See TracBrowser for help on using the repository browser.