1
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
3
* OPCODE - Optimized Collision Detection
4
* Copyright (C) 2001 Pierre Terdiman
5
* Homepage: http://www.codercorner.com/Opcode.htm
7
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
9
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
11
* Contains code for hybrid models.
12
* \file OPC_HybridModel.h
13
* \author Pierre Terdiman
16
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
18
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
20
#ifndef __OPC_HYBRIDMODEL_H__
21
#define __OPC_HYBRIDMODEL_H__
26
udword Data; //!< Packed data
28
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
30
* Gets number of triangles in the leaf.
31
* \return number of triangles N, with 0 < N <= 16
33
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
34
inline_ udword GetNbTriangles() const { return (Data & 15)+1; }
36
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
38
* Gets triangle index for this leaf. Indexed model's array of indices retrieved with HybridModel::GetIndices()
39
* \return triangle index
41
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
42
inline_ udword GetTriangleIndex() const { return Data>>4; }
43
inline_ void SetData(udword nb, udword index) { ASSERT(nb>0 && nb<=16); nb--; Data = (index<<4)|(nb&15); }
46
class HybridModel : public BaseModel
49
// Constructor/Destructor
51
virtual ~HybridModel();
53
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
55
* Builds a collision model.
56
* \param create [in] model creation structure
57
* \return true if success
59
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
60
override(BaseModel) bool Build(const OPCODECREATE& create);
62
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
64
* Gets the number of bytes used by the tree.
65
* \return amount of bytes used
67
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
68
override(BaseModel) udword GetUsedBytes() const;
70
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
72
* Refits the collision model. This can be used to handle dynamic meshes. Usage is:
73
* 1. modify your mesh vertices (keep the topology constant!)
74
* 2. refit the tree (call this method)
75
* \return true if success
77
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
78
override(BaseModel) bool Refit();
80
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
82
* Gets array of triangles.
83
* \return array of triangles
85
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
86
inline_ const LeafTriangles* GetLeafTriangles() const { return mTriangles; }
88
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
90
* Gets array of indices.
91
* \return array of indices
93
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
94
inline_ const udword* GetIndices() const { return mIndices; }
97
udword mNbLeaves; //!< Number of leaf nodes in the model
98
LeafTriangles* mTriangles; //!< Array of mNbLeaves leaf descriptors
99
udword mNbPrimitives; //!< Number of primitives in the model
100
udword* mIndices; //!< Array of primitive indices
106
#endif // __OPC_HYBRIDMODEL_H__