Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 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 
41 {
42  mIMesh = null;
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 
69 {
70  ReleaseBase();
71 }
72 
74 
79 {
82 }
83 
85 
91 bool BaseModel::CreateTree(bool no_leaf, bool quantized)
93 {
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  {
107  else mTree = new AABBNoLeafTree;
108  }
109  else
110  {
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 }