Vegastrike 0.5.1 rc1
1.0
Original sources for Vegastrike Evolved
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
OPC_BaseModel.cpp
Go to the documentation of this file.
1
/*
3
* OPCODE - Optimized Collision Detection
4
* Copyright (C) 2001 Pierre Terdiman
5
* Homepage: http://www.codercorner.com/Opcode.htm
6
*/
8
10
16
19
27
30
// Precompiled Header
31
#include "
Stdafx.h
"
32
33
using namespace
Opcode;
34
36
39
OPCODECREATE::OPCODECREATE
()
41
{
42
mIMesh
=
null
;
43
mSettings
.
mRules
=
SPLIT_SPLATTER_POINTS
|
SPLIT_GEOM_CENTER
;
44
mSettings
.
mLimit
= 1;
// Mandatory for complete trees
45
mNoLeaf
=
true
;
46
mQuantized
=
true
;
47
#ifdef __MESHMERIZER_H__
48
mCollisionHull =
false
;
49
#endif // __MESHMERIZER_H__
50
mKeepOriginal
=
false
;
51
mCanRemap
=
false
;
52
}
53
55
58
BaseModel::BaseModel
() : mIMesh(
null
), mModelCode(0), mSource(
null
), mTree(
null
)
60
{
61
}
62
64
67
BaseModel::~BaseModel
()
69
{
70
ReleaseBase
();
71
}
72
74
77
void
BaseModel::ReleaseBase
()
79
{
80
DELETESINGLE
(
mSource
);
81
DELETESINGLE
(
mTree
);
82
}
83
85
91
bool
BaseModel::CreateTree
(
bool
no_leaf,
bool
quantized)
93
{
94
DELETESINGLE
(
mTree
);
95
96
// Setup model code
97
if
(no_leaf)
mModelCode
|=
OPC_NO_LEAF
;
98
else
mModelCode
&= ~
OPC_NO_LEAF
;
99
100
if
(quantized)
mModelCode
|=
OPC_QUANTIZED
;
101
else
mModelCode
&= ~
OPC_QUANTIZED
;
102
103
// Create the correct class
104
if
(
mModelCode
&
OPC_NO_LEAF
)
105
{
106
if
(
mModelCode
&
OPC_QUANTIZED
)
mTree
=
new
AABBQuantizedNoLeafTree
;
107
else
mTree
=
new
AABBNoLeafTree
;
108
}
109
else
110
{
111
if
(
mModelCode
&
OPC_QUANTIZED
)
mTree
=
new
AABBQuantizedTree
;
112
else
mTree
=
new
AABBCollisionTree
;
113
}
114
CHECKALLOC
(
mTree
);
115
116
return
true
;
117
}
118
120
126
bool
BaseModel::Refit
()
128
{
129
// Refit the optimized tree
130
return
mTree
->
Refit
(
mIMesh
);
131
132
// Old code kept for reference : refit the source tree then rebuild !
133
// if(!mSource) return false;
134
// // Ouch...
135
// mSource->Refit(&mTB);
136
// // Ouch...
137
// return mTree->Build(mSource);
138
}
src
cmd
collide2
OPC_BaseModel.cpp
Generated on Fri May 29 2015 23:07:12 for Vegastrike 0.5.1 rc1 by
1.8.4