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 {
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 }
void ReleaseBase()
bool mKeepOriginal
true => keep a copy of the original tree (debug purpose)
Definition: Opcode.h:37
#define null
our own NULL pointer
Definition: IceTypes.h:57
OPCODECREATE()
Constructor.
bool CreateTree(bool no_leaf, bool quantized)
bool mCanRemap
true => allows OPCODE to reorganize client arrays
Definition: Opcode.h:38
Leaf/NoLeaf tree.
Definition: OPC_BaseModel.h:46
bool mQuantized
true => quantize the tree (else use a normal tree)
Definition: Opcode.h:33
Splatter primitive centers (QuickCD-style)
Definition: Opcode.h:29
udword mRules
Building/Splitting rules (a combination of SplittingRules flags)
Definition: Opcode.h:45
virtual bool Refit()
#define DELETESINGLE(x)
Deletes an instance of a class.
#define CHECKALLOC(x)
Compressed/uncompressed tree.
Definition: OPC_BaseModel.h:45
bool mNoLeaf
true => discard leaf nodes (else use a normal tree)
Definition: Opcode.h:32
Split at geometric center (else split in the middle)
Definition: Opcode.h:34
virtual ~BaseModel()
udword mLimit
Limit number of primitives / node. If limit is 1, build a complete tree (2*N-1 nodes) ...
Definition: Opcode.h:44
MeshInterface * mIMesh
Mesh interface (access to triangles & vertices) (*)
Definition: Opcode.h:30
BuildSettings mSettings
Builder's settings.
Definition: Opcode.h:31


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Sat May 8 2021 02:42:39