Newton Dynamics  4.00
ndRayCastNotify.h
1 /* Copyright (c) <2003-2022> <Julio Jerez, Newton Game Dynamics>
2 *
3 * This software is provided 'as-is', without any express or implied
4 * warranty. In no event will the authors be held liable for any damages
5 * arising from the use of this software.
6 *
7 * Permission is granted to anyone to use this software for any purpose,
8 * including commercial applications, and to alter it and redistribute it
9 * freely, subject to the following restrictions:
10 *
11 * 1. The origin of this software must not be misrepresented; you must not
12 * claim that you wrote the original software. If you use this software
13 * in a product, an acknowledgment in the product documentation would be
14 * appreciated but is not required.
15 *
16 * 2. Altered source versions must be plainly marked as such, and must not be
17 * misrepresented as being the original software.
18 *
19 * 3. This notice may not be removed or altered from any source distribution.
20 */
21 
22 #ifndef __ND_RAYCAST_NOTYFY_H__
23 #define __ND_RAYCAST_NOTYFY_H__
24 
25 #include "ndCollisionStdafx.h"
26 #include "ndBody.h"
27 #include "ndContact.h"
28 
29 D_MSV_NEWTON_ALIGN_32
31 {
32  public:
34  :m_param(ndFloat32 (1.0f))
35  {
36  }
37 
38  virtual ~ndRayCastNotify()
39  {
40  }
41 
42  D_COLLISION_API bool TraceShape(const ndVector& globalOrigin, const ndVector& globalDestination, const ndShapeInstance& shapeInstance, const ndMatrix& shapeGlobal);
43 
44  virtual ndUnsigned32 OnRayPrecastAction(const ndBody* const, const ndShapeInstance* const)
45  {
46  return 1;
47  }
48 
49  virtual ndFloat32 OnRayCastAction(const ndContactPoint& contact, ndFloat32 intersetParam) = 0;
50 
51 
52  ndContactPoint m_contact;
53  ndFloat32 m_param;
54 } D_GCC_NEWTON_ALIGN_32;
55 
56 D_MSV_NEWTON_ALIGN_32
58 {
59  public:
62  {
63  }
64 
65  ndUnsigned32 OnRayPrecastAction(const ndBody* const body, const ndShapeInstance* const)
66  {
67  // do not let player capsule picking
68  return ndUnsigned32 (((ndBody*)body)->GetAsBodyPlayerCapsule() ? 0 : 1);
69  }
70 
71  ndFloat32 OnRayCastAction(const ndContactPoint& contact, ndFloat32 intersetParam)
72  {
73  if (intersetParam < m_param)
74  {
75  m_contact = contact;
76  m_param = intersetParam;
77  }
78  return intersetParam;
79  }
80 } D_GCC_NEWTON_ALIGN_32 ;
81 
82 
83 #endif
ndClassAlloc
Base class for providing memory allocation for all other engine classes.
Definition: ndClassAlloc.h:30
ndBody
Definition: ndBody.h:43
ndRayCastNotify
Definition: ndRayCastNotify.h:31
ndContactPoint
Definition: ndContact.h:39
ndMatrix
Definition: ndMatrix.h:42
ndRayCastClosestHitCallback
Definition: ndRayCastNotify.h:58
ndShapeInstance
Definition: ndShapeInstance.h:62
ndVector
Definition: ndVectorArmNeon.h:41