ScummVM API documentation
dgCollisionUserMesh.h
1 /* Copyright (c) <2003-2011> <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 __DGCOLLIIO_USERMESH__
23 #define __DGCOLLIIO_USERMESH__
24 
25 #include "dgCollision.h"
26 #include "dgCollisionMesh.h"
27 
28 
29 typedef void (dgApi *OnUserMeshDestroyCallback)(void *const userData);
30 typedef void(dgApi *OnUserMeshCollideCallback)(NewtonUserMeshCollisionCollideDesc *const collideDescData);
31 typedef dgFloat32(dgApi *OnUserMeshRayHitCallback)(NewtonUserMeshCollisionRayHitDesc *const lineDescData);
32 typedef void (dgApi *UserMeshCollisionInfo)(void *userData, dgCollisionInfo *infoRecord);
33 typedef void(dgApi *UserMeshFacesInAABB)(void *const userData, const dFloat *const p0, const dFloat *const p1,
34  const dFloat *const *const vertexArray, int32 *const vertexCount, int32 *const vertexStrideInBytes,
35  const int32 *const indexList, int32 maxIndexCount, const int32 *const userDataList);
36 
38 public:
39  void *m_userData;
40  OnUserMeshCollideCallback m_collideCallback;
41  OnUserMeshRayHitCallback m_rayHitCallBack;
42  OnUserMeshDestroyCallback m_destroyCallback;
43  UserMeshCollisionInfo m_getInfo;
44  UserMeshFacesInAABB m_faceInAabb;
45 };
46 
47 
49 public:
50  dgCollisionUserMesh(dgMemoryAllocator *allocator, const dgVector &boxP0, const dgVector &boxP1, const dgUserMeshCreation &data);
51  dgCollisionUserMesh(dgWorld *const world, dgDeserialize deserialization, void *const userData);
52  virtual ~dgCollisionUserMesh(void);
53 
54  void GetVertexListIndexList(const dgVector &p0, const dgVector &p1, dgGetVertexListIndexList &data) const;
55 
56 private:
57  void Serialize(dgSerialize callback, void *const userData) const;
58  virtual void GetCollisionInfo(dgCollisionInfo *info) const;
59  virtual dgFloat32 RayCast(const dgVector &localP0, const dgVector &localP1, dgContactPoint &contactOut, OnRayPrecastAction preFilter, const dgBody *const body, void *const userData) const;
60  virtual dgFloat32 RayCastSimd(const dgVector &localP0, const dgVector &localP1, dgContactPoint &contactOut, OnRayPrecastAction preFilter, const dgBody *const body, void *const userData) const;
61  virtual void GetCollidingFaces(dgPolygonMeshDesc *const data) const;
62  virtual void GetCollidingFacesSimd(dgPolygonMeshDesc *const data) const;
63  void DebugCollision(const dgMatrix &matrixPtr, OnDebugCollisionMeshCallback callback, void *const userData) const;
64 
65  void *m_userData;
66  UserMeshCollisionInfo m_getInfo;
67  UserMeshFacesInAABB m_faceInAabb;
68  OnUserMeshRayHitCallback m_rayHitCallBack;
69  OnUserMeshCollideCallback m_collideCallback;
70  OnUserMeshDestroyCallback m_destroyCallback;
71 };
72 
73 
74 #endif
Definition: dgCollision.h:73
Definition: dgBody.h:85
Definition: dgCollisionUserMesh.h:37
Definition: dgCollisionMesh.h:39
Definition: dgVector.h:86
Definition: dgContact.h:88
Definition: dgCollisionMesh.h:101
Definition: Newton.h:218
Definition: dgCollisionMesh.h:90
Definition: dgCollisionUserMesh.h:48
Definition: dgMatrix.h:41
Definition: dgMemory.h:80
Definition: dgWorld.h:118
Definition: Newton.h:243