My Project: dynamics.mod/NewtonDynamics/source/physics/dgCollisionUserMesh.h Source File

My Project

dgCollisionUserMesh.h
Go to the documentation of this file.
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 __DGCOLLISION_USERMESH__
23 #define __DGCOLLISION_USERMESH__
24
25 #include "dgCollision.h"
26 #include "dgCollisionMesh.h"
27
28
29
30 class dgCollisionUserMesh: public dgCollisionMesh
31 {
32 public:
33 typedef void (dgApi *OnUserMeshDestroyCallback) (void* const userData);
34 typedef dgFloat32 (dgApi *OnUserMeshRayHitCallback) (dgCollisionMeshRayHitDesc& rayHitdata);
35 typedef void (dgApi *OnUserMeshCollisionInfo) (void* userData, dgCollisionInfo* infoRecord);
36 typedef void (dgApi *OnUserMeshCollideCallback) (void* const collideData, const void* const continueHandle);
37 typedef dgInt32 (dgApi *OnUserMeshAABBOverlapTest) (void* const userData, const dgVector& boxP0, const dgVector& boxP1);
38 typedef void (dgApi *OnUserMeshSerialize) (void* const userSerializeData, dgSerialize function, void* const serilalizeObject);
39 typedef void (dgApi *OnUserMeshFacesInAABB) (void* userData, const dgFloat32* p0, const dgFloat32* p1, const dgFloat32** vertexArray, dgInt32* vertexCount, dgInt32* vertexStrideInBytes, const dgInt32* indexList, dgInt32 maxIndexCount, const dgInt32* faceAttribute);
40
41 dgCollisionUserMesh(dgWorld* const world, const dgVector& boxP0, const dgVector& boxP1, const dgUserMeshCreation& data);
42 dgCollisionUserMesh (dgWorld* const world, dgDeserialize deserialization, void* const userData);
43 virtual ~dgCollisionUserMesh(void);
44
45 void GetVertexListIndexList (const dgVector& p0, const dgVector& p1, dgMeshVertexListIndexList &data) const;
46
47 bool AABBOvelapTest (const dgVector& boxP0, const dgVector& boxP1) const;
48
49 private:
50 void Serialize(dgSerialize callback, void* const userData) const;
51
52 dgVector SupportVertex (const dgVector& dir) const;
53
54 virtual void GetCollisionInfo(dgCollisionInfo* const info) const;
55 virtual dgFloat32 RayCast (const dgVector& localP0, const dgVector& localP1, dgFloat32 maxT, dgContactPoint& contactOut, const dgBody* const body, void* const userData, OnRayPrecastAction preFilter) const;
56 virtual void GetCollidingFaces (dgPolygonMeshDesc* const data) const;
57 virtual void DebugCollision (const dgMatrix& matrixPtr, dgCollision::OnDebugCollisionMeshCallback callback, void* const userData) const;
58
59 void* m_userData;
60 OnUserMeshSerialize m_serializeCallback;
61 OnUserMeshCollisionInfo m_getInfoCallback;
62 OnUserMeshFacesInAABB m_faceInAABBCalback;
63 OnUserMeshRayHitCallback m_rayHitCallback;
64 OnUserMeshCollideCallback m_collideCallback;
65 OnUserMeshDestroyCallback m_destroyCallback;
66 OnUserMeshAABBOverlapTest m_getAABBOvelapTestCallback;
67 };
68
69 class dgUserMeshCreation
70 {
71 public:
72 void* m_userData;
73 dgCollisionUserMesh::OnUserMeshSerialize m_serializeCallback;
74 dgCollisionUserMesh::OnUserMeshCollideCallback m_collideCallback;
75 dgCollisionUserMesh::OnUserMeshRayHitCallback m_rayHitCallback;
76 dgCollisionUserMesh::OnUserMeshDestroyCallback m_destroyCallback;
77 dgCollisionUserMesh::OnUserMeshCollisionInfo m_getInfoCallback;
78 dgCollisionUserMesh::OnUserMeshFacesInAABB m_faceInAABBCallback;
79 dgCollisionUserMesh::OnUserMeshAABBOverlapTest m_getAABBOvelapTestCallback;
80 };
81
82
83 #endif
dgApi
#define dgApi
Definition: dgTypes.h:263
dgCollisionUserMesh::OnUserMeshFacesInAABB
void(dgApi * OnUserMeshFacesInAABB)(void *userData, const dgFloat32 *p0, const dgFloat32 *p1, const dgFloat32 **vertexArray, dgInt32 *vertexCount, dgInt32 *vertexStrideInBytes, const dgInt32 *indexList, dgInt32 maxIndexCount, const dgInt32 *faceAttribute)
Definition: dgCollisionUserMesh.h:39
dgCollisionUserMesh::OnUserMeshAABBOverlapTest
dgInt32(dgApi * OnUserMeshAABBOverlapTest)(void *const userData, const dgVector &boxP0, const dgVector &boxP1)
Definition: dgCollisionUserMesh.h:37
dgUserMeshCreation::m_serializeCallback
dgCollisionUserMesh::OnUserMeshSerialize m_serializeCallback
Definition: dgCollisionUserMesh.h:73
dgUserMeshCreation::m_destroyCallback
dgCollisionUserMesh::OnUserMeshDestroyCallback m_destroyCallback
Definition: dgCollisionUserMesh.h:76
dgUserMeshCreation::m_getAABBOvelapTestCallback
dgCollisionUserMesh::OnUserMeshAABBOverlapTest m_getAABBOvelapTestCallback
Definition: dgCollisionUserMesh.h:79
dgCollision::OnDebugCollisionMeshCallback
void(dgApi * OnDebugCollisionMeshCallback)(void *userData, int vertexCount, const dgFloat32 *FaceArray, int faceId)
Definition: dgCollision.h:220
dgCollisionInfo
Definition: dgCollision.h:82
dgBody
Definition: dgBody.h:44
dgCollisionUserMesh::dgCollisionUserMesh
dgCollisionUserMesh(dgWorld *const world, const dgVector &boxP0, const dgVector &boxP1, const dgUserMeshCreation &data)
Definition: dgCollisionUserMesh.cpp:28
userData
void *const userData
Definition: dgBroadPhase.h:35
dgFloat32
float dgFloat32
Definition: dgTypes.h:233
dgInt32
int dgInt32
Definition: dgTypes.h:218
dgUserMeshCreation
Definition: dgCollisionUserMesh.h:69
void
typedef void(dgApi *ConstraintsForceFeeback)(const dgConstraint &me
dgPolygonMeshDesc
Definition: dgCollisionMesh.h:42
dgVector
Definition: dgVector.h:639
dgCollisionUserMesh::~dgCollisionUserMesh
virtual ~dgCollisionUserMesh(void)
Definition: dgCollisionUserMesh.cpp:61
dgCollisionUserMesh::OnUserMeshRayHitCallback
dgFloat32(dgApi * OnUserMeshRayHitCallback)(dgCollisionMeshRayHitDesc &rayHitdata)
Definition: dgCollisionUserMesh.h:34
dgUserMeshCreation::m_collideCallback
dgCollisionUserMesh::OnUserMeshCollideCallback m_collideCallback
Definition: dgCollisionUserMesh.h:74
dgCollisionUserMesh::OnUserMeshSerialize
void(dgApi * OnUserMeshSerialize)(void *const userSerializeData, dgSerialize function, void *const serilalizeObject)
Definition: dgCollisionUserMesh.h:38
dgContactPoint
Definition: dgContact.h:78
dgCollisionUserMesh::OnUserMeshDestroyCallback
void(dgApi * OnUserMeshDestroyCallback)(void *const userData)
Definition: dgCollisionUserMesh.h:33
dgCollisionUserMesh::OnUserMeshCollisionInfo
void(dgApi * OnUserMeshCollisionInfo)(void *userData, dgCollisionInfo *infoRecord)
Definition: dgCollisionUserMesh.h:35
dgSerialize
void(dgApi * dgSerialize)(void *const userData, const void *const buffer, size_t size)
Definition: dgTypes.h:280
dgDeserialize
void(dgApi * dgDeserialize)(void *const userData, void *buffer, size_t size)
Definition: dgTypes.h:279
dgCollisionMeshRayHitDesc
Definition: dgCollisionMesh.h:128
dgCollisionMesh.h
OnRayPrecastAction
dgUnsigned32(dgApi * OnRayPrecastAction)(const dgBody *const body, const dgCollisionInstance *const collision, void *const userData)
Definition: dgBroadPhase.h:36
dgCollisionMesh
Definition: dgCollisionMesh.h:147
dgUserMeshCreation::m_userData
void * m_userData
Definition: dgCollisionUserMesh.h:72
dgCollisionUserMesh::AABBOvelapTest
bool AABBOvelapTest(const dgVector &boxP0, const dgVector &boxP1) const
Definition: dgCollisionUserMesh.cpp:96
dgUserMeshCreation::m_faceInAABBCallback
dgCollisionUserMesh::OnUserMeshFacesInAABB m_faceInAABBCallback
Definition: dgCollisionUserMesh.h:78
dgCollision.h
dgCollisionMesh::dgMeshVertexListIndexList
Definition: dgCollisionMesh.h:152
dgCollisionUserMesh
Definition: dgCollisionUserMesh.h:30
dgMatrix
Definition: dgMatrix.h:40
dgCollisionUserMesh::OnUserMeshCollideCallback
void(dgApi * OnUserMeshCollideCallback)(void *const collideData, const void *const continueHandle)
Definition: dgCollisionUserMesh.h:36
dgUserMeshCreation::m_getInfoCallback
dgCollisionUserMesh::OnUserMeshCollisionInfo m_getInfoCallback
Definition: dgCollisionUserMesh.h:77
dgWorld
Definition: dgWorld.h:129
dgCollisionUserMesh::GetVertexListIndexList
void GetVertexListIndexList(const dgVector &p0, const dgVector &p1, dgMeshVertexListIndexList &data) const
Definition: dgCollisionUserMesh.cpp:77
dgUserMeshCreation::m_rayHitCallback
dgCollisionUserMesh::OnUserMeshRayHitCallback m_rayHitCallback
Definition: dgCollisionUserMesh.h:75